Skip to content

Latest commit

 

History

History
193 lines (135 loc) · 5.95 KB

local-setup-with-vs-code.md

File metadata and controls

193 lines (135 loc) · 5.95 KB

Local Setup with Visual Studio Code

The shape of the setup is:

  1. Run apfel --serve as a local OpenAI-compatible server.
  2. Use the Continue extension in Visual Studio Code.
  3. Route chat/code review to local apfel.
  4. Route edit/apply to a second model.
  5. Keep ~/.continue/.env in sync from the shell so Continue can read OPENAI_API_KEY.

For the underlying API contract, see openai-api-compatibility.md and server-security.md.

1. Start apfel as the local server

Use apfel as the local OpenAI-compatible base URL:

http://127.0.0.1:11434/v1

Start it in the foreground:

apfel --serve

Or run it in the background:

brew services start apfel

Background-service details: background-service.md

Important: this setup uses Chat Completions (POST /v1/chat/completions), which is what Continue's openai provider speaks. apfel also implements the newer Responses API (POST /v1/responses), but Continue does not use it here.

2. Install the Continue extension in Visual Studio Code

Use Continue as the Visual Studio Code front end.

Continue reads configuration from:

  • ~/.continue/config.yaml
  • ~/.continue/.env

3. Configure Continue with two models

Use local apfel for safer chat/review work and a second model for edit/apply.

Create or replace ~/.continue/config.yaml with:

name: Apfel Review + OpenAI Apply
version: 0.0.1
schema: v1

models:
  - name: apfel-review
    provider: openai
    model: apple-foundationmodel
    apiBase: http://127.0.0.1:11434/v1
    apiKey: ignored
    roles:
      - chat
    contextLength: 4096
    defaultCompletionOptions:
      temperature: 0.0
      maxTokens: 256
    requestOptions:
      extraBodyProperties:
        x_context_output_reserve: 256
    chatOptions:
      baseSystemMessage: |
        You are a code review assistant.
        Prioritize bugs, regressions, edge cases, security risks, and missing tests.
        Give findings first and be concrete.

  - name: gpt-5.1-apply
    provider: openai
    model: gpt-5.1
    apiKey: ${{ secrets.OPENAI_API_KEY }}
    roles:
      - edit
      - apply
    defaultCompletionOptions:
      temperature: 0.0
      maxTokens: 1200

context:
  - provider: diff
  - provider: file

Why this split works:

  • apfel-review is restricted to chat, so it becomes the local review lane.
  • gpt-5.1-apply handles edit and apply, where a stronger hosted model is more useful.
  • temperature: 0.0 keeps both lanes deterministic.
  • contextLength: 4096 is the window on macOS 26 and on M1/M2 Macs. On macOS 27 with an M3 or newer chip and 12 GB+ the on-device window is 8192, so set contextLength: 8192 there - apfel --model-info prints the live value for your machine. The window covers input and output combined.

4. Provide OPENAI_API_KEY to Continue

Continue reads secrets from ~/.continue/.env.

The direct manual version is:

OPENAI_API_KEY=your_openai_api_key_here

But in our setup, we also wired this into the shell so Continue's .env file is updated automatically from the existing Codex login helpers in ~/.zshrc. (See: Leveraging multiple, repository-specific OpenAI Codex API Keys with Visual Studio Code on macOS.)

5. Sync ~/.continue/.env automatically from ~/.zshrc

Inside the # --- OpenAI Codex: Start / # --- OpenAI Codex: End block in ~/.zshrc, we added helpers so that:

  • cli logs Codex in and writes OPENAI_API_KEY=... to ~/.continue/.env
  • clo logs Codex out and removes only the OPENAI_API_KEY line from ~/.continue/.env

This keeps the Continue secret in step with your Codex/OpenAI shell workflow without manual edits. Your typical flow becomes:

source ~/.zshrc
cli

When you are done with the Visual Studio Code session:

clo

6. Restart Visual Studio Code after auth changes

After changing auth state, reload Visual Studio Code's extension host so Continue picks up the current environment and config.

Use:

Cmd + Shift + P -> Developer: Restart Extension Host

7. Recommended day-to-day usage

Use local apfel for:

  • review the current diff
  • review the selected function
  • summarize a file before editing
  • identify likely regressions
  • point out missing tests

Use the hosted edit/apply model for:

  • targeted code changes
  • apply/fix flows
  • rewriting a selected block
  • generating a patch after review findings are clear

This is the important habit: keep apfel focused on small review contexts. It works best on a diff, one file, or one selected region, not giant repo-wide prompts.

8. Typical workflow

  1. Start apfel with apfel --serve or brew services start apfel.
  2. Open Visual Studio Code.
  3. Run cli in your shell to authenticate Codex and update ~/.continue/.env.
  4. Restart the Visual Studio Code extension host.
  5. Ask Continue chat to review the current diff or selected code using the local apfel-review model.
  6. Once the review is clear, use Edit/Apply to hand the actual code change to the hosted gpt-5.1-apply model.
  7. Run clo when you are done to clear the shell key and remove OPENAI_API_KEY from ~/.continue/.env.

9. Troubleshooting

If Continue cannot talk to local apfel:

  • make sure apfel --serve is running
  • confirm the base URL is http://127.0.0.1:11434/v1
  • confirm the model name is apple-foundationmodel
  • make sure the client is pointed at Chat Completions (/v1/chat/completions)

If Continue cannot use the hosted edit/apply model:

  • check that ~/.continue/.env contains OPENAI_API_KEY=...
  • run cli again after reloading ~/.zshrc
  • restart the Visual Studio Code extension host

If you need a browser client instead of Continue:

  • use apfel --serve --cors --allowed-origins "<your local origin>"

For security and browser details, see server-security.md.

Kudos to @dan-snelson.