Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

chore(desktop): read the Clerk dev key from the root .env

leepokai865bdecaca8c
diff --git a/.gitignore b/.gitignore
index c63ae6a5..e5521075 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,3 +26,7 @@ videos/
# Python bytecode
__pycache__/
+
+# Local secrets (Clerk dev key for apps/desktop/tools/dev-account.mjs)
+.env
+.env.*
diff --git a/apps/desktop/.gitignore b/apps/desktop/.gitignore
index 2873bc80..2783f80f 100644
--- a/apps/desktop/.gitignore
+++ b/apps/desktop/.gitignore
@@ -5,5 +5,3 @@ dist/
src/renderer/public/symbols/
native/speech-macos/.build/
resources/account-config.json
-# Clerk dev-instance secret key for tools/dev-account.mjs
-.env.local
diff --git a/apps/desktop/tools/dev-account.mjs b/apps/desktop/tools/dev-account.mjs
index 71b3a821..fd1116f4 100644
--- a/apps/desktop/tools/dev-account.mjs
+++ b/apps/desktop/tools/dev-account.mjs
@@ -1,18 +1,20 @@
// A Clerk test account for `npm run dev` sandboxes: finds or creates `sandbox-<name>[email protected]`
// in the Clerk *development* instance and mints a one-time sign-in token the app trades for a session
-// (account.ts, `CODYNC_DEV_SIGN_IN_TICKET`). The secret key comes from CLERK_SECRET_KEY, the git-ignored
-// apps/desktop/.env.local, or ~/.codync-release/clerk-dev.env (shared by every worktree); only `sk_test_`
-// keys are used, so production is never touched.
+// (account.ts, `CODYNC_DEV_SIGN_IN_TICKET`). The secret key comes from CLERK_SECRET_KEY or the git-ignored
+// `.env` in the main checkout's root (every worktree reads that one file); only `sk_test_` keys are used,
+// so production is never touched.
+import { spawnSync } from 'node:child_process'
import { existsSync, readFileSync } from 'node:fs'
-import { homedir } from 'node:os'
-import { dirname, join } from 'node:path'
+import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
const API = 'https://api.clerk.com/v1'
export function secretKey() {
- const files = [join(dirname(fileURLToPath(import.meta.url)), '..', '.env.local'), join(homedir(), '.codync-release/clerk-dev.env')]
- const fromFile = files.map((f) => (existsSync(f) ? /^CLERK_SECRET_KEY=(.+)$/m.exec(readFileSync(f, 'utf8'))?.[1] : undefined)).find(Boolean)
+ // A linked worktree's git common dir is the main checkout's `.git`, so its parent holds the shared `.env`.
+ const common = spawnSync('git', ['rev-parse', '--git-common-dir'], { cwd: dirname(fileURLToPath(import.meta.url)), encoding: 'utf8' }).stdout.trim()
+ const file = resolve(dirname(fileURLToPath(import.meta.url)), common, '..', '.env')
+ const fromFile = existsSync(file) ? /^CLERK_SECRET_KEY=(.+)$/m.exec(readFileSync(file, 'utf8'))?.[1] : undefined
const key = (process.env.CLERK_SECRET_KEY ?? fromFile ?? '').trim().replace(/^["']|["']$/g, '')
if (key && !key.startsWith('sk_test_')) throw new Error('CLERK_SECRET_KEY must be the development instance key (sk_test_...).')
return key || null
diff --git a/docs/guides/dev-app.md b/docs/guides/dev-app.md
index f087dc7e..29f90f79 100644
--- a/docs/guides/dev-app.md
+++ b/docs/guides/dev-app.md
@@ -30,7 +30,7 @@ Xcode configurations separate environment from optimization: `Debug` and `Releas
Flags go after `npm run dev --`: `--shared` takes the default Codync Dev from a worktree (quit the main checkout's first); `--sandbox` runs a sandbox from the main checkout, for a second session on `dev`; `--name <name>` runs the sandbox of that name, for another copy of the same checkout; `--cloud` lets the sandbox host use the dev cloud (each sandbox then shows as another computer); `--cdp` opens the DevTools protocol on the sandbox port + 10000; `--list` shows every sandbox; `--prune` deletes the ones whose worktree is gone (and their Clerk test accounts), so run it after removing worktrees.
-A sandbox starts past onboarding (welcome and computer-access setup, only where the window hasn't chosen yet); `--onboarding` brings the flow back. With `CLERK_SECRET_KEY` (the Clerk **development** instance's `sk_test_...` key) in the git-ignored `apps/desktop/.env.local` or `~/.codync-release/clerk-dev.env` (one copy for every worktree) or the environment, it also signs in its own Clerk test account `sandbox-<name>[email protected]`: `tools/dev-account.mjs` finds or creates that user through the Backend API and mints a one-time sign-in token, which `account.ts` trades for a session (`ticket` strategy, unpackaged Dev runs only). The session stays in the sandbox's `desktop/`, so the token is minted only while `desktop/account.bin` is missing. Keys that aren't `sk_test_` are refused. Without a key a sandbox starts signed out; it never borrows Codync Dev's login.
+A sandbox starts past onboarding (welcome and computer-access setup, only where the window hasn't chosen yet); `--onboarding` brings the flow back. With `CLERK_SECRET_KEY` (the Clerk **development** instance's `sk_test_...` key) in the git-ignored `.env` at the main checkout's root (every worktree reads that one file) or the environment, it also signs in its own Clerk test account `sandbox-<name>[email protected]`: `tools/dev-account.mjs` finds or creates that user through the Backend API and mints a one-time sign-in token, which `account.ts` trades for a session (`ticket` strategy, unpackaged Dev runs only). The session stays in the sandbox's `desktop/`, so the token is minted only while `desktop/account.bin` is missing. Keys that aren't `sk_test_` are refused. Without a key a sandbox starts signed out; it never borrows Codync Dev's login.
Still shared: macOS sees every unpackaged run as the same Electron app, so permissions and notifications are shared and a `codync-dev://` sign-in callback may reach another copy (test sign-in on the default Codync Dev); Codync Screen and computer use need the packaged `Codync Dev.app`; a global shortcut (the approval island's) goes to whichever app registered it first.