Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
feat(desktop): Settings → This project → AI tools + fix Pi leak in global section (#2511)
mike-inkeepd2b9b6c909c1
diff --git a/.changeset/settings-project-ai-tools-section.md b/.changeset/settings-project-ai-tools-section.mdnew file mode 100644index 000000000..de296291b--- /dev/null+++ b/.changeset/settings-project-ai-tools-section.md@@ -0,0 +1,7 @@+---+"@inkeep/open-knowledge": minor+---++Settings → This project gains an "AI tools" section — the project-scoped sibling of the "AI tools & CLI" section. It manages OpenKnowledge's project-local footprint for the project the window has open: the per-editor project MCP config files (`.mcp.json` for Claude Code, `.cursor/mcp.json` for Cursor, `.codex/config.toml` for Codex, and the OpenCode/Pi equivalents) and the project runtime skill (`.claude/skills/open-knowledge/`). Every row reflects its live installed state and a click installs or uninstalls that one component; removal follows the same guest discipline as install (only entries OpenKnowledge recognizably wrote are deleted). Because a written project config is not always a connected one, each installed row states its remaining step — Claude Code needs a one-time approval, Cursor must be enabled in its own settings, Codex auto-connects on a trusted project. Editors with no project surface (Claude Desktop) are omitted. Mutations resolve and serialize against the sender window's project in the desktop main process.++This also fixes a related leak in the existing "AI tools & CLI" (user-global) section: project-only editors such as Pi have no user-global MCP config, so they surfaced there as a permanently-unmanageable row. The global section now lists only `scope: 'global'` editors; Pi is managed in the new project section instead.diff --git a/packages/app/src/components/settings/ProjectAiToolsSection.dom.test.tsx b/packages/app/src/components/settings/ProjectAiToolsSection.dom.test.tsxnew file mode 100644index 000000000..b2a3d5d57--- /dev/null+++ b/packages/app/src/components/settings/ProjectAiToolsSection.dom.test.tsx@@ -0,0 +1,229 @@+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 {+ OkProjectIntegrationsSetRequest,+ OkProjectIntegrationsSetResult,+ OkProjectIntegrationsStatus,+} 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 }),+}));++const toastError = mock(() => {});+mock.module('sonner', () => ({+ toast: { error: toastError, info: mock(() => {}), success: mock(() => {}) },+}));++const { ProjectAiToolsSection } = await import('./ProjectAiToolsSection');+const { TooltipProvider } = await import('@/components/ui/tooltip');++function renderSection() {+ return render(+ <TooltipProvider>+ <ProjectAiToolsSection />+ </TooltipProvider>,+ );+}++const baseStatus: OkProjectIntegrationsStatus = {+ available: true,+ hasProject: true,+ projectDir: '~/proj',+ editors: [+ {+ id: 'claude',+ label: 'Claude Code',+ state: 'installed',+ configPath: '.mcp.json',+ entryLocator: 'mcpServers.open-knowledge',+ followUp: 'approve-once',+ },+ {+ id: 'cursor',+ label: 'Cursor',+ state: 'not-installed',+ configPath: '.cursor/mcp.json',+ entryLocator: 'mcpServers.open-knowledge',+ followUp: 'enable-manually',+ },+ {+ id: 'codex',+ label: 'Codex',+ state: 'foreign',+ configPath: '.codex/config.toml',+ entryLocator: '[mcp_servers.open-knowledge]',+ followUp: 'auto-connect',+ },+ ],+ skill: {+ installed: true,+ paths: ['.claude/skills/open-knowledge/SKILL.md', '.codex/skills/open-knowledge/SKILL.md'],+ },+};++interface HarnessOpts {+ status?: OkProjectIntegrationsStatus;+ setResult?: (request: OkProjectIntegrationsSetRequest) => OkProjectIntegrationsSetResult;+}++function installBridge({ status = baseStatus, setResult }: HarnessOpts = {}) {+ const setCalls: OkProjectIntegrationsSetRequest[] = [];+ const bridge = {+ projectIntegrations: {+ status: async () => status,+ setComponent: async (request: OkProjectIntegrationsSetRequest) => {+ 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('ProjectAiToolsSection', () => {+ test('renders the desktop-only fallback when no bridge is present', () => {+ renderSection();+ expect(screen.getByTestId('project-ai-tools-unavailable')).toBeTruthy();+ });++ test('shows the unavailable fallback (not a stuck skeleton) when the status fetch rejects', async () => {+ // A rejecting status() must land on the loadFailed branch, not hang in the+ // loading skeleton — otherwise the section silently dead-ends with no signal.+ const bridge = {+ projectIntegrations: {+ status: async () => {+ throw new Error('IPC error');+ },+ setComponent: async () => ({ ok: true as const, status: baseStatus }),+ },+ };+ Object.defineProperty(window, 'okDesktop', {+ value: bridge,+ configurable: true,+ writable: true,+ });+ renderSection();+ await waitFor(() => {+ expect(screen.getByTestId('project-ai-tools-unavailable')).toBeTruthy();+ });+ expect(screen.queryByTestId('project-ai-tools-loading')).toBeNull();+ });++ test('renders each project MCP row + the single skill row', async () => {+ installBridge();+ renderSection();+ await waitFor(() => {+ expect(screen.getByTestId('project-ai-tools-editor-checkbox-claude')).toBeTruthy();+ });+ expect(screen.getByTestId('project-ai-tools-editor-checkbox-cursor')).toBeTruthy();+ expect(screen.getByTestId('project-ai-tools-editor-checkbox-codex')).toBeTruthy();+ expect(screen.getByTestId('project-ai-tools-skill-checkbox')).toBeTruthy();+ });++ test('installed/foreign rows are checked; not-installed rows are not', async () => {+ installBridge();+ renderSection();+ await waitFor(() => {+ expect(screen.getByTestId('project-ai-tools-editor-checkbox-claude')).toBeTruthy();+ });+ // Radix Checkbox reflects state via aria-checked.+ expect(+ screen.getByTestId('project-ai-tools-editor-checkbox-claude').getAttribute('aria-checked'),+ ).toBe('true');+ expect(+ screen.getByTestId('project-ai-tools-editor-checkbox-cursor').getAttribute('aria-checked'),+ ).toBe('false');+ expect(+ screen.getByTestId('project-ai-tools-editor-checkbox-codex').getAttribute('aria-checked'),+ ).toBe('true');+ });++ test('shows the per-editor follow-up hint on installed/foreign rows only', async () => {+ installBridge();+ renderSection();+ await waitFor(() => {+ expect(screen.getByTestId('project-ai-tools-editor-followup-claude')).toBeTruthy();+ });+ // Foreign row (checked) also carries its follow-up.+ expect(screen.getByTestId('project-ai-tools-editor-followup-codex')).toBeTruthy();+ // not-installed cursor row has no follow-up yet.+ expect(screen.queryByTestId('project-ai-tools-editor-followup-cursor')).toBeNull();+ });++ test('checking a not-installed editor calls setComponent(install)', async () => {+ const { setCalls } = installBridge();+ renderSection();+ const user = userEvent.setup();+ await waitFor(() => {+ expect(screen.getByTestId('project-ai-tools-editor-checkbox-cursor')).toBeTruthy();+ });+ await user.click(screen.getByTestId('project-ai-tools-editor-checkbox-cursor'));+ await waitFor(() => expect(setCalls.length).toBe(1));+ expect(setCalls[0]).toEqual({ component: { kind: 'editor', id: 'cursor' }, enabled: true });+ });++ test('toggling the skill row fans out via a single skill component ref', async () => {+ const { setCalls } = installBridge();+ renderSection();+ const user = userEvent.setup();+ await waitFor(() => {+ expect(screen.getByTestId('project-ai-tools-skill-checkbox')).toBeTruthy();+ });+ // Installed → unchecking uninstalls.+ await user.click(screen.getByTestId('project-ai-tools-skill-checkbox'));+ await waitFor(() => expect(setCalls.length).toBe(1));+ expect(setCalls[0]).toEqual({ component: { kind: 'skill' }, enabled: false });+ });++ test('a refused toggle surfaces the error as a toast', async () => {+ installBridge({+ setResult: () => ({+ ok: false as const,+ error: 'guest config — left unchanged',+ status: baseStatus,+ }),+ });+ renderSection();+ const user = userEvent.setup();+ await waitFor(() => {+ expect(screen.getByTestId('project-ai-tools-editor-checkbox-cursor')).toBeTruthy();+ });+ await user.click(screen.getByTestId('project-ai-tools-editor-checkbox-cursor'));+ await waitFor(() => expect(toastError).toHaveBeenCalledWith('guest config — left unchanged'));+ });++ test('no project open → empty state, no rows', async () => {+ installBridge({+ status: { available: true, hasProject: false, projectDir: null, editors: [], skill: null },+ });+ renderSection();+ await waitFor(() => {+ expect(screen.getByTestId('project-ai-tools-no-project')).toBeTruthy();+ });+ expect(screen.queryByTestId('project-ai-tools-skill-checkbox')).toBeNull();+ });++ test('read-only build shows the banner and disables the checkboxes', async () => {+ installBridge({ status: { ...baseStatus, available: false } });+ renderSection();+ await waitFor(() => {+ expect(screen.getByTestId('project-ai-tools-read-only')).toBeTruthy();+ });+ expect(+ screen.getByTestId('project-ai-tools-skill-checkbox').getAttribute('data-disabled'),+ ).not.toBeNull();+ });+});diff --git a/packages/app/src/components/settings/ProjectAiToolsSection.tsx b/packages/app/src/components/settings/ProjectAiToolsSection.tsxnew file mode 100644index 000000000..60f3c7826--- /dev/null+++ b/packages/app/src/components/settings/ProjectAiToolsSection.tsx@@ -0,0 +1,358 @@+/**+ * Settings → This project → AI tools — the project-scoped sibling of+ * `AiToolsSection.tsx`. Where that surface manages OK's user-global footprint+ * (per-editor USER MCP entries, the shell-PATH shim, user-global skills), this+ * one manages the PROJECT-LOCAL footprint of the currently-open project:+ * per-editor project MCP config files (`.mcp.json`, `.cursor/mcp.json`,+ * `.codex/config.toml`, …) and the project runtime skill. Checkboxes reflect+ * LIVE installed state; each click applies immediately (check = install,+ * uncheck = uninstall) over the `projectIntegrations` bridge, which resolves+ * the window's project in main.+ *+ * The one thing the global section doesn't carry: per-editor follow-up honesty.+ * A written project config is not always a connected one — Claude Code needs a+ * one-time approval, Cursor sits silently disabled until manually enabled,+ * Codex auto-connects on a trusted project. Each installed row states its next+ * step so a project-only install isn't a silent dead-end.+ *+ * Desktop-only — the sidebar item is gated on the Electron preload bridge, and+ * this component renders a fallback if mounted without it.+ */++import { Trans, useLingui } from '@lingui/react/macro';+import { 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 {+ OkProjectIntegrationsFollowUp,+ OkProjectIntegrationsSetRequest,+ OkProjectIntegrationsStatus,+} from '@/lib/desktop-bridge-types';++type EditorRow = OkProjectIntegrationsStatus['editors'][number];+type ComponentRef = OkProjectIntegrationsSetRequest['component'];++/** Stable per-row key for the in-flight marker. */+function editorKey(id: string): string {+ return `editor:${id}`;+}+const SKILL_KEY = 'skill';++/**+ * Per-row disclosure tooltip. 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 — 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>+ );+}++/** The manual step, if any, an installed editor still needs before OK's tools+ * actually connect for this project. Rendered only on installed/foreign rows. */+function FollowUpHint({+ followUp,+ testId,+}: {+ followUp: OkProjectIntegrationsFollowUp;+ testId: string;+}) {+ if (followUp === 'none') return null;+ return (+ // Live region: the hint appears the moment a row toggles to installed, so+ // its "one more step" is announced rather than silently painted.+ <span role="status" className="text-xs text-amber-600 dark:text-amber-400" data-testid={testId}>+ {followUp === 'approve-once' ? (+ <Trans comment="Next step for a Claude Code project MCP row">+ One more step: run <code className="inline-code">claude</code> in this project and approve+ OpenKnowledge once.+ </Trans>+ ) : followUp === 'enable-manually' ? (+ <Trans comment="Next step for a Cursor project MCP row — Cursor leaves project servers disabled">+ One more step: enable it in Cursor → Settings → Tools & MCP (Cursor leaves project servers+ off until you turn them on).+ </Trans>+ ) : (+ <Trans comment="Next step for a Codex project MCP row">+ Connects automatically the next time you open this project in a trusted Codex session.+ </Trans>+ )}+ </span>+ );+}++export function ProjectAiToolsSection() {+ const { t } = useLingui();+ const bridge = typeof window !== 'undefined' ? (window.okDesktop ?? null) : null;+ const [status, setStatus] = useState<OkProjectIntegrationsStatus | null>(null);+ const [loadFailed, setLoadFailed] = useState(false);+ const [pending, setPending] = useState<string | null>(null);++ useEffect(() => {+ if (!bridge) return;+ let cancelled = false;+ bridge.projectIntegrations+ .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; 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(component.kind === 'editor' ? editorKey(component.id) : SKILL_KEY);+ try {+ const result = await bridge.projectIntegrations.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-project-ai-tools-title" className="text-base font-semibold">+ <Trans>AI tools</Trans>+ </h3>+ <p className="text-sm text-muted-foreground">+ <Trans>+ Connect the AI tools you use to this specific project. These files live in the project+ folder, so anyone who opens it gets the same setup.+ </Trans>+ </p>+ </div>+ );++ if (!bridge || loadFailed) {+ return (+ <section aria-labelledby="settings-project-ai-tools-title" className="space-y-4">+ {header}+ <p className="text-sm text-muted-foreground" data-testid="project-ai-tools-unavailable">+ <Trans>+ Project AI tool management is only available in the OpenKnowledge desktop app.+ </Trans>+ </p>+ </section>+ );+ }++ if (status === null) {+ return (+ <section aria-labelledby="settings-project-ai-tools-title" className="space-y-4">+ {header}+ <div className="space-y-2" data-testid="project-ai-tools-loading">+ <Skeleton className="h-10 w-full" />+ <Skeleton className="h-10 w-full" />+ </div>+ </section>+ );+ }++ if (!status.hasProject) {+ return (+ <section aria-labelledby="settings-project-ai-tools-title" className="space-y-4">+ {header}+ <p className="text-sm text-muted-foreground" data-testid="project-ai-tools-no-project">+ <Trans>Open a project to manage its AI tool connections.</Trans>+ </p>+ </section>+ );+ }++ const busy = pending !== null || !status.available;++ return (+ <section aria-labelledby="settings-project-ai-tools-title" className="space-y-4">+ {header}++ {!status.available && (+ <p+ className="text-sm text-amber-600 dark:text-amber-400"+ data-testid="project-ai-tools-read-only"+ >+ <Trans>Managing project AI tools is unavailable in this build.</Trans>+ </p>+ )}++ <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 project MCP list in Settings → This project → AI tools">+ MCP connections+ </Trans>+ </span>+ <ul className="rounded-md border border-border bg-card/50 divide-y divide-border overflow-hidden">+ {status.editors.map((editor) => (+ <EditorRowItem+ key={editor.id}+ editor={editor}+ busy={busy}+ onToggle={(enabled) => void applyToggle({ kind: 'editor', id: editor.id }, enabled)}+ />+ ))}+ </ul>+ </div>++ {status.skill !== null && (+ <div className="flex flex-col gap-1.5">+ <span className="text-xs font-medium text-muted-foreground">+ <Trans comment="Group label above the project runtime-skill row in Settings → This project → AI tools">+ Project skill+ </Trans>+ </span>+ <ul className="rounded-md border border-border bg-card/50 overflow-hidden">+ <li className="flex items-start hover:bg-accent">+ <Label+ htmlFor="project-ai-tools-skill"+ className="flex flex-1 cursor-pointer items-start gap-2.5 px-3 py-2.5 font-normal"+ >+ <Checkbox+ id="project-ai-tools-skill"+ checked={status.skill.installed}+ disabled={busy}+ onCheckedChange={() =>+ void applyToggle({ kind: 'skill' }, !status.skill?.installed)+ }+ className="mt-0.5"+ data-testid="project-ai-tools-skill-checkbox"+ />+ <span className="flex min-w-0 flex-1 flex-col gap-0.5">+ <span className="text-sm font-medium text-foreground">+ <code>open-knowledge</code>+ </span>+ <span className="text-xs text-muted-foreground">+ <Trans comment="Subtext for the project runtime-skill row">+ Teaches coding agents in this project to read and write through OpenKnowledge.+ </Trans>+ </span>+ </span>+ </Label>+ <RowInfoTooltip testId="project-ai-tools-skill-info">+ <p className="opacity-70">+ <Trans>Folders</Trans>+ </p>+ {status.skill.paths.map((path) => (+ <p key={path}>+ <code className="break-all">{path}</code>+ </p>+ ))}+ </RowInfoTooltip>+ </li>+ </ul>+ </div>+ )}+ </section>+ );+}++function EditorRowItem({+ editor,+ busy,+ onToggle,+}: {+ editor: EditorRow;+ busy: boolean;+ onToggle: (enabled: boolean) => void;+}) {+ const { t } = useLingui();+ const checked = editor.state === 'installed' || editor.state === 'foreign';+ const disabled = busy || editor.state === 'unmanageable';+ 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 project config`+ : 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 className={disabled ? 'flex items-start' : 'flex items-start hover:bg-accent'}>+ <Label+ htmlFor={`project-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={`project-ai-tools-editor-${editor.id}`}+ checked={checked}+ disabled={disabled}+ onCheckedChange={() => onToggle(!checked)}+ className="mt-0.5"+ data-testid={`project-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={`project-ai-tools-editor-status-${editor.id}`}+ >+ {statusLabel}+ </span>+ )}+ {checked && (+ <FollowUpHint+ followUp={editor.followUp}+ testId={`project-ai-tools-editor-followup-${editor.id}`}+ />+ )}+ </span>+ </Label>+ <RowInfoTooltip testId={`project-ai-tools-editor-info-${editor.id}`}>+ <p className="opacity-70">+ <Trans>File</Trans>+ </p>+ <p>+ <code className="break-all">{editor.configPath}</code>+ </p>+ <p className="pt-1 opacity-70">+ <Trans>Entry</Trans>+ </p>+ <p>+ <code className="break-all">{editor.entryLocator}</code>+ </p>+ </RowInfoTooltip>+ </li>+ );+}diff --git a/packages/app/src/components/settings/SettingsDialogBody.tsx b/packages/app/src/components/settings/SettingsDialogBody.tsxindex ab9b86819..8d81f2f97 100644--- a/packages/app/src/components/settings/SettingsDialogBody.tsx+++ b/packages/app/src/components/settings/SettingsDialogBody.tsx@@ -109,6 +109,7 @@ import { AccountSection } from './AccountSection';import { AiToolsSection } from './AiToolsSection';import { EmbeddingsKeySection } from './EmbeddingsKeySection';import { OkignoreSection } from './OkignoreSection';+import { ProjectAiToolsSection } from './ProjectAiToolsSection';import { ProjectTemplatesSection } from './ProjectTemplatesSection';import { SearchSection } from './SearchSection';import { SkillsManagerSection } from './SkillsManagerSection';@@ -249,6 +250,12 @@ export function SettingsDialogBody({// Electron host). Talks to main over the integrations bridge.return <AiToolsSection />;}+ if (activeId === 'project-ai-tools') {+ // Project-local AI-tool management — desktop-only (nav item gated to the+ // Electron host). Talks to main over the projectIntegrations bridge,+ // scoped to the window's open project.+ return <ProjectAiToolsSection />;+ }if (activeId === 'claude-desktop') {return <IntegrationsSection />;}diff --git a/packages/app/src/components/settings/SettingsDialogShell.tsx b/packages/app/src/components/settings/SettingsDialogShell.tsxindex 2dd868edf..46be0109a 100644--- a/packages/app/src/components/settings/SettingsDialogShell.tsx+++ b/packages/app/src/components/settings/SettingsDialogShell.tsx@@ -120,6 +120,9 @@ export function SettingsDialogShell({ open, onOpenChange }: SettingsDialogShellP{ id: 'sync', label: t`Sync` },{ id: 'search', label: t`Search` },...(isOkDesktopHost ? [{ id: 'terminal', label: t`Terminal` }] : []),+ // Per-project MCP wiring + runtime skill — desktop-only because the+ // install actors live in the Electron main process (like Terminal).+ ...(isOkDesktopHost ? [{ id: 'project-ai-tools', label: t`AI tools` }] : []),{ id: 'project-templates', label: t`Templates` },{ id: 'skills', label: t`Skills` },{ id: 'okignore', label: t`Ignore patterns` },diff --git a/packages/app/src/lib/desktop-bridge-types.ts b/packages/app/src/lib/desktop-bridge-types.tsindex 2364fc940..c60742f13 100644--- a/packages/app/src/lib/desktop-bridge-types.ts+++ b/packages/app/src/lib/desktop-bridge-types.ts@@ -504,6 +504,51 @@ export type OkIntegrationsSetResult =| { readonly ok: true; readonly status: OkIntegrationsStatus }| { readonly ok: false; readonly error: string; readonly status: OkIntegrationsStatus };+/** Post-install manual step a project MCP config needs before OK's tools+ * connect: `approve-once` (Claude Code), `enable-manually` (Cursor, silently+ * disabled until toggled), `auto-connect` (Codex on a trusted project),+ * `none`. */+export type OkProjectIntegrationsFollowUp =+ | 'approve-once'+ | 'enable-manually'+ | 'auto-connect'+ | 'none';++/** Component inventory for Settings → This project → AI tools (per-editor+ * PROJECT MCP config files + the single project runtime skill), scoped to the+ * project the requesting window has open. `hasProject: false` → empty state;+ * `available: false` → read-only. */+export interface OkProjectIntegrationsStatus {+ readonly available: boolean;+ readonly hasProject: boolean;+ readonly projectDir: string | null;+ readonly editors: readonly {+ readonly id: OkMcpWiringEditorId;+ readonly label: string;+ readonly state: OkIntegrationsEditorState;+ readonly configPath: string;+ readonly entryLocator: string;+ readonly followUp: OkProjectIntegrationsFollowUp;+ }[];+ readonly skill: {+ readonly installed: boolean;+ readonly paths: readonly string[];+ } | null;+}++/** One toggle for `projectIntegrations.setComponent`. The skill is a single+ * row (no id) — it fans out across every capable editor. */+export interface OkProjectIntegrationsSetRequest {+ readonly component:+ | { readonly kind: 'editor'; readonly id: OkMcpWiringEditorId }+ | { readonly kind: 'skill' };+ readonly enabled: boolean;+}++export type OkProjectIntegrationsSetResult =+ | { readonly ok: true; readonly status: OkProjectIntegrationsStatus }+ | { readonly ok: false; readonly error: string; readonly status: OkProjectIntegrationsStatus };+/*** Per-project consent dialog — renderer-facing payload + result shapes.* Mirrors `bridge-contract.ts` and `core/src/desktop-bridge.ts`. Drift@@ -1131,6 +1176,16 @@ export interface OkDesktopBridge {status(): Promise<OkIntegrationsStatus>;setComponent(request: OkIntegrationsSetRequest): Promise<OkIntegrationsSetResult>;};+ /**+ * Settings → This project → AI tools: live per-component install state ++ * one-component install/uninstall for OK's PROJECT-LOCAL footprint (per-editor+ * project MCP config files + the project runtime skill) against the project+ * the requesting window has open. Mutations serialize in main.+ */+ projectIntegrations: {+ status(): Promise<OkProjectIntegrationsStatus>;+ setComponent(request: OkProjectIntegrationsSetRequest): Promise<OkProjectIntegrationsSetResult>;+ };/*** Per-project consent dialog surface. Navigator-only. Renderer mounts a* shadcn Dialog when `onShow` fires; calls `confirm` / `cancel` on userdiff --git a/packages/app/src/locales/en/messages.json b/packages/app/src/locales/en/messages.jsonindex e8123301e..12f6adf91 100644--- a/packages/app/src/locales/en/messages.json+++ b/packages/app/src/locales/en/messages.json@@ -527,6 +527,7 @@"CWzc2T": ["<0>~/.ok/bin</0> and <1>~/.ok/env.sh</1> stay either way — the app always maintains them."],+ "CXTwen": ["Can't safely edit this project config"],"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."@@ -743,6 +744,7 @@"HM56Bx": ["Creating..."],"HPTPGr": ["Create a new spec file for my user story"],"HSh8u_": ["Folders"],+ "HTW0Zw": ["One more step: run <0>claude</0> in this project and approve OpenKnowledge once."],"HXFyWD": ["Split diff"],"HdkSiO": ["New file"],"HfI1dR": ["I already have it locally →"],@@ -895,6 +897,7 @@"LpB85N": ["Plain"],"LtI9AS": ["Owner"],"LtSYdi": ["Reveal in Finder"],+ "LtiJ5c": ["Project skill"],"LuoJWu": [["truncatedShownCount",@@ -966,6 +969,9 @@"NIWAux": ["No docs registered under #", ["tagDocsName"], "."],"NJyQi_": ["Branch ", ["shareBranch"], " no longer exists on the remote."],"NKkZXl": ["Initialize and open"],+ "NNJsn7": [+ "One more step: enable it in Cursor → Settings → Tools & MCP (Cursor leaves project servers off until you turn them on)."+ ],"NOHyEE": ["Retry push"],"NORKZU": ["Pattern warnings: ", ["summary"]],"NQ8llq": ["Add item"],@@ -1413,6 +1419,9 @@"ZWwYwM": ["Base branch"],"ZWxfrc": ["cleared folder properties"],"ZWyHmq": ["This project"],+ "ZYtq3m": [+ "Connect the AI tools you use to this specific project. These files live in the project folder, so anyone who opens it gets the same setup."+ ],"Zf0w-R": ["Take a piece of writing from a rough idea to a finished draft to something you're ready to share. Good for blog posts, essays, or anything you want to move through clear stages."],@@ -1441,6 +1450,7 @@"</1>."],"_BthEY": ["Open in ", ["shareBranch"]],+ "_NX6gG": ["Managing project AI tools is unavailable in this build."],"_PACVa": ["Release notes"],"_PBJRl": ["Add at least one letter or number."],"_QwkMu": ["No matching paths"],@@ -1554,6 +1564,7 @@"cn1sLi": ["Couldn't connect OpenKnowledge tools to Claude Code. Please try again."],"cnGeoo": ["Delete"],"cqQyPB": ["Folder name"],+ "crqzW5": ["AI tools"],"cs4mps": ["Config sharing"],"csDS2L": ["Available"],"ct2kv5": ["No headings in ", ["pageTarget"]],@@ -1665,6 +1676,7 @@"fwhX-N": ["Indent or outdent source"],"fxbCNQ": ["Synced. The link is up to date."],"g3UF2V": ["Accept"],+ "g4WlQK": ["Project AI tool management is only available in the OpenKnowledge desktop app."],"g4XBm0": ["Small section heading."],"g58Kwy": ["<",@@ -1867,6 +1879,7 @@"k_yIIc": ["Will be created at: <0>", ["targetPreview"], "</0>"],"kdzzOK": ["Off — search ranks by keyword only. No content leaves this computer."],"keNFEd": ["Set identity"],+ "khCa4M": ["Teaches coding agents in this project to read and write through OpenKnowledge."],"kj9pAE": ["Creating page"],"kknhfj": ["No changes"],"kmKqZg": ["Clusters"],@@ -1969,6 +1982,9 @@"Auto-sync periodically fetches, pulls, and pushes commits to your remote git repository so your edits stay in sync across machines."],"n7aopT": ["Editor mode"],+ "n8DwqQ": [+ "Connects automatically the next time you open this project in a trusted Codex session."+ ],"nCzR-G": ["Copy code ", ["userCode"]],"nD7Fx9": ["This replaces the current skill content with the bundled version ",@@ -2410,6 +2426,7 @@"yYR6za": ["Display text"],"yZmvQ4": ["This project's server (v", ["0"], ") is newer than this app (v", ["1"], ")."],"y_5CE8": ["Item ", ["0"]],+ "yaPGPa": ["Open a project to manage its AI tool connections."],"yf5r22": [["keyName"]," type: ",diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.poindex 3d833f416..b132d0505 100644--- a/packages/app/src/locales/en/messages.po+++ b/packages/app/src/locales/en/messages.po@@ -780,6 +780,11 @@ msgstr "Agent Skills"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/ProjectAiToolsSection.tsx+#: src/components/settings/SettingsDialogShell.tsx+msgid "AI tools"+msgstr "AI tools"+#: src/components/settings/AiToolsSection.tsx#: src/components/settings/SettingsDialogShell.tsxmsgid "AI tools & CLI"@@ -1136,6 +1141,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/ProjectAiToolsSection.tsx+msgid "Can't safely edit this project config"+msgstr "Can't safely edit this project config"+#: src/components/settings/AiToolsSection.tsxmsgid "Can't safely edit this tool's config"msgstr "Can't safely edit this tool's config"@@ -1567,6 +1576,10 @@ msgstr "Connect GitHub to continue."msgid "Connect OpenKnowledge to other tools you use."msgstr "Connect OpenKnowledge to other tools you use."+#: src/components/settings/ProjectAiToolsSection.tsx+msgid "Connect the AI tools you use to this specific project. These files live in the project folder, so anyone who opens it gets the same setup."+msgstr "Connect the AI tools you use to this specific project. These files live in the project folder, so anyone who opens it gets the same setup."+#: src/components/FileSidebar.tsx#: src/components/FileTree.tsxmsgid "Connect this project to GitHub to share."@@ -1622,6 +1635,11 @@ msgstr "Connection error — try again"msgid "Connection lost — keep this tab open, your edits will sync when reconnected"msgstr "Connection lost — keep this tab open, your edits will sync when reconnected"+#. Next step for a Codex project MCP row+#: src/components/settings/ProjectAiToolsSection.tsx+msgid "Connects automatically the next time you open this project in a trusted Codex session."+msgstr "Connects automatically the next time you open this project in a trusted Codex session."+#: src/components/ConsentDialogBody.tsxmsgid "Content directory"msgstr "Content directory"@@ -1850,6 +1868,7 @@ msgstr "Could not write project files. Try a different location."#. placeholder {0}: err instanceof Error ? err.message : String(err)#: src/components/settings/AiToolsSection.tsx+#: src/components/settings/ProjectAiToolsSection.tsxmsgid "Couldn't apply the change: {0}"msgstr "Couldn't apply the change: {0}"@@ -2218,6 +2237,7 @@ 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+#: src/components/settings/ProjectAiToolsSection.tsxmsgid "Custom open-knowledge entry — not managed by OpenKnowledge"msgstr "Custom open-knowledge entry — not managed by OpenKnowledge"@@ -2751,6 +2771,7 @@ 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+#: src/components/settings/ProjectAiToolsSection.tsxmsgid "Entry"msgstr "Entry"@@ -3057,6 +3078,7 @@ msgid "Fetching"msgstr "Fetching"#: src/components/settings/AiToolsSection.tsx+#: src/components/settings/ProjectAiToolsSection.tsx#: src/components/share-metadata-rows.tsx#: src/editor/slash-command/component-items.tsxmsgid "File"@@ -3208,6 +3230,7 @@ msgid "Folder target: {linkTitle}. Click to open the overview."msgstr "Folder target: {linkTitle}. Click to open the overview."#: src/components/settings/AiToolsSection.tsx+#: src/components/settings/ProjectAiToolsSection.tsxmsgid "Folders"msgstr "Folders"@@ -3724,6 +3747,7 @@ msgid "Install skills into"msgstr "Install skills into"#: src/components/settings/AiToolsSection.tsx+#: src/components/settings/ProjectAiToolsSection.tsx#: src/components/SkillEditorActions.tsx#: src/components/SkillRow.tsx#: src/components/SkillStateBadge.tsx@@ -4058,6 +4082,10 @@ msgstr "Manage the GitHub account OpenKnowledge uses to browse and sync your repmsgid "Managing AI tools is unavailable in this build."msgstr "Managing AI tools is unavailable in this build."+#: src/components/settings/ProjectAiToolsSection.tsx+msgid "Managing project AI tools is unavailable in this build."+msgstr "Managing project AI tools is unavailable in this build."+#: src/components/empty-state/use-create-suggestions.tsmsgid "Map the architecture"msgstr "Map the architecture"@@ -4079,9 +4107,11 @@ 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+#. Group label above the per-editor project MCP list in Settings → This project → AI tools#. 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+#: src/components/settings/ProjectAiToolsSection.tsxmsgid "MCP connections"msgstr "MCP connections"@@ -4725,6 +4755,16 @@ msgstr "On"msgid "On — your search queries and the text of matching pages are sent to your embeddings provider (OpenAI by default) to compute embeddings."msgstr "On — your search queries and the text of matching pages are sent to your embeddings provider (OpenAI by default) to compute embeddings."+#. Next step for a Cursor project MCP row — Cursor leaves project servers disabled+#: src/components/settings/ProjectAiToolsSection.tsx+msgid "One more step: enable it in Cursor → Settings → Tools & MCP (Cursor leaves project servers off until you turn them on)."+msgstr "One more step: enable it in Cursor → Settings → Tools & MCP (Cursor leaves project servers off until you turn them on)."++#. Next step for a Claude Code project MCP row+#: src/components/settings/ProjectAiToolsSection.tsx+msgid "One more step: run <0>claude</0> in this project and approve OpenKnowledge once."+msgstr "One more step: run <0>claude</0> in this project and approve OpenKnowledge once."+#: src/components/ConsentDialogBody.tsxmsgid "One pattern per line — appended to <0>.okignore</0>."msgstr "One pattern per line — appended to <0>.okignore</0>."@@ -4775,6 +4815,10 @@ msgstr "Open a doc to share its URL."msgid "Open a project to edit."msgstr "Open a project to edit."+#: src/components/settings/ProjectAiToolsSection.tsx+msgid "Open a project to manage its AI tool connections."+msgstr "Open a project to manage its AI tool connections."+#: src/presence/PresenceBar.tsxmsgid "Open activity panel for {tooltipName}"msgstr "Open activity panel for {tooltipName}"@@ -5308,6 +5352,10 @@ msgstr "project"msgid "Project"msgstr "Project"+#: src/components/settings/ProjectAiToolsSection.tsx+msgid "Project AI tool management is only available in the OpenKnowledge desktop app."+msgstr "Project AI tool management is only available in the OpenKnowledge desktop app."+#: src/components/CreateProjectDialog.tsxmsgid "Project folder created, but git init failed. Try again."msgstr "Project folder created, but git init failed. Try again."@@ -5321,6 +5369,11 @@ msgstr "Project name"msgid "Project root"msgstr "Project root"+#. Group label above the project runtime-skill row in Settings → This project → AI tools+#: src/components/settings/ProjectAiToolsSection.tsx+msgid "Project skill"+msgstr "Project skill"+#: src/lib/skill-scope.tsmsgid "Project Skill"msgstr "Project Skill"@@ -6756,6 +6809,11 @@ msgstr "Task List"msgid "Teach agents a repeatable task. You can edit the body after creating."msgstr "Teach agents a repeatable task. You can edit the body after creating."+#. Subtext for the project runtime-skill row+#: src/components/settings/ProjectAiToolsSection.tsx+msgid "Teaches coding agents in this project to read and write through OpenKnowledge."+msgstr "Teaches coding agents in this project to read and write through OpenKnowledge."+#: src/components/CreateProjectDialog.tsxmsgid "Team Wiki"msgstr "Team Wiki"@@ -7665,6 +7723,7 @@ msgid "What this changes"msgstr "What this changes"#: src/components/settings/AiToolsSection.tsx+#: src/components/settings/ProjectAiToolsSection.tsxmsgid "What this checkbox changes"msgstr "What this checkbox changes"diff --git a/packages/app/src/locales/pseudo/messages.json b/packages/app/src/locales/pseudo/messages.jsonindex 027f0dc2d..54739ec16 100644--- a/packages/app/src/locales/pseudo/messages.json+++ b/packages/app/src/locales/pseudo/messages.json@@ -527,6 +527,7 @@"CWzc2T": ["<0>~/.ōķ/ƀĩń</0> àńď <1>~/.ōķ/ēńv.śĥ</1> śţàŷ ēĩţĥēŕ ŵàŷ — ţĥē àƥƥ àĺŵàŷś ḿàĩńţàĩńś ţĥēḿ."],+ "CXTwen": ["Ćàń'ţ śàƒēĺŷ ēďĩţ ţĥĩś ƥŕōĴēćţ ćōńƒĩĝ"],"CXj9C-": ["Ńēŵ ƥŕōƥēŕţŷ ńàḿē"],"C_WGy8": ["Ţĥĩś ƒĩĺē ĩś ţōō ĺàŕĝē ţō ōƥēń ĩń ţĥē ƀũĩĺţ-ĩń ţēxţ ēďĩţōŕ (1 Ḿß ĺĩḿĩţ). Ũśē Ōƥēń ƒĩĺē ƀēĺōŵ ţō ōƥēń ĩţ ĩń àńōţĥēŕ àƥƥ."@@ -743,6 +744,7 @@"HM56Bx": ["Ćŕēàţĩńĝ..."],"HPTPGr": ["Ćŕēàţē à ńēŵ śƥēć ƒĩĺē ƒōŕ ḿŷ ũśēŕ śţōŕŷ"],"HSh8u_": ["Ƒōĺďēŕś"],+ "HTW0Zw": ["Ōńē ḿōŕē śţēƥ: ŕũń <0>ćĺàũďē</0> ĩń ţĥĩś ƥŕōĴēćţ àńď àƥƥŕōvē ŌƥēńĶńōŵĺēďĝē ōńćē."],"HXFyWD": ["Śƥĺĩţ ďĩƒƒ"],"HdkSiO": ["Ńēŵ ƒĩĺē"],"HfI1dR": ["Ĩ àĺŕēàďŷ ĥàvē ĩţ ĺōćàĺĺŷ →"],@@ -895,6 +897,7 @@"LpB85N": ["Ƥĺàĩń"],"LtI9AS": ["Ōŵńēŕ"],"LtSYdi": ["Ŕēvēàĺ ĩń Ƒĩńďēŕ"],+ "LtiJ5c": ["ƤŕōĴēćţ śķĩĺĺ"],"LuoJWu": [["truncatedShownCount",@@ -966,6 +969,9 @@"NIWAux": ["Ńō ďōćś ŕēĝĩśţēŕēď ũńďēŕ #", ["tagDocsName"], "."],"NJyQi_": ["ßŕàńćĥ ", ["shareBranch"], " ńō ĺōńĝēŕ ēxĩśţś ōń ţĥē ŕēḿōţē."],"NKkZXl": ["Ĩńĩţĩàĺĩźē àńď ōƥēń"],+ "NNJsn7": [+ "Ōńē ḿōŕē śţēƥ: ēńàƀĺē ĩţ ĩń Ćũŕśōŕ → Śēţţĩńĝś → Ţōōĺś & ḾĆƤ (Ćũŕśōŕ ĺēàvēś ƥŕōĴēćţ śēŕvēŕś ōƒƒ ũńţĩĺ ŷōũ ţũŕń ţĥēḿ ōń)."+ ],"NOHyEE": ["Ŕēţŕŷ ƥũśĥ"],"NORKZU": ["Ƥàţţēŕń ŵàŕńĩńĝś: ", ["summary"]],"NQ8llq": ["Àďď ĩţēḿ"],@@ -1413,6 +1419,9 @@"ZWwYwM": ["ßàśē ƀŕàńćĥ"],"ZWxfrc": ["ćĺēàŕēď ƒōĺďēŕ ƥŕōƥēŕţĩēś"],"ZWyHmq": ["Ţĥĩś ƥŕōĴēćţ"],+ "ZYtq3m": [+ "Ćōńńēćţ ţĥē ÀĨ ţōōĺś ŷōũ ũśē ţō ţĥĩś śƥēćĩƒĩć ƥŕōĴēćţ. Ţĥēśē ƒĩĺēś ĺĩvē ĩń ţĥē ƥŕōĴēćţ ƒōĺďēŕ, śō àńŷōńē ŵĥō ōƥēńś ĩţ ĝēţś ţĥē śàḿē śēţũƥ."+ ],"Zf0w-R": ["Ţàķē à ƥĩēćē ōƒ ŵŕĩţĩńĝ ƒŕōḿ à ŕōũĝĥ ĩďēà ţō à ƒĩńĩśĥēď ďŕàƒţ ţō śōḿēţĥĩńĝ ŷōũ'ŕē ŕēàďŷ ţō śĥàŕē. Ĝōōď ƒōŕ ƀĺōĝ ƥōśţś, ēśśàŷś, ōŕ àńŷţĥĩńĝ ŷōũ ŵàńţ ţō ḿōvē ţĥŕōũĝĥ ćĺēàŕ śţàĝēś."],@@ -1441,6 +1450,7 @@"</1>."],"_BthEY": ["Ōƥēń ĩń ", ["shareBranch"]],+ "_NX6gG": ["Ḿàńàĝĩńĝ ƥŕōĴēćţ ÀĨ ţōōĺś ĩś ũńàvàĩĺàƀĺē ĩń ţĥĩś ƀũĩĺď."],"_PACVa": ["Ŕēĺēàśē ńōţēś"],"_PBJRl": ["Àďď àţ ĺēàśţ ōńē ĺēţţēŕ ōŕ ńũḿƀēŕ."],"_QwkMu": ["Ńō ḿàţćĥĩńĝ ƥàţĥś"],@@ -1554,6 +1564,7 @@"cn1sLi": ["Ćōũĺďń'ţ ćōńńēćţ ŌƥēńĶńōŵĺēďĝē ţōōĺś ţō Ćĺàũďē Ćōďē. Ƥĺēàśē ţŕŷ àĝàĩń."],"cnGeoo": ["Ďēĺēţē"],"cqQyPB": ["Ƒōĺďēŕ ńàḿē"],+ "crqzW5": ["ÀĨ ţōōĺś"],"cs4mps": ["Ćōńƒĩĝ śĥàŕĩńĝ"],"csDS2L": ["Àvàĩĺàƀĺē"],"ct2kv5": ["Ńō ĥēàďĩńĝś ĩń ", ["pageTarget"]],@@ -1665,6 +1676,7 @@"fwhX-N": ["Ĩńďēńţ ōŕ ōũţďēńţ śōũŕćē"],"fxbCNQ": ["Śŷńćēď. Ţĥē ĺĩńķ ĩś ũƥ ţō ďàţē."],"g3UF2V": ["Àććēƥţ"],+ "g4WlQK": ["ƤŕōĴēćţ ÀĨ ţōōĺ ḿàńàĝēḿēńţ ĩś ōńĺŷ àvàĩĺàƀĺē ĩń ţĥē ŌƥēńĶńōŵĺēďĝē ďēśķţōƥ àƥƥ."],"g4XBm0": ["Śḿàĺĺ śēćţĩōń ĥēàďĩńĝ."],"g58Kwy": ["<",@@ -1867,6 +1879,7 @@"k_yIIc": ["Ŵĩĺĺ ƀē ćŕēàţēď àţ: <0>", ["targetPreview"], "</0>"],"kdzzOK": ["Ōƒƒ — śēàŕćĥ ŕàńķś ƀŷ ķēŷŵōŕď ōńĺŷ. Ńō ćōńţēńţ ĺēàvēś ţĥĩś ćōḿƥũţēŕ."],"keNFEd": ["Śēţ ĩďēńţĩţŷ"],+ "khCa4M": ["Ţēàćĥēś ćōďĩńĝ àĝēńţś ĩń ţĥĩś ƥŕōĴēćţ ţō ŕēàď àńď ŵŕĩţē ţĥŕōũĝĥ ŌƥēńĶńōŵĺēďĝē."],"kj9pAE": ["Ćŕēàţĩńĝ ƥàĝē"],"kknhfj": ["Ńō ćĥàńĝēś"],"kmKqZg": ["Ćĺũśţēŕś"],@@ -1969,6 +1982,9 @@"Àũţō-śŷńć ƥēŕĩōďĩćàĺĺŷ ƒēţćĥēś, ƥũĺĺś, àńď ƥũśĥēś ćōḿḿĩţś ţō ŷōũŕ ŕēḿōţē ĝĩţ ŕēƥōśĩţōŕŷ śō ŷōũŕ ēďĩţś śţàŷ ĩń śŷńć àćŕōśś ḿàćĥĩńēś."],"n7aopT": ["Ēďĩţōŕ ḿōďē"],+ "n8DwqQ": [+ "Ćōńńēćţś àũţōḿàţĩćàĺĺŷ ţĥē ńēxţ ţĩḿē ŷōũ ōƥēń ţĥĩś ƥŕōĴēćţ ĩń à ţŕũśţēď Ćōďēx śēśśĩōń."+ ],"nCzR-G": ["Ćōƥŷ ćōďē ", ["userCode"]],"nD7Fx9": ["Ţĥĩś ŕēƥĺàćēś ţĥē ćũŕŕēńţ śķĩĺĺ ćōńţēńţ ŵĩţĥ ţĥē ƀũńďĺēď vēŕśĩōń ",@@ -2410,6 +2426,7 @@"yYR6za": ["Ďĩśƥĺàŷ ţēxţ"],"yZmvQ4": ["Ţĥĩś ƥŕōĴēćţ'ś śēŕvēŕ (v", ["0"], ") ĩś ńēŵēŕ ţĥàń ţĥĩś àƥƥ (v", ["1"], ")."],"y_5CE8": ["Ĩţēḿ ", ["0"]],+ "yaPGPa": ["Ōƥēń à ƥŕōĴēćţ ţō ḿàńàĝē ĩţś ÀĨ ţōōĺ ćōńńēćţĩōńś."],"yf5r22": [["keyName"]," ţŷƥē: ",diff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.poindex 1330e8b34..e83517beb 100644--- a/packages/app/src/locales/pseudo/messages.po+++ b/packages/app/src/locales/pseudo/messages.po@@ -775,6 +775,11 @@ msgstr ""msgid "AI tool management is only available in the OpenKnowledge desktop app."msgstr ""+#: src/components/settings/ProjectAiToolsSection.tsx+#: src/components/settings/SettingsDialogShell.tsx+msgid "AI tools"+msgstr ""+#: src/components/settings/AiToolsSection.tsx#: src/components/settings/SettingsDialogShell.tsxmsgid "AI tools & CLI"@@ -1131,6 +1136,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/ProjectAiToolsSection.tsx+msgid "Can't safely edit this project config"+msgstr ""+#: src/components/settings/AiToolsSection.tsxmsgid "Can't safely edit this tool's config"msgstr ""@@ -1562,6 +1571,10 @@ msgstr ""msgid "Connect OpenKnowledge to other tools you use."msgstr ""+#: src/components/settings/ProjectAiToolsSection.tsx+msgid "Connect the AI tools you use to this specific project. These files live in the project folder, so anyone who opens it gets the same setup."+msgstr ""+#: src/components/FileSidebar.tsx#: src/components/FileTree.tsxmsgid "Connect this project to GitHub to share."@@ -1617,6 +1630,11 @@ msgstr ""msgid "Connection lost — keep this tab open, your edits will sync when reconnected"msgstr ""+#. Next step for a Codex project MCP row+#: src/components/settings/ProjectAiToolsSection.tsx+msgid "Connects automatically the next time you open this project in a trusted Codex session."+msgstr ""+#: src/components/ConsentDialogBody.tsxmsgid "Content directory"msgstr ""@@ -1845,6 +1863,7 @@ msgstr ""#. placeholder {0}: err instanceof Error ? err.message : String(err)#: src/components/settings/AiToolsSection.tsx+#: src/components/settings/ProjectAiToolsSection.tsxmsgid "Couldn't apply the change: {0}"msgstr ""@@ -2213,6 +2232,7 @@ msgid "Custom HTML with a live preview pane (sandboxed iframe)."msgstr ""#: src/components/settings/AiToolsSection.tsx+#: src/components/settings/ProjectAiToolsSection.tsxmsgid "Custom open-knowledge entry — not managed by OpenKnowledge"msgstr ""@@ -2746,6 +2766,7 @@ msgid "Enter a valid branch name (no spaces, no leading dot, no \"..\")."msgstr ""#: src/components/settings/AiToolsSection.tsx+#: src/components/settings/ProjectAiToolsSection.tsxmsgid "Entry"msgstr ""@@ -3052,6 +3073,7 @@ msgid "Fetching"msgstr ""#: src/components/settings/AiToolsSection.tsx+#: src/components/settings/ProjectAiToolsSection.tsx#: src/components/share-metadata-rows.tsx#: src/editor/slash-command/component-items.tsxmsgid "File"@@ -3203,6 +3225,7 @@ msgid "Folder target: {linkTitle}. Click to open the overview."msgstr ""#: src/components/settings/AiToolsSection.tsx+#: src/components/settings/ProjectAiToolsSection.tsxmsgid "Folders"msgstr ""@@ -3719,6 +3742,7 @@ msgid "Install skills into"msgstr ""#: src/components/settings/AiToolsSection.tsx+#: src/components/settings/ProjectAiToolsSection.tsx#: src/components/SkillEditorActions.tsx#: src/components/SkillRow.tsx#: src/components/SkillStateBadge.tsx@@ -4053,6 +4077,10 @@ msgstr ""msgid "Managing AI tools is unavailable in this build."msgstr ""+#: src/components/settings/ProjectAiToolsSection.tsx+msgid "Managing project AI tools is unavailable in this build."+msgstr ""+#: src/components/empty-state/use-create-suggestions.tsmsgid "Map the architecture"msgstr ""@@ -4074,9 +4102,11 @@ 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+#. Group label above the per-editor project MCP list in Settings → This project → AI tools#. 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+#: src/components/settings/ProjectAiToolsSection.tsxmsgid "MCP connections"msgstr ""@@ -4720,6 +4750,16 @@ msgstr ""msgid "On — your search queries and the text of matching pages are sent to your embeddings provider (OpenAI by default) to compute embeddings."msgstr ""+#. Next step for a Cursor project MCP row — Cursor leaves project servers disabled+#: src/components/settings/ProjectAiToolsSection.tsx+msgid "One more step: enable it in Cursor → Settings → Tools & MCP (Cursor leaves project servers off until you turn them on)."+msgstr ""++#. Next step for a Claude Code project MCP row+#: src/components/settings/ProjectAiToolsSection.tsx+msgid "One more step: run <0>claude</0> in this project and approve OpenKnowledge once."+msgstr ""+#: src/components/ConsentDialogBody.tsxmsgid "One pattern per line — appended to <0>.okignore</0>."msgstr ""@@ -4770,6 +4810,10 @@ msgstr ""msgid "Open a project to edit."msgstr ""+#: src/components/settings/ProjectAiToolsSection.tsx+msgid "Open a project to manage its AI tool connections."+msgstr ""+#: src/presence/PresenceBar.tsxmsgid "Open activity panel for {tooltipName}"msgstr ""@@ -5303,6 +5347,10 @@ msgstr ""msgid "Project"msgstr ""+#: src/components/settings/ProjectAiToolsSection.tsx+msgid "Project AI tool management is only available in the OpenKnowledge desktop app."+msgstr ""+#: src/components/CreateProjectDialog.tsxmsgid "Project folder created, but git init failed. Try again."msgstr ""@@ -5316,6 +5364,11 @@ msgstr ""msgid "Project root"msgstr ""+#. Group label above the project runtime-skill row in Settings → This project → AI tools+#: src/components/settings/ProjectAiToolsSection.tsx+msgid "Project skill"+msgstr ""+#: src/lib/skill-scope.tsmsgid "Project Skill"msgstr ""@@ -6751,6 +6804,11 @@ msgstr ""msgid "Teach agents a repeatable task. You can edit the body after creating."msgstr ""+#. Subtext for the project runtime-skill row+#: src/components/settings/ProjectAiToolsSection.tsx+msgid "Teaches coding agents in this project to read and write through OpenKnowledge."+msgstr ""+#: src/components/CreateProjectDialog.tsxmsgid "Team Wiki"msgstr ""@@ -7660,6 +7718,7 @@ msgid "What this changes"msgstr ""#: src/components/settings/AiToolsSection.tsx+#: src/components/settings/ProjectAiToolsSection.tsxmsgid "What this checkbox changes"msgstr ""diff --git a/packages/app/tests/stress/fixtures/handoff-mocks.ts b/packages/app/tests/stress/fixtures/handoff-mocks.tsindex 0ea374ffd..62f574057 100644--- a/packages/app/tests/stress/fixtures/handoff-mocks.ts+++ b/packages/app/tests/stress/fixtures/handoff-mocks.ts@@ -494,6 +494,26 @@ export async function installHandoffMocks(page: Page, cfg: HandoffMockConfig): P},}),},+ projectIntegrations: {+ status: async () => ({+ available: false,+ hasProject: false,+ projectDir: null,+ editors: [],+ skill: null,+ }),+ setComponent: async () => ({+ ok: false as const,+ error: 'unavailable in tests',+ status: {+ available: false,+ hasProject: false,+ projectDir: null,+ editors: [],+ skill: null,+ },+ }),+ },// installConsentListener + installOnboardingToastListener are// wired unconditionally by main.tsx (both guarded internally by// `if (!b.onboarding) return`), so these stubs run at thediff --git a/packages/cli/src/index.ts b/packages/cli/src/index.tsindex 81f1df637..100f27c35 100644--- a/packages/cli/src/index.ts+++ b/packages/cli/src/index.ts@@ -115,7 +115,15 @@ export {// Security-critical symlink-escape guard for project-scope writes. Re-exported// so the Desktop's skill-reclaim sweep shares the one canonical implementation// rather than duplicating it (precedent: single source of truth for guards).-export { assertProjectPathSafe } from './integrations/write-project-skill.ts';+// `removeProjectSkill` is the Settings-driven uninstall reverse of+// `writeProjectSkill` (which the Desktop reaches via `applyProjectIntegrations`).+export {+ assertProjectPathSafe,+ type ProjectSkillRemoveResult,+ type ProjectSkillResult,+ removeProjectSkill,+ writeProjectSkill,+} from './integrations/write-project-skill.ts';export {addOkPathsToGitExclude,type ExcludeWriteResult,diff --git a/packages/cli/src/integrations/remove-project-skill.test.ts b/packages/cli/src/integrations/remove-project-skill.test.tsnew file mode 100644index 000000000..8740bba64--- /dev/null+++ b/packages/cli/src/integrations/remove-project-skill.test.ts@@ -0,0 +1,91 @@+import { afterEach, beforeEach, describe, expect, test } from 'bun:test';+import { existsSync, mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { dirname, join } from 'node:path';+import { EDITOR_TARGETS } from '../commands/editors.ts';+import { removeProjectSkill } from './write-project-skill.ts';++const CLAUDE = EDITOR_TARGETS.claude;++describe('removeProjectSkill', () => {+ let dir: string;++ beforeEach(() => {+ dir = mkdtempSync(join(tmpdir(), 'ok-remove-project-skill-'));+ });+ afterEach(() => {+ rmSync(dir, { recursive: true, force: true });+ });++ /** Create the managed skill dir with its SKILL.md ownership marker. */+ function seedSkill(): string {+ const skillPath = CLAUDE.projectSkillPath?.(dir);+ if (!skillPath) throw new Error('claude has no projectSkillPath');+ mkdirSync(dirname(skillPath), { recursive: true });+ writeFileSync(skillPath, '# open-knowledge\n');+ return skillPath;+ }++ test('removes the managed skill directory whole', () => {+ const skillPath = seedSkill();+ const skillDir = dirname(skillPath);+ // A sibling file inside the OK-owned dir goes too — the dir is OK's namespace.+ writeFileSync(join(skillDir, 'reference.md'), 'x');+ expect(existsSync(skillPath)).toBe(true);++ const result = removeProjectSkill(CLAUDE, dir);++ expect(result.action).toBe('removed');+ expect(result.path).toBe(skillPath);+ expect(existsSync(skillDir)).toBe(false);+ });++ test('is idempotent — a second removal reports not-present', () => {+ seedSkill();+ expect(removeProjectSkill(CLAUDE, dir).action).toBe('removed');+ expect(removeProjectSkill(CLAUDE, dir).action).toBe('not-present');+ });++ test('leaves a directory without the SKILL.md ownership marker untouched', () => {+ const skillPath = CLAUDE.projectSkillPath?.(dir);+ if (!skillPath) throw new Error('claude has no projectSkillPath');+ const skillDir = dirname(skillPath);+ mkdirSync(skillDir, { recursive: true });+ // A directory squatting the name but with no managed SKILL.md is not ours.+ writeFileSync(join(skillDir, 'their-notes.md'), 'not ours');++ const result = removeProjectSkill(CLAUDE, dir);++ expect(result.action).toBe('not-present');+ expect(existsSync(skillDir)).toBe(true);+ expect(existsSync(join(skillDir, 'their-notes.md'))).toBe(true);+ });++ test('refuses to remove through a symlinked ancestor escaping the project', () => {+ // `.claude` is a symlink to an outside dir; the skill "exists" through it,+ // but removal must refuse rather than route rmSync outside the project.+ const outside = mkdtempSync(join(tmpdir(), 'ok-remove-project-skill-outside-'));+ try {+ const managed = join(outside, 'skills', 'open-knowledge');+ mkdirSync(managed, { recursive: true });+ writeFileSync(join(managed, 'SKILL.md'), '# open-knowledge\n');+ symlinkSync(outside, join(dir, '.claude'), 'dir');++ const result = removeProjectSkill(CLAUDE, dir);++ expect(result.action).toBe('failed');+ // The outside content is preserved — nothing was removed through the link.+ expect(existsSync(join(managed, 'SKILL.md'))).toBe(true);+ } finally {+ rmSync(outside, { recursive: true, force: true });+ }+ });++ test('reports skipped-unsupported for an editor with no project skill path', () => {+ const noSkill = EDITOR_TARGETS['claude-desktop'];+ expect(noSkill.projectSkillPath).toBeUndefined();+ const result = removeProjectSkill(noSkill, dir);+ expect(result.action).toBe('skipped-unsupported');+ expect(result.path).toBe('');+ });+});diff --git a/packages/cli/src/integrations/write-project-skill.ts b/packages/cli/src/integrations/write-project-skill.tsindex 25af3e095..82113eef5 100644--- a/packages/cli/src/integrations/write-project-skill.ts+++ b/packages/cli/src/integrations/write-project-skill.ts@@ -133,3 +133,70 @@ export function writeProjectSkill(target: EditorMcpTarget, cwd: string): Project};}}++// ---------------------------------------------------------------------------+// Project-local skill uninstaller+// ---------------------------------------------------------------------------++export interface ProjectSkillRemoveResult {+ readonly editorId: EditorId;+ readonly label: string;+ readonly action: 'removed' | 'not-present' | 'skipped-unsupported' | 'failed';+ readonly path: string;+ readonly error?: string;+}++/**+ * Targeted uninstall of the project-local runtime skill — the reverse of+ * `writeProjectSkill`, for the Settings-driven per-component toggle.+ *+ * OpenKnowledge owns the whole `<host>/skills/open-knowledge/` directory (the+ * write path `cpSync`s the bundle into it wholesale), so removal is+ * whole-directory. The presence of the managed `SKILL.md` at+ * `projectSkillPath` is the ownership marker: a directory at the managed path+ * WITHOUT it is not something OK authored and is left untouched+ * (`not-present`). The same symlink-escape guard the write path uses runs+ * before the `rmSync`, so a symlinked ancestor (`.claude -> /etc`) can never+ * route the recursive removal outside the project tree.+ */+export function removeProjectSkill(target: EditorMcpTarget, cwd: string): ProjectSkillRemoveResult {+ const skillPath = target.projectSkillPath?.(cwd);+ if (!skillPath) {+ return {+ editorId: target.id,+ label: target.label,+ action: 'skipped-unsupported',+ path: '',+ };+ }+ try {+ const targetDir = dirname(skillPath);+ // No managed SKILL.md at the path → nothing of ours to remove. Idempotent+ // re-run and "a foreign directory squatting the name" both land here.+ if (!existsSync(skillPath)) {+ return {+ editorId: target.id,+ label: target.label,+ action: 'not-present',+ path: skillPath,+ };+ }+ // Refuse before `rmSync` runs, exactly as the write path does.+ assertProjectPathSafe(targetDir, cwd);+ rmSync(targetDir, { recursive: true, force: true });+ return {+ editorId: target.id,+ label: target.label,+ action: 'removed',+ path: skillPath,+ };+ } catch (err) {+ return {+ editorId: target.id,+ label: target.label,+ action: 'failed',+ path: skillPath,+ error: err instanceof Error ? err.message : String(err),+ };+ }+}diff --git a/packages/core/src/bridge/bind-frontmatter-doc.ts b/packages/core/src/bridge/bind-frontmatter-doc.tsindex 8f9d95287..c014b1413 100644--- a/packages/core/src/bridge/bind-frontmatter-doc.ts+++ b/packages/core/src/bridge/bind-frontmatter-doc.ts@@ -1,4 +1,3 @@-import type * as Y from 'yjs';import type { Err, Ok, Result } from '../config/result.ts';import { type FrontmatterValidationError, toFrontmatterIssue } from '../frontmatter/errors.ts';diff --git a/packages/core/src/bridge/bridge-invariant.ts b/packages/core/src/bridge/bridge-invariant.tsindex 8bfdb40cd..005627195 100644--- a/packages/core/src/bridge/bridge-invariant.ts+++ b/packages/core/src/bridge/bridge-invariant.ts@@ -1,4 +1,3 @@-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.tsindex c18c086d5..8890f6739 100644--- a/packages/core/src/bridge/doc-boundary-space.ts+++ b/packages/core/src/bridge/doc-boundary-space.ts@@ -1,4 +1,3 @@-import { FRONTMATTER_RE, stripFrontmatter } from '../extensions/frontmatter.ts';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.tsindex 864bc7245..b0a80fbd9 100644--- a/packages/core/src/bridge/merge-three-way.ts+++ b/packages/core/src/bridge/merge-three-way.ts@@ -37,7 +37,6 @@ function mergeThreeWayImpl(baseline: string, userText: string, agentText: stringreturn 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.tsindex 592f0b956..e67f33b40 100644--- a/packages/core/src/bridge/normalize.ts+++ b/packages/core/src/bridge/normalize.ts@@ -1,4 +1,3 @@-const COMMONMARK_ESCAPE_RE = /\\([!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~])/g;const TABLE_ALIGN_ROW_RE = /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/;diff --git a/packages/core/src/bridge/pm-structural-equivalence.ts b/packages/core/src/bridge/pm-structural-equivalence.tsindex 0be5203e4..754dc5cc2 100644--- a/packages/core/src/bridge/pm-structural-equivalence.ts+++ b/packages/core/src/bridge/pm-structural-equivalence.ts@@ -32,7 +32,6 @@ const BR_SENTINEL: PmStructuralNode = { type: '__br__' };const BR_LITERAL_RE = /^<br\s*\/?>$/i;-interface DegradeEntry {readonly label: string;readonly severity: ToleranceClassSeverity;@@ -128,7 +127,6 @@ export interface ComparePmStructuralOptions {ignoreAttrs?: (attrKey: string) => boolean;}-/** Rebuild a node with `fn` applied to each child; identity when childless.* Shared by the degrade canonicalizers so none re-implements the walk. */function mapChildren(@@ -250,7 +248,6 @@ function applyDegrades(tree: PmStructuralNode): {return { normalized: current, fired };}-export function comparePmStructural(expected: PmStructuralNode,actual: PmStructuralNode,diff --git a/packages/core/src/bridge/subsequence.ts b/packages/core/src/bridge/subsequence.tsindex dca644141..af20de1e2 100644--- a/packages/core/src/bridge/subsequence.ts+++ b/packages/core/src/bridge/subsequence.ts@@ -1,4 +1,3 @@-/** True when `needle` is a subsequence of `haystack` (two-pointer, O(n+m)):* insertions in `haystack` are free; any dropped or substituted `needle` byte* fails. */diff --git a/packages/core/src/desktop-bridge.ts b/packages/core/src/desktop-bridge.tsindex b914f7af0..29e345677 100644--- a/packages/core/src/desktop-bridge.ts+++ b/packages/core/src/desktop-bridge.ts@@ -470,6 +470,47 @@ type OkIntegrationsSetResult =| { readonly ok: true; readonly status: OkIntegrationsStatus }| { readonly ok: false; readonly error: string; readonly status: OkIntegrationsStatus };+/** Post-install manual step a project MCP config needs before OK's tools+ * connect: `approve-once` (Claude Code), `enable-manually` (Cursor, silently+ * disabled until toggled), `auto-connect` (Codex on a trusted project),+ * `none`. */+type OkProjectIntegrationsFollowUp = 'approve-once' | 'enable-manually' | 'auto-connect' | 'none';++/** Component inventory for Settings → This project → AI tools (per-editor+ * PROJECT MCP config files + the single project runtime skill), scoped to the+ * project the requesting window has open. `hasProject: false` → empty state;+ * `available: false` → read-only. */+interface OkProjectIntegrationsStatus {+ readonly available: boolean;+ readonly hasProject: boolean;+ readonly projectDir: string | null;+ readonly editors: readonly {+ readonly id: OkMcpWiringEditorId;+ readonly label: string;+ readonly state: OkIntegrationsEditorState;+ readonly configPath: string;+ readonly entryLocator: string;+ readonly followUp: OkProjectIntegrationsFollowUp;+ }[];+ readonly skill: {+ readonly installed: boolean;+ readonly paths: readonly string[];+ } | null;+}++/** One toggle for `projectIntegrations.setComponent`. The skill is a single+ * row (no id) — it fans out across every capable editor. */+interface OkProjectIntegrationsSetRequest {+ readonly component:+ | { readonly kind: 'editor'; readonly id: OkMcpWiringEditorId }+ | { readonly kind: 'skill' };+ readonly enabled: boolean;+}++type OkProjectIntegrationsSetResult =+ | { readonly ok: true; readonly status: OkProjectIntegrationsStatus }+ | { readonly ok: false; readonly error: string; readonly status: OkProjectIntegrationsStatus };+/*** Per-project consent dialog — renderer-facing payload + result shapes.* Mirrors the desktop and app copies; drift caught by the@@ -1379,6 +1420,17 @@ export interface OkDesktopBridge {setComponent(request: OkIntegrationsSetRequest): Promise<OkIntegrationsSetResult>;};+ /**+ * Settings → This project → AI tools: live per-component install state ++ * one-component install/uninstall for OK's PROJECT-LOCAL footprint (per-editor+ * project MCP config files + the project runtime skill) against the project+ * the requesting window has open. Mutations serialize in main.+ */+ projectIntegrations: {+ status(): Promise<OkProjectIntegrationsStatus>;+ setComponent(request: OkProjectIntegrationsSetRequest): Promise<OkProjectIntegrationsSetResult>;+ };+/*** Per-project consent dialog surface. Navigator-only.* Renderer mounts a shadcn Dialog when `onShow` fires; callsdiff --git a/packages/core/src/markdown/callout-transformer.ts b/packages/core/src/markdown/callout-transformer.tsindex a363dfd54..83d47404a 100644--- a/packages/core/src/markdown/callout-transformer.ts+++ b/packages/core/src/markdown/callout-transformer.ts@@ -1,4 +1,3 @@-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.tsindex 47f0d07e4..193e286b0 100644--- a/packages/core/src/markdown/comment-promoter.ts+++ b/packages/core/src/markdown/comment-promoter.ts@@ -1,4 +1,3 @@-import type { Nodes, Paragraph, PhrasingContent, Root, RootContent, Text } from 'mdast';import { SKIP, visit } from 'unist-util-visit';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/dedent-block-jsx-close.ts b/packages/core/src/markdown/dedent-block-jsx-close.tsindex b6299a948..ece5c02a1 100644--- a/packages/core/src/markdown/dedent-block-jsx-close.ts+++ b/packages/core/src/markdown/dedent-block-jsx-close.ts@@ -1,4 +1,3 @@-import { findFencedRegions, isInsideFence } from './fence-regions.ts';const INDENTED_BLOCK_JSX_CLOSE_RE = /^([ ]{1,3})(<\/[A-Z][A-Za-z0-9_]*\s*>)([ \t]*)$/gm;diff --git a/packages/core/src/markdown/details-accordion-promoter.ts b/packages/core/src/markdown/details-accordion-promoter.tsindex acd398aa6..54774764a 100644--- a/packages/core/src/markdown/details-accordion-promoter.ts+++ b/packages/core/src/markdown/details-accordion-promoter.ts@@ -1,4 +1,3 @@-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.tsindex fb5ac8e8a..c7518d614 100644--- a/packages/core/src/markdown/fence-regions.ts+++ b/packages/core/src/markdown/fence-regions.ts@@ -1,4 +1,3 @@-const FENCE_RE = /^(`{3,}|~{3,})/gm;export function findFencedRegions(src: string): Array<[number, number]> {diff --git a/packages/core/src/markdown/fixtures/index.ts b/packages/core/src/markdown/fixtures/index.tsindex 6931623c7..00f5771ee 100644--- a/packages/core/src/markdown/fixtures/index.ts+++ b/packages/core/src/markdown/fixtures/index.ts@@ -1,4 +1,3 @@-import { readFileSync } from 'node:fs';import { dirname, resolve } from 'node:path';import { fileURLToPath } from 'node:url';@@ -9,7 +8,6 @@ function fixturePath(...segments: string[]): string {return resolve(FIXTURES_DIR, ...segments);}-interface GfmExample {section: string;markdown: string;@@ -19,7 +17,6 @@ export function loadGfmExamples(): GfmExample[] {return JSON.parse(readFileSync(fixturePath('gfm', 'examples.json'), 'utf8')) as GfmExample[];}-interface MdxCrashEntry {id: string;input: string;@@ -71,7 +68,6 @@ export function loadLargeEmbedFixtures(): LargeEmbedFixture[] {) as LargeEmbedFixture[];}-export function loadPrd6955Before(): string {return readFileSync(fixturePath('regression', 'prd-6955-before.md'), 'utf8');}@@ -80,7 +76,6 @@ export function loadPrd6955CorruptedTriplicated(): string {return readFileSync(fixturePath('regression', 'prd-6955-corrupted-triplicated.md'), 'utf8');}-export interface NgPinnedCase {id: string;name: string;@@ -97,7 +92,6 @@ export function loadNgPinnedCases(): NgPinnedCase[] {) as NgPinnedCase[];}-export function loadLargeRealistic(): string {return readFileSync(fixturePath('perf', 'large-realistic.md'), 'utf8');}diff --git a/packages/core/src/markdown/fixtures/perf/generate.ts b/packages/core/src/markdown/fixtures/perf/generate.tsindex daa3ef82b..8b1eb8519 100644--- a/packages/core/src/markdown/fixtures/perf/generate.ts+++ b/packages/core/src/markdown/fixtures/perf/generate.ts@@ -1,4 +1,3 @@-import { writeFileSync } from 'node:fs';import { dirname, resolve } from 'node:path';import { fileURLToPath } from 'node:url';@@ -11,7 +10,6 @@ const BASELINE_ONLY_COUNTS = [500, 2500] as const;const SEED = 0xf1de1117;-function mulberry32(seed: number): () => number {let a = seed >>> 0;return () => {@@ -38,7 +36,6 @@ function pickWeighted<T>(rand: () => number, items: readonly [T, number][]): T {return items[items.length - 1][0];}-const WORDS = ['lorem','ipsum',@@ -156,7 +153,6 @@ 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][] = [@@ -195,7 +191,6 @@ function generateDocument(blockCount: number, seed: number): string {return `${blocks.join('\n\n')}\n`;}-function main(): void {for (const count of [...BLOCK_COUNTS, ...BASELINE_ONLY_COUNTS]) {const doc = generateDocument(count, SEED);diff --git a/packages/core/src/markdown/guard-flanking-matrix.ts b/packages/core/src/markdown/guard-flanking-matrix.tsindex 32c055c5b..420dc0fe5 100644--- a/packages/core/src/markdown/guard-flanking-matrix.ts+++ b/packages/core/src/markdown/guard-flanking-matrix.ts@@ -7,7 +7,6 @@ import {import { BACKSLASH_GUARD_SUBSTITUTIONS, encodeBackslashEscapes } from './backslash-escape-guard.ts';import { ENTITY_REF_GUARD_SUBSTITUTIONS, encodeEntityRefs } from './entity-ref-guard.ts';-export const ATTENTION_DELIMITERS = ['*', '_', '**', '~~', '=='] as const;export type FlankClass = 'whitespace' | 'punctuation' | 'other';diff --git a/packages/core/src/markdown/handler-shadow-audit.ts b/packages/core/src/markdown/handler-shadow-audit.tsindex 283913255..2653473da 100644--- a/packages/core/src/markdown/handler-shadow-audit.ts+++ b/packages/core/src/markdown/handler-shadow-audit.ts@@ -1,4 +1,3 @@-export interface HandlerShadowWitness {input: string;expect: 'byte' | 'byte-and-reparse-type';diff --git a/packages/core/src/markdown/highlight-promoter.ts b/packages/core/src/markdown/highlight-promoter.tsindex 7a22e8016..f758cf737 100644--- a/packages/core/src/markdown/highlight-promoter.ts+++ b/packages/core/src/markdown/highlight-promoter.ts@@ -1,4 +1,3 @@-import type { Nodes, Parent, PhrasingContent, Root, Text } from 'mdast';import type { MdxJsxTextElement } from 'mdast-util-mdx';import { SKIP, visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/html-to-mdast.ts b/packages/core/src/markdown/html-to-mdast.tsindex 2f082e6d0..78fdfeb02 100644--- a/packages/core/src/markdown/html-to-mdast.ts+++ b/packages/core/src/markdown/html-to-mdast.ts@@ -1,4 +1,3 @@-import type { Root as HastRoot } from 'hast';import type { Root as MdastRoot } from 'mdast';import rehypeParse from 'rehype-parse';@@ -76,8 +75,7 @@ export function htmlToMdast(html: string, options?: HtmlToMdastOptions): MdastRothrow new HtmlPayloadTooLargeError(html.length, maxBytes);}- const processor = unified()- .use(rehypeParse, { fragment: true });+ const processor = unified().use(rehypeParse, { fragment: true });for (const plugin of cleanupPlugins) {processor.use(plugin);diff --git a/packages/core/src/markdown/image-promoter.ts b/packages/core/src/markdown/image-promoter.tsindex 994eb6917..706fa9afb 100644--- a/packages/core/src/markdown/image-promoter.ts+++ b/packages/core/src/markdown/image-promoter.ts@@ -1,4 +1,3 @@-import type { Image, Paragraph, Root } from 'mdast';import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/index.ts b/packages/core/src/markdown/index.tsindex c58d0847d..58be35302 100644--- a/packages/core/src/markdown/index.ts+++ b/packages/core/src/markdown/index.ts@@ -1,4 +1,3 @@-import {type FromProseMirrorOptions,fromPmMark,@@ -197,7 +196,6 @@ export class MarkdownManager {}}-const registry = createRegistry();function destructureAttrs(@@ -246,7 +244,6 @@ function destructureAttrs(return result;}-function hasDirtyDescendant(node: PmNode): boolean {let found = false;node.descendants((child) => {@@ -266,7 +263,6 @@ function effectiveDirty(node: PmNode, freshnessChecker?: StructuralFreshnessChecreturn freshnessChecker ? freshnessChecker.isDiverged(node.toJSON()) : false;}-function isEmptyMdastParagraph(node: MdastNodes): boolean {if (node.type !== 'paragraph') return false;const children = node.children ?? [];@@ -335,7 +331,6 @@ function extractTextFromMdastNodes(nodes: MdastNodes[]): string {return out;}-import {AUDIO_EXTENSIONS,FILE_ATTACHMENT_EXTENSIONS,@@ -585,7 +580,6 @@ function buildMdastToPmHandlers(}));}-if (m.emphasis) {handlers.emphasis = toPmMark(m.emphasis, (node: Emphasis) => ({sourceDelimiter: node.data?.sourceDelimiter ?? '*',@@ -665,7 +659,6 @@ function buildMdastToPmHandlers(}));}-if (m.link) {const sourceLiteralMark = m.sourceLiteral;handlers.link = (node: Link, _parent: MdastParent, state: MdastToPmState) => {@@ -944,7 +937,6 @@ function buildMdastToPmHandlers(};}-const blockUnknownHandler = (node: {type: string;position?: { start: { offset: number }; end: { offset: number } };@@ -1070,7 +1062,6 @@ function buildMdastToPmHandlers(return handlers as RemarkProseMirrorOptions['handlers'];}-function buildPmToMdastHandlers(schema: Schema,freshness: FreshnessCheckerHolder,diff --git a/packages/core/src/markdown/math-promoter.ts b/packages/core/src/markdown/math-promoter.tsindex bd79424c7..a5b511f25 100644--- a/packages/core/src/markdown/math-promoter.ts+++ b/packages/core/src/markdown/math-promoter.ts@@ -1,4 +1,3 @@-import type { Code, Root } from 'mdast';import type { Math as MdastMath } from 'mdast-util-math';import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';diff --git a/packages/core/src/markdown/mdast-to-hast-handlers.ts b/packages/core/src/markdown/mdast-to-hast-handlers.tsindex f84967798..679c72ef7 100644--- a/packages/core/src/markdown/mdast-to-hast-handlers.ts+++ b/packages/core/src/markdown/mdast-to-hast-handlers.ts@@ -1,4 +1,3 @@-import type { Comment, Element, ElementContent, Properties } from 'hast';import type { FootnoteDefinition, FootnoteReference } from 'mdast';import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx';diff --git a/packages/core/src/markdown/mdast-to-html.ts b/packages/core/src/markdown/mdast-to-html.tsindex df788a80d..8ce2b2492 100644--- a/packages/core/src/markdown/mdast-to-html.ts+++ b/packages/core/src/markdown/mdast-to-html.ts@@ -1,4 +1,3 @@-import type { Element, Root as HastRoot, Text as HastText } from 'hast';import type { Root as MdastRoot, Text as MdastText } from 'mdast';import type { Handler } from 'mdast-util-to-hast';diff --git a/packages/core/src/markdown/merged-walker.ts b/packages/core/src/markdown/merged-walker.tsindex a58f8c720..35d74b85e 100644--- a/packages/core/src/markdown/merged-walker.ts+++ b/packages/core/src/markdown/merged-walker.ts@@ -1,4 +1,3 @@-import type { Nodes, Parent, Root } from 'mdast';import { SKIP, visit } from 'unist-util-visit';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/mermaid-promoter.ts b/packages/core/src/markdown/mermaid-promoter.tsindex 17ed2b829..1a897fca8 100644--- a/packages/core/src/markdown/mermaid-promoter.ts+++ b/packages/core/src/markdown/mermaid-promoter.ts@@ -1,4 +1,3 @@-import type { Code, Root } from 'mdast';import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/parse-with-fallback.ts b/packages/core/src/markdown/parse-with-fallback.tsindex 7e4a9a48b..9864b3b60 100644--- a/packages/core/src/markdown/parse-with-fallback.ts+++ b/packages/core/src/markdown/parse-with-fallback.ts@@ -168,7 +168,6 @@ export function parseRecursive(}}-interface VFilePlace {offset?: number;start?: { offset?: number };@@ -187,7 +186,6 @@ function extractErrorOffset(err: unknown): number | undefined {return undefined;}-interface Region {start: number;end: number;@@ -211,7 +209,6 @@ function nearestBlankLineAfter(src: string, offset: number): number | null {return null;}-export interface TagEvent {kind: 'open' | 'close' | 'self-close';name: string;@@ -358,7 +355,6 @@ function findFallbackRegion(src: string, errorOffset: number): Region {return { start: blockStart, end: blockEnd };}-interface SourceBlock {src: string;start: number;@@ -456,7 +452,6 @@ function tryPerBlockFallback(};}-function wholeDocRawText(source: string): JSONContent {return {type: 'doc',diff --git a/packages/core/src/markdown/parser-drop-closure.ts b/packages/core/src/markdown/parser-drop-closure.tsindex 43d420187..e6ab4fd57 100644--- a/packages/core/src/markdown/parser-drop-closure.ts+++ b/packages/core/src/markdown/parser-drop-closure.ts@@ -1,4 +1,3 @@-export type DroppedTokenAdjudication =| {kind: 'format-dof-axis';diff --git a/packages/core/src/markdown/pipeline.ts b/packages/core/src/markdown/pipeline.tsindex 5b9550e90..5d6db7aa8 100644--- a/packages/core/src/markdown/pipeline.ts+++ b/packages/core/src/markdown/pipeline.ts@@ -1,4 +1,3 @@-import {type FromProseMirrorOptions,fromProseMirror,diff --git a/packages/core/src/markdown/position-aware-join.ts b/packages/core/src/markdown/position-aware-join.tsindex 4ac5731e7..248685cfe 100644--- a/packages/core/src/markdown/position-aware-join.ts+++ b/packages/core/src/markdown/position-aware-join.ts@@ -1,4 +1,3 @@-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.tsindex 240be90e6..50a193a16 100644--- a/packages/core/src/markdown/position-slice.ts+++ b/packages/core/src/markdown/position-slice.ts@@ -1,4 +1,3 @@-import type { Nodes, Root } from 'mdast';import { visit } from 'unist-util-visit';import type { VFile } from 'vfile';@@ -467,8 +466,7 @@ export function applyPositionSliceToNode(const first = source[startOff];if (first !== '[' && first !== '<' && !node.title) {node.data.sourceStyle = 'gfm-autolink';- }- else if (first === '[') {+ } else if (first === '[') {const slice = source.slice(startOff, endOff);const closeBracketIdx = slice.lastIndexOf('](');if (closeBracketIdx !== -1) {diff --git a/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts b/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.tsindex ca225ce9b..db10fa54b 100644--- a/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts+++ b/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts@@ -1,4 +1,3 @@-import type { Comment, Element, Root, Text } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts b/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.tsindex 3a2524a9a..34068d103 100644--- a/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts@@ -1,4 +1,3 @@-import type { Element, ElementContent, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts b/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.tsindex 2279a0189..93151d43b 100644--- a/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts@@ -1,4 +1,3 @@-import type { Element, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts b/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.tsindex a0f467c42..188f02d83 100644--- a/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts@@ -1,4 +1,3 @@-import type { Element, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts b/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.tsindex 4e8542a21..4ba2c3418 100644--- a/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts@@ -1,4 +1,3 @@-import type { Element, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts b/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.tsindex a3c96b24a..1a74b1272 100644--- a/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts@@ -1,4 +1,3 @@-import type { Element, ElementContent, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts b/packages/core/src/markdown/rehype-plugins/strip-mso-styles.tsindex e95cf43d6..de35e7b79 100644--- a/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts@@ -1,4 +1,3 @@-import type { Comment, Element, ElementContent, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts b/packages/core/src/markdown/rehype-plugins/strip-slack-classes.tsindex ffdb4d5b5..b4be1b2ea 100644--- a/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts@@ -1,4 +1,3 @@-import type { Element, ElementContent, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts b/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.tsindex e2a96d1a7..3c8d88b7c 100644--- a/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts@@ -1,4 +1,3 @@-import type { Element, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/resolve-image-url.ts b/packages/core/src/markdown/resolve-image-url.tsindex 0389575ac..cf2c9da8e 100644--- a/packages/core/src/markdown/resolve-image-url.ts+++ b/packages/core/src/markdown/resolve-image-url.ts@@ -1,4 +1,3 @@-import { isRelativeUrl } from './safe-url.ts';function isDevDiagnosticContext(): boolean {diff --git a/packages/core/src/markdown/safe-url.ts b/packages/core/src/markdown/safe-url.tsindex 8be632ba4..4d3250d3a 100644--- a/packages/core/src/markdown/safe-url.ts+++ b/packages/core/src/markdown/safe-url.ts@@ -1,4 +1,3 @@-export const SAFE_URL_SCHEMES = ['https', 'http', 'mailto', 'tel', 'ftp', 'sms'] as const;const SCHEME_ALT = SAFE_URL_SCHEMES.map((s) => `${s}:`).join('|');diff --git a/packages/core/src/markdown/serialize-helpers.ts b/packages/core/src/markdown/serialize-helpers.tsindex 542204403..46cc6a074 100644--- a/packages/core/src/markdown/serialize-helpers.ts+++ b/packages/core/src/markdown/serialize-helpers.ts@@ -1,4 +1,3 @@-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.tsindex fe73659e6..be97d4d62 100644--- a/packages/core/src/markdown/single-dollar-math-promoter.ts+++ b/packages/core/src/markdown/single-dollar-math-promoter.ts@@ -1,4 +1,3 @@-import type { PhrasingContent, Root, Text } from 'mdast';import type { InlineMath } from 'mdast-util-math';import { SKIP, visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/to-markdown-handlers.ts b/packages/core/src/markdown/to-markdown-handlers.tsindex e1161455b..1a2fb5d50 100644--- a/packages/core/src/markdown/to-markdown-handlers.ts+++ b/packages/core/src/markdown/to-markdown-handlers.ts@@ -1,4 +1,3 @@-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.tsindex c5bfd2386..cd245c38c 100644--- a/packages/core/src/markdown/unknown-mdast-guard.ts+++ b/packages/core/src/markdown/unknown-mdast-guard.ts@@ -1,4 +1,3 @@-import type { Root as MdastRoot } from 'mdast';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/whitespace-char-ref.ts b/packages/core/src/markdown/whitespace-char-ref.tsindex 1b75ba564..a100cad76 100644--- a/packages/core/src/markdown/whitespace-char-ref.ts+++ b/packages/core/src/markdown/whitespace-char-ref.ts@@ -1,4 +1,3 @@-const INLINE_WHITESPACE_BY_CODE: ReadonlyMap<number, string> = new Map([[0x20, ' '],[0x09, '\t'],diff --git a/packages/core/src/markdown/wiki-link-micromark.ts b/packages/core/src/markdown/wiki-link-micromark.tsindex afd9936fe..6dad26200 100644--- a/packages/core/src/markdown/wiki-link-micromark.ts+++ b/packages/core/src/markdown/wiki-link-micromark.ts@@ -17,7 +17,6 @@ declare module 'micromark-util-types' {}}-const CODE_BANG = 33; // !const CODE_LBRACKET = 91; // [const CODE_RBRACKET = 93; // ]@@ -261,7 +260,6 @@ export function wikiLinkSyntax(): Extension {};}-function enterWikiLink(this: CompileContext, token: Token) {this.enter({@@ -387,7 +385,6 @@ 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.tsindex 31ae6b21f..444af11a6 100644--- a/packages/desktop/src/main/index.ts+++ b/packages/desktop/src/main/index.ts@@ -56,12 +56,14 @@ import {previewContent,readExistingMcpEntry,removeOwnMcpEntry,+ removeProjectSkill,removeUserGlobalSkillBundle,runStop,type TrackedRefusal,validateLocalFolderForShare,writeEditorMcpConfig,writeProjectAiIntegrations,+ writeProjectSkill,writeUserMcpConfigs,} from '@inkeep/open-knowledge';import {@@ -233,6 +235,10 @@ import {removePathShimFromRcFiles,} from './path-install.ts';import { installStdioBrokenPipeGuard } from './process-safety-net.ts';+import {+ type ProjectIntegrationsCliSurface,+ registerProjectIntegrationsSettings,+} from './project-integrations-settings.ts';import {checkAndRepairProjectMcpOnProjectOpen,type ProjectMcpReclaimCliSurface,@@ -3882,6 +3888,7 @@ function registerIpcHandlers() {});registerIntegrationsSettingsIpc();+ registerProjectIntegrationsSettingsIpc();}/**@@ -3909,7 +3916,11 @@ function registerIntegrationsSettingsIpc(): void {available,ipcMain,cli: {- allEditorIds: ALL_EDITOR_IDS,+ // User-global surface only: `scope: 'project'` targets (Pi) have no+ // user-global MCP config to manage — their `configPath()` throws — so+ // they must not surface as a row here, mirroring the consent dialog's+ // and startup repair sweep's scope filter in `mcp-wiring.ts`.+ allEditorIds: ALL_EDITOR_IDS.filter((id) => EDITOR_TARGETS[id].scope === 'global'),editorLabel: (editorId) => EDITOR_TARGETS[editorId].label,detectInstalledEditors: (cwd, home) => detectInstalledEditors(cwd, home),classifyExistingMcpEntry: (editorId, home) =>@@ -4049,6 +4060,104 @@ function registerIntegrationsSettingsIpc(): void {});}+/**+ * Settings → This project → AI tools: persistent status/toggle IPC over the+ * same PROJECT-LOCAL install actors as the per-project onboarding dialog and+ * the reclaim-on-open sweep — `writeEditorMcpConfig` / `removeOwnMcpEntry` with+ * a project config-path override for the per-editor MCP files, and+ * `writeProjectSkill` / `removeProjectSkill` for the project runtime skill.+ * Every request resolves the sender window's project (webContents →+ * ProjectContext) so the renderer can never target a foreign directory.+ * `available` mirrors the global surface's gate set.+ */+function registerProjectIntegrationsSettingsIpc(): void {+ const projectLogger = getLogger('project-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;+ };+ // The canonical project skill lives under Claude Code's `.claude/skills/`; its+ // presence is the single row's checked state (the write fans out to every+ // capable editor, but the `.claude` copy is the one the discovery skill and+ // CLAUDE.md reference).+ const canonicalSkillTarget = EDITOR_TARGETS.claude;+ const projectInstallOpts: McpInstallOptions = { mode: 'published', skipAvailabilityCheck: true };++ const cli: ProjectIntegrationsCliSurface = {+ allEditorIds: ALL_EDITOR_IDS,+ editorLabel: (id) => EDITOR_TARGETS[id].label,+ projectConfigPath: (id, projectDir) =>+ EDITOR_TARGETS[id].projectConfigPath?.(projectDir) ?? null,+ projectSkillPath: (id, projectDir) => EDITOR_TARGETS[id].projectSkillPath?.(projectDir) ?? null,+ entryLocator: (id) => {+ const target = EDITOR_TARGETS[id];+ // `format: 'file'` targets (Pi) own a whole managed file, not a keyed+ // entry — there is no dotted/table locator to show.+ if (target.format === 'file') return 'open-knowledge (managed extension file)';+ const server = target.serverName('');+ return target.format === 'toml'+ ? `[${target.topLevelKey}.${server}]`+ : [target.topLevelKey, target.serverMapSubKey, server].filter(Boolean).join('.');+ },+ classifyExistingProjectMcpConfig: (id, projectDir, projectPath) =>+ classifyExistingMcpEntry(EDITOR_TARGETS[id], projectDir, undefined, projectPath),+ isOwnEntry: (entry) => isEntryUpToDate(entry) || isOwnManagedEntry(entry),+ writeProjectMcpConfig: ({ id, projectDir, projectPath }) => {+ const result = writeEditorMcpConfig(+ EDITOR_TARGETS[id],+ projectDir,+ projectInstallOpts,+ undefined,+ projectPath,+ );+ if (result.action === 'written' || result.action === 'overwritten') {+ return { action: result.action };+ }+ if (result.action === 'declined') {+ return { action: 'declined', reason: result.declineReason };+ }+ return { action: 'failed', error: result.error };+ },+ removeProjectMcpEntry: (id, projectDir, projectPath) =>+ removeOwnMcpEntry(EDITOR_TARGETS[id], projectDir, undefined, projectPath),+ isProjectSkillInstalled: (projectDir) => {+ const skillPath = canonicalSkillTarget.projectSkillPath?.(projectDir);+ return skillPath !== undefined && existsSync(skillPath);+ },+ writeProjectSkill: (id, projectDir) => {+ const result = writeProjectSkill(EDITOR_TARGETS[id], projectDir);+ return { action: result.action, ...(result.error ? { error: result.error } : {}) };+ },+ removeProjectSkill: (id, projectDir) => {+ const result = removeProjectSkill(EDITOR_TARGETS[id], projectDir);+ return { action: result.action, ...(result.error ? { error: result.error } : {}) };+ },+ };++ registerProjectIntegrationsSettings({+ available,+ ipcMain,+ cli,+ resolveProjectDir: (event) => {+ const win = BrowserWindow.fromWebContents(event.sender);+ if (!win) return null;+ return (+ wm.getContextForBrowserWindow(win as unknown as BrowserWindowLike)?.projectPath ?? null+ );+ },+ tildify: tildifyHomePath,+ logger: {+ warn: (msg, ctx) => projectLogger.warn((ctx ?? {}) as Record<string, unknown>, msg),+ event: (payload) => projectLogger.info(payload, payload.event),+ },+ });+}+/*** Path to the Dock/app icon PNG. Hand-authored 1024² file committed to the* repo at build/icon.png. In packaged builds, electron-builder copies thisdiff --git a/packages/desktop/src/main/project-integrations-settings.test.ts b/packages/desktop/src/main/project-integrations-settings.test.tsnew file mode 100644index 000000000..cb8e4a56f--- /dev/null+++ b/packages/desktop/src/main/project-integrations-settings.test.ts@@ -0,0 +1,307 @@+import { describe, expect, test } from 'bun:test';+import type { McpEntryClassification } from '@inkeep/open-knowledge';+import type { IpcMainInvokeEvent } from 'electron';+import type {+ McpWiringEditorId,+ ProjectIntegrationsSetRequest,+ ProjectIntegrationsSetResult,+ ProjectIntegrationsStatus,+} from '../shared/ipc-channels.ts';+import {+ type ProjectIntegrationsCliSurface,+ registerProjectIntegrationsSettings,+} from './project-integrations-settings.ts';++const PROJECT = '/proj';+const EVENT = { sender: { id: 1 } } as unknown as IpcMainInvokeEvent;++const OWN_ENTRY = { own: true };+const FOREIGN_ENTRY = { own: false };++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),+ };+}++interface CliOverrides {+ classifications?: Partial<Record<McpWiringEditorId, McpEntryClassification>>;+ writeAction?: 'written' | 'overwritten' | 'declined' | 'failed';+ removeKind?: 'removed' | 'not-present' | 'left-foreign' | 'declined';+ skillInstalled?: boolean;+ skillWriteFails?: McpWiringEditorId[];+ skillRemoveFails?: McpWiringEditorId[];+}++/** Two editors: `claude` (config + skill) and `codex` (config + skill).+ * `claude-desktop` has no project surface (both paths null) to prove rows are+ * omitted for unsupported editors. */+function makeCli(overrides: CliOverrides = {}): ProjectIntegrationsCliSurface & {+ writes: McpWiringEditorId[];+ removals: McpWiringEditorId[];+ skillWrites: McpWiringEditorId[];+ skillRemovals: McpWiringEditorId[];+} {+ const writes: McpWiringEditorId[] = [];+ const removals: McpWiringEditorId[] = [];+ const skillWrites: McpWiringEditorId[] = [];+ const skillRemovals: McpWiringEditorId[] = [];+ const CONFIG: Partial<Record<string, string>> = {+ claude: '.mcp.json',+ codex: '.codex/config.toml',+ };+ const SKILL: Partial<Record<string, string>> = {+ claude: '.claude/skills/open-knowledge/SKILL.md',+ codex: '.codex/skills/open-knowledge/SKILL.md',+ };+ return {+ writes,+ removals,+ skillWrites,+ skillRemovals,+ allEditorIds: ['claude', 'codex', 'claude-desktop'] as McpWiringEditorId[],+ editorLabel: (id) => id,+ projectConfigPath: (id, projectDir) => (CONFIG[id] ? `${projectDir}/${CONFIG[id]}` : null),+ projectSkillPath: (id, projectDir) => (SKILL[id] ? `${projectDir}/${SKILL[id]}` : null),+ entryLocator: (id) =>+ id === 'codex' ? '[mcp_servers.open-knowledge]' : 'mcpServers.open-knowledge',+ classifyExistingProjectMcpConfig: (id) =>+ overrides.classifications?.[id] ?? ({ kind: 'no-entry' } as McpEntryClassification),+ isOwnEntry: (entry) => entry === OWN_ENTRY,+ writeProjectMcpConfig: ({ id }) => {+ writes.push(id);+ const action = overrides.writeAction ?? 'written';+ if (action === 'failed') return { action: 'failed', error: 'disk full' };+ if (action === 'declined') return { action: 'declined', reason: 'unparseable' };+ return { action };+ },+ removeProjectMcpEntry: (id) => {+ removals.push(id);+ return { kind: overrides.removeKind ?? 'removed' } as ReturnType<+ ProjectIntegrationsCliSurface['removeProjectMcpEntry']+ >;+ },+ isProjectSkillInstalled: () => overrides.skillInstalled ?? false,+ writeProjectSkill: (id) => {+ skillWrites.push(id);+ if (overrides.skillWriteFails?.includes(id)) return { action: 'failed', error: 'nope' };+ return { action: 'written' };+ },+ removeProjectSkill: (id) => {+ skillRemovals.push(id);+ if (overrides.skillRemoveFails?.includes(id)) return { action: 'failed', error: 'nope' };+ return { action: 'removed' };+ },+ };+}++function register(+ cli: ProjectIntegrationsCliSurface,+ opts: { available?: boolean; projectDir?: string | null } = {},+) {+ const ipcMain = fakeIpcMain();+ const handle = registerProjectIntegrationsSettings({+ available: opts.available ?? true,+ ipcMain,+ cli,+ resolveProjectDir: () => (opts.projectDir === undefined ? PROJECT : opts.projectDir),+ tildify: (p) => p,+ });+ const dispatch = ipcMain.handlers.get('ok:project-integrations:dispatch');+ if (!dispatch) throw new Error('handler not registered');+ return {+ handle,+ ipcMain,+ status: () => dispatch(EVENT, { kind: 'status' }) as Promise<ProjectIntegrationsStatus>,+ set: (request: ProjectIntegrationsSetRequest) =>+ dispatch(EVENT, { kind: 'set', ...request }) as Promise<ProjectIntegrationsSetResult>,+ };+}++describe('registerProjectIntegrationsSettings — status', () => {+ test('omits editors with no project surface; relativizes paths; carries followUp', async () => {+ const { status } = register(makeCli());+ const s = await status();+ expect(s.hasProject).toBe(true);+ expect(s.available).toBe(true);+ // claude-desktop (no project config) is absent.+ expect(s.editors.map((e) => e.id)).toEqual(['claude', 'codex']);+ const claude = s.editors.find((e) => e.id === 'claude');+ expect(claude?.configPath).toBe('.mcp.json');+ expect(claude?.followUp).toBe('approve-once');+ expect(s.editors.find((e) => e.id === 'codex')?.followUp).toBe('auto-connect');+ });++ test('classifies own entry as installed, foreign as foreign, decline as unmanageable', async () => {+ const { status } = register(+ makeCli({+ classifications: {+ claude: { kind: 'present', entry: OWN_ENTRY } as McpEntryClassification,+ codex: { kind: 'present', entry: FOREIGN_ENTRY } as McpEntryClassification,+ },+ }),+ );+ const s = await status();+ expect(s.editors.find((e) => e.id === 'claude')?.state).toBe('installed');+ expect(s.editors.find((e) => e.id === 'codex')?.state).toBe('foreign');+ });++ test('surfaces a single skill row across capable editors', async () => {+ const { status } = register(makeCli({ skillInstalled: true }));+ const s = await status();+ expect(s.skill?.installed).toBe(true);+ expect(s.skill?.paths).toEqual([+ '.claude/skills/open-knowledge/SKILL.md',+ '.codex/skills/open-knowledge/SKILL.md',+ ]);+ });++ test('no project resolved → empty, hasProject false, still returns', async () => {+ const { status } = register(makeCli(), { projectDir: null });+ const s = await status();+ expect(s.hasProject).toBe(false);+ expect(s.projectDir).toBeNull();+ expect(s.editors).toEqual([]);+ expect(s.skill).toBeNull();+ });+});++describe('registerProjectIntegrationsSettings — set', () => {+ test('editor install writes the config and returns ok', async () => {+ const cli = makeCli();+ const { set } = register(cli);+ const r = await set({+ component: { kind: 'editor', id: 'claude' as McpWiringEditorId },+ enabled: true,+ });+ expect(r.ok).toBe(true);+ expect(cli.writes).toEqual(['claude']);+ });++ test('editor uninstall removes the entry and returns ok', async () => {+ const cli = makeCli();+ const { set } = register(cli);+ const r = await set({+ component: { kind: 'editor', id: 'codex' as McpWiringEditorId },+ enabled: false,+ });+ expect(r.ok).toBe(true);+ expect(cli.removals).toEqual(['codex']);+ });++ test('uninstall of a foreign entry refuses with an explanatory error', async () => {+ const cli = makeCli({ removeKind: 'left-foreign' });+ const { set } = register(cli);+ const r = await set({+ component: { kind: 'editor', id: 'claude' as McpWiringEditorId },+ enabled: false,+ });+ expect(r.ok).toBe(false);+ if (!r.ok) expect(r.error).toContain('left unchanged');+ });++ test('skill install fans out to every capable editor', async () => {+ const cli = makeCli();+ const { set } = register(cli);+ const r = await set({ component: { kind: 'skill' }, enabled: true });+ expect(r.ok).toBe(true);+ expect(cli.skillWrites).toEqual(['claude', 'codex']);+ });++ test('skill install reports the editors that failed', async () => {+ const cli = makeCli({ skillWriteFails: ['codex'] as McpWiringEditorId[] });+ const { set } = register(cli);+ const r = await set({ component: { kind: 'skill' }, enabled: true });+ expect(r.ok).toBe(false);+ if (!r.ok) expect(r.error).toContain('codex');+ });++ test('skill uninstall fans out removeProjectSkill to every capable editor', async () => {+ const cli = makeCli();+ const { set } = register(cli);+ const r = await set({ component: { kind: 'skill' }, enabled: false });+ expect(r.ok).toBe(true);+ expect(cli.skillRemovals).toEqual(['claude', 'codex']);+ expect(cli.skillWrites).toEqual([]); // never crosses into the install branch+ });++ test('skill uninstall reports the editors that failed', async () => {+ const cli = makeCli({ skillRemoveFails: ['codex'] as McpWiringEditorId[] });+ const { set } = register(cli);+ const r = await set({ component: { kind: 'skill' }, enabled: false });+ expect(r.ok).toBe(false);+ if (!r.ok) expect(r.error).toContain('codex');+ // The whole fan-out still runs — one editor's failure doesn't abort the rest.+ expect(cli.skillRemovals).toEqual(['claude', 'codex']);+ });++ test('editor install surfaces a declined write as a refusal, not success', async () => {+ const cli = makeCli({ writeAction: 'declined' });+ const { set } = register(cli);+ const r = await set({+ component: { kind: 'editor', id: 'claude' as McpWiringEditorId },+ enabled: true,+ });+ expect(r.ok).toBe(false);+ if (!r.ok) expect(r.error).toContain('left unchanged');+ });++ test('editor install surfaces a failed write with the failure reason', async () => {+ const cli = makeCli({ writeAction: 'failed' });+ const { set } = register(cli);+ const r = await set({+ component: { kind: 'editor', id: 'claude' as McpWiringEditorId },+ enabled: true,+ });+ expect(r.ok).toBe(false);+ if (!r.ok) {+ expect(r.error).toContain("Couldn't add");+ expect(r.error).toContain('disk full');+ }+ });++ test('editor uninstall surfaces a declined removal as a refusal', async () => {+ const cli = makeCli({ removeKind: 'declined' });+ const { set } = register(cli);+ const r = await set({+ component: { kind: 'editor', id: 'claude' as McpWiringEditorId },+ enabled: false,+ });+ expect(r.ok).toBe(false);+ if (!r.ok) expect(r.error).toContain('left unchanged');+ });++ test('read-only build refuses every mutation', async () => {+ const cli = makeCli();+ const { set } = register(cli, { available: false });+ const r = await set({ component: { kind: 'skill' }, enabled: true });+ expect(r.ok).toBe(false);+ if (!r.ok) expect(r.error).toContain('unavailable');+ expect(cli.skillWrites).toEqual([]);+ });++ test('mutation with no project open refuses', async () => {+ const cli = makeCli();+ const { set } = register(cli, { projectDir: null });+ const r = await set({+ component: { kind: 'editor', id: 'claude' as McpWiringEditorId },+ enabled: true,+ });+ expect(r.ok).toBe(false);+ if (!r.ok) expect(r.error).toContain('No project');+ expect(cli.writes).toEqual([]);+ });++ test('every set result carries a fresh status snapshot', async () => {+ const cli = makeCli();+ const { set } = register(cli);+ const r = await set({ component: { kind: 'skill' }, enabled: true });+ expect(r.status.hasProject).toBe(true);+ expect(r.status.editors.length).toBe(2);+ });+});diff --git a/packages/desktop/src/main/project-integrations-settings.ts b/packages/desktop/src/main/project-integrations-settings.tsnew file mode 100644index 000000000..7bde3f0d9--- /dev/null+++ b/packages/desktop/src/main/project-integrations-settings.ts@@ -0,0 +1,411 @@+/**+ * Settings → This project → AI tools — persistent IPC surface for per-component+ * install/uninstall of OpenKnowledge's PROJECT-LOCAL footprint: the per-editor+ * project MCP config files (`.mcp.json`, `.cursor/mcp.json`, `.codex/config.toml`,+ * …) and the project runtime skill (`.claude/skills/open-knowledge/`, …), all+ * scoped to the project the requesting window has open.+ *+ * The project-scoped sibling of `integrations-settings.ts` (which owns the+ * user-global footprint: user-scope MCP entries, the shell-PATH shim, the+ * user-global skill bundles). Both promote a one-shot consent flow into a+ * persistent, live-state Settings surface; this one mirrors the per-project+ * onboarding dialog (`consent-dialog.ts`) rather than the global first-launch+ * one. Same install actors underneath — `writeEditorMcpConfig` /+ * `removeOwnMcpEntry` / `writeProjectSkill` / `removeProjectSkill` with a+ * project config-path override — so the two surfaces and the reclaim-on-open+ * sweep can never disagree about what a project install means.+ *+ * Two things the global surface does not need:+ * 1. The active project. Every request resolves the sender window's project+ * dir via the injected `resolveProjectDir(event)` (main maps webContents →+ * ProjectContext) so the renderer can never target a foreign directory.+ * 2. Per-editor follow-up honesty. A written project config is not always a+ * connected one — Claude Code needs a one-time approval, Cursor sits+ * silently disabled until manually enabled, Codex auto-connects on a+ * trusted project. `followUp` carries that per row.+ *+ * Mutations serialize through a promise-chain mutex, same as the global+ * surface. Electron-free + dependency-injected so bun-test loads it without an+ * Electron runtime; `main/index.ts` wires the real surfaces in.+ */++import { relative } from 'node:path';+import type {+ McpDeclineReason,+ McpEntryClassification,+ McpRemoveOutcome,+} from '@inkeep/open-knowledge';+import type { IpcMain, IpcMainInvokeEvent } from 'electron';+import type {+ IntegrationsEditorState,+ McpWiringEditorId,+ ProjectIntegrationsComponentRef,+ ProjectIntegrationsEditorStatus,+ ProjectIntegrationsFollowUp,+ ProjectIntegrationsSetRequest,+ ProjectIntegrationsSetResult,+ ProjectIntegrationsStatus,+} from '../shared/ipc-channels.ts';+import { createHandler } from '../shared/ipc-handler.ts';+import { classifyEditorState } from './integrations-settings.ts';+import { logIpcError } from './ipc-log.ts';++/**+ * Post-install manual step, per editor. Product knowledge, not a config+ * property — an editor that writes a project config fine may still need a+ * consent/enable/trust step before OK's tools actually connect. Unlisted+ * editors default to `none`.+ */+const EDITOR_FOLLOW_UP: Partial<Record<McpWiringEditorId, ProjectIntegrationsFollowUp>> = {+ claude: 'approve-once',+ cursor: 'enable-manually',+ codex: 'auto-connect',+};++function followUpFor(id: McpWiringEditorId): ProjectIntegrationsFollowUp {+ return EDITOR_FOLLOW_UP[id] ?? 'none';+}++/** CLI-side surface (backed by `@inkeep/open-knowledge` project primitives). */+export interface ProjectIntegrationsCliSurface {+ allEditorIds: readonly McpWiringEditorId[];+ editorLabel(id: McpWiringEditorId): string;+ /** Absolute project config path, or null when the editor exposes no+ * project-scope MCP surface (e.g. Claude Desktop). */+ projectConfigPath(id: McpWiringEditorId, projectDir: string): string | null;+ /** Absolute project skill `SKILL.md` path, or null when the editor exposes+ * no project-scope skill surface. */+ projectSkillPath(id: McpWiringEditorId, projectDir: string): string | null;+ /** Technical locator of OK's entry inside the config — disclosure only. */+ entryLocator(id: McpWiringEditorId): string;+ classifyExistingProjectMcpConfig(+ id: McpWiringEditorId,+ projectDir: string,+ projectPath: string,+ ): McpEntryClassification;+ /** True when `entry` is recognizably OK's OWN managed entry (the only shape+ * uninstall deletes). */+ isOwnEntry(entry: unknown): boolean;+ writeProjectMcpConfig(opts: { id: McpWiringEditorId; projectDir: string; projectPath: string }): {+ action: 'written' | 'overwritten' | 'declined' | 'failed';+ reason?: McpDeclineReason;+ error?: string;+ };+ removeProjectMcpEntry(+ id: McpWiringEditorId,+ projectDir: string,+ projectPath: string,+ ): McpRemoveOutcome;+ /** The canonical project runtime skill (`.claude/skills/open-knowledge`) is+ * on disk — the single row's checked state. */+ isProjectSkillInstalled(projectDir: string): boolean;+ writeProjectSkill(+ id: McpWiringEditorId,+ projectDir: string,+ ): { action: 'written' | 'overwritten' | 'skipped-unsupported' | 'failed'; error?: string };+ removeProjectSkill(+ id: McpWiringEditorId,+ projectDir: string,+ ): { action: 'removed' | 'not-present' | 'skipped-unsupported' | 'failed'; error?: string };+}++interface ProjectIntegrationsLogger {+ warn(msg: string, ctx?: object): void;+ event(payload: { event: string; [k: string]: unknown }): void;+}++const DEFAULT_LOGGER: ProjectIntegrationsLogger = {+ warn: (msg, ctx) => console.warn('[project-integrations-settings]', msg, ctx ?? ''),+ event: (payload) => console.warn(JSON.stringify(payload)),+};++interface IpcMainLike extends Pick<IpcMain, 'handle' | 'removeHandler'> {}++export interface RegisterProjectIntegrationsSettingsOpts {+ /** Same gate set as the global surface / reclaim sweep (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: ProjectIntegrationsCliSurface;+ /** Resolve the sender window's project dir (main maps webContents →+ * ProjectContext). Null when the sender isn't bound to a project. */+ resolveProjectDir(event: IpcMainInvokeEvent): string | null;+ /** Tildify the project dir for disclosure display. Defaults to identity. */+ tildify?(path: string): string;+ logger?: ProjectIntegrationsLogger;+}++export interface ProjectIntegrationsSettingsHandle {+ destroy(): void;+}++export function registerProjectIntegrationsSettings(+ opts: RegisterProjectIntegrationsSettingsOpts,+): ProjectIntegrationsSettingsHandle {+ const {+ available,+ ipcMain,+ cli,+ resolveProjectDir,+ tildify = (p) => p,+ logger = DEFAULT_LOGGER,+ } = opts;++ /** Editors that expose a project skill surface, in registry order. */+ function editorsWithProjectSkill(projectDir: string): McpWiringEditorId[] {+ return cli.allEditorIds.filter((id) => cli.projectSkillPath(id, projectDir) !== null);+ }++ function computeEditorStatuses(projectDir: string): ProjectIntegrationsEditorStatus[] {+ const statuses: ProjectIntegrationsEditorStatus[] = [];+ for (const id of cli.allEditorIds) {+ const projectPath = cli.projectConfigPath(id, projectDir);+ if (projectPath === null) continue; // No project surface → no row.+ let state: IntegrationsEditorState;+ try {+ state = classifyEditorState(+ cli.classifyExistingProjectMcpConfig(id, projectDir, projectPath),+ cli.isOwnEntry,+ );+ } catch (err) {+ // A throwing read (EACCES, a resolver that can't produce a path) must+ // not take the whole section down — surface the row as unmanageable.+ logger.warn('project editor classify failed', {+ projectDir,+ id,+ error: err instanceof Error ? err.message : String(err),+ });+ state = 'unmanageable';+ }+ statuses.push({+ id,+ label: cli.editorLabel(id),+ state,+ configPath: relative(projectDir, projectPath),+ entryLocator: cli.entryLocator(id),+ followUp: followUpFor(id),+ });+ }+ return statuses;+ }++ function computeStatus(projectDir: string | null): ProjectIntegrationsStatus {+ if (projectDir === null) {+ return { available, hasProject: false, projectDir: null, editors: [], skill: null };+ }+ let editors: ProjectIntegrationsEditorStatus[];+ try {+ editors = computeEditorStatuses(projectDir);+ } catch (err) {+ logger.warn('project editor statuses failed', {+ projectDir,+ error: err instanceof Error ? err.message : String(err),+ });+ editors = [];+ }+ const skillPaths = editorsWithProjectSkill(projectDir)+ .map((id) => cli.projectSkillPath(id, projectDir))+ .filter((p): p is string => p !== null)+ .map((p) => relative(projectDir, p));+ let skill: ProjectIntegrationsStatus['skill'] = null;+ if (skillPaths.length > 0) {+ let installed = false;+ try {+ installed = cli.isProjectSkillInstalled(projectDir);+ } catch (err) {+ logger.warn('project skill status failed', {+ projectDir,+ error: err instanceof Error ? err.message : String(err),+ });+ }+ skill = { installed, paths: skillPaths };+ }+ return { available, hasProject: true, projectDir: tildify(projectDir), editors, skill };+ }++ async function setEditor(+ projectDir: string,+ id: McpWiringEditorId,+ enabled: boolean,+ ): Promise<{ ok: true } | { ok: false; error: string }> {+ const label = cli.editorLabel(id);+ const projectPath = cli.projectConfigPath(id, projectDir);+ if (projectPath === null) {+ return { ok: false, error: `${label} has no project-scope MCP config.` };+ }+ if (enabled) {+ let result: ReturnType<ProjectIntegrationsCliSurface['writeProjectMcpConfig']>;+ try {+ result = cli.writeProjectMcpConfig({ id, projectDir, projectPath });+ } catch (err) {+ return { ok: false, error: err instanceof Error ? err.message : String(err) };+ }+ switch (result.action) {+ case 'written':+ case 'overwritten':+ logger.event({ event: 'project-integrations-editor-installed', editor: id });+ return { ok: true };+ case 'declined':+ return {+ ok: false,+ error: `Couldn't safely edit ${label}'s project config — it was left unchanged.`,+ };+ default:+ return {+ ok: false,+ error: `Couldn't add OpenKnowledge to ${label}${result.error ? ` (${result.error})` : ''}.`,+ };+ }+ }+ let outcome: McpRemoveOutcome;+ try {+ outcome = cli.removeProjectMcpEntry(id, projectDir, projectPath);+ } catch (err) {+ return { ok: false, error: err instanceof Error ? err.message : String(err) };+ }+ switch (outcome.kind) {+ case 'removed':+ case 'not-present':+ logger.event({+ event: 'project-integrations-editor-removed',+ editor: id,+ outcome: outcome.kind,+ });+ return { ok: true };+ case 'left-foreign':+ return {+ ok: false,+ error: `The open-knowledge entry in ${label}'s project config 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 project config — it was left unchanged.`,+ };+ }+ }++ async function setSkill(+ projectDir: string,+ enabled: boolean,+ ): Promise<{ ok: true } | { ok: false; error: string }> {+ const editors = editorsWithProjectSkill(projectDir);+ if (editors.length === 0) {+ return { ok: false, error: 'No installed editor supports a project skill.' };+ }+ const failures: string[] = [];+ for (const id of editors) {+ try {+ const result = enabled+ ? cli.writeProjectSkill(id, projectDir)+ : cli.removeProjectSkill(id, projectDir);+ if (result.action === 'failed') {+ failures.push(`${cli.editorLabel(id)}${result.error ? ` (${result.error})` : ''}`);+ }+ } catch (err) {+ failures.push(+ `${cli.editorLabel(id)} (${err instanceof Error ? err.message : String(err)})`,+ );+ }+ }+ if (failures.length > 0) {+ return {+ ok: false,+ error: `Couldn't ${enabled ? 'install' : 'remove'} the project skill for: ${failures.join(', ')}.`,+ };+ }+ logger.event({+ event: enabled+ ? 'project-integrations-skill-installed'+ : 'project-integrations-skill-removed',+ editors,+ });+ return { ok: true };+ }++ async function applyComponent(+ projectDir: string | null,+ request: ProjectIntegrationsSetRequest,+ ): Promise<{ ok: true } | { ok: false; error: string }> {+ if (!available) {+ return { ok: false, error: 'Managing project AI tools is unavailable in this build.' };+ }+ if (projectDir === null) {+ return { ok: false, error: 'No project is open in this window.' };+ }+ const component = request?.component as ProjectIntegrationsComponentRef | undefined;+ const enabled = request?.enabled === true;+ if (component?.kind === 'editor') {+ if (!cli.allEditorIds.includes(component.id)) {+ return { ok: false, error: 'Unknown editor.' };+ }+ return setEditor(projectDir, component.id, enabled);+ }+ if (component?.kind === 'skill') {+ return setSkill(projectDir, 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(+ projectDir: string | null,+ request: ProjectIntegrationsSetRequest,+ ): Promise<ProjectIntegrationsSetResult> {+ const run = mutationChain.then(async (): Promise<ProjectIntegrationsSetResult> => {+ let result: { ok: true } | { ok: false; error: string };+ try {+ result = await applyComponent(projectDir, request);+ } catch (err) {+ result = { ok: false, error: err instanceof Error ? err.message : String(err) };+ }+ if (!result.ok) {+ logIpcError({+ event: 'ipc.error',+ channel: 'ok:project-integrations:dispatch',+ reason: 'set-component-refused',+ handler: 'projectIntegrationsDispatch',+ cause: { component: request?.component?.kind ?? 'unknown', error: result.error },+ });+ return { ok: false, error: result.error, status: computeStatus(projectDir) };+ }+ return { ok: true, status: computeStatus(projectDir) };+ });+ mutationChain = run.catch(() => {});+ return run;+ }++ const register = createHandler(ipcMain as IpcMain);+ register('ok:project-integrations:dispatch', async (event, request) => {+ let projectDir: string | null;+ try {+ projectDir = resolveProjectDir(event);+ } catch (err) {+ logger.warn('resolveProjectDir threw', {+ error: err instanceof Error ? err.message : String(err),+ });+ projectDir = null;+ }+ if (request?.kind === 'set') return dispatchSet(projectDir, request);+ return computeStatus(projectDir);+ });++ let destroyed = false;+ return {+ destroy(): void {+ if (destroyed) return;+ destroyed = true;+ try {+ ipcMain.removeHandler('ok:project-integrations:dispatch');+ } catch (err) {+ logger.warn('removeHandler(ok:project-integrations:dispatch) threw', {+ message: err instanceof Error ? err.message : String(err),+ });+ }+ },+ };+}diff --git a/packages/desktop/src/preload/index.ts b/packages/desktop/src/preload/index.tsindex 88edf7a1c..b66626dac 100644--- a/packages/desktop/src/preload/index.ts+++ b/packages/desktop/src/preload/index.ts@@ -49,7 +49,12 @@ import type {OkUpdateStuckHintInfo,OkWhatsNewInfo,} from '../shared/bridge-contract.ts';-import type { IntegrationsSetResult, IntegrationsStatus } from '../shared/ipc-channels.ts';+import type {+ IntegrationsSetResult,+ IntegrationsStatus,+ ProjectIntegrationsSetResult,+ ProjectIntegrationsStatus,+} from '../shared/ipc-channels.ts';import { createInvoker } from '../shared/ipc-invoke.ts';import { resolveOkDesktopMode } from '../shared/ok-desktop-mode.ts';@@ -516,6 +521,22 @@ const bridge: OkDesktopBridge = {}) as Promise<IntegrationsSetResult>,},+ projectIntegrations: {+ // Project-scoped sibling — same discriminated channel+ // (`ok:project-integrations:dispatch`), scoped in main to the sender+ // window's project. Each method casts the union result to its own arm.+ status: () =>+ invoke('ok:project-integrations:dispatch', {+ kind: 'status',+ }) as Promise<ProjectIntegrationsStatus>,+ setComponent: (request) =>+ invoke('ok:project-integrations:dispatch', {+ kind: 'set',+ component: request.component,+ enabled: request.enabled,+ }) as Promise<ProjectIntegrationsSetResult>,+ },+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.tsindex 203df6c86..544669e57 100644--- a/packages/desktop/src/shared/bridge-contract.ts+++ b/packages/desktop/src/shared/bridge-contract.ts@@ -461,6 +461,47 @@ type OkIntegrationsSetResult =| { readonly ok: true; readonly status: OkIntegrationsStatus }| { readonly ok: false; readonly error: string; readonly status: OkIntegrationsStatus };+/** Post-install manual step a project MCP config needs before OK's tools+ * connect: `approve-once` (Claude Code), `enable-manually` (Cursor, silently+ * disabled until toggled), `auto-connect` (Codex on a trusted project),+ * `none`. */+type OkProjectIntegrationsFollowUp = 'approve-once' | 'enable-manually' | 'auto-connect' | 'none';++/** Component inventory for Settings → This project → AI tools (per-editor+ * PROJECT MCP config files + the single project runtime skill), scoped to the+ * project the requesting window has open. `hasProject: false` → empty state;+ * `available: false` → read-only. */+interface OkProjectIntegrationsStatus {+ readonly available: boolean;+ readonly hasProject: boolean;+ readonly projectDir: string | null;+ readonly editors: readonly {+ readonly id: OkMcpWiringEditorId;+ readonly label: string;+ readonly state: OkIntegrationsEditorState;+ readonly configPath: string;+ readonly entryLocator: string;+ readonly followUp: OkProjectIntegrationsFollowUp;+ }[];+ readonly skill: {+ readonly installed: boolean;+ readonly paths: readonly string[];+ } | null;+}++/** One toggle for `projectIntegrations.setComponent`. The skill is a single+ * row (no id) — it fans out across every capable editor. */+interface OkProjectIntegrationsSetRequest {+ readonly component:+ | { readonly kind: 'editor'; readonly id: OkMcpWiringEditorId }+ | { readonly kind: 'skill' };+ readonly enabled: boolean;+}++type OkProjectIntegrationsSetResult =+ | { readonly ok: true; readonly status: OkProjectIntegrationsStatus }+ | { readonly ok: false; readonly error: string; readonly status: OkProjectIntegrationsStatus };+/*** Per-project consent dialog — renderer-facing payload + result* shapes. Mirrors the IPC types in `./ipc-channels.ts` so the bridge surface@@ -1593,6 +1634,17 @@ export interface OkDesktopBridge {setComponent(request: OkIntegrationsSetRequest): Promise<OkIntegrationsSetResult>;};+ /**+ * Settings → This project → AI tools: live per-component install state ++ * one-component install/uninstall for OK's PROJECT-LOCAL footprint (per-editor+ * project MCP config files + the project runtime skill) against the project+ * the requesting window has open. Mutations serialize in main.+ */+ projectIntegrations: {+ status(): Promise<OkProjectIntegrationsStatus>;+ setComponent(request: OkProjectIntegrationsSetRequest): Promise<OkProjectIntegrationsSetResult>;+ };+/*** Per-project consent dialog. Navigator-only — editor renderers never* receive `ok:onboarding:show`. Renderer mounts a shadcn Dialog whendiff --git a/packages/desktop/src/shared/ipc-channels.ts b/packages/desktop/src/shared/ipc-channels.tsindex f3410b5b4..edaef5af5 100644--- a/packages/desktop/src/shared/ipc-channels.ts+++ b/packages/desktop/src/shared/ipc-channels.ts@@ -30,7 +30,7 @@* existing channels is preferred over net-new hand-rolled channels until* that migration lands.*- * Count is 78 (ratchet cap 78). The 74→75 bump reconciled a merge collision:+ * Count is 79 (ratchet cap 79). 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@@ -38,8 +38,10 @@* on main in parallel. The 76→77 bump added the share-receive branch-switch* 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.+ * discriminated fold per the worktree-dispatch precedent). The 78→79 bump added+ * its project-scoped sibling Settings → This project → AI tools+ * (`ok:project-integrations:dispatch`, same status+set fold, scoped to the+ * sender window's project). Full rationale in the ratchet test header.*/import type {@@ -492,6 +494,73 @@ export type IntegrationsSetResult =| { readonly ok: true; readonly status: IntegrationsStatus }| { readonly ok: false; readonly error: string; readonly status: IntegrationsStatus };+// ---------------------------------------------------------------------------+// Project-scope siblings — Settings → This project → AI tools+// ---------------------------------------------------------------------------++/** Post-install manual step a project MCP config needs before OK's tools+ * actually connect — surfaced per row so a project-only install isn't a silent+ * dead-end.+ * - `approve-once` — Claude Code: one per-user approval prompt per project.+ * - `enable-manually` — Cursor: written but sits disabled until the user+ * flips it in Settings → Tools & MCP (per user × workspace × machine; can't+ * be pre-seeded from the repo).+ * - `auto-connect` — Codex: connects on the next turn for a trusted project.+ * - `none` — no known extra step. */+export type ProjectIntegrationsFollowUp =+ | 'approve-once'+ | 'enable-manually'+ | 'auto-connect'+ | 'none';++/** Per-editor project MCP config row. `state` reuses `IntegrationsEditorState`+ * (installed / not-installed / foreign / unmanageable). `configPath` is+ * project-relative (e.g. `.mcp.json`, `.cursor/mcp.json`). */+export interface ProjectIntegrationsEditorStatus {+ readonly id: McpWiringEditorId;+ readonly label: string;+ readonly state: IntegrationsEditorState;+ readonly configPath: string;+ readonly entryLocator: string;+ readonly followUp: ProjectIntegrationsFollowUp;+}++/** The single project runtime-skill row. A toggle installs/removes the skill+ * across every project-skill-capable editor at once; `paths` lists each+ * project-relative dir it touches. `installed` reflects the canonical+ * `.claude/skills/open-knowledge` copy being on disk. */+export interface ProjectIntegrationsSkillStatus {+ readonly installed: boolean;+ readonly paths: readonly string[];+}++/** Component inventory for Settings → This project → AI tools. `hasProject:+ * false` means no project resolved from the requesting window (the section+ * shows an empty state; status still returns). `available: false` renders the+ * section read-only. `projectDir` is tildified, disclosure only. */+export interface ProjectIntegrationsStatus {+ readonly available: boolean;+ readonly hasProject: boolean;+ readonly projectDir: string | null;+ readonly editors: readonly ProjectIntegrationsEditorStatus[];+ readonly skill: ProjectIntegrationsSkillStatus | null;+}++/** One toggleable component in Settings → This project → AI tools. The skill is+ * a single row (no id) — it fans out across every capable editor. */+export type ProjectIntegrationsComponentRef =+ | { readonly kind: 'editor'; readonly id: McpWiringEditorId }+ | { readonly kind: 'skill' };++export interface ProjectIntegrationsSetRequest {+ readonly component: ProjectIntegrationsComponentRef;+ readonly enabled: boolean;+}++export type ProjectIntegrationsSetResult =+ | { readonly ok: true; readonly status: ProjectIntegrationsStatus }+ | { readonly ok: false; readonly error: string; readonly status: ProjectIntegrationsStatus };+/** 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). */@@ -1159,6 +1228,18 @@ export interface RequestChannels {result: IntegrationsStatus | IntegrationsSetResult;};+ /**+ * Settings → This project → AI tools. Project-scoped sibling of+ * `ok:integrations:dispatch`: same discriminated `status` read + one-component+ * `set`, but scoped to the project the SENDER window has open (main resolves+ * webContents → ProjectContext; the renderer never names a directory). Covers+ * the per-editor project MCP config files + the single project runtime skill.+ */+ 'ok:project-integrations:dispatch': {+ args: [request: { kind: 'status' } | ({ kind: 'set' } & ProjectIntegrationsSetRequest)];+ result: ProjectIntegrationsStatus | ProjectIntegrationsSetResult;+ };+/*** Per-project consent dialog. Renderer renders a shadcn Dialog inside the* Navigator after main fires `ok:onboarding:show`; callsdiff --git a/packages/desktop/tests/integration/ipc-channel-count-ratchet.test.ts b/packages/desktop/tests/integration/ipc-channel-count-ratchet.test.tsindex 39ff8f96f..cbccdb635 100644--- a/packages/desktop/tests/integration/ipc-channel-count-ratchet.test.ts+++ b/packages/desktop/tests/integration/ipc-channel-count-ratchet.test.ts@@ -275,8 +275,28 @@ const CHANNELS_SRC = readFileSync(SRC_PATH, 'utf-8');* guards), and their confirm semantics are batched consent, not* per-component install/uninstall with live status. New* `ok:integrations:*` namespace, single member.+ *+ * Bumped from 78 to 79 for Settings → This project → AI tools (per-component+ * install/uninstall of OK's PROJECT-LOCAL footprint):+ *+ * - `ok:project-integrations:dispatch` — the project-scoped sibling of+ * `ok:integrations:dispatch`. Status read + one-component set folded into a+ * single discriminated channel (same `ok:worktree:dispatch` precedent), so+ * the surface costs one slot, not two. Could NOT fold into+ * `ok:integrations:dispatch`: that channel is user-global (keyed on+ * `osHomedir()`, no active project), whereas this one MUST resolve the+ * sender window's project (webContents → ProjectContext) and its component+ * set differs (per-editor PROJECT config files + a project skill; no+ * PATH/Claude-Desktop rows). A shared channel would have to carry a+ * scope discriminant AND branch every actor internally — two surfaces+ * wearing one channel. Could not fold into `ok:onboarding:*` (the one-shot+ * per-project consent dialog with sender-binding + mount-ack idempotence,+ * batched consent rather than live per-component toggles). New+ * `ok:project-integrations:*` namespace, single member. The typed-ipc+ * migration remains the committed end state; scoped exception with the+ * `ipc-channels.ts` header commitment updated in lock-step.*/-const REQUEST_CHANNEL_CAP = 78;+const REQUEST_CHANNEL_CAP = 79;/*** Extract the body of an interface block by name. Returns the substring