Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 32d34c2

Browse files
committed
feat: add pnpm serve command for code-server development
This adds a new `pnpm serve` command that: - Builds the extension as a vsix to a temp directory - Installs it into code-server - Configures user settings (disable welcome tab, workspace trust, etc.) - Launches code-server at http://127.0.0.1:8080 Prerequisites: brew install code-server Usage: pnpm serve
1 parent b472c15 commit 32d34c2

2 files changed

Lines changed: 177 additions & 0 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"clean": "turbo clean --log-order grouped --output-logs new-only && rimraf dist out bin .vite-port .turbo",
2222
"install:vsix": "pnpm install --frozen-lockfile && pnpm clean && pnpm vsix && node scripts/install-vsix.js",
2323
"install:vsix:nightly": "pnpm install --frozen-lockfile && pnpm clean && pnpm vsix:nightly && node scripts/install-vsix.js --nightly",
24+
"serve": "node scripts/serve.js",
2425
"changeset:version": "cp CHANGELOG.md src/CHANGELOG.md && changeset version && cp -vf src/CHANGELOG.md .",
2526
"knip": "knip --include files",
2627
"evals": "dotenvx run -f packages/evals/.env.development packages/evals/.env.local -- docker compose -f packages/evals/docker-compose.yml --profile server --profile runner up --build --scale runner=0",

