Skip to content

feat: use Claude Code instead of an API key, and start it from the Implement tab - #20

Merged
mohph197 merged 1 commit into
mainfrom
feat/claude-code-backend
Nov 1, 2026
Merged

mohph197 merged 1 commit into
mainfrom
feat/claude-code-backend

Conversation

@mohph197

@mohph197 mohph197 commented Nov 1, 2026

Copy link
Copy Markdown
Owner

What changed

  • New option, "How to reach Claude": Anthropic API, with an API key (default, unchanged) or Claude Code on this computer.

  • Claude Code backend. background/claude-code.js sends each request through chrome.runtime.connectNative to a new native messaging helper, native-host/paper-qa-host.mjs. The helper runs the user's own claude -p --output-format stream-json in an empty temporary folder with:

    • the existing system prompt (--system-prompt) and JSON schema (--json-schema), plus --model and --effort from the options page;
    • no tools except WebSearch/WebFetch when the web is allowed, no MCP servers and no saved session;
    • the paper and questions on stdin.

    Replies go through the same validators as API replies. Web sources are kept only if a search returned them or a fetch opened them, and a malformed reply is retried once.

  • Implement tab. With the Claude Code backend on, the button reads Write prompt & start Claude Code. Once the prompt is written, the helper creates <folder>/<system-name>/ with IMPLEMENTATION_PROMPT.md and paper.pdf and opens a terminal there, running Claude Code and asking it to carry out the prompt. The terminal is Terminal on macOS, the first one found on Linux, or the program in PAPER_QA_TERMINAL. Start in Claude Code starts it again in a new folder. The project folder is set on the options page (default ~/paper-qa-projects).

  • Setup. native-host/install.sh <extension-id> (the options page shows the exact command) copies the helper to ~/.paper-qa/, records where node and claude are, and registers the helper for Chrome, plus Chromium, Brave and Edge if they're installed. Supports macOS and Linux, and --uninstall. The options page's Check Claude Code button confirms the setup works.

  • Viewer. No API-key prompt or $ estimate in Claude Code mode. Setup and login errors show Open settings.

Why

This lets people use their Claude Code login and plan instead of an API key, and hands the implementation prompt straight to Claude Code instead of making the user copy it.

Permissions

Adds nativeMessaging. The justification is in store/LISTING.md, and PRIVACY.md now describes the Claude Code backend: data passes to the user's local Claude Code, and the project folder gets the prompt and a copy of the PDF. The helper itself isn't in the store package; users install it from the repository.

How it was tested

  • npm run check ✓
  • npm run test:native-host (new, also in CI) ✓: speaks the native messaging protocol to the helper, with tests/fake-claude.mjs standing in for Claude Code and a fake terminal. Covers the claude -p arguments and stdin, web tool sources, the login error, a missing claude, and project launches, including folder de-duplication.
  • npm run test:e2e ✓ (21/21): a new step registers the real helper in the headless test profile's NativeMessagingHosts with the fake claude. It switches the backend on the options page, checks Check Claude Code, answers a question, starts Claude Code from a cached prompt, then writes a prompt again with web search, which starts Claude Code on its own. It also asserts the Claude API isn't called.
  • Not tested against a real claude binary (it isn't installed on the dev machine). The flags follow the current Claude Code CLI reference.
  • Regenerated store/screenshot-4-options.png, which shows the new setting.

🤖 Generated with Claude Code

…plement tab

Adds a "How to reach Claude" option. With "Claude Code on this computer",
the service worker sends requests through native messaging to a small
helper (native-host/) that runs the user's own `claude -p` with the same
system prompts, JSON schemas, model and effort. The Implement tab then
creates a project folder with the prompt and the paper and starts Claude
Code on it in a terminal window.

Adds the nativeMessaging permission, documented in store/LISTING.md and
PRIVACY.md. Tests use a fake claude: a native helper test and an
end-to-end step through the real helper registered in the test profile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mohph197
mohph197 merged commit b2dc292 into main Nov 1, 2026
2 checks passed
@mohph197
mohph197 deleted the feat/claude-code-backend branch November 1, 2026 06:29
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