Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Restore legacy Beta update compatibility (#4947)

Andrew Mikofalvy78e4a84b4271
diff --git a/.changeset/desktop-packaging-pnpm.md b/.changeset/desktop-packaging-pnpm.md
new file mode 100644
index 000000000..13d406b49
--- /dev/null
+++ b/.changeset/desktop-packaging-pnpm.md
@@ -0,0 +1,5 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+Restore desktop release packaging and in-place updates for existing Beta installations, preserving their settings and app identity. The separately installed Beta app uses its own update feed; Stable updates remain unchanged.
diff --git a/.github/scripts/desktop-release-compatibility.test.mjs b/.github/scripts/desktop-release-compatibility.test.mjs
new file mode 100644
index 000000000..d07bf7fd2
--- /dev/null
+++ b/.github/scripts/desktop-release-compatibility.test.mjs
@@ -0,0 +1,101 @@
+import { spawnSync } from 'node:child_process';
+import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { describe, expect, test, vi } from 'vitest';
+import { parse } from 'yaml';
+import { smokeHistoricalUpgrade } from './smoke-historical-upgrade.mjs';
+
+const workflow = parse(
+ readFileSync(new URL('../workflows/desktop-release.yml', import.meta.url), 'utf8'),
+);
+const inventoryStep = workflow.jobs['publish-assets'].steps.find(
+ (step) => step.name === 'Define the expected asset inventory',
+);
+
+function inventory(channel, required) {
+ const dir = mkdtempSync(join(tmpdir(), 'ok-release-inventory-'));
+ try {
+ const envFile = join(dir, 'env');
+ const result = spawnSync('bash', ['-c', inventoryStep.run], {
+ cwd: dir,
+ env: {
+ ...process.env,
+ GITHUB_ENV: envFile,
+ CHANNEL: channel,
+ REQUIRED: required,
+ ARTIFACT_NAME: channel === 'beta' ? 'OpenKnowledge-Beta' : 'OpenKnowledge',
+ VERSION: channel === 'beta' ? '0.78.0-beta.6' : '0.78.0',
+ },
+ encoding: 'utf8',
+ });
+ expect(result.status, result.stderr).toBe(0);
+ const contents = readFileSync(envFile, 'utf8');
+ return {
+ required: contents
+ .split('EXPECTED_ASSETS<<OK_INVENTORY_EOF\n')[1]
+ .split('\nOK_INVENTORY_EOF')[0]
+ .split('\n'),
+ allowed: contents
+ .split('ALLOWED_ASSETS<<OK_ALLOWED_EOF\n')[1]
+ .split('\nOK_ALLOWED_EOF')[0]
+ .split('\n'),
+ };
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
+}
+
+describe('legacy desktop release compatibility', () => {
+ test('the historical upgrade gate refuses a developer machine', async () => {
+ vi.stubEnv('GITHUB_ACTIONS', undefined);
+ try {
+ await expect(smokeHistoricalUpgrade([])).rejects.toThrow('isolated GitHub macOS runner');
+ } finally {
+ vi.unstubAllEnvs();
+ }
+ });
+
+ test('requires both complete Beta product families before publishing', () => {
+ const { required, allowed } = inventory('beta', 'mac,windows,linux');
+ expect(required).toEqual(allowed);
+ expect(required).toHaveLength(28);
+ expect(new Set(required).size).toBe(28);
+ for (const prefix of ['beta', 'beta-product']) {
+ for (const suffix of ['.yml', '-mac.yml', '-linux.yml', '-linux-arm64.yml']) {
+ expect(required).toContain(`${prefix}${suffix}`);
+ }
+ }
+ for (const product of ['OpenKnowledge', 'OpenKnowledge-Beta']) {
+ expect(required).toContain(`${product}-0.78.0-beta.6-arm64-mac.zip`);
+ expect(required).toContain(`${product}-Setup-x64.exe`);
+ expect(required).toContain(`${product}-arm64.deb`);
+ }
+ });
+
+ test('does not change Stable asset names or manifests', () => {
+ const { required } = inventory('latest', 'mac,windows,linux');
+ expect(required).toHaveLength(14);
+ expect(required).toContain('latest-mac.yml');
+ expect(required).toContain('OpenKnowledge-0.78.0-arm64-mac.zip');
+ expect(required.some((name) => name.includes('Beta') || name.includes('beta'))).toBe(false);
+ });
+
+ test('a platform override cannot drop legacy macOS compatibility', () => {
+ const { required, allowed } = inventory('beta', 'mac');
+ expect(required).toHaveLength(10);
+ expect(required).toContain('beta-mac.yml');
+ expect(required).toContain('beta-product-mac.yml');
+ expect(allowed).toHaveLength(28);
+ });
+
+ test('all platform matrices build legacy and separate Beta, but only one Stable', () => {
+ const matrices = ['build-macos', 'build-windows', 'build-linux'].map(
+ (name) => workflow.jobs[name].strategy.matrix,
+ );
+ expect(new Set(matrices.map((matrix) => matrix.variant)).size).toBe(1);
+ expect(matrices[0].variant).toContain('["legacy-beta","beta"]');
+ expect(matrices[0].variant).toContain('["stable"]');
+ expect(matrices[2].runner).toEqual(['ubuntu-latest', 'ubuntu-24.04-arm']);
+ });
+});
diff --git a/.github/scripts/release-cascade-shape.test.mjs b/.github/scripts/release-cascade-shape.test.mjs
index 0b61cd5b7..3eed73854 100644
--- a/.github/scripts/release-cascade-shape.test.mjs
+++ b/.github/scripts/release-cascade-shape.test.mjs
@@ -885,7 +885,7 @@ describe('public desktop product variants stay independently buildable', () => {
expect(desktopRelease).toContain(pair[1]);
}
expect(desktopRelease).toContain('ARTIFACT_NAME: ${{ needs.prepare.outputs.artifact_name }}');
- expect(desktopRelease).toContain('${ARTIFACT_NAME}-${VERSION}-arm64-mac.zip');
+ expect(desktopRelease).toContain('${artifact}-${VERSION}-arm64-mac.zip');
});
test('signed Beta builds require their own provisioning profile', () => {
diff --git a/.github/scripts/smoke-historical-upgrade.mjs b/.github/scripts/smoke-historical-upgrade.mjs
new file mode 100644
index 000000000..512f9bb90
--- /dev/null
+++ b/.github/scripts/smoke-historical-upgrade.mjs
@@ -0,0 +1,145 @@
+import assert from 'node:assert/strict';
+import { execFileSync } from 'node:child_process';
+import { createReadStream, existsSync, readFileSync, statSync, writeFileSync } from 'node:fs';
+import { createServer } from 'node:http';
+import { createRequire } from 'node:module';
+import { homedir } from 'node:os';
+import { basename, join, resolve } from 'node:path';
+import { pathToFileURL } from 'node:url';
+import { withMountedDmg } from './dmg-mount.mjs';
+
+export async function smokeHistoricalUpgrade(argv = process.argv.slice(2)) {
+ // biome-ignore lint/suspicious/noUndeclaredEnvVars: Invoked directly by GitHub Actions, outside Turbo.
+ if (process.platform !== 'darwin' || process.env.GITHUB_ACTIONS !== 'true') {
+ throw new Error('Historical upgrade verification requires an isolated GitHub macOS runner.');
+ }
+
+ const desktopRoot = resolve('packages/desktop');
+ const require_ = createRequire(join(desktopRoot, 'package.json'));
+ const { _electron, expect } = require_('@playwright/test');
+ const { parse } = require_('yaml');
+ const [oldDmg, channel] = argv;
+ assert.ok(oldDmg && ['latest', 'beta'].includes(channel));
+ const outputDir = join(desktopRoot, 'dist-desktop');
+ const manifestName = `${channel}-mac.yml`;
+ const manifest = parse(readFileSync(join(outputDir, manifestName), 'utf8'));
+ const userData = join(homedir(), 'Library/Application Support/OpenKnowledge');
+ assert.equal(existsSync(userData), false, 'The upgrade test must not touch existing app state.');
+ const statePath = join(userData, 'state.json');
+ const state = () => JSON.parse(readFileSync(statePath, 'utf8'));
+ let available = false;
+ let manifestRequests = 0;
+ const server = createServer((request, response) => {
+ const filename = decodeURIComponent(new URL(request.url, 'http://localhost').pathname.slice(1));
+ if (filename === manifestName) manifestRequests++;
+ if (!available) {
+ response.writeHead(503).end();
+ return;
+ }
+ if (basename(filename) !== filename || !existsSync(join(outputDir, filename))) {
+ response.writeHead(404).end();
+ return;
+ }
+ const file = join(outputDir, filename);
+ response.writeHead(200, { 'content-length': statSync(file).size });
+ createReadStream(file).pipe(response);
+ });
+ await new Promise((done) => server.listen(0, '127.0.0.1', done));
+ const feedUrl = `http://127.0.0.1:${server.address().port}`;
+ let application;
+
+ try {
+ await withMountedDmg(oldDmg, async (appPath) => {
+ const executablePath = join(appPath, 'Contents/MacOS/OpenKnowledge');
+ const launch = async () => {
+ application = await _electron.launch({
+ executablePath,
+ env: { ...process.env, OK_UPDATER_FEED_URL: feedUrl },
+ timeout: 90_000,
+ });
+ const page = await application.firstWindow();
+ await page.waitForFunction(() => Boolean(window.okDesktop?.update?.checkNow));
+ return page;
+ };
+ const firstPage = await launch();
+ const fromVersion = await application.evaluate(({ app }) => app.getVersion());
+ assert.notEqual(fromVersion, manifest.version);
+ await firstPage.evaluate(() => window.okDesktop.update.checkNow());
+ await expect.poll(() => manifestRequests, { timeout: 60_000 }).toBeGreaterThan(0);
+ await application.close();
+ application = undefined;
+ writeFileSync(statePath, JSON.stringify({ ...state(), lastUsedProjectParent: appPath }));
+
+ available = true;
+ const page = await launch();
+ await page.evaluate(() => window.okDesktop.update.checkNow());
+ await expect
+ .poll(() => state().versionPendingInstall, { timeout: 240_000 })
+ .toBe(manifest.version);
+ const closed = application.waitForEvent('close', { timeout: 90_000 });
+ await page.evaluate(() => {
+ void window.okDesktop.update.relaunchNow();
+ });
+ await closed;
+ application = undefined;
+ await expect
+ .poll(
+ () => {
+ return execFileSync(
+ '/usr/libexec/PlistBuddy',
+ ['-c', 'Print :CFBundleShortVersionString', join(appPath, 'Contents/Info.plist')],
+ { encoding: 'utf8' },
+ ).trim();
+ },
+ { timeout: 120_000 },
+ )
+ .toBe(manifest.version);
+ await expect.poll(() => state().lastSeenVersion, { timeout: 90_000 }).toBe(manifest.version);
+ assert.equal(
+ state().lastUsedProjectParent,
+ appPath,
+ 'An upgrade must preserve existing app settings.',
+ );
+ execFileSync('codesign', ['--verify', '--deep', '--strict', appPath], { stdio: 'inherit' });
+ execFileSync('/usr/bin/osascript', ['-e', `tell application "${appPath}" to quit`], {
+ timeout: 30_000,
+ });
+ await expect
+ .poll(
+ () =>
+ execFileSync('/bin/ps', ['-axo', 'command'], { encoding: 'utf8' })
+ .split('\n')
+ .some((line) => line.startsWith(executablePath)),
+ { timeout: 30_000 },
+ )
+ .toBe(false);
+
+ const upgraded = await launch();
+ assert.equal(await application.evaluate(({ app }) => app.getVersion()), manifest.version);
+ const before = manifestRequests;
+ await upgraded.evaluate(() => window.okDesktop.update.checkNow());
+ await expect.poll(() => manifestRequests, { timeout: 60_000 }).toBeGreaterThan(before);
+ await expect.poll(() => state().versionPendingInstall, { timeout: 30_000 }).toBeNull();
+ await application.close();
+ application = undefined;
+ console.log(
+ JSON.stringify({
+ fromVersion,
+ toVersion: manifest.version,
+ channel,
+ offlineRetry: 'passed',
+ install: 'passed',
+ settings: 'preserved',
+ nextCheck: 'passed',
+ }),
+ );
+ });
+ } finally {
+ if (application) await application.close();
+ await new Promise((done) => server.close(done));
+ }
+}
+
+if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
+ await smokeHistoricalUpgrade();
+}
diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.yml
index 52449f551..5c08011e6 100644
--- a/.github/workflows/desktop-release.yml
+++ b/.github/workflows/desktop-release.yml
@@ -500,6 +500,12 @@ jobs:
# runtime to every cut. It re-runs the cheap channel detection itself; the
# two copies of that step live in one file and must stay in lockstep.
build-macos:
+ strategy:
+ fail-fast: false
+ matrix:
+ variant: ${{ fromJSON(contains(github.event.client_payload.release_tag || inputs.release_tag, '-beta.') && '["legacy-beta","beta"]' || '["stable"]') }}
+ env:
+ OK_DESKTOP_VARIANT: ${{ matrix.variant }}
# macos-26 = Apple Silicon (Tahoe) with Xcode 26.x preinstalled. Apple
# Silicon is required for the Universal DMG lipo merge (arm64 + x64 →
# universal) per parent SPEC D29. Xcode 26+ is required because
@@ -549,7 +555,10 @@ jobs:
echo "variant=beta"
echo "version=$VERSION"
} >> "$GITHUB_OUTPUT"
- echo "OK_DESKTOP_VARIANT=beta" >> "$GITHUB_ENV"
+ if [[ "$OK_DESKTOP_VARIANT" == "beta" ]]; then
+ echo "channel=beta-product" >> "$GITHUB_OUTPUT"
+ fi
+ echo "variant=$OK_DESKTOP_VARIANT" >> "$GITHUB_OUTPUT"
elif [[ "$VERSION" == *-* ]]; then
echo "::error::Unsupported prerelease ID in tag $RELEASE_TAG — this public publisher accepts only -beta.N (prepare's twin step carries the full diagnostics)."
exit 1
@@ -559,7 +568,6 @@ jobs:
echo "variant=stable"
echo "version=$VERSION"
} >> "$GITHUB_OUTPUT"
- echo "OK_DESKTOP_VARIANT=stable" >> "$GITHUB_ENV"
fi
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
@@ -810,7 +818,7 @@ jobs:
run: pnpm run build:desktop
- name: Validate variant provisioning profile
- if: steps.channel.outputs.variant != 'stable'
+ if: steps.channel.outputs.variant == 'beta'
working-directory: packages/desktop
run: |
set -euo pipefail
@@ -945,6 +953,18 @@ jobs:
fi
echo "Attested $FOUND signed, notarized, stapled app bundle(s)."
+ - name: Verify a historical app can update in place
+ if: matrix.variant != 'beta'
+ env:
+ GH_TOKEN: ${{ github.token }}
+ SOURCE_TAG: ${{ matrix.variant == 'legacy-beta' && 'v0.77.9-beta.0' || 'v0.77.8' }}
+ UPDATER_CHANNEL: ${{ matrix.variant == 'legacy-beta' && 'beta' || 'latest' }}
+ run: |
+ set -euo pipefail
+ mkdir -p "$RUNNER_TEMP/historical-upgrade"
+ gh release download "$SOURCE_TAG" --pattern 'OpenKnowledge-arm64.dmg' --dir "$RUNNER_TEMP/historical-upgrade"
+ node .github/scripts/smoke-historical-upgrade.mjs "$RUNNER_TEMP/historical-upgrade/OpenKnowledge-arm64.dmg" "$UPDATER_CHANNEL"
+
# FR5b — smoke the signed DMG before anything about this release becomes
# visible or installable. Under the fan-in topology this job failing on
# a smoke verdict means publish-assets never runs: no asset reaches the
@@ -1023,7 +1043,7 @@ jobs:
- name: Upload macOS release assets for the fan-in publisher
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
- name: macos-release-assets
+ name: macos-${{ matrix.variant }}-release-assets
path: |
packages/desktop/dist-desktop/*.dmg
packages/desktop/dist-desktop/*.dmg.blockmap
@@ -1035,11 +1055,16 @@ jobs:
build-windows:
needs: prepare
+ strategy:
+ fail-fast: false
+ matrix:
+ variant: ${{ fromJSON(contains(github.event.client_payload.release_tag || inputs.release_tag, '-beta.') && '["legacy-beta","beta"]' || '["stable"]') }}
runs-on: windows-latest
timeout-minutes: 45
env:
- OK_DESKTOP_VARIANT: ${{ needs.prepare.outputs.variant }}
- OK_DESKTOP_PRODUCT_NAME: ${{ needs.prepare.outputs.product_name }}
+ OK_DESKTOP_VARIANT: ${{ matrix.variant }}
+ OK_DESKTOP_PRODUCT_NAME: ${{ matrix.variant == 'beta' && 'OpenKnowledge Beta' || 'OpenKnowledge' }}
+ UPDATER_CHANNEL: ${{ matrix.variant == 'beta' && 'beta-product' || needs.prepare.outputs.channel }}
permissions:
# See build-macos — packaging jobs are read-only by design.
contents: read
@@ -1155,7 +1180,7 @@ jobs:
AZURE_SIGNING_PROFILE: ${{ vars.AZURE_SIGNING_PROFILE }}
AZURE_SIGNING_PUBLISHER: ${{ vars.AZURE_SIGNING_PUBLISHER }}
BUILD_VERSION: ${{ needs.prepare.outputs.version }}
- BUILD_CHANNEL: ${{ needs.prepare.outputs.channel }}
+ BUILD_CHANNEL: ${{ env.UPDATER_CHANNEL }}
GITHUB_WORKFLOW_SHA: ${{ github.workflow_sha }}
PKG_CMD: 'rm -rf dist-desktop && node scripts/run-electron-builder.mjs --win --publish never --config.extraMetadata.version="${BUILD_VERSION}" --config.win.azureSignOptions.endpoint="${AZURE_SIGNING_ENDPOINT}" --config.win.azureSignOptions.codeSigningAccountName="${AZURE_SIGNING_ACCOUNT}" --config.win.azureSignOptions.certificateProfileName="${AZURE_SIGNING_PROFILE}" --config.win.azureSignOptions.publisherName="${AZURE_SIGNING_PUBLISHER}"'
run: |
@@ -1314,7 +1339,7 @@ jobs:
- name: Assert app-update.yml is present and channel-correct
working-directory: packages/desktop
env:
- CHANNEL: ${{ needs.prepare.outputs.channel }}
+ CHANNEL: ${{ env.UPDATER_CHANNEL }}
run: |
set -euo pipefail
for dir in dist-desktop/win-unpacked dist-desktop/win-arm64-unpacked; do
@@ -1338,11 +1363,11 @@ jobs:
- name: Upload Windows release assets for the fan-in publisher
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
- name: windows-release-assets
+ name: windows-${{ matrix.variant }}-release-assets
path: |
packages/desktop/dist-desktop/*Setup-x64.exe
packages/desktop/dist-desktop/*Setup-arm64.exe
- packages/desktop/dist-desktop/${{ needs.prepare.outputs.channel }}.yml
+ packages/desktop/dist-desktop/${{ env.UPDATER_CHANNEL }}.yml
retention-days: 14
if-no-files-found: error
@@ -1357,7 +1382,8 @@ jobs:
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
env:
- OK_DESKTOP_VARIANT: ${{ needs.prepare.outputs.variant }}
+ OK_DESKTOP_VARIANT: ${{ matrix.variant }}
+ UPDATER_CHANNEL: ${{ matrix.variant == 'beta' && 'beta-product' || needs.prepare.outputs.channel }}
permissions:
# See build-macos — packaging jobs are read-only by design.
contents: read
@@ -1370,6 +1396,8 @@ jobs:
# to repeat the arch that failed. publish-assets still requires BOTH.
fail-fast: false
matrix:
+ variant: ${{ fromJSON(contains(github.event.client_payload.release_tag || inputs.release_tag, '-beta.') && '["legacy-beta","beta"]' || '["stable"]') }}
+ runner: [ubuntu-latest, ubuntu-24.04-arm]
include:
- runner: ubuntu-latest
arch: x64
@@ -1523,7 +1551,7 @@ jobs:
- name: Assert app-update.yml + package-type are present and channel-correct
working-directory: packages/desktop
env:
- CHANNEL: ${{ needs.prepare.outputs.channel }}
+ CHANNEL: ${{ env.UPDATER_CHANNEL }}
UNPACKED_DIR: ${{ matrix.unpacked_dir }}
run: |
set -euo pipefail
@@ -1554,11 +1582,11 @@ jobs:
- name: Upload Linux ${{ matrix.arch }} release assets for the fan-in publisher
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
- name: linux-${{ matrix.arch }}-release-assets
+ name: linux-${{ matrix.arch }}-${{ matrix.variant }}-release-assets
path: |
packages/desktop/dist-desktop/*.deb
packages/desktop/dist-desktop/*.rpm
- packages/desktop/dist-desktop/${{ needs.prepare.outputs.channel }}-linux*.yml
+ packages/desktop/dist-desktop/${{ env.UPDATER_CHANNEL }}-linux*.yml
retention-days: 14
if-no-files-found: error
@@ -1627,55 +1655,42 @@ jobs:
- name: Define the expected asset inventory
run: |
set -euo pipefail
- # Two lists with different jobs:
- # EXPECTED_ASSETS — the MUST-HAVE set: the full group for every
- # REQUIRED platform. Missing any of these blocks publication.
- # ALLOWED_ASSETS — the full known-name universe across ALL
- # platforms. The no-extras check validates present files against
- # THIS list, so a healthy non-required platform's assets (even a
- # partial set from one surviving matrix cell — each Linux arch
- # uploads independently under fail-fast: false) still ship,
- # while a stray builder-debug.yml still fails. Anything a
- # non-required job uploaded already passed that job's own
- # app-update/package-type asserts.
+ inventory() {
+ local platforms="$1"
+ local family
+ local families=("${ARTIFACT_NAME}:${CHANNEL}")
+ if [[ "$CHANNEL" == "beta" ]]; then
+ families=("OpenKnowledge:beta" "OpenKnowledge-Beta:beta-product")
+ fi
+ for family in "${families[@]}"; do
+ local artifact="${family%:*}"
+ local manifest="${family#*:}"
+ echo "${artifact}-arm64.dmg"
+ echo "${artifact}-arm64.dmg.blockmap"
+ echo "${artifact}-${VERSION}-arm64-mac.zip"
+ echo "${artifact}-${VERSION}-arm64-mac.zip.blockmap"
+ echo "${manifest}-mac.yml"
+ if [[ "$platforms" == *windows* ]]; then
+ echo "${artifact}-Setup-x64.exe"
+ echo "${artifact}-Setup-arm64.exe"
+ echo "${manifest}.yml"
+ fi
+ if [[ "$platforms" == *linux* ]]; then
+ echo "${artifact}-amd64.deb"
+ echo "${artifact}-arm64.deb"
+ echo "${artifact}-x86_64.rpm"
+ echo "${artifact}-aarch64.rpm"
+ echo "${manifest}-linux.yml"
+ echo "${manifest}-linux-arm64.yml"
+ fi
+ done
+ }
{
echo "EXPECTED_ASSETS<<OK_INVENTORY_EOF"
- echo "${ARTIFACT_NAME}-arm64.dmg"
- echo "${ARTIFACT_NAME}-arm64.dmg.blockmap"
- echo "${ARTIFACT_NAME}-${VERSION}-arm64-mac.zip"
- echo "${ARTIFACT_NAME}-${VERSION}-arm64-mac.zip.blockmap"
- echo "${CHANNEL}-mac.yml"
- if [[ "$REQUIRED" == *windows* ]]; then
- echo "${ARTIFACT_NAME}-Setup-x64.exe"
- echo "${ARTIFACT_NAME}-Setup-arm64.exe"
- echo "${CHANNEL}.yml"
- fi
- if [[ "$REQUIRED" == *linux* ]]; then
- echo "${ARTIFACT_NAME}-amd64.deb"
- echo "${ARTIFACT_NAME}-arm64.deb"
- echo "${ARTIFACT_NAME}-x86_64.rpm"
- echo "${ARTIFACT_NAME}-aarch64.rpm"
- echo "${CHANNEL}-linux.yml"
- echo "${CHANNEL}-linux-arm64.yml"
- fi
- # GITHUB_ENV's multiline syntax REQUIRES the closing delimiter
- # line — without it the runner rejects the whole env file.
+ inventory "$REQUIRED"
echo "OK_INVENTORY_EOF"
echo "ALLOWED_ASSETS<<OK_ALLOWED_EOF"
- echo "${ARTIFACT_NAME}-arm64.dmg"
- echo "${ARTIFACT_NAME}-arm64.dmg.blockmap"
- echo "${ARTIFACT_NAME}-${VERSION}-arm64-mac.zip"
- echo "${ARTIFACT_NAME}-${VERSION}-arm64-mac.zip.blockmap"
- echo "${CHANNEL}-mac.yml"
- echo "${ARTIFACT_NAME}-Setup-x64.exe"
- echo "${ARTIFACT_NAME}-Setup-arm64.exe"
- echo "${CHANNEL}.yml"
- echo "${ARTIFACT_NAME}-amd64.deb"
- echo "${ARTIFACT_NAME}-arm64.deb"
- echo "${ARTIFACT_NAME}-x86_64.rpm"
- echo "${ARTIFACT_NAME}-aarch64.rpm"
- echo "${CHANNEL}-linux.yml"
- echo "${CHANNEL}-linux-arm64.yml"
+ inventory "mac,windows,linux"
echo "OK_ALLOWED_EOF"
} >> "$GITHUB_ENV"
diff --git a/docs/content/reference/what-open-knowledge-writes.mdx b/docs/content/reference/what-open-knowledge-writes.mdx
index b599a03bc..cb7905067 100644
--- a/docs/content/reference/what-open-knowledge-writes.mdx
+++ b/docs/content/reference/what-open-knowledge-writes.mdx
@@ -52,7 +52,7 @@ On every platform the app writes app-level state and logs on launch. The table b
| `~/Library/Application Support/OpenKnowledge/bug-report-crash-acks.json` | Records which crash-report invitations you already answered or dismissed, so the same crash never re-prompts. Answering is what retires a crash: an invitation you simply never saw — because it went unanswered for a day, or the window it was waiting on never appeared — is dropped rather than answered, so that crash can be offered again the next time you open the app | Outside-project (home dir) |
| `~/Library/Application Support/OpenKnowledge/bug-report-main-thread-liveness.json` | Main-thread liveness witness. A background worker rewrites it every five seconds while the app runs. The next launch can identify a main-thread block that had lasted at least 15 seconds at the last successful sample. A sample below that threshold does not rule out a shorter or recovered block, or a block after the worker stopped writing. Read only at the next launch; left in place on a clean quit and overwritten on the next run, through a `.tmp-` sibling during each write. The verdict lands in the desktop log a bug report carries; it does not change whether the app prompts you | Outside-project (home dir) |
-Stable registers `openknowledge://`; Beta registers `openknowledge-beta://`. Both check for updates — on launch and periodically while running — against separate Stable/Beta paths on the OpenKnowledge update service at `openknowledge.ai/updates`, which redirects to the matching GitHub release asset and counts the update per version and channel (Stable alone can fall back to GitHub directly if the proxy is unreachable). On macOS and Windows an update on your channel downloads in the background and installs on the next quit; on Linux — where there is no apt/rpm repository — the app downloads the new deb/rpm from the release feed and asks you to authorize the install (a `pkexec` password prompt) each time. You can also check on demand from **Check for updates…** in the app and Help menus. The channel is fixed by the product you installed. Reinstall Stable from `openknowledge.ai/download` or Beta from `openknowledge.ai/download/beta`; Windows and Linux installers are available from [GitHub Releases](https://github.com/inkeep/open-knowledge/releases). Override the feed with `OK_UPDATER_FEED_URL`.
+Stable registers `openknowledge://`; Beta registers `openknowledge-beta://`. Both check for updates — on launch and periodically while running — against separate Stable/Beta paths on the OpenKnowledge update service at `openknowledge.ai/updates`, which redirects to the matching GitHub release asset and counts the update per version and channel (Stable alone can fall back to GitHub directly if the proxy is unreachable). On macOS and Windows an update on your channel downloads in the background and installs on the next quit; on Linux — where there is no apt/rpm repository — the app downloads the new deb/rpm from the release feed and asks you to authorize the install (a `pkexec` password prompt) each time. You can also check on demand from **Check for updates…** in the app and Help menus. The channel is fixed by the product you installed. Older Beta installations named `OpenKnowledge` continue receiving Beta updates in place, preserving their existing settings and CLI commands; they do not silently become the separately installed `OpenKnowledge Beta` app. Reinstall Stable from `openknowledge.ai/download` or Beta from `openknowledge.ai/download/beta`; Windows and Linux installers are available from [GitHub Releases](https://github.com/inkeep/open-knowledge/releases). Override the feed with `OK_UPDATER_FEED_URL`.
On its first launch the app also opens your default browser once to `openknowledge.ai/continue`, to check whether you installed from a share link and redeem it if so; the exchange completes over a short-lived local loopback listener.
diff --git a/docs/src/app/updates/[channel]/[...path]/route.test.ts b/docs/src/app/updates/[channel]/[...path]/route.test.ts
index 3188a56b4..d8d216457 100644
--- a/docs/src/app/updates/[channel]/[...path]/route.test.ts
+++ b/docs/src/app/updates/[channel]/[...path]/route.test.ts
@@ -19,8 +19,14 @@ const BETA_DMG_URL =
'https://github.com/inkeep/open-knowledge/releases/download/v0.20.0-beta.4/OpenKnowledge-Beta-arm64.dmg';
type BetaRedirect = { kind: string; url: string; cause?: string; refreshError?: string };
let _betaRedirect: BetaRedirect = { kind: 'fresh', url: BETA_DMG_URL };
+let _selectedAsset: string | undefined;
vi.doMock('../../../../lib/download-links.ts', () => ({
- createBetaResolver: () => () => Promise.resolve(_betaRedirect),
+ createBetaResolver:
+ ({ assetName }: { assetName: string }) =>
+ () => {
+ _selectedAsset = assetName;
+ return Promise.resolve(_betaRedirect);
+ },
}));
const { GET } = await import('./route.ts');
@@ -40,6 +46,21 @@ function call(
}
describe('GET /updates/[channel]/[...path]', () => {
+ test.each([
+ ['beta', 'beta-mac.yml', 'beta-mac.yml'],
+ ['beta', 'OpenKnowledge-Setup-x64.exe', 'beta.yml'],
+ ['beta', 'OpenKnowledge-arm64.deb', 'beta-linux-arm64.yml'],
+ ['beta', 'OpenKnowledge-x86_64.rpm', 'beta-linux.yml'],
+ ['beta-product', 'OpenKnowledge-Beta-aarch64.rpm', 'beta-product-linux-arm64.yml'],
+ ])(
+ '%s/%s resolves a release carrying %s, not another platform',
+ async (channel, filename, manifest) => {
+ _betaRedirect = { kind: 'fresh', url: BETA_DMG_URL };
+ expect((await call(channel, [filename])).status).toBe(302);
+ expect(_selectedAsset).toBe(manifest);
+ },
+ );
+
test('stable manifest 302s to the latest alias and is NOT counted', async () => {
_lastCapture = null;
const res = await call('stable', ['latest-mac.yml']);
@@ -76,7 +97,7 @@ describe('GET /updates/[channel]/[...path]', () => {
test('beta zip parses the prerelease version and counts (no from_version header)', async () => {
_lastCapture = null;
- const file = 'OpenKnowledge-Beta-0.20.0-beta.4-arm64-mac.zip';
+ const file = 'OpenKnowledge-0.20.0-beta.4-arm64-mac.zip';
const res = await call('beta', [file]);
expect(res.status).toBe(302);
expect(res.headers.get('location')).toBe(`${REL}/download/v0.20.0-beta.4/${file}`);
@@ -130,6 +151,26 @@ describe('GET /updates/[channel]/[...path]', () => {
404,
);
expect((await call('beta', ['OpenKnowledge-0.21.0-arm64-mac.zip'])).status).toBe(404);
+ expect((await call('beta', ['OpenKnowledge-Beta-0.21.0-beta.4-arm64-mac.zip'])).status).toBe(
+ 404,
+ );
+ expect((await call('beta', ['beta-product-mac.yml'])).status).toBe(404);
+ expect((await call('beta-product', ['beta-mac.yml'])).status).toBe(404);
+ expect((await call('beta-product', ['OpenKnowledge-0.21.0-beta.4-arm64-mac.zip'])).status).toBe(
+ 404,
+ );
+ });
+
+ test('separate Beta uses its own manifest and artifact names', async () => {
+ _betaRedirect = { kind: 'fresh', url: BETA_DMG_URL };
+ const manifest = await call('beta-product', ['beta-product-mac.yml']);
+ expect(manifest.headers.get('location')).toBe(
+ `${REL}/download/v0.20.0-beta.4/beta-product-mac.yml`,
+ );
+ const file = 'OpenKnowledge-Beta-0.20.0-beta.4-arm64-mac.zip';
+ expect((await call('beta-product', [file])).headers.get('location')).toBe(
+ `${REL}/download/v0.20.0-beta.4/${file}`,
+ );
});
test('path traversal / multi-segment → 404', async () => {
@@ -238,13 +279,13 @@ describe('GET /updates/[channel]/[...path]', () => {
expect(_lastCapture?.properties?.to_version).toBe('0.20.0');
_lastCapture = null;
- await call('beta', ['OpenKnowledge-Beta-arm64.deb'], { 'x-ok-to-version': '9.9.9' });
+ await call('beta', ['OpenKnowledge-arm64.deb'], { 'x-ok-to-version': '9.9.9' });
expect(_lastCapture?.properties?.to_version).toBe('0.20.0-beta.4');
});
test('Linux beta deb counts with to_version derived from the resolved beta tag', async () => {
_lastCapture = null;
- const file = 'OpenKnowledge-Beta-arm64.deb';
+ const file = 'OpenKnowledge-arm64.deb';
const res = await call('beta', [file]);
expect(res.status).toBe(302);
expect(res.headers.get('location')).toBe(`${REL}/download/v0.20.0-beta.4/${file}`);
diff --git a/docs/src/app/updates/[channel]/[...path]/route.ts b/docs/src/app/updates/[channel]/[...path]/route.ts
index 2d6ff5164..ea910a71b 100644
--- a/docs/src/app/updates/[channel]/[...path]/route.ts
+++ b/docs/src/app/updates/[channel]/[...path]/route.ts
@@ -6,13 +6,14 @@ export const dynamic = 'force-dynamic';
const RELEASES_BASE = 'https://github.com/inkeep/open-knowledge/releases';
const CHANNELS = {
stable: { manifestPrefix: 'latest', productPrefix: 'OpenKnowledge-' },
- beta: { manifestPrefix: 'beta', productPrefix: 'OpenKnowledge-Beta-' },
+ beta: { manifestPrefix: 'beta', productPrefix: 'OpenKnowledge-' },
+ 'beta-product': { manifestPrefix: 'beta-product', productPrefix: 'OpenKnowledge-Beta-' },
} as const;
type UpdateChannel = keyof typeof CHANNELS;
const SAFE_FILENAME = /^[A-Za-z0-9._-]+$/;
const ARTIFACT_VERSION =
/-(\d+\.\d+\.\d+(?:-[0-9A-Za-z.]+)?)-(?:arm64|x64|universal)-mac\.zip(?:\.blockmap)?$/;
-const MANIFEST = /^(?:latest|beta)(?:-mac|-linux(?:-arm64)?)?\.yml$/;
+const MANIFEST = /^(?:latest|beta|beta-product)(?:-mac|-linux(?:-arm64)?)?\.yml$/;
const TAG_FROM_URL = /\/releases\/download\/([^/]+)\//;
const HEADER_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.]+)?$/;
@@ -22,7 +23,14 @@ function headerVersion(request: Request, name: string): string | undefined {
}
const VERSION_FROM_TAG = /^v(\d+\.\d+\.\d+(?:-[0-9A-Za-z.]+)?)$/;
-const resolveBeta = createBetaResolver();
+const betaResolvers = new Map(
+ ['beta', 'beta-product'].flatMap((prefix) =>
+ ['.yml', '-mac.yml', '-linux.yml', '-linux-arm64.yml'].map((suffix) => {
+ const assetName = `${prefix}${suffix}`;
+ return [assetName, createBetaResolver({ assetName })] as const;
+ }),
+ ),
+);
type ArtifactType = 'manifest' | 'zip' | 'blockmap' | 'dmg' | 'exe' | 'deb' | 'rpm' | 'other';
@@ -71,8 +79,22 @@ function errorResponse(status: number): Response {
return new Response(null, { status, headers: { 'cache-control': 'no-store' } });
}
-async function latestBetaTag(): Promise<string | null> {
- const redirect = await resolveBeta();
+async function latestBetaTag(
+ channel: 'beta' | 'beta-product',
+ filename: string,
+ type: ArtifactType,
+): Promise<string | null> {
+ const manifest =
+ type === 'manifest'
+ ? filename
+ : type === 'exe'
+ ? `${channel}.yml`
+ : type === 'deb' || type === 'rpm'
+ ? `${channel}-linux${archOf(filename) === 'arm64' ? '-arm64' : ''}.yml`
+ : `${channel}-mac.yml`;
+ const resolve = betaResolvers.get(manifest);
+ if (!resolve) return null;
+ const redirect = await resolve();
if (redirect.kind === 'stale-lkg') {
console.warn(
`[updates/beta] serving stale LKG tag after refresh failure: ${redirect.refreshError}`,
@@ -93,13 +115,12 @@ function matchesChannelIdentity(
): boolean {
const config = CHANNELS[channel];
if (type === 'manifest') {
- return (
- filename.startsWith(`${config.manifestPrefix}-`) ||
- filename === `${config.manifestPrefix}.yml`
+ return ['.yml', '-mac.yml', '-linux.yml', '-linux-arm64.yml'].some(
+ (suffix) => filename === `${config.manifestPrefix}${suffix}`,
);
}
if (!filename.startsWith(config.productPrefix)) return false;
- return channel !== 'stable' || !filename.startsWith(CHANNELS.beta.productPrefix);
+ return channel === 'beta-product' || !filename.startsWith(CHANNELS['beta-product'].productPrefix);
}
export async function GET(
@@ -118,6 +139,9 @@ export async function GET(
}
const version = ARTIFACT_VERSION.exec(filename)?.[1];
+ if (version && (channel === 'stable' ? version.includes('-') : !/-beta\.\d+$/.test(version))) {
+ return errorResponse(404);
+ }
let target: string;
let resolvedTagVersion: string | undefined;
@@ -126,7 +150,7 @@ export async function GET(
} else if (channel === 'stable') {
target = `${RELEASES_BASE}/latest/download/${filename}`;
} else {
- const tag = await latestBetaTag();
+ const tag = await latestBetaTag(channel, filename, type);
if (!tag) {
return errorResponse(503);
}
diff --git a/docs/src/lib/download-links.test.ts b/docs/src/lib/download-links.test.ts
index c4980385e..ef5939966 100644
--- a/docs/src/lib/download-links.test.ts
+++ b/docs/src/lib/download-links.test.ts
@@ -4,7 +4,7 @@ import {
createBetaResolver,
DMG_ASSET_NAME,
FALLBACK_CACHE_CONTROL,
- pickLatestBetaDmgUrl,
+ pickLatestBetaAssetUrl,
RELEASES_PAGE_URL,
STABLE_DMG_URL,
SUCCESS_CACHE_CONTROL,
@@ -40,9 +40,34 @@ function jsonResponse(payload: unknown, status = 200) {
return new Response(JSON.stringify(payload), { status });
}
-describe('pickLatestBetaDmgUrl', () => {
+describe('pickLatestBetaAssetUrl', () => {
+ test('keeps a platform on its latest available release when a newer release omits it', () => {
+ const releases = [
+ release('v0.78.0-beta.7', { assetNames: ['beta-mac.yml', DMG_ASSET_NAME] }),
+ release('v0.78.0-beta.6', { assetNames: ['beta.yml', 'beta-linux-arm64.yml'] }),
+ ];
+ expect(pickLatestBetaAssetUrl(releases, 'beta.yml')).toBe(dmgUrl('v0.78.0-beta.6', 'beta.yml'));
+ expect(pickLatestBetaAssetUrl(releases, 'beta-linux-arm64.yml')).toBe(
+ dmgUrl('v0.78.0-beta.6', 'beta-linux-arm64.yml'),
+ );
+ expect(pickLatestBetaAssetUrl(releases, 'beta-mac.yml')).toBe(
+ dmgUrl('v0.78.0-beta.7', 'beta-mac.yml'),
+ );
+ });
+
+ test('resolves legacy and separate Beta independently from the same release list', () => {
+ const releases = [
+ release('v0.78.0-beta.6', { assetNames: [DMG_ASSET_NAME, BETA_DMG_ASSET_NAME] }),
+ release('v0.78.0-beta.7', { assetNames: [BETA_DMG_ASSET_NAME] }),
+ ];
+ expect(pickLatestBetaAssetUrl(releases, DMG_ASSET_NAME)).toBe(
+ dmgUrl('v0.78.0-beta.6', DMG_ASSET_NAME),
+ );
+ expect(pickLatestBetaAssetUrl(releases)).toBe(dmgUrl('v0.78.0-beta.7'));
+ });
+
test('picks the highest-versioned published beta', () => {
- const url = pickLatestBetaDmgUrl([
+ const url = pickLatestBetaAssetUrl([
release('v0.12.0-beta.7'),
release('v0.12.0-beta.6'),
release('v0.11.0', { prerelease: false }),
@@ -51,7 +76,7 @@ describe('pickLatestBetaDmgUrl', () => {
});
test('ranks by version, not the array order GitHub returns (older beta listed first)', () => {
- const url = pickLatestBetaDmgUrl([
+ const url = pickLatestBetaAssetUrl([
release('v0.20.0-beta.9'),
release('v0.20.0-beta.8'),
release('v0.20.0-beta.13'),
@@ -62,12 +87,12 @@ describe('pickLatestBetaDmgUrl', () => {
});
test('beta.10 outranks beta.9 (no lexical tag compare)', () => {
- const url = pickLatestBetaDmgUrl([release('v0.20.0-beta.9'), release('v0.20.0-beta.10')]);
+ const url = pickLatestBetaAssetUrl([release('v0.20.0-beta.9'), release('v0.20.0-beta.10')]);
expect(url).toBe(dmgUrl('v0.20.0-beta.10'));
});
test('ranks across base versions (minor/patch), not just the beta counter', () => {
- const url = pickLatestBetaDmgUrl([
+ const url = pickLatestBetaAssetUrl([
release('v0.20.0-beta.99'),
release('v0.21.0-beta.1'),
release('v0.20.1-beta.2'),
@@ -76,7 +101,7 @@ describe('pickLatestBetaDmgUrl', () => {
});
test('skips the newest beta when its DMG is missing, ranking the next-newest', () => {
- const url = pickLatestBetaDmgUrl([
+ const url = pickLatestBetaAssetUrl([
release('v0.20.0-beta.13', { assetNames: ['beta-mac.yml'] }),
release('v0.20.0-beta.12'),
release('v0.20.0-beta.9'),
@@ -85,7 +110,7 @@ describe('pickLatestBetaDmgUrl', () => {
});
test('skips stable releases even when they appear first', () => {
- const url = pickLatestBetaDmgUrl([
+ const url = pickLatestBetaAssetUrl([
release('v0.11.0', { prerelease: false }),
release('v0.11.0-beta.3'),
]);
@@ -93,7 +118,7 @@ describe('pickLatestBetaDmgUrl', () => {
});
test('skips a beta whose DMG never uploaded and falls back to the previous one', () => {
- const url = pickLatestBetaDmgUrl([
+ const url = pickLatestBetaAssetUrl([
release('v0.12.0-beta.7', { assetNames: ['beta-mac.yml'] }),
release('v0.12.0-beta.6'),
]);
@@ -101,7 +126,7 @@ describe('pickLatestBetaDmgUrl', () => {
});
test('skips drafts', () => {
- const url = pickLatestBetaDmgUrl([
+ const url = pickLatestBetaAssetUrl([
release('v0.12.0-beta.7', { draft: true }),
release('v0.12.0-beta.6'),
]);
@@ -109,7 +134,7 @@ describe('pickLatestBetaDmgUrl', () => {
});
test('skips prereleases that are not -beta.N tags', () => {
- const url = pickLatestBetaDmgUrl([
+ const url = pickLatestBetaAssetUrl([
release('v0.12.0-rc.1'),
release('beta-latest'),
release('v0.12.0-beta'),
@@ -119,7 +144,7 @@ describe('pickLatestBetaDmgUrl', () => {
});
test('skips legacy shared-identity beta artifacts', () => {
- const url = pickLatestBetaDmgUrl([
+ const url = pickLatestBetaAssetUrl([
release('v0.12.0-beta.8', { assetNames: [DMG_ASSET_NAME] }),
release('v0.12.0-beta.7'),
]);
@@ -127,7 +152,7 @@ describe('pickLatestBetaDmgUrl', () => {
});
test('rejects asset URLs outside our release-download prefix', () => {
- const url = pickLatestBetaDmgUrl([
+ const url = pickLatestBetaAssetUrl([
release('v0.12.0-beta.7', { assetHost: 'https://evil.example.com/releases/download' }),
release('v0.12.0-beta.6'),
]);
@@ -135,14 +160,14 @@ describe('pickLatestBetaDmgUrl', () => {
});
test('returns null when no published beta carries the DMG', () => {
- expect(pickLatestBetaDmgUrl([release('v0.11.0', { prerelease: false })])).toBeNull();
- expect(pickLatestBetaDmgUrl([])).toBeNull();
+ expect(pickLatestBetaAssetUrl([release('v0.11.0', { prerelease: false })])).toBeNull();
+ expect(pickLatestBetaAssetUrl([])).toBeNull();
});
test('returns null on malformed payloads instead of throwing', () => {
- expect(pickLatestBetaDmgUrl(null)).toBeNull();
- expect(pickLatestBetaDmgUrl({ message: 'API rate limit exceeded' })).toBeNull();
- expect(pickLatestBetaDmgUrl([{ tag_name: 42 }])).toBeNull();
+ expect(pickLatestBetaAssetUrl(null)).toBeNull();
+ expect(pickLatestBetaAssetUrl({ message: 'API rate limit exceeded' })).toBeNull();
+ expect(pickLatestBetaAssetUrl([{ tag_name: 42 }])).toBeNull();
});
});
diff --git a/docs/src/lib/download-links.ts b/docs/src/lib/download-links.ts
index cdaa02767..6f8bcdf25 100644
--- a/docs/src/lib/download-links.ts
+++ b/docs/src/lib/download-links.ts
@@ -46,7 +46,10 @@ const releasesSchema = z.array(
}),
);
-export function pickLatestBetaDmgUrl(payload: unknown): string | null {
+export function pickLatestBetaAssetUrl(
+ payload: unknown,
+ assetName = BETA_DMG_ASSET_NAME,
+): string | null {
const parsed = releasesSchema.safeParse(payload);
if (!parsed.success) {
console.warn(
@@ -62,8 +65,7 @@ export function pickLatestBetaDmgUrl(payload: unknown): string | null {
if (!parts) continue;
const dmg = release.assets.find(
(asset) =>
- asset.name === BETA_DMG_ASSET_NAME &&
- asset.browser_download_url.startsWith(ASSET_URL_PREFIX),
+ asset.name === assetName && asset.browser_download_url.startsWith(ASSET_URL_PREFIX),
);
if (!dmg) continue;
const rank: PrereleaseRank = [
@@ -92,7 +94,7 @@ function describeError(err: unknown): string {
}
export function createBetaResolver(
- deps: { fetchImpl?: typeof fetch; now?: () => number } = {},
+ deps: { fetchImpl?: typeof fetch; now?: () => number; assetName?: string } = {},
): () => Promise<PrereleaseRedirect> {
const fetchImpl = deps.fetchImpl ?? fetch;
const now = deps.now ?? Date.now;
@@ -121,9 +123,11 @@ export function createBetaResolver(
cause: parseErr,
});
}
- const url = pickLatestBetaDmgUrl(payload);
+ const url = pickLatestBetaAssetUrl(payload, deps.assetName);
if (!url) {
- throw new Error('no published beta release carries the Beta DMG asset');
+ throw new Error(
+ `no published beta release carries ${deps.assetName ?? BETA_DMG_ASSET_NAME}`,
+ );
}
lkg = { url, fetchedAt: now() };
return { kind: 'fresh', url };
diff --git a/knip.config.ts b/knip.config.ts
index 6a38348d8..8b615429f 100644
--- a/knip.config.ts
+++ b/knip.config.ts
@@ -143,11 +143,15 @@ 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.ts
index 8a60e5826..a28cc2b18 100644
--- a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts
+++ b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts
@@ -1,3 +1,4 @@
+
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.ts
index 6fcdc23f2..4fc2c11f9 100644
--- a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts
+++ b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts
@@ -1,3 +1,4 @@
+
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.ts
index 40b5cdfd6..9f2f6feb6 100644
--- a/packages/app/tests/integration/interior-edit-freshness.test.ts
+++ b/packages/app/tests/integration/interior-edit-freshness.test.ts
@@ -1,3 +1,4 @@
+
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.ts
index 93666af70..2a085742b 100644
--- a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts
+++ b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts
@@ -1,3 +1,4 @@
+
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.ts
index 867598d34..878d5196b 100644
--- a/packages/app/tests/integration/producer-guard-wiring.test.ts
+++ b/packages/app/tests/integration/producer-guard-wiring.test.ts
@@ -1,3 +1,4 @@
+
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.ts
index 0970ac12f..4ada3cf26 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,3 +1,4 @@
+
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.ts
index b632185e1..cbe2b705f 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,3 +1,4 @@
+
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.ts
index c530ce4ba..89bc9b4d9 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,3 +1,4 @@
+
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.ts
index d3767adc9..a78aeb0e4 100644
--- a/packages/app/tests/integration/undo-after-rollback.test.ts
+++ b/packages/app/tests/integration/undo-after-rollback.test.ts
@@ -1,3 +1,4 @@
+
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.ts
index b076f955c..e7cc69c3f 100644
--- a/packages/app/tests/integration/undo-recycle-reset.test.ts
+++ b/packages/app/tests/integration/undo-recycle-reset.test.ts
@@ -1,3 +1,4 @@
+
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.ts
index 7935e35f8..9ddcd0730 100644
--- a/packages/app/tests/integration/undo-rederive-survival.test.ts
+++ b/packages/app/tests/integration/undo-rederive-survival.test.ts
@@ -1,3 +1,4 @@
+
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/core/src/bridge/compose.ts b/packages/core/src/bridge/compose.ts
index f4cc8a286..2a597ec3d 100644
--- a/packages/core/src/bridge/compose.ts
+++ b/packages/core/src/bridge/compose.ts
@@ -1,3 +1,4 @@
+
import { prependFrontmatter, stripFrontmatter } from '../extensions/frontmatter.ts';
export type ComposeAdjustment = 'none' | 'body' | 'frontmatter' | 'unresolved';
diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.ts
index 8fb428b90..01ef76a9f 100644
--- a/packages/core/src/bridge/doc-boundary-space.ts
+++ b/packages/core/src/bridge/doc-boundary-space.ts
@@ -1,3 +1,4 @@
+
import { FRONTMATTER_RE, stripFrontmatter } from '../extensions/frontmatter.ts';
import { carriedEdgeEmpties, type DocEdgeEmpties } from '../markdown/doc-edge-blank-runs.ts';
diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.ts
index fc267cbea..fb0ba5a7c 100644
--- a/packages/core/src/markdown/comment-promoter.ts
+++ b/packages/core/src/markdown/comment-promoter.ts
@@ -1,3 +1,4 @@
+
import type { Nodes, Paragraph, PhrasingContent, Root, RootContent, Text } from 'mdast';
import { SKIP, visit } from 'unist-util-visit';
import type { VFile } from 'vfile';
diff --git a/packages/core/src/markdown/merged-walker.ts b/packages/core/src/markdown/merged-walker.ts
index bfd7e3109..fa3cfcd86 100644
--- a/packages/core/src/markdown/merged-walker.ts
+++ b/packages/core/src/markdown/merged-walker.ts
@@ -1,3 +1,4 @@
+
import type { Nodes, Parent, Root } from 'mdast';
import { SKIP, visit } from 'unist-util-visit';
import type { VFile } from 'vfile';
diff --git a/packages/core/src/markdown/safe-url.ts b/packages/core/src/markdown/safe-url.ts
index 4d3250d3a..8be632ba4 100644
--- a/packages/core/src/markdown/safe-url.ts
+++ b/packages/core/src/markdown/safe-url.ts
@@ -1,3 +1,4 @@
+
export const SAFE_URL_SCHEMES = ['https', 'http', 'mailto', 'tel', 'ftp', 'sms'] as const;
const SCHEME_ALT = SAFE_URL_SCHEMES.map((s) => `${s}:`).join('|');
diff --git a/packages/desktop/package.json b/packages/desktop/package.json
index 91920d052..e6ff9d1b1 100644
--- a/packages/desktop/package.json
+++ b/packages/desktop/package.json
@@ -10,6 +10,7 @@
},
"private": true,
"type": "module",
+ "packageManager": "[email protected]",
"main": "out/main/index.js",
"engines": {
"node": ">=24"
diff --git a/packages/desktop/scripts/desktop-variant-config.ts b/packages/desktop/scripts/desktop-variant-config.ts
index 317d09ac0..04af65853 100644
--- a/packages/desktop/scripts/desktop-variant-config.ts
+++ b/packages/desktop/scripts/desktop-variant-config.ts
@@ -95,17 +95,17 @@ export function createVariantBuilderConfig(
config.productName = variant.productName;
config.extraMetadata = {
...config.extraMetadata,
- okDesktopVariant: variant.name,
+ okDesktopVariant: variantName,
productName: variant.productName,
...(variant.name === 'stable' ? {} : { name: variant.packageName }),
- ...(variant.name === 'beta' ? { version: betaBuildVersion(sourceVersion) } : {}),
+ ...(variant.updateChannel === 'beta' ? { version: betaBuildVersion(sourceVersion) } : {}),
};
config.protocols = [
{ name: `${variant.productName} URL`, schemes: [variant.protocolScheme], role: 'Editor' },
];
config.publish = config.publish.map((entry) => ({
...entry,
- channel: variant.updateChannel,
+ channel: variant.feedChannel,
}));
config.mac.icon = variant.name === 'stable' ? config.mac.icon : variant.iconPath;
config.mac.artifactName = `${variant.artifactName}-\${version}-\${arch}-mac.\${ext}`;
diff --git a/packages/desktop/scripts/run-electron-builder.mjs b/packages/desktop/scripts/run-electron-builder.mjs
index d00678cdf..c8563a4fe 100644
--- a/packages/desktop/scripts/run-electron-builder.mjs
+++ b/packages/desktop/scripts/run-electron-builder.mjs
@@ -19,8 +19,8 @@ const variantName = parseDesktopVariantName(process.env.OK_DESKTOP_VARIANT);
const variant = DESKTOP_VARIANTS[variantName];
const args = process.argv.slice(2);
const buildDir = join(process.cwd(), '.variant-build');
-const profilePath = join(process.cwd(), `build/embedded.${variantName}.provisionprofile`);
-const profileAvailable = variantName === 'stable' || existsSync(profilePath);
+const profilePath = join(process.cwd(), `build/embedded.${variant.name}.provisionprofile`);
+const profileAvailable = variant.name === 'stable' || existsSync(profilePath);
const packagingMac = args.includes('--mac') || args.includes('--dir');
const signingRequested = Boolean(process.env.CSC_LINK || process.env.CSC_KEYCHAIN);
diff --git a/packages/desktop/scripts/smoke-mock-update.mjs b/packages/desktop/scripts/smoke-mock-update.mjs
index 105ee8448..d02093b4a 100644
--- a/packages/desktop/scripts/smoke-mock-update.mjs
+++ b/packages/desktop/scripts/smoke-mock-update.mjs
@@ -7,7 +7,7 @@ import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { deflateRawSync } from 'node:zlib';
-const SUPPORTED_CHANNELS = /** @type {const} */ (['latest', 'beta']);
+const SUPPORTED_CHANNELS = /** @type {const} */ (['latest', 'beta', 'beta-product']);
const RAW_CHANNEL = process.env.OK_UPDATER_MOCK_CHANNEL ?? 'latest';
if (!SUPPORTED_CHANNELS.includes(/** @type {any} */ (RAW_CHANNEL))) {
console.error(
@@ -15,10 +15,10 @@ if (!SUPPORTED_CHANNELS.includes(/** @type {any} */ (RAW_CHANNEL))) {
);
process.exit(2);
}
-/** @type {'latest' | 'beta'} */
-const CHANNEL = /** @type {'latest' | 'beta'} */ (RAW_CHANNEL);
+/** @type {'latest' | 'beta' | 'beta-product'} */
+const CHANNEL = /** @type {'latest' | 'beta' | 'beta-product'} */ (RAW_CHANNEL);
const MANIFEST_NAME = `${CHANNEL}-mac.yml`;
-const DEFAULT_VERSION = CHANNEL === 'beta' ? '0.4.0-beta.0' : '0.99.0-mock';
+const DEFAULT_VERSION = CHANNEL === 'latest' ? '0.99.0-mock' : '0.4.0-beta.0';
const VERSION = process.env.MOCK_UPDATE_VERSION ?? DEFAULT_VERSION;
const TIMEOUT_MS = Number.parseInt(process.env.MOCK_UPDATE_TIMEOUT_MS ?? '30000', 10);
const KEEP_ALIVE = process.argv.includes('--keep-alive');
diff --git a/packages/desktop/src/main/auto-updater.ts b/packages/desktop/src/main/auto-updater.ts
index 2f379040b..088d5be37 100644
--- a/packages/desktop/src/main/auto-updater.ts
+++ b/packages/desktop/src/main/auto-updater.ts
@@ -106,7 +106,11 @@ interface StartAutoUpdaterOpts {
platform?: NodeJS.Platform;
forceDevBypass?: boolean;
feedUrl?: string;
- proxyFeed?: { base: string; channels: ReadonlySet<UpdateChannel> };
+ proxyFeed?: {
+ base: string;
+ channels: ReadonlySet<UpdateChannel>;
+ betaChannel?: 'beta' | 'beta-product';
+ };
whenRendererReady?: (fn: () => void) => void;
prepareForRelaunch?: () => void | Promise<void>;
sweepUpdateSurvivors?: () => WindowsUpdateSurvivorSweepResult | undefined;
@@ -404,7 +408,11 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
applyChannelSettings(updater, buildChannel);
updater.forceDevUpdateConfig = forceDevBypass;
- const proxyChannelPath = buildChannel === 'beta' ? 'beta' : 'stable';
+ const proxyChannelPath = buildChannel === 'beta' ? (proxyFeed?.betaChannel ?? 'beta') : 'stable';
+ if (buildChannel === 'beta' && proxyFeed?.betaChannel) {
+ updater.channel = proxyFeed.betaChannel;
+ updater.allowDowngrade = false;
+ }
const configuredProxyFeed =
!feedUrl && proxyFeed?.channels.has(buildChannel)
? {
diff --git a/packages/desktop/src/main/index.ts b/packages/desktop/src/main/index.ts
index 437bd36a6..4b11a6bb6 100644
--- a/packages/desktop/src/main/index.ts
+++ b/packages/desktop/src/main/index.ts
@@ -6625,6 +6625,7 @@ function bootPrimaryInstance(): void {
proxyFeed: {
base: 'https://openknowledge.ai/updates',
channels: new Set<UpdateChannel>(['beta', 'latest']),
+ betaChannel: DESKTOP_VARIANT.name === 'beta' ? 'beta-product' : 'beta',
},
whenRendererReady: (fn) => {
const tryFire = (win: BrowserWindow): void => {
diff --git a/packages/desktop/src/shared/desktop-variant.test.ts b/packages/desktop/src/shared/desktop-variant.test.ts
index e89fb4a59..a074f5aa8 100644
--- a/packages/desktop/src/shared/desktop-variant.test.ts
+++ b/packages/desktop/src/shared/desktop-variant.test.ts
@@ -18,7 +18,7 @@ describe('desktop variant identities', () => {
});
test('gives every variant a disjoint persistent identity', () => {
- const identities = Object.values(DESKTOP_VARIANTS);
+ const identities = [DESKTOP_VARIANTS.stable, DESKTOP_VARIANTS.beta];
const keys: Array<keyof (typeof identities)[number]> = [
'appId',
'productName',
@@ -34,10 +34,20 @@ describe('desktop variant identities', () => {
expect(new Set(identities.flatMap((identity) => identity.cliCommandNames)).size).toBe(4);
});
+ test('keeps legacy Beta on the original identity and manifest contract', () => {
+ expect(DESKTOP_VARIANTS['legacy-beta']).toEqual({
+ ...DESKTOP_VARIANTS.stable,
+ updateChannel: 'beta',
+ feedChannel: 'beta',
+ });
+ expect(DESKTOP_VARIANTS.beta.feedChannel).toBe('beta-product');
+ });
+
test.each<[string | undefined, DesktopVariantName]>([
[undefined, 'stable'],
['', 'stable'],
[' BETA ', 'beta'],
+ ['legacy-beta', 'legacy-beta'],
])('parses %j as %s', (raw, expected) => {
expect(parseDesktopVariantName(raw)).toBe(expected);
});
diff --git a/packages/desktop/src/shared/desktop-variant.ts b/packages/desktop/src/shared/desktop-variant.ts
index ee0bdef5f..9d17e73bf 100644
--- a/packages/desktop/src/shared/desktop-variant.ts
+++ b/packages/desktop/src/shared/desktop-variant.ts
@@ -1,17 +1,18 @@
import { DESKTOP_PRODUCTS, type DesktopProductName } from '@inkeep/open-knowledge-core';
-const DESKTOP_VARIANT_NAMES = ['stable', 'beta'] as const satisfies readonly DesktopProductName[];
+const DESKTOP_VARIANT_NAMES = ['stable', 'beta', 'legacy-beta'] as const;
export type DesktopVariantName = (typeof DESKTOP_VARIANT_NAMES)[number];
interface DesktopVariantIdentity {
- readonly name: DesktopVariantName;
+ readonly name: DesktopProductName;
readonly appId: string;
readonly productName: string;
readonly artifactName: string;
readonly packageName: string;
readonly protocolScheme: string;
readonly updateChannel: 'latest' | 'beta';
+ readonly feedChannel: 'latest' | 'beta' | 'beta-product';
readonly instanceLabel: string | null;
readonly iconPath: string;
readonly linuxExecutableName: string;
@@ -23,7 +24,7 @@ interface DesktopVariantIdentity {
readonly cliHomeSegment: string | null;
}
-export const DESKTOP_VARIANTS = {
+const DESKTOP_PRODUCT_VARIANTS = {
stable: {
name: 'stable',
appId: DESKTOP_PRODUCTS.stable.appId,
@@ -32,6 +33,7 @@ export const DESKTOP_VARIANTS = {
packageName: DESKTOP_PRODUCTS.stable.packageName,
protocolScheme: 'openknowledge',
updateChannel: 'latest',
+ feedChannel: 'latest',
instanceLabel: null,
iconPath: 'build/icon.png',
linuxExecutableName: DESKTOP_PRODUCTS.stable.linuxExecutableName,
@@ -47,6 +49,7 @@ export const DESKTOP_VARIANTS = {
packageName: DESKTOP_PRODUCTS.beta.packageName,
protocolScheme: 'openknowledge-beta',
updateChannel: 'beta',
+ feedChannel: 'beta-product',
instanceLabel: 'Beta',
iconPath: 'build/icon-beta.png',
linuxExecutableName: DESKTOP_PRODUCTS.beta.linuxExecutableName,
@@ -54,6 +57,15 @@ export const DESKTOP_VARIANTS = {
cliCommandNames: ['ok-beta', 'open-knowledge-beta'],
cliHomeSegment: 'beta',
},
+} as const satisfies Record<DesktopProductName, DesktopVariantIdentity>;
+
+export const DESKTOP_VARIANTS = {
+ ...DESKTOP_PRODUCT_VARIANTS,
+ 'legacy-beta': {
+ ...DESKTOP_PRODUCT_VARIANTS.stable,
+ updateChannel: 'beta',
+ feedChannel: 'beta',
+ },
} as const satisfies Record<DesktopVariantName, DesktopVariantIdentity>;
export function parseDesktopVariantName(raw: string | undefined): DesktopVariantName {
@@ -62,7 +74,7 @@ export function parseDesktopVariantName(raw: string | undefined): DesktopVariant
return normalized as DesktopVariantName;
}
throw new Error(
- `Unsupported OK_DESKTOP_VARIANT=${JSON.stringify(raw)}. Expected stable or beta.`,
+ `Unsupported OK_DESKTOP_VARIANT=${JSON.stringify(raw)}. Expected stable or beta or legacy-beta.`,
);
}
diff --git a/packages/desktop/tests/integration/auto-updater.test.ts b/packages/desktop/tests/integration/auto-updater.test.ts
index 9ed72075c..0be0e2d7e 100644
--- a/packages/desktop/tests/integration/auto-updater.test.ts
+++ b/packages/desktop/tests/integration/auto-updater.test.ts
@@ -196,7 +196,11 @@ function makeRig(
platform?: NodeJS.Platform;
forceDevBypass?: boolean;
feedUrl?: string;
- proxyFeed?: { base: string; channels: ReadonlySet<'latest' | 'beta'> };
+ proxyFeed?: {
+ base: string;
+ channels: ReadonlySet<'latest' | 'beta'>;
+ betaChannel?: 'beta' | 'beta-product';
+ };
updaterSetup?: (u: FakeUpdater) => void;
extraWindowCount?: number;
prepareForRelaunch?: () => void;
@@ -434,6 +438,30 @@ describe('startAutoUpdater — initial configuration (parent §8.10 LOCKED)', ()
});
});
+ test('separate Beta uses its own feed and manifest without enabling downgrades', () => {
+ const { rig } = makeRig({
+ appVersion: '0.78.0-beta.6',
+ updaterSetup: (updater) => {
+ let channel: string | null = null;
+ Object.defineProperty(updater, 'channel', {
+ get: () => channel,
+ set: (value: string) => {
+ channel = value;
+ updater.allowDowngrade = true;
+ },
+ });
+ },
+ proxyFeed: { base: PROXY_BASE, channels: new Set(['beta']), betaChannel: 'beta-product' },
+ });
+ expect(rig.updater.setFeedURL).toHaveBeenCalledWith({
+ provider: 'generic',
+ url: `${PROXY_BASE}/beta-product`,
+ });
+ expect(rig.updater.channel).toBe('beta-product');
+ expect(rig.updater.allowPrerelease).toBe(true);
+ expect(rig.updater.allowDowngrade).toBe(false);
+ });
+
test('proxyFeed: stable build maps the latest channel to the proxy /stable path', () => {
const { rig } = makeRig({
appVersion: '0.4.0',
diff --git a/packages/desktop/tests/unit/desktop-variant-config.test.ts b/packages/desktop/tests/unit/desktop-variant-config.test.ts
index 59c14bc41..f35f1d682 100644
--- a/packages/desktop/tests/unit/desktop-variant-config.test.ts
+++ b/packages/desktop/tests/unit/desktop-variant-config.test.ts
@@ -75,6 +75,30 @@ const platformArtifact = (name: string): string => `${name}-${token('arch')}.${t
const nsisArtifact = (name: string): string => `${name}-Setup-${token('arch')}.${token('ext')}`;
describe('desktop variant builder config', () => {
+ test('legacy Beta preserves the installed identity, CLI wrappers and old manifest names', () => {
+ const stable = createVariantBuilderConfig(
+ parseBuilderConfig(configSource),
+ 'stable',
+ paths,
+ '0.78.0-beta.6',
+ );
+ const legacy = createVariantBuilderConfig(
+ parseBuilderConfig(configSource),
+ 'legacy-beta',
+ paths,
+ '0.78.0-beta.6',
+ );
+ expect(legacy).toEqual({
+ ...stable,
+ extraMetadata: {
+ ...stable.extraMetadata,
+ okDesktopVariant: 'legacy-beta',
+ version: '0.78.0-beta.6',
+ },
+ publish: stable.publish.map((entry) => ({ ...entry, channel: 'beta' })),
+ });
+ });
+
test('preserves Stable identity', () => {
const config = createVariantBuilderConfig(
parseBuilderConfig(configSource),
@@ -127,7 +151,7 @@ describe('desktop variant builder config', () => {
appId: 'com.inkeep.open-knowledge.beta',
productName: 'OpenKnowledge Beta',
protocols: [{ schemes: ['openknowledge-beta'] }],
- publish: [{ channel: 'beta' }],
+ publish: [{ channel: 'beta-product' }],
extraMetadata: {
name: 'openknowledge-beta-desktop',
productName: 'OpenKnowledge Beta',
diff --git a/packages/desktop/tests/unit/electron-builder-package-manager.test.mjs b/packages/desktop/tests/unit/electron-builder-package-manager.test.mjs
new file mode 100644
index 000000000..8fb8e64fb
--- /dev/null
+++ b/packages/desktop/tests/unit/electron-builder-package-manager.test.mjs
@@ -0,0 +1,54 @@
+import { spawnSync } from 'node:child_process';
+import { readFileSync } from 'node:fs';
+import { createRequire } from 'node:module';
+import { resolve } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+
+const desktopRoot = fileURLToPath(new URL('../..', import.meta.url));
+const workspaceRoot = resolve(desktopRoot, '../..');
+const require_ = createRequire(import.meta.url);
+const builderRequire = createRequire(require_.resolve('electron-builder'));
+const collectorPath = builderRequire.resolve('app-builder-lib/out/node-module-collector/index.js');
+
+describe('desktop packaging package manager', () => {
+ test('keeps the desktop package manager aligned with the workspace', () => {
+ const desktop = JSON.parse(readFileSync(resolve(desktopRoot, 'package.json'), 'utf8'));
+ const workspace = JSON.parse(readFileSync(resolve(workspaceRoot, 'package.json'), 'utf8'));
+ expect(desktop.packageManager).toBe(workspace.packageManager);
+ });
+
+ test.each([undefined, 'npm/11.0.0 node/v24.18.0'])(
+ 'selects pnpm and its workspace for a direct Node invocation with user agent %s',
+ (userAgent) => {
+ const env = { ...process.env };
+ for (const key of Object.keys(env)) {
+ if (/^npm_/i.test(key) || key === 'INIT_CWD') delete env[key];
+ }
+ if (userAgent) env.npm_config_user_agent = userAgent;
+ const result = spawnSync(
+ process.execPath,
+ [
+ '--input-type=module',
+ '--eval',
+ `
+ import { createRequire } from 'node:module';
+ const require = createRequire(import.meta.url);
+ const { determinePackageManagerEnv } = require(${JSON.stringify(collectorPath)});
+ const result = await determinePackageManagerEnv({
+ projectDir: process.cwd(), appDir: process.cwd(), workspaceRoot: undefined,
+ }).value;
+ console.log(JSON.stringify({ pm: result.pm, root: await result.workspaceRoot }));
+ `,
+ ],
+ { cwd: desktopRoot, env, encoding: 'utf8', timeout: 30_000 },
+ );
+ expect(result.error).toBeUndefined();
+ expect(result.status, result.stderr).toBe(0);
+ expect(JSON.parse(result.stdout.trim().split('\n').at(-1))).toEqual({
+ pm: 'pnpm',
+ root: workspaceRoot,
+ });
+ },
+ );
+});