mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-07 02:58:15 +00:00
Add config getters to RooCodeAPI (#2048)
This commit is contained in:
parent
7eb469f636
commit
3d0fc3ccc5
6 changed files with 69 additions and 14 deletions
5
.changeset/two-months-drop.md
Normal file
5
.changeset/two-months-drop.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"roo-cline": patch
|
||||
---
|
||||
|
||||
Add config getters to RooCodeAPI
|
||||
|
|
@ -12,7 +12,6 @@ import * as vscode from "vscode"
|
|||
import {
|
||||
CheckpointStorage,
|
||||
GlobalState,
|
||||
SecretState,
|
||||
Language,
|
||||
ProviderSettings,
|
||||
RooCodeSettings,
|
||||
|
|
@ -2802,27 +2801,29 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|||
return history
|
||||
}
|
||||
|
||||
// global
|
||||
// ContextProxy
|
||||
|
||||
public async updateGlobalState<K extends keyof GlobalState>(key: K, value: GlobalState[K]) {
|
||||
// @deprecated - Use `ContextProxy#setValue` instead.
|
||||
private async updateGlobalState<K extends keyof GlobalState>(key: K, value: GlobalState[K]) {
|
||||
await this.contextProxy.setValue(key, value)
|
||||
}
|
||||
|
||||
public getGlobalState<K extends keyof GlobalState>(key: K) {
|
||||
// @deprecated - Use `ContextProxy#getValue` instead.
|
||||
private getGlobalState<K extends keyof GlobalState>(key: K) {
|
||||
return this.contextProxy.getValue(key)
|
||||
}
|
||||
|
||||
// secrets
|
||||
|
||||
public async storeSecret(key: keyof SecretState, value?: string) {
|
||||
public async setValue<K extends keyof RooCodeSettings>(key: K, value: RooCodeSettings[K]) {
|
||||
await this.contextProxy.setValue(key, value)
|
||||
}
|
||||
|
||||
private getSecret(key: keyof SecretState) {
|
||||
public getValue<K extends keyof RooCodeSettings>(key: K) {
|
||||
return this.contextProxy.getValue(key)
|
||||
}
|
||||
|
||||
// global + secret
|
||||
public getValues() {
|
||||
return this.contextProxy.getValues()
|
||||
}
|
||||
|
||||
public async setValues(values: RooCodeSettings) {
|
||||
await this.contextProxy.setValues(values)
|
||||
|
|
|
|||
|
|
@ -630,7 +630,7 @@ describe("ClineProvider", () => {
|
|||
setModeConfig: jest.fn(),
|
||||
} as any
|
||||
|
||||
provider.updateGlobalState("currentApiConfigName", "current-config")
|
||||
provider.setValue("currentApiConfigName", "current-config")
|
||||
|
||||
// Switch to architect mode
|
||||
await messageHandler({ type: "mode", text: "architect" })
|
||||
|
|
@ -759,7 +759,7 @@ describe("ClineProvider", () => {
|
|||
},
|
||||
}
|
||||
|
||||
provider.updateGlobalState("customModePrompts", existingPrompts)
|
||||
provider.setValue("customModePrompts", existingPrompts)
|
||||
|
||||
// Test updating a prompt
|
||||
await messageHandler({
|
||||
|
|
@ -2159,19 +2159,19 @@ describe.skip("ContextProxy integration", () => {
|
|||
})
|
||||
|
||||
test("updateGlobalState uses contextProxy", async () => {
|
||||
await provider.updateGlobalState("currentApiConfigName", "testValue")
|
||||
await provider.setValue("currentApiConfigName", "testValue")
|
||||
expect(mockContextProxy.updateGlobalState).toHaveBeenCalledWith("currentApiConfigName", "testValue")
|
||||
})
|
||||
|
||||
test("getGlobalState uses contextProxy", async () => {
|
||||
mockContextProxy.getGlobalState.mockResolvedValueOnce("testValue")
|
||||
const result = await provider.getGlobalState("currentApiConfigName")
|
||||
const result = await provider.getValue("currentApiConfigName")
|
||||
expect(mockContextProxy.getGlobalState).toHaveBeenCalledWith("currentApiConfigName")
|
||||
expect(result).toBe("testValue")
|
||||
})
|
||||
|
||||
test("storeSecret uses contextProxy", async () => {
|
||||
await provider.storeSecret("apiKey", "test-secret")
|
||||
await provider.setValue("apiKey", "test-secret")
|
||||
expect(mockContextProxy.storeSecret).toHaveBeenCalledWith("apiKey", "test-secret")
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -78,10 +78,22 @@ export class API extends EventEmitter<RooCodeEvents> implements RooCodeAPI {
|
|||
await this.provider.postMessageToWebview({ type: "invoke", invoke: "secondaryButtonClick" })
|
||||
}
|
||||
|
||||
public getConfiguration() {
|
||||
return this.provider.getValues()
|
||||
}
|
||||
|
||||
public getConfigurationValue<K extends keyof RooCodeSettings>(key: K) {
|
||||
return this.provider.getValue(key)
|
||||
}
|
||||
|
||||
public async setConfiguration(values: RooCodeSettings) {
|
||||
await this.provider.setValues(values)
|
||||
}
|
||||
|
||||
public async setConfigurationValue<K extends keyof RooCodeSettings>(key: K, value: RooCodeSettings[K]) {
|
||||
await this.provider.setValue(key, value)
|
||||
}
|
||||
|
||||
public isReady() {
|
||||
return this.provider.viewLaunched
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,12 +61,32 @@ export interface RooCodeAPI extends EventEmitter<RooCodeEvents> {
|
|||
*/
|
||||
pressSecondaryButton(): Promise<void>
|
||||
|
||||
/**
|
||||
* Returns the current configuration.
|
||||
* @returns The current configuration.
|
||||
*/
|
||||
getConfiguration(): RooCodeSettings
|
||||
|
||||
/**
|
||||
* Returns the value of a configuration key.
|
||||
* @param key The key of the configuration value to return.
|
||||
* @returns The value of the configuration key.
|
||||
*/
|
||||
getConfigurationValue<K extends keyof RooCodeSettings>(key: K): RooCodeSettings[K]
|
||||
|
||||
/**
|
||||
* Sets the configuration for the current task.
|
||||
* @param values An object containing key-value pairs to set.
|
||||
*/
|
||||
setConfiguration(values: RooCodeSettings): Promise<void>
|
||||
|
||||
/**
|
||||
* Sets the value of a configuration key.
|
||||
* @param key The key of the configuration value to set.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
setConfigurationValue<K extends keyof RooCodeSettings>(key: K, value: RooCodeSettings[K]): Promise<void>
|
||||
|
||||
/**
|
||||
* Returns true if the API is ready to use.
|
||||
*/
|
||||
|
|
|
|||
17
src/exports/roo-code.d.ts
vendored
17
src/exports/roo-code.d.ts
vendored
|
|
@ -452,11 +452,28 @@ interface RooCodeAPI extends EventEmitter<RooCodeEvents> {
|
|||
* Simulates pressing the secondary button in the chat interface.
|
||||
*/
|
||||
pressSecondaryButton(): Promise<void>
|
||||
/**
|
||||
* Returns the current configuration.
|
||||
* @returns The current configuration.
|
||||
*/
|
||||
getConfiguration(): RooCodeSettings
|
||||
/**
|
||||
* Returns the value of a configuration key.
|
||||
* @param key The key of the configuration value to return.
|
||||
* @returns The value of the configuration key.
|
||||
*/
|
||||
getConfigurationValue<K extends keyof RooCodeSettings>(key: K): RooCodeSettings[K]
|
||||
/**
|
||||
* Sets the configuration for the current task.
|
||||
* @param values An object containing key-value pairs to set.
|
||||
*/
|
||||
setConfiguration(values: RooCodeSettings): Promise<void>
|
||||
/**
|
||||
* Sets the value of a configuration key.
|
||||
* @param key The key of the configuration value to set.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
setConfigurationValue<K extends keyof RooCodeSettings>(key: K, value: RooCodeSettings[K]): Promise<void>
|
||||
/**
|
||||
* Returns true if the API is ready to use.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue