mirror of
https://github.com/aaronsb/obsidian-mcp-plugin.git
synced 2026-07-22 06:45:14 +00:00
`vault combine` without a `destination` now returns the combined content
inline in the response instead of erroring. Read-only consumers can use
combine for multi-file retrieval with no side effects.
- router.ts: no-destination path returns { inline, content, ... }; the
destination-exists guard is skipped when there is no destination.
- formatters/vault.ts: FileCombineResponse gains optional destination +
inline/content; formatFileCombine renders an inline block.
- semantic-tools.ts: combine counts as a write-op (blocked in read-only
mode) only when a destination is given; param description updated.
- tests: formatter inline/destination/fallback coverage.
Reimplemented from PR #146 against current `main` (code only); supersedes
and closes out #146. Dropped the original PR's
`path: destination || '_inline_'` validator workaround — the batch.combine
validators (BatchLimitValidator, PathArrayValidator) never inspect `path`,
so the hack was unnecessary. The README/troubleshooting cert-trust docs
that #146 also carried are covered by the #143 reimplementation instead, to
avoid duplicate divergent copies.
Co-authored-by: Earl Plak <5597016+laplaque@users.noreply.github.com>
53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
import { formatFileCombine, FileCombineResponse } from '../src/formatters/vault';
|
|
|
|
describe('formatFileCombine — inline (no destination) mode', () => {
|
|
test('renders combined content inline without a Destination line', () => {
|
|
const response: FileCombineResponse = {
|
|
success: true,
|
|
inline: true,
|
|
content: 'alpha\n\n---\n\nbeta',
|
|
filesCombined: 2,
|
|
totalSize: 16,
|
|
sourceFiles: ['a.md', 'b.md'],
|
|
};
|
|
|
|
const out = formatFileCombine(response);
|
|
|
|
expect(out).toContain('Combined 2 files (inline)');
|
|
expect(out).toContain('alpha');
|
|
expect(out).toContain('beta');
|
|
// Inline mode wrote no file, so it must not claim a destination
|
|
expect(out).not.toContain('Destination');
|
|
});
|
|
|
|
test('still renders destination mode when a destination is present', () => {
|
|
const response: FileCombineResponse = {
|
|
success: true,
|
|
destination: 'combined.md',
|
|
filesCombined: 2,
|
|
totalSize: 16,
|
|
sourceFiles: ['a.md', 'b.md'],
|
|
};
|
|
|
|
const out = formatFileCombine(response);
|
|
|
|
expect(out).toContain('Combined: combined.md');
|
|
expect(out).toContain('Destination');
|
|
expect(out).not.toContain('(inline)');
|
|
});
|
|
|
|
test('inline branch requires content to be defined', () => {
|
|
// inline:true but content undefined falls through to destination mode
|
|
const response: FileCombineResponse = {
|
|
success: true,
|
|
inline: true,
|
|
destination: 'fallback.md',
|
|
filesCombined: 1,
|
|
};
|
|
|
|
const out = formatFileCombine(response);
|
|
|
|
expect(out).toContain('Combined: fallback.md');
|
|
expect(out).not.toContain('(inline)');
|
|
});
|
|
});
|