Skip to content
This repository was archived by the owner on Nov 14, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build VS Code Extension

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v3

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha): An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.

Source: opengrep

with:
version: 9

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build Webview assets
run: pnpm run build:webview

- name: Compile extension
run: pnpm run compile

- name: Package VSIX
run: pnpm run vsix

- name: Upload VSIX artifact
uses: actions/upload-artifact@v4
with:
name: claudex-extension
path: "*.vsix"
if-no-files-found: error
2 changes: 1 addition & 1 deletion esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const copyClaudeCliPlugin = {
const require = createRequire(import.meta.url);
build.onEnd(async () => {
try {
const pkgDir = path.dirname(require.resolve('@anthropic-ai/claude-code/cli.js'));
const pkgDir = path.dirname(require.resolve('@anthropic-ai/claude-agent-sdk/cli.js'));
const outDir = path.resolve(process.cwd(), 'dist');
await fs.mkdir(outDir, { recursive: true });

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
"vue-tsc": "^3.0.8"
},
"dependencies": {
"@anthropic-ai/claude-code": "^1.0.123",
"@anthropic-ai/claude-agent-sdk": "^0.1.9",
"@anthropic-ai/sdk": "^0.63.1",
"@mdi/font": "^7.4.47",
"@modelcontextprotocol/sdk": "^1.18.1",
Expand Down
38 changes: 6 additions & 32 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 29 additions & 14 deletions src/services/claude/claude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import type { Options, PermissionResult, Query, SDKMessage, SDKUserMessage, CanUseTool } from '@anthropic-ai/claude-code';
import type { Options, PermissionResult, Query, SDKMessage, SDKUserMessage, CanUseTool } from '@anthropic-ai/claude-agent-sdk';
import Anthropic from '@anthropic-ai/sdk';
import { DeferredPromise } from '../common/deferred';
import { Disposable } from '../common/lifecycle';
Expand Down Expand Up @@ -88,28 +88,43 @@ class ClaudeCodeSession {
try {
// Build options for the Claude Code SDK
const isDebugEnabled = this.configService.getConfig(ConfigKey.Internal.ClaudeCodeDebugEnabled);
const options: Options = {
cwd: this.workspaceService.getWorkspaceFolders().at(0)?.fsPath,
abortController,
executable: 'node',
pathToClaudeCodeExecutable: this.envService.claudeCliPath,
env: {
const options: Options = {
cwd: this.workspaceService.getWorkspaceFolders().at(0)?.fsPath,
abortController,
executable: 'node',
pathToClaudeCodeExecutable: this.envService.claudeCliPath,
env: {
...process.env,
...(isDebugEnabled ? { DEBUG: '1' } : {}),
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: '1',
},
resume: this.sessionId,
model: 'claude-sonnet-4-20250514',
permissionMode: 'default',
includePartialMessages: true,
canUseTool: async (name, input, opts): Promise<PermissionResult> => {
return this.canUseTool(name, input, bus, opts as any);
},
...optionsOverride,
};
includePartialMessages: true,
canUseTool: async (name, input, opts): Promise<PermissionResult> => {
return this.canUseTool(name, input, bus, opts as any);
},
...optionsOverride,
};

if (!optionsOverride?.systemPrompt) {
const customSystemPrompt = this.configService.getConfig<string>('claudex.customSystemPrompt')?.trim();
const appendSystemPrompt = this.configService.getConfig<string>('claudex.appendSystemPrompt')?.trim();

if (customSystemPrompt) {
options.systemPrompt = customSystemPrompt;
} else {
options.systemPrompt = {
type: 'preset',
preset: 'claude_code',
...(appendSystemPrompt ? { append: appendSystemPrompt } : {})
} as const;
}
}

this.logService.trace(`Claude CLI SDK: Starting query with options: ${JSON.stringify({ ...options, env: undefined })}`);
const { query } = await import('@anthropic-ai/claude-code');
const { query } = await import('@anthropic-ai/claude-agent-sdk');
const def = new DeferredPromise<void>();

async function* createPromptIterable(promptText: string, sessionId?: string): AsyncIterable<SDKUserMessage> {
Expand Down
2 changes: 1 addition & 1 deletion src/services/claude/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { IClaudeCodeSessionService } from './session';
import { ClaudeAgentManager } from './claude';
import { UiMessageBus } from './uiMessageBus';
import { UiEvent, ClaudeRequest } from './types';
import { SDKMessage } from '@anthropic-ai/claude-code';
import { SDKMessage } from '@anthropic-ai/claude-agent-sdk';
import { ILogService } from '../log/logService';
import type { CancellationToken } from '../common/types';

Expand Down
2 changes: 1 addition & 1 deletion src/services/claude/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { SDKMessage, SDKUserMessage, SDKUserMessageReplay } from '@anthropic-ai/claude-code';
import { SDKMessage, SDKUserMessage, SDKUserMessageReplay } from '@anthropic-ai/claude-agent-sdk';
import Anthropic from '@anthropic-ai/sdk';
// import type { CancellationToken } from 'vscode';
import { ResourceMap, ResourceSet } from '../common/map';
Expand Down
2 changes: 1 addition & 1 deletion src/services/claude/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
SDKSystemMessage,
SDKUserMessage,
SDKUserMessageReplay,
} from '@anthropic-ai/claude-code';
} from '@anthropic-ai/claude-agent-sdk';

// 供 UI 使用的消息事件总线类型(仅数据透传与轻量增强)

Expand Down
2 changes: 1 addition & 1 deletion src/types/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// 全局类型声明

// 修复 @anthropic-ai/claude-code SDK 中缺失的 Dict 类型
// 修复 @anthropic-ai/claude-agent-sdk SDK 中缺失的 Dict 类型
declare global {
type Dict<T = any> = Record<string, T>;
}
Expand Down
Loading