Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
PRD-9201 Fix false link warnings in skip-named folders (#7438)
Andrew Mikofalvy2108b7828b20
diff --git a/.changeset/linked-file-skip-directories.md b/.changeset/linked-file-skip-directories.mdnew file mode 100644index 000000000..6e00d7fb3--- /dev/null+++ b/.changeset/linked-file-skip-directories.md@@ -0,0 +1,6 @@+---+'@inkeep/open-knowledge': patch+'@inkeep/open-knowledge-server': patch+---++Fix false broken-link warnings from agent writes and edits for existing source files in directories such as Applications, vendor, build, and dist.diff --git a/knip.config.ts b/knip.config.tsindex 0cdeeb401..1342c6bf1 100644--- a/knip.config.ts+++ b/knip.config.ts@@ -157,9 +157,7 @@ export default {'src/shadow-fixture-launch.test-helper.mjs',],project: 'src/**',- ignoreDependencies: [- '@types/shell-quote',- ],+ ignoreDependencies: ['@types/shell-quote'],},'packages/cli': {entry: [@@ -169,9 +167,7 @@ export default {'src/parse-worker.ts','src/bin.ts',],- ignoreDependencies: [- 'yjs',- ],+ ignoreDependencies: ['yjs'],},'packages/desktop': {entry: [diff --git a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts b/packages/app/tests/integration/bug3-source-mode-writeback.test.tsindex 4549c74b3..a50b00123 100644--- a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts+++ b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts@@ -1,4 +1,3 @@-import { readFileSync } from 'node:fs';import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';diff --git a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts b/packages/app/tests/integration/indented-jsx-byte-sacred.test.tsindex 4fc2c11f9..6fcdc23f2 100644--- a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts+++ b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts@@ -1,4 +1,3 @@-import { setTimeout as wait } from 'node:timers/promises';import { normalizeBridge } from '@inkeep/open-knowledge-core';import { updateYFragment } from '@tiptap/y-tiptap';diff --git a/packages/app/tests/integration/interior-edit-freshness.test.ts b/packages/app/tests/integration/interior-edit-freshness.test.tsindex 9f2f6feb6..40b5cdfd6 100644--- a/packages/app/tests/integration/interior-edit-freshness.test.ts+++ b/packages/app/tests/integration/interior-edit-freshness.test.ts@@ -1,4 +1,3 @@-import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts b/packages/app/tests/integration/keystroke-cadence-danger-space.test.tsindex 2a085742b..93666af70 100644--- a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts+++ b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts@@ -1,4 +1,3 @@-import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/link-authoring-contract.test.ts b/packages/app/tests/integration/link-authoring-contract.test.tsindex 1db13b426..a184042d4 100644--- a/packages/app/tests/integration/link-authoring-contract.test.ts+++ b/packages/app/tests/integration/link-authoring-contract.test.ts@@ -1,5 +1,6 @@import { randomUUID } from 'node:crypto';-import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';+import { mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';import { join } from 'node:path';import { afterAll, beforeAll, expect, test } from 'vitest';import { HARNESS_BOOT_TIMEOUT_MS } from './harness-boot-timeout';@@ -25,7 +26,7 @@ interface LocalTargetEvidence {interface BrokenLink {href: string;resolvedTo: string | null;- reason: 'no-such-doc' | 'no-such-file' | 'unresolvable';+ reason: 'no-such-doc' | 'no-such-file' | 'unresolvable' | 'excluded';localTarget?: LocalTargetEvidence;}@@ -214,6 +215,136 @@ test('write validates links to any file on disk, not just docs (source-file dept]);});+test.each(['write', 'edit'] as const)(+ '%s accepts a source-file link beneath a built-in skip directory',+ async (tool) => {+ const session = await openMcpSession(server.port);+ const uid = randomUUID().slice(0, 8);+ const existing = `Applications/probe-${uid}.java`;+ const missing = `Applications/missing-${uid}.java`;+ const image = `dist/logo-${uid}.png`;+ const documents = [`Applications/readme-${uid}.md`, `Applications/readme-${uid}.mdx`];+ mkdirSync(join(server.contentDir, 'Applications'), { recursive: true });+ writeFileSync(join(server.contentDir, existing), 'class Probe {}\n');+ mkdirSync(join(server.contentDir, 'dist'), { recursive: true });+ writeFileSync(join(server.contentDir, image), 'image\n');+ for (const document of documents) {+ writeFileSync(join(server.contentDir, document), '# Reference\n');+ }+ const docName = `wiki-${uid}/index`;+ const links = [+ `See [source](../${existing}), [missing](../${missing}) and [image file](../${image}).`,+ ...documents.map((path) => `[document](../${path})`),+ ``,+ ].join('\n');++ if (tool === 'edit') {+ const seeded = await callTool(+ server.port,+ session,+ 'write',+ { document: { path: docName, content: '# Module\n\nPlaceholder.\n', position: 'replace' } },+ server.contentDir,+ );+ expect(seeded.isError ?? false).toBe(false);+ }++ const document =+ tool === 'write'+ ? { path: docName, content: `# Module\n\n${links}\n`, position: 'replace' }+ : { path: docName, find: 'Placeholder.', replace: links };+ const result = await callTool(server.port, session, tool, { document }, server.contentDir);++ expect(result.isError ?? false).toBe(false);+ expect(docResult(result.structuredContent).brokenLinks).toEqual([+ { href: `../${missing}`, resolvedTo: missing, reason: 'no-such-file' },+ ...documents.map((path) => ({+ href: `../${path}`,+ resolvedTo: path.replace(/\.mdx?$/, ''),+ reason: 'no-such-doc',+ })),+ {+ href: `../${image}`,+ resolvedTo: image,+ reason: 'no-such-file',+ localTarget: {+ href: `../${image}`,+ targetKind: 'file',+ role: 'image',+ sourceForm: 'markdown-inline',+ resolvedTarget: image,+ reason: 'no-such-file',+ resolutionMethod: 'source-relative',+ },+ },+ ]);+ },+);++test.each(['write', 'edit'] as const)(+ '%s retains excluded advisories for links and images hidden by ignore files',+ async (tool) => {+ const contentDir = realpathSync(mkdtempSync(join(tmpdir(), 'ok-link-advisory-ignored-')));+ let ignoredServer: TestServer | undefined;+ try {+ mkdirSync(join(contentDir, '.ok'));+ writeFileSync(join(contentDir, '.ok', 'config.yml'), '');+ writeFileSync(join(contentDir, '.gitignore'), 'ignored-by-git/\n');+ writeFileSync(join(contentDir, '.okignore'), 'ignored-by-ok/\n');+ for (const folder of ['ignored-by-git', 'ignored-by-ok']) {+ mkdirSync(join(contentDir, folder));+ writeFileSync(join(contentDir, folder, 'notice.txt'), 'Notice\n');+ }+ ignoredServer = await createTestServer({ contentDir, debounce: 50, maxDebounce: 200 });+ const session = await openMcpSession(ignoredServer.port);+ const docName = `wiki-${randomUUID().slice(0, 8)}/index`;+ const links = [+ '[git](../ignored-by-git/notice.txt)',+ '[ok](../ignored-by-ok/notice.txt)',+ '',+ ].join('\n');+ if (tool === 'edit') {+ const seeded = await callTool(+ ignoredServer.port,+ session,+ 'write',+ {+ document: { path: docName, content: '# Module\n\nPlaceholder.\n', position: 'replace' },+ },+ contentDir,+ );+ expect(seeded.isError ?? false).toBe(false);+ }+ const document =+ tool === 'write'+ ? { path: docName, content: `# Module\n\n${links}\n`, position: 'replace' }+ : { path: docName, find: 'Placeholder.', replace: links };+ const result = await callTool(ignoredServer.port, session, tool, { document }, contentDir);++ expect(result.isError ?? false).toBe(false);+ const broken = docResult(result.structuredContent).brokenLinks as BrokenLink[];+ expect(+ broken.map(({ href, reason, localTarget }) => ({+ href,+ reason,+ role: localTarget?.role ?? 'link',+ })),+ ).toEqual([+ { href: '../ignored-by-git/notice.txt', reason: 'excluded', role: 'link' },+ { href: '../ignored-by-ok/notice.txt', reason: 'excluded', role: 'link' },+ { href: '../ignored-by-git/notice.txt', reason: 'excluded', role: 'image' },+ ]);+ } finally {+ try {+ await ignoredServer?.cleanup();+ } finally {+ rmSync(contentDir, { recursive: true, force: true });+ }+ }+ },+ HARNESS_BOOT_TIMEOUT_MS + 30_000,+);+test('edit (body find/replace) reports a broken link introduced by the edit', async () => {const session = await openMcpSession(server.port);const docName = `edited-${randomUUID().slice(0, 8)}`;diff --git a/packages/app/tests/integration/producer-guard-wiring.test.ts b/packages/app/tests/integration/producer-guard-wiring.test.tsindex 878d5196b..867598d34 100644--- a/packages/app/tests/integration/producer-guard-wiring.test.ts+++ b/packages/app/tests/integration/producer-guard-wiring.test.ts@@ -1,4 +1,3 @@-import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.tsindex 4ada3cf26..0970ac12f 100644--- a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts+++ b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts@@ -1,4 +1,3 @@-import { randomUUID } from 'node:crypto';import { afterEach, describe, expect, test } from 'vitest';import { agentWriteMd, createTestServer, type TestServer } from './test-harness';diff --git a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts b/packages/app/tests/integration/qa-045-restore-after-gc.test.tsindex cbe2b705f..b632185e1 100644--- a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts+++ b/packages/app/tests/integration/qa-045-restore-after-gc.test.ts@@ -1,4 +1,3 @@-import { execFileSync } from 'node:child_process';import { randomUUID } from 'node:crypto';import { join } from 'node:path';diff --git a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.tsindex 89bc9b4d9..c530ce4ba 100644--- a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts+++ b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts@@ -1,4 +1,3 @@-import { randomUUID } from 'node:crypto';import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest';import type * as Y from 'yjs';diff --git a/packages/app/tests/integration/undo-after-rollback.test.ts b/packages/app/tests/integration/undo-after-rollback.test.tsindex a78aeb0e4..d3767adc9 100644--- a/packages/app/tests/integration/undo-after-rollback.test.ts+++ b/packages/app/tests/integration/undo-after-rollback.test.ts@@ -1,4 +1,3 @@-import { ROLLBACK_ORIGIN } from '@inkeep/open-knowledge-server';import { afterAll, beforeAll, describe, expect, test } from 'vitest';import * as Y from 'yjs';diff --git a/packages/app/tests/integration/undo-recycle-reset.test.ts b/packages/app/tests/integration/undo-recycle-reset.test.tsindex e7cc69c3f..b076f955c 100644--- a/packages/app/tests/integration/undo-recycle-reset.test.ts+++ b/packages/app/tests/integration/undo-recycle-reset.test.ts@@ -1,4 +1,3 @@-import { writeFileSync } from 'node:fs';import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';diff --git a/packages/app/tests/integration/undo-rederive-survival.test.ts b/packages/app/tests/integration/undo-rederive-survival.test.tsindex 9ddcd0730..7935e35f8 100644--- a/packages/app/tests/integration/undo-rederive-survival.test.ts+++ b/packages/app/tests/integration/undo-rederive-survival.test.ts@@ -1,4 +1,3 @@-import { prependFrontmatter } from '@inkeep/open-knowledge-core';import { Plugin, PluginKey } from '@tiptap/pm/state';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';diff --git a/packages/core/src/bridge/compose.ts b/packages/core/src/bridge/compose.tsindex 2a597ec3d..f4cc8a286 100644--- a/packages/core/src/bridge/compose.ts+++ b/packages/core/src/bridge/compose.ts@@ -1,4 +1,3 @@-import { prependFrontmatter, stripFrontmatter } from '../extensions/frontmatter.ts';export type ComposeAdjustment = 'none' | 'body' | 'frontmatter' | 'unresolved';diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.tsindex ffd8fce06..e7e63f43d 100644--- a/packages/core/src/bridge/doc-boundary-space.ts+++ b/packages/core/src/bridge/doc-boundary-space.ts@@ -1,4 +1,3 @@-import { FRONTMATTER_RE, stripFrontmatter } from '../extensions/frontmatter.ts';import { carriedEdgeEmpties, type DocEdgeEmpties } from '../markdown/doc-edge-blank-runs.ts';diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.tsindex fb0ba5a7c..fc267cbea 100644--- a/packages/core/src/markdown/comment-promoter.ts+++ b/packages/core/src/markdown/comment-promoter.ts@@ -1,4 +1,3 @@-import type { Nodes, Paragraph, PhrasingContent, Root, RootContent, Text } from 'mdast';import { SKIP, visit } from 'unist-util-visit';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/merged-walker.ts b/packages/core/src/markdown/merged-walker.tsindex ae8cb390b..861003fb4 100644--- a/packages/core/src/markdown/merged-walker.ts+++ b/packages/core/src/markdown/merged-walker.ts@@ -1,4 +1,3 @@-import type { Nodes, Parent, Root } from 'mdast';import { SKIP, visit } from 'unist-util-visit';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/safe-url.ts b/packages/core/src/markdown/safe-url.tsindex 8be632ba4..4d3250d3a 100644--- a/packages/core/src/markdown/safe-url.ts+++ b/packages/core/src/markdown/safe-url.ts@@ -1,4 +1,3 @@-export const SAFE_URL_SCHEMES = ['https', 'http', 'mailto', 'tel', 'ftp', 'sms'] as const;const SCHEME_ALT = SAFE_URL_SCHEMES.map((s) => `${s}:`).join('|');diff --git a/packages/server/src/api-extension.ts b/packages/server/src/api-extension.tsindex 90dc01618..78f7c59d1 100644--- a/packages/server/src/api-extension.ts+++ b/packages/server/src/api-extension.ts@@ -2372,6 +2372,7 @@ export function createApiExtension(options: ApiExtensionOptions): Extension & {fileExists: createLinkedFileExists(),folderExists: createLinkedFolderExists(),fileExcluded: createLinkedFileExcluded(),+ imagePathExcluded: contentFilter?.isPathIgnored ?? null,resolveWikiFile: createLinkedWikiFileResolver(),resolveFileByBasename: createLinkedFileBasenameResolver(),};diff --git a/packages/server/src/local-target-inventory.test.ts b/packages/server/src/local-target-inventory.test.tsindex d4c833ef8..912ddd2c5 100644--- a/packages/server/src/local-target-inventory.test.ts+++ b/packages/server/src/local-target-inventory.test.ts@@ -1,7 +1,8 @@import { existsSync, mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';-import { join } from 'node:path';+import { dirname, join } from 'node:path';import { afterEach, describe, expect, test } from 'vitest';+import { createContentFilter } from './content-filter.ts';import type { AllFileEntries, FileIndexEntry, FolderIndexEntry } from './file-watcher.ts';import {createFileExistsOracle,@@ -292,6 +293,58 @@ describe('createFileExistsOracle', () => {expect(exists('missing.txt')).toBe(false);});+ test.each(['Applications/pom.xml', 'vendor/lib/source.java', 'build/output.txt', 'dist/app.js'])(+ 'accepts an existing file under a built-in skip directory: %s',+ (relativePath) => {+ const root = project();+ mkdirSync(dirname(join(root, relativePath)), { recursive: true });+ writeFileSync(join(root, relativePath), 'source\n');+ const filter = createContentFilter({ projectDir: root, contentDir: root });+ const exists = createFileExistsOracle([], root, filter);++ expect(filter.isPathIgnored(relativePath)).toBe(true);+ expect(exists(relativePath)).toBe(true);+ },+ );++ test('retains ignore-file exclusions for the excluded-target advisory', () => {+ const root = project();+ writeFileSync(join(root, '.gitignore'), 'ignored-by-git/\n');+ writeFileSync(join(root, '.okignore'), 'ignored-by-ok/\n');+ const paths = ['ignored-by-git/source.txt', 'ignored-by-ok/source.txt'];+ for (const path of paths) {+ mkdirSync(dirname(join(root, path)), { recursive: true });+ writeFileSync(join(root, path), 'source\n');+ }+ const filter = createContentFilter({ projectDir: root, contentDir: root });+ const exists = createFileExistsOracle([], root, filter);++ for (const path of paths) {+ expect(filter.isPathIgnored(path)).toBe(true);+ expect(exists(path)).toBe(false);+ }+ });++ test.each([+ '.env',+ '.env.local',+ '.ssh/id_rsa',+ '.aws/credentials',+ '.git/config',+ '.ok/config.yml',+ '.claude/settings.json',+ 'node_modules/pkg/index.js',+ '__system__.md',+ '__config__/project.md',+ ])('refuses an existing protected file: %s', (relativePath) => {+ const root = project();+ mkdirSync(dirname(join(root, relativePath)), { recursive: true });+ writeFileSync(join(root, relativePath), 'protected\n');+ const filter = createContentFilter({ projectDir: root, contentDir: root });++ expect(createFileExistsOracle([], root, filter)(relativePath)).toBe(false);+ });+test('never accepts a directory as an existing file', () => {const exists = createFileExistsOracle([], project(), undefined);expect(exists('Sub')).toBe(false);@@ -301,6 +354,7 @@ describe('createFileExistsOracle', () => {test('refuses an ignored path', () => {const exists = createFileExistsOracle([], project(), {isPathIgnored: (path) => path === 'Makefile',+ isExcludedByIgnoreFiles: () => false,});expect(exists('Makefile')).toBe(false);});diff --git a/packages/server/src/local-target-inventory.ts b/packages/server/src/local-target-inventory.tsindex 4ee1f3fad..4486ba189 100644--- a/packages/server/src/local-target-inventory.ts+++ b/packages/server/src/local-target-inventory.ts@@ -167,13 +167,15 @@ export function createFileBasenameResolver(export function createFileExistsOracle(fileTargets: Iterable<string>,contentDir: string,- contentFilter: Pick<ContentFilter, 'isPathIgnored'> | undefined,+ contentFilter: Pick<ContentFilter, 'isPathIgnored' | 'isExcludedByIgnoreFiles'> | undefined,): (contentRootRelativePath: string) => boolean {const admittedFiles = asTargetNamespace('file', fileTargets);const canonicalContentDir = realpathSync(contentDir);return (contentRootRelativePath) => {if (admittedFiles.resolve(contentRootRelativePath) !== undefined) return true;- if (contentFilter?.isPathIgnored(contentRootRelativePath)) return false;+ if (contentFilter?.isPathIgnored(contentRootRelativePath, { bypassFilters: true }))+ return false;+ if (contentFilter?.isExcludedByIgnoreFiles(contentRootRelativePath)) return false;const candidate = resolve(contentDir, contentRootRelativePath);if (!isWithinDir(candidate, contentDir)) return false;diff --git a/packages/server/src/write-advisory-links.test.ts b/packages/server/src/write-advisory-links.test.tsindex bd2d026fd..cf6f7c60c 100644--- a/packages/server/src/write-advisory-links.test.ts+++ b/packages/server/src/write-advisory-links.test.ts@@ -9,6 +9,7 @@ const NO_TARGETS: WriteAdvisoryTargets = {fileExists: null,folderExists: null,fileExcluded: null,+ imagePathExcluded: null,resolveWikiFile: null,resolveFileByBasename: null,};@@ -17,6 +18,7 @@ const NOTHING_TRACKED: WriteAdvisoryTargets = {fileExists: () => false,folderExists: () => false,fileExcluded: () => false,+ imagePathExcluded: () => false,resolveWikiFile: () => undefined,resolveFileByBasename: () => undefined,};@@ -97,6 +99,36 @@ describe('computeWriteAdvisoryLinks', () => {] satisfies WriteAdvisoryLink[]);});+ test('retains the unavailable-image warning without flagging a plain link to its existing file', () => {+ const links = computeWriteAdvisoryLinks(+ '[source](./dist/logo.png)\n\n',+ 'notes',+ new Set<string>(),+ {+ ...NOTHING_TRACKED,+ fileExists: fileOracle('dist/logo.png'),+ imagePathExcluded: (path) => path === 'dist/logo.png',+ },+ );++ expect(links).toEqual([+ {+ href: './dist/logo.png',+ resolvedTo: 'dist/logo.png',+ reason: 'no-such-file',+ localTarget: {+ href: './dist/logo.png',+ targetKind: 'file',+ role: 'image',+ sourceForm: 'markdown-inline',+ resolvedTarget: 'dist/logo.png',+ reason: 'no-such-file',+ resolutionMethod: 'source-relative',+ },+ },+ ] satisfies WriteAdvisoryLink[]);+ });+test('adds a missing HTML img source as an html-img image finding', () => {const links = computeWriteAdvisoryLinks('<img src="./banner.png" alt="banner">\n',@@ -401,13 +433,14 @@ describe('file targets that exist but are excluded by ignore rules (PRD-8896)',const links = computeWriteAdvisoryLinks('[d](./ig.png)\n', 'notes', new Set<string>(), {...NOTHING_TRACKED,fileExcluded: null,+ imagePathExcluded: null,});expect(links).toEqual([]);});});describe('a null capability gives the targets it judges no verdict, never missing (PRD-8896)', () => {- const rows: Array<[keyof WriteAdvisoryTargets, string, string[]]> = [+ const rows: Array<[keyof WriteAdvisoryTargets, string, string[], WriteAdvisoryTargets?]> = [['fileExists', 'See  and [m](./Makefile).\n', ['./Makefile', './i.png']],['folderExists', 'See [dir](./assets) and [[assets]].\n', ['./assets', '[[assets]]']],[@@ -415,6 +448,16 @@ describe('a null capability gives the targets it judges no verdict, never missin'See [d](./ig.png),  and [m](./Makefile).\n',['./ig.png', './Makefile', './ig.png'],],+ [+ 'imagePathExcluded',+ '\n',+ ['./i.png'],+ {+ ...NOTHING_TRACKED,+ fileExists: fileOracle('i.png'),+ imagePathExcluded: (path) => path === 'i.png',+ },+ ],['resolveWikiFile', 'See ![[Images/cat.png]].\n', ['Images/cat.png']],['resolveFileByBasename', 'See ![[cat.png]].\n', ['cat.png']],];@@ -423,12 +466,12 @@ describe('a null capability gives the targets it judges no verdict, never missinexpect(rows.map(([capability]) => capability).sort()).toEqual(Object.keys(NO_TARGETS).sort());});- for (const [capability, md, reportedWhenNothingIsTracked] of rows) {- test(`${capability}: null withholds what an oracle that knows nothing would report`, () => {+ for (const [capability, md, expectedHrefs, knownTargets = NOTHING_TRACKED] of rows) {+ test(`${capability}: null withholds the verdict that requires it`, () => {const hrefs = (targets: WriteAdvisoryTargets): string[] =>computeWriteAdvisoryLinks(md, 'notes', new Set<string>(), targets).map((link) => link.href);- expect(hrefs(NOTHING_TRACKED)).toEqual(reportedWhenNothingIsTracked);- expect(hrefs({ ...NOTHING_TRACKED, [capability]: null })).toEqual([]);+ expect(hrefs(knownTargets)).toEqual(expectedHrefs);+ expect(hrefs({ ...knownTargets, [capability]: null })).toEqual([]);});}});diff --git a/packages/server/src/write-advisory-links.ts b/packages/server/src/write-advisory-links.tsindex 577ea050f..c3f0723bd 100644--- a/packages/server/src/write-advisory-links.ts+++ b/packages/server/src/write-advisory-links.ts@@ -23,6 +23,7 @@ export interface WriteAdvisoryTargets {fileExists: ((contentRootRelativePath: string) => boolean) | null;folderExists: ((folderPath: string) => boolean) | null;fileExcluded: ((contentRootRelativePath: string) => boolean) | null;+ imagePathExcluded: ((contentRootRelativePath: string) => boolean) | null;resolveWikiFile: ((contentRootRelativePath: string) => string | undefined) | null;resolveFileByBasename: ((basename: string, sourceDocName: string) => string | undefined) | null;}@@ -109,9 +110,19 @@ export function computeWriteAdvisoryLinks(const seenRepairSites = new Set<string>();for (const assessment of assessments) {- if (assessment.reason === null) continue;+ let reason = assessment.reason;+ if (+ reason === null &&+ assessment.targetKind === 'file' &&+ assessment.occurrence.role === 'image' &&+ assessment.resolvedTarget !== null &&+ targets.imagePathExcluded?.(assessment.resolvedTarget) === true+ ) {+ reason = 'no-such-file';+ }+ if (reason === null) continue;const verdict = hasVerdict(targets, {- reason: assessment.reason,+ reason,targetKind: assessment.targetKind,wikiAsset: wikiAssetName(assessment.occurrence) !== null,mayNameFile: !isWikiForm(assessment.occurrence.sourceForm),@@ -119,7 +130,7 @@ export function computeWriteAdvisoryLinks(if (!verdict) continue;const { href, role, sourceForm, range, reference } = assessment.occurrence;if (role === 'link' && sourceForm === 'markdown-inline' && graphHrefs.has(href)) continue;- const localTarget = buildLocalTargetEvidence(assessment, assessment.reason);+ const localTarget = buildLocalTargetEvidence(assessment, reason);if (localTarget === null) continue;const repairRange = reference?.definition.repairRange ?? range;const repairSite = `${repairRange.start}:${repairRange.end}`;@@ -128,7 +139,7 @@ export function computeWriteAdvisoryLinks(links.push({href,resolvedTo: assessment.resolvedTarget,- reason: assessment.reason,+ reason,localTarget,});}diff --git a/packages/server/src/write-advisory-links.type-tests.ts b/packages/server/src/write-advisory-links.type-tests.tsindex 6d5c8e3a3..c591c4d47 100644--- a/packages/server/src/write-advisory-links.type-tests.ts+++ b/packages/server/src/write-advisory-links.type-tests.ts@@ -3,6 +3,7 @@ import type { WriteAdvisoryTargets } from './write-advisory-links.ts';const fileCapabilities = {fileExists: () => false,fileExcluded: () => false,+ imagePathExcluded: () => false,resolveWikiFile: () => undefined,resolveFileByBasename: () => undefined,};@@ -14,6 +15,7 @@ const _optsOutOfFiles: WriteAdvisoryTargets = {fileExists: null,folderExists: () => false,fileExcluded: null,+ imagePathExcluded: null,resolveWikiFile: null,resolveFileByBasename: null,};