Files
openchamber/packages/vscode/webview/api/index.ts
T
Bohdan Triapitsyn bb72c0fb0c feat: vscode extension (#59)
* feat: add initial VS Code extension plan and implementation tasks

* feat(vscode): added initial version of an Openchamber VSCode extension

* feat(vscode): enhance VS Code extension with theme integration and session management

* feat(vscode): implement connection status handling and overlay in VSCode layout

* feat: move extension to secondary sidebar

* chore: upgrade @opencode-ai/sdk to 1.0.150

* vscode: editor bridge, file picker, click-to-open in tool parts

* vscode: layout session lifecycle, theme sync, typography overrides

* ui: compact mode for vscode, model search, autocomplete width fixes

* perf: scroll force flag, raf placeholder, git polling backoff

* ui: tool output styling, markdown code block fix, gitignore

* refactor: update typography handling for VSCode runtime, remove unused styles

* docs: update README with VS Code extension details and add extension image

* docs: update changelog with new features and performance improvements
2025-12-13 16:34:17 +02:00

64 lines
3.0 KiB
TypeScript

import type { RuntimeAPIs, TerminalAPI, GitAPI, NotificationsAPI } from '@openchamber/ui/lib/api/types';
import { createVSCodeFilesAPI } from './files';
import { createVSCodeSettingsAPI } from './settings';
import { createVSCodePermissionsAPI } from './permissions';
import { createVSCodeToolsAPI } from './tools';
import { createVSCodeEditorAPI } from './editor';
// Stub APIs return sensible defaults instead of throwing
const createStubTerminalAPI = (): TerminalAPI => ({
createSession: async () => ({ sessionId: '', cols: 80, rows: 24 }),
connect: () => ({ close: () => {} }),
sendInput: async () => {},
resize: async () => {},
close: async () => {},
});
const createStubGitAPI = (): GitAPI => ({
checkIsGitRepository: async () => false,
getGitStatus: async () => ({ current: '', tracking: null, ahead: 0, behind: 0, files: [], isClean: true }),
getGitDiff: async () => ({ diff: '' }),
getGitFileDiff: async () => ({ original: '', modified: '', path: '' }),
revertGitFile: async () => {},
isLinkedWorktree: async () => false,
getGitBranches: async () => ({ all: [], current: '', branches: {} }),
deleteGitBranch: async () => ({ success: false }),
deleteRemoteBranch: async () => ({ success: false }),
generateCommitMessage: async () => ({ message: { subject: '', highlights: [] } }),
listGitWorktrees: async () => [],
addGitWorktree: async () => ({ success: false, path: '', branch: '' }),
removeGitWorktree: async () => ({ success: false }),
ensureOpenChamberIgnored: async () => {},
createGitCommit: async () => ({ success: false, commit: '', branch: '', summary: { changes: 0, insertions: 0, deletions: 0 } }),
gitPush: async () => ({ success: false, pushed: [], repo: '', ref: null }),
gitPull: async () => ({ success: false, summary: { changes: 0, insertions: 0, deletions: 0 }, files: [], insertions: 0, deletions: 0 }),
gitFetch: async () => ({ success: false }),
checkoutBranch: async () => ({ success: false, branch: '' }),
createBranch: async () => ({ success: false, branch: '' }),
getGitLog: async () => ({ all: [], latest: null, total: 0 }),
getCommitFiles: async () => ({ files: [] }),
getCurrentGitIdentity: async () => null,
setGitIdentity: async () => ({ success: false, profile: { id: '', name: '', userName: '', userEmail: '' } }),
getGitIdentities: async () => [],
createGitIdentity: async (p) => p,
updateGitIdentity: async (_, p) => p,
deleteGitIdentity: async () => {},
});
const createStubNotificationsAPI = (): NotificationsAPI => ({
notifyAgentCompletion: async () => true,
canNotify: () => true,
});
export const createVSCodeAPIs = (): RuntimeAPIs => ({
runtime: { platform: 'vscode', isDesktop: false, isVSCode: true, label: 'VS Code Extension' },
terminal: createStubTerminalAPI(),
git: createStubGitAPI(),
files: createVSCodeFilesAPI(),
settings: createVSCodeSettingsAPI(),
permissions: createVSCodePermissionsAPI(),
notifications: createStubNotificationsAPI(),
tools: createVSCodeToolsAPI(),
editor: createVSCodeEditorAPI(),
});