obsidian-mcp-server 3.5.4 → 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 (58) hide show
  1. package/AGENTS.md +9 -3
  2. package/CLAUDE.md +9 -3
  3. package/README.md +14 -13
  4. package/changelog/3.5.x/3.5.5.md +20 -0
  5. package/changelog/3.6.x/3.6.0.md +31 -0
  6. package/dist/mcp-server/tools/definitions/_shared/schemas.d.ts.map +1 -1
  7. package/dist/mcp-server/tools/definitions/_shared/schemas.js +2 -2
  8. package/dist/mcp-server/tools/definitions/_shared/schemas.js.map +1 -1
  9. package/dist/mcp-server/tools/definitions/index.d.ts +97 -61
  10. package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -1
  11. package/dist/mcp-server/tools/definitions/obsidian-append-to-note.tool.d.ts +14 -2
  12. package/dist/mcp-server/tools/definitions/obsidian-append-to-note.tool.d.ts.map +1 -1
  13. package/dist/mcp-server/tools/definitions/obsidian-append-to-note.tool.js +17 -4
  14. package/dist/mcp-server/tools/definitions/obsidian-append-to-note.tool.js.map +1 -1
  15. package/dist/mcp-server/tools/definitions/obsidian-get-note.tool.d.ts.map +1 -1
  16. package/dist/mcp-server/tools/definitions/obsidian-get-note.tool.js +4 -3
  17. package/dist/mcp-server/tools/definitions/obsidian-get-note.tool.js.map +1 -1
  18. package/dist/mcp-server/tools/definitions/obsidian-manage-tags.tool.d.ts +5 -2
  19. package/dist/mcp-server/tools/definitions/obsidian-manage-tags.tool.d.ts.map +1 -1
  20. package/dist/mcp-server/tools/definitions/obsidian-manage-tags.tool.js +6 -3
  21. package/dist/mcp-server/tools/definitions/obsidian-manage-tags.tool.js.map +1 -1
  22. package/dist/mcp-server/tools/definitions/obsidian-patch-note.tool.d.ts +17 -4
  23. package/dist/mcp-server/tools/definitions/obsidian-patch-note.tool.d.ts.map +1 -1
  24. package/dist/mcp-server/tools/definitions/obsidian-patch-note.tool.js +20 -6
  25. package/dist/mcp-server/tools/definitions/obsidian-patch-note.tool.js.map +1 -1
  26. package/dist/mcp-server/tools/definitions/obsidian-search-notes.tool.d.ts +6 -5
  27. package/dist/mcp-server/tools/definitions/obsidian-search-notes.tool.d.ts.map +1 -1
  28. package/dist/mcp-server/tools/definitions/obsidian-search-notes.tool.js +26 -24
  29. package/dist/mcp-server/tools/definitions/obsidian-search-notes.tool.js.map +1 -1
  30. package/dist/mcp-server/tools/definitions/obsidian-write-note.tool.d.ts +14 -2
  31. package/dist/mcp-server/tools/definitions/obsidian-write-note.tool.d.ts.map +1 -1
  32. package/dist/mcp-server/tools/definitions/obsidian-write-note.tool.js +26 -13
  33. package/dist/mcp-server/tools/definitions/obsidian-write-note.tool.js.map +1 -1
  34. package/dist/services/obsidian/frontmatter-ops.d.ts +7 -4
  35. package/dist/services/obsidian/frontmatter-ops.d.ts.map +1 -1
  36. package/dist/services/obsidian/frontmatter-ops.js +502 -59
  37. package/dist/services/obsidian/frontmatter-ops.js.map +1 -1
  38. package/dist/services/obsidian/markdown-blocks.d.ts +39 -0
  39. package/dist/services/obsidian/markdown-blocks.d.ts.map +1 -0
  40. package/dist/services/obsidian/markdown-blocks.js +611 -0
  41. package/dist/services/obsidian/markdown-blocks.js.map +1 -0
  42. package/dist/services/obsidian/obsidian-service.d.ts +18 -12
  43. package/dist/services/obsidian/obsidian-service.d.ts.map +1 -1
  44. package/dist/services/obsidian/obsidian-service.js +653 -130
  45. package/dist/services/obsidian/obsidian-service.js.map +1 -1
  46. package/dist/services/obsidian/patch-instruction.d.ts +141 -0
  47. package/dist/services/obsidian/patch-instruction.d.ts.map +1 -0
  48. package/dist/services/obsidian/patch-instruction.js +217 -0
  49. package/dist/services/obsidian/patch-instruction.js.map +1 -0
  50. package/dist/services/obsidian/section-extractor.d.ts +109 -6
  51. package/dist/services/obsidian/section-extractor.d.ts.map +1 -1
  52. package/dist/services/obsidian/section-extractor.js +364 -87
  53. package/dist/services/obsidian/section-extractor.js.map +1 -1
  54. package/dist/services/obsidian/types.d.ts +23 -9
  55. package/dist/services/obsidian/types.d.ts.map +1 -1
  56. package/manifest.json +1 -1
  57. package/package.json +3 -2
  58. package/server.json +3 -3
