obsidian-mcp-server 3.6.1 → 3.7.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.
- package/AGENTS.md +27 -17
- package/CLAUDE.md +27 -17
- package/README.md +22 -13
- package/changelog/3.7.x/3.7.0.md +34 -0
- package/dist/config/server-config.d.ts +1 -0
- package/dist/config/server-config.d.ts.map +1 -1
- package/dist/config/server-config.js +4 -0
- package/dist/config/server-config.js.map +1 -1
- package/dist/index.js +28 -9
- package/dist/index.js.map +1 -1
- package/dist/mcp-server/resources/definitions/obsidian-tags.resource.d.ts +7 -5
- package/dist/mcp-server/resources/definitions/obsidian-tags.resource.d.ts.map +1 -1
- package/dist/mcp-server/resources/definitions/obsidian-tags.resource.js +12 -8
- package/dist/mcp-server/resources/definitions/obsidian-tags.resource.js.map +1 -1
- package/dist/mcp-server/tools/definitions/_shared/suggest-paths.d.ts +30 -9
- package/dist/mcp-server/tools/definitions/_shared/suggest-paths.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/_shared/suggest-paths.js +28 -6
- package/dist/mcp-server/tools/definitions/_shared/suggest-paths.js.map +1 -1
- package/dist/mcp-server/tools/definitions/index.d.ts +230 -294
- package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/index.js +9 -3
- package/dist/mcp-server/tools/definitions/index.js.map +1 -1
- package/dist/mcp-server/tools/definitions/obsidian-delete-note.tool.d.ts +107 -10
- package/dist/mcp-server/tools/definitions/obsidian-delete-note.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/obsidian-delete-note.tool.js +237 -162
- package/dist/mcp-server/tools/definitions/obsidian-delete-note.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/obsidian-get-note.tool.d.ts +1 -0
- package/dist/mcp-server/tools/definitions/obsidian-get-note.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/obsidian-get-note.tool.js +61 -19
- package/dist/mcp-server/tools/definitions/obsidian-get-note.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/obsidian-list-notes.tool.d.ts +6 -1
- package/dist/mcp-server/tools/definitions/obsidian-list-notes.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/obsidian-list-notes.tool.js +8 -10
- package/dist/mcp-server/tools/definitions/obsidian-list-notes.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/obsidian-list-tags.tool.d.ts +7 -5
- package/dist/mcp-server/tools/definitions/obsidian-list-tags.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/obsidian-list-tags.tool.js +13 -7
- package/dist/mcp-server/tools/definitions/obsidian-list-tags.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/obsidian-open-in-ui.tool.d.ts +4 -1
- package/dist/mcp-server/tools/definitions/obsidian-open-in-ui.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/obsidian-open-in-ui.tool.js +15 -4
- package/dist/mcp-server/tools/definitions/obsidian-open-in-ui.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/obsidian-search-notes.tool.js +1 -1
- package/dist/mcp-server/tools/definitions/obsidian-search-notes.tool.js.map +1 -1
- package/dist/services/obsidian/obsidian-service.d.ts +7 -0
- package/dist/services/obsidian/obsidian-service.d.ts.map +1 -1
- package/dist/services/obsidian/obsidian-service.js +57 -15
- package/dist/services/obsidian/obsidian-service.js.map +1 -1
- package/dist/services/obsidian/patch-instruction.d.ts +20 -1
- package/dist/services/obsidian/patch-instruction.d.ts.map +1 -1
- package/dist/services/obsidian/patch-instruction.js +30 -0
- package/dist/services/obsidian/patch-instruction.js.map +1 -1
- package/dist/services/obsidian/path-policy.d.ts +23 -1
- package/dist/services/obsidian/path-policy.d.ts.map +1 -1
- package/dist/services/obsidian/path-policy.js +45 -3
- package/dist/services/obsidian/path-policy.js.map +1 -1
- package/dist/services/obsidian/section-extractor.d.ts +24 -0
- package/dist/services/obsidian/section-extractor.d.ts.map +1 -1
- package/dist/services/obsidian/section-extractor.js +37 -0
- package/dist/services/obsidian/section-extractor.js.map +1 -1
- package/manifest.json +9 -1
- package/package.json +2 -2
- package/server.json +17 -3
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAClG,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAEhE,MAAM,MAAM,GAAG,eAAe,EAAE,CAAC;AACjC,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;AAEtC;;;;;GAKG;AACH,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAC5B,MAAM,QAAQ,GAAG,kBAAkB,EAAE,CAAC;AACtC,MAAM,mBAAmB,GAAG,MAAM,QAAQ,CAAC,eAAe,EAAE,CAAC;AAE7D,MAAM,eAAe,GAAG,oBAAoB,CAAC,EAAE,mBAAmB,EAAE,CAAC,CAAC;AAEtE;;;;;GAKG;AACH,SAAS,iBAAiB;IACxB,MAAM,QAAQ,GAAa;QACzB,qXAAqX;KACtX,CAAC;IACF,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,QAAQ,CAAC,IAAI,CACX,oQAAoQ,CACrQ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C;AACJ,CAAC"}
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
* @fileoverview obsidian://tags — vault tag listing with usage counts, for
|
|
3
3
|
* clients that prefer attaching resources.
|
|
4
4
|
*
|
|
5
|
-
* Not a mirror of `obsidian_list_tags`: this is a snapshot of
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* Not a mirror of `obsidian_list_tags`: this is a snapshot of
|
|
6
|
+
* `ObsidianService.listTags`, returned whole and unsorted — the upstream
|
|
7
|
+
* `/tags/` payload in upstream order, or under OBSIDIAN_READ_PATHS the tags of
|
|
8
|
+
* readable notes in order of first appearance. The tool shapes the same
|
|
9
|
+
* payload for an LLM caller — count-descending, capped, filterable — and that
|
|
10
|
+
* shaping deliberately lives in the tool handler rather than the shared
|
|
11
|
+
* service call both make.
|
|
10
12
|
* @module mcp-server/resources/definitions/obsidian-tags.resource
|
|
11
13
|
*/
|
|
12
14
|
import { z } from '@cyanheads/mcp-ts-core';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"obsidian-tags.resource.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/resources/definitions/obsidian-tags.resource.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"obsidian-tags.resource.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/resources/definitions/obsidian-tags.resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAY,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAGrD,eAAO,MAAM,YAAY;;;;;6BA+BvB,CAAC"}
|
|
@@ -2,18 +2,20 @@
|
|
|
2
2
|
* @fileoverview obsidian://tags — vault tag listing with usage counts, for
|
|
3
3
|
* clients that prefer attaching resources.
|
|
4
4
|
*
|
|
5
|
-
* Not a mirror of `obsidian_list_tags`: this is a snapshot of
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* Not a mirror of `obsidian_list_tags`: this is a snapshot of
|
|
6
|
+
* `ObsidianService.listTags`, returned whole and unsorted — the upstream
|
|
7
|
+
* `/tags/` payload in upstream order, or under OBSIDIAN_READ_PATHS the tags of
|
|
8
|
+
* readable notes in order of first appearance. The tool shapes the same
|
|
9
|
+
* payload for an LLM caller — count-descending, capped, filterable — and that
|
|
10
|
+
* shaping deliberately lives in the tool handler rather than the shared
|
|
11
|
+
* service call both make.
|
|
10
12
|
* @module mcp-server/resources/definitions/obsidian-tags.resource
|
|
11
13
|
*/
|
|
12
14
|
import { resource, z } from '@cyanheads/mcp-ts-core';
|
|
13
15
|
import { getObsidianService } from '../../../services/obsidian/obsidian-service.js';
|
|
14
16
|
export const obsidianTags = resource('obsidian://tags', {
|
|
15
17
|
name: 'obsidian-tags',
|
|
16
|
-
description: 'All tags found in the Obsidian vault, with usage counts,
|
|
18
|
+
description: 'All tags found in the Obsidian vault, with usage counts, unsorted and uncapped — a full snapshot. When OBSIDIAN_READ_PATHS is set, only tags carried by readable notes. Includes hierarchical parents (e.g. `work` for `work/tasks`). Use the `obsidian_list_tags` tool for a count-ranked, capped, filterable view.',
|
|
17
19
|
mimeType: 'application/json',
|
|
18
20
|
params: z.object({}),
|
|
19
21
|
output: z.object({
|
|
@@ -21,10 +23,12 @@ export const obsidianTags = resource('obsidian://tags', {
|
|
|
21
23
|
.array(z
|
|
22
24
|
.object({
|
|
23
25
|
name: z.string().describe('Tag name without the leading `#`.'),
|
|
24
|
-
count: z
|
|
26
|
+
count: z
|
|
27
|
+
.number()
|
|
28
|
+
.describe('Times the tag, or a tag nested under it, occurs across the vault. When OBSIDIAN_READ_PATHS is set: the number of readable notes carrying the tag or a tag nested under it.'),
|
|
25
29
|
})
|
|
26
30
|
.describe('A tag with its usage count.'))
|
|
27
|
-
.describe('Every tag in the vault, in
|
|
31
|
+
.describe('Every tag in the vault, in the order the Local REST API reports them. When OBSIDIAN_READ_PATHS is set: every tag carried by a readable note, in order of first appearance.'),
|
|
28
32
|
}),
|
|
29
33
|
auth: ['resource:obsidian-tags:read'],
|
|
30
34
|
async handler(_params, ctx) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"obsidian-tags.resource.js","sourceRoot":"","sources":["../../../../src/mcp-server/resources/definitions/obsidian-tags.resource.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"obsidian-tags.resource.js","sourceRoot":"","sources":["../../../../src/mcp-server/resources/definitions/obsidian-tags.resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAE7E,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC,iBAAiB,EAAE;IACtD,IAAI,EAAE,eAAe;IACrB,WAAW,EACT,sTAAsT;IACxT,QAAQ,EAAE,kBAAkB;IAC5B,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,IAAI,EAAE,CAAC;aACJ,KAAK,CACJ,CAAC;aACE,MAAM,CAAC;YACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;YAC9D,KAAK,EAAE,CAAC;iBACL,MAAM,EAAE;iBACR,QAAQ,CACP,4KAA4K,CAC7K;SACJ,CAAC;aACD,QAAQ,CAAC,6BAA6B,CAAC,CAC3C;aACA,QAAQ,CACP,4KAA4K,CAC7K;KACJ,CAAC;IACF,IAAI,EAAE,CAAC,6BAA6B,CAAC;IAErC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG;QACxB,MAAM,GAAG,GAAG,kBAAkB,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACrC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC;IACvE,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -4,8 +4,12 @@
|
|
|
4
4
|
* 1. **Case-insensitive fallback.** If a path lookup 404s, list the parent
|
|
5
5
|
* directory and look for a single case-insensitive filename match. If
|
|
6
6
|
* found, retry against the canonical filesystem path (matches v2.x
|
|
7
|
-
* behavior)
|
|
8
|
-
*
|
|
7
|
+
* behavior) and report the path that was asked for as `requestedPath`, so
|
|
8
|
+
* the caller can disclose the substitution. The fallback is reachable on
|
|
9
|
+
* every host: the plugin's `note+json` and document-map reads resolve
|
|
10
|
+
* through Obsidian's case-sensitive vault index even on a case-insensitive
|
|
11
|
+
* filesystem (macOS, Windows). Only the raw-markdown read case-folds there,
|
|
12
|
+
* answering 200 for a wrong-case path before any fallback runs.
|
|
9
13
|
*
|
|
10
14
|
* 2. **"Did you mean" suggestions.** When no case match exists but the parent
|
|
11
15
|
* directory has near-matches (e.g., extension-stripped variants), re-throw
|
|
@@ -19,6 +23,16 @@
|
|
|
19
23
|
import type { Context } from '@cyanheads/mcp-ts-core';
|
|
20
24
|
import type { ObsidianService } from '../../../../services/obsidian/obsidian-service.js';
|
|
21
25
|
import type { NoteTarget } from '../../../../services/obsidian/types.js';
|
|
26
|
+
/** Outcome of {@link withCaseFallback}; `requestedPath` is present only when another path was read. */
|
|
27
|
+
export type CaseFallback<T> = {
|
|
28
|
+
result: T;
|
|
29
|
+
resolvedPath: string | undefined;
|
|
30
|
+
requestedPath?: never;
|
|
31
|
+
} | {
|
|
32
|
+
result: T;
|
|
33
|
+
resolvedPath: string;
|
|
34
|
+
requestedPath: string;
|
|
35
|
+
};
|
|
22
36
|
/**
|
|
23
37
|
* Wrap a service call with case-insensitive path fallback and "did you mean"
|
|
24
38
|
* enrichment. Non-path targets pass through — their paths are resolved
|
|
@@ -27,7 +41,7 @@ import type { NoteTarget } from '../../../../services/obsidian/types.js';
|
|
|
27
41
|
* For path targets:
|
|
28
42
|
* - **Exact match** → returns `{ result, resolvedPath: target.path }`.
|
|
29
43
|
* - **Single case match** → retries with the canonical path and returns
|
|
30
|
-
* `{ result, resolvedPath: <canonical
|
|
44
|
+
* `{ result, resolvedPath: <canonical>, requestedPath: target.path }`.
|
|
31
45
|
* - **Multiple case matches** → throws `Conflict` with the candidates so the
|
|
32
46
|
* agent can disambiguate.
|
|
33
47
|
* - **No case match, extension-stripped near-matches** → throws `NotFound`
|
|
@@ -36,17 +50,24 @@ import type { NoteTarget } from '../../../../services/obsidian/types.js';
|
|
|
36
50
|
*
|
|
37
51
|
* `resolvedPath` is `undefined` for non-path targets — callers derive the
|
|
38
52
|
* canonical path from the result itself (typically `NoteJson.path`).
|
|
53
|
+
* `requestedPath` is present only on the single-case-match branch.
|
|
39
54
|
*/
|
|
40
|
-
export declare function withCaseFallback<T>(ctx: Context, svc: ObsidianService, target: NoteTarget, fn: (target: NoteTarget) => Promise<T>): Promise<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
55
|
+
export declare function withCaseFallback<T>(ctx: Context, svc: ObsidianService, target: NoteTarget, fn: (target: NoteTarget) => Promise<T>): Promise<CaseFallback<T>>;
|
|
56
|
+
/**
|
|
57
|
+
* Disclose a `withCaseFallback` substitution on the caller's enrichment: the
|
|
58
|
+
* `requestedPath` field plus a one-line notice naming both paths. `action` is
|
|
59
|
+
* what the tool did with the canonical file. Returns the notice — `notice` is
|
|
60
|
+
* last-wins, so a caller that sets another one must fold this text into it —
|
|
61
|
+
* or `undefined` when nothing was substituted.
|
|
62
|
+
*/
|
|
63
|
+
export declare function discloseCaseSubstitution(ctx: Context, fallback: CaseFallback<unknown>, action: 'read' | 'opened'): string | undefined;
|
|
44
64
|
/**
|
|
45
65
|
* List the parent directory of `path` and return up to {@link MAX_SUGGESTIONS}
|
|
46
66
|
* close-match candidates. Match order: case-insensitive equality first, then
|
|
47
67
|
* extension-stripped equality. Returns `[]` on listing failure or empty
|
|
48
|
-
* basename. Used by callers that need suggestions without
|
|
49
|
-
*
|
|
68
|
+
* basename. Used by callers that need suggestions without substituting a
|
|
69
|
+
* match (e.g., `obsidian_delete_note`'s exact-case miss, which names the
|
|
70
|
+
* candidates but never deletes one in place of the requested path).
|
|
50
71
|
*/
|
|
51
72
|
export declare function findSimilarPaths(ctx: Context, svc: ObsidianService, path: string): Promise<string[]>;
|
|
52
73
|
//# sourceMappingURL=suggest-paths.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggest-paths.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-server/tools/definitions/_shared/suggest-paths.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"suggest-paths.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-server/tools/definitions/_shared/suggest-paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAW/D,uGAAuG;AACvG,MAAM,MAAM,YAAY,CAAC,CAAC,IACtB;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,aAAa,CAAC,EAAE,KAAK,CAAA;CAAE,GACtE;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/D;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,eAAe,EACpB,MAAM,EAAE,UAAU,EAClB,EAAE,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC,GACrC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAsC1B;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,OAAO,EACZ,QAAQ,EAAE,YAAY,CAAC,OAAO,CAAC,EAC/B,MAAM,EAAE,MAAM,GAAG,QAAQ,GACxB,MAAM,GAAG,SAAS,CAOpB;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,EAAE,CAAC,CAGnB"}
|
|
@@ -4,8 +4,12 @@
|
|
|
4
4
|
* 1. **Case-insensitive fallback.** If a path lookup 404s, list the parent
|
|
5
5
|
* directory and look for a single case-insensitive filename match. If
|
|
6
6
|
* found, retry against the canonical filesystem path (matches v2.x
|
|
7
|
-
* behavior)
|
|
8
|
-
*
|
|
7
|
+
* behavior) and report the path that was asked for as `requestedPath`, so
|
|
8
|
+
* the caller can disclose the substitution. The fallback is reachable on
|
|
9
|
+
* every host: the plugin's `note+json` and document-map reads resolve
|
|
10
|
+
* through Obsidian's case-sensitive vault index even on a case-insensitive
|
|
11
|
+
* filesystem (macOS, Windows). Only the raw-markdown read case-folds there,
|
|
12
|
+
* answering 200 for a wrong-case path before any fallback runs.
|
|
9
13
|
*
|
|
10
14
|
* 2. **"Did you mean" suggestions.** When no case match exists but the parent
|
|
11
15
|
* directory has near-matches (e.g., extension-stripped variants), re-throw
|
|
@@ -26,7 +30,7 @@ const MAX_SUGGESTIONS = 5;
|
|
|
26
30
|
* For path targets:
|
|
27
31
|
* - **Exact match** → returns `{ result, resolvedPath: target.path }`.
|
|
28
32
|
* - **Single case match** → retries with the canonical path and returns
|
|
29
|
-
* `{ result, resolvedPath: <canonical
|
|
33
|
+
* `{ result, resolvedPath: <canonical>, requestedPath: target.path }`.
|
|
30
34
|
* - **Multiple case matches** → throws `Conflict` with the candidates so the
|
|
31
35
|
* agent can disambiguate.
|
|
32
36
|
* - **No case match, extension-stripped near-matches** → throws `NotFound`
|
|
@@ -35,6 +39,7 @@ const MAX_SUGGESTIONS = 5;
|
|
|
35
39
|
*
|
|
36
40
|
* `resolvedPath` is `undefined` for non-path targets — callers derive the
|
|
37
41
|
* canonical path from the result itself (typically `NoteJson.path`).
|
|
42
|
+
* `requestedPath` is present only on the single-case-match branch.
|
|
38
43
|
*/
|
|
39
44
|
export async function withCaseFallback(ctx, svc, target, fn) {
|
|
40
45
|
if (target.type !== 'path') {
|
|
@@ -51,7 +56,7 @@ export async function withCaseFallback(ctx, svc, target, fn) {
|
|
|
51
56
|
const sole = probe.caseMatches.length === 1 ? probe.caseMatches[0] : undefined;
|
|
52
57
|
if (sole !== undefined) {
|
|
53
58
|
const result = await fn({ type: 'path', path: sole });
|
|
54
|
-
return { result, resolvedPath: sole };
|
|
59
|
+
return { result, resolvedPath: sole, requestedPath: target.path };
|
|
55
60
|
}
|
|
56
61
|
if (probe.caseMatches.length > 1) {
|
|
57
62
|
const list = probe.caseMatches.map((m) => `"${m}"`).join(', ');
|
|
@@ -69,12 +74,29 @@ export async function withCaseFallback(ctx, svc, target, fn) {
|
|
|
69
74
|
throw notFound(`${prefix}. Did you mean: ${list}?`, { ...(err.data ?? {}), suggestions }, { cause: err });
|
|
70
75
|
}
|
|
71
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Disclose a `withCaseFallback` substitution on the caller's enrichment: the
|
|
79
|
+
* `requestedPath` field plus a one-line notice naming both paths. `action` is
|
|
80
|
+
* what the tool did with the canonical file. Returns the notice — `notice` is
|
|
81
|
+
* last-wins, so a caller that sets another one must fold this text into it —
|
|
82
|
+
* or `undefined` when nothing was substituted.
|
|
83
|
+
*/
|
|
84
|
+
export function discloseCaseSubstitution(ctx, fallback, action) {
|
|
85
|
+
if (fallback.requestedPath === undefined)
|
|
86
|
+
return;
|
|
87
|
+
const { requestedPath, resolvedPath } = fallback;
|
|
88
|
+
const notice = `\`${requestedPath}\` has no exact match; ${action} \`${resolvedPath}\`, the one file in that folder whose name matches it ignoring case. Write and delete tools match paths exactly — pass them \`${resolvedPath}\`.`;
|
|
89
|
+
ctx.enrich({ requestedPath });
|
|
90
|
+
ctx.enrich.notice(notice);
|
|
91
|
+
return notice;
|
|
92
|
+
}
|
|
72
93
|
/**
|
|
73
94
|
* List the parent directory of `path` and return up to {@link MAX_SUGGESTIONS}
|
|
74
95
|
* close-match candidates. Match order: case-insensitive equality first, then
|
|
75
96
|
* extension-stripped equality. Returns `[]` on listing failure or empty
|
|
76
|
-
* basename. Used by callers that need suggestions without
|
|
77
|
-
*
|
|
97
|
+
* basename. Used by callers that need suggestions without substituting a
|
|
98
|
+
* match (e.g., `obsidian_delete_note`'s exact-case miss, which names the
|
|
99
|
+
* candidates but never deletes one in place of the requested path).
|
|
78
100
|
*/
|
|
79
101
|
export async function findSimilarPaths(ctx, svc, path) {
|
|
80
102
|
const probe = await probeParentDir(ctx, svc, path);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggest-paths.js","sourceRoot":"","sources":["../../../../../src/mcp-server/tools/definitions/_shared/suggest-paths.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"suggest-paths.js","sourceRoot":"","sources":["../../../../../src/mcp-server/tools/definitions/_shared/suggest-paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAI/F,MAAM,eAAe,GAAG,CAAC,CAAC;AAc1B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,GAAY,E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