1+ import fs from "node:fs/promises" ;
2+ import path from "node:path" ;
13import { describe , expect , it } from "vitest" ;
24import type { ResolvedMemoryWikiConfig } from "./config.js" ;
3- import { createWikiApplyTool } from "./tool.js" ;
5+ import { renderWikiMarkdown } from "./markdown.js" ;
6+ import { createMemoryWikiTestHarness } from "./test-helpers.js" ;
7+ import { createWikiApplyTool , createWikiLintTool } from "./tool.js" ;
8+
9+ const { createVault } = createMemoryWikiTestHarness ( ) ;
410
511function asSchemaObject ( value : unknown ) : Record < string , unknown > {
612 if ( typeof value !== "object" || value === null || Array . isArray ( value ) ) {
@@ -10,6 +16,44 @@ function asSchemaObject(value: unknown): Record<string, unknown> {
1016}
1117
1218describe ( "memory-wiki tools" , ( ) => {
19+ it ( "returns relative bounded details from wiki_lint" , async ( ) => {
20+ const { rootDir, config } = await createVault ( {
21+ prefix : "memory-wiki-tool-lint-" ,
22+ config : {
23+ vault : { renderMode : "obsidian" } ,
24+ } ,
25+ } ) ;
26+ await fs . mkdir ( path . join ( rootDir , "entities" ) , { recursive : true } ) ;
27+ await fs . writeFile (
28+ path . join ( rootDir , "entities" , "alpha.md" ) ,
29+ renderWikiMarkdown ( {
30+ frontmatter : {
31+ pageType : "entity" ,
32+ id : "entity.alpha" ,
33+ title : "Alpha" ,
34+ } ,
35+ body : "# Alpha\n\n[[missing-page]]\n" ,
36+ } ) ,
37+ "utf8" ,
38+ ) ;
39+
40+ const tool = createWikiLintTool ( config ) ;
41+ const result = await tool . execute ( "call-1" , { } ) ;
42+ const text = result . content
43+ . map ( ( entry ) => ( entry . type === "text" ? entry . text : "" ) )
44+ . join ( "\n" ) ;
45+ const details = asSchemaObject ( result . details ) ;
46+
47+ expect ( text ) . toContain ( "Report: reports/lint.md" ) ;
48+ expect ( text ) . not . toContain ( rootDir ) ;
49+ expect ( details . reportPath ) . toBe ( "reports/lint.md" ) ;
50+ expect ( details ) . not . toHaveProperty ( "vaultRoot" ) ;
51+ expect ( JSON . stringify ( details ) ) . not . toContain ( rootDir ) ;
52+ expect ( asSchemaObject ( details . issuesByCategory ) . links ) . toEqual (
53+ expect . arrayContaining ( [ expect . objectContaining ( { code : "broken-wikilink" } ) ] ) ,
54+ ) ;
55+ } ) ;
56+
1357 it ( "allows provenance metadata in wiki_apply claim evidence" , ( ) => {
1458 const tool = createWikiApplyTool ( { } as ResolvedMemoryWikiConfig ) ;
1559 const applyProperties = asSchemaObject ( asSchemaObject ( tool . parameters ) . properties ) ;
0 commit comments