Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(ok): keep OK's own skills out of the fullscreen graph (PRD-7959) (#3440)

tim-inkeepff9f2a960820
diff --git a/.changeset/graph-skill-node-filter.md b/.changeset/graph-skill-node-filter.md
new file mode 100644
index 000000000..6234691ed
--- /dev/null
+++ b/.changeset/graph-skill-node-filter.md
@@ -0,0 +1,9 @@
+---
+'@inkeep/open-knowledge': patch
+---
+
+Hide OpenKnowledge's own built-in skills from the fullscreen graph, and add a control for the rest.
+
+The link index treats skill bundles as graph nodes on purpose, but a global skill can never link to a document — the index registers it node-only and resolves its refs same-scope. OK force-installs two of its own bundles into every project, so every graph carried four nodes that were structurally incapable of connecting to anything in it.
+
+Those bundles are now excluded from the fullscreen graph unless another skill links them directly by name. A new toggle beside the external-URL control governs your own skills, project and global, and shows them by default. The docked local graph is unchanged: it still shows every skill node, so a skill's own neighborhood stays inspectable there.
diff --git a/knip.config.ts b/knip.config.ts
index 78162ec09..f9179f2d4 100644
--- a/knip.config.ts
+++ b/knip.config.ts
@@ -123,7 +123,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/GraphPanel.skill-nodes-toggle.dom.test.tsx b/packages/app/src/components/GraphPanel.skill-nodes-toggle.dom.test.tsx
new file mode 100644
index 000000000..20f37bacb
--- /dev/null
+++ b/packages/app/src/components/GraphPanel.skill-nodes-toggle.dom.test.tsx
@@ -0,0 +1,197 @@
+import * as actualLinguiMacro from '@lingui/react/macro';
+import { act, cleanup, render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import type { ReactNode } from 'react';
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
+import { TooltipProvider } from '@/components/ui/tooltip';
+import { renderLinguiTemplate } from '@/test-utils/lingui-mock';
+
+vi.doMock('@lingui/core/macro', () => ({
+ ...actualLinguiMacro,
+ t: renderLinguiTemplate,
+ msg: renderLinguiTemplate,
+}));
+
+vi.doMock('@lingui/react/macro', () => ({
+ ...actualLinguiMacro,
+ Plural: ({ one }: { one: string }) => <>{one}</>,
+ Trans: ({ children }: { children: ReactNode }) => <>{children}</>,
+ useLingui: () => ({ t: renderLinguiTemplate }),
+}));
+
+vi.doMock('next-themes', () => ({
+ useTheme: () => ({ resolvedTheme: 'light' }),
+}));
+
+vi.doMock('@/components/PageListContext', () => ({
+ usePageList: () => ({
+ assetPaths: new Set<string>(),
+ error: null,
+ folderPaths: new Set<string>(),
+ loading: false,
+ pages: new Set<string>(['docs/Active']),
+ pagesBySlug: new Map<string, string>(),
+ pageMeta: new Map(),
+ pageTitles: new Map([['docs/Active', 'Active']]),
+ refetch: () => {},
+ addPage: () => {},
+ }),
+}));
+
+type DocSelection = {
+ kind: 'doc';
+ id: string;
+ docName: string;
+ label: string;
+ anchor?: string;
+};
+
+const graphHarness: { select?: (selection: DocSelection) => void } = {};
+
+vi.doMock('@/components/GraphView', () => ({
+ GraphView: ({
+ isExpanded,
+ skillVisibility,
+ onSelectNode,
+ }: {
+ isExpanded: boolean;
+ skillVisibility: string;
+ onSelectNode?: (selection: DocSelection) => void;
+ }) => {
+ graphHarness.select = onSelectNode;
+ return (
+ <div
+ data-testid="graph-view"
+ data-expanded={String(isExpanded)}
+ data-skill-visibility={skillVisibility}
+ />
+ );
+ },
+}));
+
+const PREF_KEY = 'ok-graph-fullscreen-skill-nodes-v1';
+
+/**
+ * Install a memory-backed `window.localStorage`. The DOM env does not provide one
+ * on every Node version we run (it is absent under Node 26 locally), and this
+ * suite asserts the persistence contract directly — so it owns its storage rather
+ * than inheriting whatever the environment happens to supply.
+ */
+function installMemoryStorage(): Storage {
+ const entries = new Map<string, string>();
+ const storage: Storage = {
+ get length() {
+ return entries.size;
+ },
+ clear: () => entries.clear(),
+ getItem: (key: string) => entries.get(key) ?? null,
+ key: (index: number) => [...entries.keys()][index] ?? null,
+ removeItem: (key: string) => void entries.delete(key),
+ setItem: (key: string, value: string) => void entries.set(key, String(value)),
+ };
+ Object.defineProperty(window, 'localStorage', {
+ configurable: true,
+ value: storage,
+ writable: true,
+ });
+ return storage;
+}
+
+async function renderPanel() {
+ const { GraphPanel } = await import('./GraphPanel');
+ render(
+ <TooltipProvider>
+ <GraphPanel activeDocName="docs/Active" />
+ </TooltipProvider>,
+ );
+}
+
+function graphView() {
+ return screen.getByTestId('graph-view');
+}
+
+describe('GraphPanel skill-node visibility control', () => {
+ beforeEach(() => {
+ installMemoryStorage();
+ });
+
+ afterEach(() => {
+ cleanup();
+ window.localStorage.clear();
+ graphHarness.select = undefined;
+ });
+
+ test('docked graph is unfiltered and offers no skill control', async () => {
+ await renderPanel();
+
+ // The local 2-hop viewer keeps built-ins so a skill's own neighborhood
+ // stays inspectable there.
+ expect(graphView().getAttribute('data-skill-visibility')).toBe('all');
+ expect(screen.queryByRole('button', { name: 'Hide skill nodes' })).toBeNull();
+ });
+
+ test('fullscreen hides built-ins by default while still showing user skills', async () => {
+ await renderPanel();
+ await userEvent.click(screen.getByRole('button', { name: 'Expand graph' }));
+
+ expect(graphView().getAttribute('data-skill-visibility')).toBe('hide-builtins');
+ expect(window.localStorage.getItem(PREF_KEY)).toBeNull();
+ });
+
+ test('toggling off hides every skill node and persists the deviation', async () => {
+ await renderPanel();
+ await userEvent.click(screen.getByRole('button', { name: 'Expand graph' }));
+ await userEvent.click(screen.getByRole('button', { name: 'Hide skill nodes' }));
+
+ expect(graphView().getAttribute('data-skill-visibility')).toBe('none');
+ expect(window.localStorage.getItem(PREF_KEY)).toBe('false');
+
+ await userEvent.click(screen.getByRole('button', { name: 'Show skill nodes' }));
+ expect(graphView().getAttribute('data-skill-visibility')).toBe('hide-builtins');
+ // Back at the default, so the key clears rather than storing 'true'.
+ expect(window.localStorage.getItem(PREF_KEY)).toBeNull();
+ });
+
+ test('hiding skills dismisses a selected skill that is no longer drawn', async () => {
+ await renderPanel();
+ await userEvent.click(screen.getByRole('button', { name: 'Expand graph' }));
+ act(() => {
+ graphHarness.select?.({
+ kind: 'doc',
+ id: 'skill-1',
+ docName: '.claude/skills/team-conventions/SKILL',
+ label: 'Team conventions',
+ });
+ });
+ expect(screen.getByRole('status', { name: 'Selected graph item' })).toBeTruthy();
+
+ await userEvent.click(screen.getByRole('button', { name: 'Hide skill nodes' }));
+
+ expect(screen.queryByRole('status', { name: 'Selected graph item' })).toBeNull();
+ });
+
+ test('hiding skills keeps a selected content document', async () => {
+ await renderPanel();
+ await userEvent.click(screen.getByRole('button', { name: 'Expand graph' }));
+ act(() => {
+ graphHarness.select?.({
+ kind: 'doc',
+ id: 'doc-1',
+ docName: 'docs/Notes',
+ label: 'Notes',
+ });
+ });
+
+ await userEvent.click(screen.getByRole('button', { name: 'Hide skill nodes' }));
+
+ expect(screen.getByRole('status', { name: 'Selected graph item' })).toBeTruthy();
+ });
+
+ test('a stored off preference is restored on mount', async () => {
+ window.localStorage.setItem(PREF_KEY, 'false');
+ await renderPanel();
+ await userEvent.click(screen.getByRole('button', { name: 'Expand graph' }));
+
+ expect(graphView().getAttribute('data-skill-visibility')).toBe('none');
+ });
+});
diff --git a/packages/app/src/components/GraphPanel.tsx b/packages/app/src/components/GraphPanel.tsx
index dd05b83ae..cbd4b0877 100644
--- a/packages/app/src/components/GraphPanel.tsx
+++ b/packages/app/src/components/GraphPanel.tsx
@@ -9,6 +9,8 @@ import {
type OrphanMode,
OrphansSuccessSchema,
ProblemDetailsSchema,
+ parseGlobalSkillBundleDoc,
+ parseProjectSkillBundleDoc,
} from '@inkeep/open-knowledge-core';
import { t } from '@lingui/core/macro';
import { Plural, Trans, useLingui } from '@lingui/react/macro';
@@ -18,12 +20,14 @@ import {
ArrowUpRight,
CheckCircle2,
Globe,
+ Hexagon,
Maximize2,
Minimize2,
} from 'lucide-react';
import { useEffect, useState } from 'react';
import { GraphLegend } from '@/components/GraphLegend';
import { GraphView } from '@/components/GraphView';
+import type { GraphSkillVisibility } from '@/components/graph-skill-filter';
import {
type GraphNodeSelection,
getHashForGraphDocSelection,
@@ -42,6 +46,7 @@ import {
} from '@/components/ui/panel';
import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group';
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
+import { loadBoolPref, saveBoolPref } from '@/lib/bool-pref';
import { hashFromDocName } from '@/lib/doc-hash';
import { openExternalUrl } from '@/lib/external-link';
import { isOverlayLayerOpen } from '@/lib/overlay-layers';
@@ -51,28 +56,9 @@ const FULLSCREEN_HUB_LIMIT = 50;
const GRAPH_URL_NODES_DOCKED_KEY = 'ok-graph-docked-url-nodes-v1';
const GRAPH_URL_NODES_FULLSCREEN_KEY = 'ok-graph-fullscreen-url-nodes-v1';
-
-function loadBoolPref(key: string): boolean {
- if (typeof window === 'undefined') return false;
- try {
- return window.localStorage.getItem(key) === 'true';
- } catch {
- return false;
- }
-}
-
-function saveBoolPref(key: string, value: boolean): void {
- if (typeof window === 'undefined') return;
- try {
- if (value) {
- window.localStorage.setItem(key, 'true');
- } else {
- window.localStorage.removeItem(key);
- }
- } catch {
- // quota exceeded / private mode — ignore, stays in-memory
- }
-}
+// Fullscreen only. The docked view is a 2-hop neighborhood used to inspect what a
+// given doc — including a skill — connects to, so it stays unfiltered by design.
+const GRAPH_SKILL_NODES_FULLSCREEN_KEY = 'ok-graph-fullscreen-skill-nodes-v1';
type FullscreenGraphMode = 'explore' | 'orphans' | 'hubs';
@@ -302,6 +288,9 @@ export function GraphPanel({ activeDocName }: { activeDocName: string }) {
const [showUrlNodesFull, setShowUrlNodesFull] = useState(() =>
loadBoolPref(GRAPH_URL_NODES_FULLSCREEN_KEY),
);
+ const [showSkillsFull, setShowSkillsFull] = useState(() =>
+ loadBoolPref(GRAPH_SKILL_NODES_FULLSCREEN_KEY, true),
+ );
const nodeCount = stats?.nodes ?? 0;
const linkCount = stats?.links ?? 0;
@@ -313,6 +302,10 @@ export function GraphPanel({ activeDocName }: { activeDocName: string }) {
saveBoolPref(GRAPH_URL_NODES_FULLSCREEN_KEY, showUrlNodesFull);
}, [showUrlNodesFull]);
+ useEffect(() => {
+ saveBoolPref(GRAPH_SKILL_NODES_FULLSCREEN_KEY, showSkillsFull, true);
+ }, [showSkillsFull]);
+
useEffect(() => {
if (!isExpanded) return;
// Capture phase on `window` so the open-layer probe runs before Radix's
@@ -340,8 +333,26 @@ export function GraphPanel({ activeDocName }: { activeDocName: string }) {
}
}, [fullscreenMode, selectedNode]);
+ useEffect(() => {
+ if (
+ !showSkillsFull &&
+ selectedNode?.kind === 'doc' &&
+ (parseProjectSkillBundleDoc(selectedNode.docName) !== null ||
+ parseGlobalSkillBundleDoc(selectedNode.docName) !== null)
+ ) {
+ setSelectedNode(null);
+ }
+ }, [showSkillsFull, selectedNode]);
+
const activeMode = isExpanded ? fullscreenMode : 'explore';
const showUrlNodes = isExpanded ? showUrlNodesFull : showUrlNodesDocked;
+ // Docked stays unfiltered on both axes: it shows every skill node, built-ins
+ // included, because it is the surface for inspecting a skill's neighborhood.
+ const skillVisibility: GraphSkillVisibility = !isExpanded
+ ? 'all'
+ : showSkillsFull
+ ? 'hide-builtins'
+ : 'none';
const setShowUrlNodes = isExpanded ? setShowUrlNodesFull : setShowUrlNodesDocked;
const selectedNodeIntent =
selectedNode?.kind === 'doc' && !pageListLoading
@@ -526,6 +537,35 @@ export function GraphPanel({ activeDocName }: { activeDocName: string }) {
)}
</TooltipContent>
</Tooltip>
+ {isExpanded ? (
+ <Tooltip delayDuration={0}>
+ <TooltipTrigger asChild>
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ className="text-muted-foreground hover:text-foreground hover:bg-accent"
+ aria-label={showSkillsFull ? t`Hide skill nodes` : t`Show skill nodes`}
+ aria-pressed={showSkillsFull}
+ onClick={() => setShowSkillsFull((prev) => !prev)}
+ >
+ <Hexagon
+ className={
+ showSkillsFull
+ ? 'size-4 text-sidebar-accent-foreground'
+ : 'size-4 text-muted-foreground'
+ }
+ />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent side="bottom" sideOffset={8} className="z-[9999]">
+ {showSkillsFull ? (
+ <Trans>Hide skill nodes</Trans>
+ ) : (
+ <Trans>Show skill nodes</Trans>
+ )}
+ </TooltipContent>
+ </Tooltip>
+ ) : null}
<Tooltip delayDuration={0}>
<TooltipTrigger asChild>
<Button
@@ -556,6 +596,7 @@ export function GraphPanel({ activeDocName }: { activeDocName: string }) {
selectedNodeId={isExpanded ? (selectedNode?.id ?? null) : null}
isExpanded={isExpanded}
showUrlNodes={showUrlNodes}
+ skillVisibility={skillVisibility}
className="h-full min-h-0"
docClickBehavior={isExpanded ? 'select' : 'navigate'}
onSelectNode={isExpanded ? setSelectedNode : undefined}
diff --git a/packages/app/src/components/GraphView.tsx b/packages/app/src/components/GraphView.tsx
index a4e8524ac..575d49b7e 100644
--- a/packages/app/src/components/GraphView.tsx
+++ b/packages/app/src/components/GraphView.tsx
@@ -20,6 +20,7 @@ import {
planGraphLabels,
} from './graph-label-layout';
import { buildGraphLabelDescriptors } from './graph-label-utils';
+import { filterGraphSkillNodes, type GraphSkillVisibility } from './graph-skill-filter';
import {
buildGraphLinkSignature,
buildGraphNodeSignature,
@@ -506,6 +507,7 @@ export function GraphView({
showcase = false,
showcaseBaseline = null,
showUrlNodes = true,
+ skillVisibility = 'all',
className = '',
docClickBehavior = 'navigate',
onSelectNode,
@@ -525,6 +527,9 @@ export function GraphView({
* ADDITIONS get the staged pop-in entrance. */
showcaseBaseline?: { nodeIds: ReadonlySet<string>; linkKeys: ReadonlySet<string> } | null;
showUrlNodes?: boolean;
+ /** How much of the skill layer to draw. The docked local graph leaves this
+ * 'all' so a skill's own neighborhood stays inspectable there. */
+ skillVisibility?: GraphSkillVisibility;
className?: string;
docClickBehavior?: GraphDocClickBehavior;
onSelectNode?: (selection: GraphNodeSelection) => void;
@@ -755,7 +760,7 @@ export function GraphView({
// label budget than the docked 2-hop neighborhood view to avoid flooding.
const maxVisibleLabels = isExpanded ? 10 : 18;
- const displayData: GraphData = showUrlNodes
+ const urlFilteredData: GraphData = showUrlNodes
? graphData
: (() => {
const externalNodeIds = new Set(
@@ -771,6 +776,8 @@ export function GraphView({
};
})();
+ const displayData: GraphData = filterGraphSkillNodes(urlFilteredData, skillVisibility);
+
const layoutNodes = displayData.nodes as GraphLabelLayoutNode[];
const layoutLinks = displayData.links as GraphLabelLayoutLink[];
const labelDescriptors = buildGraphLabelDescriptors(displayData.nodes);
diff --git a/packages/app/src/components/graph-skill-filter.test.ts b/packages/app/src/components/graph-skill-filter.test.ts
new file mode 100644
index 000000000..8c485d9fd
--- /dev/null
+++ b/packages/app/src/components/graph-skill-filter.test.ts
@@ -0,0 +1,188 @@
+import { describe, expect, test } from 'vitest';
+import { filterGraphSkillNodes } from './graph-skill-filter';
+import type { GraphData } from './graph-view-utils';
+
+function doc(id: string, docName: string, managed = false) {
+ return {
+ kind: 'doc' as const,
+ id,
+ docName,
+ anchor: null,
+ label: docName,
+ ...(managed ? { managed: true as const } : {}),
+ };
+}
+
+/** A node the server flagged as one of OpenKnowledge's own bundles. */
+function builtinDoc(id: string, docName: string) {
+ return doc(id, docName, true);
+}
+
+function graph(
+ nodes: ReturnType<typeof doc>[],
+ links: Array<{ source: string; target: string }>,
+): GraphData {
+ return { nodes, links } as GraphData;
+}
+
+const BUILTIN_SKILL = '__skill__/global/open-knowledge-write-skill';
+const BUILTIN_REF = '__skill__/global/open-knowledge-write-skill/references/patterns';
+const USER_SKILL = '__skill__/global/my-notes';
+const PROJECT_SKILL = '.claude/skills/team-conventions/SKILL';
+const PACK_SKILL = '__skill__/global/open-knowledge-pack-worldbuilding';
+
+const SHOW_FULLSCREEN = 'hide-builtins' as const;
+const DOCKED = 'all' as const;
+const HIDE_ALL = 'none' as const;
+
+describe('filterGraphSkillNodes', () => {
+ test('drops an unreferenced built-in bundle, keeping content and user skills', () => {
+ const result = filterGraphSkillNodes(
+ graph(
+ [
+ doc('a', 'notes/index'),
+ builtinDoc('b', BUILTIN_SKILL),
+ builtinDoc('c', BUILTIN_REF),
+ doc('d', USER_SKILL),
+ ],
+ [{ source: 'b', target: 'c' }],
+ ),
+ SHOW_FULLSCREEN,
+ );
+ expect(result.nodes.map((n) => n.id).sort()).toEqual(['a', 'd']);
+ expect(result.links).toEqual([]);
+ });
+
+ test("a bundle's own structural edges do not make it self-referenced", () => {
+ // The SKILL→reference edge crosses no bundle boundary. If it counted, no
+ // built-in would ever be hidden and the default would be a no-op.
+ const result = filterGraphSkillNodes(
+ graph(
+ [builtinDoc('b', BUILTIN_SKILL), builtinDoc('c', BUILTIN_REF)],
+ [{ source: 'b', target: 'c' }],
+ ),
+ SHOW_FULLSCREEN,
+ );
+ expect(result.nodes).toEqual([]);
+ });
+
+ test('keeps a built-in that another skill links directly, with its references', () => {
+ const result = filterGraphSkillNodes(
+ graph(
+ [doc('u', USER_SKILL), builtinDoc('b', BUILTIN_SKILL), builtinDoc('c', BUILTIN_REF)],
+ [
+ { source: 'u', target: 'b' },
+ { source: 'b', target: 'c' },
+ ],
+ ),
+ SHOW_FULLSCREEN,
+ );
+ expect(result.nodes.map((n) => n.id).sort()).toEqual(['b', 'c', 'u']);
+ expect(result.links).toHaveLength(2);
+ });
+
+ test('never hides a user skill whose name merely looks built-in', () => {
+ // `open-knowledge-pack-*` installs are real user skills kept indefinitely. The
+ // app classifies purely on the server's flag, so a name that resembles a
+ // built-in is not enough to hide it.
+ const result = filterGraphSkillNodes(graph([doc('p', PACK_SKILL)], []), SHOW_FULLSCREEN);
+ expect(result.nodes.map((n) => n.id)).toEqual(['p']);
+ });
+
+ test('an unflagged node is never treated as built-in, whatever it is named', () => {
+ const result = filterGraphSkillNodes(
+ graph([doc('b', BUILTIN_SKILL), doc('c', BUILTIN_REF)], [{ source: 'b', target: 'c' }]),
+ SHOW_FULLSCREEN,
+ );
+ expect(result.nodes.map((n) => n.id).sort()).toEqual(['b', 'c']);
+ });
+
+ test('keeps project skills at the default setting', () => {
+ const result = filterGraphSkillNodes(graph([doc('p', PROJECT_SKILL)], []), SHOW_FULLSCREEN);
+ expect(result.nodes.map((n) => n.id)).toEqual(['p']);
+ });
+
+ test('showSkills=false drops every skill node including referenced built-ins', () => {
+ const result = filterGraphSkillNodes(
+ graph(
+ [
+ doc('a', 'notes/index'),
+ doc('u', USER_SKILL),
+ builtinDoc('b', BUILTIN_SKILL),
+ doc('p', PROJECT_SKILL),
+ ],
+ [
+ { source: 'u', target: 'b' },
+ { source: 'a', target: 'p' },
+ ],
+ ),
+ HIDE_ALL,
+ );
+ expect(result.nodes.map((n) => n.id)).toEqual(['a']);
+ expect(result.links).toEqual([]);
+ });
+
+ test('the docked local graph keeps unreferenced built-ins', () => {
+ const result = filterGraphSkillNodes(
+ graph(
+ [builtinDoc('b', BUILTIN_SKILL), builtinDoc('c', BUILTIN_REF)],
+ [{ source: 'b', target: 'c' }],
+ ),
+ DOCKED,
+ );
+ expect(result.nodes.map((n) => n.id).sort()).toEqual(['b', 'c']);
+ });
+
+ test('a graph with no skill nodes is returned untouched', () => {
+ const input = graph([doc('a', 'notes/index')], []);
+ expect(filterGraphSkillNodes(input, SHOW_FULLSCREEN)).toBe(input);
+ });
+
+ test('hides the project-scope built-in projection as well as the global ones', () => {
+ const result = filterGraphSkillNodes(
+ graph(
+ [
+ builtinDoc('g', '__skill__/global/open-knowledge-discovery'),
+ builtinDoc('p', '.claude/skills/open-knowledge/SKILL'),
+ ],
+ [],
+ ),
+ SHOW_FULLSCREEN,
+ );
+ expect(result.nodes).toEqual([]);
+ });
+
+ test('keeps a built-in connected to a user skill regardless of authored direction', () => {
+ // The link graph mirrors SKILL-to-SKILL refs, so edge direction cannot identify
+ // which document authored the ref.
+ const result = filterGraphSkillNodes(
+ graph(
+ [builtinDoc('b', BUILTIN_SKILL), doc('u', USER_SKILL)],
+ [
+ { source: 'b', target: 'u' },
+ { source: 'u', target: 'b' },
+ ],
+ ),
+ SHOW_FULLSCREEN,
+ );
+ expect(result.nodes.map((n) => n.id).sort()).toEqual(['b', 'u']);
+ expect(result.links).toHaveLength(2);
+ });
+
+ test('keeps built-ins connected across bundle boundaries visible', () => {
+ const result = filterGraphSkillNodes(
+ graph(
+ [
+ builtinDoc('b', BUILTIN_SKILL),
+ builtinDoc('d', '__skill__/global/open-knowledge-discovery'),
+ ],
+ [
+ { source: 'b', target: 'd' },
+ { source: 'd', target: 'b' },
+ ],
+ ),
+ SHOW_FULLSCREEN,
+ );
+ expect(result.nodes.map((n) => n.id).sort()).toEqual(['b', 'd']);
+ });
+});
diff --git a/packages/app/src/components/graph-skill-filter.ts b/packages/app/src/components/graph-skill-filter.ts
new file mode 100644
index 000000000..e8c06bc95
--- /dev/null
+++ b/packages/app/src/components/graph-skill-filter.ts
@@ -0,0 +1,86 @@
+import { parseGlobalSkillBundleDoc, parseProjectSkillBundleDoc } from '@inkeep/open-knowledge-core';
+import { type GraphData, getGraphLinkEndpointId } from './graph-view-utils';
+
+/**
+ * How much of the skill layer the graph draws.
+ *
+ * - `all` — every skill node. The docked local graph, which exists to
+ * show what a given doc (skill included) connects to.
+ * - `hide-builtins`— the fullscreen default: the user's own skills, but not
+ * OpenKnowledge's, unless something links at one.
+ * - `none` — no skill nodes at all.
+ */
+export type GraphSkillVisibility = 'all' | 'hide-builtins' | 'none';
+
+/**
+ * Identity of the skill bundle a node belongs to, or null when it is not part of
+ * one. Scope is part of the key: a project skill and a global skill can share a
+ * name while being separate bundles that never link to each other.
+ */
+function bundleKeyForDocName(docName: string): string | null {
+ const project = parseProjectSkillBundleDoc(docName);
+ if (project) return `project:${project.name}`;
+ const global = parseGlobalSkillBundleDoc(docName);
+ if (global) return `global:${global.name}`;
+ return null;
+}
+
+/**
+ * Apply skill-node visibility to a graph payload.
+ *
+ * Which bundles are OpenKnowledge's own is read from the server-set `managed`
+ * flag, never re-derived from names here — the reserved names live in the server
+ * package, and a second copy in the app would be free to drift.
+ *
+ * Skill-reference edges are mirrored in the link-graph payload, so direction does
+ * not reveal which skill authored a ref. The server-side bundle guard therefore
+ * requires managed user-global bundles to author no skill refs. Under that
+ * invariant, any edge crossing a managed bundle boundary means another skill
+ * references it. Bundle-internal SKILL-to-reference edges do not count because
+ * they cross no bundle boundary.
+ */
+export function filterGraphSkillNodes(
+ data: GraphData,
+ visibility: GraphSkillVisibility,
+): GraphData {
+ if (visibility === 'all') return data;
+
+ const bundleKeyByNodeId = new Map<string, string>();
+ const managedBundleKeys = new Set<string>();
+ for (const node of data.nodes) {
+ if (node.kind !== 'doc') continue;
+ const bundleKey = bundleKeyForDocName(node.docName);
+ if (bundleKey === null) continue;
+ bundleKeyByNodeId.set(node.id, bundleKey);
+ if (node.managed === true) managedBundleKeys.add(bundleKey);
+ }
+ if (bundleKeyByNodeId.size === 0) return data;
+
+ const referencedBundles = new Set<string>();
+ if (visibility === 'hide-builtins') {
+ for (const link of data.links) {
+ const sourceBundle = bundleKeyByNodeId.get(getGraphLinkEndpointId(link.source)) ?? null;
+ const targetBundle = bundleKeyByNodeId.get(getGraphLinkEndpointId(link.target)) ?? null;
+ if (sourceBundle === targetBundle) continue;
+ if (targetBundle !== null) referencedBundles.add(targetBundle);
+ }
+ }
+
+ const hiddenNodeIds = new Set<string>();
+ for (const [nodeId, bundleKey] of bundleKeyByNodeId) {
+ const hidden =
+ visibility === 'none' ||
+ (managedBundleKeys.has(bundleKey) && !referencedBundles.has(bundleKey));
+ if (hidden) hiddenNodeIds.add(nodeId);
+ }
+ if (hiddenNodeIds.size === 0) return data;
+
+ return {
+ nodes: data.nodes.filter((node) => !hiddenNodeIds.has(node.id)),
+ links: data.links.filter(
+ (link) =>
+ !hiddenNodeIds.has(getGraphLinkEndpointId(link.source)) &&
+ !hiddenNodeIds.has(getGraphLinkEndpointId(link.target)),
+ ),
+ };
+}
diff --git a/packages/app/src/components/graph-view-utils.ts b/packages/app/src/components/graph-view-utils.ts
index b7647b813..f5c27ce49 100644
--- a/packages/app/src/components/graph-view-utils.ts
+++ b/packages/app/src/components/graph-view-utils.ts
@@ -9,6 +9,10 @@ interface DocGraphNode {
cluster?: string | null;
category?: string | null;
tags?: string[] | null;
+ /** Server-set: this node belongs to one of OpenKnowledge's own skill bundles.
+ * The reserved names live in the server package, so the classification arrives
+ * on the payload rather than being re-derived here. */
+ managed?: boolean;
/** Wall-clock ms this node first entered the rendered graph (birth animation). */
bornAt?: number;
}
diff --git a/packages/app/src/lib/bool-pref.dom.test.ts b/packages/app/src/lib/bool-pref.dom.test.ts
new file mode 100644
index 000000000..00c8c9233
--- /dev/null
+++ b/packages/app/src/lib/bool-pref.dom.test.ts
@@ -0,0 +1,109 @@
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
+import { loadBoolPref, saveBoolPref } from './bool-pref';
+
+const KEY = 'test-pref';
+
+function installStorage(impl?: Partial<Storage>): Map<string, string> {
+ const entries = new Map<string, string>();
+ const storage = {
+ get length() {
+ return entries.size;
+ },
+ clear: () => entries.clear(),
+ getItem: (key: string) => entries.get(key) ?? null,
+ key: (index: number) => [...entries.keys()][index] ?? null,
+ removeItem: (key: string) => void entries.delete(key),
+ setItem: (key: string, value: string) => void entries.set(key, String(value)),
+ ...impl,
+ } as Storage;
+ Object.defineProperty(window, 'localStorage', {
+ configurable: true,
+ value: storage,
+ writable: true,
+ });
+ return entries;
+}
+
+describe('bool-pref', () => {
+ let entries: Map<string, string>;
+
+ beforeEach(() => {
+ entries = installStorage();
+ });
+
+ afterEach(() => {
+ vi.restoreAllMocks();
+ });
+
+ describe('default-off preferences (the pre-existing behavior)', () => {
+ test('absent reads false and true persists as the deviation', () => {
+ expect(loadBoolPref(KEY)).toBe(false);
+ saveBoolPref(KEY, true);
+ expect(entries.get(KEY)).toBe('true');
+ expect(loadBoolPref(KEY)).toBe(true);
+ });
+
+ test('returning to the default clears the key rather than storing it', () => {
+ saveBoolPref(KEY, true);
+ saveBoolPref(KEY, false);
+ expect(entries.has(KEY)).toBe(false);
+ expect(loadBoolPref(KEY)).toBe(false);
+ });
+
+ test("a value written by the older 'true'-only writer still reads true", () => {
+ // Existing installs carry keys written before defaults were supported.
+ entries.set(KEY, 'true');
+ expect(loadBoolPref(KEY)).toBe(true);
+ });
+ });
+
+ describe('default-on preferences', () => {
+ test('absent reads true', () => {
+ expect(loadBoolPref(KEY, true)).toBe(true);
+ });
+
+ test('false persists as the deviation and reads back', () => {
+ saveBoolPref(KEY, false, true);
+ expect(entries.get(KEY)).toBe('false');
+ expect(loadBoolPref(KEY, true)).toBe(false);
+ });
+
+ test('returning to the default clears the key', () => {
+ saveBoolPref(KEY, false, true);
+ saveBoolPref(KEY, true, true);
+ expect(entries.has(KEY)).toBe(false);
+ expect(loadBoolPref(KEY, true)).toBe(true);
+ });
+
+ test('clearing storage restores the default instead of flipping it off', () => {
+ saveBoolPref(KEY, false, true);
+ entries.clear();
+ expect(loadBoolPref(KEY, true)).toBe(true);
+ });
+ });
+
+ describe('storage is a trust boundary', () => {
+ test('a throwing read falls back to the default', () => {
+ installStorage({
+ getItem: () => {
+ throw new Error('SecurityError');
+ },
+ });
+ expect(loadBoolPref(KEY)).toBe(false);
+ expect(loadBoolPref(KEY, true)).toBe(true);
+ });
+
+ test('a throwing write is swallowed so the caller still works', () => {
+ installStorage({
+ setItem: () => {
+ throw new Error('QuotaExceededError');
+ },
+ removeItem: () => {
+ throw new Error('QuotaExceededError');
+ },
+ });
+ expect(() => saveBoolPref(KEY, true)).not.toThrow();
+ expect(() => saveBoolPref(KEY, false, true)).not.toThrow();
+ });
+ });
+});
diff --git a/packages/app/src/lib/bool-pref.ts b/packages/app/src/lib/bool-pref.ts
new file mode 100644
index 000000000..697d1bf67
--- /dev/null
+++ b/packages/app/src/lib/bool-pref.ts
@@ -0,0 +1,46 @@
+/**
+ * Machine-local yes/no view preferences, stored in `localStorage`.
+ *
+ * `defaultValue` is what an ABSENT key means, and storage holds only the
+ * DEVIATION from it: a default-on preference persists `'false'`, a default-off
+ * one persists `'true'`, and returning to the default clears the key. That keeps
+ * cleared storage equal to intended defaults instead of silently flipping every
+ * default-on preference off.
+ *
+ * SCOPE: this helper owns the `'true'`/`'false'` encoding, which is what most of
+ * the app's boolean prefs already use. A minority of older prefs encode `'1'`/`'0'`
+ * with always-store semantics instead (`acp/follow-file.ts`,
+ * `lib/terminal-new-tab-store.ts`, and others). That split predates this helper and
+ * is deliberate to leave alone: adopting it for a `'1'`/`'0'` pref would misread
+ * every already-stored value, so migrating one needs a read-both-write-new shim
+ * per key, not a call-site swap. Prefer this helper for NEW boolean prefs rather
+ * than adding a third encoding.
+ *
+ * Browser storage is a trust boundary — it throws on quota exhaustion and in
+ * some private-browsing modes, and is absent entirely in non-browser contexts.
+ * Both helpers swallow those failures: a preference that cannot persist degrades
+ * to in-memory for the session rather than breaking the surface that reads it.
+ */
+export function loadBoolPref(key: string, defaultValue = false): boolean {
+ if (typeof window === 'undefined') return defaultValue;
+ try {
+ const stored = window.localStorage.getItem(key);
+ if (stored === null) return defaultValue;
+ return stored === 'true';
+ } catch {
+ return defaultValue;
+ }
+}
+
+export function saveBoolPref(key: string, value: boolean, defaultValue = false): void {
+ if (typeof window === 'undefined') return;
+ try {
+ if (value === defaultValue) {
+ window.localStorage.removeItem(key);
+ } else {
+ window.localStorage.setItem(key, value ? 'true' : 'false');
+ }
+ } catch {
+ // quota exceeded / private mode — ignore, stays in-memory
+ }
+}
diff --git a/packages/app/src/locales/ar/messages.json b/packages/app/src/locales/ar/messages.json
index 1520976b3..eb79efe51 100644
--- a/packages/app/src/locales/ar/messages.json
+++ b/packages/app/src/locales/ar/messages.json
@@ -4246,6 +4246,7 @@
"qFWMl-": ["العرض كنص"],
"qIJIrD": ["يجري الاختبار"],
"qJSo0_": ["ما الفرق بين النسخ والروابط الرمزية؟"],
+ "qKMfPp": ["إخفاء عقد المهارات"],
"qNOgUu": ["تصل التعديلات من المصدر إلى هنا — بلا انحراف نسخ ولصق."],
"qQi_um": ["تم استيراد السمة."],
"qRZh7J": ["دع مفتاح Tab يخرج من محرر المصدر بدلًا من الإزاحة."],
@@ -4704,6 +4705,7 @@
"vy_VIN": [
"متتبَّع في git — تتدفق التحديثات عبر مستودعك (بالسحب أو التكامل المستمر)، لا بالتحديث التلقائي"
],
+ "w0YVAE": ["إظهار عقد المهارات"],
"w3tVpc": ["لا توجد روابط بعد. أضف روابط ويكي أو روابط Markdown لبناء رسم بياني."],
"w3vFfL": ["إخفاء الملفات"],
"w4ZzmQ": ["تعذّر الوصول إلى مزوّد التضمينات — أعد المحاولة"],
diff --git a/packages/app/src/locales/ar/messages.po b/packages/app/src/locales/ar/messages.po
index 1aacf3d84..80c758cbe 100644
--- a/packages/app/src/locales/ar/messages.po
+++ b/packages/app/src/locales/ar/messages.po
@@ -6054,6 +6054,10 @@ msgstr "إخفاء معاينة التحديد"
msgid "Hide sidebar"
msgstr "إخفاء الشريط الجانبي"
+#: src/components/GraphPanel.tsx
+msgid "Hide skill nodes"
+msgstr "إخفاء عقد المهارات"
+
#: src/components/command-palette-commands.ts
msgid "Hide Terminal"
msgstr "إخفاء Terminal"
@@ -11128,6 +11132,10 @@ msgstr "إظهار معاينة التحديد"
msgid "Show sidebar"
msgstr "إظهار الشريط الجانبي"
+#: src/components/GraphPanel.tsx
+msgid "Show skill nodes"
+msgstr "إظهار عقد المهارات"
+
#: src/components/MermaidFileViewer.tsx
msgid "Show source"
msgstr "إظهار المصدر"
diff --git a/packages/app/src/locales/bn/messages.json b/packages/app/src/locales/bn/messages.json
index e14ddb2a6..95d1307a0 100644
--- a/packages/app/src/locales/bn/messages.json
+++ b/packages/app/src/locales/bn/messages.json
@@ -3624,6 +3624,7 @@
"qFWMl-": ["লেখা হিসেবে দেখুন"],
"qIJIrD": ["পরীক্ষা করা হচ্ছে"],
"qJSo0_": ["অনুলিপি ও সিমলিংকের মধ্যে পার্থক্য কী?"],
+ "qKMfPp": ["স্কিল নোড লুকান"],
"qNOgUu": ["উৎসে করা সম্পাদনা এখানে এসে পড়ে — কপি-পেস্টের কোনো বিচ্যুতি নেই।"],
"qQi_um": ["থিম আমদানি করা হয়েছে।"],
"qRZh7J": ["Tab যেন ভেতরে না নিয়ে সোর্স সম্পাদক থেকে বেরিয়ে যায়।"],
@@ -3993,6 +3994,7 @@
"vvWZnu": ["পার্থক্য অনুপলব্ধ"],
"vwV-kH": ["ফাইল ঠিক করার কাজ অপ্রত্যাশিতভাবে থেমে গেছে।"],
"vy_VIN": ["git-এ হিসাবভুক্ত — হালনাগাদ আপনার রিপোজিটরির মাধ্যমে আসে (pull বা CI), স্বয়ংক্রিয় হালনাগাদে নয়"],
+ "w0YVAE": ["স্কিল নোড দেখান"],
"w3tVpc": ["এখনও কোনো লিংক নেই। গ্রাফ গড়তে উইকি লিংক বা markdown লিংক যোগ করুন।"],
"w3vFfL": ["Files লুকান"],
"w4ZzmQ": ["এমবেডিং সরবরাহকারীর নাগাল পাওয়া যায়নি — আবার চেষ্টা করুন"],
diff --git a/packages/app/src/locales/bn/messages.po b/packages/app/src/locales/bn/messages.po
index 3cc3e2fac..1bc404918 100644
--- a/packages/app/src/locales/bn/messages.po
+++ b/packages/app/src/locales/bn/messages.po
@@ -6050,6 +6050,10 @@ msgstr "নির্বাচনের প্রাকদর্শন লুক
msgid "Hide sidebar"
msgstr "সাইডবার লুকান"
+#: src/components/GraphPanel.tsx
+msgid "Hide skill nodes"
+msgstr "স্কিল নোড লুকান"
+
#: src/components/command-palette-commands.ts
msgid "Hide Terminal"
msgstr "Terminal লুকান"
@@ -11124,6 +11128,10 @@ msgstr "নির্বাচনের প্রাকদর্শন দেখ
msgid "Show sidebar"
msgstr "সাইডবার দেখান"
+#: src/components/GraphPanel.tsx
+msgid "Show skill nodes"
+msgstr "স্কিল নোড দেখান"
+
#: src/components/MermaidFileViewer.tsx
msgid "Show source"
msgstr "সোর্স দেখান"
diff --git a/packages/app/src/locales/en/messages.json b/packages/app/src/locales/en/messages.json
index 015783909..a34ea3bbb 100644
--- a/packages/app/src/locales/en/messages.json
+++ b/packages/app/src/locales/en/messages.json
@@ -3735,6 +3735,7 @@
"qFWMl-": ["View as text"],
"qIJIrD": ["Testing"],
"qJSo0_": ["What is the difference between copies and symlinks?"],
+ "qKMfPp": ["Hide skill nodes"],
"qNOgUu": ["Edits at the source land here — no copy-paste drift."],
"qQi_um": ["Theme imported."],
"qRZh7J": ["Let Tab leave the source editor instead of indenting."],
@@ -4132,6 +4133,7 @@
"vvWZnu": ["Diff unavailable"],
"vwV-kH": ["Fixing files stopped unexpectedly."],
"vy_VIN": ["Tracked in git — updates flow through your repo (pull or CI), not auto-update"],
+ "w0YVAE": ["Show skill nodes"],
"w3tVpc": ["No links yet. Add wiki links or markdown links to build a graph."],
"w3vFfL": ["Hide Files"],
"w4ZzmQ": ["Couldn't reach the embeddings provider — retry"],
diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.po
index 68764c775..e83509c35 100644
--- a/packages/app/src/locales/en/messages.po
+++ b/packages/app/src/locales/en/messages.po
@@ -6054,6 +6054,10 @@ msgstr "Hide selection preview"
msgid "Hide sidebar"
msgstr "Hide sidebar"
+#: src/components/GraphPanel.tsx
+msgid "Hide skill nodes"
+msgstr "Hide skill nodes"
+
#: src/components/command-palette-commands.ts
msgid "Hide Terminal"
msgstr "Hide Terminal"
@@ -11128,6 +11132,10 @@ msgstr "Show selection preview"
msgid "Show sidebar"
msgstr "Show sidebar"
+#: src/components/GraphPanel.tsx
+msgid "Show skill nodes"
+msgstr "Show skill nodes"
+
#: src/components/MermaidFileViewer.tsx
msgid "Show source"
msgstr "Show source"
diff --git a/packages/app/src/locales/es/messages.json b/packages/app/src/locales/es/messages.json
index 5ccaa00af..878a678ba 100644
--- a/packages/app/src/locales/es/messages.json
+++ b/packages/app/src/locales/es/messages.json
@@ -4325,6 +4325,7 @@
"qFWMl-": ["Ver como texto"],
"qIJIrD": ["Probando"],
"qJSo0_": ["¿Qué diferencia hay entre las copias y los enlaces simbólicos?"],
+ "qKMfPp": ["Ocultar los nodos de habilidades"],
"qNOgUu": [
"Las ediciones hechas en el origen llegan aquí: sin desviaciones por copiar y pegar."
],
@@ -4783,6 +4784,7 @@
"vy_VIN": [
"Seguido en git: las actualizaciones llegan por tu repositorio (pull o CI), no por actualización automática"
],
+ "w0YVAE": ["Mostrar los nodos de habilidades"],
"w3tVpc": [
"Todavía no hay enlaces. Añade enlaces wiki o enlaces markdown para construir un grafo."
],
diff --git a/packages/app/src/locales/es/messages.po b/packages/app/src/locales/es/messages.po
index 02651488f..5c17c61d5 100644
--- a/packages/app/src/locales/es/messages.po
+++ b/packages/app/src/locales/es/messages.po
@@ -6054,6 +6054,10 @@ msgstr "Ocultar la vista previa de la selección"
msgid "Hide sidebar"
msgstr "Ocultar la barra lateral"
+#: src/components/GraphPanel.tsx
+msgid "Hide skill nodes"
+msgstr "Ocultar los nodos de habilidades"
+
#: src/components/command-palette-commands.ts
msgid "Hide Terminal"
msgstr "Ocultar Terminal"
@@ -11128,6 +11132,10 @@ msgstr "Mostrar la vista previa de la selección"
msgid "Show sidebar"
msgstr "Mostrar la barra lateral"
+#: src/components/GraphPanel.tsx
+msgid "Show skill nodes"
+msgstr "Mostrar los nodos de habilidades"
+
#: src/components/MermaidFileViewer.tsx
msgid "Show source"
msgstr "Mostrar el código"
diff --git a/packages/app/src/locales/fr/messages.json b/packages/app/src/locales/fr/messages.json
index 1192467af..86b990243 100644
--- a/packages/app/src/locales/fr/messages.json
+++ b/packages/app/src/locales/fr/messages.json
@@ -4376,6 +4376,7 @@
"qFWMl-": ["Afficher comme texte"],
"qIJIrD": ["Test en cours"],
"qJSo0_": ["Quelle est la différence entre les copies et les liens symboliques ?"],
+ "qKMfPp": ["Masquer les nœuds de compétences"],
"qNOgUu": [
"Les modifications faites à la source arrivent ici — aucune dérive due au copier-coller."
],
@@ -4843,6 +4844,7 @@
"vy_VIN": [
"Suivi dans git — les mises à jour arrivent via votre dépôt (pull ou CI), pas par mise à jour automatique"
],
+ "w0YVAE": ["Afficher les nœuds de compétences"],
"w3tVpc": [
"Pas encore de liens. Ajoutez des liens wiki ou markdown pour construire un graphe."
],
diff --git a/packages/app/src/locales/fr/messages.po b/packages/app/src/locales/fr/messages.po
index 8d3dc4c71..f96188a61 100644
--- a/packages/app/src/locales/fr/messages.po
+++ b/packages/app/src/locales/fr/messages.po
@@ -6054,6 +6054,10 @@ msgstr "Masquer l'aperçu de la sélection"
msgid "Hide sidebar"
msgstr "Masquer la barre latérale"
+#: src/components/GraphPanel.tsx
+msgid "Hide skill nodes"
+msgstr "Masquer les nœuds de compétences"
+
#: src/components/command-palette-commands.ts
msgid "Hide Terminal"
msgstr "Masquer Terminal"
@@ -11128,6 +11132,10 @@ msgstr "Afficher l'aperçu de la sélection"
msgid "Show sidebar"
msgstr "Afficher la barre latérale"
+#: src/components/GraphPanel.tsx
+msgid "Show skill nodes"
+msgstr "Afficher les nœuds de compétences"
+
#: src/components/MermaidFileViewer.tsx
msgid "Show source"
msgstr "Afficher la source"
diff --git a/packages/app/src/locales/hi/messages.json b/packages/app/src/locales/hi/messages.json
index 410a22985..9ae0a5f11 100644
--- a/packages/app/src/locales/hi/messages.json
+++ b/packages/app/src/locales/hi/messages.json
@@ -3613,6 +3613,7 @@
"qFWMl-": ["पाठ के रूप में देखें"],
"qIJIrD": ["जाँचा जा रहा है"],
"qJSo0_": ["प्रतियों और सिमलिंक में क्या अंतर है?"],
+ "qKMfPp": ["स्किल नोड छिपाएँ"],
"qNOgUu": ["स्रोत पर किए गए संपादन यहाँ आते हैं — कॉपी-पेस्ट का कोई बिखराव नहीं।"],
"qQi_um": ["थीम आयात की गई।"],
"qRZh7J": ["Tab को अंदर करने के बजाय स्रोत संपादक से बाहर जाने दें।"],
@@ -3984,6 +3985,7 @@
"vy_VIN": [
"git में ट्रैक किया गया — अपडेट आपकी रिपॉज़िटरी के ज़रिए आते हैं (pull या CI), स्वत: अपडेट से नहीं"
],
+ "w0YVAE": ["स्किल नोड दिखाएँ"],
"w3tVpc": ["अभी कोई लिंक नहीं। ग्राफ़ बनाने के लिए विकी लिंक या markdown लिंक जोड़ें।"],
"w3vFfL": ["Files छिपाएँ"],
"w4ZzmQ": ["एम्बेडिंग प्रदाता तक नहीं पहुँचा जा सका — फिर कोशिश करें"],
diff --git a/packages/app/src/locales/hi/messages.po b/packages/app/src/locales/hi/messages.po
index 9bf7b2455..892a7916d 100644
--- a/packages/app/src/locales/hi/messages.po
+++ b/packages/app/src/locales/hi/messages.po
@@ -6050,6 +6050,10 @@ msgstr "चयन पूर्वावलोकन छिपाएँ"
msgid "Hide sidebar"
msgstr "साइडबार छिपाएँ"
+#: src/components/GraphPanel.tsx
+msgid "Hide skill nodes"
+msgstr "स्किल नोड छिपाएँ"
+
#: src/components/command-palette-commands.ts
msgid "Hide Terminal"
msgstr "Terminal छिपाएँ"
@@ -11124,6 +11128,10 @@ msgstr "चयन पूर्वावलोकन दिखाएँ"
msgid "Show sidebar"
msgstr "साइडबार दिखाएँ"
+#: src/components/GraphPanel.tsx
+msgid "Show skill nodes"
+msgstr "स्किल नोड दिखाएँ"
+
#: src/components/MermaidFileViewer.tsx
msgid "Show source"
msgstr "स्रोत दिखाएँ"
diff --git a/packages/app/src/locales/id/messages.json b/packages/app/src/locales/id/messages.json
index 4fafc77a9..11ba58992 100644
--- a/packages/app/src/locales/id/messages.json
+++ b/packages/app/src/locales/id/messages.json
@@ -3766,6 +3766,7 @@
"qFWMl-": ["Lihat sebagai teks"],
"qIJIrD": ["Menguji"],
"qJSo0_": ["Apa bedanya salinan dan symlink?"],
+ "qKMfPp": ["Sembunyikan simpul keterampilan"],
"qNOgUu": ["Suntingan di sumbernya sampai ke sini — tanpa penyimpangan salin-tempel."],
"qQi_um": ["Tema diimpor."],
"qRZh7J": ["Biarkan Tab keluar dari penyunting sumber alih-alih menambah indentasi."],
@@ -4148,6 +4149,7 @@
"vy_VIN": [
"Dilacak di git — pembaruan mengalir lewat repo Anda (pull atau CI), bukan pembaruan otomatis"
],
+ "w0YVAE": ["Tampilkan simpul keterampilan"],
"w3tVpc": [
"Belum ada tautan. Tambahkan tautan wiki atau tautan markdown untuk membangun sebuah graf."
],
diff --git a/packages/app/src/locales/id/messages.po b/packages/app/src/locales/id/messages.po
index a3c835716..028a7c8aa 100644
--- a/packages/app/src/locales/id/messages.po
+++ b/packages/app/src/locales/id/messages.po
@@ -6050,6 +6050,10 @@ msgstr "Sembunyikan pratinjau pilihan"
msgid "Hide sidebar"
msgstr "Sembunyikan bilah sisi"
+#: src/components/GraphPanel.tsx
+msgid "Hide skill nodes"
+msgstr "Sembunyikan simpul keterampilan"
+
#: src/components/command-palette-commands.ts
msgid "Hide Terminal"
msgstr "Sembunyikan Terminal"
@@ -11124,6 +11128,10 @@ msgstr "Tampilkan pratinjau pilihan"
msgid "Show sidebar"
msgstr "Tampilkan bilah sisi"
+#: src/components/GraphPanel.tsx
+msgid "Show skill nodes"
+msgstr "Tampilkan simpul keterampilan"
+
#: src/components/MermaidFileViewer.tsx
msgid "Show source"
msgstr "Tampilkan sumber"
diff --git a/packages/app/src/locales/pseudo/messages.json b/packages/app/src/locales/pseudo/messages.json
index f2b752f2e..4a1f3da6c 100644
--- a/packages/app/src/locales/pseudo/messages.json
+++ b/packages/app/src/locales/pseudo/messages.json
@@ -3735,6 +3735,7 @@
"qFWMl-": ["Vĩēŵ àś ţēxţ"],
"qIJIrD": ["Ţēśţĩńĝ"],
"qJSo0_": ["Ŵĥàţ ĩś ţĥē ďĩƒƒēŕēńćē ƀēţŵēēń ćōƥĩēś àńď śŷḿĺĩńķś?"],
+ "qKMfPp": ["Ĥĩďē śķĩĺĺ ńōďēś"],
"qNOgUu": ["Ēďĩţś àţ ţĥē śōũŕćē ĺàńď ĥēŕē — ńō ćōƥŷ-ƥàśţē ďŕĩƒţ."],
"qQi_um": ["Ţĥēḿē ĩḿƥōŕţēď."],
"qRZh7J": ["Ĺēţ Ţàƀ ĺēàvē ţĥē śōũŕćē ēďĩţōŕ ĩńśţēàď ōƒ ĩńďēńţĩńĝ."],
@@ -4132,6 +4133,7 @@
"vvWZnu": ["Ďĩƒƒ ũńàvàĩĺàƀĺē"],
"vwV-kH": ["Ƒĩxĩńĝ ƒĩĺēś śţōƥƥēď ũńēxƥēćţēďĺŷ."],
"vy_VIN": ["Ţŕàćķēď ĩń ĝĩţ — ũƥďàţēś ƒĺōŵ ţĥŕōũĝĥ ŷōũŕ ŕēƥō (ƥũĺĺ ōŕ ĆĨ), ńōţ àũţō-ũƥďàţē"],
+ "w0YVAE": ["Śĥōŵ śķĩĺĺ ńōďēś"],
"w3tVpc": ["Ńō ĺĩńķś ŷēţ. Àďď ŵĩķĩ ĺĩńķś ōŕ ḿàŕķďōŵń ĺĩńķś ţō ƀũĩĺď à ĝŕàƥĥ."],
"w3vFfL": ["Ĥĩďē Ƒĩĺēś"],
"w4ZzmQ": ["Ćōũĺďń'ţ ŕēàćĥ ţĥē ēḿƀēďďĩńĝś ƥŕōvĩďēŕ — ŕēţŕŷ"],
diff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.po
index 57ec41308..c9da87d4d 100644
--- a/packages/app/src/locales/pseudo/messages.po
+++ b/packages/app/src/locales/pseudo/messages.po
@@ -6050,6 +6050,10 @@ msgstr ""
msgid "Hide sidebar"
msgstr ""
+#: src/components/GraphPanel.tsx
+msgid "Hide skill nodes"
+msgstr ""
+
#: src/components/command-palette-commands.ts
msgid "Hide Terminal"
msgstr ""
@@ -11124,6 +11128,10 @@ msgstr ""
msgid "Show sidebar"
msgstr ""
+#: src/components/GraphPanel.tsx
+msgid "Show skill nodes"
+msgstr ""
+
#: src/components/MermaidFileViewer.tsx
msgid "Show source"
msgstr ""
diff --git a/packages/app/src/locales/pt-BR/messages.json b/packages/app/src/locales/pt-BR/messages.json
index 3583412b7..10555b990 100644
--- a/packages/app/src/locales/pt-BR/messages.json
+++ b/packages/app/src/locales/pt-BR/messages.json
@@ -4243,6 +4243,7 @@
"qFWMl-": ["Ver como texto"],
"qIJIrD": ["Testando"],
"qJSo0_": ["Qual é a diferença entre cópias e links simbólicos?"],
+ "qKMfPp": ["Ocultar os nós de habilidades"],
"qNOgUu": ["As edições feitas na fonte chegam aqui — sem desvio por copiar e colar."],
"qQi_um": ["Tema importado."],
"qRZh7J": ["Deixar o Tab sair do editor de código em vez de recuar."],
@@ -4690,6 +4691,7 @@
"vy_VIN": [
"Rastreado no git — as atualizações chegam pelo seu repositório (pull ou CI), não por atualização automática"
],
+ "w0YVAE": ["Mostrar os nós de habilidades"],
"w3tVpc": ["Ainda não há links. Adicione links wiki ou links markdown para montar um grafo."],
"w3vFfL": ["Ocultar Arquivos"],
"w4ZzmQ": ["Não deu para contatar o provedor de embeddings — tentar de novo"],
diff --git a/packages/app/src/locales/pt-BR/messages.po b/packages/app/src/locales/pt-BR/messages.po
index fe08b9cd4..295e6cfad 100644
--- a/packages/app/src/locales/pt-BR/messages.po
+++ b/packages/app/src/locales/pt-BR/messages.po
@@ -6050,6 +6050,10 @@ msgstr "Ocultar a pré-visualização da seleção"
msgid "Hide sidebar"
msgstr "Ocultar a barra lateral"
+#: src/components/GraphPanel.tsx
+msgid "Hide skill nodes"
+msgstr "Ocultar os nós de habilidades"
+
#: src/components/command-palette-commands.ts
msgid "Hide Terminal"
msgstr "Ocultar o Terminal"
@@ -11124,6 +11128,10 @@ msgstr "Mostrar a pré-visualização da seleção"
msgid "Show sidebar"
msgstr "Mostrar a barra lateral"
+#: src/components/GraphPanel.tsx
+msgid "Show skill nodes"
+msgstr "Mostrar os nós de habilidades"
+
#: src/components/MermaidFileViewer.tsx
msgid "Show source"
msgstr "Mostrar o código"
diff --git a/packages/app/src/locales/ur/messages.json b/packages/app/src/locales/ur/messages.json
index c779a665c..206968b7b 100644
--- a/packages/app/src/locales/ur/messages.json
+++ b/packages/app/src/locales/ur/messages.json
@@ -3819,6 +3819,7 @@
"qFWMl-": ["متن کے طور پر دیکھیں"],
"qIJIrD": ["جانچا جا رہا ہے"],
"qJSo0_": ["نقول اور سِم لنکس میں کیا فرق ہے؟"],
+ "qKMfPp": ["مہارت نوڈز چھپائیں"],
"qNOgUu": ["ماخذ پر ہونے والی ترامیم یہاں پہنچتی ہیں — نقل و چسپاں کا کوئی فرق نہیں۔"],
"qQi_um": ["تھیم درآمد ہو گئی۔"],
"qRZh7J": ["Tab کو سورس ایڈیٹر سے باہر نکلنے دیں، اندروں کھسکانے کے بجائے۔"],
@@ -4205,6 +4206,7 @@
"vy_VIN": [
"git میں ٹریک شدہ — اپ ڈیٹس آپ کے ریپو کے ذریعے آتی ہیں (کھینچ کر یا CI سے)، خودکار اپ ڈیٹ سے نہیں"
],
+ "w0YVAE": ["مہارت نوڈز دکھائیں"],
"w3tVpc": ["ابھی کوئی لنک نہیں۔ گراف بنانے کے لیے وکی لنکس یا Markdown لنکس شامل کریں۔"],
"w3vFfL": ["فائلیں چھپائیں"],
"w4ZzmQ": ["ایمبیڈنگز فراہم کنندہ تک رسائی نہیں ہو سکی — دوبارہ کوشش کریں"],
diff --git a/packages/app/src/locales/ur/messages.po b/packages/app/src/locales/ur/messages.po
index 71bcbf506..2720727d9 100644
--- a/packages/app/src/locales/ur/messages.po
+++ b/packages/app/src/locales/ur/messages.po
@@ -6054,6 +6054,10 @@ msgstr "انتخاب کا پیش منظر چھپائیں"
msgid "Hide sidebar"
msgstr "سائیڈ بار چھپائیں"
+#: src/components/GraphPanel.tsx
+msgid "Hide skill nodes"
+msgstr "مہارت نوڈز چھپائیں"
+
#: src/components/command-palette-commands.ts
msgid "Hide Terminal"
msgstr "Terminal چھپائیں"
@@ -11128,6 +11132,10 @@ msgstr "انتخاب کا پیش منظر دکھائیں"
msgid "Show sidebar"
msgstr "سائیڈ بار دکھائیں"
+#: src/components/GraphPanel.tsx
+msgid "Show skill nodes"
+msgstr "مہارت نوڈز دکھائیں"
+
#: src/components/MermaidFileViewer.tsx
msgid "Show source"
msgstr "سورس دکھائیں"
diff --git a/packages/app/src/locales/zh-Hans/messages.json b/packages/app/src/locales/zh-Hans/messages.json
index 1c5df2fdb..fb9872c88 100644
--- a/packages/app/src/locales/zh-Hans/messages.json
+++ b/packages/app/src/locales/zh-Hans/messages.json
@@ -3308,6 +3308,7 @@
"qFWMl-": ["以文本方式查看"],
"qIJIrD": ["正在测试"],
"qJSo0_": ["副本和符号链接有什么区别?"],
+ "qKMfPp": ["隐藏技能节点"],
"qNOgUu": ["在来源处的编辑会同步到这里——不会因复制粘贴而产生偏差。"],
"qQi_um": ["主题已导入。"],
"qRZh7J": ["让 Tab 键离开源码编辑器,而不是缩进。"],
@@ -3624,6 +3625,7 @@
"vvWZnu": ["无法显示差异"],
"vwV-kH": ["修复文件的过程意外中止。"],
"vy_VIN": ["受 git 跟踪——更新通过你的仓库(pull 或 CI)流入,而不是自动更新"],
+ "w0YVAE": ["显示技能节点"],
"w3tVpc": ["还没有链接。添加维基链接或 markdown 链接来构建关系图。"],
"w3vFfL": ["隐藏「文件」"],
"w4ZzmQ": ["无法连接到嵌入服务提供方——请重试"],
diff --git a/packages/app/src/locales/zh-Hans/messages.po b/packages/app/src/locales/zh-Hans/messages.po
index 80ee6b1da..192f10dbe 100644
--- a/packages/app/src/locales/zh-Hans/messages.po
+++ b/packages/app/src/locales/zh-Hans/messages.po
@@ -6054,6 +6054,10 @@ msgstr "隐藏选区预览"
msgid "Hide sidebar"
msgstr "隐藏侧边栏"
+#: src/components/GraphPanel.tsx
+msgid "Hide skill nodes"
+msgstr "隐藏技能节点"
+
#: src/components/command-palette-commands.ts
msgid "Hide Terminal"
msgstr "隐藏 Terminal"
@@ -11128,6 +11132,10 @@ msgstr "显示选区预览"
msgid "Show sidebar"
msgstr "显示侧边栏"
+#: src/components/GraphPanel.tsx
+msgid "Show skill nodes"
+msgstr "显示技能节点"
+
#: src/components/MermaidFileViewer.tsx
msgid "Show source"
msgstr "显示源码"
diff --git a/packages/app/src/locales/zh-Hant/messages.json b/packages/app/src/locales/zh-Hant/messages.json
index d3bfe4feb..217e2375c 100644
--- a/packages/app/src/locales/zh-Hant/messages.json
+++ b/packages/app/src/locales/zh-Hant/messages.json
@@ -3334,6 +3334,7 @@
"qFWMl-": ["以文字方式檢視"],
"qIJIrD": ["正在測試"],
"qJSo0_": ["副本和符號連結有什麼差別?"],
+ "qKMfPp": ["隱藏技能節點"],
"qNOgUu": ["在來源處的編輯會同步到這裡——不會因為複製貼上而產生偏差。"],
"qQi_um": ["主題已匯入。"],
"qRZh7J": ["讓 Tab 鍵離開原始碼編輯器,而不是縮排。"],
@@ -3652,6 +3653,7 @@
"vvWZnu": ["無法顯示差異"],
"vwV-kH": ["修復檔案的過程意外中止。"],
"vy_VIN": ["由 git 追蹤——更新是透過你的儲存庫(pull 或 CI)流入,不是自動更新"],
+ "w0YVAE": ["顯示技能節點"],
"w3tVpc": ["還沒有連結。加上維基連結或 markdown 連結來建立關係圖。"],
"w3vFfL": ["隱藏「檔案」"],
"w4ZzmQ": ["無法連上嵌入服務供應商——請再試一次"],
diff --git a/packages/app/src/locales/zh-Hant/messages.po b/packages/app/src/locales/zh-Hant/messages.po
index 8044adb15..3b3339baa 100644
--- a/packages/app/src/locales/zh-Hant/messages.po
+++ b/packages/app/src/locales/zh-Hant/messages.po
@@ -6054,6 +6054,10 @@ msgstr "隱藏選取範圍預覽"
msgid "Hide sidebar"
msgstr "隱藏側邊欄"
+#: src/components/GraphPanel.tsx
+msgid "Hide skill nodes"
+msgstr "隱藏技能節點"
+
#: src/components/command-palette-commands.ts
msgid "Hide Terminal"
msgstr "隱藏 Terminal"
@@ -11128,6 +11132,10 @@ msgstr "顯示選取範圍預覽"
msgid "Show sidebar"
msgstr "顯示側邊欄"
+#: src/components/GraphPanel.tsx
+msgid "Show skill nodes"
+msgstr "顯示技能節點"
+
#: src/components/MermaidFileViewer.tsx
msgid "Show source"
msgstr "顯示原始碼"
diff --git a/packages/core/src/bridge/bind-frontmatter-doc.ts b/packages/core/src/bridge/bind-frontmatter-doc.ts
index 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.ts
index 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.ts
index 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/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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/markdown/callout-transformer.ts b/packages/core/src/markdown/callout-transformer.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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): MdastRo
throw 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.ts
index 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.ts
index 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?: StructuralFreshnessChec
return 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.ts
index 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.ts
index 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.ts
index c400441b2..1e3ad29c6 100644
--- a/packages/core/src/markdown/lint/config-schemas.ts
+++ b/packages/core/src/markdown/lint/config-schemas.ts
@@ -39,6 +39,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.ts
index 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, MarkdownlintRuleSetting
MD013: 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.ts
index 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.ts
index 0d4c9a0df..b96d19182 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.ts
index af38c2ae2..1ca263610 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/plugins.ts b/packages/core/src/markdown/lint/plugins.ts
index 5e832aa19..be5871ed9 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 {
@@ -13,6 +14,7 @@ import {
type MarkdownlintSlice,
} from './types.ts';
+
const MarkdownlintRuleSettingSchema = z.union([
z.boolean(),
z.enum(MARKDOWNLINT_RULE_SEVERITIES),
diff --git a/packages/core/src/markdown/lint/types.ts b/packages/core/src/markdown/lint/types.ts
index 01ce4a5af..3dae5c031 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';
export const LINT_PLUGIN_IDS = ['markdownlint', 'frontmatter'] as const;
@@ -98,6 +99,7 @@ export interface FrontmatterSlice {
schemas: ResolvedFrontmatterSchemaEntry[];
}
+
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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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) {
diff --git a/packages/core/src/schemas/api/document-read.ts b/packages/core/src/schemas/api/document-read.ts
index 056134d56..63c2b068a 100644
--- a/packages/core/src/schemas/api/document-read.ts
+++ b/packages/core/src/schemas/api/document-read.ts
@@ -349,6 +349,12 @@ export const LinkGraphDocNodeSchema = z
cluster: z.string().nullable(),
category: z.string().nullable(),
tags: z.array(z.string()).nullable(),
+ /** True when this node belongs to one of OpenKnowledge's own shipped skill
+ * bundles. Server-set: the reserved bundle names live in the server package,
+ * which core and the app cannot import, so the classification travels on the
+ * payload rather than being re-derived (and duplicated) client-side. Absent
+ * for every ordinary document. */
+ managed: z.boolean().optional(),
})
.loose() satisfies StandardSchemaV1;
export type LinkGraphDocNode = z.infer<typeof LinkGraphDocNodeSchema>;
diff --git a/packages/server/src/api-link-graph-managed-skills.test.ts b/packages/server/src/api-link-graph-managed-skills.test.ts
new file mode 100644
index 000000000..155a68bfd
--- /dev/null
+++ b/packages/server/src/api-link-graph-managed-skills.test.ts
@@ -0,0 +1,84 @@
+import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';
+import { mkdtemp, rm } from 'node:fs/promises';
+import { tmpdir } from 'node:os';
+import { resolve } from 'node:path';
+import { afterAll, beforeAll, describe, expect, test } from 'vitest';
+import type { BootedServer } from './boot.ts';
+import { bootCompositionRig } from './composition-rig.test-helper.ts';
+
+/**
+ * `/api/link-graph` flags nodes belonging to OpenKnowledge's own skill bundles.
+ * The reserved bundle names live in this package, which core and the app cannot
+ * import, so the classification has to travel on the payload — the app filters
+ * OK's bundles out of the fullscreen graph purely from this flag and never
+ * re-derives it from doc names.
+ */
+
+let tmpRoot: string;
+let booted: BootedServer;
+
+function writeSkill(contentDir: string, name: string, body: string): void {
+ const dir = resolve(contentDir, '.claude', 'skills', name);
+ mkdirSync(dir, { recursive: true });
+ writeFileSync(resolve(dir, 'SKILL.md'), body, 'utf-8');
+}
+
+beforeAll(async () => {
+ tmpRoot = await mkdtemp(resolve(tmpdir(), 'ok-linkgraph-managed-'));
+ const contentDir = mkdtempSync(resolve(tmpRoot, 'content-'));
+
+ writeFileSync(resolve(contentDir, 'alpha.md'), '# Alpha\n\nLinks to [[beta]].\n', 'utf-8');
+ writeFileSync(resolve(contentDir, 'beta.md'), '# Beta\n\nBody.\n', 'utf-8');
+ // OK's own project bundle, under its reserved name.
+ writeSkill(contentDir, 'open-knowledge', '---\nname: open-knowledge\n---\n\n# OK\n');
+ // A user-authored project skill whose name merely resembles a reserved one.
+ writeSkill(
+ contentDir,
+ 'open-knowledge-pack-worldbuilding',
+ '---\nname: open-knowledge-pack-worldbuilding\n---\n\n# Pack\n',
+ );
+ // An ordinary user-authored project skill.
+ writeSkill(contentDir, 'team-notes', '---\nname: team-notes\n---\n\n# Team\n');
+
+ booted = await bootCompositionRig(contentDir);
+ await booted.ready;
+}, 60_000);
+
+afterAll(async () => {
+ await booted?.destroy();
+ await rm(tmpRoot, { recursive: true, force: true });
+});
+
+describe('/api/link-graph managed-skill flagging', () => {
+ test("project skills are graph nodes; only OK's own bundle is flagged", async () => {
+ const res = await fetch(`http://127.0.0.1:${booted.port}/api/link-graph`);
+ expect(res.status).toBe(200);
+ const body = (await res.json()) as {
+ nodes: Array<{ docName?: string; managed?: boolean }>;
+ };
+ const flagByDocName = new Map(
+ body.nodes
+ .filter((n): n is { docName: string; managed?: boolean } => n.docName !== undefined)
+ .map((n) => [n.docName, n.managed === true]),
+ );
+
+ // Project skills reach the graph as ordinary content docs, linked or not.
+ // Note this content dir is not a git repo, so the `.gitignore` carve-out that
+ // normally keeps OK's project bundle out of the index does not apply and the
+ // projection is indexed — the narrow case the spec records. The managed flag
+ // is what keeps it out of the fullscreen graph there.
+ expect([...flagByDocName.keys()].sort()).toEqual([
+ '.claude/skills/open-knowledge-pack-worldbuilding/SKILL',
+ '.claude/skills/open-knowledge/SKILL',
+ '.claude/skills/team-notes/SKILL',
+ 'alpha',
+ 'beta',
+ ]);
+
+ // Exactly one of them is OK's own. The pack-named skill is a real user
+ // install that merely resembles a reserved name and must stay unflagged.
+ expect([...flagByDocName.entries()].filter(([, flagged]) => flagged).map(([n]) => n)).toEqual([
+ '.claude/skills/open-knowledge/SKILL',
+ ]);
+ });
+});
diff --git a/packages/server/src/backlink-index.test.ts b/packages/server/src/backlink-index.test.ts
index e2a2d9113..971300e0d 100644
--- a/packages/server/src/backlink-index.test.ts
+++ b/packages/server/src/backlink-index.test.ts
@@ -827,7 +827,7 @@ describe('BacklinkIndex', () => {
writeFileSync(
join(cacheDir, 'backlinks.json'),
JSON.stringify({
- version: 1,
+ version: 2,
backward: {
ghost: [{ source: 'alpha', anchor: null, snippet: 'See ghost.' }],
// Invalid positions (hand-edited or corrupt cache) must degrade to
@@ -874,6 +874,57 @@ describe('BacklinkIndex', () => {
}
});
+ test('a v1 cache is rejected so skill refs are recorded instead of silently missing', async () => {
+ const projectDir = mkdtempSync(join(tmpdir(), 'ok-backlinks-skillrefs-guard-'));
+ const contentDir = join(projectDir, 'content');
+ mkdirSync(contentDir, { recursive: true });
+ try {
+ // `skillRefs` was added to the cache as an optional field without bumping
+ // the version, so a v1 cache loaded fine and deserialized it to empty.
+ // With mtimes matching disk the reconcile re-parses nothing, so
+ // `recordSkillRefs` never runs and every `/skill-name` edge a project
+ // skill authors stays missing for the life of the cache.
+ const analyze = '.agents/skills/analyze/SKILL';
+ const research = '.agents/skills/research/SKILL';
+ mkdirSync(join(contentDir, '.agents', 'skills', 'analyze'), { recursive: true });
+ mkdirSync(join(contentDir, '.agents', 'skills', 'research'), { recursive: true });
+ writeFileSync(
+ join(contentDir, '.agents', 'skills', 'analyze', 'SKILL.md'),
+ '# Analyze\n\nFor reports use /research.\n',
+ );
+ writeFileSync(join(contentDir, '.agents', 'skills', 'research', 'SKILL.md'), '# Research\n');
+
+ const cacheDir = join(projectDir, '.ok', LOCAL_DIR, 'cache', 'main');
+ mkdirSync(cacheDir, { recursive: true });
+ writeFileSync(
+ join(cacheDir, 'backlinks.json'),
+ JSON.stringify({
+ version: 1,
+ backward: {},
+ forward: { [analyze]: [], [research]: [] },
+ externalForward: {},
+ // No skillRefs key — exactly what a pre-skillRefs cache looks like.
+ // mtimes are filled in below so the reconcile would skip both files.
+ mtimes: {},
+ }),
+ 'utf-8',
+ );
+
+ const index = new BacklinkIndex({ projectDir, contentDir });
+ expect(await index.loadFromDisk()).toBe(false);
+
+ // The caller's fallback on a rejected load: a cold rebuild re-parses both
+ // files, so the ref edge is present.
+ await index.rebuildFromDisk();
+ expect(index.getForwardLinks(analyze)).toEqual([research]);
+ expect(index.getBacklinks(research)).toEqual([
+ { source: analyze, anchor: null, snippet: null },
+ ]);
+ } finally {
+ rmSync(projectDir, { recursive: true, force: true });
+ }
+ });
+
test('a versionless pre-upgrade cache is rejected so boot cold-rebuilds instead of serving stale keys', async () => {
const projectDir = mkdtempSync(join(tmpdir(), 'ok-backlinks-version-guard-'));
const contentDir = join(projectDir, 'content');
diff --git a/packages/server/src/backlink-index.ts b/packages/server/src/backlink-index.ts
index 18f63d65a..ca1762ba7 100644
--- a/packages/server/src/backlink-index.ts
+++ b/packages/server/src/backlink-index.ts
@@ -236,8 +236,16 @@ interface BranchGraphState {
* pre-v1 cache carrying an edge under that key would otherwise surface a false
* dead link (`getDeadLinks`) and a false orphan (`getOrphans`) until the
* source doc happened to be re-parsed.
+ *
+ * Bump on an ADDED key too, not just a changed one. v2 covers `skillRefs`:
+ * added as an optional field without a bump, so v1 caches stayed loadable and
+ * deserialized it to empty. The mtime reconcile then skips every unchanged
+ * file, so `recordSkillRefs` never runs for them and every `/skill-name` edge
+ * a project skill authors is missing until that file happens to be edited.
+ * Global bundles hid the bug — `ingestGlobalSkillBundles` re-reads them on
+ * every boot, so their refs looked fine while project skills had none.
*/
-const SNAPSHOT_VERSION = 1;
+const SNAPSHOT_VERSION = 2;
interface SerializedBranchGraphState {
version?: number;
@@ -306,7 +314,7 @@ function isUndecidedTarget(state: BranchGraphState, target: string): boolean {
* same skill, a project SKILL only to project references, never across the
* scope boundary or into a project's KB.
*/
-function parseSkillBundleDocAnyScope(
+export function parseSkillBundleDocAnyScope(
docName: string,
): { name: string; kind: 'skill' | 'reference'; skillDocName: string } | null {
const project = parseProjectSkillBundleDoc(docName);
@@ -1461,7 +1469,18 @@ export class BacklinkIndex {
* authors. No-op for non-bundle docs — plain prose mentioning `/tmp`-style
* tokens must never fabricate graph edges. */
private recordSkillRefs(docName: string, body: string, branch = this.activeBranch): void {
- const state = this.getState(branch);
+ this.recordSkillRefsInto(this.getState(branch), docName, body);
+ }
+
+ /**
+ * State-explicit twin of {@link recordSkillRefs}. The cold rebuild builds a
+ * detached state and only installs it at the end, so it cannot go through
+ * `getState(branch)` — it would write refs into the state it is replacing.
+ * Both paths share this one implementation so the rule cannot drift; a
+ * rebuild that skipped it left every project skill's `/skill-name` edges
+ * missing while global bundles (re-ingested per boot) looked fine.
+ */
+ private recordSkillRefsInto(state: BranchGraphState, docName: string, body: string): void {
if (!parseSkillBundleDocAnyScope(docName)) return;
const refs = extractSkillRefs(body);
if (refs.length === 0) state.skillRefs.delete(docName);
@@ -2223,6 +2242,7 @@ export class BacklinkIndex {
];
const targets = new Set<string>();
const externalTargets = new Map<string, { label: string | null; snippet: string | null }>();
+ this.recordSkillRefsInto(state, docName, body);
state.forward.set(docName, targets);
state.epoch++;
state.externalForward.set(docName, externalTargets);
diff --git a/packages/server/src/content-filter-skill-roots.test.ts b/packages/server/src/content-filter-skill-roots.test.ts
new file mode 100644
index 000000000..281b71f15
--- /dev/null
+++ b/packages/server/src/content-filter-skill-roots.test.ts
@@ -0,0 +1,71 @@
+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { describe, expect, test } from 'vitest';
+import { createContentFilter } from './content-filter.ts';
+
+/**
+ * A skill projected into several editor host dirs must reach the content index
+ * ONCE — via its elected canonical bundle. The election is per SKILL, not per
+ * root: one skill can be canonical in `.github` while the next is canonical in
+ * `.claude`, so no root can be privileged or blanket-skipped.
+ */
+describe('skill-root admission', () => {
+ function withFixture<T>(fn: (contentDir: string) => T): T {
+ const projectDir = mkdtempSync(join(tmpdir(), 'ok-skill-roots-'));
+ try {
+ mkdirSync(join(projectDir, '.github'), { recursive: true });
+ writeFileSync(join(projectDir, '.github', 'CI_RUNBOOK.md'), '# Runbook\n');
+ return fn(projectDir);
+ } finally {
+ rmSync(projectDir, { recursive: true, force: true });
+ }
+ }
+
+ test('a non-canonical projection is excluded while the canonical one is admitted', () => {
+ withFixture((contentDir) => {
+ const filter = createContentFilter({
+ projectDir: contentDir,
+ contentDir,
+ // Election picked `.claude` for this skill.
+ inPlaceSkillDirs: new Set(['.claude/skills/knowledge-base']),
+ skillRootPaths: new Set(['.claude/skills', '.github/skills']),
+ });
+ expect(filter.isExcluded('.claude/skills/knowledge-base/SKILL.md')).toBe(false);
+ // Same skill, second projection — already represented by the canonical.
+ expect(filter.isExcluded('.github/skills/knowledge-base/SKILL.md')).toBe(true);
+ });
+ });
+
+ test('a skill canonical in .github is admitted — no root is privileged', () => {
+ withFixture((contentDir) => {
+ const filter = createContentFilter({
+ projectDir: contentDir,
+ contentDir,
+ inPlaceSkillDirs: new Set(['.github/skills/github-only']),
+ skillRootPaths: new Set(['.claude/skills', '.github/skills']),
+ });
+ expect(filter.isExcluded('.github/skills/github-only/SKILL.md')).toBe(false);
+ });
+ });
+
+ test('content beside a projection stays indexed — the root path is scoped, not the host dotdir', () => {
+ withFixture((contentDir) => {
+ const filter = createContentFilter({
+ projectDir: contentDir,
+ contentDir,
+ inPlaceSkillDirs: new Set(['.claude/skills/knowledge-base']),
+ skillRootPaths: new Set(['.claude/skills', '.github/skills']),
+ });
+ // Segment-matching `.github` instead of `.github/skills` would bury this.
+ expect(filter.isExcluded('.github/CI_RUNBOOK.md')).toBe(false);
+ });
+ });
+
+ test('feature off (no roots supplied) leaves admission unchanged', () => {
+ withFixture((contentDir) => {
+ const filter = createContentFilter({ projectDir: contentDir, contentDir });
+ expect(filter.isExcluded('.github/CI_RUNBOOK.md')).toBe(false);
+ });
+ });
+});
diff --git a/packages/server/src/content-filter.ts b/packages/server/src/content-filter.ts
index 685fb4efe..43ca93d07 100644
--- a/packages/server/src/content-filter.ts
+++ b/packages/server/src/content-filter.ts
@@ -541,6 +541,30 @@ function isShareableOkArtifactAncestorDir(relativePath: string): boolean {
* relative, '/'-joined, no leading/trailing slash.
*/
+/**
+ * True for a path under a KNOWN skill root (`.claude/skills`, `.github/skills`,
+ * `.agents/skills`, a ledger custom root, …). Roots arrive from the same
+ * registry the scanner uses, never a literal list here — hosts get added and
+ * users configure custom roots, and a hand-maintained copy in this file has
+ * already drifted once: every editor dotdir was skipped wholesale EXCEPT
+ * `.github`, so Copilot's projection was swept in as ordinary content and every
+ * skill rendered twice in the graph.
+ *
+ * Scoped to the ROOT PATH (`.github/skills`), never the host dotdir
+ * (`.github`) — segment-matching the dotdir would also bury real content that
+ * lives beside the projection (`.github/CI_RUNBOOK.md` and friends).
+ *
+ * Admission is unchanged: a bundle still enters only via the elected-canonical
+ * allow-list, which is a per-SKILL election. One skill can be canonical in
+ * `.github` while the next is canonical in `.cursor`; no root is privileged.
+ */
+function isUnderSkillRoot(relativePath: string, roots: ReadonlySet<string>): boolean {
+ for (const root of roots) {
+ if (relativePath === root || relativePath.startsWith(`${root}/`)) return true;
+ }
+ return false;
+}
+
/** True for a FILE under one of the admitted in-place skill bundle dirs. */
function isInPlaceSkillFile(relativePath: string, dirs: ReadonlySet<string>): boolean {
if (dirs.size === 0) return false;
@@ -912,6 +936,13 @@ export interface ContentFilterOptions {
* secret floor still runs first, so secrets under a skill dir stay excluded.
*/
inPlaceSkillDirs?: ReadonlySet<string>;
+ /**
+ * Known skill ROOT paths for this content dir (contentDir-relative, e.g.
+ * `.claude/skills`, `.github/skills`, `.tim/skills`). A non-canonical
+ * projection under one of these is excluded; the elected canonical bundle is
+ * re-admitted by `inPlaceSkillDirs`. Empty / omitted = feature off.
+ */
+ skillRootPaths?: ReadonlySet<string>;
/**
* Optional provider re-run inside `rebuildIgnorePatterns()` to refresh the
* in-place skill allow-list (live re-scan on skill add/remove). Throws are
@@ -1094,6 +1125,7 @@ export function createContentFilter(opts: ContentFilterOptions): ContentFilter {
let configuredAttachmentFolder = attachmentFolderShape(
opts.attachmentFolderPath ?? DEFAULT_ATTACHMENT_FOLDER_PATH,
);
+ const skillRootPaths: ReadonlySet<string> = opts.skillRootPaths ?? new Set();
// Precompute the contentDir-to-projectDir prefix for path conversion.
// When contentDir is outside projectDir, the relative path starts with ".."
@@ -1333,6 +1365,20 @@ export function createContentFilter(opts: ContentFilterOptions): ContentFilter {
// file-level carve-out must defer to the always-skip floor under bypass
// too — otherwise a caller passing `bypassFilters` straight to `isExcluded`
// on a `.ok/skills/...` path would get inconsistent admission.
+
+ // A file under a known skill root that the canonical election did NOT
+ // admit is a duplicate projection of a skill already represented by its
+ // canonical bundle. Excluded ahead of that carve-out so it cannot be
+ // re-admitted as ordinary content — the leak that made one skill render
+ // once per editor dir it happened to be projected into.
+ if (
+ !opts?.bypassFilters &&
+ isUnderSkillRoot(relativePath, skillRootPaths) &&
+ !isInPlaceSkillFile(relativePath, inPlaceSkillDirs)
+ ) {
+ return true;
+ }
+
if (
!opts?.bypassFilters &&
(isSkillContentFile(relativePath) ||
@@ -1914,6 +1960,7 @@ export async function createContentFilterAsync(opts: ContentFilterOptions): Prom
let configuredAttachmentFolder = attachmentFolderShape(
opts.attachmentFolderPath ?? DEFAULT_ATTACHMENT_FOLDER_PATH,
);
+ const skillRootPaths: ReadonlySet<string> = opts.skillRootPaths ?? new Set();
const contentRelPrefix = toPosix(relative(projectDir, contentDir));
const contentOutsideProject = contentRelPrefix.startsWith('..');
@@ -2072,6 +2119,20 @@ export async function createContentFilterAsync(opts: ContentFilterOptions): Prom
// Skills-as-content carve-out — admit project skill docs + linkable assets
// under `.ok/skills/**` (see sync variant for rationale, incl. the
// `!bypassFilters` gate that mirrors `isDirExcluded`).
+
+ // A file under a known skill root that the canonical election did NOT
+ // admit is a duplicate projection of a skill already represented by its
+ // canonical bundle. Excluded ahead of that carve-out so it cannot be
+ // re-admitted as ordinary content — the leak that made one skill render
+ // once per editor dir it happened to be projected into.
+ if (
+ !opts?.bypassFilters &&
+ isUnderSkillRoot(relativePath, skillRootPaths) &&
+ !isInPlaceSkillFile(relativePath, inPlaceSkillDirs)
+ ) {
+ return true;
+ }
+
if (
!opts?.bypassFilters &&
(isSkillContentFile(relativePath) ||
diff --git a/packages/server/src/http/link-graph-routes.ts b/packages/server/src/http/link-graph-routes.ts
index bd38d871f..63467c1b2 100644
--- a/packages/server/src/http/link-graph-routes.ts
+++ b/packages/server/src/http/link-graph-routes.ts
@@ -29,6 +29,7 @@ import {
TagsForNameSuccessSchema,
TagsListSuccessSchema,
} from '@inkeep/open-knowledge-core';
+import { parseSkillBundleDocAnyScope } from '../backlink-index.ts';
import { isConfigDoc, isSystemDoc } from '../cc1-broadcast.ts';
import {
type DerivedDocumentIndexApiPort,
@@ -39,6 +40,7 @@ import {
import type { FileIndexEntry } from '../file-watcher.ts';
import { toForwardLinkLocalTargets } from '../local-target-assessment.ts';
import type { FrontmatterMetadata } from '../page-identity.ts';
+import { isInternalBundleSkillName } from '../skill-bundles.ts';
import { SuggestLinksTargetNotFoundError, suggestLinks } from '../suggest-links.ts';
import type { ApiRouteTable } from './api-pipeline.ts';
import { errorResponse } from './error-response.ts';
@@ -329,6 +331,7 @@ export function createLinkGraphRoutes(deps: LinkGraphRouteDeps): LinkGraphRoutes
const enrichedNodes = nodes.map((node) => {
if (node.kind === 'doc') {
const meta = readFrontmatterMetadataForLinkedDocName(node.docName, admitted);
+ const bundle = parseSkillBundleDocAnyScope(node.docName);
return {
id: node.id,
kind: 'doc' as const,
@@ -338,6 +341,10 @@ export function createLinkGraphRoutes(deps: LinkGraphRouteDeps): LinkGraphRoutes
cluster: meta.cluster ?? null,
category: meta.category ?? null,
tags: meta.tags ?? null,
+ // Only stamped when true — an ordinary document carries no flag.
+ ...(bundle !== null && isInternalBundleSkillName(bundle.name)
+ ? { managed: true as const }
+ : {}),
};
}
return {
diff --git a/packages/server/src/in-place-skills.ts b/packages/server/src/in-place-skills.ts
index 81221020f..03793c055 100644
--- a/packages/server/src/in-place-skills.ts
+++ b/packages/server/src/in-place-skills.ts
@@ -505,6 +505,17 @@ export function resolveGlobalNativeSkillDir(home: string, name: string): string
* The contentDir-relative canonical bundle dirs to admit as content (the
* `ContentFilter.inPlaceSkillDirs` allow-list).
*/
+/**
+ * Known skill ROOT paths for a project, contentDir-relative — every editor host
+ * root plus the ledger's custom roots. The content filter uses this to exclude
+ * non-canonical projections without hardcoding a host list of its own; sharing
+ * `knownSkillRootsFor` with the scanner is what keeps a newly-supported host
+ * (or a user's custom root) from silently leaking in as ordinary content.
+ */
+export function skillRootPathsFor(contentDir: string): ReadonlySet<string> {
+ return new Set(knownSkillRootsFor(contentDir, 'project').map((r) => r.root));
+}
+
export function scanInPlaceSkillDirs(contentDir: string): ReadonlySet<string> {
return new Set(scanInPlaceSkills(contentDir).map((s) => s.dir));
}
diff --git a/packages/server/src/server-factory.ts b/packages/server/src/server-factory.ts
index 41f421262..96d29bd57 100644
--- a/packages/server/src/server-factory.ts
+++ b/packages/server/src/server-factory.ts
@@ -137,7 +137,11 @@ import { type HeadWatcherHandle, readProjectHeadState, startHeadWatcher } from '
import { errnoCode } from './http/handler-utils.ts';
import type { NativeApiHandle } from './http/http-app.ts';
import type { LocalApiDispatch } from './http/local-api-dispatch.ts';
-import { scanGlobalInPlaceSkills, scanInPlaceSkillDirs } from './in-place-skills.ts';
+import {
+ scanGlobalInPlaceSkills,
+ scanInPlaceSkillDirs,
+ skillRootPathsFor,
+} from './in-place-skills.ts';
import {
buildIngressPolicy,
type IngressPolicy,
@@ -1407,6 +1411,10 @@ export function createServer(options: ServerOptions): ServerInstance {
// one when a host skills dir changes).
inPlaceSkillDirs: scanInPlaceSkillDirs(contentDir),
rescanInPlaceSkillDirs: () => scanInPlaceSkillDirs(contentDir),
+ // Same registry the scan uses, so a non-canonical projection under any
+ // known root (including a host the filter has never heard of) is excluded
+ // rather than swept in as ordinary content.
+ skillRootPaths: skillRootPathsFor(contentDir),
onAfterRebuild: () => {
// Re-derive relationship views against the freshly rebuilt admission
// boundary. The coordinator serializes rapid successive rebuilds.
diff --git a/packages/server/src/skill-bundles.test.ts b/packages/server/src/skill-bundles.test.ts
index 54f5edc98..9d4adfac0 100644
--- a/packages/server/src/skill-bundles.test.ts
+++ b/packages/server/src/skill-bundles.test.ts
@@ -1,9 +1,14 @@
import { existsSync, readFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
-import { RESERVED_PROJECT_SKILL_NAME } from '@inkeep/open-knowledge-core';
+import { extractSkillRefs, RESERVED_PROJECT_SKILL_NAME } from '@inkeep/open-knowledge-core';
import { describe, expect, test } from 'vitest';
-import { BUNDLE_IDS, BUNDLE_SKILL_NAME, bundleSkillMdPath } from './skill-bundles.ts';
+import {
+ BUNDLE_IDS,
+ BUNDLE_SKILL_NAME,
+ bundleSkillMdPath,
+ USER_GLOBAL_BUNDLE_IDS,
+} from './skill-bundles.ts';
// Repo root = three levels up from this file (packages/server/src → root).
const REPO_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..', '..', '..');
@@ -36,6 +41,23 @@ describe('skill-bundles (single source of truth)', () => {
expect(RESERVED_PROJECT_SKILL_NAME).toBe(BUNDLE_SKILL_NAME.project);
});
+ test('user-global bundles contain no skill refs', () => {
+ // Skill-ref edges between SKILL documents are mirrored, so any ref from a
+ // managed user-global bundle can make that bundle appear referenced and visible.
+ //
+ // Scoped to the user-global bundles because only those become graph nodes:
+ // they install into `~/.{host}/skills/`, which the global skill-graph scan
+ // ingests. The `project` bundle is exempt — its projection is force-added to
+ // the project `.gitignore` on every open, so it is not indexed as content and
+ // never reaches the graph. It legitimately references /open-knowledge-write-skill
+ // for agent routing, and that ref must stay.
+ for (const id of USER_GLOBAL_BUNDLE_IDS) {
+ const raw = readFileSync(join(REPO_ROOT, bundleSkillMdPath(id)), 'utf-8');
+ const refs = extractSkillRefs(raw);
+ expect({ id, refs }).toEqual({ id, refs: [] });
+ }
+ });
+
test('write-skill description is within the skill contract (≤1024, no XML tags)', () => {
const raw = readFileSync(join(REPO_ROOT, bundleSkillMdPath('write-skill')), 'utf-8');
const desc = /description:\s*"([\s\S]*?)"\n/.exec(raw)?.[1] ?? '';