@@ -1,16 +1,18 @@
1
1
  /**
2
- * @fileoverview Client-side section extraction from a NoteJson body.
3
- * The upstream Local REST API exposes section *targeting* for PATCH but not
4
- * section-extracted GET, so we slice the markdown ourselves for `format: 'section'`.
2
+ * @fileoverview Client-side section extraction from a NoteJson body for
3
+ * `format: 'section'`. Headings are found the way the plugin's markdown-patch
4
+ * finds them for its document map and PATCH targeting, so a section read
5
+ * covers the span a section write edits, sliced from the note's own bytes.
5
6
  * @module services/obsidian/section-extractor
6
7
  */
7
8
  import type { NoteJson, SectionTarget } from './types.js';
8
9
  /** An extracted section value plus, for heading targets, how the locator resolved. */
9
10
  export interface SectionExtraction {
10
11
  /**
11
- * Every full heading path sharing the bare-leaf target, in document order.
12
- * Present only when more than one heading matched — the read still returns
13
- * the first, so this is disclosure, not a new failure mode.
12
+ * Every full heading path the target could name, in document order: each
13
+ * heading sharing a bare-leaf target, or each repeat of a delimited target's
14
+ * resolved path. Present only when more than one heading matched — the read
15
+ * still returns the first, so this is disclosure, not a new failure mode.
14
16
  */
15
17
  candidates?: string[];
16
18
  /**
@@ -26,6 +28,107 @@ export interface SectionExtraction {
26
28
  * Throws `NotFound` if the target does not exist in the note.
27
29
  */
28
30
  export declare function extractSection(note: NoteJson, section: SectionTarget): SectionExtraction;
31
+ /** A heading as the plugin's parser reads it, located in the note's own bytes. */
32
+ export interface Heading {
33
+ /**
34
+ * Offset just past the heading's last line — its underline, for a setext
35
+ * heading — and that line's ending, or the note's length.
36
+ */
37
+ end: number;
38
+ /** 1–6: the `#` count of an ATX heading, 1 or 2 for a setext `=` or `-` underline. */
39
+ level: number;
40
+ /** Offset of the heading's first byte: its `#` line (indent included), or a setext heading's first text line. */
41
+ start: number;
42
+ /**
43
+ * Heading text as the document map keys it: the parser's text, trimmed.
44
+ * Empty for an untitled heading; a multi-line setext heading keeps its
45
+ * newlines.
46
+ */
47
+ text: string;
48
+ }
49
+ /**
50
+ * Every heading in `content`, in document order, found the way the plugin's
51
+ * markdown-patch 2.0 finds them for its document map and PATCH targeting: the
52
+ * frontmatter-stripped body, line endings normalized, lexed with `marked`, and
53
+ * each top-level `heading` token located by accumulating token `raw` lengths.
54
+ * That reads setext headings and skips `#` lines inside fences, HTML blocks,
55
+ * list items, and blockquotes, exactly as the map does. Offsets are mapped
56
+ * back to `content`, so a slice between them is the note's own bytes, CRs
57
+ * included.
58
+ */
59
+ export declare function scanHeadings(content: string): Heading[];
60
+ /** A section's own body, as markdown-patch 2.0 models it for a `within` write. */
61
+ export interface SectionBody {
62
+ /**
63
+ * `marked` token type of each top-level block in the section's direct body —
64
+ * below its heading line and above its first sub-heading — in order: the
65
+ * blocks a 2.0 `within` index counts (`paragraph`, `list`, `table`, `code`, …).
66
+ */
67
+ blocks: string[];
68
+ /**
69
+ * The section's `content` scope in the note's own bytes: below its heading
70
+ * line through its last subsection. What 2.0's `rejectIfContentPreexists`
71
+ * searches on a plain heading write.
72
+ */
73
+ content: string;
74
+ /** Whether sub-headings follow the direct body — a plain append lands below them. */
75
+ subsections: boolean;
76
+ }
77
+ /**
78
+ * The body of the heading at full path `path` (its first occurrence), read
79
+ * from one lex of the note, or `undefined` when the note has no such heading.
80
+ * 2.0 assigns a section every top-level token between its heading and the
81
+ * next heading of any level; a `space` token is not a block.
82
+ */
83
+ export declare function sectionBody(content: string, path: string): SectionBody | undefined;
84
+ /** The `marked` token type of each top-level block in `markdown`, in order. */
85
+ export declare function blockKinds(markdown: string): string[];
86
+ /**
87
+ * Full `::`-joined path of every heading in `content`, in document order,
88
+ * repeats included — the markdown-patch 2.0 map's heading tree, flattened.
89
+ * Deduplicated and with the `""` entry dropped, it is the 1.x map's `headings`
90
+ * array.
91
+ */
92
+ export declare function listHeadingPaths(content: string): string[];
93
+ /**
94
+ * The level of the heading at full path `path` in `content` — its first
95
+ * occurrence. For a path the note does not have: with `create`, the level
96
+ * markdown-patch 2.0 gives it when `createTargetIfMissing` creates it — one
97
+ * below the deepest existing ancestor for each missing segment, counted from 0
98
+ * when no ancestor exists — and without, `undefined`.
99
+ */
100
+ export declare function sectionLevel(content: string, path: string, create: boolean): number | undefined;
101
+ /**
102
+ * True when `blockId` is referenced in `content` by an isolated marker: a
103
+ * `^blockId` line on its own, after a blank line (or at the body's start), so
104
+ * the parser reads it as its own paragraph and the id names the block above.
105
+ * A marker line with no blank line above it continues that block instead (a
106
+ * table row, a paragraph line, a list item), and a line inside a fence or
107
+ * indented as code is not a marker.
108
+ */
109
+ export declare function isIsolatedBlockId(content: string, blockId: string): boolean;
110
+ /** The `#` run opening a top-level ATX heading in a markdown fragment. */
111
+ export interface AtxHeadingMarker {
112
+ /** Length of the `#` run — the heading's level. */
113
+ hashes: number;
114
+ /** The heading's line, trimmed, for messages. */
115
+ line: string;
116
+ /** Offset of the run's first `#` in the fragment's `normalized` text. */
117
+ start: number;
118
+ }
119
+ /** A markdown fragment with its line endings read as `\n`, and its ATX heading markers. */
120
+ export interface AtxHeadingFragment {
121
+ markers: AtxHeadingMarker[];
122
+ normalized: string;
123
+ }
124
+ /**
125
+ * The `#` run of every top-level ATX heading in `markdown`, found as
126
+ * markdown-patch 2.0 finds the headings it re-levels in written content: line
127
+ * endings normalized, lexed with `marked`, and each top-level `heading` token
128
+ * whose raw text opens with a `#` run. A setext heading, a `#` line inside a
129
+ * fence or HTML block, and a hashtag carry none.
130
+ */
131
+ export declare function atxHeadingMarkers(markdown: string): AtxHeadingFragment;
29
132
  /**
30
133
  * Mark line indices that fall inside fenced code blocks (` ``` ` or `~~~`) so
31
134
  * downstream scanning doesn't false-match on markdown-about-markdown notes.
@@ -1 +1 @@
1
- {"version":3,"file":"section-extractor.d.ts","sourceRoot":"","sources":["../../../src/services/obsidian/section-extractor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAK1D,sFAAsF;AACtF,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,GAAG,iBAAiB,CASxF;AAgMD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,SAAI,GAAG,OAAO,EAAE,CA0BrE"}
1
+ {"version":3,"file":"section-extractor.d.ts","sourceRoot":"","sources":["../../../src/services/obsidian/section-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAK1D,sFAAsF;AACtF,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,GAAG,iBAAiB,CASxF;AAYD,kFAAkF;AAClF,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,sFAAsF;IACtF,KAAK,EAAE,MAAM,CAAC;IACd,iHAAiH;IACjH,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAaD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE,CAMvD;AA6BD,kFAAkF;AACl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