Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

feat(settings): AI tools & CLI section — per-component install/uninstall of global MCPs, skills, PATH shim (#2482)

mike-inkeep6ec99dcdb9d5
diff --git a/.changeset/settings-ai-tools-section.md b/.changeset/settings-ai-tools-section.md
new file mode 100644
index 000000000..dd1e1d604
--- /dev/null
+++ b/.changeset/settings-ai-tools-section.md
@@ -0,0 +1,5 @@
+---
+"@inkeep/open-knowledge": minor
+---
+
+Settings → User gains an "AI tools & CLI" section — the first-launch "Connect your AI tools to OpenKnowledge" dialog is now a persistent, stateful surface in the desktop app's settings. Every global component is listed with a checkbox reflecting its live installed state, and clicking installs or uninstalls that one component: the per-editor `open-knowledge` MCP entries (Claude Code, Claude Desktop, Cursor, Codex, OpenCode, OpenClaw), the `ok` shell-PATH shim, and the user-global Agent Skills (`open-knowledge-discovery`, `open-knowledge-write-skill`). Removal follows the same guest discipline as install: only entries OpenKnowledge recognizably wrote are deleted (customized/forked entries are reported and left byte-unchanged), PATH removal strips only the managed rc block and records a declined consent so startup self-heal never re-appends it, and skill removal records the per-bundle decision every install actor honors.
diff --git a/packages/app/src/components/settings/AiToolsSection.dom.test.tsx b/packages/app/src/components/settings/AiToolsSection.dom.test.tsx
new file mode 100644
index 000000000..f0b8de4dd
--- /dev/null
+++ b/packages/app/src/components/settings/AiToolsSection.dom.test.tsx
@@ -0,0 +1,267 @@
+import { afterEach, describe, expect, mock, test } from 'bun:test';
+import { cleanup, render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import type { ReactNode } from 'react';
+import type {
+ OkIntegrationsSetRequest,
+ OkIntegrationsSetResult,
+ OkIntegrationsStatus,
+} from '@/lib/desktop-bridge-types';
+import { renderLinguiTemplate } from '@/test-utils/lingui-mock';
+
+mock.module('@lingui/react/macro', () => ({
+ Trans: ({ children }: { children: ReactNode }) => <>{children}</>,
+ useLingui: () => ({ t: renderLinguiTemplate }),
+}));
+
+// Sonner is loaded by the SUT — stub to mute its real toaster.
+const toastError = mock(() => {});
+mock.module('sonner', () => ({
+ toast: { error: toastError, info: mock(() => {}), success: mock(() => {}) },
+}));
+
+const { AiToolsSection } = await import('./AiToolsSection');
+const { TooltipProvider } = await import('@/components/ui/tooltip');
+
+/** Production mounts under the app-level TooltipProvider (main.tsx). */
+function renderSection() {
+ return render(
+ <TooltipProvider>
+ <AiToolsSection />
+ </TooltipProvider>,
+ );
+}
+
+const baseStatus: OkIntegrationsStatus = {
+ available: true,
+ editors: [
+ {
+ id: 'claude',
+ label: 'Claude',
+ detected: true,
+ state: 'installed',
+ configPath: '~/.claude.json',
+ entryLocator: 'mcpServers.open-knowledge',
+ },
+ {
+ id: 'cursor',
+ label: 'Cursor',
+ detected: false,
+ state: 'not-installed',
+ configPath: '~/.cursor/mcp.json',
+ entryLocator: 'mcpServers.open-knowledge',
+ },
+ {
+ id: 'codex',
+ label: 'Codex',
+ detected: true,
+ state: 'foreign',
+ configPath: '~/.codex/config.toml',
+ entryLocator: '[mcp_servers.open-knowledge]',
+ },
+ {
+ id: 'opencode',
+ label: 'OpenCode',
+ detected: false,
+ state: 'unmanageable',
+ configPath: null,
+ entryLocator: 'mcp.open-knowledge',
+ },
+ ],
+ path: { shellDetected: true, rcFilesToTouch: ['~/.zshrc'], installed: false },
+ skills: [
+ {
+ id: 'discovery',
+ name: 'open-knowledge-discovery',
+ installed: true,
+ paths: [
+ '~/.agents/skills/open-knowledge-discovery',
+ '~/.claude/skills/open-knowledge-discovery',
+ ],
+ },
+ {
+ id: 'write-skill',
+ name: 'open-knowledge-write-skill',
+ installed: false,
+ paths: ['~/.agents/skills/open-knowledge-write-skill'],
+ },
+ ],
+};
+
+interface HarnessOpts {
+ status?: OkIntegrationsStatus;
+ setResult?: (request: OkIntegrationsSetRequest) => OkIntegrationsSetResult;
+}
+
+function installBridge({ status = baseStatus, setResult }: HarnessOpts = {}) {
+ const setCalls: OkIntegrationsSetRequest[] = [];
+ const bridge = {
+ integrations: {
+ status: async () => status,
+ setComponent: async (request: OkIntegrationsSetRequest) => {
+ setCalls.push(request);
+ return setResult ? setResult(request) : { ok: true as const, status };
+ },
+ },
+ };
+ Object.defineProperty(window, 'okDesktop', {
+ value: bridge,
+ configurable: true,
+ writable: true,
+ });
+ return { setCalls };
+}
+
+afterEach(() => {
+ cleanup();
+ toastError.mockClear();
+ // biome-ignore lint/suspicious/noExplicitAny: test-only global teardown.
+ (window as any).okDesktop = undefined;
+});
+
+describe('AiToolsSection', () => {
+ test('renders the three component groups from the status snapshot', async () => {
+ installBridge();
+ renderSection();
+
+ await waitFor(() => {
+ expect(screen.getByTestId('ai-tools-path-checkbox')).toBeTruthy();
+ });
+ // PATH row: not installed → names the rc file a grant would touch.
+ expect(screen.getByTestId('ai-tools-path-status').textContent).toContain('~/.zshrc');
+
+ // Editors: checked reflects installed/foreign, per-state status copy.
+ expect(screen.getByTestId('ai-tools-editor-checkbox-claude').getAttribute('data-state')).toBe(
+ 'checked',
+ );
+ expect(screen.getByTestId('ai-tools-editor-checkbox-cursor').getAttribute('data-state')).toBe(
+ 'unchecked',
+ );
+ expect(screen.getByTestId('ai-tools-editor-checkbox-codex').getAttribute('data-state')).toBe(
+ 'checked',
+ );
+ expect(screen.getByTestId('ai-tools-editor-status-codex').textContent).toContain(
+ 'not managed by OpenKnowledge',
+ );
+ // Undetected, never-configured tools link to their setup guide instead of
+ // a dead-end "Not detected" — same contract as the first-launch dialog.
+ const cursorLink = screen.getByTestId('ai-tools-editor-status-cursor');
+ expect(cursorLink.tagName).toBe('A');
+ expect(cursorLink.getAttribute('href')).toBe(
+ 'https://openknowledge.ai/docs/integrations/cursor',
+ );
+ // Unmanageable rows render disabled and keep their status text (no link).
+ expect(screen.getByTestId('ai-tools-editor-checkbox-opencode').hasAttribute('disabled')).toBe(
+ true,
+ );
+ expect(screen.getByTestId('ai-tools-editor-status-opencode').tagName).toBe('SPAN');
+
+ // Skills: installed state drives the checkbox.
+ expect(screen.getByTestId('ai-tools-skill-checkbox-discovery').getAttribute('data-state')).toBe(
+ 'checked',
+ );
+ expect(
+ screen.getByTestId('ai-tools-skill-checkbox-write-skill').getAttribute('data-state'),
+ ).toBe('unchecked');
+ });
+
+ test('clicking a checkbox sends the matching install/uninstall and re-renders from the result', async () => {
+ const flipped: OkIntegrationsStatus = {
+ ...baseStatus,
+ editors: baseStatus.editors.map((e) =>
+ e.id === 'cursor' ? { ...e, state: 'installed' as const } : e,
+ ),
+ };
+ const { setCalls } = installBridge({
+ setResult: () => ({ ok: true as const, status: flipped }),
+ });
+ renderSection();
+ await waitFor(() => {
+ expect(screen.getByTestId('ai-tools-editor-checkbox-cursor')).toBeTruthy();
+ });
+
+ await userEvent.click(screen.getByTestId('ai-tools-editor-checkbox-cursor'));
+ await waitFor(() => {
+ expect(setCalls).toEqual([{ component: { kind: 'editor', id: 'cursor' }, enabled: true }]);
+ });
+ // The fresh snapshot from the result drives the re-render.
+ await waitFor(() => {
+ expect(screen.getByTestId('ai-tools-editor-checkbox-cursor').getAttribute('data-state')).toBe(
+ 'checked',
+ );
+ });
+ expect(toastError).not.toHaveBeenCalled();
+ });
+
+ test('unchecking an installed component sends enabled: false', async () => {
+ const { setCalls } = installBridge();
+ renderSection();
+ await waitFor(() => {
+ expect(screen.getByTestId('ai-tools-skill-checkbox-discovery')).toBeTruthy();
+ });
+
+ await userEvent.click(screen.getByTestId('ai-tools-skill-checkbox-discovery'));
+ await waitFor(() => {
+ expect(setCalls).toEqual([{ component: { kind: 'skill', id: 'discovery' }, enabled: false }]);
+ });
+ });
+
+ test('a refused toggle surfaces the main-process error as a toast and keeps the truthful state', async () => {
+ installBridge({
+ setResult: () => ({
+ ok: false as const,
+ error: 'left unchanged',
+ status: baseStatus,
+ }),
+ });
+ renderSection();
+ await waitFor(() => {
+ expect(screen.getByTestId('ai-tools-editor-checkbox-codex')).toBeTruthy();
+ });
+
+ await userEvent.click(screen.getByTestId('ai-tools-editor-checkbox-codex'));
+ await waitFor(() => {
+ expect(toastError).toHaveBeenCalledWith('left unchanged');
+ });
+ // Status snapshot from the refused result still applies — checkbox stays checked.
+ expect(screen.getByTestId('ai-tools-editor-checkbox-codex').getAttribute('data-state')).toBe(
+ 'checked',
+ );
+ });
+
+ test('available: false renders the read-only note and disables every checkbox', async () => {
+ installBridge({ status: { ...baseStatus, available: false } });
+ renderSection();
+ await waitFor(() => {
+ expect(screen.getByTestId('ai-tools-read-only')).toBeTruthy();
+ });
+ expect(screen.getByTestId('ai-tools-path-checkbox').hasAttribute('disabled')).toBe(true);
+ expect(screen.getByTestId('ai-tools-editor-checkbox-claude').hasAttribute('disabled')).toBe(
+ true,
+ );
+ expect(screen.getByTestId('ai-tools-skill-checkbox-discovery').hasAttribute('disabled')).toBe(
+ true,
+ );
+ });
+
+ test('without the desktop bridge the section explains itself instead of crashing', () => {
+ renderSection();
+ expect(screen.getByTestId('ai-tools-unavailable')).toBeTruthy();
+ });
+
+ test('the row info tooltip discloses the exact file and entry the checkbox touches', async () => {
+ installBridge();
+ renderSection();
+ await waitFor(() => {
+ expect(screen.getByTestId('ai-tools-editor-info-claude')).toBeTruthy();
+ });
+
+ // Radix tooltips open on trigger focus (keyboard path — also the stable
+ // one under happy-dom). Content portals to the body.
+ screen.getByTestId('ai-tools-editor-info-claude').focus();
+ const paths = await screen.findAllByText('~/.claude.json');
+ expect(paths.length).toBeGreaterThan(0);
+ const locators = await screen.findAllByText('mcpServers.open-knowledge');
+ expect(locators.length).toBeGreaterThan(0);
+ });
+});
diff --git a/packages/app/src/components/settings/AiToolsSection.tsx b/packages/app/src/components/settings/AiToolsSection.tsx
new file mode 100644
index 000000000..a71b3d20d
--- /dev/null
+++ b/packages/app/src/components/settings/AiToolsSection.tsx
@@ -0,0 +1,380 @@
+/**
+ * Settings → User → AI tools & CLI — the persistent, stateful sibling of the
+ * first-launch "Connect your AI tools to OpenKnowledge" consent dialog
+ * (`McpConsentDialogBody.tsx`). Same three component groups (shell-PATH shim,
+ * per-editor MCP entries, user-global Agent Skills), but checkboxes reflect
+ * LIVE installed state and each click applies immediately: check = install,
+ * uncheck = uninstall. One component mutates at a time (main serializes;
+ * the UI disables the group while a toggle is in flight). Each row carries an
+ * info tooltip disclosing the exact file + entry (or folders) it touches.
+ *
+ * Desktop-only — the sidebar item is gated on the Electron preload bridge, and
+ * this component renders a fallback if mounted without it.
+ */
+
+import { EDITOR_SETUP_DOC_SLUG } from '@inkeep/open-knowledge-core';
+import { Trans, useLingui } from '@lingui/react/macro';
+import { ArrowUpRight, Info } from 'lucide-react';
+import { type ReactNode, useEffect, useState } from 'react';
+import { toast } from 'sonner';
+import { Button } from '@/components/ui/button';
+import { Checkbox } from '@/components/ui/checkbox';
+import { Label } from '@/components/ui/label';
+import { Skeleton } from '@/components/ui/skeleton';
+import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
+import type { OkIntegrationsSetRequest, OkIntegrationsStatus } from '@/lib/desktop-bridge-types';
+import { dispatchExternalLinkClick } from '@/lib/external-link';
+
+type ComponentRef = OkIntegrationsSetRequest['component'];
+
+/** Stable per-row key for the in-flight marker. */
+function componentKey(component: ComponentRef): string {
+ if (component.kind === 'editor') return `editor:${component.id}`;
+ if (component.kind === 'skill') return `skill:${component.id}`;
+ return 'path';
+}
+
+/**
+ * Per-row disclosure tooltip: exactly which file/entry (or folders) the
+ * checkbox touches. Rendered as a sibling of the row's Label — a button
+ * inside the label would sit in its activation path.
+ */
+function RowInfoTooltip({ testId, children }: { testId: string; children: ReactNode }) {
+ const { t } = useLingui();
+ return (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="mt-1.5 mr-1.5 h-6 w-6 shrink-0 text-muted-foreground opacity-60 hover:opacity-100"
+ aria-label={t`What this checkbox changes`}
+ data-testid={testId}
+ >
+ <Info className="size-3.5" />
+ </Button>
+ </TooltipTrigger>
+ {/* The base TooltipContent is a flex ROW (inline-flex items-center) —
+ without the single-column wrapper, sibling <p>s render side by side. */}
+ <TooltipContent side="left" className="max-w-sm text-left">
+ <div className="flex min-w-0 flex-col gap-1">{children}</div>
+ </TooltipContent>
+ </Tooltip>
+ );
+}
+
+export function AiToolsSection() {
+ const { t } = useLingui();
+ const bridge = typeof window !== 'undefined' ? (window.okDesktop ?? null) : null;
+ const [status, setStatus] = useState<OkIntegrationsStatus | null>(null);
+ const [loadFailed, setLoadFailed] = useState(false);
+ const [pending, setPending] = useState<string | null>(null);
+
+ useEffect(() => {
+ if (!bridge) return;
+ let cancelled = false;
+ bridge.integrations
+ .status()
+ .then((snapshot) => {
+ if (!cancelled) setStatus(snapshot);
+ })
+ .catch(() => {
+ if (!cancelled) setLoadFailed(true);
+ });
+ return () => {
+ cancelled = true;
+ };
+ }, [bridge]);
+
+ // No `finally` — the React Compiler can't lower TryStatement finalizers
+ // (BuildHIR::lowerStatement Todo); the catch swallows, so the trailing
+ // setPending(null) runs on both paths.
+ async function applyToggle(component: ComponentRef, enabled: boolean): Promise<void> {
+ if (!bridge) return;
+ setPending(componentKey(component));
+ try {
+ const result = await bridge.integrations.setComponent({ component, enabled });
+ setStatus(result.status);
+ if (!result.ok) toast.error(result.error);
+ } catch (err) {
+ toast.error(
+ t`Couldn't apply the change: ${err instanceof Error ? err.message : String(err)}`,
+ );
+ }
+ setPending(null);
+ }
+
+ const header = (
+ <div className="space-y-1">
+ <h3 id="settings-ai-tools-title" className="text-base font-semibold">
+ <Trans>AI tools & CLI</Trans>
+ </h3>
+ <p className="text-sm text-muted-foreground">
+ <Trans>
+ Give the AI tools you use access to read and update your projects. Checking a box sets it
+ up right away; unchecking removes it.
+ </Trans>
+ </p>
+ </div>
+ );
+
+ if (!bridge || loadFailed) {
+ return (
+ <section aria-labelledby="settings-ai-tools-title" className="space-y-4">
+ {header}
+ <p className="text-sm text-muted-foreground" data-testid="ai-tools-unavailable">
+ <Trans>AI tool management is only available in the OpenKnowledge desktop app.</Trans>
+ </p>
+ </section>
+ );
+ }
+
+ if (status === null) {
+ return (
+ <section aria-labelledby="settings-ai-tools-title" className="space-y-4">
+ {header}
+ <div className="space-y-2" data-testid="ai-tools-loading">
+ <Skeleton className="h-10 w-full" />
+ <Skeleton className="h-10 w-full" />
+ <Skeleton className="h-10 w-full" />
+ </div>
+ </section>
+ );
+ }
+
+ const busy = pending !== null || !status.available;
+ const showPathRow = status.path.shellDetected || status.path.installed;
+
+ return (
+ <section aria-labelledby="settings-ai-tools-title" className="space-y-4">
+ {header}
+
+ {!status.available && (
+ <p className="text-sm text-amber-600 dark:text-amber-400" data-testid="ai-tools-read-only">
+ <Trans>Managing AI tools is unavailable in this build.</Trans>
+ </p>
+ )}
+
+ {showPathRow && (
+ <div className="flex flex-col gap-1.5">
+ <span className="text-xs font-medium text-muted-foreground">
+ <Trans comment="Group label above the shell-PATH row in Settings → AI tools & CLI">
+ Terminal
+ </Trans>
+ </span>
+ {/* Row hover lives on the container so the info-button strip grays
+ with the rest of the row instead of reading as its own column. */}
+ <div className="flex items-start overflow-hidden rounded-md border border-border bg-card/50 hover:bg-accent">
+ <Label
+ htmlFor="ai-tools-path"
+ className="flex flex-1 cursor-pointer items-start gap-2.5 px-3 py-2.5 font-normal"
+ >
+ <Checkbox
+ id="ai-tools-path"
+ checked={status.path.installed}
+ disabled={busy}
+ onCheckedChange={() => void applyToggle({ kind: 'path' }, !status.path.installed)}
+ className="mt-0.5"
+ data-testid="ai-tools-path-checkbox"
+ />
+ <span className="flex min-w-0 flex-1 flex-col gap-0.5">
+ <span className="text-sm font-medium text-foreground">
+ <Trans comment="Checkbox in Settings → AI tools & CLI that adds the ok CLI to the user's shell PATH">
+ Add the <code className="inline-code">ok</code> command to your terminal
+ </Trans>
+ </span>
+ <span className="text-xs text-muted-foreground" data-testid="ai-tools-path-status">
+ {status.path.installed
+ ? t`Installed — ok is available in external terminals. Unchecking removes it; OpenKnowledge's built-in terminal and AI tools keep working.`
+ : t`Adds a managed block to ${status.path.rcFilesToTouch.join(', ')}`}
+ </span>
+ </span>
+ </Label>
+ <RowInfoTooltip testId="ai-tools-path-info">
+ <p className="opacity-70">
+ <Trans>Adds a managed block to</Trans>
+ </p>
+ {status.path.rcFilesToTouch.map((file) => (
+ <p key={file}>
+ <code className="break-all">{file}</code>
+ </p>
+ ))}
+ <p className="pt-1">
+ <Trans>
+ <code>~/.ok/bin</code> and <code>~/.ok/env.sh</code> stay either way — the app
+ always maintains them.
+ </Trans>
+ </p>
+ </RowInfoTooltip>
+ </div>
+ </div>
+ )}
+
+ <div className="flex flex-col gap-1.5">
+ <span className="text-xs font-medium text-muted-foreground">
+ <Trans comment="Group label above the per-editor MCP list in Settings → AI tools & CLI — each row wires OpenKnowledge's MCP server into that tool">
+ MCP connections
+ </Trans>
+ </span>
+ <ul className="rounded-md border border-border bg-card/50 divide-y divide-border overflow-hidden">
+ {status.editors.map((editor) => {
+ const checked = editor.state === 'installed' || editor.state === 'foreign';
+ const disabled = busy || editor.state === 'unmanageable';
+ // Undetected, never-configured tools get a setup-guide link instead
+ // of a dead-end "Not detected" — same contract as the first-launch
+ // consent dialog.
+ const showSetupLink = editor.state === 'not-installed' && !editor.detected;
+ const setupUrl = `https://openknowledge.ai/docs/integrations/${EDITOR_SETUP_DOC_SLUG[editor.id]}`;
+ const statusLabel =
+ editor.state === 'installed'
+ ? t`Installed`
+ : editor.state === 'foreign'
+ ? t`Custom open-knowledge entry — not managed by OpenKnowledge`
+ : editor.state === 'unmanageable'
+ ? t`Can't safely edit this tool's config`
+ : editor.detected
+ ? t`Detected on this machine`
+ : null;
+ const statusClass =
+ editor.state === 'foreign' || editor.state === 'unmanageable'
+ ? 'text-xs text-amber-600 dark:text-amber-400'
+ : 'text-xs text-muted-foreground';
+ return (
+ <li
+ key={editor.id}
+ className={disabled ? 'flex items-start' : 'flex items-start hover:bg-accent'}
+ >
+ <Label
+ htmlFor={`ai-tools-editor-${editor.id}`}
+ className={
+ disabled
+ ? 'flex flex-1 items-start gap-2.5 px-3 py-2.5 font-normal'
+ : 'flex flex-1 cursor-pointer items-start gap-2.5 px-3 py-2.5 font-normal'
+ }
+ >
+ <Checkbox
+ id={`ai-tools-editor-${editor.id}`}
+ checked={checked}
+ disabled={disabled}
+ onCheckedChange={() =>
+ void applyToggle({ kind: 'editor', id: editor.id }, !checked)
+ }
+ className="mt-0.5"
+ data-testid={`ai-tools-editor-checkbox-${editor.id}`}
+ />
+ <span className="flex min-w-0 flex-1 flex-col gap-0.5">
+ <span className="text-sm font-medium text-foreground">{editor.label}</span>
+ {statusLabel !== null && (
+ <span
+ className={statusClass}
+ data-testid={`ai-tools-editor-status-${editor.id}`}
+ >
+ {statusLabel}
+ </span>
+ )}
+ </span>
+ </Label>
+ {/* Sibling of the Label, not a descendant — an anchor must never
+ sit inside a label's activation path. */}
+ {showSetupLink && (
+ <a
+ href={setupUrl}
+ target="_blank"
+ rel="noopener noreferrer"
+ onClick={(e) => dispatchExternalLinkClick(e, setupUrl)}
+ onAuxClick={(e) => dispatchExternalLinkClick(e, setupUrl)}
+ aria-label={t`How to set up ${editor.label} (opens in browser)`}
+ className="flex shrink-0 items-center gap-0.5 px-2 py-2.5 text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
+ data-testid={`ai-tools-editor-status-${editor.id}`}
+ >
+ <Trans comment="Link on an undetected tool row to its OpenKnowledge setup guide">
+ How to set up
+ </Trans>
+ <ArrowUpRight className="size-3" aria-hidden />
+ </a>
+ )}
+ <RowInfoTooltip testId={`ai-tools-editor-info-${editor.id}`}>
+ <p className="opacity-70">
+ <Trans>File</Trans>
+ </p>
+ <p>
+ <code className="break-all">
+ {editor.configPath ?? t`unavailable on this platform`}
+ </code>
+ </p>
+ <p className="pt-1 opacity-70">
+ <Trans>Entry</Trans>
+ </p>
+ <p>
+ <code className="break-all">{editor.entryLocator}</code>
+ </p>
+ </RowInfoTooltip>
+ </li>
+ );
+ })}
+ </ul>
+ </div>
+
+ {status.skills.length > 0 && (
+ <div className="flex flex-col gap-1.5">
+ <span className="text-xs font-medium text-muted-foreground">
+ <Trans comment="Group label above the skill rows in Settings → AI tools & CLI">
+ Agent Skills
+ </Trans>
+ </span>
+ <ul className="rounded-md border border-border bg-card/50 divide-y divide-border overflow-hidden">
+ {status.skills.map((skill) => (
+ <li key={skill.id} className="flex items-start hover:bg-accent">
+ <Label
+ htmlFor={`ai-tools-skill-${skill.id}`}
+ className="flex flex-1 cursor-pointer items-start gap-2.5 px-3 py-2.5 font-normal"
+ >
+ <Checkbox
+ id={`ai-tools-skill-${skill.id}`}
+ checked={skill.installed}
+ disabled={busy}
+ onCheckedChange={() =>
+ void applyToggle({ kind: 'skill', id: skill.id }, !skill.installed)
+ }
+ className="mt-0.5"
+ data-testid={`ai-tools-skill-checkbox-${skill.id}`}
+ />
+ <span className="flex min-w-0 flex-1 flex-col gap-0.5">
+ <span className="text-sm font-medium text-foreground">
+ <code>{skill.name}</code>
+ </span>
+ <span
+ className="text-xs text-muted-foreground"
+ data-testid={`ai-tools-skill-status-${skill.id}`}
+ >
+ {skill.id === 'discovery' ? (
+ <Trans comment="Subtext for the open-knowledge-discovery skill row">
+ Helps your coding agent recognize OpenKnowledge projects and route reads
+ and writes through it.
+ </Trans>
+ ) : (
+ <Trans comment="Subtext for the open-knowledge-write-skill skill row">
+ Adds a guided workflow for authoring new Agent Skills.
+ </Trans>
+ )}
+ </span>
+ </span>
+ </Label>
+ <RowInfoTooltip testId={`ai-tools-skill-info-${skill.id}`}>
+ <p className="opacity-70">
+ <Trans>Folders</Trans>
+ </p>
+ {skill.paths.map((path) => (
+ <p key={path}>
+ <code className="break-all">{path}</code>
+ </p>
+ ))}
+ </RowInfoTooltip>
+ </li>
+ ))}
+ </ul>
+ </div>
+ )}
+ </section>
+ );
+}
diff --git a/packages/app/src/components/settings/SettingsDialogBody.tsx b/packages/app/src/components/settings/SettingsDialogBody.tsx
index a93f1a5cb..ab9b86819 100644
--- a/packages/app/src/components/settings/SettingsDialogBody.tsx
+++ b/packages/app/src/components/settings/SettingsDialogBody.tsx
@@ -106,6 +106,7 @@ import {
} from '@/lib/keyboard-shortcuts';
import { cn } from '@/lib/utils';
import { AccountSection } from './AccountSection';
+import { AiToolsSection } from './AiToolsSection';
import { EmbeddingsKeySection } from './EmbeddingsKeySection';
import { OkignoreSection } from './OkignoreSection';
import { ProjectTemplatesSection } from './ProjectTemplatesSection';
@@ -243,6 +244,11 @@ export function SettingsDialogBody({
// `<ConfigProvider>` — both write to the same Y.Text body.
return <OkignoreSection binding={okignoreBinding} synced={okignoreSynced} />;
}
+ if (activeId === 'ai-tools') {
+ // Global AI-tool management — desktop-only (nav item gated to the
+ // Electron host). Talks to main over the integrations bridge.
+ return <AiToolsSection />;
+ }
if (activeId === 'claude-desktop') {
return <IntegrationsSection />;
}
diff --git a/packages/app/src/components/settings/SettingsDialogShell.tsx b/packages/app/src/components/settings/SettingsDialogShell.tsx
index f9f4f8fd9..2dd868edf 100644
--- a/packages/app/src/components/settings/SettingsDialogShell.tsx
+++ b/packages/app/src/components/settings/SettingsDialogShell.tsx
@@ -19,7 +19,8 @@
* the body chunk is cached after the first open.
*
* Sidebar IA:
- * USER → Preferences, Hotkeys, Account
+ * USER → Preferences, Hotkeys, Account, AI tools & CLI (Electron
+ * host only)
* THIS PROJECT → Sync, Search, Templates, Ignore patterns, Config sharing
* INTEGRATIONS → Claude Desktop (hidden when desktopPresent === false)
*/
@@ -105,6 +106,10 @@ export function SettingsDialogShell({ open, onOpenChange }: SettingsDialogShellP
{ id: 'preferences', label: t`Preferences` },
{ id: 'hotkeys', label: t`Hotkeys` },
{ id: 'account', label: t`Account` },
+ // Machine-level OK footprint (per-editor MCP entries, Agent Skills,
+ // the ok PATH command) — user-scoped, and desktop-only because the
+ // install actors live in the Electron main process.
+ ...(isOkDesktopHost ? [{ id: 'ai-tools', label: t`AI tools & CLI` }] : []),
],
},
{
diff --git a/packages/app/src/lib/desktop-bridge-types.ts b/packages/app/src/lib/desktop-bridge-types.ts
index dd014ac56..2364fc940 100644
--- a/packages/app/src/lib/desktop-bridge-types.ts
+++ b/packages/app/src/lib/desktop-bridge-types.ts
@@ -455,6 +455,55 @@ export interface OkMcpWiringConfirmRequest {
/** Result shape for `mcpWiring.confirm` / `skip`. */
export type OkMcpWiringResult = { ok: true } | { ok: false; error: string };
+/**
+ * Per-editor MCP state for Settings → AI tools. `installed` rows uncheck to
+ * remove; `not-installed` rows check to install; `foreign` is an entry under
+ * OK's server name that isn't recognizably OK's own (uninstall refuses,
+ * install overwrites); `unmanageable` is a config OK can't safely edit.
+ */
+export type OkIntegrationsEditorState = 'installed' | 'not-installed' | 'foreign' | 'unmanageable';
+
+/** Component inventory for Settings → AI tools. `available: false` renders
+ * the section read-only (install actors gated off for this process). `path.
+ * installed` reflects the managed rc block actually being on disk. */
+export interface OkIntegrationsStatus {
+ readonly available: boolean;
+ readonly editors: readonly {
+ readonly id: OkMcpWiringEditorId;
+ readonly label: string;
+ readonly detected: boolean;
+ readonly state: OkIntegrationsEditorState;
+ readonly configPath: string | null;
+ readonly entryLocator: string;
+ }[];
+ readonly path: {
+ readonly shellDetected: boolean;
+ readonly rcFilesToTouch: readonly string[];
+ readonly installed: boolean;
+ };
+ readonly skills: readonly {
+ readonly id: string;
+ readonly name: string;
+ readonly installed: boolean;
+ readonly paths: readonly string[];
+ }[];
+}
+
+/** One toggle for `integrations.setComponent`. */
+export interface OkIntegrationsSetRequest {
+ readonly component:
+ | { readonly kind: 'editor'; readonly id: OkMcpWiringEditorId }
+ | { readonly kind: 'path' }
+ | { readonly kind: 'skill'; readonly id: string };
+ readonly enabled: boolean;
+}
+
+/** Set-component result — both arms carry a fresh status snapshot so the
+ * renderer re-renders truthfully after failed/refused toggles too. */
+export type OkIntegrationsSetResult =
+ | { readonly ok: true; readonly status: OkIntegrationsStatus }
+ | { readonly ok: false; readonly error: string; readonly status: OkIntegrationsStatus };
+
/**
* Per-project consent dialog — renderer-facing payload + result shapes.
* Mirrors `bridge-contract.ts` and `core/src/desktop-bridge.ts`. Drift
@@ -1073,6 +1122,15 @@ export interface OkDesktopBridge {
confirm(request: OkMcpWiringConfirmRequest): Promise<OkMcpWiringResult>;
skip(): Promise<OkMcpWiringResult>;
};
+ /**
+ * Settings → AI tools: live per-component install state + one-component
+ * install/uninstall for OK's global footprint (per-editor MCP entries,
+ * shell-PATH shim, user-global skill bundles). Mutations serialize in main.
+ */
+ integrations: {
+ status(): Promise<OkIntegrationsStatus>;
+ setComponent(request: OkIntegrationsSetRequest): Promise<OkIntegrationsSetResult>;
+ };
/**
* Per-project consent dialog surface. Navigator-only. Renderer mounts a
* shadcn Dialog when `onShow` fires; calls `confirm` / `cancel` on user
diff --git a/packages/app/src/locales/en/messages.json b/packages/app/src/locales/en/messages.json
index 655aab7d1..b9dd79482 100644
--- a/packages/app/src/locales/en/messages.json
+++ b/packages/app/src/locales/en/messages.json
@@ -109,6 +109,7 @@
"28B21t": ["Agent Skills"],
"29VNqC": ["Unknown error"],
"29XZXN": ["Set git identity"],
+ "2B6eYX": ["What this checkbox changes"],
"2BBAbc": ["List"],
"2FYpfJ": ["More"],
"2GT3Hf": ["Global"],
@@ -456,6 +457,7 @@
". Change it in Settings → Sync."
],
"AcK_r0": ["Claude CLI"],
+ "AczYxH": ["Custom open-knowledge entry — not managed by OpenKnowledge"],
"AdcGcG": ["Applying your change"],
"AddR83": ["Could not create project. Try again or pick a different location."],
"AeHuzT": ["# One pattern per line.\n# Examples:\n# drafts/\n# *.draft.md\n# !keep.md"],
@@ -521,6 +523,9 @@
"CSL0l1": ["Couldn't clear the key — please try again."],
"CTJLpz": ["\"", ["trimmed"], "\" already exists here"],
"CU3AiE": ["Switching branches"],
+ "CWzc2T": [
+ "<0>~/.ok/bin</0> and <1>~/.ok/env.sh</1> stay either way — the app always maintains them."
+ ],
"CXj9C-": ["New property name"],
"C_WGy8": [
"This file is too large to open in the built-in text editor (1 MB limit). Use Open file below to open it in another app."
@@ -736,6 +741,7 @@
"HIb0vl": ["Network error — please try again"],
"HM56Bx": ["Creating..."],
"HPTPGr": ["Create a new spec file for my user story"],
+ "HSh8u_": ["Folders"],
"HXFyWD": ["Split diff"],
"HdkSiO": ["New file"],
"HfI1dR": ["I already have it locally →"],
@@ -870,6 +876,7 @@
"LXdWeS": ["Medium section heading."],
"LXfNU-": ["Navigation and suggestions"],
"LYufDw": ["Failed to enable semantic search — ", ["detail"]],
+ "LbmLyU": ["Can't safely edit this tool's config"],
"Lcehxn": ["Save resolution"],
"LdABLa": ["Could not open ", ["target"], ". Try opening it manually."],
"LdKIHS": ["Draft a spec"],
@@ -986,6 +993,7 @@
"O0Z2Xr": ["Outgoing"],
"O2UpM1": ["Browse"],
"O3oNi5": ["Email"],
+ "O4PnDd": ["AI tool management is only available in the OpenKnowledge desktop app."],
"O6yEPk": ["Create a new OpenKnowledge project in the folder of your choice."],
"O7_W_a": ["Open with AI"],
"OD0FCX": ["Hidden “", ["basename"], "”"],
@@ -1017,6 +1025,7 @@
"On0aF2": ["Website"],
"Oo_WWc": ["No pages found"],
"Oos8fo": ["Copy command"],
+ "OplnBG": ["Managing AI tools is unavailable in this build."],
"OuY8t9": ["Open in current branch"],
"OvEjsP": ["Copying..."],
"OxplNM": ["Updated \"", ["0"], "\": added ", ["1"], ", removed ", ["2"]],
@@ -1234,6 +1243,7 @@
"VBE2dw": [
"Build and keep track of the world behind your story. A home for your characters, places, factions, and the lore that ties them together, so details stay consistent as you write."
],
+ "VIwCaD": ["Entry"],
"VM7H66": ["This file is binary and can't be shown as text."],
"VNgKZz": ["Advanced settings"],
"VU3Nrn": ["Missing"],
@@ -1413,6 +1423,7 @@
"ZvzbDF": ["Add it directly to this project."],
"ZxXhLY": ["Hide Files (", ["sidebarShortcut"], ")"],
"Zz25kq": ["Show Files (", ["sidebarShortcut"], ")"],
+ "_5qBNl": ["AI tools & CLI"],
"_6FVBz": ["Jump to tab 1-8"],
"_7UQ7y": ["Whole word"],
"_8quCH": ["From template"],
@@ -1488,6 +1499,7 @@
],
"b4itZn": ["Working"],
"b5aNbi": ["The ", ["targetNoun"], " could not be opened — try navigating to it manually."],
+ "bBE5tC": ["Detected on this machine"],
"bBcFK_": ["Open emoji picker for ", ["keyName"]],
"bD8I7O": ["Complete"],
"bGa3Fk": ["Uploading file"],
@@ -1619,6 +1631,7 @@
"f1XQyZ": ["Move block"],
"f65AOQ": ["Start from"],
"f8jU-L": [["0"], "/", ["1"], " — ", ["2"]],
+ "f9lQNJ": ["Adds a managed block to"],
"fBHvBn": ["There's no project folder for this window, so a terminal can't start here."],
"fBaTkM": ["Toggle the bottom terminal panel."],
"fG0X0e": ["Install ", ["brand"], " →"],
@@ -1670,6 +1683,7 @@
],
"gYz2ep": ["Expires in ", ["timeLabel"]],
"gbHcbI": ["Failed to delete property"],
+ "gfdqcY": ["Couldn't apply the change: ", ["0"]],
"gfohmY": ["Connect tools"],
"ggm6JX": [
"This page doesn't exist yet. Open it to create the page in the editor and collapse the graph."
@@ -1901,6 +1915,9 @@
"mBltnd": ["Path suggestions"],
"mGaZwZ": ["See the full install guide"],
"mHVPm5": ["Reconnect required"],
+ "mLAjyL": [
+ "Give the AI tools you use access to read and update your projects. Checking a box sets it up right away; unchecking removes it."
+ ],
"mNY1G6": ["Undo all edits"],
"mPneVR": ["Updated \"", ["display"], "\" to ", ["0"], "."],
"mPy9lS": [
@@ -1966,6 +1983,7 @@
"nYeBmY": [["hours"], "h ago"],
"nbfdhU": ["Integrations"],
"ndeI89": ["Use Cmd/Ctrl+C to copy the link below, or open OK in the desktop app."],
+ "ndwmea": ["unavailable on this platform"],
"neRy3o": ["Split list item"],
"nfoduq": ["create worktree"],
"nft48x": [
@@ -2389,6 +2407,9 @@
["typeLabel"],
" (inherited from folder properties; not editable here)"
],
+ "yhdqox": [
+ "Installed — ok is available in external terminals. Unchecking removes it; OpenKnowledge's built-in terminal and AI tools keep working."
+ ],
"yitgD9": ["Failed to load skill targets: ", ["0"]],
"yjExfe": ["Branch <0>", ["shareBranch"], "</0> is checked out in:"],
"ylXj1N": ["Selected"],
diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.po
index 9ee2b363f..ee1b813a3 100644
--- a/packages/app/src/locales/en/messages.po
+++ b/packages/app/src/locales/en/messages.po
@@ -476,6 +476,10 @@ msgstr "<{componentName}> isn't a known component. Copy the source to use it els
msgid "<{descriptorLabel}> failed to render (likely a bad prop). Copy the source to see what went wrong, or delete the block."
msgstr "<{descriptorLabel}> failed to render (likely a bad prop). Copy the source to see what went wrong, or delete the block."
+#: src/components/settings/AiToolsSection.tsx
+msgid "<0>~/.ok/bin</0> and <1>~/.ok/env.sh</1> stay either way — the app always maintains them."
+msgstr "<0>~/.ok/bin</0> and <1>~/.ok/env.sh</1> stay either way — the app always maintains them."
+
#: src/editor/components/Mirror.tsx
msgid "<0>Mirror — pick a source.</0> Set <1>src</1> + <2>anchor</2> via the property panel to point at a <3><MirrorSource></3> elsewhere."
msgstr "<0>Mirror — pick a source.</0> Set <1>src</1> + <2>anchor</2> via the property panel to point at a <3><MirrorSource></3> elsewhere."
@@ -708,8 +712,10 @@ msgstr "Add tab"
msgid "Add tag"
msgstr "Add tag"
+#. Checkbox in Settings → AI tools & CLI that adds the ok CLI to the user's shell PATH
#. Toggle in the first-launch dialog that adds the ok CLI to the user's shell PATH
#: src/components/McpConsentDialogBody.tsx
+#: src/components/settings/AiToolsSection.tsx
msgid "Add the <0>ok</0> command to your terminal"
msgstr "Add the <0>ok</0> command to your terminal"
@@ -717,13 +723,21 @@ msgstr "Add the <0>ok</0> command to your terminal"
msgid "Add the next matching source selection."
msgstr "Add the next matching source selection."
+#. Subtext for the open-knowledge-write-skill skill row
#. Subtext for the open-knowledge-write-skill skill row
#: src/components/McpConsentDialogBody.tsx
+#: src/components/settings/AiToolsSection.tsx
msgid "Adds a guided workflow for authoring new Agent Skills."
msgstr "Adds a guided workflow for authoring new Agent Skills."
+#: src/components/settings/AiToolsSection.tsx
+msgid "Adds a managed block to"
+msgstr "Adds a managed block to"
+
#. placeholder {0}: pathInstall.rcFilesToTouch.join(', ')
+#. placeholder {0}: status.path.rcFilesToTouch.join(', ')
#: src/components/McpConsentDialogBody.tsx
+#: src/components/settings/AiToolsSection.tsx
msgid "Adds a managed block to {0}"
msgstr "Adds a managed block to {0}"
@@ -752,11 +766,22 @@ msgstr "Agent activity"
msgid "Agent configuration file"
msgstr "Agent configuration file"
+#. Group label above the skill rows in Settings → AI tools & CLI
#. Section label above the skill checkboxes in the first-launch dialog
#: src/components/McpConsentDialogBody.tsx
+#: src/components/settings/AiToolsSection.tsx
msgid "Agent Skills"
msgstr "Agent Skills"
+#: src/components/settings/AiToolsSection.tsx
+msgid "AI tool management is only available in the OpenKnowledge desktop app."
+msgstr "AI tool management is only available in the OpenKnowledge desktop app."
+
+#: src/components/settings/AiToolsSection.tsx
+#: src/components/settings/SettingsDialogShell.tsx
+msgid "AI tools & CLI"
+msgstr "AI tools & CLI"
+
#: src/components/FolderOverview.tsx
msgid "All files"
msgstr "All files"
@@ -1108,6 +1133,10 @@ msgstr "By tag"
msgid "Can't nest projects. An OpenKnowledge project already exists at <0>{rootPath}</0>. Choose a location outside it, or open that project instead."
msgstr "Can't nest projects. An OpenKnowledge project already exists at <0>{rootPath}</0>. Choose a location outside it, or open that project instead."
+#: src/components/settings/AiToolsSection.tsx
+msgid "Can't safely edit this tool's config"
+msgstr "Can't safely edit this tool's config"
+
#: src/components/ActivityPanelFileRow.tsx
#: src/components/AuthModal.tsx
#: src/components/CloneDialog.tsx
@@ -1808,6 +1837,11 @@ msgstr "Could not validate folder. Please try again."
msgid "Could not write project files. Try a different location."
msgstr "Could not write project files. Try a different location."
+#. placeholder {0}: err instanceof Error ? err.message : String(err)
+#: src/components/settings/AiToolsSection.tsx
+msgid "Couldn't apply the change: {0}"
+msgstr "Couldn't apply the change: {0}"
+
#: src/components/settings/EmbeddingsKeySection.tsx
msgid "Couldn't clear the key — please try again."
msgstr "Couldn't clear the key — please try again."
@@ -2172,6 +2206,10 @@ msgstr "Custom display text"
msgid "Custom HTML with a live preview pane (sandboxed iframe)."
msgstr "Custom HTML with a live preview pane (sandboxed iframe)."
+#: src/components/settings/AiToolsSection.tsx
+msgid "Custom open-knowledge entry — not managed by OpenKnowledge"
+msgstr "Custom open-knowledge entry — not managed by OpenKnowledge"
+
#: src/components/settings/SettingsDialogBody.tsx
msgid "Customize how the editor looks and behaves."
msgstr "Customize how the editor looks and behaves."
@@ -2301,6 +2339,10 @@ msgstr "Details"
msgid "Detected from the editors this project is set up for. Adjust to control where every skill installs."
msgstr "Detected from the editors this project is set up for. Adjust to control where every skill installs."
+#: src/components/settings/AiToolsSection.tsx
+msgid "Detected on this machine"
+msgstr "Detected on this machine"
+
#: src/components/CommandPalette.tsx
#: src/components/handoff/OpenInAgentMenuItem.tsx
msgid "Detecting"
@@ -2689,6 +2731,10 @@ msgstr "Enter a title for this template."
msgid "Enter a valid branch name (no spaces, no leading dot, no \"..\")."
msgstr "Enter a valid branch name (no spaces, no leading dot, no \"..\")."
+#: src/components/settings/AiToolsSection.tsx
+msgid "Entry"
+msgstr "Entry"
+
#: src/components/ShareReceiveDialog.tsx
msgid "Error:"
msgstr "Error:"
@@ -2991,6 +3037,7 @@ msgstr "Fetch failed — check the server logs for details."
msgid "Fetching"
msgstr "Fetching"
+#: src/components/settings/AiToolsSection.tsx
#: src/components/share-metadata-rows.tsx
#: src/editor/slash-command/component-items.tsx
msgid "File"
@@ -3141,6 +3188,10 @@ msgstr "Folder properties"
msgid "Folder target: {linkTitle}. Click to open the overview."
msgstr "Folder target: {linkTitle}. Click to open the overview."
+#: src/components/settings/AiToolsSection.tsx
+msgid "Folders"
+msgstr "Folders"
+
#: src/components/SubscribeCard.tsx
msgid "Follow us on"
msgstr "Follow us on"
@@ -3225,6 +3276,10 @@ msgstr "GitHub authentication failed. Try signing in again."
msgid "GitHub sign-in is missing or expired. Reconnect to resume syncing."
msgstr "GitHub sign-in is missing or expired. Reconnect to resume syncing."
+#: src/components/settings/AiToolsSection.tsx
+msgid "Give the AI tools you use access to read and update your projects. Checking a box sets it up right away; unchecking removes it."
+msgstr "Give the AI tools you use access to read and update your projects. Checking a box sets it up right away; unchecking removes it."
+
#: src/components/McpConsentDialogBody.tsx
msgid "Give the AI tools you use access to read and update your projects. Pick what to set up below, and change it anytime."
msgstr "Give the AI tools you use access to read and update your projects. Pick what to set up below, and change it anytime."
@@ -3317,8 +3372,10 @@ msgstr "Heads up"
msgid "Hello, world!"
msgstr "Hello, world!"
+#. Subtext for the open-knowledge-discovery skill row
#. Subtext for the open-knowledge-discovery skill row
#: src/components/McpConsentDialogBody.tsx
+#: src/components/settings/AiToolsSection.tsx
msgid "Helps your coding agent recognize OpenKnowledge projects and route reads and writes through it."
msgstr "Helps your coding agent recognize OpenKnowledge projects and route reads and writes through it."
@@ -3435,13 +3492,16 @@ msgstr "How does sharing work?"
msgid "How to push manually"
msgstr "How to push manually"
+#. Link on an undetected tool row to its OpenKnowledge setup guide
#. Link on an undetected tool row to its OpenKnowledge setup guide
#: src/components/McpConsentDialogBody.tsx
+#: src/components/settings/AiToolsSection.tsx
msgid "How to set up"
msgstr "How to set up"
#. placeholder {0}: editor.label
#: src/components/McpConsentDialogBody.tsx
+#: src/components/settings/AiToolsSection.tsx
msgid "How to set up {0} (opens in browser)"
msgstr "How to set up {0} (opens in browser)"
@@ -3648,12 +3708,17 @@ msgstr "Install on all"
msgid "Install skills into"
msgstr "Install skills into"
+#: src/components/settings/AiToolsSection.tsx
#: src/components/SkillEditorActions.tsx
#: src/components/SkillRow.tsx
#: src/components/SkillStateBadge.tsx
msgid "Installed"
msgstr "Installed"
+#: src/components/settings/AiToolsSection.tsx
+msgid "Installed — ok is available in external terminals. Unchecking removes it; OpenKnowledge's built-in terminal and AI tools keep working."
+msgstr "Installed — ok is available in external terminals. Unchecking removes it; OpenKnowledge's built-in terminal and AI tools keep working."
+
#. placeholder {0}: skill.name
#. placeholder {1}: label(added)
#: src/components/skill-actions.tsx
@@ -3970,6 +4035,10 @@ msgstr "Manage hidden files in Settings → Ignore patterns."
msgid "Manage the GitHub account OpenKnowledge uses to browse and sync your repositories."
msgstr "Manage the GitHub account OpenKnowledge uses to browse and sync your repositories."
+#: src/components/settings/AiToolsSection.tsx
+msgid "Managing AI tools is unavailable in this build."
+msgstr "Managing AI tools is unavailable in this build."
+
#: src/components/empty-state/use-create-suggestions.ts
msgid "Map the architecture"
msgstr "Map the architecture"
@@ -3990,8 +4059,10 @@ msgstr "Markdown source"
msgid "Match case"
msgstr "Match case"
+#. Group label above the per-editor MCP list in Settings → AI tools & CLI — each row wires OpenKnowledge's MCP server into that tool
#. Section label above the editor checkbox list in the first-launch dialog — each row wires OpenKnowledge's MCP server into that tool
#: src/components/McpConsentDialogBody.tsx
+#: src/components/settings/AiToolsSection.tsx
msgid "MCP connections"
msgstr "MCP connections"
@@ -6699,6 +6770,7 @@ msgstr "Templates"
msgid "Templates available"
msgstr "Templates available"
+#. Group label above the shell-PATH row in Settings → AI tools & CLI
#. Section label above the shell-PATH toggle in the first-launch dialog
#: src/components/empty-state/CreatePromptComposer.tsx
#: src/components/handoff/AgentSplitButton.tsx
@@ -6706,6 +6778,7 @@ msgstr "Templates available"
#: src/components/handoff/OpenInAgentEmptySpaceSubmenu.tsx
#: src/components/handoff/OpenInAgentMenu.tsx
#: src/components/McpConsentDialogBody.tsx
+#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/SettingsDialogShell.tsx
#: src/components/settings/TerminalSection.tsx
#: src/components/TerminalNewChatButton.tsx
@@ -7199,6 +7272,10 @@ msgstr "Type to edit; <0>⌘ Enter</0> saves, <1>Esc</1> cancels."
msgid "Type to find a doc"
msgstr "Type to find a doc"
+#: src/components/settings/AiToolsSection.tsx
+msgid "unavailable on this platform"
+msgstr "unavailable on this platform"
+
#: src/components/AutoSyncEnableWarning.tsx
msgid "Uncommitted changes"
msgstr "Uncommitted changes"
@@ -7560,6 +7637,10 @@ msgstr "What the agent may read, write, and surface."
msgid "What this changes"
msgstr "What this changes"
+#: src/components/settings/AiToolsSection.tsx
+msgid "What this checkbox changes"
+msgstr "What this checkbox changes"
+
#: src/components/empty-state/empty-state-copy.ts
msgid "What would you like to create?"
msgstr "What would you like to create?"
diff --git a/packages/app/src/locales/pseudo/messages.json b/packages/app/src/locales/pseudo/messages.json
index 51130360b..c0afde109 100644
--- a/packages/app/src/locales/pseudo/messages.json
+++ b/packages/app/src/locales/pseudo/messages.json
@@ -109,6 +109,7 @@
"28B21t": ["Àĝēńţ Śķĩĺĺś"],
"29VNqC": ["Ũńķńōŵń ēŕŕōŕ"],
"29XZXN": ["Śēţ ĝĩţ ĩďēńţĩţŷ"],
+ "2B6eYX": ["Ŵĥàţ ţĥĩś ćĥēćķƀōx ćĥàńĝēś"],
"2BBAbc": ["Ĺĩśţ"],
"2FYpfJ": ["Ḿōŕē"],
"2GT3Hf": ["Ĝĺōƀàĺ"],
@@ -456,6 +457,7 @@
". Ćĥàńĝē ĩţ ĩń Śēţţĩńĝś → Śŷńć."
],
"AcK_r0": ["Ćĺàũďē ĆĹĨ"],
+ "AczYxH": ["Ćũśţōḿ ōƥēń-ķńōŵĺēďĝē ēńţŕŷ — ńōţ ḿàńàĝēď ƀŷ ŌƥēńĶńōŵĺēďĝē"],
"AdcGcG": ["Àƥƥĺŷĩńĝ ŷōũŕ ćĥàńĝē"],
"AddR83": ["Ćōũĺď ńōţ ćŕēàţē ƥŕōĴēćţ. Ţŕŷ àĝàĩń ōŕ ƥĩćķ à ďĩƒƒēŕēńţ ĺōćàţĩōń."],
"AeHuzT": ["# Ōńē ƥàţţēŕń ƥēŕ ĺĩńē.\n# Ēxàḿƥĺēś:\n# ďŕàƒţś/\n# *.ďŕàƒţ.ḿď\n# !ķēēƥ.ḿď"],
@@ -521,6 +523,9 @@
"CSL0l1": ["Ćōũĺďń'ţ ćĺēàŕ ţĥē ķēŷ — ƥĺēàśē ţŕŷ àĝàĩń."],
"CTJLpz": ["\"", ["trimmed"], "\" àĺŕēàďŷ ēxĩśţś ĥēŕē"],
"CU3AiE": ["Śŵĩţćĥĩńĝ ƀŕàńćĥēś"],
+ "CWzc2T": [
+ "<0>~/.ōķ/ƀĩń</0> àńď <1>~/.ōķ/ēńv.śĥ</1> śţàŷ ēĩţĥēŕ ŵàŷ — ţĥē àƥƥ àĺŵàŷś ḿàĩńţàĩńś ţĥēḿ."
+ ],
"CXj9C-": ["Ńēŵ ƥŕōƥēŕţŷ ńàḿē"],
"C_WGy8": [
"Ţĥĩś ƒĩĺē ĩś ţōō ĺàŕĝē ţō ōƥēń ĩń ţĥē ƀũĩĺţ-ĩń ţēxţ ēďĩţōŕ (1 Ḿß ĺĩḿĩţ). Ũśē Ōƥēń ƒĩĺē ƀēĺōŵ ţō ōƥēń ĩţ ĩń àńōţĥēŕ àƥƥ."
@@ -736,6 +741,7 @@
"HIb0vl": ["Ńēţŵōŕķ ēŕŕōŕ — ƥĺēàśē ţŕŷ àĝàĩń"],
"HM56Bx": ["Ćŕēàţĩńĝ..."],
"HPTPGr": ["Ćŕēàţē à ńēŵ śƥēć ƒĩĺē ƒōŕ ḿŷ ũśēŕ śţōŕŷ"],
+ "HSh8u_": ["Ƒōĺďēŕś"],
"HXFyWD": ["Śƥĺĩţ ďĩƒƒ"],
"HdkSiO": ["Ńēŵ ƒĩĺē"],
"HfI1dR": ["Ĩ àĺŕēàďŷ ĥàvē ĩţ ĺōćàĺĺŷ →"],
@@ -870,6 +876,7 @@
"LXdWeS": ["Ḿēďĩũḿ śēćţĩōń ĥēàďĩńĝ."],
"LXfNU-": ["Ńàvĩĝàţĩōń àńď śũĝĝēśţĩōńś"],
"LYufDw": ["Ƒàĩĺēď ţō ēńàƀĺē śēḿàńţĩć śēàŕćĥ — ", ["detail"]],
+ "LbmLyU": ["Ćàń'ţ śàƒēĺŷ ēďĩţ ţĥĩś ţōōĺ'ś ćōńƒĩĝ"],
"Lcehxn": ["Śàvē ŕēśōĺũţĩōń"],
"LdABLa": ["Ćōũĺď ńōţ ōƥēń ", ["target"], ". Ţŕŷ ōƥēńĩńĝ ĩţ ḿàńũàĺĺŷ."],
"LdKIHS": ["Ďŕàƒţ à śƥēć"],
@@ -986,6 +993,7 @@
"O0Z2Xr": ["Ōũţĝōĩńĝ"],
"O2UpM1": ["ßŕōŵśē"],
"O3oNi5": ["Ēḿàĩĺ"],
+ "O4PnDd": ["ÀĨ ţōōĺ ḿàńàĝēḿēńţ ĩś ōńĺŷ àvàĩĺàƀĺē ĩń ţĥē ŌƥēńĶńōŵĺēďĝē ďēśķţōƥ àƥƥ."],
"O6yEPk": ["Ćŕēàţē à ńēŵ ŌƥēńĶńōŵĺēďĝē ƥŕōĴēćţ ĩń ţĥē ƒōĺďēŕ ōƒ ŷōũŕ ćĥōĩćē."],
"O7_W_a": ["Ōƥēń ŵĩţĥ ÀĨ"],
"OD0FCX": ["Ĥĩďďēń “", ["basename"], "”"],
@@ -1017,6 +1025,7 @@
"On0aF2": ["Ŵēƀśĩţē"],
"Oo_WWc": ["Ńō ƥàĝēś ƒōũńď"],
"Oos8fo": ["Ćōƥŷ ćōḿḿàńď"],
+ "OplnBG": ["Ḿàńàĝĩńĝ ÀĨ ţōōĺś ĩś ũńàvàĩĺàƀĺē ĩń ţĥĩś ƀũĩĺď."],
"OuY8t9": ["Ōƥēń ĩń ćũŕŕēńţ ƀŕàńćĥ"],
"OvEjsP": ["Ćōƥŷĩńĝ..."],
"OxplNM": ["Ũƥďàţēď \"", ["0"], "\": àďďēď ", ["1"], ", ŕēḿōvēď ", ["2"]],
@@ -1234,6 +1243,7 @@
"VBE2dw": [
"ßũĩĺď àńď ķēēƥ ţŕàćķ ōƒ ţĥē ŵōŕĺď ƀēĥĩńď ŷōũŕ śţōŕŷ. À ĥōḿē ƒōŕ ŷōũŕ ćĥàŕàćţēŕś, ƥĺàćēś, ƒàćţĩōńś, àńď ţĥē ĺōŕē ţĥàţ ţĩēś ţĥēḿ ţōĝēţĥēŕ, śō ďēţàĩĺś śţàŷ ćōńśĩśţēńţ àś ŷōũ ŵŕĩţē."
],
+ "VIwCaD": ["Ēńţŕŷ"],
"VM7H66": ["Ţĥĩś ƒĩĺē ĩś ƀĩńàŕŷ àńď ćàń'ţ ƀē śĥōŵń àś ţēxţ."],
"VNgKZz": ["Àďvàńćēď śēţţĩńĝś"],
"VU3Nrn": ["Ḿĩśśĩńĝ"],
@@ -1413,6 +1423,7 @@
"ZvzbDF": ["Àďď ĩţ ďĩŕēćţĺŷ ţō ţĥĩś ƥŕōĴēćţ."],
"ZxXhLY": ["Ĥĩďē Ƒĩĺēś (", ["sidebarShortcut"], ")"],
"Zz25kq": ["Śĥōŵ Ƒĩĺēś (", ["sidebarShortcut"], ")"],
+ "_5qBNl": ["ÀĨ ţōōĺś & ĆĹĨ"],
"_6FVBz": ["ĵũḿƥ ţō ţàƀ 1-8"],
"_7UQ7y": ["Ŵĥōĺē ŵōŕď"],
"_8quCH": ["Ƒŕōḿ ţēḿƥĺàţē"],
@@ -1488,6 +1499,7 @@
],
"b4itZn": ["Ŵōŕķĩńĝ"],
"b5aNbi": ["Ţĥē ", ["targetNoun"], " ćōũĺď ńōţ ƀē ōƥēńēď — ţŕŷ ńàvĩĝàţĩńĝ ţō ĩţ ḿàńũàĺĺŷ."],
+ "bBE5tC": ["Ďēţēćţēď ōń ţĥĩś ḿàćĥĩńē"],
"bBcFK_": ["Ōƥēń ēḿōĴĩ ƥĩćķēŕ ƒōŕ ", ["keyName"]],
"bD8I7O": ["Ćōḿƥĺēţē"],
"bGa3Fk": ["Ũƥĺōàďĩńĝ ƒĩĺē"],
@@ -1619,6 +1631,7 @@
"f1XQyZ": ["Ḿōvē ƀĺōćķ"],
"f65AOQ": ["Śţàŕţ ƒŕōḿ"],
"f8jU-L": [["0"], "/", ["1"], " — ", ["2"]],
+ "f9lQNJ": ["Àďďś à ḿàńàĝēď ƀĺōćķ ţō"],
"fBHvBn": ["Ţĥēŕē'ś ńō ƥŕōĴēćţ ƒōĺďēŕ ƒōŕ ţĥĩś ŵĩńďōŵ, śō à ţēŕḿĩńàĺ ćàń'ţ śţàŕţ ĥēŕē."],
"fBaTkM": ["Ţōĝĝĺē ţĥē ƀōţţōḿ ţēŕḿĩńàĺ ƥàńēĺ."],
"fG0X0e": ["Ĩńśţàĺĺ ", ["brand"], " →"],
@@ -1670,6 +1683,7 @@
],
"gYz2ep": ["Ēxƥĩŕēś ĩń ", ["timeLabel"]],
"gbHcbI": ["Ƒàĩĺēď ţō ďēĺēţē ƥŕōƥēŕţŷ"],
+ "gfdqcY": ["Ćōũĺďń'ţ àƥƥĺŷ ţĥē ćĥàńĝē: ", ["0"]],
"gfohmY": ["Ćōńńēćţ ţōōĺś"],
"ggm6JX": [
"Ţĥĩś ƥàĝē ďōēśń'ţ ēxĩśţ ŷēţ. Ōƥēń ĩţ ţō ćŕēàţē ţĥē ƥàĝē ĩń ţĥē ēďĩţōŕ àńď ćōĺĺàƥśē ţĥē ĝŕàƥĥ."
@@ -1901,6 +1915,9 @@
"mBltnd": ["Ƥàţĥ śũĝĝēśţĩōńś"],
"mGaZwZ": ["Śēē ţĥē ƒũĺĺ ĩńśţàĺĺ ĝũĩďē"],
"mHVPm5": ["Ŕēćōńńēćţ ŕēǫũĩŕēď"],
+ "mLAjyL": [
+ "Ĝĩvē ţĥē ÀĨ ţōōĺś ŷōũ ũśē àććēśś ţō ŕēàď àńď ũƥďàţē ŷōũŕ ƥŕōĴēćţś. Ćĥēćķĩńĝ à ƀōx śēţś ĩţ ũƥ ŕĩĝĥţ àŵàŷ; ũńćĥēćķĩńĝ ŕēḿōvēś ĩţ."
+ ],
"mNY1G6": ["Ũńďō àĺĺ ēďĩţś"],
"mPneVR": ["Ũƥďàţēď \"", ["display"], "\" ţō ", ["0"], "."],
"mPy9lS": [
@@ -1966,6 +1983,7 @@
"nYeBmY": [["hours"], "ĥ àĝō"],
"nbfdhU": ["Ĩńţēĝŕàţĩōńś"],
"ndeI89": ["Ũśē Ćḿď/Ćţŕĺ+Ć ţō ćōƥŷ ţĥē ĺĩńķ ƀēĺōŵ, ōŕ ōƥēń ŌĶ ĩń ţĥē ďēśķţōƥ àƥƥ."],
+ "ndwmea": ["ũńàvàĩĺàƀĺē ōń ţĥĩś ƥĺàţƒōŕḿ"],
"neRy3o": ["Śƥĺĩţ ĺĩśţ ĩţēḿ"],
"nfoduq": ["ćŕēàţē ŵōŕķţŕēē"],
"nft48x": [
@@ -2389,6 +2407,9 @@
["typeLabel"],
" (ĩńĥēŕĩţēď ƒŕōḿ ƒōĺďēŕ ƥŕōƥēŕţĩēś; ńōţ ēďĩţàƀĺē ĥēŕē)"
],
+ "yhdqox": [
+ "Ĩńśţàĺĺēď — ōķ ĩś àvàĩĺàƀĺē ĩń ēxţēŕńàĺ ţēŕḿĩńàĺś. Ũńćĥēćķĩńĝ ŕēḿōvēś ĩţ; ŌƥēńĶńōŵĺēďĝē'ś ƀũĩĺţ-ĩń ţēŕḿĩńàĺ àńď ÀĨ ţōōĺś ķēēƥ ŵōŕķĩńĝ."
+ ],
"yitgD9": ["Ƒàĩĺēď ţō ĺōàď śķĩĺĺ ţàŕĝēţś: ", ["0"]],
"yjExfe": ["ßŕàńćĥ <0>", ["shareBranch"], "</0> ĩś ćĥēćķēď ōũţ ĩń:"],
"ylXj1N": ["Śēĺēćţēď"],
diff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.po
index 293629d9b..963384dfe 100644
--- a/packages/app/src/locales/pseudo/messages.po
+++ b/packages/app/src/locales/pseudo/messages.po
@@ -471,6 +471,10 @@ msgstr ""
msgid "<{descriptorLabel}> failed to render (likely a bad prop). Copy the source to see what went wrong, or delete the block."
msgstr ""
+#: src/components/settings/AiToolsSection.tsx
+msgid "<0>~/.ok/bin</0> and <1>~/.ok/env.sh</1> stay either way — the app always maintains them."
+msgstr ""
+
#: src/editor/components/Mirror.tsx
msgid "<0>Mirror — pick a source.</0> Set <1>src</1> + <2>anchor</2> via the property panel to point at a <3><MirrorSource></3> elsewhere."
msgstr ""
@@ -703,8 +707,10 @@ msgstr ""
msgid "Add tag"
msgstr ""
+#. Checkbox in Settings → AI tools & CLI that adds the ok CLI to the user's shell PATH
#. Toggle in the first-launch dialog that adds the ok CLI to the user's shell PATH
#: src/components/McpConsentDialogBody.tsx
+#: src/components/settings/AiToolsSection.tsx
msgid "Add the <0>ok</0> command to your terminal"
msgstr ""
@@ -712,13 +718,21 @@ msgstr ""
msgid "Add the next matching source selection."
msgstr ""
+#. Subtext for the open-knowledge-write-skill skill row
#. Subtext for the open-knowledge-write-skill skill row
#: src/components/McpConsentDialogBody.tsx
+#: src/components/settings/AiToolsSection.tsx
msgid "Adds a guided workflow for authoring new Agent Skills."
msgstr ""
+#: src/components/settings/AiToolsSection.tsx
+msgid "Adds a managed block to"
+msgstr ""
+
#. placeholder {0}: pathInstall.rcFilesToTouch.join(', ')
+#. placeholder {0}: status.path.rcFilesToTouch.join(', ')
#: src/components/McpConsentDialogBody.tsx
+#: src/components/settings/AiToolsSection.tsx
msgid "Adds a managed block to {0}"
msgstr ""
@@ -747,11 +761,22 @@ msgstr ""
msgid "Agent configuration file"
msgstr ""
+#. Group label above the skill rows in Settings → AI tools & CLI
#. Section label above the skill checkboxes in the first-launch dialog
#: src/components/McpConsentDialogBody.tsx
+#: src/components/settings/AiToolsSection.tsx
msgid "Agent Skills"
msgstr ""
+#: src/components/settings/AiToolsSection.tsx
+msgid "AI tool management is only available in the OpenKnowledge desktop app."
+msgstr ""
+
+#: src/components/settings/AiToolsSection.tsx
+#: src/components/settings/SettingsDialogShell.tsx
+msgid "AI tools & CLI"
+msgstr ""
+
#: src/components/FolderOverview.tsx
msgid "All files"
msgstr ""
@@ -1103,6 +1128,10 @@ msgstr ""
msgid "Can't nest projects. An OpenKnowledge project already exists at <0>{rootPath}</0>. Choose a location outside it, or open that project instead."
msgstr ""
+#: src/components/settings/AiToolsSection.tsx
+msgid "Can't safely edit this tool's config"
+msgstr ""
+
#: src/components/ActivityPanelFileRow.tsx
#: src/components/AuthModal.tsx
#: src/components/CloneDialog.tsx
@@ -1803,6 +1832,11 @@ msgstr ""
msgid "Could not write project files. Try a different location."
msgstr ""
+#. placeholder {0}: err instanceof Error ? err.message : String(err)
+#: src/components/settings/AiToolsSection.tsx
+msgid "Couldn't apply the change: {0}"
+msgstr ""
+
#: src/components/settings/EmbeddingsKeySection.tsx
msgid "Couldn't clear the key — please try again."
msgstr ""
@@ -2167,6 +2201,10 @@ msgstr ""
msgid "Custom HTML with a live preview pane (sandboxed iframe)."
msgstr ""
+#: src/components/settings/AiToolsSection.tsx
+msgid "Custom open-knowledge entry — not managed by OpenKnowledge"
+msgstr ""
+
#: src/components/settings/SettingsDialogBody.tsx
msgid "Customize how the editor looks and behaves."
msgstr ""
@@ -2296,6 +2334,10 @@ msgstr ""
msgid "Detected from the editors this project is set up for. Adjust to control where every skill installs."
msgstr ""
+#: src/components/settings/AiToolsSection.tsx
+msgid "Detected on this machine"
+msgstr ""
+
#: src/components/CommandPalette.tsx
#: src/components/handoff/OpenInAgentMenuItem.tsx
msgid "Detecting"
@@ -2684,6 +2726,10 @@ msgstr ""
msgid "Enter a valid branch name (no spaces, no leading dot, no \"..\")."
msgstr ""
+#: src/components/settings/AiToolsSection.tsx
+msgid "Entry"
+msgstr ""
+
#: src/components/ShareReceiveDialog.tsx
msgid "Error:"
msgstr ""
@@ -2986,6 +3032,7 @@ msgstr ""
msgid "Fetching"
msgstr ""
+#: src/components/settings/AiToolsSection.tsx
#: src/components/share-metadata-rows.tsx
#: src/editor/slash-command/component-items.tsx
msgid "File"
@@ -3136,6 +3183,10 @@ msgstr ""
msgid "Folder target: {linkTitle}. Click to open the overview."
msgstr ""
+#: src/components/settings/AiToolsSection.tsx
+msgid "Folders"
+msgstr ""
+
#: src/components/SubscribeCard.tsx
msgid "Follow us on"
msgstr ""
@@ -3220,6 +3271,10 @@ msgstr ""
msgid "GitHub sign-in is missing or expired. Reconnect to resume syncing."
msgstr ""
+#: src/components/settings/AiToolsSection.tsx
+msgid "Give the AI tools you use access to read and update your projects. Checking a box sets it up right away; unchecking removes it."
+msgstr ""
+
#: src/components/McpConsentDialogBody.tsx
msgid "Give the AI tools you use access to read and update your projects. Pick what to set up below, and change it anytime."
msgstr ""
@@ -3312,8 +3367,10 @@ msgstr ""
msgid "Hello, world!"
msgstr ""
+#. Subtext for the open-knowledge-discovery skill row
#. Subtext for the open-knowledge-discovery skill row
#: src/components/McpConsentDialogBody.tsx
+#: src/components/settings/AiToolsSection.tsx
msgid "Helps your coding agent recognize OpenKnowledge projects and route reads and writes through it."
msgstr ""
@@ -3430,13 +3487,16 @@ msgstr ""
msgid "How to push manually"
msgstr ""
+#. Link on an undetected tool row to its OpenKnowledge setup guide
#. Link on an undetected tool row to its OpenKnowledge setup guide
#: src/components/McpConsentDialogBody.tsx
+#: src/components/settings/AiToolsSection.tsx
msgid "How to set up"
msgstr ""
#. placeholder {0}: editor.label
#: src/components/McpConsentDialogBody.tsx
+#: src/components/settings/AiToolsSection.tsx
msgid "How to set up {0} (opens in browser)"
msgstr ""
@@ -3643,12 +3703,17 @@ msgstr ""
msgid "Install skills into"
msgstr ""
+#: src/components/settings/AiToolsSection.tsx
#: src/components/SkillEditorActions.tsx
#: src/components/SkillRow.tsx
#: src/components/SkillStateBadge.tsx
msgid "Installed"
msgstr ""
+#: src/components/settings/AiToolsSection.tsx
+msgid "Installed — ok is available in external terminals. Unchecking removes it; OpenKnowledge's built-in terminal and AI tools keep working."
+msgstr ""
+
#. placeholder {0}: skill.name
#. placeholder {1}: label(added)
#: src/components/skill-actions.tsx
@@ -3965,6 +4030,10 @@ msgstr ""
msgid "Manage the GitHub account OpenKnowledge uses to browse and sync your repositories."
msgstr ""
+#: src/components/settings/AiToolsSection.tsx
+msgid "Managing AI tools is unavailable in this build."
+msgstr ""
+
#: src/components/empty-state/use-create-suggestions.ts
msgid "Map the architecture"
msgstr ""
@@ -3985,8 +4054,10 @@ msgstr ""
msgid "Match case"
msgstr ""
+#. Group label above the per-editor MCP list in Settings → AI tools & CLI — each row wires OpenKnowledge's MCP server into that tool
#. Section label above the editor checkbox list in the first-launch dialog — each row wires OpenKnowledge's MCP server into that tool
#: src/components/McpConsentDialogBody.tsx
+#: src/components/settings/AiToolsSection.tsx
msgid "MCP connections"
msgstr ""
@@ -6694,6 +6765,7 @@ msgstr ""
msgid "Templates available"
msgstr ""
+#. Group label above the shell-PATH row in Settings → AI tools & CLI
#. Section label above the shell-PATH toggle in the first-launch dialog
#: src/components/empty-state/CreatePromptComposer.tsx
#: src/components/handoff/AgentSplitButton.tsx
@@ -6701,6 +6773,7 @@ msgstr ""
#: src/components/handoff/OpenInAgentEmptySpaceSubmenu.tsx
#: src/components/handoff/OpenInAgentMenu.tsx
#: src/components/McpConsentDialogBody.tsx
+#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/SettingsDialogShell.tsx
#: src/components/settings/TerminalSection.tsx
#: src/components/TerminalNewChatButton.tsx
@@ -7194,6 +7267,10 @@ msgstr ""
msgid "Type to find a doc"
msgstr ""
+#: src/components/settings/AiToolsSection.tsx
+msgid "unavailable on this platform"
+msgstr ""
+
#: src/components/AutoSyncEnableWarning.tsx
msgid "Uncommitted changes"
msgstr ""
@@ -7555,6 +7632,10 @@ msgstr ""
msgid "What this changes"
msgstr ""
+#: src/components/settings/AiToolsSection.tsx
+msgid "What this checkbox changes"
+msgstr ""
+
#: src/components/empty-state/empty-state-copy.ts
msgid "What would you like to create?"
msgstr ""
diff --git a/packages/app/tests/stress/fixtures/handoff-mocks.ts b/packages/app/tests/stress/fixtures/handoff-mocks.ts
index 3f9271d20..0ea374ffd 100644
--- a/packages/app/tests/stress/fixtures/handoff-mocks.ts
+++ b/packages/app/tests/stress/fixtures/handoff-mocks.ts
@@ -476,6 +476,24 @@ export async function installHandoffMocks(page: Page, cfg: HandoffMockConfig): P
confirm: async () => ({ ok: true }),
skip: async () => ({ ok: true }),
},
+ integrations: {
+ status: async () => ({
+ available: false,
+ editors: [],
+ path: { shellDetected: false, rcFilesToTouch: [], installed: false },
+ skills: [],
+ }),
+ setComponent: async () => ({
+ ok: false as const,
+ error: 'unavailable in tests',
+ status: {
+ available: false,
+ editors: [],
+ path: { shellDetected: false, rcFilesToTouch: [], installed: false },
+ skills: [],
+ },
+ }),
+ },
// installConsentListener + installOnboardingToastListener are
// wired unconditionally by main.tsx (both guarded internally by
// `if (!b.onboarding) return`), so these stubs run at the
diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts
index fead87d8f..81f1df637 100644
--- a/packages/cli/src/index.ts
+++ b/packages/cli/src/index.ts
@@ -44,6 +44,10 @@ export {
writeEditorMcpConfig,
writeUserMcpConfigs,
} from './commands/init.ts';
+export {
+ type McpRemoveOutcome,
+ removeOwnMcpEntry,
+} from './commands/mcp-config-removal.ts';
export {
buildMcpConfigDeclineEvent,
type McpConfigDeclineEvent,
diff --git a/packages/core/src/bridge/bind-frontmatter-doc.ts b/packages/core/src/bridge/bind-frontmatter-doc.ts
index c014b1413..8f9d95287 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/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.ts
index 8890f6739..c18c086d5 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';
const LEADING_BOUNDARY_RE = /^(?:\r?\n)+/;
diff --git a/packages/core/src/bridge/merge-three-way.ts b/packages/core/src/bridge/merge-three-way.ts
index b0a80fbd9..864bc7245 100644
--- a/packages/core/src/bridge/merge-three-way.ts
+++ b/packages/core/src/bridge/merge-three-way.ts
@@ -37,6 +37,7 @@ function mergeThreeWayImpl(baseline: string, userText: string, agentText: string
return parts.join('\n');
}
+
export type BridgeMergeContentLossSide = 'user' | 'agent';
export type BridgeMergeContentLossWhich = 'substring' | 'order';
diff --git a/packages/core/src/bridge/normalize.ts b/packages/core/src/bridge/normalize.ts
index e67f33b40..592f0b956 100644
--- a/packages/core/src/bridge/normalize.ts
+++ b/packages/core/src/bridge/normalize.ts
@@ -1,3 +1,4 @@
+
const COMMONMARK_ESCAPE_RE = /\\([!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~])/g;
const TABLE_ALIGN_ROW_RE = /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/;
diff --git a/packages/core/src/desktop-bridge.ts b/packages/core/src/desktop-bridge.ts
index 2fa7bac00..b914f7af0 100644
--- a/packages/core/src/desktop-bridge.ts
+++ b/packages/core/src/desktop-bridge.ts
@@ -421,6 +421,55 @@ interface OkMcpWiringConfirmRequest {
*/
type OkMcpWiringResult = { ok: true } | { ok: false; error: string };
+/**
+ * Per-editor MCP state for Settings → AI tools. `installed` rows uncheck to
+ * remove; `not-installed` rows check to install; `foreign` is an entry under
+ * OK's server name that isn't recognizably OK's own (uninstall refuses,
+ * install overwrites); `unmanageable` is a config OK can't safely edit.
+ */
+type OkIntegrationsEditorState = 'installed' | 'not-installed' | 'foreign' | 'unmanageable';
+
+/** Component inventory for Settings → AI tools. `available: false` renders
+ * the section read-only (install actors gated off for this process). `path.
+ * installed` reflects the managed rc block actually being on disk. */
+interface OkIntegrationsStatus {
+ readonly available: boolean;
+ readonly editors: readonly {
+ readonly id: OkMcpWiringEditorId;
+ readonly label: string;
+ readonly detected: boolean;
+ readonly state: OkIntegrationsEditorState;
+ readonly configPath: string | null;
+ readonly entryLocator: string;
+ }[];
+ readonly path: {
+ readonly shellDetected: boolean;
+ readonly rcFilesToTouch: readonly string[];
+ readonly installed: boolean;
+ };
+ readonly skills: readonly {
+ readonly id: string;
+ readonly name: string;
+ readonly installed: boolean;
+ readonly paths: readonly string[];
+ }[];
+}
+
+/** One toggle for `integrations.setComponent`. */
+interface OkIntegrationsSetRequest {
+ readonly component:
+ | { readonly kind: 'editor'; readonly id: OkMcpWiringEditorId }
+ | { readonly kind: 'path' }
+ | { readonly kind: 'skill'; readonly id: string };
+ readonly enabled: boolean;
+}
+
+/** Set-component result — both arms carry a fresh status snapshot so the
+ * renderer re-renders truthfully after failed/refused toggles too. */
+type OkIntegrationsSetResult =
+ | { readonly ok: true; readonly status: OkIntegrationsStatus }
+ | { readonly ok: false; readonly error: string; readonly status: OkIntegrationsStatus };
+
/**
* Per-project consent dialog — renderer-facing payload + result shapes.
* Mirrors the desktop and app copies; drift caught by the
@@ -1320,6 +1369,16 @@ export interface OkDesktopBridge {
skip(): Promise<OkMcpWiringResult>;
};
+ /**
+ * Settings → AI tools: live per-component install state + one-component
+ * install/uninstall for OK's global footprint (per-editor MCP entries,
+ * shell-PATH shim, user-global skill bundles). Mutations serialize in main.
+ */
+ integrations: {
+ status(): Promise<OkIntegrationsStatus>;
+ setComponent(request: OkIntegrationsSetRequest): Promise<OkIntegrationsSetResult>;
+ };
+
/**
* Per-project consent dialog surface. Navigator-only.
* Renderer mounts a shadcn Dialog when `onShow` fires; calls
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/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.ts
index 193e286b0..47f0d07e4 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/fence-regions.ts b/packages/core/src/markdown/fence-regions.ts
index c7518d614..fb5ac8e8a 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 f758cf737..7a22e8016 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 78fdfeb02..2f082e6d0 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 { Root as HastRoot } from 'hast';
import type { Root as MdastRoot } from 'mdast';
import rehypeParse from 'rehype-parse';
@@ -75,7 +76,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 58a810193..064fa0773 100644
--- a/packages/core/src/markdown/index.ts
+++ b/packages/core/src/markdown/index.ts
@@ -1,3 +1,4 @@
+
import {
type FromProseMirrorOptions,
fromPmMark,
@@ -164,6 +165,7 @@ export class MarkdownManager {
}
}
+
const registry = createRegistry();
function destructureAttrs(
@@ -212,6 +214,7 @@ function destructureAttrs(
return result;
}
+
function hasDirtyDescendant(node: PmNode): boolean {
let found = false;
node.descendants((child) => {
@@ -230,6 +233,7 @@ function effectiveDirty(node: PmNode): boolean {
return node.attrs.sourceDirty || hasDirtyDescendant(node);
}
+
function isEmptyMdastParagraph(node: MdastNodes): boolean {
if (node.type !== 'paragraph') return false;
const children = node.children ?? [];
@@ -298,6 +302,7 @@ function extractTextFromMdastNodes(nodes: MdastNodes[]): string {
return out;
}
+
import {
AUDIO_EXTENSIONS,
FILE_ATTACHMENT_EXTENSIONS,
@@ -547,6 +552,7 @@ function buildMdastToPmHandlers(
}));
}
+
if (m.emphasis) {
handlers.emphasis = toPmMark(m.emphasis, (node: Emphasis) => ({
sourceDelimiter: node.data?.sourceDelimiter ?? '*',
@@ -626,6 +632,7 @@ function buildMdastToPmHandlers(
}));
}
+
if (m.link) {
const sourceLiteralMark = m.sourceLiteral;
handlers.link = (node: Link, _parent: MdastParent, state: MdastToPmState) => {
@@ -904,6 +911,7 @@ function buildMdastToPmHandlers(
};
}
+
const blockUnknownHandler = (node: {
type: string;
position?: { start: { offset: number }; end: { offset: number } };
@@ -1029,6 +1037,7 @@ function buildMdastToPmHandlers(
return handlers as RemarkProseMirrorOptions['handlers'];
}
+
function buildPmToMdastHandlers(schema: Schema): {
nodeHandlers: FromProseMirrorOptions<string, string>['nodeHandlers'];
markHandlers: FromProseMirrorOptions<string, string>['markHandlers'];
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 679c72ef7..f84967798 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 35d74b85e..a58f8c720 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 9864b3b60..7e4a9a48b 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 5d6db7aa8..5b9550e90 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 248685cfe..4ac5731e7 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';
diff --git a/packages/core/src/markdown/position-slice.ts b/packages/core/src/markdown/position-slice.ts
index 50a193a16..240be90e6 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';
@@ -466,7 +467,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-helpers.ts b/packages/core/src/markdown/serialize-helpers.ts
index 46cc6a074..542204403 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, MdxJsxExpressionAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import type { PropDef, SerializeContext } from '../registry/types.ts';
diff --git a/packages/core/src/markdown/single-dollar-math-promoter.ts b/packages/core/src/markdown/single-dollar-math-promoter.ts
index be97d4d62..fe73659e6 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 1a2fb5d50..e1161455b 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/unknown-mdast-guard.ts b/packages/core/src/markdown/unknown-mdast-guard.ts
index cd245c38c..c5bfd2386 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 a100cad76..1b75ba564 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/desktop/src/main/index.ts b/packages/desktop/src/main/index.ts
index 25fc204fa..31ae6b21f 100644
--- a/packages/desktop/src/main/index.ts
+++ b/packages/desktop/src/main/index.ts
@@ -48,11 +48,14 @@ import {
detectInstalledEditors,
EDITOR_TARGETS,
getOkArtifactPaths,
+ HOSTS_WITH_USER_SKILL_DIR,
+ isEntryUpToDate,
isOwnManagedEntry,
type McpInstallOptions,
type ProjectAiIntegrationsResult,
previewContent,
readExistingMcpEntry,
+ removeOwnMcpEntry,
removeUserGlobalSkillBundle,
runStop,
type TrackedRefusal,
@@ -180,6 +183,7 @@ import { ensureGitAvailable } from './git-preflight-handler.ts';
import { readCanonicalGitHubRemoteUrl } from './git-remote.ts';
import { formatInstanceAppName, resolveInstanceLabel } from './instance-identity.ts';
import { deriveInstanceUserDataDir } from './instance-isolation.ts';
+import { registerIntegrationsSettings } from './integrations-settings.ts';
import { handleBuildAndOpen, handleDetectClaudeDesktop } from './ipc/install-skill.ts';
import {
createLocalOpState,
@@ -225,6 +229,8 @@ import {
computePathLeg,
type EnsureCliOnPathResult,
ensureCliOnPath,
+ isPathShimInstalled,
+ removePathShimFromRcFiles,
} from './path-install.ts';
import { installStdioBrokenPipeGuard } from './process-safety-net.ts';
import {
@@ -3874,6 +3880,173 @@ function registerIpcHandlers() {
handle('ok:local-op:auth:repos', async (_event, request) => {
return handleAuthRepos(localOpDeps, request);
});
+
+ registerIntegrationsSettingsIpc();
+}
+
+/**
+ * Settings → AI tools: persistent status/toggle IPC over the same install
+ * actors as the first-launch consent dialog (`createMcpWiringOpts`) and the
+ * startup reclaim — `writeUserMcpConfigs` + surgical removal for editors,
+ * `ensureCliOnPath` / rc-block strip for the PATH shim, decision-gated
+ * reclaim + teardown for the user-global skill bundles. `available` mirrors
+ * the wiring gate set so the section renders read-only exactly where the
+ * consent dialog would refuse to arm.
+ */
+function registerIntegrationsSettingsIpc(): void {
+ const integrationsLogger = getLogger('integrations-settings');
+ const available =
+ process.env.OK_RECLAIM_DISABLE !== '1' &&
+ process.platform === 'darwin' &&
+ (app.isPackaged || process.env.OK_M6B_FORCE === '1') &&
+ /\.app\/Contents\/MacOS\/[^/]+$/.test(app.getPath('exe'));
+ const tildifyHomePath = (path: string): string => {
+ const home = osHomedir();
+ return path.startsWith(`${home}/`) ? `~${path.slice(home.length)}` : path;
+ };
+ registerIntegrationsSettings({
+ home: osHomedir(),
+ available,
+ ipcMain,
+ cli: {
+ allEditorIds: ALL_EDITOR_IDS,
+ editorLabel: (editorId) => EDITOR_TARGETS[editorId].label,
+ detectInstalledEditors: (cwd, home) => detectInstalledEditors(cwd, home),
+ classifyExistingMcpEntry: (editorId, home) =>
+ classifyExistingMcpEntry(EDITOR_TARGETS[editorId], '', home),
+ // The removal gate: `isEntryUpToDate` recognizes both the resolver-chain
+ // and OpenCode shapes via the version sentinel; `isOwnManagedEntry` is
+ // the exact canonical match. Same predicate `removeOwnMcpEntry` applies
+ // internally, so a row shown as 'installed' is always removable.
+ isOwnEntry: (entry) => isEntryUpToDate(entry) || isOwnManagedEntry(entry),
+ editorConfigPath: (editorId) => {
+ try {
+ return tildifyHomePath(EDITOR_TARGETS[editorId].configPath('', osHomedir()));
+ } catch {
+ // Platform-mismatched resolver (e.g. Claude Desktop off-macOS).
+ return null;
+ }
+ },
+ editorEntryLocator: (editorId) => {
+ const target = EDITOR_TARGETS[editorId];
+ const server = target.serverName('');
+ return target.format === 'toml'
+ ? `[${target.topLevelKey}.${server}]`
+ : [target.topLevelKey, target.serverMapSubKey, server].filter(Boolean).join('.');
+ },
+ writeUserMcpConfigs: (writeOpts) => writeUserMcpConfigs(writeOpts),
+ removeUserMcpEntry: (editorId) =>
+ removeOwnMcpEntry(EDITOR_TARGETS[editorId], '', osHomedir()),
+ },
+ path: {
+ computeStatus: () => {
+ const descriptor = computePathInstallDescriptor({
+ home: osHomedir(),
+ env: process.env,
+ logger: pathInstallLogger,
+ });
+ return {
+ shellDetected: descriptor.shellDetected,
+ rcFilesToTouch: descriptor.rcFilesToTouch,
+ installed: isPathShimInstalled({
+ home: osHomedir(),
+ env: process.env,
+ logger: pathInstallLogger,
+ }),
+ };
+ },
+ install: async () => {
+ const result = await ensureCliOnPath({
+ ...buildEnsureCliOnPathOpts(),
+ consentDecision: { status: 'granted', at: new Date().toISOString() },
+ });
+ if (result.status === 'failed-all') return { ok: false as const, error: result.error };
+ if (result.status === 'skipped') {
+ return {
+ ok: false as const,
+ error: `PATH setup is unavailable in this build (${result.reason}).`,
+ };
+ }
+ return { ok: true as const };
+ },
+ uninstall: async () => {
+ const result = removePathShimFromRcFiles({
+ home: osHomedir(),
+ env: process.env,
+ logger: pathInstallLogger,
+ });
+ if (result.status === 'failed') return { ok: false as const, error: result.error };
+ return { ok: true as const };
+ },
+ },
+ skills: {
+ computeStatuses: () =>
+ USER_GLOBAL_BUNDLE_IDS.map((id) => {
+ const home = osHomedir();
+ const name = BUNDLE_SKILL_NAME[id];
+ return {
+ id,
+ name,
+ installed: existsSync(join(home, '.agents', 'skills', name)),
+ // Central copy always; per-host copies only where the host root
+ // exists (mirrors installUserBundleToHostDirs' skipped-host-absent).
+ paths: [
+ `~/.agents/skills/${name}`,
+ ...HOSTS_WITH_USER_SKILL_DIR.filter((h) => existsSync(join(home, h.hostDir))).map(
+ (h) => `~/${h.hostDir}/skills/${name}`,
+ ),
+ ],
+ };
+ }),
+ setEnabled: async (bundleId, enabled) => {
+ const home = osHomedir();
+ const id = USER_GLOBAL_BUNDLE_IDS.find((b) => b === bundleId);
+ if (!id) return { ok: false as const, error: 'Unknown skill.' };
+ const name = BUNDLE_SKILL_NAME[id];
+ // Decision first (the durable record every install actor gates on),
+ // then the disk effect — same order as the consent-dialog leg.
+ try {
+ await writeBundleDecision(home, name, enabled);
+ } catch (err) {
+ return {
+ ok: false as const,
+ error: `Couldn't save your preference for ${name}: ${formatUnknownError(err)}`,
+ };
+ }
+ if (!enabled) {
+ try {
+ removeUserGlobalSkillBundle(home, id);
+ } catch (err) {
+ return { ok: false as const, error: formatUnknownError(err) };
+ }
+ return { ok: true as const };
+ }
+ try {
+ const result = await reclaimUserSkillsOnLaunch(buildReclaimUserSkillsOpts());
+ if (result.status === 'skipped') {
+ return {
+ ok: false as const,
+ error: `Couldn't install ${name} (${result.reason}).`,
+ };
+ }
+ } catch (err) {
+ return { ok: false as const, error: formatUnknownError(err) };
+ }
+ // Verify by effect — the reclaim reports per-target entries, but the
+ // central-store dir is the definitive "installed" signal every other
+ // surface reads.
+ if (!existsSync(join(home, '.agents', 'skills', name))) {
+ return { ok: false as const, error: `Couldn't install ${name}.` };
+ }
+ return { ok: true as const };
+ },
+ },
+ logger: {
+ warn: (msg, ctx) => integrationsLogger.warn((ctx ?? {}) as Record<string, unknown>, msg),
+ error: (msg, ctx) => integrationsLogger.error((ctx ?? {}) as Record<string, unknown>, msg),
+ event: (payload) => integrationsLogger.info(payload, payload.event),
+ },
+ });
}
/**
diff --git a/packages/desktop/src/main/integrations-settings.test.ts b/packages/desktop/src/main/integrations-settings.test.ts
new file mode 100644
index 000000000..f6369a4d4
--- /dev/null
+++ b/packages/desktop/src/main/integrations-settings.test.ts
@@ -0,0 +1,434 @@
+import { describe, expect, test } from 'bun:test';
+import type { IpcMainInvokeEvent } from 'electron';
+import type {
+ IntegrationsSetRequest,
+ IntegrationsSetResult,
+ IntegrationsStatus,
+ McpWiringEditorId,
+} from '../shared/ipc-channels.ts';
+import {
+ classifyEditorState,
+ type IntegrationsCliSurface,
+ type IntegrationsPathSurface,
+ type IntegrationsSkillsSurface,
+ type RegisterIntegrationsSettingsOpts,
+ registerIntegrationsSettings,
+} from './integrations-settings.ts';
+import type { McpStatusMarker, McpWiringFsOps } from './mcp-wiring.ts';
+
+const HOME = '/test-home';
+const MARKER_PATH = `${HOME}/.ok/mcp-status.json`;
+
+/** In-memory FsOps for the mcp-status marker. */
+function memFs(initial: Record<string, string> = {}): McpWiringFsOps & {
+ files: Map<string, string>;
+} {
+ const files = new Map(Object.entries(initial));
+ return {
+ files,
+ existsSync: (path) => files.has(path),
+ readFileSync: (path) => {
+ const content = files.get(path);
+ if (content === undefined) throw new Error(`ENOENT: ${path}`);
+ return content;
+ },
+ writeFileSync: (path, content) => {
+ files.set(path, content);
+ },
+ mkdirSync: () => {},
+ renameSync: (oldPath, newPath) => {
+ const content = files.get(oldPath);
+ if (content === undefined) throw new Error(`ENOENT: ${oldPath}`);
+ files.set(newPath, content);
+ files.delete(oldPath);
+ },
+ unlinkSync: (path) => {
+ files.delete(path);
+ },
+ };
+}
+
+type Handler = (event: IpcMainInvokeEvent, ...args: unknown[]) => unknown;
+
+function fakeIpcMain() {
+ const handlers = new Map<string, Handler>();
+ return {
+ handlers,
+ handle: (channel: string, handler: Handler) => {
+ handlers.set(channel, handler);
+ },
+ removeHandler: (channel: string) => {
+ handlers.delete(channel);
+ },
+ };
+}
+
+const EVENT = { sender: { id: 1 } } as unknown as IpcMainInvokeEvent;
+
+const OWN_ENTRY = { own: true };
+const FOREIGN_ENTRY = { own: false };
+
+interface CliOverrides {
+ classifications?: Partial<
+ Record<McpWiringEditorId, ReturnType<IntegrationsCliSurface['classifyExistingMcpEntry']>>
+ >;
+ writeAction?: 'written' | 'overwritten' | 'failed' | 'declined';
+ writeError?: string;
+ removeKind?: 'removed' | 'not-present' | 'left-foreign' | 'declined';
+ detected?: McpWiringEditorId[];
+}
+
+function makeCli(overrides: CliOverrides = {}): IntegrationsCliSurface & {
+ writes: McpWiringEditorId[][];
+ removals: McpWiringEditorId[];
+} {
+ const writes: McpWiringEditorId[][] = [];
+ const removals: McpWiringEditorId[] = [];
+ return {
+ writes,
+ removals,
+ allEditorIds: ['claude', 'cursor'] as McpWiringEditorId[],
+ editorLabel: (id) => (id === 'claude' ? 'Claude' : 'Cursor'),
+ detectInstalledEditors: () => overrides.detected ?? (['claude'] as McpWiringEditorId[]),
+ classifyExistingMcpEntry: (id) =>
+ overrides.classifications?.[id] ?? { kind: 'no-entry' as const },
+ isOwnEntry: (entry) => entry === OWN_ENTRY,
+ editorConfigPath: (id) => `~/.${id}.json`,
+ editorEntryLocator: () => 'mcpServers.open-knowledge',
+ writeUserMcpConfigs: async (opts) => {
+ writes.push([...opts.editors]);
+ return opts.editors.map((editorId) => ({
+ editorId,
+ action: overrides.writeAction ?? ('written' as const),
+ error: overrides.writeError,
+ }));
+ },
+ removeUserMcpEntry: (id) => {
+ removals.push(id);
+ return { kind: overrides.removeKind ?? 'removed' };
+ },
+ };
+}
+
+function makePath(installed = false): IntegrationsPathSurface & { calls: string[] } {
+ const calls: string[] = [];
+ let isInstalled = installed;
+ return {
+ calls,
+ computeStatus: () => ({
+ shellDetected: true,
+ rcFilesToTouch: ['~/.zshrc'],
+ installed: isInstalled,
+ }),
+ install: async () => {
+ calls.push('install');
+ isInstalled = true;
+ return { ok: true };
+ },
+ uninstall: async () => {
+ calls.push('uninstall');
+ isInstalled = false;
+ return { ok: true };
+ },
+ };
+}
+
+function makeSkills(
+ installedIds: string[] = [],
+): IntegrationsSkillsSurface & { calls: Array<[string, boolean]> } {
+ const calls: Array<[string, boolean]> = [];
+ const installed = new Set(installedIds);
+ return {
+ calls,
+ computeStatuses: () => [
+ {
+ id: 'discovery',
+ name: 'open-knowledge-discovery',
+ installed: installed.has('discovery'),
+ paths: ['~/.agents/skills/open-knowledge-discovery'],
+ },
+ {
+ id: 'write-skill',
+ name: 'open-knowledge-write-skill',
+ installed: installed.has('write-skill'),
+ paths: ['~/.agents/skills/open-knowledge-write-skill'],
+ },
+ ],
+ setEnabled: async (bundleId, enabled) => {
+ calls.push([bundleId, enabled]);
+ if (enabled) installed.add(bundleId);
+ else installed.delete(bundleId);
+ return { ok: true };
+ },
+ };
+}
+
+function setup(overrides: Partial<RegisterIntegrationsSettingsOpts> = {}) {
+ const ipcMain = fakeIpcMain();
+ const cli = makeCli();
+ const path = makePath();
+ const skills = makeSkills();
+ const fs = memFs();
+ const handle = registerIntegrationsSettings({
+ home: HOME,
+ available: true,
+ ipcMain,
+ cli,
+ path,
+ skills,
+ fs,
+ now: () => new Date('2026-07-07T00:00:00.000Z'),
+ logger: { warn: () => {}, error: () => {}, event: () => {} },
+ ...overrides,
+ });
+ const dispatch = ipcMain.handlers.get('ok:integrations:dispatch');
+ if (!dispatch) throw new Error('dispatch handler not registered');
+ const status = () => dispatch(EVENT, { kind: 'status' }) as Promise<IntegrationsStatus>;
+ const set = (request: IntegrationsSetRequest) =>
+ dispatch(EVENT, { kind: 'set', ...request }) as Promise<IntegrationsSetResult>;
+ return { ipcMain, cli, path, skills, fs, handle, status, set };
+}
+
+describe('classifyEditorState', () => {
+ const isOwn = (entry: unknown) => entry === OWN_ENTRY;
+
+ test('maps every classification kind to its row state', () => {
+ expect(classifyEditorState({ kind: 'absent' }, isOwn)).toBe('not-installed');
+ expect(classifyEditorState({ kind: 'no-entry' }, isOwn)).toBe('not-installed');
+ expect(classifyEditorState({ kind: 'decline' }, isOwn)).toBe('unmanageable');
+ expect(classifyEditorState({ kind: 'present', entry: OWN_ENTRY }, isOwn)).toBe('installed');
+ expect(classifyEditorState({ kind: 'present', entry: FOREIGN_ENTRY }, isOwn)).toBe('foreign');
+ });
+});
+
+describe('ok:integrations:dispatch — status', () => {
+ test('returns per-editor state, detection, PATH and skill rows', async () => {
+ const { status } = setup({
+ cli: makeCli({
+ classifications: { claude: { kind: 'present', entry: OWN_ENTRY } },
+ detected: ['claude'] as McpWiringEditorId[],
+ }),
+ skills: makeSkills(['discovery']),
+ });
+ const snapshot = await status();
+ expect(snapshot.available).toBe(true);
+ expect(snapshot.editors).toEqual([
+ {
+ id: 'claude',
+ label: 'Claude',
+ detected: true,
+ state: 'installed',
+ configPath: '~/.claude.json',
+ entryLocator: 'mcpServers.open-knowledge',
+ },
+ {
+ id: 'cursor',
+ label: 'Cursor',
+ detected: false,
+ state: 'not-installed',
+ configPath: '~/.cursor.json',
+ entryLocator: 'mcpServers.open-knowledge',
+ },
+ ]);
+ expect(snapshot.path).toEqual({
+ shellDetected: true,
+ rcFilesToTouch: ['~/.zshrc'],
+ installed: false,
+ });
+ expect(snapshot.skills).toEqual([
+ {
+ id: 'discovery',
+ name: 'open-knowledge-discovery',
+ installed: true,
+ paths: ['~/.agents/skills/open-knowledge-discovery'],
+ },
+ {
+ id: 'write-skill',
+ name: 'open-knowledge-write-skill',
+ installed: false,
+ paths: ['~/.agents/skills/open-knowledge-write-skill'],
+ },
+ ]);
+ });
+
+ test('a throwing per-editor classify degrades that row to unmanageable, not the whole section', async () => {
+ const cli = makeCli();
+ cli.classifyExistingMcpEntry = (id) => {
+ if (id === 'claude') throw new Error('EACCES');
+ return { kind: 'no-entry' };
+ };
+ const { status } = setup({ cli });
+ const snapshot = await status();
+ expect(snapshot.editors[0]?.state).toBe('unmanageable');
+ expect(snapshot.editors[1]?.state).toBe('not-installed');
+ });
+
+ test('throwing path/skill surfaces degrade to hidden rows', async () => {
+ const path = makePath();
+ path.computeStatus = () => {
+ throw new Error('boom');
+ };
+ const skills = makeSkills();
+ skills.computeStatuses = () => {
+ throw new Error('boom');
+ };
+ const { status } = setup({ path, skills });
+ const snapshot = await status();
+ expect(snapshot.path).toEqual({ shellDetected: false, rcFilesToTouch: [], installed: false });
+ expect(snapshot.skills).toEqual([]);
+ });
+});
+
+describe('ok:integrations:dispatch — set editor', () => {
+ test('enable writes the one editor and returns ok with a fresh snapshot', async () => {
+ const cli = makeCli();
+ const { set } = setup({ cli });
+ const result = await set({ component: { kind: 'editor', id: 'claude' }, enabled: true });
+ expect(result.ok).toBe(true);
+ expect(cli.writes).toEqual([['claude']]);
+ });
+
+ test('disable removes the entry; a foreign entry is refused with the config untouched', async () => {
+ const cli = makeCli({ removeKind: 'left-foreign' });
+ const { set } = setup({ cli });
+ const result = await set({ component: { kind: 'editor', id: 'claude' }, enabled: false });
+ expect(result.ok).toBe(false);
+ if (!result.ok) expect(result.error).toContain("isn't one OpenKnowledge wrote");
+ expect(cli.removals).toEqual(['claude']);
+ });
+
+ test('a declined write surfaces the left-unchanged error', async () => {
+ const { set } = setup({ cli: makeCli({ writeAction: 'declined' }) });
+ const result = await set({ component: { kind: 'editor', id: 'cursor' }, enabled: true });
+ expect(result.ok).toBe(false);
+ if (!result.ok) expect(result.error).toContain("Couldn't safely edit Cursor's config");
+ });
+
+ test('a failed write surfaces its error', async () => {
+ const { set } = setup({ cli: makeCli({ writeAction: 'failed', writeError: 'EROFS' }) });
+ const result = await set({ component: { kind: 'editor', id: 'claude' }, enabled: true });
+ expect(result.ok).toBe(false);
+ if (!result.ok) expect(result.error).toContain('EROFS');
+ });
+
+ test('unknown editor id is refused', async () => {
+ const { set } = setup();
+ const result = await set({
+ component: { kind: 'editor', id: 'not-an-editor' as McpWiringEditorId },
+ enabled: true,
+ });
+ expect(result.ok).toBe(false);
+ });
+
+ test('an existing marker is refreshed to the installed set; an absent marker is never created', async () => {
+ const priorMarker: McpStatusMarker = {
+ configured: true,
+ configuredAt: '2026-01-01T00:00:00.000Z',
+ editors: ['claude'],
+ };
+ const markerFs = memFs({ [MARKER_PATH]: JSON.stringify(priorMarker) });
+ const withMarker = setup({
+ fs: markerFs,
+ cli: makeCli({
+ classifications: {
+ claude: { kind: 'present', entry: OWN_ENTRY },
+ cursor: { kind: 'present', entry: OWN_ENTRY },
+ },
+ }),
+ });
+ await withMarker.set({ component: { kind: 'editor', id: 'cursor' }, enabled: true });
+ const marker = JSON.parse(markerFs.files.get(MARKER_PATH) ?? 'null');
+ expect(marker.configured).toBe(true);
+ expect(marker.editors).toEqual(['claude', 'cursor']);
+ // Original decision timestamp is preserved.
+ expect(marker.configuredAt).toBe('2026-01-01T00:00:00.000Z');
+
+ const withoutMarker = setup();
+ await withoutMarker.set({ component: { kind: 'editor', id: 'claude' }, enabled: true });
+ expect(withoutMarker.fs.files.has(MARKER_PATH)).toBe(false);
+ });
+});
+
+describe('ok:integrations:dispatch — set path / skill', () => {
+ test('path toggles route to install/uninstall and the snapshot reflects the new state', async () => {
+ const path = makePath(false);
+ const { set } = setup({ path });
+ const enabled = await set({ component: { kind: 'path' }, enabled: true });
+ expect(enabled.ok).toBe(true);
+ expect(enabled.status.path.installed).toBe(true);
+ const disabled = await set({ component: { kind: 'path' }, enabled: false });
+ expect(disabled.ok).toBe(true);
+ expect(disabled.status.path.installed).toBe(false);
+ expect(path.calls).toEqual(['install', 'uninstall']);
+ });
+
+ test('skill toggles route with the enabled flag; unknown ids are refused', async () => {
+ const skills = makeSkills(['discovery']);
+ const { set } = setup({ skills });
+ const off = await set({ component: { kind: 'skill', id: 'discovery' }, enabled: false });
+ expect(off.ok).toBe(true);
+ expect(off.status.skills.find((s) => s.id === 'discovery')?.installed).toBe(false);
+ expect(skills.calls).toEqual([['discovery', false]]);
+
+ const unknown = await set({ component: { kind: 'skill', id: 'nope' }, enabled: true });
+ expect(unknown.ok).toBe(false);
+ });
+});
+
+describe('ok:integrations:dispatch — gates and serialization', () => {
+ test('available: false refuses mutations but still reports status', async () => {
+ const cli = makeCli();
+ const { set, status } = setup({ available: false, cli });
+ const snapshot = await status();
+ expect(snapshot.available).toBe(false);
+ const result = await set({ component: { kind: 'editor', id: 'claude' }, enabled: true });
+ expect(result.ok).toBe(false);
+ expect(cli.writes).toEqual([]);
+ });
+
+ test('concurrent mutations serialize in arrival order', async () => {
+ const order: string[] = [];
+ const path = makePath();
+ let releaseFirst: () => void = () => {};
+ path.install = async () => {
+ order.push('install-start');
+ await new Promise<void>((resolve) => {
+ releaseFirst = resolve;
+ });
+ order.push('install-end');
+ return { ok: true };
+ };
+ path.uninstall = async () => {
+ order.push('uninstall');
+ return { ok: true };
+ };
+ const { set } = setup({ path });
+ const first = set({ component: { kind: 'path' }, enabled: true });
+ const second = set({ component: { kind: 'path' }, enabled: false });
+ // Give the first mutation a tick to start, then release it.
+ await new Promise((resolve) => setTimeout(resolve, 10));
+ releaseFirst();
+ await Promise.all([first, second]);
+ expect(order).toEqual(['install-start', 'install-end', 'uninstall']);
+ });
+
+ test('a failed mutation still leaves the chain usable for the next one', async () => {
+ const path = makePath();
+ path.install = async () => {
+ throw new Error('boom');
+ };
+ const { set } = setup({ path });
+ const failed = await set({ component: { kind: 'path' }, enabled: true });
+ expect(failed.ok).toBe(false);
+ const next = await set({ component: { kind: 'path' }, enabled: false });
+ expect(next.ok).toBe(true);
+ });
+
+ test('destroy removes the handler; a second destroy is a no-op', () => {
+ const { ipcMain, handle } = setup();
+ expect(ipcMain.handlers.has('ok:integrations:dispatch')).toBe(true);
+ handle.destroy();
+ expect(ipcMain.handlers.has('ok:integrations:dispatch')).toBe(false);
+ handle.destroy();
+ });
+});
diff --git a/packages/desktop/src/main/integrations-settings.ts b/packages/desktop/src/main/integrations-settings.ts
new file mode 100644
index 000000000..0779e73dc
--- /dev/null
+++ b/packages/desktop/src/main/integrations-settings.ts
@@ -0,0 +1,368 @@
+/**
+ * Settings → AI tools — persistent IPC surface for per-component
+ * install/uninstall of OpenKnowledge's GLOBAL footprint: per-editor user-scope
+ * MCP entries, the shell-PATH shim, and the user-global skill bundles.
+ *
+ * Sibling of the one-shot first-launch consent flow (`mcp-wiring.ts`): the
+ * dialog solicits a batched decision once; this surface reflects live state
+ * (checked = actually installed) and applies one component per invoke, for the
+ * lifetime of the app. Same install actors underneath — `writeUserMcpConfigs`,
+ * `ensureCliOnPath`, the decision-gated skill reclaim — so the two surfaces
+ * can never disagree about what an install means.
+ *
+ * Mutations serialize through a promise-chain mutex: two windows toggling
+ * concurrently (or a rage-click) queue rather than interleave partial writes
+ * on the same config file.
+ *
+ * Electron-free, dependency-injected (mirrors `mcp-wiring.ts`) so bun-test
+ * loads it without an Electron runtime; `main/index.ts` wires the real
+ * surfaces in.
+ */
+
+import type { IpcMain } from 'electron';
+import type {
+ IntegrationsComponentRef,
+ IntegrationsEditorState,
+ IntegrationsEditorStatus,
+ IntegrationsPathStatus,
+ IntegrationsSetRequest,
+ IntegrationsSetResult,
+ IntegrationsSkillStatus,
+ IntegrationsStatus,
+ McpWiringEditorId,
+} from '../shared/ipc-channels.ts';
+import { createHandler } from '../shared/ipc-handler.ts';
+import { logIpcError } from './ipc-log.ts';
+import {
+ type McpStatusMarker,
+ type McpWiringFsOps,
+ readMcpStatusMarker,
+ writeMcpStatusMarker,
+} from './mcp-wiring.ts';
+
+/** Per-editor removal outcome — mirrors the CLI's `McpRemoveOutcome` kinds so
+ * the injected surface can pass the CLI result straight through. */
+interface IntegrationsRemoveOutcome {
+ kind: 'removed' | 'not-present' | 'left-foreign' | 'declined';
+}
+
+/** CLI-side surface (backed by `@inkeep/open-knowledge`). */
+export interface IntegrationsCliSurface {
+ allEditorIds: readonly McpWiringEditorId[];
+ editorLabel(editorId: McpWiringEditorId): string;
+ detectInstalledEditors(cwd: string, home?: string): McpWiringEditorId[];
+ /** Discriminated read of the editor's user config — never throws for the
+ * expected absent/no-entry/decline cases. */
+ classifyExistingMcpEntry(
+ editorId: McpWiringEditorId,
+ home: string,
+ ): { kind: 'absent' | 'no-entry' | 'decline' } | { kind: 'present'; entry: unknown };
+ /** True when `entry` is recognizably OK's OWN managed entry (the only
+ * shape uninstall will delete). */
+ isOwnEntry(entry: unknown): boolean;
+ /** Tildified user-config path for the row's disclosure tooltip; null when
+ * the resolver can't produce one on this platform. */
+ editorConfigPath(editorId: McpWiringEditorId): string | null;
+ /** Technical locator of OK's entry inside the config (json dotted path or
+ * toml table header) — disclosure only. */
+ editorEntryLocator(editorId: McpWiringEditorId): string;
+ writeUserMcpConfigs(opts: { editors: McpWiringEditorId[]; home?: string }): Promise<
+ Array<{
+ editorId: McpWiringEditorId;
+ action:
+ | 'written'
+ | 'overwritten'
+ | 'skipped-missing'
+ | 'skipped-flag'
+ | 'failed'
+ | 'declined';
+ error?: string;
+ }>
+ >;
+ removeUserMcpEntry(editorId: McpWiringEditorId): IntegrationsRemoveOutcome;
+}
+
+/** PATH-shim surface (backed by `path-install.ts`). */
+export interface IntegrationsPathSurface {
+ computeStatus(): IntegrationsPathStatus;
+ install(): Promise<{ ok: true } | { ok: false; error: string }>;
+ uninstall(): Promise<{ ok: true } | { ok: false; error: string }>;
+}
+
+/** User-global skills surface (backed by skill-state + skill-reclaim). */
+export interface IntegrationsSkillsSurface {
+ computeStatuses(): IntegrationsSkillStatus[];
+ setEnabled(
+ bundleId: string,
+ enabled: boolean,
+ ): Promise<{ ok: true } | { ok: false; error: string }>;
+}
+
+interface IntegrationsLogger {
+ warn(msg: string, ctx?: object): void;
+ error(msg: string, ctx?: object): void;
+ event(payload: { event: string; [k: string]: unknown }): void;
+}
+
+const DEFAULT_LOGGER: IntegrationsLogger = {
+ warn: (msg, ctx) => console.warn('[integrations-settings]', msg, ctx ?? ''),
+ error: (msg, ctx) => console.error('[integrations-settings]', msg, ctx ?? ''),
+ event: (payload) => console.warn(JSON.stringify(payload)),
+};
+
+interface IpcMainLike extends Pick<IpcMain, 'handle' | 'removeHandler'> {}
+
+export interface RegisterIntegrationsSettingsOpts {
+ home: string;
+ /** Same gate set as the consent dialog / startup reclaim (darwin, packaged
+ * or OK_M6B_FORCE, `.app` executable shape). False renders the section
+ * read-only: status still computes, mutations refuse. */
+ available: boolean;
+ ipcMain: IpcMainLike;
+ cli: IntegrationsCliSurface;
+ path: IntegrationsPathSurface;
+ skills: IntegrationsSkillsSurface;
+ fs?: McpWiringFsOps;
+ now?: () => Date;
+ logger?: IntegrationsLogger;
+}
+
+export interface IntegrationsSettingsHandle {
+ destroy(): void;
+}
+
+/** Map one editor's config classification to the Settings row state. */
+export function classifyEditorState(
+ classification: ReturnType<IntegrationsCliSurface['classifyExistingMcpEntry']>,
+ isOwnEntry: (entry: unknown) => boolean,
+): IntegrationsEditorState {
+ switch (classification.kind) {
+ case 'absent':
+ case 'no-entry':
+ return 'not-installed';
+ case 'decline':
+ return 'unmanageable';
+ case 'present':
+ return isOwnEntry(classification.entry) ? 'installed' : 'foreign';
+ }
+}
+
+export function registerIntegrationsSettings(
+ opts: RegisterIntegrationsSettingsOpts,
+): IntegrationsSettingsHandle {
+ const { home, available, ipcMain, cli, path, skills, fs, now, logger = DEFAULT_LOGGER } = opts;
+ const nowDate = (): Date => (now ? now() : new Date());
+
+ function computeEditorStatuses(): IntegrationsEditorStatus[] {
+ let detected: Set<McpWiringEditorId>;
+ try {
+ detected = new Set(cli.detectInstalledEditors('', home));
+ } catch {
+ detected = new Set();
+ }
+ return cli.allEditorIds.map((id) => {
+ let state: IntegrationsEditorState;
+ try {
+ state = classifyEditorState(cli.classifyExistingMcpEntry(id, home), cli.isOwnEntry);
+ } catch (err) {
+ // A throwing read (platform-mismatched config resolver, EACCES) must
+ // not take the whole section down — surface the row as unmanageable.
+ logger.warn('editor classify failed', {
+ id,
+ error: err instanceof Error ? err.message : String(err),
+ });
+ state = 'unmanageable';
+ }
+ return {
+ id,
+ label: cli.editorLabel(id),
+ detected: detected.has(id),
+ state,
+ configPath: cli.editorConfigPath(id),
+ entryLocator: cli.editorEntryLocator(id),
+ };
+ });
+ }
+
+ function computeStatus(): IntegrationsStatus {
+ let pathStatus: IntegrationsPathStatus;
+ try {
+ pathStatus = path.computeStatus();
+ } catch (err) {
+ logger.warn('path status failed', {
+ error: err instanceof Error ? err.message : String(err),
+ });
+ pathStatus = { shellDetected: false, rcFilesToTouch: [], installed: false };
+ }
+ let skillStatuses: IntegrationsSkillStatus[];
+ try {
+ skillStatuses = skills.computeStatuses();
+ } catch (err) {
+ logger.warn('skill statuses failed', {
+ error: err instanceof Error ? err.message : String(err),
+ });
+ skillStatuses = [];
+ }
+ return { available, editors: computeEditorStatuses(), path: pathStatus, skills: skillStatuses };
+ }
+
+ /**
+ * Keep the first-launch marker's editor list truthful after a
+ * settings-driven toggle. Only when a marker already EXISTS — its absence
+ * means "no prior decision", which must keep firing the first-launch
+ * dialog; a settings toggle on a marker-less install (possible only when
+ * the consent dialog never delivered) doesn't claim that decision.
+ */
+ function refreshMarkerEditors(): void {
+ const marker = readMcpStatusMarker(home, fs);
+ if (marker === null) return;
+ const installed = computeEditorStatuses()
+ .filter((e) => e.state === 'installed')
+ .map((e) => e.id);
+ const next: McpStatusMarker = {
+ configured: true,
+ configuredAt: marker.configured === true ? marker.configuredAt : nowDate().toISOString(),
+ editors: installed,
+ };
+ try {
+ writeMcpStatusMarker(home, next, fs);
+ } catch (err) {
+ // Bookkeeping only — the entry write itself already succeeded, and the
+ // startup repair scans configs directly rather than trusting the list.
+ logger.warn('marker refresh failed', {
+ error: err instanceof Error ? err.message : String(err),
+ });
+ }
+ }
+
+ async function setEditor(
+ id: McpWiringEditorId,
+ enabled: boolean,
+ ): Promise<{ ok: true } | { ok: false; error: string }> {
+ const label = cli.editorLabel(id);
+ if (enabled) {
+ let results: Awaited<ReturnType<IntegrationsCliSurface['writeUserMcpConfigs']>>;
+ try {
+ results = await cli.writeUserMcpConfigs({ editors: [id], home });
+ } catch (err) {
+ return { ok: false, error: err instanceof Error ? err.message : String(err) };
+ }
+ const result = results.find((r) => r.editorId === id);
+ if (!result) return { ok: false, error: `No write result for ${label}.` };
+ switch (result.action) {
+ case 'written':
+ case 'overwritten':
+ refreshMarkerEditors();
+ logger.event({ event: 'integrations-editor-installed', editor: id });
+ return { ok: true };
+ case 'declined':
+ return {
+ ok: false,
+ error: `Couldn't safely edit ${label}'s config — it was left unchanged.`,
+ };
+ default:
+ return {
+ ok: false,
+ error: `Couldn't add OpenKnowledge to ${label}${result.error ? ` (${result.error})` : ''}.`,
+ };
+ }
+ }
+ let outcome: IntegrationsRemoveOutcome;
+ try {
+ outcome = cli.removeUserMcpEntry(id);
+ } catch (err) {
+ return { ok: false, error: err instanceof Error ? err.message : String(err) };
+ }
+ switch (outcome.kind) {
+ case 'removed':
+ case 'not-present':
+ refreshMarkerEditors();
+ logger.event({ event: 'integrations-editor-removed', editor: id, outcome: outcome.kind });
+ return { ok: true };
+ case 'left-foreign':
+ return {
+ ok: false,
+ error: `The open-knowledge entry in ${label} isn't one OpenKnowledge wrote — it was left unchanged. Remove it manually if you no longer want it.`,
+ };
+ case 'declined':
+ return {
+ ok: false,
+ error: `Couldn't safely edit ${label}'s config — it was left unchanged.`,
+ };
+ }
+ }
+
+ async function applyComponent(
+ request: IntegrationsSetRequest,
+ ): Promise<{ ok: true } | { ok: false; error: string }> {
+ if (!available) {
+ return { ok: false, error: 'Managing AI tools is unavailable in this build.' };
+ }
+ const component = request?.component as IntegrationsComponentRef | undefined;
+ const enabled = request?.enabled === true;
+ if (component?.kind === 'editor') {
+ if (!cli.allEditorIds.includes(component.id)) {
+ return { ok: false, error: 'Unknown editor.' };
+ }
+ return setEditor(component.id, enabled);
+ }
+ if (component?.kind === 'path') {
+ return enabled ? path.install() : path.uninstall();
+ }
+ if (component?.kind === 'skill') {
+ const known = skills.computeStatuses().some((s) => s.id === component.id);
+ if (!known) return { ok: false, error: 'Unknown skill.' };
+ return skills.setEnabled(component.id, enabled);
+ }
+ return { ok: false, error: 'Unknown component.' };
+ }
+
+ // Promise-chain mutex: mutations run strictly one at a time, in arrival
+ // order. Failures don't break the chain (each link swallows into a result).
+ let mutationChain: Promise<unknown> = Promise.resolve();
+
+ function dispatchSet(request: IntegrationsSetRequest): Promise<IntegrationsSetResult> {
+ const run = mutationChain.then(async (): Promise<IntegrationsSetResult> => {
+ let result: { ok: true } | { ok: false; error: string };
+ try {
+ result = await applyComponent(request);
+ } catch (err) {
+ result = { ok: false, error: err instanceof Error ? err.message : String(err) };
+ }
+ if (!result.ok) {
+ logIpcError({
+ event: 'ipc.error',
+ channel: 'ok:integrations:dispatch',
+ reason: 'set-component-refused',
+ handler: 'integrationsDispatch',
+ cause: { component: request?.component?.kind ?? 'unknown', error: result.error },
+ });
+ return { ok: false, error: result.error, status: computeStatus() };
+ }
+ return { ok: true, status: computeStatus() };
+ });
+ mutationChain = run.catch(() => {});
+ return run;
+ }
+
+ const register = createHandler(ipcMain as IpcMain);
+ register('ok:integrations:dispatch', async (_event, request) => {
+ if (request?.kind === 'set') return dispatchSet(request);
+ return computeStatus();
+ });
+
+ let destroyed = false;
+ return {
+ destroy(): void {
+ if (destroyed) return;
+ destroyed = true;
+ try {
+ ipcMain.removeHandler('ok:integrations:dispatch');
+ } catch (err) {
+ logger.warn('removeHandler(ok:integrations:dispatch) threw', {
+ message: err instanceof Error ? err.message : String(err),
+ });
+ }
+ },
+ };
+}
diff --git a/packages/desktop/src/main/path-install.test.ts b/packages/desktop/src/main/path-install.test.ts
index 5dcc9cf54..398f9a5c9 100644
--- a/packages/desktop/src/main/path-install.test.ts
+++ b/packages/desktop/src/main/path-install.test.ts
@@ -17,7 +17,9 @@ import {
computePathLeg,
type EnsureCliOnPathResult,
ensureCliOnPath,
+ isPathShimInstalled,
pathInstallMarkerPath,
+ removePathShimFromRcFiles,
} from './path-install.ts';
const EXE = '/Applications/OpenKnowledge.app/Contents/MacOS/OpenKnowledge';
@@ -441,11 +443,12 @@ describe('computePathInstallDescriptor', () => {
expect(descriptor.shellDetected).toBe(true);
});
- test('granted consent without a block (user manages PATH themselves) still reads alreadyInstalled', async () => {
+ test('an explicit grant writes the promised block even when ~/.ok/bin is already on the discovered PATH', async () => {
const h = home();
- // Grant while `~/.ok/bin` is already on the discovered PATH after an
- // undecided boot → canSkipRc leaves every rc file untouched, but the
- // decision is recorded. The row must not re-solicit.
+ // The probe PATH can be stale-true (inherited from a terminal session
+ // that predates an uninstall) and the consent surface named the exact
+ // file it would edit — so an explicit grant always writes. Only the
+ // undecided startup self-heal uses the on-PATH shortcut.
await ensureCliOnPath(baseOpts(h));
await ensureCliOnPath(
baseOpts(h, {
@@ -453,7 +456,7 @@ describe('computePathInstallDescriptor', () => {
spawn: async () => ({ code: 0, stdout: `${h}/.ok/bin:/usr/bin`, stderr: '' }),
}),
);
- expect(existsSync(join(h, '.zshrc'))).toBe(false);
+ expect(readFileSync(join(h, '.zshrc'), 'utf8')).toContain('# >>> open-knowledge cli >>>');
const descriptor = computePathInstallDescriptor({ home: h, env: { SHELL: '/bin/zsh' } });
expect(descriptor.alreadyInstalled).toBe(true);
});
@@ -498,3 +501,107 @@ describe('computePathLeg', () => {
expect(computePathLeg({ status: 'healthy-current', marker })).toEqual({ status: 'none' });
});
});
+
+describe('isPathShimInstalled / removePathShimFromRcFiles — the Settings → AI tools PATH toggle', () => {
+ test('grant → installed reads true; remove strips every block, deletes the OK-owned fish conf, and records declined', async () => {
+ const h = home();
+ writeFileSync(join(h, '.zshrc'), 'export FOO=1\n');
+ await ensureCliOnPath(baseOpts(h, { consentDecision: GRANTED }));
+ const env = { SHELL: '/bin/zsh' };
+ expect(isPathShimInstalled({ home: h, env })).toBe(true);
+
+ const result = removePathShimFromRcFiles({ home: h, env });
+ expect(result.status).toBe('removed');
+ // The user's own lines survive; only the managed block is gone.
+ expect(readFileSync(join(h, '.zshrc'), 'utf8')).not.toContain('# >>> open-knowledge cli >>>');
+ expect(readFileSync(join(h, '.zshrc'), 'utf8')).toContain('export FOO=1');
+ // The fish conf file held nothing but the block — removed outright.
+ expect(existsSync(join(h, '.config', 'fish', 'conf.d', 'open-knowledge.fish'))).toBe(false);
+ const marker = readMarkerFile(h);
+ expect(marker.rcFiles).toEqual([]);
+ expect((marker.consent as { status: string }).status).toBe('declined');
+ // NOT recorded as user opt-outs — a Settings re-install must still work.
+ expect(marker.rcOptOuts).toEqual([]);
+ expect(isPathShimInstalled({ home: h, env })).toBe(false);
+ });
+
+ test('startup after a Settings removal never re-appends; a Settings re-install does', async () => {
+ const h = home();
+ writeFileSync(join(h, '.zshrc'), 'export FOO=1\n');
+ await ensureCliOnPath(baseOpts(h, { consentDecision: GRANTED }));
+ removePathShimFromRcFiles({ home: h, env: { SHELL: '/bin/zsh' } });
+
+ // Undecided startup run: recorded decline wins — rc files stay clean.
+ await ensureCliOnPath(baseOpts(h));
+ expect(readFileSync(join(h, '.zshrc'), 'utf8')).not.toContain('# >>> open-knowledge cli >>>');
+
+ // Settings re-install: a fresh grant re-appends (no opt-out poisoning).
+ const regrant = await ensureCliOnPath(baseOpts(h, { consentDecision: GRANTED }));
+ expect(regrant.status).toBe('installed');
+ expect(readFileSync(join(h, '.zshrc'), 'utf8')).toContain('# >>> open-knowledge cli >>>');
+ expect(isPathShimInstalled({ home: h, env: { SHELL: '/bin/zsh' } })).toBe(true);
+ });
+
+ test('re-grant works even when the probe shell inherits a stale PATH containing ~/.ok/bin', async () => {
+ // The app launched from a terminal whose session predates the uninstall
+ // still exports ~/.ok/bin; the login-shell probe inherits it. The
+ // canSkipRc shortcut must not swallow the explicit grant.
+ const h = home();
+ writeFileSync(join(h, '.zshrc'), 'export FOO=1\n');
+ const stalePathSpawn = async () => ({
+ code: 0,
+ stdout: `${join(h, '.ok', 'bin')}:/usr/bin:/bin`,
+ stderr: '',
+ });
+ await ensureCliOnPath(baseOpts(h, { consentDecision: GRANTED, spawn: stalePathSpawn }));
+ removePathShimFromRcFiles({ home: h, env: { SHELL: '/bin/zsh' } });
+
+ const regrant = await ensureCliOnPath(
+ baseOpts(h, { consentDecision: GRANTED, spawn: stalePathSpawn }),
+ );
+ expect(regrant.status).toBe('installed');
+ expect(readFileSync(join(h, '.zshrc'), 'utf8')).toContain('# >>> open-knowledge cli >>>');
+ expect(isPathShimInstalled({ home: h, env: { SHELL: '/bin/zsh' } })).toBe(true);
+ });
+
+ test('a wedged granted-but-blockless marker heals on the next explicit grant', async () => {
+ // State left behind by the pre-fix lockout: consent recorded granted,
+ // rcFiles empty, no block on disk. The healthy-current fast path is
+ // vacuously true for it; an explicit grant must still write the block.
+ const h = home();
+ writeFileSync(join(h, '.zshrc'), 'export FOO=1\n');
+ await ensureCliOnPath(baseOpts(h, { consentDecision: GRANTED }));
+ removePathShimFromRcFiles({ home: h, env: { SHELL: '/bin/zsh' } });
+ const marker = readMarkerFile(h);
+ writeFileSync(
+ pathInstallMarkerPath(h),
+ JSON.stringify({ ...marker, rcFiles: [], consent: GRANTED }, null, 2),
+ );
+
+ const regrant = await ensureCliOnPath(baseOpts(h, { consentDecision: GRANTED }));
+ expect(regrant.status).toBe('installed');
+ expect(readFileSync(join(h, '.zshrc'), 'utf8')).toContain('# >>> open-knowledge cli >>>');
+ });
+
+ test('nothing installed and no marker → not-installed no-op', () => {
+ const h = home();
+ const result = removePathShimFromRcFiles({ home: h, env: { SHELL: '/bin/zsh' } });
+ expect(result.status).toBe('not-installed');
+ expect(existsSync(pathInstallMarkerPath(h))).toBe(false);
+ });
+
+ test('a doubled managed block (dotfile-sync merge) comes out fully clean', async () => {
+ const h = home();
+ await ensureCliOnPath(baseOpts(h, { consentDecision: GRANTED }));
+ const zshrc = join(h, '.zshrc');
+ const withBlock = readFileSync(zshrc, 'utf8');
+ const block = withBlock.slice(
+ withBlock.indexOf('# >>> open-knowledge cli >>>'),
+ withBlock.indexOf('# <<< open-knowledge cli <<<') + '# <<< open-knowledge cli <<<\n'.length,
+ );
+ writeFileSync(zshrc, `${withBlock}\n${block}`);
+ const result = removePathShimFromRcFiles({ home: h, env: { SHELL: '/bin/zsh' } });
+ expect(result.status).toBe('removed');
+ expect(readFileSync(zshrc, 'utf8')).not.toContain('open-knowledge cli');
+ });
+});
diff --git a/packages/desktop/src/main/path-install.ts b/packages/desktop/src/main/path-install.ts
index 74119947a..f7fb412f1 100644
--- a/packages/desktop/src/main/path-install.ts
+++ b/packages/desktop/src/main/path-install.ts
@@ -467,13 +467,17 @@ export async function ensureCliOnPath(opts: EnsureCliOnPathOpts): Promise<Ensure
const wrapper = wrapperPathInBundle(executablePath);
const prior = readMarker(home, fs, logger);
- // A caller-supplied decision that CHANGES the recorded consent must reach
- // the full install path — the fast-path below would otherwise swallow a
- // dialog grant on a marker that is healthy-but-blockless (fresh boot wrote
- // symlinks + shim, rcFiles empty, consent undecided).
- const consentUnchanged =
- opts.consentDecision === undefined || prior?.consent?.status === opts.consentDecision.status;
- if (prior && consentUnchanged && markerHealthy(prior, home, wrapper, fs, logger)) {
+ // ANY caller-supplied decision must reach the full install path. The
+ // fast-path below would otherwise swallow a grant on a marker that is
+ // healthy-but-blockless: `markerHealthy` is vacuously true when `rcFiles`
+ // is empty (fresh boot wrote only symlinks + shim; or a Settings uninstall
+ // stripped the blocks and recorded declined), so a same-status re-grant
+ // (granted → granted after a partial write) or a declined → granted flip
+ // from the Settings checkbox would return healthy-current without ever
+ // appending a block. The full path is idempotent, so an explicit decision
+ // re-running it is safe.
+ const explicitDecision = opts.consentDecision !== undefined;
+ if (prior && !explicitDecision && markerHealthy(prior, home, wrapper, fs, logger)) {
// Grandfather stamp: a pre-consent marker whose recorded rc files
// all still carry the managed block — markerHealthy just verified them —
// is a working silent-era install. Record it as granted so the decision
@@ -549,7 +553,15 @@ export async function ensureCliOnPath(opts: EnsureCliOnPathOpts): Promise<Ensure
(target) => !rcOptOuts.includes(target.path),
);
const activePriorRcFiles = (prior?.rcFiles ?? []).filter((file) => !rcOptOuts.includes(file));
+ // An explicit grant must never take this shortcut: after a Settings
+ // uninstall `rcFiles` is empty (vacuously "all healthy") and
+ // `okBinAlreadyOnPath` is often stale-true — the probe shell INHERITS the
+ // app's PATH, which still carries `~/.ok/bin` when the app was launched
+ // from a terminal whose session predates the uninstall. Skipping here
+ // would record the grant while writing no block, wedging the checkbox.
+ const explicitGrant = opts.consentDecision?.status === 'granted';
const canSkipRc =
+ !explicitGrant &&
prior != null &&
discovery?.okBinAlreadyOnPath === true &&
activePriorRcFiles.every((file) => rcBlockHealthy(file, fs));
@@ -676,3 +688,108 @@ export function computePathInstallDescriptor(opts: {
alreadyInstalled: blockPresent || marker?.consent?.status === 'granted',
};
}
+
+/**
+ * Settings-surface probe: is the managed rc block actually on disk? Distinct
+ * from `computePathInstallDescriptor().alreadyInstalled`, which also reads
+ * true on a recorded grant with no block — the Settings checkbox reflects the
+ * real effect (block present ⇒ `ok` resolves in external terminals), so a
+ * failed or reverted grant renders unchecked and stays re-installable.
+ */
+export function isPathShimInstalled(opts: {
+ home: string;
+ env?: Record<string, string | undefined>;
+ fs?: PathInstallFsOps;
+ logger?: PathInstallLogger;
+}): boolean {
+ const { home, fs = defaultFsOps, logger = DEFAULT_LOGGER } = opts;
+ const marker = readMarker(home, fs, logger);
+ const candidates = new Set<string>([
+ ...rcTargets(home, (opts.env ?? process.env).SHELL, fs).map((target) => target.path),
+ ...(marker?.rcFiles ?? []),
+ ]);
+ return [...candidates].some((path) => rcBlockHealthy(path, fs));
+}
+
+export type RemovePathShimResult =
+ | { status: 'removed'; strippedFiles: string[] }
+ | { status: 'not-installed' }
+ | { status: 'failed'; error: string };
+
+/**
+ * Settings-surface uninstall — the inverse of the consent-granted rc append.
+ * Strips the managed block from every candidate rc file (recorded
+ * `marker.rcFiles` plus the current shell targets), deletes the OK-owned fish
+ * conf file outright when nothing but the block was in it, and records
+ * `consent: declined` with `rcFiles: []` so the startup self-heal never
+ * re-appends.
+ *
+ * Deliberately narrower than `ok uninstall`: `~/.ok/bin` and `~/.ok/env.sh`
+ * stay — the built-in terminal injects `~/.ok/bin` itself and MCP wiring runs
+ * over npx, so only the EXTERNAL-terminal footprint (the rc blocks) is
+ * removed. Stripped files are NOT added to `rcOptOuts` — that list means "the
+ * USER removed the block, never write there again", and recording an
+ * OK-initiated removal there would break a later re-install from the same
+ * Settings checkbox.
+ */
+export function removePathShimFromRcFiles(opts: {
+ home: string;
+ env?: Record<string, string | undefined>;
+ fs?: PathInstallFsOps;
+ logger?: PathInstallLogger;
+ now?: () => Date;
+}): RemovePathShimResult {
+ const { home, fs = defaultFsOps, logger = DEFAULT_LOGGER } = opts;
+ const marker = readMarker(home, fs, logger);
+ const candidates = new Set<string>([
+ ...rcTargets(home, (opts.env ?? process.env).SHELL, fs).map((target) => target.path),
+ ...(marker?.rcFiles ?? []),
+ ]);
+ const okOwnedFishConf = join(home, '.config', 'fish', 'conf.d', 'open-knowledge.fish');
+ const strippedFiles: string[] = [];
+ try {
+ for (const path of candidates) {
+ if (!fs.existsSync(path)) continue;
+ const prior = fs.readFileSync(path, 'utf8');
+ // Loop: a file that somehow accumulated multiple managed blocks (rc
+ // concatenation, dotfile sync merge) must come out fully clean.
+ let next = prior;
+ while (BLOCK_RE.test(next)) next = next.replace(BLOCK_RE, '');
+ if (next === prior) continue;
+ if (next.trim() === '' && path === okOwnedFishConf) {
+ // The whole file was the managed block (OK created it) — remove the
+ // file rather than leave an empty husk behind.
+ fs.unlinkSync(path);
+ } else {
+ fs.writeFileSync(path, next);
+ }
+ strippedFiles.push(path);
+ logger.event({ event: 'path-install-rc-block-removed', path: tildify(path, home) });
+ }
+ const consentAlreadyDeclined = marker?.consent?.status === 'declined';
+ if (marker && (strippedFiles.length > 0 || !consentAlreadyDeclined)) {
+ writeMarker(
+ home,
+ {
+ ...marker,
+ rcFiles: [],
+ consent: { status: 'declined', at: (opts.now?.() ?? new Date()).toISOString() },
+ },
+ fs,
+ );
+ logger.event({
+ event: 'path-install-consent-declined',
+ source: 'settings',
+ rcTargetCount: strippedFiles.length,
+ });
+ }
+ if (strippedFiles.length === 0 && (marker === null || consentAlreadyDeclined)) {
+ return { status: 'not-installed' };
+ }
+ } catch (err) {
+ const error = err instanceof Error ? err.message : String(err);
+ logger.event({ event: 'path-install-remove-failed', error });
+ return { status: 'failed', error };
+ }
+ return { status: 'removed', strippedFiles };
+}
diff --git a/packages/desktop/src/preload/index.ts b/packages/desktop/src/preload/index.ts
index ab2aae52b..88edf7a1c 100644
--- a/packages/desktop/src/preload/index.ts
+++ b/packages/desktop/src/preload/index.ts
@@ -49,6 +49,7 @@ import type {
OkUpdateStuckHintInfo,
OkWhatsNewInfo,
} from '../shared/bridge-contract.ts';
+import type { IntegrationsSetResult, IntegrationsStatus } from '../shared/ipc-channels.ts';
import { createInvoker } from '../shared/ipc-invoke.ts';
import { resolveOkDesktopMode } from '../shared/ok-desktop-mode.ts';
@@ -500,6 +501,21 @@ const bridge: OkDesktopBridge = {
skip: () => invoke('ok:mcp-wiring:skip'),
},
+ integrations: {
+ // One discriminated channel (`ok:integrations:dispatch`) backs both
+ // methods, respecting the hand-rolled-channel cap (the
+ // `ok:worktree:dispatch` precedent). Each method knows its branch, so it
+ // casts the union result to its own arm.
+ status: () =>
+ invoke('ok:integrations:dispatch', { kind: 'status' }) as Promise<IntegrationsStatus>,
+ setComponent: (request) =>
+ invoke('ok:integrations:dispatch', {
+ kind: 'set',
+ component: request.component,
+ enabled: request.enabled,
+ }) as Promise<IntegrationsSetResult>,
+ },
+
onboarding: {
onShow(cb: (payload: OkOnboardingShowPayload) => void) {
const listener = (_event: IpcRendererEvent, payload: OkOnboardingShowPayload) => cb(payload);
diff --git a/packages/desktop/src/shared/bridge-contract.ts b/packages/desktop/src/shared/bridge-contract.ts
index 29d84b4ac..203df6c86 100644
--- a/packages/desktop/src/shared/bridge-contract.ts
+++ b/packages/desktop/src/shared/bridge-contract.ts
@@ -412,6 +412,55 @@ export interface OkMcpWiringConfirmRequest {
/** Result shape for `mcpWiring.confirm` / `skip`. */
type OkMcpWiringResult = { ok: true } | { ok: false; error: string };
+/**
+ * Per-editor MCP state for Settings → AI tools. `installed` rows uncheck to
+ * remove; `not-installed` rows check to install; `foreign` is an entry under
+ * OK's server name that isn't recognizably OK's own (uninstall refuses,
+ * install overwrites); `unmanageable` is a config OK can't safely edit.
+ */
+type OkIntegrationsEditorState = 'installed' | 'not-installed' | 'foreign' | 'unmanageable';
+
+/** Component inventory for Settings → AI tools. `available: false` renders
+ * the section read-only (install actors gated off for this process). `path.
+ * installed` reflects the managed rc block actually being on disk. */
+interface OkIntegrationsStatus {
+ readonly available: boolean;
+ readonly editors: readonly {
+ readonly id: OkMcpWiringEditorId;
+ readonly label: string;
+ readonly detected: boolean;
+ readonly state: OkIntegrationsEditorState;
+ readonly configPath: string | null;
+ readonly entryLocator: string;
+ }[];
+ readonly path: {
+ readonly shellDetected: boolean;
+ readonly rcFilesToTouch: readonly string[];
+ readonly installed: boolean;
+ };
+ readonly skills: readonly {
+ readonly id: string;
+ readonly name: string;
+ readonly installed: boolean;
+ readonly paths: readonly string[];
+ }[];
+}
+
+/** One toggle for `integrations.setComponent`. */
+interface OkIntegrationsSetRequest {
+ readonly component:
+ | { readonly kind: 'editor'; readonly id: OkMcpWiringEditorId }
+ | { readonly kind: 'path' }
+ | { readonly kind: 'skill'; readonly id: string };
+ readonly enabled: boolean;
+}
+
+/** Set-component result — both arms carry a fresh status snapshot so the
+ * renderer re-renders truthfully after failed/refused toggles too. */
+type OkIntegrationsSetResult =
+ | { readonly ok: true; readonly status: OkIntegrationsStatus }
+ | { readonly ok: false; readonly error: string; readonly status: OkIntegrationsStatus };
+
/**
* Per-project consent dialog — renderer-facing payload + result
* shapes. Mirrors the IPC types in `./ipc-channels.ts` so the bridge surface
@@ -1534,6 +1583,16 @@ export interface OkDesktopBridge {
skip(): Promise<OkMcpWiringResult>;
};
+ /**
+ * Settings → AI tools: live per-component install state + one-component
+ * install/uninstall for OK's global footprint (per-editor MCP entries,
+ * shell-PATH shim, user-global skill bundles). Mutations serialize in main.
+ */
+ integrations: {
+ status(): Promise<OkIntegrationsStatus>;
+ setComponent(request: OkIntegrationsSetRequest): Promise<OkIntegrationsSetResult>;
+ };
+
/**
* Per-project consent dialog. Navigator-only — editor renderers never
* receive `ok:onboarding:show`. Renderer mounts a shadcn Dialog when
diff --git a/packages/desktop/src/shared/ipc-channels.ts b/packages/desktop/src/shared/ipc-channels.ts
index 10b975aa9..f3410b5b4 100644
--- a/packages/desktop/src/shared/ipc-channels.ts
+++ b/packages/desktop/src/shared/ipc-channels.ts
@@ -30,13 +30,15 @@
* existing channels is preferred over net-new hand-rolled channels until
* that migration lands.
*
- * Count is 77 (ratchet cap 77). The 74→75 bump reconciled a merge collision:
+ * Count is 78 (ratchet cap 78). The 74→75 bump reconciled a merge collision:
* the worktree selector (`ok:worktree:dispatch`) and the terminal-controls PR
* (`ok:terminal:cli-installed-map`) each landed in the base tree's single free
* slot concurrently. The 75→76 bump then unioned in the desktop
* startup-instrumentation channel (`ok:startup:renderer-marks`), which landed
* on main in parallel. The 76→77 bump added the share-receive branch-switch
- * dialog's verdict probe (`ok:project:fetch-target-status`). Full rationale in
+ * dialog's verdict probe (`ok:project:fetch-target-status`). The 77→78 bump
+ * added Settings → AI tools (`ok:integrations:dispatch`, a status+set
+ * discriminated fold per the worktree-dispatch precedent). Full rationale in
* the ratchet test header.
*/
@@ -418,6 +420,78 @@ export interface McpWiringGlobalSkillDescriptor {
export type McpWiringConfirmResult = { ok: true } | { ok: false; error: string };
export type McpWiringSkipResult = { ok: true } | { ok: false; error: string };
+/** Per-editor MCP state for Settings → AI tools.
+ * - `installed` — OK's own managed entry is in the editor's user config;
+ * checkbox renders checked and unchecking removes the entry.
+ * - `not-installed` — no entry under OK's server name (or no config file);
+ * checking writes the canonical entry.
+ * - `foreign` — an entry EXISTS under OK's server name but is not
+ * recognizably OK's own (customized/forked wrapper). Rendered checked
+ * with a disclosure; uninstall refuses (guest discipline), install
+ * overwrites under the namespace-ownership posture.
+ * - `unmanageable` — a present config OK cannot safely edit (unparseable /
+ * oversize / duplicate container). Row renders disabled. */
+export type IntegrationsEditorState = 'installed' | 'not-installed' | 'foreign' | 'unmanageable';
+
+export interface IntegrationsEditorStatus {
+ readonly id: McpWiringEditorId;
+ readonly label: string;
+ readonly detected: boolean;
+ readonly state: IntegrationsEditorState;
+ /** Tildified user-config file this row edits; null when the resolver can't
+ * produce one on this platform. Disclosure only — writes re-resolve. */
+ readonly configPath: string | null;
+ /** Technical locator of OK's entry inside the config, e.g.
+ * `mcpServers.open-knowledge` or `[mcp_servers.open-knowledge]`. */
+ readonly entryLocator: string;
+}
+
+/** PATH-shim row for Settings → AI tools. `installed` reflects the managed
+ * rc block actually being on disk (not merely a recorded grant), so the
+ * checkbox mirrors what external terminals really resolve. */
+export interface IntegrationsPathStatus {
+ readonly shellDetected: boolean;
+ readonly rcFilesToTouch: readonly string[];
+ readonly installed: boolean;
+}
+
+export interface IntegrationsSkillStatus {
+ readonly id: string;
+ readonly name: string;
+ readonly installed: boolean;
+ /** Tildified directories a toggle touches: the central `~/.agents/skills`
+ * copy plus each per-host copy whose host root exists on this machine. */
+ readonly paths: readonly string[];
+}
+
+/** Full component inventory for Settings → AI tools. `available: false`
+ * means the desktop's install actors are gated off for this process
+ * (non-darwin, unpackaged dev build without OK_M6B_FORCE) — status still
+ * reads, but the section renders read-only. */
+export interface IntegrationsStatus {
+ readonly available: boolean;
+ readonly editors: readonly IntegrationsEditorStatus[];
+ readonly path: IntegrationsPathStatus;
+ readonly skills: readonly IntegrationsSkillStatus[];
+}
+
+/** One toggleable component in Settings → AI tools. */
+export type IntegrationsComponentRef =
+ | { readonly kind: 'editor'; readonly id: McpWiringEditorId }
+ | { readonly kind: 'path' }
+ | { readonly kind: 'skill'; readonly id: string };
+
+export interface IntegrationsSetRequest {
+ readonly component: IntegrationsComponentRef;
+ readonly enabled: boolean;
+}
+
+/** Set-component response. Both arms carry a fresh status snapshot so the
+ * renderer re-renders truthfully even after a failed or refused toggle. */
+export type IntegrationsSetResult =
+ | { readonly ok: true; readonly status: IntegrationsStatus }
+ | { readonly ok: false; readonly error: string; readonly status: IntegrationsStatus };
+
/** Options for the open-folder native picker. `defaultPath` seeds the initial
* directory shown to the user (e.g., the project root for the consent dialog's
* Browse button). */
@@ -1067,6 +1141,24 @@ export interface RequestChannels {
*/
'ok:mcp-wiring:renderer-ready': { args: []; result: undefined };
+ /**
+ * Settings → AI tools. One consolidated discriminated channel — following
+ * the `ok:worktree:dispatch` precedent rather than adding two net-new
+ * channels — for both operations on OK's global footprint:
+ * - `{ kind: 'status' }` → full component inventory (per-editor MCP
+ * entries, the shell-PATH shim, user-global skill bundles). Read-only.
+ * - `{ kind: 'set', component, enabled }` → install or uninstall ONE
+ * component. Serialized in main (one in-flight mutation at a time) so
+ * two windows' toggles can't interleave partial writes on the same
+ * config file. Returns a fresh status snapshot on both arms.
+ * The renderer's `bridge.integrations.{status,setComponent}` recovers
+ * per-operation typing from the discriminated result.
+ */
+ 'ok:integrations:dispatch': {
+ args: [request: { kind: 'status' } | ({ kind: 'set' } & IntegrationsSetRequest)];
+ result: IntegrationsStatus | IntegrationsSetResult;
+ };
+
/**
* Per-project consent dialog. Renderer renders a shadcn Dialog inside the
* Navigator after main fires `ok:onboarding:show`; calls
diff --git a/packages/desktop/tests/integration/ipc-channel-count-ratchet.test.ts b/packages/desktop/tests/integration/ipc-channel-count-ratchet.test.ts
index ab567af81..39ff8f96f 100644
--- a/packages/desktop/tests/integration/ipc-channel-count-ratchet.test.ts
+++ b/packages/desktop/tests/integration/ipc-channel-count-ratchet.test.ts
@@ -262,8 +262,21 @@ const CHANNELS_SRC = readFileSync(SRC_PATH, 'utf-8');
* keep branch-info's fast path off the network) nor `ok:project:run-checkout`
* (a POST that MUTATES the working tree; this is a read-only fetch+classify).
* Extends the existing `ok:project:*` namespace, single member.
+ *
+ * Bumped from 77 to 78 for Settings → AI tools (per-component
+ * install/uninstall of OK's global footprint):
+ *
+ * - `ok:integrations:dispatch` — status read + one-component set folded
+ * into a single discriminated channel (the `ok:worktree:dispatch`
+ * precedent), so the surface costs one slot, not two. Could not fold
+ * into the `ok:mcp-wiring:*` channels: those are the ONE-SHOT
+ * first-launch consent flow with sender-binding + `handled` idempotence
+ * (a persistent settings surface riding them would have to defeat both
+ * guards), and their confirm semantics are batched consent, not
+ * per-component install/uninstall with live status. New
+ * `ok:integrations:*` namespace, single member.
*/
-const REQUEST_CHANNEL_CAP = 77;
+const REQUEST_CHANNEL_CAP = 78;
/**
* Extract the body of an interface block by name. Returns the substring
diff --git a/scripts/bun-install-ci.test.mjs b/scripts/bun-install-ci.test.mjs
index 9b463195b..23855f2c1 100644
--- a/scripts/bun-install-ci.test.mjs
+++ b/scripts/bun-install-ci.test.mjs
@@ -37,13 +37,21 @@
* attempts.
*/
-import { afterEach, describe, expect, test } from 'bun:test';
+import { afterEach, describe, expect, setDefaultTimeout, test } from 'bun:test';
import { spawnSync } from 'node:child_process';
import { chmodSync, existsSync, mkdtempSync, rmSync, statSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
+// Every test here drives the wrapper via `spawnSync` (bash spawning bash), and
+// spawn/exec latency is variable under machine load — a nominally-instant
+// happy-path attempt has been observed to overrun Bun's 5s default per-test
+// budget on a saturated box even though its real work is milliseconds. The hang
+// tests carry explicit long timeouts already; raise the file default so the
+// fast tests get the same headroom instead of flaking on scheduling latency.
+setDefaultTimeout(30000);
+
const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));
const WRAPPER = join(SCRIPT_DIR, 'bun-install-ci.sh');