Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
fix(ok): stop agent reads from taking over the workspace tab (PRD-8012) (#3789)
Abraham811bf16422d2
diff --git a/.changeset/prd-8012-acp-reads-dont-take-over-tab.md b/.changeset/prd-8012-acp-reads-dont-take-over-tab.mdnew file mode 100644index 000000000..7c2044f67--- /dev/null+++ b/.changeset/prd-8012-acp-reads-dont-take-over-tab.md@@ -0,0 +1,5 @@+---+"@inkeep/open-knowledge": patch+---++Agent-side reads (`exec cat`, `search`, native reads) no longer take over the workspace tab. Follow-the-file now only reacts to write-shaped tool calls, so Claude exploring the doc index while it works can't yank you off what you were reading.diff --git a/knip.config.ts b/knip.config.tsindex b61debe5e..8ad68f996 100644--- a/knip.config.ts+++ b/knip.config.ts@@ -124,7 +124,9 @@ export default {'packages/server': {entry: ['src/**/*.test.ts', 'src/parse-worker.ts'],project: 'src/**',- ignoreDependencies: ['@types/shell-quote'],+ ignoreDependencies: [+ '@types/shell-quote',+ ],},'packages/cli': {entry: ['src/**/*.test.ts', 'scripts/*.ts', 'tests/**/*.ts', 'src/parse-worker.ts'],diff --git a/packages/app/src/components/acp/ThreadView.tsx b/packages/app/src/components/acp/ThreadView.tsxindex c1318e6fd..ac38e495d 100644--- a/packages/app/src/components/acp/ThreadView.tsx+++ b/packages/app/src/components/acp/ThreadView.tsx@@ -159,7 +159,6 @@ import {INITIAL_FOLLOW_NAV_STATE,latestFollowTarget,loadFollowFilePref,- pageListFollowOptions,saveFollowFilePref,} from './follow-file';import { PlanChecklist } from './PlanChecklist';@@ -542,18 +541,12 @@ export function ThreadView({// Mid-turn sends don't reject anymore — the server queues them behind the// active turn and drains FIFO (`ThreadInfo.queue`).const canQueue = !archived && turnActive;- // Read-shaped follow targets (exec `cat foo.md`, or a non-`edit` call's- // newest location) only navigate to docs that exist — a read of a missing- // file would open a blank create-on-open tab. `pageListFollowOptions`- // arms the predicate only when the page-list snapshot is authoritative;- // the exact loading/error rules live at the helper (unit-tested there).- // Extract `pageList` once and drive both follow-file (page-existence- // check) and the doc-path-link resolver from the same snapshot — avoids- // two independent `useOptionalPageList` sites racing to consume it, and- // avoids per-message `useWorkspace` calls that would each fire a+ // Extract `pageList` once for the doc-path-link resolver. Follow-the-file+ // reads nothing from it any more — only write-shaped tool calls drive+ // navigation, so there is no "does the doc exist" gate left to arm. Kept+ // here to avoid per-message `useWorkspace` calls that would each fire a// `/api/workspace` fetch on web hosts.const pageList = useOptionalPageList();- const followOptions = pageListFollowOptions(pageList);// Trust the last-known `pages` set even when the provider surfaces an// `error` from a background refetch: `PageListProvider.refetch` fires on// window focus / visibilitychange / CC1 `files` push and, on failure, sets@@ -571,8 +564,7 @@ export function ThreadView({// ThreadView derives from the same workspace + page list).setDocPathResolver(docPathResolver);const resolverReady = docPathResolver !== null;- const transcriptFollowTarget =- model !== null ? latestFollowTarget(model.items, workspace, followOptions) : null;+ const transcriptFollowTarget = model !== null ? latestFollowTarget(model.items, workspace) : null;// Presence-derived write stream — the fallback when the transcript is// informationally empty (some adapters send rawInput {} and no locationsdiff --git a/packages/app/src/components/acp/doc-path-links.ts b/packages/app/src/components/acp/doc-path-links.tsindex 1300d6928..66493d932 100644--- a/packages/app/src/components/acp/doc-path-links.ts+++ b/packages/app/src/components/acp/doc-path-links.ts@@ -3,8 +3,7 @@* the docs they name. The resolver classifies a candidate string against* three shapes, in order, and only returns a docName the workspace's page* list actually contains — an unresolvable path stays plain text so we- * never route the user to a create-on-open blank tab (the same trap the- * follow-the-file predicate arms against).+ * never route the user to a create-on-open blank tab.** The three shapes agents write:*diff --git a/packages/app/src/components/acp/follow-file.test.ts b/packages/app/src/components/acp/follow-file.test.tsindex 944d80132..c8dbe8fe9 100644--- a/packages/app/src/components/acp/follow-file.test.ts+++ b/packages/app/src/components/acp/follow-file.test.ts@@ -8,7 +8,6 @@ import {followTargetFromToolCall,INITIAL_FOLLOW_NAV_STATE,latestFollowTarget,- pageListFollowOptions,} from './follow-file';const posix: Workspace = { contentDir: '/home/me/notes', pathSeparator: '/' };@@ -156,6 +155,39 @@ describe('followTargetFromToolCall', () => {).toBeNull();});+ test.each([+ 'read',+ 'search',+ 'execute',+ 'other',+ ] as const)('flat docName on a %s-shaped tool call never follows', (kind) => {+ // A `history` call could carry `arguments: { docName }` on a+ // future / renamed adapter; today its wire schema uses `document`.+ // The gate is defensive coverage for adapter drift — every+ // read-shaped ACP toolKind must refuse to follow the flat shape.+ expect(+ followTargetFromToolCall(+ call({+ toolKind: kind,+ rawInput: {+ server: 'open-knowledge',+ tool: 'history',+ arguments: { docName: 'notes/today' },+ },+ }),+ posix,+ ),+ ).toBeNull();+ // Bare-arg adapter (no tool name) on the same read kind: unknown tool+ // + non-write kind = safe default is null.+ expect(+ followTargetFromToolCall(+ call({ toolKind: kind, rawInput: { docName: 'notes/today' } }),+ posix,+ ),+ ).toBeNull();+ });+test('flat docName argument shape also resolves', () => {const target = followTargetFromToolCall(call({@@ -284,39 +316,47 @@ describe('followTargetFromToolCall', () => {});});-describe('followTargetFromToolCall — exec command strings', () => {- test('command reads of MISSING docs never navigate; write targets are not gated', () => {- // Live-run regression: the agent ran `cat log.md` on a doc that was never- // created, and follow parked the editor on a blank create-on-open tab.- const missingRead = call({- rawInput: { tool: 'exec', arguments: { command: 'cat log.md' } },- });- const exists = (docName: string) => docName !== 'log';- expect(followTargetFromToolCall(missingRead, posix, { docExists: exists })).toBeNull();- // The same read WITH the doc present follows normally.- expect(followTargetFromToolCall(missingRead, posix, { docExists: () => true })).toBe('log');- // No predicate (page list still loading) → ungated, previous behavior.- expect(followTargetFromToolCall(missingRead, posix)).toBe('log');- // Write targets may name docs that don't exist YET — never gated.- expect(- followTargetFromToolCall(- call({- rawInput: {- tool: 'write',- arguments: { document: { path: 'brand/new-page' } },- },- }),- posix,- { docExists: () => false },- ),- ).toBe('brand/new-page');- });-- test('latestFollowTarget falls back past a gated command read to the last write', () => {+describe('followTargetFromToolCall — exec commands never follow', () => {+ // An agent-side `exec cat notes.md` used to open notes.md in the workspace+ // and blow away whatever the user was on. Only user gestures move the+ // active doc now — every `exec`/shell shape below yields null, regardless+ // of the command head, path shape, or whether the doc exists.+ test.each([+ [+ 'cat with a relative markdown path',+ { tool: 'exec', arguments: { command: 'cat specs/foo/SPEC.md' } },+ ],+ [+ 'quoted paths with spaces',+ { tool: 'exec', arguments: { command: 'cat "my notes/plan.md"' } },+ ],+ ['leading ./ normalization', { tool: 'exec', arguments: { command: 'head -25 ./readme.md' } }],+ [+ 'flags-then-md operand',+ { tool: 'exec', arguments: { command: 'grep -rn oauth articles/auth.md' } },+ ],+ ['globs', { tool: 'exec', arguments: { command: 'head -25 specs/*/SPEC.md' } }],+ ['directory listing', { tool: 'exec', arguments: { command: 'ls specs/' } }],+ ['destructive head', { tool: 'exec', arguments: { command: 'rm wiki/tea.md' } }],+ [+ 'absolute in-workspace path',+ { tool: 'exec', arguments: { command: 'cat /home/me/notes/wiki/tea.md' } },+ ],+ [+ 'absolute out-of-workspace path',+ { tool: 'exec', arguments: { command: 'cat /etc/motd.md' } },+ ],+ ['piped md operand', { tool: 'exec', arguments: { command: 'cat notes.md | head -5' } }],+ ['bare command field (native terminal)', { command: 'cat wiki/tea.md' }],+ ])('%s never follows', (_label, rawInput) => {+ expect(followTargetFromToolCall(call({ toolKind: 'execute', rawInput }), posix)).toBeNull();+ });++ test('latestFollowTarget picks up the most recent write while ignoring intervening reads', () => {const items = [{kind: 'tool_call',- toolKind: 'execute',+ toolKind: 'edit',title: 'write',locations: [],rawInput: { tool: 'write', arguments: { documents: [{ path: 'articles/caffeine' }] } },@@ -329,177 +369,29 @@ describe('followTargetFromToolCall — exec command strings', () => {rawInput: { tool: 'exec', arguments: { command: 'cat log.md' } },},];- expect(latestFollowTarget(items, posix, { docExists: (d) => d !== 'log' })).toBe(- 'articles/caffeine',- );- });-- test('cat with a relative markdown path', () => {- expect(- followTargetFromToolCall(- call({ rawInput: { tool: 'exec', arguments: { command: 'cat specs/foo/SPEC.md' } } }),- posix,- ),- ).toBe('specs/foo/SPEC');- });-- test('quoted paths with spaces', () => {- expect(- followTargetFromToolCall(- call({ rawInput: { tool: 'exec', arguments: { command: 'cat "my notes/plan.md"' } } }),- posix,- ),- ).toBe('my notes/plan');- });-- test('leading ./ is normalized', () => {- expect(- followTargetFromToolCall(- call({ rawInput: { tool: 'exec', arguments: { command: 'head -25 ./readme.md' } } }),- posix,- ),- ).toBe('readme');- });-- test('flags are skipped; the first md operand wins', () => {- expect(- followTargetFromToolCall(- call({- rawInput: { tool: 'exec', arguments: { command: 'grep -rn oauth articles/auth.md' } },- }),- posix,- ),- ).toBe('articles/auth');- });-- test('globs carry no single target', () => {- expect(- followTargetFromToolCall(- call({ rawInput: { tool: 'exec', arguments: { command: 'head -25 specs/*/SPEC.md' } } }),- posix,- ),- ).toBeNull();- });-- test('directory listings carry no doc target', () => {- expect(- followTargetFromToolCall(- call({ rawInput: { tool: 'exec', arguments: { command: 'ls specs/' } } }),- posix,- ),- ).toBeNull();- });-- test('non-read command heads never navigate', () => {- expect(- followTargetFromToolCall(- call({ rawInput: { tool: 'exec', arguments: { command: 'rm wiki/tea.md' } } }),- posix,- ),- ).toBeNull();- });-- test('absolute in-workspace paths map through the workspace root', () => {- expect(- followTargetFromToolCall(- call({- rawInput: { tool: 'exec', arguments: { command: 'cat /home/me/notes/wiki/tea.md' } },- }),- posix,- ),- ).toBe('wiki/tea');- });-- test('absolute out-of-workspace paths resolve to null', () => {- expect(- followTargetFromToolCall(- call({ rawInput: { tool: 'exec', arguments: { command: 'cat /etc/motd.md' } } }),- posix,- ),- ).toBeNull();- });-- test('pipes: an md operand anywhere in the pipeline is found', () => {- expect(- followTargetFromToolCall(- call({ rawInput: { tool: 'exec', arguments: { command: 'cat notes.md | head -5' } } }),- posix,- ),- ).toBe('notes');+ expect(latestFollowTarget(items, posix)).toBe('articles/caffeine');});+});- test('a native terminal command (bare command field) also follows', () => {+describe('followTargetFromToolCall — location-based follow is write-only', () => {+ // Only `edit` and `move` locations drive navigation. Read/search/execute/+ // other tool kinds surface locations for context, but they never yank the+ // workspace tab.+ test.each([+ 'execute',+ 'search',+ 'other',+ 'read',+ ] as const)('%s never navigates from its locations (even when the doc exists)', (kind) => {expect(followTargetFromToolCall(- call({ toolKind: 'execute', rawInput: { command: 'cat wiki/tea.md' } }),+ call({ toolKind: kind, locations: [{ path: '/home/me/notes/main.md' }] }),posix,),- ).toBe('wiki/tea');- });-});--describe('followTargetFromToolCall — location existence gate', () => {- test('a non-edit call whose newest location is a MISSING doc never navigates', () => {- // Live-run regression: a read-shaped tool call resolved to a phantom doc- // ("main"), and follow parked the editor on a blank create-on-open tab.- // Read/search/exec locations are gated on existence.- const missingLocation = call({- toolKind: 'read',- locations: [{ path: '/home/me/notes/main.md' }],- });- const exists = (docName: string) => docName !== 'main';- expect(followTargetFromToolCall(missingLocation, posix, { docExists: exists })).toBeNull();- // The same read WITH the doc present follows normally.- expect(followTargetFromToolCall(missingLocation, posix, { docExists: () => true })).toBe(- 'main',- );- // No predicate (page list still loading) → ungated, previous behavior.- expect(followTargetFromToolCall(missingLocation, posix)).toBe('main');- });-- test('non-edit locations gate at the newest miss — no fall-through to an older valid location', () => {- // Per-call semantic: on a gated miss the newest location wins the veto- // and the call yields null; the loop must NOT `continue` to an older- // location. A "be more helpful" refactor that swapped `return null` for- // `continue` would let the editor silently follow a stale older path,- // and the transcript-level `latestFollowTarget` fall-back (its own test- // below) would never get a chance to route to the previous tool call.- const missingNewest = call({- toolKind: 'read',- locations: [- { path: '/home/me/notes/articles/existing.md' },- { path: '/home/me/notes/main.md' },- ],- });- expect(- followTargetFromToolCall(missingNewest, posix, { docExists: (d) => d !== 'main' }),).toBeNull();});- test('every read-shaped toolKind (execute/search/other/read) is gated on location existence', () => {- // The gate is `toolKind !== 'edit' && toolKind !== 'move'` — a narrowing- // to `toolKind === 'read'` would re-open the phantom-tab class for- // execute/search/other calls. The original live-run was an execute-shaped- // call whose newest location resolved to `main`. Table-drive over the- // read-shaped kinds so a future kind (`browse`?) needing exemption is- // explicit at THIS gate, not silently masked.- const gated = (docName: string) => docName !== 'main';- for (const kind of ['execute', 'search', 'other', 'read'] as const) {- const c = call({- toolKind: kind,- locations: [{ path: '/home/me/notes/main.md' }],- });- expect(followTargetFromToolCall(c, posix, { docExists: gated })).toBeNull();- }- });-- test('a move call names the destination — its location stays ungated (the rename case)', () => {- // `move`'s newest location IS the destination path — by definition not- // in the page list yet — so gating it on existence would suppress the- // follow of every rename. The MCP path already treats `stringField(args,- // 'to')` as write-shaped (ungated); the native-locations path must- // agree. Without this exemption, `ok mv old new` reported through- // `locations[]` would silently stop following once the rename lands.+ test('a move call names the destination — its location follows even when the doc does not exist yet', () => {expect(followTargetFromToolCall(call({@@ -507,24 +399,20 @@ describe('followTargetFromToolCall — location existence gate', () => {locations: [{ path: '/home/me/notes/renamed/destination.md' }],}),posix,- { docExists: () => false },),).toBe('renamed/destination');});- test('an edit call may name a doc that does not exist YET — its location is not gated', () => {- // The create case: a native write/edit names the doc it is about to- // create, so following it before it lands is correct.+ test('an edit call may name a doc that does not exist YET — its location still follows', () => {expect(followTargetFromToolCall(call({ toolKind: 'edit', locations: [{ path: '/home/me/notes/brand/new-page.md' }] }),posix,- { docExists: () => false },),).toBe('brand/new-page');});- test('latestFollowTarget falls back past a gated missing read location to the last write', () => {+ test('latestFollowTarget ignores a read location and lands on the last write', () => {const items = [{kind: 'tool_call',@@ -541,9 +429,7 @@ describe('followTargetFromToolCall — location existence gate', () => {rawInput: undefined,},];- expect(latestFollowTarget(items, posix, { docExists: (d) => d !== 'main' })).toBe(- 'articles/caffeine',- );+ expect(latestFollowTarget(items, posix)).toBe('articles/caffeine');});});@@ -564,60 +450,6 @@ describe('latestFollowTarget', () => {});});-describe('pageListFollowOptions', () => {- test('null pageList (no provider — dock in hosts/tests) → no predicate', () => {- // The ThreadView is rendered from surfaces that don't wrap it in a- // PageListProvider (docks, standalone previews); the follow-file layer- // must degrade to ungated navigation there, not throw.- expect(pageListFollowOptions(null)).toEqual({});- });-- test('loading pageList → no predicate (unknown ≠ missing during cold fetch)', () => {- const opts = pageListFollowOptions({ loading: true, error: null, pages: new Set() });- expect(opts).toEqual({});- });-- test('errored pageList → no predicate (failed fetch cannot distinguish missing from unknown)', () => {- // Load-bearing regression guard: if this drops back to `{ docExists:- // pages.has }` on a failed fetch, follow-file silently stops for all- // read-shaped targets until the next successful refetch — the empty- // `pages` set gates every doc as missing. `error !== null` must keep- // the predicate absent so the transient failure degrades to previous- // ungated behavior instead of a silent user-visible stop.- const opts = pageListFollowOptions({- loading: false,- error: 'Network error',- pages: new Set(),- });- expect(opts).toEqual({});- });-- test('errored pageList with non-empty pages → still no predicate', () => {- // Even if the snapshot carries stale docs from a prior successful fetch,- // an active error means we cannot trust the set as authoritative — the- // safe pass-through is ungated, matching the loading branch.- const opts = pageListFollowOptions({- loading: false,- error: 'stale',- pages: new Set(['a']),- });- expect(opts).toEqual({});- });-- test('loaded + no error → predicate delegates to `pages.has`', () => {- const opts = pageListFollowOptions({- loading: false,- error: null,- pages: new Set(['articles/caffeine', 'plans/launch']),- });- expect(opts.docExists).toBeDefined();- expect(opts.docExists?.('articles/caffeine')).toBe(true);- expect(opts.docExists?.('plans/launch')).toBe(true);- expect(opts.docExists?.('main')).toBe(false);- expect(opts.docExists?.('')).toBe(false);- });-});-describe('decideFollowNavigation', () => {const initial: FollowNavState = INITIAL_FOLLOW_NAV_STATE;@@ -753,7 +585,7 @@ describe('decideFollowNavigation', () => {});test('turn boundary re-arm dedupes the stale followTarget (no yank to yesterday`s work)', () => {- // The regression pullfrog surfaced: `followTarget` is scanned from the+ // The regression: `followTarget` is scanned from the// accumulated event log and doesn't reset between turns, so a new turn// begins with the PREVIOUS turn's last file as `followTarget`. If the// re-arm zeroed `lastFollowed`, off-track would short-circuit falsediff --git a/packages/app/src/components/acp/follow-file.ts b/packages/app/src/components/acp/follow-file.tsindex 5093a50fb..1d8ba9939 100644--- a/packages/app/src/components/acp/follow-file.ts+++ b/packages/app/src/components/acp/follow-file.ts@@ -5,19 +5,22 @@* OpenKnowledge MCP tools' argument shapes).** Two signal shapes, in priority order:- * 1. OK MCP tool calls — adapters report them with+ * 1. OK MCP write-shaped tool calls — adapters report them with* `rawInput: { server, tool, arguments: {…} }` (Codex), with `arguments`* as a JSON string (adapter-dependent), or as the arguments object* directly. The doc target is wherever the verb vocabulary puts it:- * `document.path` (write / edit), flat `to` (move), flat `docName`- * (links / history), or a `.md`/`.mdx` path referenced inside an `exec`- * / shell `command` string.- * 2. `locations[]` — absolute file paths (native read/edit tools). Mapped to- * a docName by stripping the workspace `contentDir` prefix and the- * `.md`/`.mdx` extension; non-markdown paths are not editor documents and- * resolve to null.+ * `document.path` (write / edit), flat `to` (move), or the flat+ * `docName` fallback shape.+ * 2. `locations[]` — absolute file paths from `edit` / `move` tool calls+ * (native writes / renames). Mapped to a docName by stripping the+ * workspace `contentDir` prefix and the `.md`/`.mdx` extension;+ * non-markdown paths are not editor documents and resolve to null.+ *+ * Read-shaped calls (`exec`, `search`, `read`, other) NEVER drive follow:+ * only the user's own gestures move the active workspace tab.*/+import { OPEN_KNOWLEDGE_MCP_WRITE_TOOLS } from '@inkeep/open-knowledge-core';import { stringField, unwrapMcpInput } from '@/lib/acp/mcp-input';import type { RenderedToolCall } from '@/lib/acp/thread-event-model';import type { Workspace } from '@/lib/workspace-paths';@@ -67,119 +70,7 @@ export function docNameFromAbsolutePath(path: string, workspace: Workspace): strreturn sanitizeDocName(relative.slice(0, -match[0].length));}-/**- * Read-only command heads worth following (mirrors the OK `exec` tool's- * allowlist, plus common read-only lookalikes). A command whose head is not- * listed — `rm`, `mv`, arbitrary scripts — never drives navigation: following- * a file that a command is deleting or renaming is not what follow means.- */-const FOLLOWABLE_COMMAND_HEADS = new Set([- 'cat',- 'ls',- 'grep',- 'rg',- 'find',- 'head',- 'tail',- 'wc',- 'sort',- 'uniq',- 'cut',- 'sed',- 'awk',- 'bat',- 'less',- 'more',-]);--/**- * DocName referenced by a shell-ish `command` string (the OK `exec` tool, or- * a native terminal tool). First `.md`/`.mdx` token wins — the primary- * operand. Globs carry no single target; flags are skipped; absolute paths- * map through the workspace root like `locations[]` entries do.- */-function docTargetFromCommand(command: string, workspace: Workspace | null): string | null {- const tokens: string[] = [];- const tokenizer = /"([^"]*)"|'([^']*)'|(\S+)/g;- let match: RegExpExecArray | null = tokenizer.exec(command);- while (match !== null) {- tokens.push(match[1] ?? match[2] ?? match[3] ?? '');- match = tokenizer.exec(command);- }- const head = tokens[0];- if (head === undefined || !FOLLOWABLE_COMMAND_HEADS.has(head)) return null;- for (const token of tokens.slice(1)) {- if (token.startsWith('-')) continue;- if (/[*?[\]]/.test(token)) continue;- const mdMatch = /\.(md|mdx)$/i.exec(token);- if (mdMatch === null) continue;- if (token.startsWith('/') || /^[A-Za-z]:[\\/]/.test(token)) {- if (workspace !== null) {- const doc = docNameFromAbsolutePath(token, workspace);- if (doc !== null) return doc;- }- continue;- }- const doc = sanitizeDocName(token.replace(/^\.\//, '').slice(0, -mdMatch[0].length));- if (doc !== null) return doc;- }- return null;-}--/**- * Follow-target options. `docExists` gates READ-shaped targets on the doc- * actually existing: a read of a missing file must not navigate — the editor- * would open a blank create-on-open tab. Two read-shaped sources are gated:- * the `exec`/shell `command` string path (`cat log.md` on a doc that was never- * created, which parked the editor on an empty "log" page), and the- * `locations[]` path of non-`edit` tool calls (a native read/search/exec whose- * newest location names a doc that never existed, which opened a blank "main"- * page). Write-shaped targets (`document`/`documents`/`to`/`docName`, and- * `edit`/`move` locations) are deliberately NOT gated: they routinely name- * docs that don't exist YET (the write creates them). When the predicate is- * absent (the page list is still loading, or its fetch failed and we can't- * distinguish missing from unknown) targets pass through ungated — unknown is- * not the same as missing.- */-export interface FollowTargetOptions {- docExists?: (docName: string) => boolean;-}--/**- * Structural subset of `PageListContextValue` this module reads. Kept narrow- * on purpose — the follow-file layer never touches the wider PageList API- * (slug indexes, folder paths, refetch), so accepting only what it consumes- * keeps the ThreadView call site substitutable without wiring the full- * context shape through.- */-export interface PageListPredicateInput {- readonly loading: boolean;- readonly error: string | null;- readonly pages: ReadonlySet<string>;-}--/**- * Derive the follow-file predicate options from a page-list snapshot. The- * predicate is only armed when the snapshot is authoritative: the cold- * fetch has resolved (`!loading`) AND it did NOT error (`error === null`).- * A failed fetch may leave `pages` empty (cold-load failure) or stale- * (background refetch failure keeps the last-good set — see- * `PageListContext`); in either case the set is not authoritative and- * treating it as such would mask every doc as missing (cold) or- * misclassify a just-created doc as missing (stale) and silently disable- * all read-shaped follow until the next successful refetch — unknown is- * not the same as missing.- * Optional variant: the dock renders in hosts/tests without the provider,- * so `null` degrades to an empty options object (predicate absent →- * ungated, previous behavior).- */-export function pageListFollowOptions(- pageList: PageListPredicateInput | null,-): FollowTargetOptions {- if (pageList === null || pageList.loading || pageList.error !== null) return {};- const pages = pageList.pages;- return { docExists: (docName: string) => pages.has(docName) };-}+const OK_MCP_WRITE_TOOLS: ReadonlySet<string> = new Set(OPEN_KNOWLEDGE_MCP_WRITE_TOOLS);/*** DocName from an OK MCP tool call's rawInput, or null when the call is not@@ -189,8 +80,7 @@ export function pageListFollowOptions(function mcpDocTarget(rawInput: unknown,title: string,- workspace: Workspace | null,- options: FollowTargetOptions,+ toolKind: RenderedToolCall['toolKind'],): string | null {const unwrapped = unwrapMcpInput(rawInput);if (unwrapped === null) return null;@@ -204,8 +94,10 @@ function mcpDocTarget(// `documents: [...]` instead — the LAST entry is the most recent write, so// that's the one to follow (observed live: a 12-page batch produced no// follow target at all before this branch existed); `move` lands the doc at- // flat `to` (template/skill moves nest theirs — those are not documents);- // `docName` is the flat fallback shape.+ // flat `to` (template/skill moves nest theirs — those are not documents).+ // These three shapes are structurally write-only in the OK MCP schema, so+ // they are trusted at any toolKind / tool-name pair — including+ // `toolKind: 'execute'` writes the Codex adapter reports.const document =typeof args.document === 'object' && args.document !== null? (args.document as Record<string, unknown>)@@ -220,25 +112,29 @@ function mcpDocTarget(}}}- const docName =+ const structural =(document !== null ? stringField(document, 'path') : null) ??(lastBatchEntry !== null ? stringField(lastBatchEntry, 'path') : null) ??- stringField(args, 'to') ??- stringField(args, 'docName');- if (docName !== null) {+ stringField(args, 'to');+ if (structural !== null) {// Agents sometimes pass the on-disk form (`orbit/plan.md`); the navigable// docName is extension-less.- return sanitizeDocName(docName.replace(/\.(md|mdx)$/, ''));+ return sanitizeDocName(structural.replace(/\.(md|mdx)$/, ''));}- const command = stringField(args, 'command');- if (command !== null) {- const target = docTargetFromCommand(command, workspace);- if (target !== null && options.docExists !== undefined && !options.docExists(target)) {- return null;- }- return target;- }- return null;+ // Flat `docName` is a defensive fallback — the OK MCP wire schemas for+ // reads use `document` / `name` / `file`, not `docName`, so this branch is+ // unreachable for a current OK MCP read. It exists for adapter drift: a+ // bare-arg or renamed shape could put `docName` on a read tomorrow, and+ // the same gate that lets flat write shapes through must not silently let+ // that through. Follow only when the call is provably a write: either the+ // tool name is in the write allowlist, or the ACP `toolKind` is a write+ // kind (`edit` / `move`).+ const flat = stringField(args, 'docName');+ if (flat === null) return null;+ const isKnownWrite = tool !== null && OK_MCP_WRITE_TOOLS.has(tool);+ const isWriteToolKind = toolKind === 'edit' || toolKind === 'move';+ if (!isKnownWrite && !isWriteToolKind) return null;+ return sanitizeDocName(flat.replace(/\.(md|mdx)$/, ''));}/**@@ -248,30 +144,23 @@ function mcpDocTarget(export function followTargetFromToolCall(call: Pick<RenderedToolCall, 'toolKind' | 'title' | 'locations' | 'rawInput'>,workspace: Workspace | null,- options: FollowTargetOptions = {},): string | null {if (call.toolKind === 'delete') return null;- const mcp = mcpDocTarget(call.rawInput, call.title, workspace, options);+ const mcp = mcpDocTarget(call.rawInput, call.title, call.toolKind);if (mcp !== null) return mcp;if (workspace === null) return null;- // A location-derived target from a non-write-shaped call (read/search/exec/…)- // only navigates to a doc that exists — the newest location of such a call- // can name a file that was never created (a git branch name, a phantom path- // from the prompt), which would otherwise open a blank create-on-open tab.- // `edit` is the create case (it names the doc it is about to write) and- // `move` is the rename case (its newest location IS the destination — by- // definition not in the page list yet); both stay ungated, matching the- // write-shaped MCP targets above (`document.path` for edit, flat `to` for- // move). Every other ACP toolKind is treated as read-shaped and gated.- const gateMissingLocation =- call.toolKind !== 'edit' && call.toolKind !== 'move' && options.docExists !== undefined;+ // Only WRITE-shaped tool kinds drive follow from their `locations[]`:+ // `edit` is the create case, `move` is the rename case, both naming the+ // destination the agent is producing. Every other ACP toolKind — `read`,+ // `search`, `execute`, `other` — is the agent exploring, and+ // agent reads never mutate the active tab.+ if (call.toolKind !== 'edit' && call.toolKind !== 'move') return null;// Newest location wins — long calls append locations as they progress.for (let i = call.locations.length - 1; i >= 0; i--) {const location = call.locations[i];if (location === undefined) continue;const docName = docNameFromAbsolutePath(location.path, workspace);if (docName === null) continue;- if (gateMissingLocation && !options.docExists?.(docName)) return null;return docName;}return null;@@ -368,12 +257,11 @@ export function decideFollowNavigation(export function latestFollowTarget(items: ReadonlyArray<{ kind: string }>,workspace: Workspace | null,- options: FollowTargetOptions = {},): string | null {let target: string | null = null;for (const item of items) {if (item.kind !== 'tool_call') continue;- const resolved = followTargetFromToolCall(item as RenderedToolCall, workspace, options);+ const resolved = followTargetFromToolCall(item as RenderedToolCall, workspace);if (resolved !== null) target = resolved;}return target;diff --git a/packages/core/src/bridge/bind-frontmatter-doc.ts b/packages/core/src/bridge/bind-frontmatter-doc.tsindex d7a845280..dfd95ef49 100644--- a/packages/core/src/bridge/bind-frontmatter-doc.ts+++ b/packages/core/src/bridge/bind-frontmatter-doc.ts@@ -1,3 +1,4 @@+import type * as Y from 'yjs';import type { Err, Ok, Result } from '../config/result.ts';import { type FrontmatterValidationError, toFrontmatterIssue } from '../frontmatter/errors.ts';diff --git a/packages/core/src/bridge/bridge-invariant.ts b/packages/core/src/bridge/bridge-invariant.tsindex 005627195..8bfdb40cd 100644--- a/packages/core/src/bridge/bridge-invariant.ts+++ b/packages/core/src/bridge/bridge-invariant.ts@@ -1,3 +1,4 @@+import { fnv1aDigest } from './hash-util.ts';export type BridgeInvariantSite = 'observer-b' | 'persistence' | 'test-harness';diff --git a/packages/core/src/bridge/compose.ts b/packages/core/src/bridge/compose.tsindex f4cc8a286..2a597ec3d 100644--- a/packages/core/src/bridge/compose.ts+++ b/packages/core/src/bridge/compose.ts@@ -1,3 +1,4 @@+import { prependFrontmatter, stripFrontmatter } from '../extensions/frontmatter.ts';export type ComposeAdjustment = 'none' | 'body' | 'frontmatter' | 'unresolved';diff --git a/packages/core/src/bridge/divergence-locate.ts b/packages/core/src/bridge/divergence-locate.tsindex 6b505314d..d979f4b39 100644--- a/packages/core/src/bridge/divergence-locate.ts+++ b/packages/core/src/bridge/divergence-locate.ts@@ -1,3 +1,4 @@+import { findFirstDivergenceIndex } from './tolerance-telemetry.ts';export const BRIDGE_LINE_KINDS = [diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.tsindex 8fb428b90..01ef76a9f 100644--- a/packages/core/src/bridge/doc-boundary-space.ts+++ b/packages/core/src/bridge/doc-boundary-space.ts@@ -1,3 +1,4 @@+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/bridge/growth-detect.ts b/packages/core/src/bridge/growth-detect.tsindex 9d9c244b0..463e89595 100644--- a/packages/core/src/bridge/growth-detect.ts+++ b/packages/core/src/bridge/growth-detect.ts@@ -1,3 +1,4 @@+const DEFAULT_MIN_SUBSTANTIVE_LINE_LENGTH = 16;export const DUPLICATION_GATE_MIN_LINE_LENGTH = 8;diff --git a/packages/core/src/bridge/intraline-predicate.ts b/packages/core/src/bridge/intraline-predicate.tsindex c43fdd7e7..0939885bb 100644--- a/packages/core/src/bridge/intraline-predicate.ts+++ b/packages/core/src/bridge/intraline-predicate.ts@@ -1,3 +1,4 @@+export function rawLineCounts(doc: string): Map<string, number> {const counts = new Map<string, number>();for (const line of doc.split('\n')) {diff --git a/packages/core/src/bridge/merge-three-way.ts b/packages/core/src/bridge/merge-three-way.tsindex 251560a35..c0dc65705 100644--- a/packages/core/src/bridge/merge-three-way.ts+++ b/packages/core/src/bridge/merge-three-way.ts@@ -65,6 +65,7 @@ export function tryLineLevelCombine(return { clean: true, merged };}+export type BridgeMergeContentLossSide = 'user' | 'agent';export type BridgeMergeContentLossWhich = 'substring' | 'order' | 'growth';diff --git a/packages/core/src/bridge/normalize.ts b/packages/core/src/bridge/normalize.tsindex 01ac80099..dcc5b0690 100644--- a/packages/core/src/bridge/normalize.ts+++ b/packages/core/src/bridge/normalize.ts@@ -1,3 +1,4 @@+import { stripFrontmatter } from '../extensions/frontmatter.ts';import { bodyEdgeEmpties } from './doc-boundary-space.ts';diff --git a/packages/core/src/bridge/pm-structural-equivalence.ts b/packages/core/src/bridge/pm-structural-equivalence.tsindex 754dc5cc2..0be5203e4 100644--- a/packages/core/src/bridge/pm-structural-equivalence.ts+++ b/packages/core/src/bridge/pm-structural-equivalence.ts@@ -32,6 +32,7 @@ const BR_SENTINEL: PmStructuralNode = { type: '__br__' };const BR_LITERAL_RE = /^<br\s*\/?>$/i;+interface DegradeEntry {readonly label: string;readonly severity: ToleranceClassSeverity;@@ -127,6 +128,7 @@ export interface ComparePmStructuralOptions {ignoreAttrs?: (attrKey: string) => boolean;}+/** Rebuild a node with `fn` applied to each child; identity when childless.* Shared by the degrade canonicalizers so none re-implements the walk. */function mapChildren(@@ -248,6 +250,7 @@ function applyDegrades(tree: PmStructuralNode): {return { normalized: current, fired };}+export function comparePmStructural(expected: PmStructuralNode,actual: PmStructuralNode,diff --git a/packages/core/src/bridge/subsequence.ts b/packages/core/src/bridge/subsequence.tsindex af20de1e2..dca644141 100644--- a/packages/core/src/bridge/subsequence.ts+++ b/packages/core/src/bridge/subsequence.ts@@ -1,3 +1,4 @@+/** True when `needle` is a subsequence of `haystack` (two-pointer, O(n+m)):* insertions in `haystack` are free; any dropped or substituted `needle` byte* fails. */diff --git a/packages/core/src/constants/mcp.ts b/packages/core/src/constants/mcp.tsindex b5167f050..7adf7fcc5 100644--- a/packages/core/src/constants/mcp.ts+++ b/packages/core/src/constants/mcp.ts@@ -60,6 +60,26 @@ export const OPEN_KNOWLEDGE_MCP_TOOLS = [/** One registered OpenKnowledge MCP tool name. */export type OpenKnowledgeMcpTool = (typeof OPEN_KNOWLEDGE_MCP_TOOLS)[number];+/**+ * Subset of {@link OPEN_KNOWLEDGE_MCP_TOOLS} whose calls MUTATE a document.+ * Consumers that need to distinguish reads from writes without probing the+ * argument shape read this set directly — e.g. follow-the-file uses it to+ * refuse navigation on a read that happens to carry a `docName` field.+ * Must stay a subset of the flat list above; the `satisfies` clause below+ * enforces this at compile time.+ */+export const OPEN_KNOWLEDGE_MCP_WRITE_TOOLS = [+ 'write',+ 'edit',+ 'delete',+ 'move',+ 'install',+ 'import',+ 'checkpoint',+ 'restore_version',+ 'resolve_conflict',+] as const satisfies ReadonlyArray<OpenKnowledgeMcpTool>;+/*** Env marker stamped on every agent OpenKnowledge launches itself — today the* in-app agent panel. An `ok mcp` process spawned by such an agent inheritsdiff --git a/packages/core/src/index.ts b/packages/core/src/index.tsindex f8d149216..c1e018a30 100644--- a/packages/core/src/index.ts+++ b/packages/core/src/index.ts@@ -387,6 +387,7 @@ export {OK_DESKTOP_TERMINAL_ENV,OK_HOSTED_AGENT_ENV,OPEN_KNOWLEDGE_MCP_TOOLS,+ OPEN_KNOWLEDGE_MCP_WRITE_TOOLS,type OpenKnowledgeMcpTool,READ_DOCUMENT_HISTORY_DEPTH,resolveIsHostedAgent,diff --git a/packages/core/src/markdown/callout-transformer.ts b/packages/core/src/markdown/callout-transformer.tsindex 83d47404a..a363dfd54 100644--- a/packages/core/src/markdown/callout-transformer.ts+++ b/packages/core/src/markdown/callout-transformer.ts@@ -1,3 +1,4 @@+import type { Blockquote, Paragraph, Root } from 'mdast';import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/code-fence.ts b/packages/core/src/markdown/code-fence.tsindex 9807a7e82..4499dbc92 100644--- a/packages/core/src/markdown/code-fence.ts+++ b/packages/core/src/markdown/code-fence.ts@@ -1,3 +1,4 @@+export function selectFenceChar(info: string): '`' | '~' {return info.includes('`') ? '~' : '`';}diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.tsindex 7415c474a..34704165b 100644--- a/packages/core/src/markdown/comment-promoter.ts+++ b/packages/core/src/markdown/comment-promoter.ts@@ -1,3 +1,4 @@+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/dedent-block-jsx-close.ts b/packages/core/src/markdown/dedent-block-jsx-close.tsindex ece5c02a1..b6299a948 100644--- a/packages/core/src/markdown/dedent-block-jsx-close.ts+++ b/packages/core/src/markdown/dedent-block-jsx-close.ts@@ -1,3 +1,4 @@+import { findFencedRegions, isInsideFence } from './fence-regions.ts';const INDENTED_BLOCK_JSX_CLOSE_RE = /^([ ]{1,3})(<\/[A-Z][A-Za-z0-9_]*\s*>)([ \t]*)$/gm;diff --git a/packages/core/src/markdown/details-accordion-promoter.ts b/packages/core/src/markdown/details-accordion-promoter.tsindex 54774764a..acd398aa6 100644--- a/packages/core/src/markdown/details-accordion-promoter.ts+++ b/packages/core/src/markdown/details-accordion-promoter.ts@@ -1,3 +1,4 @@+import type { Nodes, Paragraph, Parent, Root, Text } from 'mdast';import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/div-align-promoter.ts b/packages/core/src/markdown/div-align-promoter.tsindex 43ecdc709..ba9b56384 100644--- a/packages/core/src/markdown/div-align-promoter.ts+++ b/packages/core/src/markdown/div-align-promoter.ts@@ -1,3 +1,4 @@+import type { Nodes, Paragraph, Parent, Root, Text } from 'mdast';import type { MdxJsxFlowElement } from 'mdast-util-mdx';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/fence-regions.ts b/packages/core/src/markdown/fence-regions.tsindex 6d3f3643e..4513da9bb 100644--- a/packages/core/src/markdown/fence-regions.ts+++ b/packages/core/src/markdown/fence-regions.ts@@ -1,3 +1,4 @@+const FENCE_RE = /^(`{3,}|~{3,})/gm;export function findFencedRegions(src: string): Array<[number, number]> {diff --git a/packages/core/src/markdown/fixtures/index.ts b/packages/core/src/markdown/fixtures/index.tsindex 00f5771ee..6931623c7 100644--- a/packages/core/src/markdown/fixtures/index.ts+++ b/packages/core/src/markdown/fixtures/index.ts@@ -1,3 +1,4 @@+import { readFileSync } from 'node:fs';import { dirname, resolve } from 'node:path';import { fileURLToPath } from 'node:url';@@ -8,6 +9,7 @@ function fixturePath(...segments: string[]): string {return resolve(FIXTURES_DIR, ...segments);}+interface GfmExample {section: string;markdown: string;@@ -17,6 +19,7 @@ export function loadGfmExamples(): GfmExample[] {return JSON.parse(readFileSync(fixturePath('gfm', 'examples.json'), 'utf8')) as GfmExample[];}+interface MdxCrashEntry {id: string;input: string;@@ -68,6 +71,7 @@ export function loadLargeEmbedFixtures(): LargeEmbedFixture[] {) as LargeEmbedFixture[];}+export function loadPrd6955Before(): string {return readFileSync(fixturePath('regression', 'prd-6955-before.md'), 'utf8');}@@ -76,6 +80,7 @@ export function loadPrd6955CorruptedTriplicated(): string {return readFileSync(fixturePath('regression', 'prd-6955-corrupted-triplicated.md'), 'utf8');}+export interface NgPinnedCase {id: string;name: string;@@ -92,6 +97,7 @@ export function loadNgPinnedCases(): NgPinnedCase[] {) as NgPinnedCase[];}+export function loadLargeRealistic(): string {return readFileSync(fixturePath('perf', 'large-realistic.md'), 'utf8');}diff --git a/packages/core/src/markdown/fixtures/perf/generate.ts b/packages/core/src/markdown/fixtures/perf/generate.tsindex 8b1eb8519..daa3ef82b 100644--- a/packages/core/src/markdown/fixtures/perf/generate.ts+++ b/packages/core/src/markdown/fixtures/perf/generate.ts@@ -1,3 +1,4 @@+import { writeFileSync } from 'node:fs';import { dirname, resolve } from 'node:path';import { fileURLToPath } from 'node:url';@@ -10,6 +11,7 @@ const BASELINE_ONLY_COUNTS = [500, 2500] as const;const SEED = 0xf1de1117;+function mulberry32(seed: number): () => number {let a = seed >>> 0;return () => {@@ -36,6 +38,7 @@ function pickWeighted<T>(rand: () => number, items: readonly [T, number][]): T {return items[items.length - 1][0];}+const WORDS = ['lorem','ipsum',@@ -153,6 +156,7 @@ function mdxBlock(rand: () => number): string {return `<${name}>\n\n${sentence(rand)}\n\n</${name}>`;}+type BlockKind = 'paragraph' | 'heading' | 'list' | 'code' | 'table' | 'mdx';const MIX: readonly [BlockKind, number][] = [@@ -191,6 +195,7 @@ function generateDocument(blockCount: number, seed: number): string {return `${blocks.join('\n\n')}\n`;}+function main(): void {for (const count of [...BLOCK_COUNTS, ...BASELINE_ONLY_COUNTS]) {const doc = generateDocument(count, SEED);diff --git a/packages/core/src/markdown/guard-flanking-matrix.ts b/packages/core/src/markdown/guard-flanking-matrix.tsindex 420dc0fe5..32c055c5b 100644--- a/packages/core/src/markdown/guard-flanking-matrix.ts+++ b/packages/core/src/markdown/guard-flanking-matrix.ts@@ -7,6 +7,7 @@ import {import { BACKSLASH_GUARD_SUBSTITUTIONS, encodeBackslashEscapes } from './backslash-escape-guard.ts';import { ENTITY_REF_GUARD_SUBSTITUTIONS, encodeEntityRefs } from './entity-ref-guard.ts';+export const ATTENTION_DELIMITERS = ['*', '_', '**', '~~', '=='] as const;export type FlankClass = 'whitespace' | 'punctuation' | 'other';diff --git a/packages/core/src/markdown/handler-shadow-audit.ts b/packages/core/src/markdown/handler-shadow-audit.tsindex 2653473da..283913255 100644--- a/packages/core/src/markdown/handler-shadow-audit.ts+++ b/packages/core/src/markdown/handler-shadow-audit.ts@@ -1,3 +1,4 @@+export interface HandlerShadowWitness {input: string;expect: 'byte' | 'byte-and-reparse-type';diff --git a/packages/core/src/markdown/highlight-promoter.ts b/packages/core/src/markdown/highlight-promoter.tsindex da0a81d23..5d1000cc4 100644--- a/packages/core/src/markdown/highlight-promoter.ts+++ b/packages/core/src/markdown/highlight-promoter.ts@@ -1,3 +1,4 @@+import type { Nodes, Parent, PhrasingContent, Root, Text } from 'mdast';import type { MdxJsxTextElement } from 'mdast-util-mdx';import { SKIP, visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/html-to-mdast.ts b/packages/core/src/markdown/html-to-mdast.tsindex 787315157..9681c0056 100644--- a/packages/core/src/markdown/html-to-mdast.ts+++ b/packages/core/src/markdown/html-to-mdast.ts@@ -1,3 +1,4 @@+import type { Element as HastElement, Root as HastRoot } from 'hast';import type { List, Nodes as MdastNodes, Root as MdastRoot } from 'mdast';import rehypeParse from 'rehype-parse';@@ -128,7 +129,8 @@ export function htmlToMdast(html: string, options?: HtmlToMdastOptions): MdastRothrow new HtmlPayloadTooLargeError(html.length, maxBytes);}- const processor = unified().use(rehypeParse, { fragment: true });+ const processor = unified()+ .use(rehypeParse, { fragment: true });for (const plugin of cleanupPlugins) {processor.use(plugin);diff --git a/packages/core/src/markdown/image-promoter.ts b/packages/core/src/markdown/image-promoter.tsindex 706fa9afb..994eb6917 100644--- a/packages/core/src/markdown/image-promoter.ts+++ b/packages/core/src/markdown/image-promoter.ts@@ -1,3 +1,4 @@+import type { Image, Paragraph, Root } from 'mdast';import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/index.ts b/packages/core/src/markdown/index.tsindex 779e27500..ec1ac1b7e 100644--- a/packages/core/src/markdown/index.ts+++ b/packages/core/src/markdown/index.ts@@ -1,3 +1,4 @@+import {type FromProseMirrorOptions,fromPmMark,@@ -206,6 +207,7 @@ export class MarkdownManager {}}+const registry = createRegistry();function destructureAttrs(@@ -254,6 +256,7 @@ function destructureAttrs(return result;}+function hasDirtyDescendant(node: PmNode): boolean {let found = false;node.descendants((child) => {@@ -276,6 +279,7 @@ function effectiveDirty(node: PmNode, freshnessChecker?: StructuralFreshnessChecreturn freshnessChecker ? freshnessChecker.isDiverged(node.toJSON()) : false;}+function isEmptyMdastParagraph(node: MdastNodes): boolean {if (node.type !== 'paragraph') return false;const children = node.children ?? [];@@ -344,6 +348,7 @@ function extractTextFromMdastNodes(nodes: MdastNodes[]): string {return out;}+import {AUDIO_EXTENSIONS,FILE_ATTACHMENT_EXTENSIONS,@@ -596,6 +601,7 @@ function buildMdastToPmHandlers(}));}+if (m.emphasis) {handlers.emphasis = toPmMark(m.emphasis, (node: Emphasis) => ({sourceDelimiter: node.data?.sourceDelimiter ?? '*',@@ -676,6 +682,7 @@ function buildMdastToPmHandlers(}));}+if (m.link) {const sourceLiteralMark = m.sourceLiteral;handlers.link = (node: Link, _parent: MdastParent, state: MdastToPmState) => {@@ -973,6 +980,7 @@ function buildMdastToPmHandlers(};}+const blockUnknownHandler = (node: {type: string;position?: { start: { offset: number }; end: { offset: number } };@@ -1098,6 +1106,7 @@ function buildMdastToPmHandlers(return handlers as RemarkProseMirrorOptions['handlers'];}+function buildPmToMdastHandlers(schema: Schema,freshness: FreshnessCheckerHolder,diff --git a/packages/core/src/markdown/lint/applies-to.ts b/packages/core/src/markdown/lint/applies-to.tsindex fa0be9e86..b79e9aef7 100644--- a/packages/core/src/markdown/lint/applies-to.ts+++ b/packages/core/src/markdown/lint/applies-to.ts@@ -1,3 +1,4 @@+import picomatch from 'picomatch';import { SUPPORTED_DOC_EXTENSIONS } from '../../constants/doc-extensions.ts';diff --git a/packages/core/src/markdown/lint/config-files.ts b/packages/core/src/markdown/lint/config-files.tsindex 312c9c74b..94b34dee1 100644--- a/packages/core/src/markdown/lint/config-files.ts+++ b/packages/core/src/markdown/lint/config-files.ts@@ -1,3 +1,4 @@+const MARKDOWNLINT_JSON_CONFIG_FILES: ReadonlySet<string> = new Set(['.markdownlint.json','.markdownlint.jsonc',diff --git a/packages/core/src/markdown/lint/config-schemas.ts b/packages/core/src/markdown/lint/config-schemas.tsindex 1a81aa524..fbbd309df 100644--- a/packages/core/src/markdown/lint/config-schemas.ts+++ b/packages/core/src/markdown/lint/config-schemas.ts@@ -52,6 +52,7 @@ const fullPluginShape = Object.fromEntries(LINT_PLUGINS.map((plugin) => [plugin.id, plugin.sliceSchema]),) as z.ZodRawShape;+export const LinterConfigSchema = z.object({enabled: z.boolean(),plugins: z.object(fullPluginShape),diff --git a/packages/core/src/markdown/lint/default-config.ts b/packages/core/src/markdown/lint/default-config.tsindex d48eea5e4..a51f2ffb0 100644--- a/packages/core/src/markdown/lint/default-config.ts+++ b/packages/core/src/markdown/lint/default-config.ts@@ -6,6 +6,7 @@ export const DEFAULT_MARKDOWNLINT_CONFIG: Record<string, MarkdownlintRuleSettingMD013: false,};+export function resolveMarkdownlintConfig(rules: Record<string, MarkdownlintRuleSetting> | undefined,): Configuration {diff --git a/packages/core/src/markdown/lint/frontmatter-schema-edit.ts b/packages/core/src/markdown/lint/frontmatter-schema-edit.tsindex ef478e268..9c9542661 100644--- a/packages/core/src/markdown/lint/frontmatter-schema-edit.ts+++ b/packages/core/src/markdown/lint/frontmatter-schema-edit.ts@@ -1,3 +1,4 @@+import { CANONICAL_SCHEMA_DIALECT_URIS, DEFAULT_SCHEMA_DIALECT } from './frontmatter-validate.ts';export interface FrontmatterFieldConstraint {diff --git a/packages/core/src/markdown/lint/frontmatter-validate.ts b/packages/core/src/markdown/lint/frontmatter-validate.tsindex 5f953d667..b0e7833fd 100644--- a/packages/core/src/markdown/lint/frontmatter-validate.ts+++ b/packages/core/src/markdown/lint/frontmatter-validate.ts@@ -1,3 +1,4 @@+import Ajv, { type ValidateFunction } from 'ajv';import Ajv2019 from 'ajv/dist/2019.js';import Ajv2020 from 'ajv/dist/2020.js';diff --git a/packages/core/src/markdown/lint/index.ts b/packages/core/src/markdown/lint/index.tsindex 11b5abdfd..ffd277a90 100644--- a/packages/core/src/markdown/lint/index.ts+++ b/packages/core/src/markdown/lint/index.ts@@ -1,3 +1,4 @@+import { LINT_PLUGINS, type LinterConfig } from './plugins.ts';import type { LintDiagnostic } from './types.ts';diff --git a/packages/core/src/markdown/lint/okf-frontmatter/materialize.ts b/packages/core/src/markdown/lint/okf-frontmatter/materialize.tsindex 7a5af097e..f438f1b16 100644--- a/packages/core/src/markdown/lint/okf-frontmatter/materialize.ts+++ b/packages/core/src/markdown/lint/okf-frontmatter/materialize.ts@@ -1,3 +1,4 @@+import type { OkfRuleId } from '../okf-rule-meta.ts';import { fileNameFor, OKF_SCHEMA_DIR, okfSchemaPathFor } from './paths.ts';import { OKF_FRONTMATTER_REGISTRY } from './registry.ts';diff --git a/packages/core/src/markdown/lint/okf-frontmatter/paths.ts b/packages/core/src/markdown/lint/okf-frontmatter/paths.tsindex 1ee913527..c290b6878 100644--- a/packages/core/src/markdown/lint/okf-frontmatter/paths.ts+++ b/packages/core/src/markdown/lint/okf-frontmatter/paths.ts@@ -1,3 +1,4 @@+import type { OkfRuleId } from '../okf-rule-meta.ts';export const OKF_SCHEMA_DIR = '.ok/okf';diff --git a/packages/core/src/markdown/lint/okf-frontmatter/registry.ts b/packages/core/src/markdown/lint/okf-frontmatter/registry.tsindex f325fbbb4..53ecb619d 100644--- a/packages/core/src/markdown/lint/okf-frontmatter/registry.ts+++ b/packages/core/src/markdown/lint/okf-frontmatter/registry.ts@@ -1,3 +1,4 @@+import { compileAppliesTo } from '../applies-to.ts';import { validateFrontmatterSource } from '../frontmatter-validate.ts';import {diff --git a/packages/core/src/markdown/lint/okf-frontmatter/schemas.ts b/packages/core/src/markdown/lint/okf-frontmatter/schemas.tsindex f1c37671b..89845d3d5 100644--- a/packages/core/src/markdown/lint/okf-frontmatter/schemas.ts+++ b/packages/core/src/markdown/lint/okf-frontmatter/schemas.ts@@ -1,3 +1,4 @@+// file-level form is deliberate: the sibling `biome-ignore` must sit on the line// oxlint-disable unicorn/no-thenablediff --git a/packages/core/src/markdown/lint/okf-project/rules.ts b/packages/core/src/markdown/lint/okf-project/rules.tsindex 6d691ae2b..8b476332e 100644--- a/packages/core/src/markdown/lint/okf-project/rules.ts+++ b/packages/core/src/markdown/lint/okf-project/rules.ts@@ -1,3 +1,4 @@+import { SUPPORTED_DOC_EXTENSIONS } from '../../../constants/doc-extensions.ts';import { isOkfRuleEnabled, type OkfRuleId, type OkfRuleToggles } from '../okf-rule-meta.ts';diff --git a/packages/core/src/markdown/lint/okf-rule-meta.ts b/packages/core/src/markdown/lint/okf-rule-meta.tsindex 4de50d79f..44913a9dc 100644--- a/packages/core/src/markdown/lint/okf-rule-meta.ts+++ b/packages/core/src/markdown/lint/okf-rule-meta.ts@@ -1,3 +1,4 @@+export const OKF_RULE_IDS = ['no-wiki-links','log-shape',diff --git a/packages/core/src/markdown/lint/okf-rules.ts b/packages/core/src/markdown/lint/okf-rules.tsindex 1d5538421..d0999b62e 100644--- a/packages/core/src/markdown/lint/okf-rules.ts+++ b/packages/core/src/markdown/lint/okf-rules.ts@@ -1,3 +1,4 @@+import { isOkfRuleEnabled, type OkfRuleId, type OkfRuleToggles } from './okf-rule-meta.ts';import type { OkfRule } from './okf-runner.ts';import { indexShape } from './rules/index-shape.ts';diff --git a/packages/core/src/markdown/lint/okf-runner.ts b/packages/core/src/markdown/lint/okf-runner.tsindex de130e3f4..fabb08d6e 100644--- a/packages/core/src/markdown/lint/okf-runner.ts+++ b/packages/core/src/markdown/lint/okf-runner.ts@@ -1,3 +1,4 @@+import type { Root } from 'mdast';import remarkFrontmatter from 'remark-frontmatter';import remarkGfm from 'remark-gfm';diff --git a/packages/core/src/markdown/lint/plugins.ts b/packages/core/src/markdown/lint/plugins.tsindex 09c8450ee..0a089990e 100644--- a/packages/core/src/markdown/lint/plugins.ts+++ b/packages/core/src/markdown/lint/plugins.ts@@ -1,3 +1,4 @@+import { z } from 'zod';import { DEFAULT_MARKDOWNLINT_CONFIG, resolveMarkdownlintConfig } from './default-config.ts';import {@@ -23,6 +24,7 @@ import {type OkfSlice,} from './types.ts';+const MarkdownlintRuleSettingSchema = z.union([z.boolean(),z.enum(MARKDOWNLINT_RULE_SEVERITIES),diff --git a/packages/core/src/markdown/lint/rules/index-shape.ts b/packages/core/src/markdown/lint/rules/index-shape.tsindex 59fe9b87d..fcbb1b56c 100644--- a/packages/core/src/markdown/lint/rules/index-shape.ts+++ b/packages/core/src/markdown/lint/rules/index-shape.ts@@ -1,3 +1,4 @@+import type { List, ListItem } from 'mdast';import { EXIT, visit } from 'unist-util-visit';import { defineScopedOkfRule } from '../okf-runner.ts';diff --git a/packages/core/src/markdown/lint/rules/log-shape.ts b/packages/core/src/markdown/lint/rules/log-shape.tsindex e0159519f..431e4e9c8 100644--- a/packages/core/src/markdown/lint/rules/log-shape.ts+++ b/packages/core/src/markdown/lint/rules/log-shape.ts@@ -1,3 +1,4 @@+import type { Heading } from 'mdast';import { toString as headingText } from 'mdast-util-to-string';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/lint/rules/no-wiki-links.ts b/packages/core/src/markdown/lint/rules/no-wiki-links.tsindex 2123e977f..f75a04d15 100644--- a/packages/core/src/markdown/lint/rules/no-wiki-links.ts+++ b/packages/core/src/markdown/lint/rules/no-wiki-links.ts@@ -1,3 +1,4 @@+import type { Point } from 'unist';import { visit } from 'unist-util-visit';import { defineOkfRule } from '../okf-runner.ts';diff --git a/packages/core/src/markdown/lint/rules/reserved-casing.ts b/packages/core/src/markdown/lint/rules/reserved-casing.tsindex 89ef3e4a9..c8b4d8f28 100644--- a/packages/core/src/markdown/lint/rules/reserved-casing.ts+++ b/packages/core/src/markdown/lint/rules/reserved-casing.ts@@ -1,3 +1,4 @@+import { SUPPORTED_DOC_EXTENSIONS } from '../../../constants/doc-extensions.ts';import { defineOkfRule } from '../okf-runner.ts';diff --git a/packages/core/src/markdown/lint/types.ts b/packages/core/src/markdown/lint/types.tsindex 6836b962d..c04fa4de0 100644--- a/packages/core/src/markdown/lint/types.ts+++ b/packages/core/src/markdown/lint/types.ts@@ -1,3 +1,4 @@+import type { BrokenLinkReason } from '../../schemas/api/agent-write.ts';import type { OkfRuleId } from './okf-rule-meta.ts';@@ -112,6 +113,7 @@ export interface OkfSlice {generate?: { index?: boolean };}+interface RuleOptionSpecBase {key: string;description: string;diff --git a/packages/core/src/markdown/lint/validation-counts.ts b/packages/core/src/markdown/lint/validation-counts.tsindex 98238656e..437cc539a 100644--- a/packages/core/src/markdown/lint/validation-counts.ts+++ b/packages/core/src/markdown/lint/validation-counts.ts@@ -1,3 +1,4 @@+export interface ValidationSourceCounts {errorCount: number;warningCount: number;diff --git a/packages/core/src/markdown/math-promoter.ts b/packages/core/src/markdown/math-promoter.tsindex a5b511f25..bd79424c7 100644--- a/packages/core/src/markdown/math-promoter.ts+++ b/packages/core/src/markdown/math-promoter.ts@@ -1,3 +1,4 @@+import type { Code, Root } from 'mdast';import type { Math as MdastMath } from 'mdast-util-math';import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';diff --git a/packages/core/src/markdown/mdast-to-hast-handlers.ts b/packages/core/src/markdown/mdast-to-hast-handlers.tsindex ed89371d0..00fbc0035 100644--- a/packages/core/src/markdown/mdast-to-hast-handlers.ts+++ b/packages/core/src/markdown/mdast-to-hast-handlers.ts@@ -1,3 +1,4 @@+import type { Comment, Element, ElementContent, Properties } from 'hast';import type { FootnoteDefinition, FootnoteReference } from 'mdast';import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx';diff --git a/packages/core/src/markdown/mdast-to-html.ts b/packages/core/src/markdown/mdast-to-html.tsindex 8ce2b2492..df788a80d 100644--- a/packages/core/src/markdown/mdast-to-html.ts+++ b/packages/core/src/markdown/mdast-to-html.ts@@ -1,3 +1,4 @@+import type { Element, Root as HastRoot, Text as HastText } from 'hast';import type { Root as MdastRoot, Text as MdastText } from 'mdast';import type { Handler } from 'mdast-util-to-hast';diff --git a/packages/core/src/markdown/merged-walker.ts b/packages/core/src/markdown/merged-walker.tsindex bfd7e3109..fa3cfcd86 100644--- a/packages/core/src/markdown/merged-walker.ts+++ b/packages/core/src/markdown/merged-walker.ts@@ -1,3 +1,4 @@+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/mermaid-promoter.ts b/packages/core/src/markdown/mermaid-promoter.tsindex 1a897fca8..17ed2b829 100644--- a/packages/core/src/markdown/mermaid-promoter.ts+++ b/packages/core/src/markdown/mermaid-promoter.ts@@ -1,3 +1,4 @@+import type { Code, Root } from 'mdast';import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/parse-with-fallback.ts b/packages/core/src/markdown/parse-with-fallback.tsindex d988f4b8b..4aa0490c4 100644--- a/packages/core/src/markdown/parse-with-fallback.ts+++ b/packages/core/src/markdown/parse-with-fallback.ts@@ -168,6 +168,7 @@ export function parseRecursive(}}+interface VFilePlace {offset?: number;start?: { offset?: number };@@ -186,6 +187,7 @@ function extractErrorOffset(err: unknown): number | undefined {return undefined;}+interface Region {start: number;end: number;@@ -209,6 +211,7 @@ function nearestBlankLineAfter(src: string, offset: number): number | null {return null;}+export interface TagEvent {kind: 'open' | 'close' | 'self-close';name: string;@@ -355,6 +358,7 @@ function findFallbackRegion(src: string, errorOffset: number): Region {return { start: blockStart, end: blockEnd };}+interface SourceBlock {src: string;start: number;@@ -452,6 +456,7 @@ function tryPerBlockFallback(};}+function wholeDocRawText(source: string): JSONContent {return {type: 'doc',diff --git a/packages/core/src/markdown/parser-drop-closure.ts b/packages/core/src/markdown/parser-drop-closure.tsindex e6ab4fd57..43d420187 100644--- a/packages/core/src/markdown/parser-drop-closure.ts+++ b/packages/core/src/markdown/parser-drop-closure.ts@@ -1,3 +1,4 @@+export type DroppedTokenAdjudication =| {kind: 'format-dof-axis';diff --git a/packages/core/src/markdown/pipeline.ts b/packages/core/src/markdown/pipeline.tsindex 0e3224206..55736041c 100644--- a/packages/core/src/markdown/pipeline.ts+++ b/packages/core/src/markdown/pipeline.ts@@ -1,3 +1,4 @@+import {type FromProseMirrorOptions,fromProseMirror,diff --git a/packages/core/src/markdown/position-aware-join.ts b/packages/core/src/markdown/position-aware-join.tsindex 91cdf658f..ccf06e94d 100644--- a/packages/core/src/markdown/position-aware-join.ts+++ b/packages/core/src/markdown/position-aware-join.ts@@ -1,3 +1,4 @@+import type { Join } from 'mdast-util-to-markdown';import type { Position } from 'unist';import { isBlankLineParagraph } from './zero-emission-blocks.ts';diff --git a/packages/core/src/markdown/position-slice.ts b/packages/core/src/markdown/position-slice.tsindex 0f399d34c..e5b4c9eba 100644--- a/packages/core/src/markdown/position-slice.ts+++ b/packages/core/src/markdown/position-slice.ts@@ -1,3 +1,4 @@+import type { Nodes, Root } from 'mdast';import { visit } from 'unist-util-visit';import type { VFile } from 'vfile';@@ -476,7 +477,8 @@ export function applyPositionSliceToNode(const first = source[startOff];if (first !== '[' && first !== '<' && !node.title) {node.data.sourceStyle = 'gfm-autolink';- } else if (first === '[') {+ }+ else if (first === '[') {const slice = source.slice(startOff, endOff);const closeBracketIdx = slice.lastIndexOf('](');if (closeBracketIdx !== -1) {diff --git a/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts b/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.tsindex db10fa54b..ca225ce9b 100644--- a/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts+++ b/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts@@ -1,3 +1,4 @@+import type { Comment, Element, Root, Text } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts b/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.tsindex 34068d103..3a2524a9a 100644--- a/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts@@ -1,3 +1,4 @@+import type { Element, ElementContent, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts b/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.tsindex 93151d43b..2279a0189 100644--- a/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts@@ -1,3 +1,4 @@+import type { Element, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts b/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.tsindex 188f02d83..a0f467c42 100644--- a/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts@@ -1,3 +1,4 @@+import type { Element, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts b/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.tsindex 4ba2c3418..4e8542a21 100644--- a/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts@@ -1,3 +1,4 @@+import type { Element, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts b/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.tsindex 1a74b1272..a3c96b24a 100644--- a/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts@@ -1,3 +1,4 @@+import type { Element, ElementContent, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts b/packages/core/src/markdown/rehype-plugins/strip-mso-styles.tsindex de35e7b79..e95cf43d6 100644--- a/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts@@ -1,3 +1,4 @@+import type { Comment, Element, ElementContent, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts b/packages/core/src/markdown/rehype-plugins/strip-slack-classes.tsindex b4be1b2ea..ffdb4d5b5 100644--- a/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts@@ -1,3 +1,4 @@+import type { Element, ElementContent, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts b/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.tsindex 3c8d88b7c..e2a96d1a7 100644--- a/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts@@ -1,3 +1,4 @@+import type { Element, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/resolve-image-url.ts b/packages/core/src/markdown/resolve-image-url.tsindex cf2c9da8e..0389575ac 100644--- a/packages/core/src/markdown/resolve-image-url.ts+++ b/packages/core/src/markdown/resolve-image-url.ts@@ -1,3 +1,4 @@+import { isRelativeUrl } from './safe-url.ts';function isDevDiagnosticContext(): boolean {diff --git a/packages/core/src/markdown/safe-url.ts b/packages/core/src/markdown/safe-url.tsindex 4d3250d3a..8be632ba4 100644--- a/packages/core/src/markdown/safe-url.ts+++ b/packages/core/src/markdown/safe-url.ts@@ -1,3 +1,4 @@+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/core/src/markdown/serialize-fidelity.test-helper.ts b/packages/core/src/markdown/serialize-fidelity.test-helper.tsindex 0dd54070e..96304e7a5 100644--- a/packages/core/src/markdown/serialize-fidelity.test-helper.ts+++ b/packages/core/src/markdown/serialize-fidelity.test-helper.ts@@ -1,3 +1,4 @@+import type { JSONContent } from '@tiptap/core';import type { Nodes } from 'mdast';import { expect } from 'vitest';diff --git a/packages/core/src/markdown/serialize-helpers.ts b/packages/core/src/markdown/serialize-helpers.tsindex 7cac5b042..93798cf83 100644--- a/packages/core/src/markdown/serialize-helpers.ts+++ b/packages/core/src/markdown/serialize-helpers.ts@@ -1,3 +1,4 @@+import type { Node as PmNode } from '@tiptap/pm/model';import type {MdxJsxAttribute,diff --git a/packages/core/src/markdown/single-dollar-math-promoter.ts b/packages/core/src/markdown/single-dollar-math-promoter.tsindex b012a5aff..8c08b7a04 100644--- a/packages/core/src/markdown/single-dollar-math-promoter.ts+++ b/packages/core/src/markdown/single-dollar-math-promoter.ts@@ -1,3 +1,4 @@+import type { PhrasingContent, Root, Text } from 'mdast';import type { InlineMath } from 'mdast-util-math';import { SKIP, visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/to-markdown-handlers.ts b/packages/core/src/markdown/to-markdown-handlers.tsindex 3e79f8cb6..959cc0bd2 100644--- a/packages/core/src/markdown/to-markdown-handlers.ts+++ b/packages/core/src/markdown/to-markdown-handlers.ts@@ -1,3 +1,4 @@+import type { Nodes, Parents } from 'mdast';import type { MdxJsxAttribute, MdxJsxExpressionAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';import type { Handle, Info, State } from 'mdast-util-to-markdown';diff --git a/packages/core/src/markdown/underline-promoter.ts b/packages/core/src/markdown/underline-promoter.tsindex 0f1b0f27d..6e6d73400 100644--- a/packages/core/src/markdown/underline-promoter.ts+++ b/packages/core/src/markdown/underline-promoter.ts@@ -1,3 +1,4 @@+import type { Nodes, Parent, Root } from 'mdast';import type { MdxJsxTextElement } from 'mdast-util-mdx';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/unknown-mdast-guard.ts b/packages/core/src/markdown/unknown-mdast-guard.tsindex 1a082bda7..932d7d2a8 100644--- a/packages/core/src/markdown/unknown-mdast-guard.ts+++ b/packages/core/src/markdown/unknown-mdast-guard.ts@@ -1,3 +1,4 @@+import type { Root as MdastRoot } from 'mdast';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/whitespace-char-ref.ts b/packages/core/src/markdown/whitespace-char-ref.tsindex d578476a7..ac9f5239b 100644--- a/packages/core/src/markdown/whitespace-char-ref.ts+++ b/packages/core/src/markdown/whitespace-char-ref.ts@@ -1,3 +1,4 @@+const INLINE_WHITESPACE_BY_CODE: ReadonlyMap<number, string> = new Map([[0x20, ' '],[0x09, '\t'],diff --git a/packages/core/src/markdown/wiki-link-micromark.ts b/packages/core/src/markdown/wiki-link-micromark.tsindex 6dad26200..afd9936fe 100644--- a/packages/core/src/markdown/wiki-link-micromark.ts+++ b/packages/core/src/markdown/wiki-link-micromark.ts@@ -17,6 +17,7 @@ declare module 'micromark-util-types' {}}+const CODE_BANG = 33; // !const CODE_LBRACKET = 91; // [const CODE_RBRACKET = 93; // ]@@ -260,6 +261,7 @@ export function wikiLinkSyntax(): Extension {};}+function enterWikiLink(this: CompileContext, token: Token) {this.enter({@@ -385,6 +387,7 @@ export const wikiLinkToMarkdown: {unsafe: [{ character: '[', inConstruct: ['phrasing'] }],};+const MICROMARK_EXT = wikiLinkSyntax();export function remarkWikiLink(this: Processor) {