Skip to content

feat(gateway): add Claude Code Desktop support#784

Open
BYK wants to merge 1 commit into
mainfrom
feat/claude-code-desktop
Open

feat(gateway): add Claude Code Desktop support#784
BYK wants to merge 1 commit into
mainfrom
feat/claude-code-desktop

Conversation

@BYK

@BYK BYK commented Jun 15, 2026

Copy link
Copy Markdown
Owner

What

Adds a claude-code-desktop agent and lore setup claude-code-desktop command so the Anthropic Claude Code Desktop app (macOS + Windows) can route through the Lore gateway.

Why / key fact

The Desktop app spawns the same claude CLI as a child process for local Code sessions and reads ANTHROPIC_BASE_URL from ~/.claude/settings.jsonnot from the parent process env. So the integration surface differs from the CLI's lore run env-injection path.

Changes

  • lib/desktop-detect.ts (new): isClaudeDesktopInstalled() — macOS /Applications/Claude.app/Contents/MacOS/Claude, Windows %LOCALAPPDATA%\Programs\Claude\*, null on Linux/other.
  • agents.ts: new claude-code-desktop agent. envVars deliberately omits ANTHROPIC_BASE_URL / DISABLE_AUTO_COMPACT (the spawned child won't inherit them) and only injects the X-Lore-* headers. binary is a stable placeholder; the real launcher path is resolved at runtime via detect().
  • main.ts / run.ts: the shorthand and explicit-command paths now match by agent name OR binary, so lore claude-code-desktop works whether or not the app is installed. Existing binary-matched agents (lore run codex, lore run claude, …) keep spawning the literal token unchanged.
  • setup.ts setupClaudeCodeDesktop: writes ~/.claude/settings.json (primary, documented path), runs setx ANTHROPIC_BASE_URL on Windows so dev/preview servers inherit it, and prints in-app Local env editor values as a fallback for builds hitting anthropics/claude-code#67619. 🔴 The in-app editor store is Electron safeStorage-encrypted and is never written by Lore.
  • Docs + help text: with-claude-code.md gains a Desktop section; setup.md and help.ts list the new app.

Integration approach (researched)

The in-app Local env editor is safeStorage-encrypted (macOS Keychain / Windows DPAPI) and cannot be written by an external tool. Lore therefore automates the documented plaintext path (settings.json + Windows setx) and surfaces the in-app editor only as a manual fallback.

Tests

Deterministic tests added (mocking node:fs existsSync, node:child_process execFileSync, and the detector) for: detection on each platform, the agent's envVars omissions, the linux/mac-detected/mac-missing/windows-setx setup branches, and settings.json write. All discrimination-checked.

Verification

  • pnpm test — 3174 passed / 6 skipped
  • pnpm run typecheck — clean
  • pnpm run lint — clean
  • pnpm run build — all packages + website build
  • Smoke-tested lore setup claude-code-desktop and lore claude-code-desktop dispatch on Linux

Note

An adversarial review was run pre-PR; it caught a BLOCKER (the shorthand failing when the app is installed, due to a module-load-resolved binary) and several MAJOR/MINOR items — all fixed in this branch (stable placeholder binary, name-or-binary matching in main.ts, precise spawn-target resolution, broadened non-desktop-platform guard, and deterministic/discriminating tests).

Add a `claude-code-desktop` agent and `lore setup claude-code-desktop`
command so the Anthropic Claude Code Desktop app (macOS + Windows) can
route through the Lore gateway.

The Desktop spawns the same `claude` CLI as a child and reads
`ANTHROPIC_BASE_URL` from `~/.claude/settings.json` (not the parent env),
so:

- New `lib/desktop-detect.ts` `isClaudeDesktopInstalled()` detects the
  app (macOS `/Applications/Claude.app`, Windows `%LOCALAPPDATA%\Programs\
  Claude`, null on Linux/other).
- The agent's `envVars` deliberately omits `ANTHROPIC_BASE_URL` /
  `DISABLE_AUTO_COMPACT` (the child won't inherit them) and only injects
  the `X-Lore-*` headers. `binary` is a stable placeholder; the real
  launcher path is resolved at runtime via `detect()`.
- `main.ts` / `run.ts` match the shorthand by agent name OR binary so
  `lore claude-code-desktop` works whether or not the app is installed,
  while existing binary-matched agents (`lore run codex`, etc.) keep
  spawning the literal token unchanged.
- `setupClaudeCodeDesktop` writes `~/.claude/settings.json` (primary,
  documented path), runs `setx ANTHROPIC_BASE_URL` on Windows for
  dev/preview servers, and prints in-app Local env editor values as a
  fallback for builds hitting anthropics/claude-code#67619. The in-app
  editor store is Electron `safeStorage`-encrypted and is never written.

Docs and help text updated; deterministic tests added for detection,
envVars, the setup branches, and the Windows `setx` path.
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://withlore.ai/_preview/pr-784/

Built to branch gh-pages at 2026-06-15 23:29 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ Patch coverage is 87.50%. Project has 5698 uncovered lines.
✅ Project coverage is 65.95%. Comparing base (base) to head (head).

Files with missing lines (4)
File Patch % Lines
packages/gateway/src/cli/setup.ts 90.20% ⚠️ 5 Missing and 1 partials
packages/gateway/src/cli/agents.ts 71.43% ⚠️ 2 Missing and 1 partials
packages/gateway/src/cli/main.ts 0.00% ⚠️ 2 Missing
packages/gateway/src/cli/lib/desktop-detect.ts 100.00% ⚠️ 1 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    65.81%    65.95%    +0.14%
==========================================
  Files          106       107        +1
  Lines        16666     16736       +70
  Branches     11670     11692       +22
==========================================
+ Hits         10969     11038       +69
- Misses        5697      5698        +1
- Partials      1333      1336        +3

Generated by Codecov Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant