Skip to content

Commit 0ee3680

Browse files
authored
feat(dx): streamline extension installation and documentation (RooCodeInc#4284)
1 parent ff1e8ac commit 0ee3680

File tree

3 files changed

+132
-8
lines changed

3 files changed

+132
-8
lines changed

README.md

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,22 +138,54 @@ pnpm install
138138

139139
3. **Run the extension**:
140140

141-
Press `F5` (or **Run****Start Debugging**) in VSCode to open a new window with Roo Code running.
141+
There are several ways to run the Roo Code extension:
142142

143-
Changes to the webview will appear immediately. Changes to the core extension will require a restart of the extension host.
143+
### Development Mode (F5)
144144

145-
Alternatively you can build a .vsix and install it directly in VSCode:
145+
For active development, use VSCode's built-in debugging:
146146

147-
```sh
148-
pnpm vsix
149-
```
147+
Press `F5` (or go to **Run****Start Debugging**) in VSCode. This will open a new VSCode window with the Roo Code extension running.
148+
149+
- Changes to the webview will appear immediately.
150+
- Changes to the core extension will also hot reload automatically.
151+
152+
### Automated VSIX Installation
150153

151-
A `.vsix` file will appear in the `bin/` directory which can be installed with:
154+
To build and install the extension as a VSIX package directly into VSCode:
152155

153156
```sh
154-
code --install-extension bin/roo-cline-<version>.vsix
157+
pnpm install:vsix [-y] [--editor=<command>]
155158
```
156159

160+
This command will:
161+
162+
- Ask which editor command to use (code/cursor/code-insiders) - defaults to 'code'
163+
- Uninstall any existing version of the extension.
164+
- Build the latest VSIX package.
165+
- Install the newly built VSIX.
166+
- Prompt you to restart VS Code for changes to take effect.
167+
168+
Options:
169+
170+
- `-y`: Skip all confirmation prompts and use defaults
171+
- `--editor=<command>`: Specify the editor command (e.g., `--editor=cursor` or `--editor=code-insiders`)
172+
173+
### Manual VSIX Installation
174+
175+
If you prefer to install the VSIX package manually:
176+
177+
1. First, build the VSIX package:
178+
```sh
179+
pnpm vsix
180+
```
181+
2. A `.vsix` file will be generated in the `bin/` directory (e.g., `bin/roo-cline-<version>.vsix`).
182+
3. Install it manually using the VSCode CLI:
183+
```sh
184+
code --install-extension bin/roo-cline-<version>.vsix
185+
```
186+
187+
---
188+
157189
We use [changesets](https://github.com/changesets/changesets) for versioning and publishing. Check our `CHANGELOG.md` for release notes.
158190

159191
---

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"vsix": "turbo vsix --log-order grouped --output-logs new-only",
2020
"vsix:nightly": "turbo vsix:nightly --log-order grouped --output-logs new-only",
2121
"clean": "turbo clean --log-order grouped --output-logs new-only && rimraf dist out bin .vite-port .turbo",
22+
"install:vsix": "pnpm install --frozen-lockfile && pnpm clean && pnpm vsix && node scripts/install-vsix.js",
2223
"changeset:version": "cp CHANGELOG.md src/CHANGELOG.md && changeset version && cp -vf src/CHANGELOG.md .",
2324
"knip": "knip --include files",
2425
"update-contributors": "node scripts/update-contributors.js",

scripts/install-vsix.js

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
const { execSync } = require("child_process")
2+
const fs = require("fs")
3+
const readline = require("readline")
4+
5+
// detect "yes" flags
6+
const autoYes = process.argv.includes("-y")
7+
8+
// detect editor command from args or default to "code"
9+
const editorArg = process.argv.find((arg) => arg.startsWith("--editor="))
10+
const defaultEditor = editorArg ? editorArg.split("=")[1] : "code"
11+
12+
const rl = readline.createInterface({
13+
input: process.stdin,
14+
output: process.stdout,
15+
})
16+
17+
const askQuestion = (question) => {
18+
return new Promise((resolve) => {
19+
rl.question(question, (answer) => {
20+
resolve(answer)
21+
})
22+
})
23+
}
24+
25+
async function main() {
26+
try {
27+
const packageJson = JSON.parse(fs.readFileSync("./src/package.json", "utf-8"))
28+
const name = packageJson.name
29+
const version = packageJson.version
30+
const vsixFileName = `./bin/${name}-${version}.vsix`
31+
const publisher = packageJson.publisher
32+
const extensionId = `${publisher}.${name}`
33+
34+
console.log("\n🚀 Roo Code VSIX Installer")
35+
console.log("========================")
36+
console.log("\nThis script will:")
37+
console.log("1. Uninstall any existing version of the Roo Code extension")
38+
console.log("2. Install the newly built VSIX package")
39+
console.log(`\nExtension: ${extensionId}`)
40+
console.log(`VSIX file: ${vsixFileName}`)
41+
42+
// Ask for editor command if not provided
43+
let editorCommand = defaultEditor
44+
if (!editorArg && !autoYes) {
45+
const editorAnswer = await askQuestion(
46+
"\nWhich editor command to use? (code/cursor/code-insiders) [default: code]: ",
47+
)
48+
if (editorAnswer.trim()) {
49+
editorCommand = editorAnswer.trim()
50+
}
51+
}
52+
53+
// skip prompt if auto-yes
54+
const answer = autoYes ? "y" : await askQuestion("\nDo you wish to continue? (y/n): ")
55+
56+
if (answer.toLowerCase() !== "y") {
57+
console.log("Installation cancelled.")
58+
rl.close()
59+
process.exit(0)
60+
}
61+
62+
console.log(`\nProceeding with installation using '${editorCommand}' command...`)
63+
64+
try {
65+
execSync(`${editorCommand} --uninstall-extension ${extensionId}`, { stdio: "inherit" })
66+
} catch (e) {
67+
console.log("Extension not installed, skipping uninstall step")
68+
}
69+
70+
if (!fs.existsSync(vsixFileName)) {
71+
console.error(`\n❌ VSIX file not found: ${vsixFileName}`)
72+
console.error("Make sure the build completed successfully")
73+
rl.close()
74+
process.exit(1)
75+
}
76+
77+
execSync(`${editorCommand} --install-extension ${vsixFileName}`, { stdio: "inherit" })
78+
79+
console.log(`\n✅ Successfully installed extension from ${vsixFileName}`)
80+
console.log("\n⚠️ IMPORTANT: You need to restart VS Code for the changes to take effect.")
81+
console.log(" Please close and reopen VS Code to use the updated extension.\n")
82+
83+
rl.close()
84+
} catch (error) {
85+
console.error("\n❌ Failed to install extension:", error.message)
86+
rl.close()
87+
process.exit(1)
88+
}
89+
}
90+
91+
main()

0 commit comments

Comments
 (0)