obsidian-mcp-server 3.5.5 → 3.6.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 (50) hide show
  1. package/AGENTS.md +4 -2
  2. package/CLAUDE.md +4 -2
  3. package/README.md +8 -8
  4. package/changelog/3.6.x/3.6.0.md +31 -0
  5. package/dist/mcp-server/tools/definitions/_shared/schemas.d.ts.map +1 -1
  6. package/dist/mcp-server/tools/definitions/_shared/schemas.js +1 -1
  7. package/dist/mcp-server/tools/definitions/_shared/schemas.js.map +1 -1
  8. package/dist/mcp-server/tools/definitions/index.d.ts +36 -0
  9. package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -1
  10. package/dist/mcp-server/tools/definitions/obsidian-append-to-note.tool.d.ts +12 -0
  11. package/dist/mcp-server/tools/definitions/obsidian-append-to-note.tool.d.ts.map +1 -1
  12. package/dist/mcp-server/tools/definitions/obsidian-append-to-note.tool.js +15 -2
  13. package/dist/mcp-server/tools/definitions/obsidian-append-to-note.tool.js.map +1 -1
  14. package/dist/mcp-server/tools/definitions/obsidian-manage-tags.tool.d.ts +3 -2
  15. package/dist/mcp-server/tools/definitions/obsidian-manage-tags.tool.d.ts.map +1 -1
  16. package/dist/mcp-server/tools/definitions/obsidian-manage-tags.tool.js +4 -3
  17. package/dist/mcp-server/tools/definitions/obsidian-manage-tags.tool.js.map +1 -1
  18. package/dist/mcp-server/tools/definitions/obsidian-patch-note.tool.d.ts +15 -2
  19. package/dist/mcp-server/tools/definitions/obsidian-patch-note.tool.d.ts.map +1 -1
  20. package/dist/mcp-server/tools/definitions/obsidian-patch-note.tool.js +18 -4
  21. package/dist/mcp-server/tools/definitions/obsidian-patch-note.tool.js.map +1 -1
  22. package/dist/mcp-server/tools/definitions/obsidian-write-note.tool.d.ts +12 -0
  23. package/dist/mcp-server/tools/definitions/obsidian-write-note.tool.d.ts.map +1 -1
  24. package/dist/mcp-server/tools/definitions/obsidian-write-note.tool.js +23 -10
  25. package/dist/mcp-server/tools/definitions/obsidian-write-note.tool.js.map +1 -1
  26. package/dist/services/obsidian/frontmatter-ops.d.ts +4 -3
  27. package/dist/services/obsidian/frontmatter-ops.d.ts.map +1 -1
  28. package/dist/services/obsidian/frontmatter-ops.js +379 -114
  29. package/dist/services/obsidian/frontmatter-ops.js.map +1 -1
  30. package/dist/services/obsidian/markdown-blocks.d.ts +39 -0
  31. package/dist/services/obsidian/markdown-blocks.d.ts.map +1 -0
  32. package/dist/services/obsidian/markdown-blocks.js +611 -0
  33. package/dist/services/obsidian/markdown-blocks.js.map +1 -0
  34. package/dist/services/obsidian/obsidian-service.d.ts +9 -7
  35. package/dist/services/obsidian/obsidian-service.d.ts.map +1 -1
  36. package/dist/services/obsidian/obsidian-service.js +308 -111
  37. package/dist/services/obsidian/obsidian-service.js.map +1 -1
  38. package/dist/services/obsidian/patch-instruction.d.ts +141 -0
  39. package/dist/services/obsidian/patch-instruction.d.ts.map +1 -0
  40. package/dist/services/obsidian/patch-instruction.js +217 -0
  41. package/dist/services/obsidian/patch-instruction.js.map +1 -0
  42. package/dist/services/obsidian/section-extractor.d.ts +97 -24
  43. package/dist/services/obsidian/section-extractor.d.ts.map +1 -1
  44. package/dist/services/obsidian/section-extractor.js +295 -58
  45. package/dist/services/obsidian/section-extractor.js.map +1 -1
  46. package/dist/services/obsidian/types.d.ts +12 -5
  47. package/dist/services/obsidian/types.d.ts.map +1 -1
  48. package/manifest.json +1 -1
  49. package/package.json +2 -1
  50. package/server.json +3 -3
