Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Send Beta CLI deep links to the Beta app (part of PRD-9083) (#5831)
Andrew Mikofalvyb6b04fc64597
diff --git a/.changeset/prd-9083-beta-deep-link-scheme.md b/.changeset/prd-9083-beta-deep-link-scheme.mdnew file mode 100644index 000000000..1db93d235--- /dev/null+++ b/.changeset/prd-9083-beta-deep-link-scheme.md@@ -0,0 +1,5 @@+---+"@inkeep/open-knowledge": patch+---++Running `open-knowledge-beta open`, or opening a Markdown file from the Beta command line, now opens it in the OpenKnowledge Beta app.diff --git a/knip.config.ts b/knip.config.tsindex d3638888e..65f0e8807 100644--- a/knip.config.ts+++ b/knip.config.ts@@ -147,15 +147,11 @@ export default {'packages/server': {entry: ['src/**/*.test.ts', 'src/parse-worker.ts'],project: 'src/**',- ignoreDependencies: [- '@types/shell-quote',- ],+ ignoreDependencies: ['@types/shell-quote'],},'packages/cli': {entry: ['src/**/*.test.ts', 'scripts/*.ts', 'tests/**/*.ts', 'src/parse-worker.ts'],- ignoreDependencies: [- 'yjs',- ],+ ignoreDependencies: ['yjs'],},'packages/desktop': {entry: [diff --git a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts b/packages/app/tests/integration/bug3-source-mode-writeback.test.tsindex 4549c74b3..a50b00123 100644--- a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts+++ b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts@@ -1,4 +1,3 @@-import { readFileSync } from 'node:fs';import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';diff --git a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts b/packages/app/tests/integration/indented-jsx-byte-sacred.test.tsindex 4fc2c11f9..6fcdc23f2 100644--- a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts+++ b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts@@ -1,4 +1,3 @@-import { setTimeout as wait } from 'node:timers/promises';import { normalizeBridge } from '@inkeep/open-knowledge-core';import { updateYFragment } from '@tiptap/y-tiptap';diff --git a/packages/app/tests/integration/interior-edit-freshness.test.ts b/packages/app/tests/integration/interior-edit-freshness.test.tsindex 9f2f6feb6..40b5cdfd6 100644--- a/packages/app/tests/integration/interior-edit-freshness.test.ts+++ b/packages/app/tests/integration/interior-edit-freshness.test.ts@@ -1,4 +1,3 @@-import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts b/packages/app/tests/integration/keystroke-cadence-danger-space.test.tsindex 2a085742b..93666af70 100644--- a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts+++ b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts@@ -1,4 +1,3 @@-import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/producer-guard-wiring.test.ts b/packages/app/tests/integration/producer-guard-wiring.test.tsindex 878d5196b..867598d34 100644--- a/packages/app/tests/integration/producer-guard-wiring.test.ts+++ b/packages/app/tests/integration/producer-guard-wiring.test.ts@@ -1,4 +1,3 @@-import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.tsindex 4ada3cf26..0970ac12f 100644--- a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts+++ b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts@@ -1,4 +1,3 @@-import { randomUUID } from 'node:crypto';import { afterEach, describe, expect, test } from 'vitest';import { agentWriteMd, createTestServer, type TestServer } from './test-harness';diff --git a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts b/packages/app/tests/integration/qa-045-restore-after-gc.test.tsindex cbe2b705f..b632185e1 100644--- a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts+++ b/packages/app/tests/integration/qa-045-restore-after-gc.test.ts@@ -1,4 +1,3 @@-import { execFileSync } from 'node:child_process';import { randomUUID } from 'node:crypto';import { join } from 'node:path';diff --git a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.tsindex 89bc9b4d9..c530ce4ba 100644--- a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts+++ b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts@@ -1,4 +1,3 @@-import { randomUUID } from 'node:crypto';import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest';import type * as Y from 'yjs';diff --git a/packages/app/tests/integration/undo-after-rollback.test.ts b/packages/app/tests/integration/undo-after-rollback.test.tsindex a78aeb0e4..d3767adc9 100644--- a/packages/app/tests/integration/undo-after-rollback.test.ts+++ b/packages/app/tests/integration/undo-after-rollback.test.ts@@ -1,4 +1,3 @@-import { ROLLBACK_ORIGIN } from '@inkeep/open-knowledge-server';import { afterAll, beforeAll, describe, expect, test } from 'vitest';import * as Y from 'yjs';diff --git a/packages/app/tests/integration/undo-recycle-reset.test.ts b/packages/app/tests/integration/undo-recycle-reset.test.tsindex e7cc69c3f..b076f955c 100644--- a/packages/app/tests/integration/undo-recycle-reset.test.ts+++ b/packages/app/tests/integration/undo-recycle-reset.test.ts@@ -1,4 +1,3 @@-import { writeFileSync } from 'node:fs';import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';diff --git a/packages/app/tests/integration/undo-rederive-survival.test.ts b/packages/app/tests/integration/undo-rederive-survival.test.tsindex 9ddcd0730..7935e35f8 100644--- a/packages/app/tests/integration/undo-rederive-survival.test.ts+++ b/packages/app/tests/integration/undo-rederive-survival.test.ts@@ -1,4 +1,3 @@-import { prependFrontmatter } from '@inkeep/open-knowledge-core';import { Plugin, PluginKey } from '@tiptap/pm/state';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';diff --git a/packages/cli/src/commands/desktop-dispatch.test.ts b/packages/cli/src/commands/desktop-dispatch.test.tsindex 9dc6a520f..efdd68bb4 100644--- a/packages/cli/src/commands/desktop-dispatch.test.ts+++ b/packages/cli/src/commands/desktop-dispatch.test.ts@@ -1,5 +1,6 @@import type { SpawnOptions } from 'node:child_process';-import { describe, expect, test } from 'vitest';+import { OK_CHANNEL_ENV } from '@inkeep/open-knowledge-core';+import { describe, expect, test, vi } from 'vitest';import {DESKTOP_BUNDLE_ID,type DetectDeps,@@ -35,17 +36,21 @@ describe('detectDesktop — platform gate (FR10)', () => {const result = detectDesktop(baseDeps({ platform: 'freebsd' as NodeJS.Platform, statSync: statForFile(APP_EXEC) }),);- expect(result).toEqual({ available: false, reason: 'unsupported-platform' });+ expect(result).toEqual({+ available: false,+ reason: 'unsupported-platform',+ cliProduct: 'stable',+ });});test('linux with no install → no-bundle (falls back to browser mode)', () => {const result = detectDesktop(baseDeps({ platform: 'linux', statSync: statForFile(APP_EXEC) }));- expect(result).toEqual({ available: false, reason: 'no-bundle' });+ expect(result).toEqual({ available: false, reason: 'no-bundle', cliProduct: 'stable' });});test('win32 with no install → no-bundle (falls back to browser mode)', () => {const result = detectDesktop(baseDeps({ platform: 'win32', statSync: statForFile(APP_EXEC) }));- expect(result).toEqual({ available: false, reason: 'no-bundle' });+ expect(result).toEqual({ available: false, reason: 'no-bundle', cliProduct: 'stable' });});});@@ -65,7 +70,13 @@ describe('detectDesktop — Windows/Linux install resolution', () => {statSync: statForFile(WIN_EXE),}),);- expect(result).toEqual({ available: true, reason: 'available', bundlePath: WIN_EXE });+ expect(result).toEqual({+ available: true,+ reason: 'available',+ bundlePath: WIN_EXE,+ product: 'stable',+ cliProduct: 'stable',+ });});test('win32: bundled-CLI introspection (ok.cmd wrapper) → the running exe', () => {@@ -77,7 +88,31 @@ describe('detectDesktop — Windows/Linux install resolution', () => {statSync: () => null,}),);- expect(result).toEqual({ available: true, reason: 'available', bundlePath: WIN_EXE });+ expect(result).toEqual({+ available: true,+ reason: 'available',+ bundlePath: WIN_EXE,+ product: 'stable',+ cliProduct: 'stable',+ });+ });++ test('win32: bundled-CLI introspection reports the Beta product for the Beta exe', () => {+ const result = detectDesktop(+ baseDeps({+ platform: 'win32',+ env: { ELECTRON_RUN_AS_NODE: '1' },+ execPath: BETA_WIN_EXE,+ statSync: () => null,+ }),+ );+ expect(result).toEqual({+ available: true,+ reason: 'available',+ bundlePath: BETA_WIN_EXE,+ product: 'beta',+ cliProduct: 'beta',+ });});test('win32: Beta per-user install → available', () => {@@ -88,7 +123,13 @@ describe('detectDesktop — Windows/Linux install resolution', () => {statSync: statForFile(BETA_WIN_EXE),}),);- expect(result).toEqual({ available: true, reason: 'available', bundlePath: BETA_WIN_EXE });+ expect(result).toEqual({+ available: true,+ reason: 'available',+ bundlePath: BETA_WIN_EXE,+ product: 'beta',+ cliProduct: 'stable',+ });});test('linux: deb install at /opt → available (with a display)', () => {@@ -99,14 +140,26 @@ describe('detectDesktop — Windows/Linux install resolution', () => {statSync: statForFile(DEB_EXE),}),);- expect(result).toEqual({ available: true, reason: 'available', bundlePath: DEB_EXE });+ expect(result).toEqual({+ available: true,+ reason: 'available',+ bundlePath: DEB_EXE,+ product: 'stable',+ cliProduct: 'stable',+ });});test('linux: no DISPLAY/WAYLAND_DISPLAY → headless even on a TTY', () => {const result = detectDesktop(baseDeps({ platform: 'linux', env: {}, statSync: statForFile(DEB_EXE) }),);- expect(result).toEqual({ available: false, reason: 'headless', bundlePath: DEB_EXE });+ expect(result).toEqual({+ available: false,+ reason: 'headless',+ bundlePath: DEB_EXE,+ product: 'stable',+ cliProduct: 'stable',+ });});test('linux: Beta deb install at /opt → available', () => {@@ -117,7 +170,13 @@ describe('detectDesktop — Windows/Linux install resolution', () => {statSync: statForFile(BETA_DEB_EXE),}),);- expect(result).toEqual({ available: true, reason: 'available', bundlePath: BETA_DEB_EXE });+ expect(result).toEqual({+ available: true,+ reason: 'available',+ bundlePath: BETA_DEB_EXE,+ product: 'beta',+ cliProduct: 'stable',+ });});});@@ -141,6 +200,8 @@ describe('detectDesktop — bundle resolution (FR10 D2 a/b/c)', () => {available: true,reason: 'available',bundlePath: '/Applications/OpenKnowledge Beta.app',+ product: 'beta',+ cliProduct: 'stable',});});@@ -154,7 +215,7 @@ describe('detectDesktop — bundle resolution (FR10 D2 a/b/c)', () => {test('darwin + no bundle → no-bundle', () => {const result = detectDesktop(baseDeps());- expect(result).toEqual({ available: false, reason: 'no-bundle' });+ expect(result).toEqual({ available: false, reason: 'no-bundle', cliProduct: 'stable' });});test('bundled-CLI introspection (FR10 D2 path a) — ELECTRON_RUN_AS_NODE + execPath in .app', () => {@@ -169,6 +230,18 @@ describe('detectDesktop — bundle resolution (FR10 D2 a/b/c)', () => {expect(result.bundlePath).toBe('/Applications/OpenKnowledge.app');});+ test('bundled-CLI introspection reports the Beta product for the Beta bundle', () => {+ const result = detectDesktop(+ baseDeps({+ env: { ELECTRON_RUN_AS_NODE: '1' },+ execPath: BETA_APP_EXEC,+ statSync: () => null,+ }),+ );+ expect(result.bundlePath).toBe('/Applications/OpenKnowledge Beta.app');+ expect(result.product).toBe('beta');+ });+test('bundled-CLI introspection — execPath outside .app falls through to stat probes', () => {const result = detectDesktop(baseDeps({@@ -189,7 +262,7 @@ describe('detectDesktop — bundle resolution (FR10 D2 a/b/c)', () => {},}),);- expect(result).toEqual({ available: false, reason: 'no-bundle' });+ expect(result).toEqual({ available: false, reason: 'no-bundle', cliProduct: 'stable' });});});@@ -201,7 +274,7 @@ describe('detectDesktop — env overrides (FR8)', () => {statSync: statForFile(APP_EXEC),}),);- expect(result).toEqual({ available: false, reason: 'force-browser' });+ expect(result).toEqual({ available: false, reason: 'force-browser', cliProduct: 'stable' });});test('OK_FORCE_BROWSER=1 with darwin + bundle still returns false', () => {@@ -239,6 +312,55 @@ describe('detectDesktop — env overrides (FR8)', () => {});});+describe('detectDesktop — unsupported channel override', () => {+ test('an unsupported channel falls back to the npm CLI product and warns once', () => {+ const warn = vi.fn();+ const result = detectDesktop(+ baseDeps({ env: { [OK_CHANNEL_ENV]: 'nightly' }, statSync: statForFile(APP_EXEC), warn }),+ );+ expect(result).toEqual({+ available: true,+ reason: 'available',+ bundlePath: '/Applications/OpenKnowledge.app',+ product: 'stable',+ cliProduct: 'stable',+ });+ expect(warn).toHaveBeenCalledTimes(1);+ expect(warn).toHaveBeenCalledWith(+ `Treating this CLI as OpenKnowledge (Stable) for this command: Unsupported ${OK_CHANNEL_ENV}="nightly". Expected stable or beta.`,+ );+ });++ test('an unsupported channel falls back to the bundled Beta executable, not Stable', () => {+ const warn = vi.fn();+ const result = detectDesktop(+ baseDeps({+ platform: 'linux',+ env: { [OK_CHANNEL_ENV]: 'nightly', ELECTRON_RUN_AS_NODE: '1', DISPLAY: ':0' },+ execPath: '/opt/OpenKnowledge Beta/openknowledge-beta',+ warn,+ }),+ );+ expect(result).toEqual({+ available: true,+ reason: 'available',+ bundlePath: '/opt/OpenKnowledge Beta/openknowledge-beta',+ product: 'beta',+ cliProduct: 'beta',+ });+ expect(warn).toHaveBeenCalledWith(+ `Treating this CLI as OpenKnowledge Beta for this command: Unsupported ${OK_CHANNEL_ENV}="nightly". Expected stable or beta.`,+ );+ });++ test('a supported channel override does not warn', () => {+ const warn = vi.fn();+ const result = detectDesktop(baseDeps({ env: { [OK_CHANNEL_ENV]: 'beta' }, warn }));+ expect(result.cliProduct).toBe('beta');+ expect(warn).not.toHaveBeenCalled();+ });+});+describe('detectDesktop — headless gate (FR9 — CI is intentionally NOT a trigger)', () => {const WIN_EXE ='C:\\Users\\u\\AppData\\Local\\Programs\\@inkeepopen-knowledge-desktop\\OpenKnowledge.exe';@@ -264,7 +386,13 @@ describe('detectDesktop — headless gate (FR9 — CI is intentionally NOT a tristatSync: statForFile(WIN_EXE),}),);- expect(result).toEqual({ available: true, reason: 'available', bundlePath: WIN_EXE });+ expect(result).toEqual({+ available: true,+ reason: 'available',+ bundlePath: WIN_EXE,+ product: 'stable',+ cliProduct: 'stable',+ });});test('win32: isTTY=undefined + CI env → headless', () => {@@ -365,11 +493,17 @@ describe('launchDesktop — spawn shape (FR11)', () => {let logged = '';launchDesktop({ spawn: fakeSpawn, log: (m) => (logged = m), platform: 'darwin' },- { available: true, reason: 'available', bundlePath: '/Applications/OpenKnowledge Beta.app' },+ {+ available: true,+ reason: 'available',+ bundlePath: '/Applications/OpenKnowledge.app',+ product: 'stable',+ cliProduct: 'stable',+ },);expect(captured.command).toBe('open');- expect(captured.args).toEqual(['-a', '/Applications/OpenKnowledge Beta.app']);+ expect(captured.args).toEqual(['-a', '/Applications/OpenKnowledge.app']);expect(captured.opts?.detached).toBe(true);expect(captured.opts?.stdio).toBe('ignore');expect(unrefCalled).toBe(true);@@ -378,6 +512,52 @@ describe('launchDesktop — spawn shape (FR11)', () => {expect(logged).toContain('ok start');});+ test('a Stable CLI opening a Beta-only install names the Beta app but its own start command', () => {+ let spawnedArgs: readonly string[] | undefined;+ const fakeSpawn = ((_command: string, args: readonly string[]) => {+ spawnedArgs = args;+ return { unref: () => {} };+ }) as unknown as Parameters<typeof launchDesktop>[0]['spawn'];+ const detection = detectDesktop(baseDeps({ statSync: statForFile(BETA_APP_EXEC) }));+ let logged = '';+ launchDesktop({ spawn: fakeSpawn, log: (m) => (logged = m), platform: 'darwin' }, detection);++ expect(spawnedArgs).toEqual(['-a', '/Applications/OpenKnowledge Beta.app']);+ expect(logged).toContain('Launching OpenKnowledge Beta desktop');+ expect(logged).toContain('`ok start`');+ expect(logged).not.toContain('ok-beta');+ });++ test('a Beta CLI that falls back to the Stable app still names its own start command', () => {+ const fakeSpawn = (() => ({ unref: () => {} })) as unknown as Parameters<+ typeof launchDesktop+ >[0]['spawn'];+ const detection = detectDesktop(+ baseDeps({ env: { OK_CHANNEL: 'beta' }, statSync: statForFile(APP_EXEC) }),+ );+ let logged = '';+ launchDesktop({ spawn: fakeSpawn, log: (m) => (logged = m), platform: 'darwin' }, detection);++ expect(detection).toMatchObject({ product: 'stable', cliProduct: 'beta' });+ expect(logged).toContain('Launching OpenKnowledge desktop');+ expect(logged).toContain('`ok-beta start`');+ });++ test('skips the spawn when the detection carries no executable', () => {+ let spawned = false;+ const fakeSpawn = (() => {+ spawned = true;+ return { unref: () => {} };+ }) as unknown as Parameters<typeof launchDesktop>[0]['spawn'];+ const logs: string[] = [];+ launchDesktop(+ { spawn: fakeSpawn, log: (m) => logs.push(m), platform: 'darwin' },+ { available: false, reason: 'no-bundle', cliProduct: 'stable' },+ );+ expect(spawned).toBe(false);+ expect(logs).toEqual(['Desktop launch skipped: no resolved desktop executable (caller bug).']);+ });+for (const platform of ['win32', 'linux'] as const) {test(`${platform}: spawns the detected desktop executable directly, detached + unref`, () => {let captured: { command?: string; args?: readonly string[]; opts?: SpawnOptions } = {};@@ -397,7 +577,13 @@ describe('launchDesktop — spawn shape (FR11)', () => {: '/opt/OpenKnowledge/openknowledge';launchDesktop({ spawn: fakeSpawn, log: () => {}, platform },- { available: true, reason: 'available', bundlePath: exe },+ {+ available: true,+ reason: 'available',+ bundlePath: exe,+ product: 'stable',+ cliProduct: 'stable',+ },);expect(captured.command).toBe(exe);@@ -420,7 +606,13 @@ describe('launchDesktop — spawn shape (FR11)', () => {launchDesktop({ spawn: fakeSpawn, log: () => {}, platform: 'darwin' },- { available: true, reason: 'available', bundlePath: '/Applications/OpenKnowledge.app' },+ {+ available: true,+ reason: 'available',+ bundlePath: '/Applications/OpenKnowledge.app',+ product: 'stable',+ cliProduct: 'stable',+ },);expect(captured.opts?.env).toBeDefined();diff --git a/packages/cli/src/commands/desktop-dispatch.ts b/packages/cli/src/commands/desktop-dispatch.tsindex 71199aec4..18e03f6b9 100644--- a/packages/cli/src/commands/desktop-dispatch.ts+++ b/packages/cli/src/commands/desktop-dispatch.ts@@ -4,14 +4,50 @@ import { homedir } from 'node:os';import { join, win32 } from 'node:path';import {DESKTOP_PRODUCTS,+ type DesktopProduct,+ type DesktopProductName,+ desktopChannelLabel,desktopWindowsExecutableName,desktopWindowsInstallDirNames,+ OK_CHANNEL_ENV,+ resolveDesktopProductName,} from '@inkeep/open-knowledge-core';import { spawnDetachedScrubbed } from '../utils/detached-spawn.ts';export const DESKTOP_BUNDLE_ID = DESKTOP_PRODUCTS.stable.appId;-const DESKTOP_PRODUCT_LIST = [DESKTOP_PRODUCTS.stable, DESKTOP_PRODUCTS.beta] as const;+const ALL_DESKTOP_PRODUCTS = Object.keys(DESKTOP_PRODUCTS) as readonly DesktopProductName[];++const PUBLIC_DESKTOP_PRODUCTS: readonly DesktopProductName[] = ['stable', 'beta'];++interface ResolvedDesktop {+ readonly path: string;+ readonly product: DesktopProductName;+}++export function runningDesktopProduct(+ env: NodeJS.ProcessEnv,+ execPath: string,+ warn: (message: string) => void = (message) => console.error(message),+): DesktopProductName {+ try {+ return resolveDesktopProductName(env, execPath);+ } catch (err) {+ const product = resolveDesktopProductName({ ...env, [OK_CHANNEL_ENV]: undefined }, execPath);+ warn(+ `Treating this CLI as ${desktopChannelLabel(product)} for this command: ${err instanceof Error ? err.message : String(err)}`,+ );+ return product;+ }+}++export function desktopProductsVisibleTo(+ cliProduct: DesktopProductName,+): readonly DesktopProductName[] {+ return PUBLIC_DESKTOP_PRODUCTS.includes(cliProduct)+ ? PUBLIC_DESKTOP_PRODUCTS+ : [cliProduct, ...PUBLIC_DESKTOP_PRODUCTS];+}type DetectReason =| 'available'@@ -22,10 +58,27 @@ type DetectReason =| 'headless'| 'stat-error';-export interface DetectResult {+interface DetectResultBase {readonly available: boolean;readonly reason: DetectReason;- readonly bundlePath?: string;+ readonly cliProduct: DesktopProductName;+}++export type DetectResult =+ | (DetectResultBase & { readonly bundlePath?: undefined; readonly product?: undefined })+ | (DetectResultBase & { readonly bundlePath: string; readonly product: DesktopProductName });++export interface DesktopAppTarget {+ readonly bundlePath: string;+ readonly protocolScheme: DesktopProduct['protocolScheme'];+}++export function desktopAppTarget(detection: DetectResult): DesktopAppTarget | null {+ if (detection.bundlePath === undefined) return null;+ return {+ bundlePath: detection.bundlePath,+ protocolScheme: DESKTOP_PRODUCTS[detection.product].protocolScheme,+ };}export interface DetectDeps {@@ -37,6 +90,7 @@ export interface DetectDeps {path: string,) => { isFile?: () => boolean; isDirectory?: () => boolean } | null;readonly homeDir?: string;+ readonly warn?: (message: string) => void;}export function createRealDetectDeps(): DetectDeps {@@ -55,20 +109,29 @@ export function createRealDetectDeps(): DetectDeps {};}-function resolveBundlePath(deps: DetectDeps): string | null {+function resolveBundlePath(+ deps: DetectDeps,+ cliProduct: DesktopProductName,+): ResolvedDesktop | null {if (deps.env.ELECTRON_RUN_AS_NODE === '1') {const m = /(.+?\.app)\/Contents\/MacOS\//.exec(deps.execPath);if (m?.[1]) {- return m[1];+ const bundle = m[1];+ const product =+ ALL_DESKTOP_PRODUCTS.find((name) =>+ bundle.endsWith(`/${DESKTOP_PRODUCTS[name].productName}.app`),+ ) ?? cliProduct;+ return { path: bundle, product };}}const home = deps.homeDir ?? homedir();- for (const product of DESKTOP_PRODUCT_LIST) {+ for (const product of desktopProductsVisibleTo(cliProduct)) {+ const { productName } = DESKTOP_PRODUCTS[product];for (const applicationsDir of [join(home, 'Applications'), '/Applications']) {- const bundlePath = join(applicationsDir, `${product.productName}.app`);- if (probeExecutable(deps, join(bundlePath, 'Contents', 'MacOS', product.productName))) {- return bundlePath;+ const bundlePath = join(applicationsDir, `${productName}.app`);+ if (probeExecutable(deps, join(bundlePath, 'Contents', 'MacOS', productName))) {+ return { path: bundlePath, product };}}}@@ -86,86 +149,96 @@ function probeExecutable(deps: DetectDeps, path: string): boolean {}}-function resolveWindowsExecutable(deps: DetectDeps): string | null {+function resolveWindowsExecutable(+ deps: DetectDeps,+ cliProduct: DesktopProductName,+): ResolvedDesktop | null {if (deps.env.ELECTRON_RUN_AS_NODE === '1') {- const bundledProduct = DESKTOP_PRODUCT_LIST.find((product) =>+ const bundledProduct = ALL_DESKTOP_PRODUCTS.find((name) =>deps.execPath.toLowerCase()- .endsWith(`\\${desktopWindowsExecutableName(product).toLowerCase()}`),+ .endsWith(`\\${desktopWindowsExecutableName(DESKTOP_PRODUCTS[name]).toLowerCase()}`),);- if (bundledProduct) return deps.execPath;+ if (bundledProduct) return { path: deps.execPath, product: bundledProduct };}const localAppData = deps.env.LOCALAPPDATA;if (localAppData) {- for (const product of DESKTOP_PRODUCT_LIST) {- for (const dirName of desktopWindowsInstallDirNames(product)) {+ for (const product of desktopProductsVisibleTo(cliProduct)) {+ for (const dirName of desktopWindowsInstallDirNames(DESKTOP_PRODUCTS[product])) {const exe = win32.join(localAppData,'Programs',dirName,- desktopWindowsExecutableName(product),+ desktopWindowsExecutableName(DESKTOP_PRODUCTS[product]),);- if (probeExecutable(deps, exe)) return exe;+ if (probeExecutable(deps, exe)) return { path: exe, product };}}}return null;}-function resolveLinuxExecutable(deps: DetectDeps): string | null {+function resolveLinuxExecutable(+ deps: DetectDeps,+ cliProduct: DesktopProductName,+): ResolvedDesktop | null {if (deps.env.ELECTRON_RUN_AS_NODE === '1') {- const bundledProduct = DESKTOP_PRODUCT_LIST.find((product) =>- deps.execPath.endsWith(`/${product.linuxExecutableName}`),+ const bundledProduct = ALL_DESKTOP_PRODUCTS.find((name) =>+ deps.execPath.endsWith(`/${DESKTOP_PRODUCTS[name].linuxExecutableName}`),);- if (bundledProduct) return deps.execPath;+ if (bundledProduct) return { path: deps.execPath, product: bundledProduct };}- for (const product of DESKTOP_PRODUCT_LIST) {- const debExe = `/opt/${product.productName}/${product.linuxExecutableName}`;- if (probeExecutable(deps, debExe)) return debExe;+ for (const product of desktopProductsVisibleTo(cliProduct)) {+ const { productName, linuxExecutableName } = DESKTOP_PRODUCTS[product];+ const debExe = `/opt/${productName}/${linuxExecutableName}`;+ if (probeExecutable(deps, debExe)) return { path: debExe, product };}return null;}export function detectDesktop(deps: DetectDeps): DetectResult {+ const cliProduct = runningDesktopProduct(deps.env, deps.execPath, deps.warn);+if (deps.env.OK_FORCE_BROWSER === '1') {- return { available: false, reason: 'force-browser' };+ return { available: false, reason: 'force-browser', cliProduct };}if (deps.platform !== 'darwin' && deps.platform !== 'win32' && deps.platform !== 'linux') {- return { available: false, reason: 'unsupported-platform' };+ return { available: false, reason: 'unsupported-platform', cliProduct };}- let bundlePath: string | null;+ let resolved: ResolvedDesktop | null;try {- bundlePath =+ resolved =deps.platform === 'darwin'- ? resolveBundlePath(deps)+ ? resolveBundlePath(deps, cliProduct): deps.platform === 'win32'- ? resolveWindowsExecutable(deps)- : resolveLinuxExecutable(deps);+ ? resolveWindowsExecutable(deps, cliProduct)+ : resolveLinuxExecutable(deps, cliProduct);} catch {- return { available: false, reason: 'stat-error' };+ return { available: false, reason: 'stat-error', cliProduct };}- if (!bundlePath) {- return { available: false, reason: 'no-bundle' };+ if (!resolved) {+ return { available: false, reason: 'no-bundle', cliProduct };}+ const app = { bundlePath: resolved.path, product: resolved.product, cliProduct };if (deps.env.OK_FORCE_DESKTOP === '1') {- return { available: true, reason: 'available', bundlePath };+ return { available: true, reason: 'available', ...app };}const ttyInteractive =deps.isTTY === true || (deps.platform === 'win32' && deps.isTTY === undefined && !deps.env.CI);if (!ttyInteractive || deps.env.SSH_CONNECTION || deps.env.SSH_TTY) {- return { available: false, reason: 'headless', bundlePath };+ return { available: false, reason: 'headless', ...app };}if (deps.platform === 'linux' && !deps.env.DISPLAY && !deps.env.WAYLAND_DISPLAY) {- return { available: false, reason: 'headless', bundlePath };+ return { available: false, reason: 'headless', ...app };}- return { available: true, reason: 'available', bundlePath };+ return { available: true, reason: 'available', ...app };}interface LaunchDeps {@@ -174,17 +247,19 @@ interface LaunchDeps {readonly platform?: NodeJS.Platform;}-export function launchDesktop(deps: LaunchDeps, detection?: DetectResult): void {+export function launchDesktop(deps: LaunchDeps, detection: DetectResult): void {const log = deps.log ?? ((m) => console.error(m));const platform = deps.platform ?? process.platform;- log(- 'Launching OpenKnowledge desktop (use `ok start` for the browser server, or `OK_FORCE_BROWSER=1` to always skip)',- );- const target = detection?.bundlePath;- if (!target) {+ if (detection.bundlePath === undefined) {log('Desktop launch skipped: no resolved desktop executable (caller bug).');return;}+ const { productName } = DESKTOP_PRODUCTS[detection.product];+ const [cliCommandName] = DESKTOP_PRODUCTS[detection.cliProduct].cliCommandNames;+ log(+ `Launching ${productName} desktop (use \`${cliCommandName} start\` for the browser server, or \`OK_FORCE_BROWSER=1\` to always skip)`,+ );+ const target = detection.bundlePath;if (platform === 'darwin') {spawnDetachedScrubbed('open', ['-a', target], { spawn: deps.spawn });return;diff --git a/packages/cli/src/commands/open.test.ts b/packages/cli/src/commands/open.test.tsindex c1103f0db..4c0ab872a 100644--- a/packages/cli/src/commands/open.test.ts+++ b/packages/cli/src/commands/open.test.ts@@ -1,7 +1,23 @@import { describe, expect, test } from 'vitest';import type { OpenTargetOptions } from '../utils/open-target.ts';+import {+ type DesktopAppTarget,+ type DetectDeps,+ type DetectResult,+ detectDesktop,+} from './desktop-dispatch.ts';import { createRealOpenDeps, type OpenDeps, runOpen } from './open.ts';+const STABLE_APP: DesktopAppTarget = {+ bundlePath: '/Applications/OpenKnowledge.app',+ protocolScheme: 'openknowledge',+};++const BETA_APP: DesktopAppTarget = {+ bundlePath: '/Applications/OpenKnowledge Beta.app',+ protocolScheme: 'openknowledge-beta',+};+function makeDeps(overrides: Partial<OpenDeps> = {}): {deps: OpenDeps;opened: string[];@@ -14,7 +30,7 @@ function makeDeps(overrides: Partial<OpenDeps> = {}): {const logs: string[] = [];const errors: string[] = [];const deps: OpenDeps = {- detectBundlePath: () => null,+ detectDesktopApp: () => null,resolveBaseUrl: () => null,classifyName: () => 'doc',openTarget: async (t, options) => {@@ -35,7 +51,7 @@ function makeDeps(overrides: Partial<OpenDeps> = {}): {describe('runOpen', () => {test('doc with a desktop bundle → openknowledge:// deep link, exit 0', async () => {const { deps, opened } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,});const code = await runOpen('bim-brain/log', { project: '/abs/proj' }, deps);expect(code).toBe(0);@@ -44,7 +60,7 @@ describe('runOpen', () => {test('doc with a desktop bundle threads the verified bundle path to openTarget', async () => {const { deps, openedOptions } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,});await runOpen('bim-brain/log', { project: '/abs/proj' }, deps);expect(openedOptions).toEqual([{ desktopBundlePath: '/Applications/OpenKnowledge.app' }]);@@ -52,7 +68,7 @@ describe('runOpen', () => {test('doc, no bundle but UI running → browser route, exit 0', async () => {const { deps, opened } = makeDeps({- detectBundlePath: () => null,+ detectDesktopApp: () => null,resolveBaseUrl: () => 'http://localhost:5173',});const code = await runOpen('specs/foo/SPEC', { project: '/p' }, deps);@@ -62,7 +78,7 @@ describe('runOpen', () => {test('launcher failure returns exit 1 without printing a success message', async () => {const { deps, logs, errors } = makeDeps({- detectBundlePath: () => null,+ detectDesktopApp: () => null,resolveBaseUrl: () => 'http://localhost:5173',openTarget: async () => ({ ok: false, reason: 'not-installed' }),});@@ -87,7 +103,7 @@ describe('runOpen', () => {test('folder with a desktop bundle → folder= deep link, exit 0', async () => {const { deps, opened, openedOptions } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,});const code = await runOpen('specs/foo/', { project: '/p' }, deps);expect(code).toBe(0);@@ -97,7 +113,7 @@ describe('runOpen', () => {test('folder, no bundle but UI running → browser folder route, exit 0', async () => {const { deps, opened } = makeDeps({- detectBundlePath: () => null,+ detectDesktopApp: () => null,resolveBaseUrl: () => 'http://localhost:5173',});const code = await runOpen('specs/foo/', { project: '/p' }, deps);@@ -107,7 +123,7 @@ describe('runOpen', () => {test('auto-detects a folder from disk (no trailing slash needed)', async () => {const { deps, opened } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,classifyName: () => 'folder',});const code = await runOpen('specs/foo', { project: '/p' }, deps);@@ -127,7 +143,7 @@ describe('runOpen', () => {test('skill with a desktop bundle → rides doc=__skill__/<scope>/<name> deep link', async () => {const { deps, opened, openedOptions } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,});const code = await runOpen('trip-log', { skill: true, project: '/p' }, deps);expect(code).toBe(0);@@ -146,7 +162,7 @@ describe('runOpen', () => {test('skill with an invalid --scope → error, exit 1', async () => {const { deps, errors } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,});const code = await runOpen('trip-log', { skill: true, scope: 'nonsense', project: '/p' }, deps);expect(code).toBe(1);@@ -163,7 +179,7 @@ describe('runOpen', () => {test('skill name with a traversal/unsafe segment → error before any open', async () => {const { deps, opened, errors } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,});for (const bad of ['../../etc', '/abs', 'a\\b']) {const code = await runOpen(bad, { skill: true, project: '/p' }, deps);@@ -196,7 +212,7 @@ describe('runOpen', () => {'rejects names the desktop parser would drop (%s) instead of false success',async (_label, name) => {const { deps, opened, errors } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,});const code = await runOpen(name, { project: '/p' }, deps);expect(code).toBe(1);@@ -215,7 +231,7 @@ describe('runOpen', () => {test('doc deep link encodes the whole name including the slash (%2F)', async () => {const { deps, opened } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,});const code = await runOpen('notes/My Doc#1', { project: '/p' }, deps);expect(code).toBe(0);@@ -231,34 +247,109 @@ describe('runOpen', () => {});describe('createRealOpenDeps wiring', () => {- test('detectBundlePath collapses a bundlePath-absent DetectResult to null (the force-browser/no-bundle contract)', () => {- const deps = createRealOpenDeps(() => ({ available: false, reason: 'force-browser' }));- expect(deps.detectBundlePath()).toBeNull();+ test('detectDesktopApp collapses a bundlePath-absent DetectResult to null (the force-browser/no-bundle contract)', () => {+ const deps = createRealOpenDeps(() => ({+ available: false,+ reason: 'force-browser',+ cliProduct: 'stable',+ }));+ expect(deps.detectDesktopApp()).toBeNull();});- test('detectBundlePath returns the bundle path when detect reports one', () => {+ test('detectDesktopApp returns the bundle path and Stable scheme when detect reports a Stable bundle', () => {const deps = createRealOpenDeps(() => ({available: true,reason: 'available',bundlePath: '/Applications/OpenKnowledge.app',+ product: 'stable',+ cliProduct: 'stable',}));- expect(deps.detectBundlePath()).toBe('/Applications/OpenKnowledge.app');+ expect(deps.detectDesktopApp()).toEqual(STABLE_APP);});- test('detectBundlePath returns the bundle path when available:false but bundlePath is set', () => {+ test('detectDesktopApp returns the bundle path when available:false but bundlePath is set', () => {const deps = createRealOpenDeps(() => ({available: false,reason: 'headless',bundlePath: '/Applications/OpenKnowledge.app',+ product: 'stable',+ cliProduct: 'stable',}));- expect(deps.detectBundlePath()).toBe('/Applications/OpenKnowledge.app');+ expect(deps.detectDesktopApp()).toEqual(STABLE_APP);+ });++ test('detectDesktopApp carries the Beta scheme for a Beta bundle', () => {+ const deps = createRealOpenDeps(() => ({+ available: true,+ reason: 'available',+ bundlePath: '/Applications/OpenKnowledge Beta.app',+ product: 'beta',+ cliProduct: 'beta',+ }));+ expect(deps.detectDesktopApp()).toEqual(BETA_APP);+ });+});++describe('Beta desktop app', () => {+ const macBetaCli: DetectDeps = {+ platform: 'darwin',+ env: { ELECTRON_RUN_AS_NODE: '1' },+ execPath: '/Applications/OpenKnowledge Beta.app/Contents/MacOS/OpenKnowledge Beta',+ isTTY: true,+ statSync: () => null,+ };++ function withRealDetection(detect: () => DetectResult): ReturnType<typeof makeDeps> {+ const recorder = makeDeps();+ const { detectDesktopApp: _stubbed, ...stubs } = recorder.deps;+ return { ...recorder, deps: { ...createRealOpenDeps(detect), ...stubs } };+ }++ test('a doc deep link uses the Beta scheme so it reaches the Beta app', async () => {+ const { deps, opened, openedOptions } = makeDeps({ detectDesktopApp: () => BETA_APP });+ const code = await runOpen('notes/plan', { project: '/p' }, deps);+ expect(code).toBe(0);+ expect(opened).toEqual(['openknowledge-beta://open?project=%2Fp&doc=notes%2Fplan']);+ expect(openedOptions).toEqual([{ desktopBundlePath: BETA_APP.bundlePath }]);+ });++ test('folder and skill deep links use the Beta scheme', async () => {+ const { deps, opened } = makeDeps({+ detectDesktopApp: () => BETA_APP,+ classifyName: () => 'folder',+ });+ await runOpen('specs', { project: '/p' }, deps);+ await runOpen('trip-log', { project: '/p', skill: true }, deps);+ expect(opened).toEqual([+ 'openknowledge-beta://open?project=%2Fp&folder=specs',+ 'openknowledge-beta://open?project=%2Fp&doc=__skill__%2Fproject%2Ftrip-log',+ ]);+ });++ test('the bundled Beta CLI on macOS deep-links into the Beta app, not Stable', async () => {+ const { deps, opened, openedOptions } = withRealDetection(() => detectDesktop(macBetaCli));+ const code = await runOpen('notes/plan', { project: '/p' }, deps);+ expect(code).toBe(0);+ expect(opened).toEqual(['openknowledge-beta://open?project=%2Fp&doc=notes%2Fplan']);+ expect(openedOptions).toEqual([{ desktopBundlePath: BETA_APP.bundlePath }]);+ });++ test('the bundled Stable CLI keeps the Stable scheme', async () => {+ const { deps, opened } = withRealDetection(() =>+ detectDesktop({+ ...macBetaCli,+ execPath: '/Applications/OpenKnowledge.app/Contents/MacOS/OpenKnowledge',+ }),+ );+ await runOpen('notes/plan', { project: '/p' }, deps);+ expect(opened).toEqual(['openknowledge://open?project=%2Fp&doc=notes%2Fplan']);});});describe('resolved-project disclosure', () => {test('doc open names the absolute project root', async () => {const { deps, logs } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,});const code = await runOpen('specs/foo/SPEC', { project: '/abs/proj' }, deps);expect(code).toBe(0);@@ -267,7 +358,7 @@ describe('resolved-project disclosure', () => {test('folder open names the absolute project root', async () => {const { deps, logs } = makeDeps({- detectBundlePath: () => null,+ detectDesktopApp: () => null,resolveBaseUrl: () => 'http://localhost:5173',classifyName: () => 'folder',});@@ -278,7 +369,7 @@ describe('resolved-project disclosure', () => {test('skill open names the absolute project root', async () => {const { deps, logs } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,});const code = await runOpen('my-skill', { skill: true, project: '/abs/proj' }, deps);expect(code).toBe(0);@@ -287,7 +378,7 @@ describe('resolved-project disclosure', () => {test('a failed open discloses nothing (no false project claim)', async () => {const { deps, logs } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,openTarget: async () => ({ ok: false, reason: 'not-installed' }),});const code = await runOpen('doc', { project: '/abs/proj' }, deps);@@ -297,7 +388,7 @@ describe('resolved-project disclosure', () => {test('a nested project root names BOTH roots, once', async () => {const { deps, logs } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,findAncestorProject: () => '/abs',});const code = await runOpen('doc', { project: '/abs/nested' }, deps);@@ -310,7 +401,7 @@ describe('resolved-project disclosure', () => {test('a non-nested project root says nothing extra', async () => {const { deps, logs } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,findAncestorProject: () => null,});await runOpen('doc', { project: '/abs/proj' }, deps);@@ -321,7 +412,7 @@ describe('resolved-project disclosure', () => {describe('explicit --project validation', () => {test('refuses an override that does not name a project, without opening anything', async () => {const { deps, opened, errors } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,isProjectRoot: () => false,});const code = await runOpen('README', { project: '/tmp/not-a-project' }, deps);@@ -332,7 +423,7 @@ describe('explicit --project validation', () => {test('honors an override that does name a project', async () => {const { deps, opened } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,isProjectRoot: () => true,});const code = await runOpen('README', { project: '/tmp/real-project' }, deps);@@ -343,7 +434,7 @@ describe('explicit --project validation', () => {test('an absent override keeps the cwd default and is never validated', async () => {let consulted = false;const { deps, logs } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,isProjectRoot: () => {consulted = true;return false;@@ -360,7 +451,7 @@ describe('explicit --project validation', () => {describe('running outside any project', () => {test('does not call the cwd fallback a project', async () => {const { deps, logs } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,enclosingProject: () => null,});const code = await runOpen('notes', {}, deps);@@ -371,7 +462,7 @@ describe('running outside any project', () => {test('does not derive a nested-project note from a non-project directory', async () => {const { deps, logs } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,enclosingProject: () => null,findAncestorProject: () => '/repo/root',});@@ -383,7 +474,7 @@ describe('running outside any project', () => {describe('running from a subdirectory of a project', () => {test('acts on the enclosing project, not the subdirectory it was run from', async () => {const { deps, opened, logs } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,enclosingProject: () => '/repo/root',findAncestorProject: () => null,});@@ -395,7 +486,7 @@ describe('running from a subdirectory of a project', () => {test('does not claim a nested topology just because it ran below the root', async () => {const { deps, logs } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,enclosingProject: () => '/repo/root',findAncestorProject: () => null,});@@ -406,7 +497,7 @@ describe('running from a subdirectory of a project', () => {test('an explicit --project is never overridden by the cwd lookup', async () => {let consulted = false;const { deps, opened } = makeDeps({- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,enclosingProject: () => {consulted = true;return '/repo/root';diff --git a/packages/cli/src/commands/open.ts b/packages/cli/src/commands/open.tsindex d9093f971..ff17c80d3 100644--- a/packages/cli/src/commands/open.ts+++ b/packages/cli/src/commands/open.ts@@ -16,7 +16,13 @@ import {openTargetFailureMessage,openTarget as openTargetReal,} from '../utils/open-target.ts';-import { createRealDetectDeps, type DetectResult, detectDesktop } from './desktop-dispatch.ts';+import {+ createRealDetectDeps,+ type DesktopAppTarget,+ type DetectResult,+ desktopAppTarget,+ detectDesktop,+} from './desktop-dispatch.ts';export interface OpenOptions {skill?: boolean;@@ -25,7 +31,7 @@ export interface OpenOptions {}export interface OpenDeps {- detectBundlePath: () => string | null;+ detectDesktopApp: () => DesktopAppTarget | null;resolveBaseUrl: (projectDir: string) => string | null;classifyName: (projectDir: string, name: string) => 'doc' | 'folder';openTarget: (@@ -43,7 +49,7 @@ export function createRealOpenDeps(detect: () => DetectResult = () => detectDesktop(createRealDetectDeps()),): OpenDeps {return {- detectBundlePath: () => detect().bundlePath ?? null,+ detectDesktopApp: () => desktopAppTarget(detect()),resolveBaseUrl: (projectDir) => resolveUiInfo({ lockDir: resolveLockDir(projectDir) }).baseUrl,classifyName: (projectDir, name) => {const abs = join(projectDir, name);@@ -146,9 +152,9 @@ export async function runOpen(name: string, options: OpenOptions, deps: OpenDeps);return 1;}- const bundlePath = deps.detectBundlePath();- if (bundlePath) {- const deepLink = `openknowledge://open?project=${encodeURIComponent(+ const desktopApp = deps.detectDesktopApp();+ if (desktopApp) {+ const deepLink = `${desktopApp.protocolScheme}://open?project=${encodeURIComponent(projectDir,)}&doc=${encodeURIComponent(`__skill__/${scope}/${cleanName}`)}`;return openAndReport(@@ -157,7 +163,7 @@ export async function runOpen(name: string, options: OpenOptions, deps: OpenDepsprojectDir,isProject,deps,- bundlePath,+ desktopApp.bundlePath,);}const baseUrl = deps.resolveBaseUrl(projectDir);@@ -176,10 +182,10 @@ export async function runOpen(name: string, options: OpenOptions, deps: OpenDepsconst isFolder = /\/+$/.test(name) || deps.classifyName(projectDir, cleanName) === 'folder';- const bundlePath = deps.detectBundlePath();+ const desktopApp = deps.detectDesktopApp();if (isFolder) {- if (bundlePath) {- const deepLink = `openknowledge://open?project=${encodeURIComponent(+ if (desktopApp) {+ const deepLink = `${desktopApp.protocolScheme}://open?project=${encodeURIComponent(projectDir,)}&folder=${encodeURIComponent(cleanName)}`;return openAndReport(@@ -188,7 +194,7 @@ export async function runOpen(name: string, options: OpenOptions, deps: OpenDepsprojectDir,isProject,deps,- bundlePath,+ desktopApp.bundlePath,);}const baseUrl = deps.resolveBaseUrl(projectDir);@@ -205,8 +211,8 @@ export async function runOpen(name: string, options: OpenOptions, deps: OpenDepsreturn noTargetError(deps);}- if (bundlePath) {- const deepLink = `openknowledge://open?project=${encodeURIComponent(+ if (desktopApp) {+ const deepLink = `${desktopApp.protocolScheme}://open?project=${encodeURIComponent(projectDir,)}&doc=${encodeURIComponent(cleanName)}`;return openAndReport(@@ -215,7 +221,7 @@ export async function runOpen(name: string, options: OpenOptions, deps: OpenDepsprojectDir,isProject,deps,- bundlePath,+ desktopApp.bundlePath,);}const baseUrl = deps.resolveBaseUrl(projectDir);diff --git a/packages/cli/src/commands/single-file-open.test.ts b/packages/cli/src/commands/single-file-open.test.tsindex b9bf2a41c..190efcfd8 100644--- a/packages/cli/src/commands/single-file-open.test.ts+++ b/packages/cli/src/commands/single-file-open.test.ts@@ -7,7 +7,17 @@ import {} from '@inkeep/open-knowledge-server';import { describe, expect, test } from 'vitest';import type { OpenTargetOptions } from '../utils/open-target.ts';-import { runSingleFileOpen, type SingleFileOpenDeps } from './single-file-open.ts';+import { type DesktopAppTarget, detectDesktop } from './desktop-dispatch.ts';+import {+ createRealSingleFileOpenDeps,+ runSingleFileOpen,+ type SingleFileOpenDeps,+} from './single-file-open.ts';++const STABLE_APP: DesktopAppTarget = {+ bundlePath: '/Applications/OpenKnowledge.app',+ protocolScheme: 'openknowledge',+};interface Recorder {prepareOptions: Array<PrepareSingleFileOpenOptions | undefined>;@@ -38,7 +48,7 @@ function makeDeps(if (!overrides.plan) throw new Error('no plan configured');return overrides.plan;},- detectBundlePath: overrides.detectBundlePath ?? (() => null),+ detectDesktopApp: overrides.detectDesktopApp ?? (() => null),openTarget:overrides.openTarget ??(async (t, options) => {@@ -90,7 +100,7 @@ describe('runSingleFileOpen', () => {test('ephemeral mode with a desktop bundle deep-links the file to the app', async () => {const { deps, rec } = makeDeps({plan: ephemeralPlan,- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,});const code = await runSingleFileOpen('/Users/me/notes/todo.md', deps);expect(code).toBe(0);@@ -103,10 +113,34 @@ describe('runSingleFileOpen', () => {expect(rec.browserOpens).toHaveLength(0);});+ test('ephemeral mode with the bundled Beta CLI on Linux deep-links into the Beta app', async () => {+ const execPath = '/opt/OpenKnowledge Beta/openknowledge-beta';+ const real = createRealSingleFileOpenDeps(() =>+ detectDesktop({+ platform: 'linux',+ env: { ELECTRON_RUN_AS_NODE: '1', DISPLAY: ':0' },+ execPath,+ isTTY: true,+ statSync: () => null,+ }),+ );+ const { deps, rec } = makeDeps({+ plan: ephemeralPlan,+ detectDesktopApp: real.detectDesktopApp,+ });+ const code = await runSingleFileOpen('/Users/me/notes/todo.md', deps);+ expect(code).toBe(0);+ expect(rec.openTargets).toEqual([+ `openknowledge-beta://open?file=${encodeURIComponent('/Users/me/notes/todo.md')}`,+ ]);+ expect(rec.openTargetOptions).toEqual([{ desktopBundlePath: execPath }]);+ expect(rec.browserOpens).toHaveLength(0);+ });+test('ephemeral mode reports launcher failures as exit code 1', async () => {const { deps, rec } = makeDeps({plan: ephemeralPlan,- detectBundlePath: () => '/Applications/OpenKnowledge.app',+ detectDesktopApp: () => STABLE_APP,openTarget: async () => ({ ok: false, reason: 'not-installed' }),});@@ -119,7 +153,7 @@ describe('runSingleFileOpen', () => {});test('ephemeral mode with no desktop bundle falls back to the browser session', async () => {- const { deps, rec } = makeDeps({ plan: ephemeralPlan, detectBundlePath: () => null });+ const { deps, rec } = makeDeps({ plan: ephemeralPlan, detectDesktopApp: () => null });await runSingleFileOpen('/Users/me/notes/todo.md', deps);expect(rec.browserOpens).toEqual([ephemeralPlan]);expect(rec.openTargets).toHaveLength(0);diff --git a/packages/cli/src/commands/single-file-open.ts b/packages/cli/src/commands/single-file-open.tsindex aa786310c..b220ceeff 100644--- a/packages/cli/src/commands/single-file-open.ts+++ b/packages/cli/src/commands/single-file-open.ts@@ -15,14 +15,20 @@ import {openTargetFailureMessage,openTarget as openTargetReal,} from '../utils/open-target.ts';-import { createRealDetectDeps, type DetectResult, detectDesktop } from './desktop-dispatch.ts';+import {+ createRealDetectDeps,+ type DesktopAppTarget,+ type DetectResult,+ desktopAppTarget,+ detectDesktop,+} from './desktop-dispatch.ts';import { createRealOpenDeps, runOpen } from './open.ts';const EPHEMERAL_IDLE_SHUTDOWN_MS = 10 * 60 * 1000;export interface SingleFileOpenDeps {prepare: (filePath: string, options?: PrepareSingleFileOpenOptions) => SingleFileOpenPlan;- detectBundlePath: () => string | null;+ detectDesktopApp: () => DesktopAppTarget | null;openTarget: (target: string,options?: Pick<OpenTargetOptions, 'desktopBundlePath'>,@@ -38,7 +44,7 @@ export function createRealSingleFileOpenDeps(): SingleFileOpenDeps {return {prepare: prepareSingleFileOpen,- detectBundlePath: () => detect().bundlePath ?? null,+ detectDesktopApp: () => desktopAppTarget(detect()),openTarget: openTargetReal,runProjectOpen: (docName, projectRoot) =>runOpen(docName, { project: projectRoot }, createRealOpenDeps()),@@ -77,10 +83,10 @@ export async function runSingleFileOpen(return await deps.runProjectOpen(plan.docName, plan.projectRoot);}- const bundlePath = deps.detectBundlePath();- if (bundlePath) {- const deepLink = `openknowledge://open?file=${encodeURIComponent(plan.canonicalFilePath)}`;- const outcome = await deps.openTarget(deepLink, { desktopBundlePath: bundlePath });+ const desktopApp = deps.detectDesktopApp();+ if (desktopApp) {+ const deepLink = `${desktopApp.protocolScheme}://open?file=${encodeURIComponent(plan.canonicalFilePath)}`;+ const outcome = await deps.openTarget(deepLink, { desktopBundlePath: desktopApp.bundlePath });if (!outcome.ok) {deps.error(`Could not open the OpenKnowledge desktop app: ${openTargetFailureMessage(diff --git a/packages/cli/src/commands/uninstall.test.ts b/packages/cli/src/commands/uninstall.test.tsindex 683fbd87e..b95215a50 100644--- a/packages/cli/src/commands/uninstall.test.ts+++ b/packages/cli/src/commands/uninstall.test.ts@@ -63,6 +63,30 @@ describe('detectInstallMethods', () => {]);});+ test('a Beta CLI lists the same Stable and Beta apps as a Stable CLI', () => {+ const home = '/Users/jane';+ const installed = new Set([+ '/Applications/OpenKnowledge.app',+ '/Applications/OpenKnowledge Beta.app',+ ]);+ const labels = (execPath: string) =>+ detectInstallMethods(+ home,+ undefined,+ () => null,+ (path) => installed.has(path),+ { platform: 'darwin', env: {}, execPath },+ ).map((method) => method.label);+ const expected = [+ 'OpenKnowledge (/Applications/OpenKnowledge.app)',+ 'OpenKnowledge Beta (/Applications/OpenKnowledge Beta.app)',+ ];+ expect(labels('/usr/local/bin/node')).toEqual(expected);+ expect(+ labels('/Applications/OpenKnowledge Beta.app/Contents/MacOS/OpenKnowledge Beta'),+ ).toEqual(expected);+ });+test('detects the Windows NSIS install and points at Settings → Apps', () => {const localAppData = 'C:\\Users\\Jane\\AppData\\Local';const exe = join(@@ -301,6 +325,38 @@ describe('runUninstall', () => {}});+ test.each([+ ['/usr/local/bin/node', 'The openknowledge:// URL scheme'],+ ['/opt/OpenKnowledge Beta/openknowledge-beta', 'The openknowledge-beta:// URL scheme'],+ ])('names the URL scheme of the CLI that ran (%s)', async (execPath, note) => {+ const home = mkdtempSync(join(tmpdir(), 'ok-uninstall-scheme-'));+ try {+ const result = await runUninstall({+ home,+ cwd: home,+ env: {},+ execPath,+ platform: 'darwin',+ yes: true,+ deps: {+ discoverLockDirs: async () => [],+ resolveRecentProjects: async () => [],+ detectInstallMethods: () => [],+ probeClients: async () => null,+ runRemovalDeps: {+ clearToken: async () => ({ touched: [] }),+ clearEmbeddingsKey: async () => ({ touched: [] }),+ stopServer: async () => ({ stopped: 0, failed: [] }),+ },+ },+ });+ expect(result.status).toBe('done');+ expect(result.message).toContain(note);+ } finally {+ rmSync(home, { recursive: true, force: true });+ }+ });+test('dry-run renders the plan + binary instructions, removing nothing', async () => {const home = mkdtempSync(join(tmpdir(), 'ok-uninst-cmd-'));try {diff --git a/packages/cli/src/commands/uninstall.ts b/packages/cli/src/commands/uninstall.tsindex 586ebd8c3..9f465e159 100644--- a/packages/cli/src/commands/uninstall.ts+++ b/packages/cli/src/commands/uninstall.ts@@ -16,6 +16,7 @@ import { readPathInstallMarker } from '../integrations/path-shim.ts';import { accent, dim, error as errorColor, info, success, warning } from '../ui/colors.ts';import { confirmDestructive } from '../ui/confirm.ts';import { discoverLockDirs } from '../utils/process-scan.ts';+import { desktopProductsVisibleTo, runningDesktopProduct } from './desktop-dispatch.ts';import {buildUninstallPlan,describeAttachedClients,@@ -37,21 +38,22 @@ export interface InstallMethod {instruction: string;}-const DESKTOP_PRODUCT_LIST = [DESKTOP_PRODUCTS.stable, DESKTOP_PRODUCTS.beta] as const;-export function detectInstallMethods(home: string,argv1: string | undefined,runNpmLs: (args: string[]) => string | null = defaultNpmLs,exists: (path: string) => boolean = existsSync,- opts: { platform?: NodeJS.Platform; env?: NodeJS.ProcessEnv } = {},+ opts: { platform?: NodeJS.Platform; env?: NodeJS.ProcessEnv; execPath?: string } = {},): InstallMethod[] {const methods: InstallMethod[] = [];const platform = opts.platform ?? process.platform;const env = opts.env ?? process.env;+ const desktopProducts = desktopProductsVisibleTo(+ runningDesktopProduct(env, opts.execPath ?? process.execPath),+ ).map((name) => DESKTOP_PRODUCTS[name]);if (platform === 'darwin') {- for (const product of DESKTOP_PRODUCT_LIST) {+ for (const product of desktopProducts) {for (const applicationsDir of ['/Applications', join(home, 'Applications')]) {const app = join(applicationsDir, `${product.productName}.app`);if (exists(app)) {@@ -66,7 +68,7 @@ export function detectInstallMethods(} else if (platform === 'win32') {const localAppData = env.LOCALAPPDATA;if (localAppData) {- for (const product of DESKTOP_PRODUCT_LIST) {+ for (const product of desktopProducts) {for (const dirName of desktopWindowsInstallDirNames(product)) {const exe = join(localAppData,@@ -86,7 +88,7 @@ export function detectInstallMethods(}}} else if (platform === 'linux') {- for (const product of DESKTOP_PRODUCT_LIST) {+ for (const product of desktopProducts) {const installDir = `/opt/${product.productName}`;if (exists(join(installDir, product.linuxExecutableName))) {const { deb: debPackageName, rpm: rpmPackageName } = product.linuxPackageNames;@@ -275,6 +277,7 @@ export interface UninstallOptions {isTTY?: boolean;isStdinTTY?: boolean;argv1?: string;+ execPath?: string;confirmStream?: NodeJS.ReadableStream;deps?: UninstallDeps;}@@ -286,14 +289,18 @@ export interface UninstallResult {runFeedbackAfterReport?: () => Promise<void>;}-const URL_SCHEME_NOTE = dim(- 'The openknowledge:// URL scheme deregisters itself once the app is removed — no action needed.',-);+function urlSchemeNote(env: NodeJS.ProcessEnv, execPath: string): string {+ const { protocolScheme } = DESKTOP_PRODUCTS[runningDesktopProduct(env, execPath)];+ return dim(+ `The ${protocolScheme}:// URL scheme deregisters itself once the app is removed — no action needed.`,+ );+}export async function runUninstall(opts: UninstallOptions = {}): Promise<UninstallResult> {const home = opts.home ?? homedir();const platform = opts.platform ?? process.platform;const env = opts.env ?? process.env;+ const execPath = opts.execPath ?? process.execPath;const cwd = resolve(opts.cwd ?? process.cwd());const host = opts.host ?? 'github.com';const purgeContent = opts.purgeContent ?? false;@@ -337,7 +344,11 @@ export async function runUninstall(opts: UninstallOptions = {}): Promise<Uninsta);const binaryBlock = (): string =>formatInstallInstructions(- detectInstall(home, opts.argv1 ?? process.argv[1], undefined, undefined, { platform, env }),+ detectInstall(home, opts.argv1 ?? process.argv[1], undefined, undefined, {+ platform,+ env,+ execPath,+ }),platform,);@@ -411,7 +422,7 @@ export async function runUninstall(opts: UninstallOptions = {}): Promise<Uninsta: formatRemovalOutcome(outcome),];if (!opts.json) {- parts.push('', fallbackNote, URL_SCHEME_NOTE);+ parts.push('', fallbackNote, urlSchemeNote(env, execPath));if (outcome.failed.length === 0) {parts.push('', success("OpenKnowledge's files have been removed from this machine."));}diff --git a/packages/cli/src/utils/open-target.test.ts b/packages/cli/src/utils/open-target.test.tsindex de7c93f2d..96c242723 100644--- a/packages/cli/src/utils/open-target.test.ts+++ b/packages/cli/src/utils/open-target.test.ts@@ -44,6 +44,22 @@ describe('openTarget', () => {expect(capture.args).toEqual(['-a', desktopBundlePath, target]);});+ test('macOS hands a Beta deep link to the verified Beta bundle', async () => {+ const capture: SpawnCapture = {};+ const target = 'openknowledge-beta://open?file=%2FUsers%2Fme%2Fnotes%2Ftodo.md';+ const desktopBundlePath = '/Applications/OpenKnowledge Beta.app';++ const outcome = await openTarget(target, {+ platform: 'darwin',+ desktopBundlePath,+ spawn: makeSpawn(capture, { type: 'spawn' }),+ });++ expect(outcome).toEqual({ ok: true });+ expect(capture.command).toBe('/usr/bin/open');+ expect(capture.args).toEqual(['-a', desktopBundlePath, target]);+ });+test('macOS falls back to plain scheme resolution when no bundle path is given', async () => {const capture: SpawnCapture = {};const target = 'openknowledge://open?project=%2FUsers%2Fme%2Fnotes&doc=specs%2Flaunch';diff --git a/packages/cli/src/utils/open-target.ts b/packages/cli/src/utils/open-target.tsindex ced082d0d..2ce1ca820 100644--- a/packages/cli/src/utils/open-target.ts+++ b/packages/cli/src/utils/open-target.ts@@ -1,4 +1,5 @@import type { spawn as NativeSpawn } from 'node:child_process';+import { DESKTOP_PRODUCTS } from '@inkeep/open-knowledge-core';import {type SpawnDetachedScrubbedOutcome,spawnDetachedScrubbedAndWait,@@ -17,13 +18,19 @@ interface OpenInvocation {args: readonly string[];}+function isDesktopDeepLink(target: string): boolean {+ return Object.values(DESKTOP_PRODUCTS).some(({ protocolScheme }) =>+ target.startsWith(`${protocolScheme}://`),+ );+}+function resolveOpenInvocation(target: string,platform: NodeJS.Platform,desktopBundlePath?: string,): OpenInvocation {if (platform === 'darwin') {- if (desktopBundlePath && target.startsWith('openknowledge://')) {+ if (desktopBundlePath && isDesktopDeepLink(target)) {return { command: '/usr/bin/open', args: ['-a', desktopBundlePath, target] };}return { command: '/usr/bin/open', args: [target] };diff --git a/packages/core/src/bridge/compose.ts b/packages/core/src/bridge/compose.tsindex 2a597ec3d..f4cc8a286 100644--- a/packages/core/src/bridge/compose.ts+++ b/packages/core/src/bridge/compose.ts@@ -1,4 +1,3 @@-import { prependFrontmatter, stripFrontmatter } from '../extensions/frontmatter.ts';export type ComposeAdjustment = 'none' | 'body' | 'frontmatter' | 'unresolved';diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.tsindex 01ef76a9f..8fb428b90 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';import { carriedEdgeEmpties, type DocEdgeEmpties } from '../markdown/doc-edge-blank-runs.ts';diff --git a/packages/core/src/constants/product.test.ts b/packages/core/src/constants/product.test.tsindex 24e3d4660..e8f4302d5 100644--- a/packages/core/src/constants/product.test.ts+++ b/packages/core/src/constants/product.test.ts@@ -49,6 +49,17 @@ describe('resolveDesktopProductName', () => {expect(DESKTOP_PRODUCTS.stable.userHomeDirName).toBe('.ok');expect(DESKTOP_PRODUCTS.stable.keyringService).toBe('open-knowledge');});++ it('gives every channel its own deep-link scheme, keeping Stable on openknowledge', () => {+ expect(+ Object.fromEntries(+ Object.entries(DESKTOP_PRODUCTS).map(([name, p]) => [name, p.protocolScheme]),+ ),+ ).toEqual({+ stable: 'openknowledge',+ beta: 'openknowledge-beta',+ });+ });});describe('desktopChannelLabel', () => {diff --git a/packages/core/src/constants/product.ts b/packages/core/src/constants/product.tsindex 3b6a6b90f..3292d1f53 100644--- a/packages/core/src/constants/product.ts+++ b/packages/core/src/constants/product.ts@@ -4,6 +4,7 @@ export const DESKTOP_PRODUCTS = {productName: 'OpenKnowledge',packageName: '@inkeep/open-knowledge-desktop',linuxExecutableName: 'openknowledge',+ protocolScheme: 'openknowledge',linuxPackageNames: {deb: 'openknowledge',rpm: 'OpenKnowledge',@@ -20,6 +21,7 @@ export const DESKTOP_PRODUCTS = {productName: 'OpenKnowledge Beta',packageName: 'openknowledge-beta-desktop',linuxExecutableName: 'openknowledge-beta',+ protocolScheme: 'openknowledge-beta',linuxPackageNames: {deb: 'openknowledge-beta-desktop',rpm: 'openknowledge-beta-desktop',diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.tsindex fb0ba5a7c..fc267cbea 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/merged-walker.ts b/packages/core/src/markdown/merged-walker.tsindex fa3cfcd86..bfd7e3109 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/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/desktop/src/shared/desktop-variant.test.ts b/packages/desktop/src/shared/desktop-variant.test.tsindex a074f5aa8..c22a9513e 100644--- a/packages/desktop/src/shared/desktop-variant.test.ts+++ b/packages/desktop/src/shared/desktop-variant.test.ts@@ -1,3 +1,4 @@+import { DESKTOP_PRODUCTS } from '@inkeep/open-knowledge-core';import { describe, expect, test } from 'vitest';import {DESKTOP_VARIANTS,@@ -34,6 +35,12 @@ describe('desktop variant identities', () => {expect(new Set(identities.flatMap((identity) => identity.cliCommandNames)).size).toBe(4);});+ test('takes each product deep-link scheme from the shared desktop product', () => {+ expect(DESKTOP_VARIANTS.stable.protocolScheme).toBe(DESKTOP_PRODUCTS.stable.protocolScheme);+ expect(DESKTOP_VARIANTS.beta.protocolScheme).toBe(DESKTOP_PRODUCTS.beta.protocolScheme);+ expect(DESKTOP_VARIANTS.beta.protocolScheme).toBe('openknowledge-beta');+ });+test('keeps legacy Beta on the original identity and manifest contract', () => {expect(DESKTOP_VARIANTS['legacy-beta']).toEqual({...DESKTOP_VARIANTS.stable,diff --git a/packages/desktop/src/shared/desktop-variant.ts b/packages/desktop/src/shared/desktop-variant.tsindex 0b7fb1b9e..7405a7552 100644--- a/packages/desktop/src/shared/desktop-variant.ts+++ b/packages/desktop/src/shared/desktop-variant.ts@@ -32,7 +32,7 @@ const DESKTOP_PRODUCT_VARIANTS = {productName: DESKTOP_PRODUCTS.stable.productName,artifactName: 'OpenKnowledge',packageName: DESKTOP_PRODUCTS.stable.packageName,- protocolScheme: 'openknowledge',+ protocolScheme: DESKTOP_PRODUCTS.stable.protocolScheme,updateChannel: 'latest',feedChannel: 'latest',instanceLabel: null,@@ -49,7 +49,7 @@ const DESKTOP_PRODUCT_VARIANTS = {productName: DESKTOP_PRODUCTS.beta.productName,artifactName: 'OpenKnowledge-Beta',packageName: DESKTOP_PRODUCTS.beta.packageName,- protocolScheme: 'openknowledge-beta',+ protocolScheme: DESKTOP_PRODUCTS.beta.protocolScheme,updateChannel: 'beta',feedChannel: 'beta-product',instanceLabel: 'Beta',