Skip to content

Commit 0abd13e

Browse files
authored
Better environments for the vibes (RooCodeInc#4077)
* Get root of the cline storage directory from an env var. Set the cline directory env var when running the standalone app from the vscode launcher. Add missing vscode SDK stub. * Stop spamming the logs.
1 parent 7e37cec commit 0abd13e

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

.vscode/launch.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
"env": {
5353
"GRPC_TRACE": "all",
5454
"GRPC_VERBOSITY": "DEBUG",
55-
"NODE_PATH": "${workspaceFolder}/dist-standalone/node_modules"
55+
"NODE_PATH": "${workspaceFolder}/dist-standalone/node_modules",
56+
"CLINE_DIR": "${userHome}/.cline-standalone"
5657
},
5758
"program": "standalone.js"
5859
}

src/core/controller/models/refreshOpenRouterModels.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { GlobalFileNames } from "@core/storage/disk"
1515
*/
1616
export async function refreshOpenRouterModels(
1717
controller: Controller,
18-
request: EmptyRequest,
18+
_request: EmptyRequest,
1919
): Promise<OpenRouterCompatibleModelInfo> {
2020
const openRouterModelsFilePath = path.join(await ensureCacheDirectoryExists(controller), GlobalFileNames.openRouterModels)
2121

@@ -123,7 +123,7 @@ export async function refreshOpenRouterModels(
123123
console.error("Invalid response from OpenRouter API")
124124
}
125125
await fs.writeFile(openRouterModelsFilePath, JSON.stringify(models))
126-
console.log("OpenRouter models fetched and saved", models)
126+
console.log("OpenRouter models fetched and saved", JSON.stringify(models).slice(0, 300))
127127
} catch (error) {
128128
console.error("Error fetching OpenRouter models:", error)
129129

src/standalone/vscode-context-stubs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const outputChannel: vscode.OutputChannel = {
1515
}
1616

1717
function postMessage(message: ExtensionMessage): Promise<boolean> {
18-
log("postMessage stub called:", message)
18+
log("postMessage stub called:", JSON.stringify(message).slice(0, 200))
1919
return Promise.resolve(true)
2020
}
2121

src/standalone/vscode-context.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
import { URI } from "vscode-uri"
22

33
import path from "path"
4+
import { mkdirSync } from "fs"
45
import type { Extension, ExtensionContext } from "vscode"
56
import { ExtensionKind, ExtensionMode } from "vscode"
67
import { outputChannel, postMessage } from "./vscode-context-stubs"
78
import { EnvironmentVariableCollection, MementoStore, readJson, SecretStore } from "./vscode-context-utils"
9+
import { log } from "./utils"
810

9-
const DATA_DIR = process.env.DATA_DIR ?? "."
10-
const EXTENSION_DIR = process.env.EXTENSION_DIR ?? "."
11+
if (!process.env.CLINE_DIR) {
12+
console.warn("Environment variable CLINE_DIR was not set.")
13+
process.exit(1)
14+
}
15+
const DATA_DIR = path.join(process.env.CLINE_DIR, "data")
16+
mkdirSync(DATA_DIR, { recursive: true })
17+
log("Using settings dir:", DATA_DIR)
18+
19+
const EXTENSION_DIR = path.join(process.env.CLINE_DIR, "core")
1120
const EXTENSION_MODE = process.env.IS_DEV === "true" ? ExtensionMode.Development : ExtensionMode.Production
1221

1322
const extension: Extension<void> = {

standalone/runtime-files/vscode/vscode-impls.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ vscode.window = {
5353
tabGroups: {
5454
all: [],
5555
close: async () => {},
56+
onDidChangeTabs: createStub("vscode.env.tabGroups.onDidChangeTabs"),
5657
},
5758
withProgress: async (_options, task) => {
5859
console.log("Stubbed withProgress")

0 commit comments

Comments
 (0)