@@ -0,0 +1,611 @@
1
+ /**
2
+ * @fileoverview Block structure of a note body, reduced to what inline tag
3
+ * detection needs: the lines where Obsidian reads no tag — fenced and indented
4
+ * code, HTML blocks, display math — and the ranges that hold inline content —
5
+ * paragraphs, headings, table rows. Blockquotes and list items are tracked so
6
+ * indentation is measured from where a line's content starts. The rules follow
7
+ * CommonMark except where Obsidian 1.13.7's metadata-cache readback differs;
8
+ * each difference is noted where it is implemented. Issues #139 and #140.
9
+ * @module services/obsidian/markdown-blocks
10
+ */
11
+ function ruleSuffix({ text, last }) {
12
+ const char = text[last] ?? '';
13
+ let from = last + 1;
14
+ if (char === '*' || char === '-' || char === '_') {
15
+ while (from > 0 &&
16
+ (text[from - 1] === char || text[from - 1] === ' ' || text[from - 1] === '\t')) {
17
+ from--;
18
+ }
19
+ }
20
+ const counts = new Uint32Array(last + 2 - from);
21
+ for (let i = last; i >= from; i--) {
22
+ counts[i - from] = (counts[i - from + 1] ?? 0) + (text[i] === char ? 1 : 0);
23
+ }
24
+ return { char, counts, from };
25
+ }
26
+ /**
27
+ * A position in one line. Columns count from the content start of the
28
+ * innermost blockquote, and a tab advances to the next multiple of four. A list
29
+ * item's indent can end partway through a tab; the columns of that tab it did
30
+ * not take are `spare`, read as spaces by whatever comes next.
31
+ */
32
+ class LineCursor {
33
+ line;
34
+ pos = 0;
35
+ col = 0;
36
+ spare = 0;
37
+ constructor(line) {
38
+ this.line = line;
39
+ }
40
+ static start(text) {
41
+ let last = text.length - 1;
42
+ while (last >= 0 && (text[last] === ' ' || text[last] === '\t' || text[last] === '\r'))
43
+ last--;
44
+ return new LineCursor({ text, last });
45
+ }
46
+ get text() {
47
+ return this.line.text;
48
+ }
49
+ clone() {
50
+ const c = new LineCursor(this.line);
51
+ c.pos = this.pos;
52
+ c.col = this.col;
53
+ c.spare = this.spare;
54
+ return c;
55
+ }
56
+ /** Whether only whitespace is left on the line. */
57
+ get atEnd() {
58
+ return this.pos > this.line.last;
59
+ }
60
+ /**
61
+ * Whether the rest of the line from `pos` is a thematic break: three or more
62
+ * of one of `*`, `-`, `_`, with only spaces and tabs between. A line of
63
+ * nested list markers asks this once per marker, so the answer comes from
64
+ * one backward pass per line rather than a regex run to the end each time.
65
+ */
66
+ thematicBreakAt(pos) {
67
+ this.line.rule ??= ruleSuffix(this.line);
68
+ const { from, char, counts } = this.line.rule;
69
+ return pos >= from && this.text[pos] === char && (counts[pos - from] ?? 0) >= 3;
70
+ }
71
+ /** Width of the whitespace ahead, counted no further than `limit` columns. */
72
+ columns(limit = Number.POSITIVE_INFINITY) {
73
+ let n = this.spare;
74
+ let col = this.col + this.spare;
75
+ for (let i = this.pos; n < limit; i++) {
76
+ const ch = this.text[i];
77
+ if (ch === ' ') {
78
+ n++;
79
+ col++;
80
+ }
81
+ else if (ch === '\t') {
82
+ const w = 4 - (col % 4);
83
+ n += w;
84
+ col += w;
85
+ }
86
+ else
87
+ break;
88
+ }
89
+ return n;
90
+ }
91
+ /** Consume exactly `cols` columns of whitespace. When fewer are there, consumes nothing and returns false. */
92
+ take(cols) {
93
+ const { pos, col, spare } = this;
94
+ let left = cols;
95
+ while (left > 0) {
96
+ if (this.spare > 0) {
97
+ const t = Math.min(this.spare, left);
98
+ this.spare -= t;
99
+ this.col += t;
100
+ left -= t;
101
+ continue;
102
+ }
103
+ const ch = this.text[this.pos];
104
+ if (ch === ' ') {
105
+ this.pos++;
106
+ this.col++;
107
+ left--;
108
+ }
109
+ else if (ch === '\t') {
110
+ const t = Math.min(4 - (this.col % 4), left);
111
+ this.spare = 4 - (this.col % 4) - t;
112
+ this.pos++;
113
+ this.col += t;
114
+ left -= t;
115
+ }
116
+ else {
117
+ this.pos = pos;
118
+ this.col = col;
119
+ this.spare = spare;
120
+ return false;
121
+ }
122
+ }
123
+ return true;
124
+ }
125
+ skipWhitespace() {
126
+ this.take(this.columns());
127
+ }
128
+ }
129
+ const ATX_HEADING = /#{1,6}(?:[ \t]|\r?$)/y;
130
+ const LIST_MARKER = /(?:[-+*]|(?<start>\d{1,9})[.)])(?=[ \t]|\r?$)/y;
131
+ /** A backtick fence's info string cannot hold a backtick — ```` ``` a`b ```` is inline code. */
132
+ const FENCE_OPEN = /`{3,}(?=[^`]*$)|~{3,}/y;
133
+ const FENCE_CLOSE = /(`{3,}|~{3,})[ \t]*\r?$/y;
134
+ const MATH_CLOSE = /[ \t]*\$\$[ \t]*\r?$/y;
135
+ const SETEXT_UNDERLINE = /(?:=+|-+)[ \t]*\r?$/y;
136
+ const LINK_DEFINITION = /\[[^[\]]+\]:/y;
137
+ /** Obsidian's blank line: empty or spaces only. A line holding a tab continues an open paragraph or HTML block. */
138
+ const BLANK = / *\r?$/y;
139
+ /** A table delimiter row after its optional leading pipe: `-|-`, `:--|--:|`. */
140
+ const DELIMITER_ROW = /[ \t]*:?-+:?(?:[ \t]*\|[ \t]*:?-+:?)*(?:[ \t]*\|)?[ \t]*\r?$/y;
141
+ /**
142
+ * CommonMark's open tag and closing tag (raw HTML): a tag name, attributes —
143
+ * each a name and an optional `=` value, unquoted, single-quoted, or
144
+ * double-quoted — and an optional `/` before `>`; a closing tag takes no
145
+ * attributes. Whitespace between the parts may hold one line ending and a
146
+ * quoted value any number, which only an inline tag can use: a block start is
147
+ * matched one line at a time. Obsidian 1.13.7 reads both uses by this grammar
148
+ * — `x <a b #t> y` and `x </a #t> y` are plain text around a tag, while
149
+ * `<a\nb="c">#t` is an element followed by one. Issue #144.
150
+ */
151
+ export const HTML_TAG_SOURCE = (() => {
152
+ const ws = String.raw `[ \t]*(?:\r?\n[ \t]*)?`;
153
+ const value = String.raw `[^ \t\r\n"'=<>\x60]+|'[^']*'|"[^"]*"`;
154
+ const attribute = String.raw `(?=[ \t]|\r?\n)${ws}[A-Za-z_:][\w.:-]*(?:${ws}=${ws}(?:${value}))?`;
155
+ const name = '[A-Za-z][A-Za-z0-9-]*';
156
+ return String.raw `<${name}(?:${attribute})*${ws}\/?>|<\/${name}${ws}>`;
157
+ })();
158
+ /**
159
+ * CommonMark's seven HTML block starts, in order: the start pattern, the
160
+ * pattern whose line ends the block (none: a blank line ends it), and whether
161
+ * the block can interrupt a paragraph. Read back from Obsidian: `<div>`,
162
+ * `<p>`, `<pre>`, a lone `<span>`, `<?…?>`, `<!DOCTYPE`, and `<![CDATA[`
163
+ * blocks all hide their tags, while `<span>x #t</span>` is a paragraph.
164
+ */
165
+ const HTML_BLOCKS = [
166
+ [/<(?:pre|script|style|textarea)(?=[ \t>]|\r?$)/iy, /<\/(?:pre|script|style|textarea)>/gi, true],
167
+ [/<!--/y, /-->/g, true],
168
+ [/<\?/y, /\?>/g, true],
169
+ [/<![A-Za-z]/y, />/g, true],
170
+ [/<!\[CDATA\[/y, /\]\]>/g, true],
171
+ [
172
+ /<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?=[ \t]|\/?>|\r?$)/iy,
173
+ undefined,
174
+ true,
175
+ ],
176
+ [new RegExp(String.raw `(?:${HTML_TAG_SOURCE})[ \t]*\r?$`, 'y'), undefined, false],
177
+ ];
178
+ function sticky(re, text, pos) {
179
+ re.lastIndex = pos;
180
+ return re.exec(text);
181
+ }
182
+ /** Whether `close` occurs in `text` at or after `from`. */
183
+ function closes(close, text, from) {
184
+ close.lastIndex = from;
185
+ return close.test(text);
186
+ }
187
+ /** The HTML block opening at `pos`, if any: the pattern that ends it, or `undefined` when a blank line does. */
188
+ function htmlBlockAt(text, pos, paragraphOpen) {
189
+ if (text[pos] !== '<')
190
+ return;
191
+ for (const [open, close, interruptsParagraph] of HTML_BLOCKS) {
192
+ if (paragraphOpen && !interruptsParagraph)
193
+ continue;
194
+ if (sticky(open, text, pos))
195
+ return { close };
196
+ }
197
+ return;
198
+ }
199
+ /** A display math block opens with `$$` on a line that holds no second `$$`. */
200
+ function mathOpensAt(text, pos) {
201
+ return text.startsWith('$$', pos) && !text.includes('$$', pos + 2);
202
+ }
203
+ /** The unescaped `$$` delimiters in `text` from `from` on. */
204
+ function doubleDollars(text, from) {
205
+ let n = 0;
206
+ for (let i = text.indexOf('$$', from); i !== -1;) {
207
+ let slashes = 0;
208
+ while (text[i - 1 - slashes] === '\\')
209
+ slashes++;
210
+ if (slashes % 2 === 0) {
211
+ n++;
212
+ i = text.indexOf('$$', i + 2);
213
+ }
214
+ else {
215
+ i = text.indexOf('$$', i + 1);
216
+ }
217
+ }
218
+ return n;
219
+ }
220
+ /**
221
+ * The list item whose marker sits at `c`: a cursor at its content and the
222
+ * columns the marker and the spaces after it take. `null` when there is none,
223
+ * or when it may not interrupt an open paragraph — an empty item, or an
224
+ * ordered one not starting at 1.
225
+ *
226
+ * One Obsidian difference is left unmodelled: under a `1.`-style item (not
227
+ * `1)`), a line after an empty line indented exactly seven columns is text to
228
+ * Obsidian unless some line of the item is indented three, so `1. a`, empty,
229
+ * then seven spaces and `#t` is tagged `t` there and read as code here.
230
+ * Matching it would take the item's later lines into account.
231
+ */
232
+ function listItemAt(c, paragraphOpen) {
233
+ if (c.thematicBreakAt(c.pos))
234
+ return null;
235
+ const m = sticky(LIST_MARKER, c.text, c.pos);
236
+ if (!m)
237
+ return null;
238
+ const marker = m[0].length;
239
+ const cursor = c.clone();
240
+ cursor.pos += marker;
241
+ cursor.col += marker;
242
+ const empty = cursor.atEnd;
243
+ if (paragraphOpen) {
244
+ const start = m.groups?.start;
245
+ if (empty || (start !== undefined && Number(start) !== 1))
246
+ return null;
247
+ }
248
+ if (empty)
249
+ return { cursor, width: marker + 1 };
250
+ /** Five or more spaces after the marker: the item's text is indented code, and the marker takes one. */
251
+ const spaces = cursor.columns(5);
252
+ const taken = spaces >= 5 ? 1 : spaces;
253
+ cursor.take(taken);
254
+ return { cursor, width: marker + taken };
255
+ }
256
+ /** Whether `text[from, to)` holds a `|` that is not escaped. */
257
+ function hasPipe(text, from, to) {
258
+ let escaped = false;
259
+ for (let i = from; i < to; i++) {
260
+ const ch = text[i];
261
+ if (ch === '|' && !escaped)
262
+ return true;
263
+ escaped = ch === '\\' && !escaped;
264
+ }
265
+ return false;
266
+ }
267
+ /**
268
+ * Whether the text at `c` opens a block that ends a paragraph. Such a line
269
+ * cannot continue a paragraph lazily, nor a fence, math, or HTML block.
270
+ * `mathOpen` is whether a `$$` line may open display math here — see
271
+ * `BlockScanner.startLeaf`.
272
+ */
273
+ function interrupts(c, mathOpen) {
274
+ if (c.columns(4) >= 4)
275
+ return false;
276
+ const t = c.clone();
277
+ t.skipWhitespace();
278
+ const { text, pos } = t;
279
+ return (text[pos] === '>' ||
280
+ t.thematicBreakAt(pos) ||
281
+ listItemAt(t, true) !== null ||
282
+ sticky(ATX_HEADING, text, pos) !== null ||
283
+ sticky(FENCE_OPEN, text, pos) !== null ||
284
+ htmlBlockAt(text, pos, true) !== undefined ||
285
+ (mathOpen && mathOpensAt(text, pos)));
286
+ }
287
+ class BlockScanner {
288
+ body;
289
+ spans = [];
290
+ stack = [];
291
+ /** Indices into `stack` of its blockquotes, outermost first. A blank line continues every list item and no blockquote. */
292
+ quotes = [];
293
+ leaf;
294
+ prevBlank = false;
295
+ constructor(body) {
296
+ this.body = body;
297
+ }
298
+ run() {
299
+ for (let start = 0;;) {
300
+ const nl = this.body.indexOf('\n', start);
301
+ this.line(start, this.body.slice(start, nl === -1 ? this.body.length : nl));
302
+ if (nl === -1)
303
+ break;
304
+ start = nl + 1;
305
+ }
306
+ this.closeContainers(0);
307
+ this.closeLeaf();
308
+ return this.spans;
309
+ }
310
+ inline(start, end, tableRow = false) {
311
+ this.spans.push({ kind: 'inline', start, end, tableRow });
312
+ }
313
+ closeLeaf() {
314
+ const leaf = this.leaf;
315
+ this.leaf = undefined;
316
+ if (!leaf || leaf.kind === 'table')
317
+ return;
318
+ if (leaf.kind === 'paragraph')
319
+ this.inline(leaf.start, leaf.end);
320
+ else
321
+ this.spans.push({ kind: 'hidden', start: leaf.start, end: leaf.end });
322
+ }
323
+ closeContainers(depth) {
324
+ if (depth < this.stack.length)
325
+ this.closeLeaf();
326
+ this.stack.length = depth;
327
+ while ((this.quotes.at(-1) ?? -1) >= depth)
328
+ this.quotes.pop();
329
+ }
330
+ line(start, text) {
331
+ const end = start + text.length;
332
+ const c = LineCursor.start(text);
333
+ const whitespaceLine = c.atEnd;
334
+ let matched = 0;
335
+ if (whitespaceLine) {
336
+ matched = this.quotes[0] ?? this.stack.length;
337
+ }
338
+ else {
339
+ for (; matched < this.stack.length; matched++) {
340
+ const k = this.stack[matched];
341
+ if (k.quote ? !this.quoteMarker(c) : !c.atEnd && !c.take(k.indent))
342
+ break;
343
+ }
344
+ }
345
+ const blank = sticky(BLANK, text, c.pos) !== null;
346
+ const afterBlank = this.prevBlank;
347
+ this.prevBlank = whitespaceLine;
348
+ if (matched === this.stack.length) {
349
+ if (this.leaf && this.continueLeaf(this.leaf, c, start, end, blank))
350
+ return;
351
+ }
352
+ else {
353
+ if (this.lazy(c, matched, end, afterBlank))
354
+ return;
355
+ this.closeContainers(matched);
356
+ }
357
+ if (c.atEnd) {
358
+ /** A line of tabs continues an open paragraph; only an empty or spaces-only line ends one. */
359
+ if (this.leaf?.kind === 'paragraph' && !blank)
360
+ return;
361
+ this.closeLeaf();
362
+ return;
363
+ }
364
+ let cur = c;
365
+ while (cur.columns(4) < 4) {
366
+ const t = cur.clone();
367
+ t.skipWhitespace();
368
+ if (text[t.pos] === '>') {
369
+ this.closeLeaf();
370
+ this.quoteMarker(cur);
371
+ this.quotes.push(this.stack.length);
372
+ this.stack.push({ quote: true, indent: 0 });
373
+ continue;
374
+ }
375
+ const item = listItemAt(t, this.leaf?.kind === 'paragraph');
376
+ if (!item)
377
+ break;
378
+ this.closeLeaf();
379
+ this.stack.push({ quote: false, indent: cur.columns(4) + item.width });
380
+ cur = item.cursor;
381
+ }
382
+ if (!cur.atEnd)
383
+ this.startLeaf(cur, start, end);
384
+ }
385
+ /**
386
+ * A lazy line: CommonMark lets a paragraph run on over a line that drops its
387
+ * container's markers, and Obsidian lets a fence, math, or HTML block run on
388
+ * the same way — `- ```` then an unindented line is still code, and an
389
+ * unindented fence cannot close it. That stops at a blank line or a line
390
+ * that opens a block. One more Obsidian rule: a line indented four columns
391
+ * never continues a blockquote lazily (`> para` then ` #t` is code).
392
+ */
393
+ lazy(c, matched, end, afterBlank) {
394
+ const leaf = this.leaf;
395
+ if (!leaf || leaf.kind === 'code' || leaf.kind === 'table')
396
+ return false;
397
+ if (c.atEnd || (afterBlank && leaf.kind !== 'paragraph'))
398
+ return false;
399
+ if (interrupts(c, leaf.kind !== 'paragraph' || leaf.dollars % 2 === 0))
400
+ return false;
401
+ if ((this.quotes.at(-1) ?? -1) >= matched && c.columns(4) >= 4)
402
+ return false;
403
+ if (leaf.kind === 'paragraph')
404
+ this.grow(leaf, c, end);
405
+ else
406
+ leaf.end = end;
407
+ if (leaf.kind === 'html' && leaf.close && closes(leaf.close, c.text, 0))
408
+ this.closeLeaf();
409
+ return true;
410
+ }
411
+ /** Add the rest of the line at `c` to the open paragraph. */
412
+ grow(paragraph, c, end) {
413
+ paragraph.end = end;
414
+ paragraph.lines++;
415
+ paragraph.dollars += doubleDollars(c.text, c.pos);
416
+ }
417
+ /**
418
+ * Consume a blockquote marker: up to three columns of indentation, `>`, and
419
+ * one following space. Obsidian then measures the rest of the line from
420
+ * column zero, so a tab after `>` is four columns wide (`>\t#t` is indented
421
+ * code), where CommonMark would have the marker take one of its columns.
422
+ */
423
+ quoteMarker(c) {
424
+ if (c.columns(4) >= 4)
425
+ return false;
426
+ const t = c.clone();
427
+ t.skipWhitespace();
428
+ if (t.text[t.pos] !== '>')
429
+ return false;
430
+ c.pos = t.pos + 1;
431
+ if (c.text[c.pos] === ' ')
432
+ c.pos++;
433
+ c.col = 0;
434
+ c.spare = 0;
435
+ return true;
436
+ }
437
+ /** Continue the open leaf with this line. False when the line ends it and is read as a new block. */
438
+ continueLeaf(leaf, c, start, end, blank) {
439
+ const { text } = c;
440
+ switch (leaf.kind) {
441
+ case 'fence': {
442
+ leaf.end = end;
443
+ if (c.columns(4) < 4) {
444
+ const t = c.clone();
445
+ t.skipWhitespace();
446
+ const run = sticky(FENCE_CLOSE, text, t.pos)?.[1];
447
+ if (run && run[0] === leaf.marker[0] && run.length >= leaf.marker.length)
448
+ this.closeLeaf();
449
+ }
450
+ return true;
451
+ }
452
+ case 'math':
453
+ leaf.end = end;
454
+ if (sticky(MATH_CLOSE, text, c.pos))
455
+ this.closeLeaf();
456
+ return true;
457
+ case 'html':
458
+ if (!leaf.close && blank) {
459
+ this.closeLeaf();
460
+ return false;
461
+ }
462
+ leaf.end = end;
463
+ if (leaf.close && closes(leaf.close, text, 0))
464
+ this.closeLeaf();
465
+ return true;
466
+ case 'code':
467
+ /** Blank lines stay inside indented code without extending its span. */
468
+ if (c.atEnd)
469
+ return true;
470
+ if (c.columns(4) >= 4) {
471
+ leaf.end = end;
472
+ return true;
473
+ }
474
+ this.closeLeaf();
475
+ return false;
476
+ case 'table':
477
+ if (this.tableRow(c, leaf.lead)) {
478
+ this.inline(start, end, true);
479
+ return true;
480
+ }
481
+ this.closeLeaf();
482
+ return false;
483
+ case 'paragraph':
484
+ return false;
485
+ }
486
+ }
487
+ /**
488
+ * Obsidian reads a table row only at the container's content start — one
489
+ * leading space and the table is gone — and only in the header's style: a
490
+ * table whose header opens with `|` takes rows that open with `|`, and one
491
+ * whose header does not takes rows that hold a `|` without opening with one.
492
+ */
493
+ tableRow(c, lead) {
494
+ if (c.atEnd || c.columns(1) > 0)
495
+ return false;
496
+ const { text, pos } = c;
497
+ if (lead)
498
+ return text[pos] === '|';
499
+ return text[pos] !== '|' && hasPipe(text, pos, text.length);
500
+ }
501
+ startLeaf(c, start, end) {
502
+ const { text } = c;
503
+ const leaf = this.leaf;
504
+ const cols = c.columns(4);
505
+ if (cols >= 4) {
506
+ /** Indented code cannot interrupt a paragraph; the line continues it. */
507
+ if (leaf?.kind === 'paragraph') {
508
+ this.grow(leaf, c, end);
509
+ }
510
+ else {
511
+ this.closeLeaf();
512
+ this.leaf = { kind: 'code', start, end };
513
+ }
514
+ return;
515
+ }
516
+ c.skipWhitespace();
517
+ const { pos } = c;
518
+ const at = start + pos;
519
+ if (leaf?.kind === 'paragraph') {
520
+ if (sticky(SETEXT_UNDERLINE, text, pos)) {
521
+ this.closeLeaf();
522
+ return;
523
+ }
524
+ if (leaf.lines === 1 &&
525
+ leaf.header >= 0 &&
526
+ cols === 0 &&
527
+ this.delimiterRow(text, pos, leaf)) {
528
+ return;
529
+ }
530
+ }
531
+ if (c.thematicBreakAt(pos)) {
532
+ this.closeLeaf();
533
+ return;
534
+ }
535
+ if (sticky(ATX_HEADING, text, pos)) {
536
+ this.closeLeaf();
537
+ this.inline(start, end);
538
+ return;
539
+ }
540
+ const fence = sticky(FENCE_OPEN, text, pos);
541
+ if (fence) {
542
+ this.closeLeaf();
543
+ this.leaf = { kind: 'fence', start, end, marker: fence[0] };
544
+ return;
545
+ }
546
+ const html = htmlBlockAt(text, pos, leaf?.kind === 'paragraph');
547
+ if (html) {
548
+ this.closeLeaf();
549
+ this.leaf = { kind: 'html', start: at, end, close: html.close };
550
+ if (html.close && closes(html.close, text, pos))
551
+ this.closeLeaf();
552
+ return;
553
+ }
554
+ /**
555
+ * A `$$` line opens display math, interrupting a paragraph — unless the
556
+ * paragraph already holds an unpaired inline `$$`, which Obsidian closes on
557
+ * this line instead: `a $$` then `#t` then `$$ b` hides `#t` as inline math.
558
+ */
559
+ if (mathOpensAt(text, pos) && !(leaf?.kind === 'paragraph' && leaf.dollars % 2 === 1)) {
560
+ this.closeLeaf();
561
+ this.leaf = { kind: 'math', start: at, end };
562
+ return;
563
+ }
564
+ if (leaf?.kind === 'paragraph') {
565
+ this.grow(leaf, c, end);
566
+ return;
567
+ }
568
+ this.closeLeaf();
569
+ /** Obsidian does not read a link reference definition as a paragraph: an indented line after `[a]: u` is code. */
570
+ if (sticky(LINK_DEFINITION, text, pos)) {
571
+ this.inline(start, end);
572
+ return;
573
+ }
574
+ this.leaf = {
575
+ kind: 'paragraph',
576
+ start,
577
+ end,
578
+ lines: 1,
579
+ header: cols === 0 ? at : -1,
580
+ dollars: doubleDollars(text, pos),
581
+ };
582
+ }
583
+ /**
584
+ * Turn a one-line paragraph into a table when this line is a delimiter row
585
+ * in the header's style. Obsidian does not require the column counts to
586
+ * agree, and does not let a table interrupt a paragraph.
587
+ */
588
+ delimiterRow(text, pos, paragraph) {
589
+ const lead = this.body[paragraph.header] === '|';
590
+ if ((text[pos] === '|') !== lead)
591
+ return false;
592
+ const from = lead ? pos + 1 : pos;
593
+ if (!sticky(DELIMITER_ROW, text, from) || !text.includes('|', from))
594
+ return false;
595
+ if (!hasPipe(this.body, lead ? paragraph.header + 1 : paragraph.header, paragraph.end)) {
596
+ return false;
597
+ }
598
+ this.leaf = { kind: 'table', lead };
599
+ this.inline(paragraph.start, paragraph.end, true);
600
+ return true;
601
+ }
602
+ }
603
+ /**
604
+ * The hidden and inline ranges of `body`, in order and non-overlapping.
605
+ * Linear in the length of the body: each line is read a bounded number of
606
+ * times, and a blank line matches its containers without walking them.
607
+ */
608
+ export function scanBlocks(body) {
609
+ return new BlockScanner(body).run();
610
+ }
611
+ //# sourceMappingURL=markdown-blocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-blocks.js","sourceRoot":"","sources":["../../../src/services/obsidian/markdown-blocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAmDH,SAAS,UAAU,CAAC,EAAE,IAAI,EAAE,IAAI,EAAQ;IACtC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAC9B,IAAI,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC;IACpB,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;QACjD,OACE,IAAI,GAAG,CAAC;YACR,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,EAC9E,CAAC;YACD,IAAI,EAAE,CAAC;QACT,CAAC;IACH,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC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AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC;AACtC,CAAC"}
@@ -8,7 +8,7 @@ import type { Context } from '@cyanheads/mcp-ts-core';
8
8
  import { type Dispatcher, type RequestInit, fetch as undiciFetch } from 'undici';
9
9
  import { type ServerConfig } from '../../config/server-config.js';
10
10
  import { PathPolicy } from './path-policy.js';
11
- import type { DocumentMap, FileListing, NoteJson, NoteTarget, ObsidianCommand, ObsidianTag, OmnisearchHit, PatchHeaders, StructuredSearchHit, TextSearchHit, VaultStatus } from './types.js';
11
+ import type { DocumentMap, FileListing, NoteJson, NoteTarget, ObsidianCommand, ObsidianTag, OmnisearchHit, PatchInstruction, StructuredSearchHit, TextSearchHit, VaultStatus } from './types.js';
12
12
  type UndiciResponse = Awaited<ReturnType<typeof undiciFetch>>;
13
13
  /**
14
14
  * The HTTP fetch contract this service depends on. Defaults to undici's
@@ -73,13 +73,15 @@ export declare class ObsidianService {
73
73
  writeNote(ctx: Context, target: NoteTarget, content: string, contentType?: 'markdown' | 'json'): Promise<void>;
74
74
  appendToNote(ctx: Context, target: NoteTarget, content: string, contentType?: 'markdown' | 'json'): Promise<void>;
75
75
  /**
76
- * Apply a header-targeted PATCH. Returns the section locator the edit was
77
- * actually applied to — identical to `headers.target` unless a bare heading
78
- * leaf was expanded to its full `Parent::Child` path (see
79
- * `#resolveHeadingTarget`), which callers echo back so an agent can see where
80
- * the write landed.
76
+ * Apply a section-targeted PATCH in the markdown-patch format the plugin
77
+ * speaks: a 2.0 JSON instruction on Local REST API 5.x and later, 1.x
78
+ * request headers on 4.x and for the table-row writes 2.0 cannot express
79
+ * (`#wireFormat`). Returns the section locator the edit was actually
80
+ * applied to — identical to `instruction.target` unless a bare heading leaf
81
+ * was expanded to its full `Parent::Child` path (see `#resolveHeadingTarget`),
82
+ * which callers echo back so an agent can see where the write landed.
81
83
  */
82
- patchNote(ctx: Context, target: NoteTarget, content: string, headers: PatchHeaders): Promise<string>;
84
+ patchNote(ctx: Context, target: NoteTarget, content: string, instruction: PatchInstruction): Promise<string>;
83
85
  deleteNote(ctx: Context, target: NoteTarget): Promise<void>;
84
86
  /**
85
87
  * Byte size of a note at `target`, derived from the HEAD `Content-Length`