scripts/serve.js

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
/**
2+
* Serve script for Roo Code extension development
3+
*
4+
* This script builds the extension as a vsix, installs it into code-server,
5+
* and launches code-server for web-based VS Code testing.
6+
*
7+
* Prerequisites:
8+
* brew install code-server
9+
*
10+
* Usage:
11+
* pnpm serve
12+
*
13+
* The script will:
14+
* 1. Check if code-server is installed
15+
* 2. Build the vsix (pnpm vsix)
16+
* 3. Install the vsix into code-server
17+
* 4. Configure user settings (disable welcome tab)
18+
* 5. Start code-server on http://127.0.0.1:8080
19+
*
20+
* Your password is stored in ~/.config/code-server/config.yaml
21+
*/
22+
23+
const { execSync, spawn } = require("child_process")
24+
const fs = require("fs")
25+
const path = require("path")
26+
const os = require("os")
27+
28+
const RESET = "\x1b[0m"
29+
const BOLD = "\x1b[1m"
30+
const GREEN = "\x1b[32m"
31+
const YELLOW = "\x1b[33m"
32+
const CYAN = "\x1b[36m"
33+
const RED = "\x1b[31m"
34+
35+
// Build vsix to a fixed path in temp directory
36+
const VSIX_PATH = path.join(os.tmpdir(), "roo-code-serve.vsix")
37+
38+
function log(message) {
39+
console.log(`${CYAN}[serve]${RESET} ${message}`)
40+
}
41+
42+
function logSuccess(message) {
43+
console.log(`${GREEN}${RESET} ${message}`)
44+
}
45+
46+
function logWarning(message) {
47+
console.log(`${YELLOW}${RESET} ${message}`)
48+
}
49+
50+
function logError(message) {
51+
console.error(`${RED}${RESET} ${message}`)
52+
}
53+
54+
function isCodeServerInstalled() {
55+
try {
56+
execSync("which code-server", { stdio: "pipe" })
57+
return true
58+
} catch {
59+
return false
60+
}
61+
}
62+
63+
function ensureUserSettings() {
64+
// code-server stores user data in ~/.local/share/code-server
65+
const userDataDir = path.join(process.env.HOME || process.env.USERPROFILE, ".local", "share", "code-server", "User")
66+
const settingsFile = path.join(userDataDir, "settings.json")
67+
68+
// Create directory if it doesn't exist
69+
if (!fs.existsSync(userDataDir)) {
70+
fs.mkdirSync(userDataDir, { recursive: true })
71+
}
72+
73+
// Read existing settings or start fresh
74+
let settings = {}
75+
if (fs.existsSync(settingsFile)) {
76+
try {
77+
settings = JSON.parse(fs.readFileSync(settingsFile, "utf8"))
78+
} catch {
79+
// If parsing fails, start fresh
80+
}
81+
}
82+
83+
// Set the startup editor to none (disables welcome tab)
84+
settings["workbench.startupEditor"] = "none"
85+
86+
// Hide the secondary sidebar (auxiliary bar)
87+
settings["workbench.auxiliaryBar.visible"] = false
88+
89+
// Disable extension recommendations prompts
90+
settings["extensions.ignoreRecommendations"] = true
91+
92+
fs.writeFileSync(settingsFile, JSON.stringify(settings, null, "\t"))
93+
}
94+
95+
async function main() {
96+
console.log(`\n${BOLD}🚀 Roo Code - code-server Development Server${RESET}\n`)
97+
98+
// Step 1: Check if code-server is installed
99+
log("Checking for code-server...")
100+
if (!isCodeServerInstalled()) {
101+
logError("code-server is not installed")
102+
console.log("\nTo install code-server on macOS:")
103+
console.log(` ${CYAN}brew install code-server${RESET}`)
104+
console.log("\nFor other platforms, see: https://coder.com/docs/code-server/install")
105+
process.exit(1)
106+
}
107+
logSuccess("code-server found")
108+
109+
// Step 2: Build vsix to temp directory
110+
log(`Building vsix to ${VSIX_PATH}...`)
111+
try {
112+
execSync(`pnpm vsix -- --out "${VSIX_PATH}"`, { stdio: "inherit" })
113+
logSuccess("Build complete")
114+
} catch (error) {
115+
logError("Build failed")
116+
process.exit(1)
117+
}
118+
119+
// Step 3: Install extension into code-server
120+
log("Installing extension into code-server...")
121+
try {
122+
execSync(`code-server --install-extension "${VSIX_PATH}"`, { stdio: "inherit" })
123+
logSuccess("Extension installed")
124+
} catch (error) {
125+
logWarning("Extension installation had warnings (this is usually fine)")
126+
}
127+
128+
// Step 4: Configure user settings to disable welcome tab
129+
log("Configuring user settings...")
130+
ensureUserSettings()
131+
logSuccess("User settings configured (welcome tab disabled)")
132+
133+
// Step 5: Start code-server
134+
const cwd = process.cwd()
135+
console.log(`\n${BOLD}Starting code-server...${RESET}`)
136+
console.log(` Working directory: ${cwd}`)
137+
console.log(` URL: ${CYAN}http://127.0.0.1:8080${RESET}`)
138+
console.log(` Password: ${YELLOW}~/.config/code-server/config.yaml${RESET}`)
139+
console.log(`\n Press ${BOLD}Ctrl+C${RESET} to stop\n`)
140+
141+
// Spawn code-server with:
142+
// --disable-workspace-trust: Skip workspace trust prompts
143+
// --disable-getting-started-override: Disable welcome/getting started page
144+
// -e: Ignore last opened directory (start fresh)
145+
const codeServer = spawn(
146+
"code-server",
147+
["--disable-workspace-trust", "--disable-getting-started-override", "-e", cwd],
148+
{
149+
stdio: "inherit",
150+
cwd: cwd,
151+
},
152+
)
153+
154+
codeServer.on("error", (err) => {
155+
logError(`Failed to start code-server: ${err.message}`)
156+
process.exit(1)
157+
})
158+
159+
codeServer.on("close", (code) => {
160+
if (code !== 0 && code !== null) {
161+
logError(`code-server exited with code ${code}`)
162+
}
163+
})
164+
165+
// Handle Ctrl+C gracefully
166+
process.on("SIGINT", () => {
167+
console.log("\n")
168+
log("Shutting down code-server...")
169+
codeServer.kill("SIGTERM")
170+
})
171+
}
172+
173+
main().catch((error) => {
174+
logError(error.message)
175+
process.exit(1)
176+
})

0 commit comments

Comments
 (0)