open-code-review/extensions/vscode
Mountain Ghost. W 74a2ac1c1c
Some checks are pending
CI / test (push) Waiting to run
Deploy Pages / build (push) Waiting to run
Deploy Pages / deploy (push) Blocked by required conditions
feat(llm): add z-ai-coding provider for GLM Coding Plan endpoint (#258)
* feat(llm): add z-ai-coding provider for GLM Coding Plan endpoint

Z.AI (智谱) subscribers to the GLM Coding Plan must route requests through
the dedicated coding endpoint (https://open.bigmodel.cn/api/coding/paas/v4)
for them to be billed against the subscription quota. The existing z-ai
provider points at the generic pay-as-you-go endpoint
(https://open.bigmodel.cn/api/paas/v4), so Coding Plan keys silently drain
the wallet balance instead of consuming the plan quota, surfacing as a
spurious "1113 余额不足" error even when the plan is barely used.

Add a dedicated z-ai-coding provider following the existing *-tokenplan
pattern (dashscope/dashscope-tokenplan, tencent-tokenhub/hy-tokenplan).
It reuses Z_AI_API_KEY — the same key authenticates against both endpoints,
so selecting this provider is all that's needed to activate the plan. The
model list is restricted to the models officially supported by the Coding
Plan to avoid selecting a non-plan model that falls back to wallet billing.

- internal/llm/providers.go: register z-ai-coding preset
- extensions/vscode/src/shared/providers.ts: mirror the preset (kept in
  sync with the Go registry per the file header)
- internal/llm/providers_test.go: update the sorted provider list assertion

Co-Authored-By: Oz <oz-agent@warp.dev>

* docs(pages): add Z.AI GLM Coding Plan config tip to docs page

Subscribers to the Z.AI (Zhipu) GLM Coding Plan must route requests through
the dedicated coding endpoint (https://open.bigmodel.cn/api/coding/paas/v4)
to bill against the plan quota. The default z-ai preset points at the generic
pay-as-you-go endpoint, so coding-plan keys silently drain the wallet and
surface a spurious "1113 余额不足" error — a recurring trap for new users.

Add a provider-specific callout at the end of the Docs config section showing
the one-line fix that works today on any released version:

  ocr config set providers.z-ai.url https://open.bigmodel.cn/api/coding/paas/v4

This complements the z-ai-coding provider added in the previous commit: the
provider gives a native first-class option going forward, while this doc tip
rescues users already running released builds. Copy/localized for zh/en/ja.

Co-Authored-By: Oz <oz-agent@warp.dev>

* fix(llm): address review feedback for z-ai-coding provider

- Switch z-ai-coding to a dedicated Z_AI_CODING_API_KEY env var instead
  of reusing Z_AI_API_KEY, matching the tokenplan-provider convention so
  pay-as-you-go and Coding Plan keys can be configured independently
- Remove comment blocks from the z-ai-coding presets (Go and TS) to keep
  the registry as plain data consistent with the other entries
- Revert pages/ changes (i18n + DocsPage.tsx); provider docs are out of
  scope for a provider-registration PR

Co-Authored-By: Oz <oz-agent@warp.dev>

---------

Co-authored-by: mountainwu <mountainwu@kuainiugroup.com>
Co-authored-by: Oz <oz-agent@warp.dev>
2026-07-02 19:23:17 +08:00
..
.vscode feat(vscode): add VSCode extension for AI code review with security fixes 2026-06-23 14:33:31 +08:00
__mocks__ Feature/vscode i18n (#219) 2026-06-25 22:30:52 +08:00
resources feat(vscode): add VSCode extension for AI code review with security fixes 2026-06-23 14:33:31 +08:00
src feat(llm): add z-ai-coding provider for GLM Coding Plan endpoint (#258) 2026-07-02 19:23:17 +08:00
.eslintrc.json feat(vscode): add VSCode extension for AI code review with security fixes 2026-06-23 14:33:31 +08:00
.gitignore feat(vscode): add VSCode extension for AI code review with security fixes 2026-06-23 14:33:31 +08:00
.vscodeignore feat(vscode): add VSCode extension for AI code review with security fixes 2026-06-23 14:33:31 +08:00
jest.config.js feat(vscode): add VSCode extension for AI code review with security fixes 2026-06-23 14:33:31 +08:00
open-code-review-vscode-0.1.0.vsix Feature/vscode i18n (#219) 2026-06-25 22:30:52 +08:00
package.json Feature/vscode i18n (#219) 2026-06-25 22:30:52 +08:00
package.nls.json Feature/vscode i18n (#219) 2026-06-25 22:30:52 +08:00
package.nls.zh-cn.json Feature/vscode i18n (#219) 2026-06-25 22:30:52 +08:00
prototype.html feat(vscode): add VSCode extension for AI code review with security fixes 2026-06-23 14:33:31 +08:00
README.md feat(vscode): add VSCode extension for AI code review with security fixes 2026-06-23 14:33:31 +08:00
README.zh-CN.md feat(vscode): add VSCode extension for AI code review with security fixes 2026-06-23 14:33:31 +08:00
tsconfig.extension.json feat(vscode): add VSCode extension for AI code review with security fixes 2026-06-23 14:33:31 +08:00
tsconfig.json feat(vscode): add VSCode extension for AI code review with security fixes 2026-06-23 14:33:31 +08:00
tsconfig.webview.json feat(vscode): add VSCode extension for AI code review with security fixes 2026-06-23 14:33:31 +08:00
webpack.config.js feat(vscode): add full-width BYOK provider config panel (#204) 2026-06-25 10:37:25 +08:00
yarn.lock fix(vscode): upgrade minimatch to >=9.0.7 for CVE-2026-27903 (#220) 2026-06-25 21:04:48 +08:00

English | 简体中文

Open Code Review (VS Code Extension)

A VS Code code-review extension built on the open-code-review (ocr) CLI. It recreates the prototype experience with a Preact WebView and brings AI code review into the editor: start reviews from the sidebar, stream logs live, and apply / dismiss / flag-as-false-positive each comment inline — kept in sync with the sidebar both ways.


Features

  • Three review modes: workspace changes, branch comparison (--from / --to), and a single commit (--commit).
  • Files-to-review preview: lists changed files from the current Git state; click a file to view its changes in the native diff view.
  • Custom review prompt: optionally append a --background hint for the current review.
  • Streaming logs: tail the CLI output live during review, cancel anytime.
  • Results + two-way sync: on completion, comment cards appear in the sidebar while CommentThreads render in the editor; apply / dismiss / false-positive actions stay in sync on both sides.
  • Empty / cancelled / failed states: dedicated views for no issues, user cancellation, and CLI failure (failures are retryable and surface the real error returned by the CLI).
  • Configuration management: view / edit the LLM provider config inside the extension (persisted via ocr config set).
  • Model switching / connectivity test: switch models and test connectivity to the LLM from the status bar.

Prerequisites

  1. Install the ocr CLI globally:

    npm i -g @alibaba-group/open-code-review
    
  2. Configure a working LLM (endpoint, API key, model). Configure it via the CLI directly, or in the extension's config view:

    ocr config set llm.url https://api.anthropic.com/v1/messages
    ocr config set llm.auth_token sk-...
    ocr config set llm.model claude-opus-4-6
    ocr config set llm.use_anthropic true
    

    The config is written to ~/.opencodereview/config.json.


Development

Environment

  • Node.js ≥ 18, with Yarn as the package manager (the repo ships a yarn.lock).
  • VS Code ≥ 1.74.
  • A globally available ocr CLI (see "Prerequisites" above) — the extension is essentially a GUI front-end for ocr.

Start the dev environment

cd extensions/vscode
yarn install      # install dependencies
yarn watch        # watch-mode dev build (recommended: rebuilds out/ on change)

Then open the extensions/vscode folder in VS Code and press F5 to launch the Extension Development Host (debug config is provided in .vscode/launch.json). In the new window, open a project with Git changes — you'll see the Open Code Review icon in the activity bar and can start a review.

After editing code: WebView changes require reopening the sidebar in the dev host window (or running Developer: Reload Webviews); Extension Host changes require restarting the debug session (the ⟳ button on the debug toolbar, or Cmd+R in the host window).

Scripts

yarn compile      # one-off dev build (webpack development)
yarn watch        # watch-mode dev build
yarn build        # production build (webpack production; runs automatically before packaging)
yarn test         # run Jest unit tests
yarn lint         # ESLint
yarn package      # produce a distributable .vsix package (see "Build a release package")

Debugging notes

  • Two-way messaging: the WebView and Extension Host communicate via postMessage; message types live in src/shared/messages.ts. Both sides route through dispatch / handle — start there when debugging.
  • CLI invocation: all ocr sub-commands run via child_process.spawn in src/extension/services/CliService.ts. runRaw rejects on a non-zero CLI exit code and includes the Error: text from stderr, which helps diagnose "review failed / connection failed".
  • Config read/write: ConfigService reads ~/.opencodereview/config.json and delegates writes to ocr config set. WebView fields are camelCase (e.g. useAnthropic) while the disk/CLI side is snake_case (e.g. use_anthropic); the conversion lives in src/extension/services/configParse.ts.

Build

Compile artifacts only

yarn build        # production build (webpack production)

Artifacts: out/extension.js (Extension Host) + out/webview.js (WebView SPA).

Build a release package (.vsix)

yarn package      # = vsce package --no-yarn

This command:

  1. Triggers vscode:prepublish → runs the yarn build production build;
  2. Excludes source, tests, and dev files per .vscodeignore;
  3. Produces open-code-review-vscode-<version>.vsix in the current directory.

The packaging tool is @vscode/vsce, installed as a devDependency — no global install or network download needed. --no-yarn skips vsce's default npm dependency-tree check (this project uses Yarn).

The release package contains only the runtime essentials: package.json, README.md, resources/icon.svg, out/extension.js, out/webview.js.

Install / verify locally

code --install-extension open-code-review-vscode-<version>.vsix

Or in VS Code: Extensions panel → top-right Install from VSIX… → pick the generated .vsix file.

To publish to the Marketplace, use vsce publish instead (requires a publisher account and PAT); for everyday distribution the .vsix above is enough.


Architecture

It uses a Monolithic WebView + Thin Extension Host design:

  • The WebView is a separately built Preact SPA that reproduces the full visual and interactive prototype.
  • The Extension Host layer is thin, handling only CLI invocation, the file system, Git operations, and editor comments.
  • The two communicate via postMessage, with shared TypeScript types in src/shared/ for type safety.
src/
├── extension/      Extension Host (Node.js): services / providers / commands
├── webview/        WebView SPA (Preact): views / components / store / bridge
└── shared/         shared types and the postMessage protocol (no vscode dependency)

License

Apache-2.0