Skip to content

Commit 038f2c0

Browse files
committed
Roo Code Nightly
1 parent cbd2a16 commit 038f2c0

File tree

13 files changed

+488
-33
lines changed

13 files changed

+488
-33
lines changed

apps/vscode-nightly/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

apps/vscode-nightly/esbuild.mjs

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
import * as esbuild from "esbuild"
2+
import * as fs from "fs"
3+
import * as path from "path"
4+
import { fileURLToPath } from "url"
5+
6+
import { copyPaths, copyLocales, copyWasms, copyAssets } from "@roo-code/build"
7+
8+
const __filename = fileURLToPath(import.meta.url)
9+
const __dirname = path.dirname(__filename)
10+
11+
async function main() {
12+
const production = process.argv.includes("--production")
13+
const minify = production
14+
const sourcemap = !production
15+
16+
/**
17+
* @type {import('esbuild').BuildOptions}
18+
*/
19+
const buildOptions = {
20+
bundle: true,
21+
minify,
22+
sourcemap,
23+
logLevel: "silent",
24+
format: "cjs",
25+
sourcesContent: false,
26+
platform: "node",
27+
}
28+
29+
const srcDir = path.join(__dirname, "..", "..", "src")
30+
const buildDir = path.join(__dirname, "build")
31+
const distDir = path.join(buildDir, "dist")
32+
33+
/**
34+
* @type {import('esbuild').Plugin[]}
35+
*/
36+
const plugins = [
37+
{
38+
name: "copy-src",
39+
setup(build) {
40+
build.onEnd(() => {
41+
copyPaths(["assets", "LICENSE", ".vscodeignore"], srcDir, buildDir)
42+
43+
let count = 0
44+
45+
fs.readdirSync(path.join(srcDir)).forEach((file) => {
46+
if (file.startsWith("package.nls")) {
47+
fs.copyFileSync(path.join(srcDir, file), path.join(buildDir, file))
48+
count++
49+
}
50+
})
51+
52+
console.log(`[copy-src] Copied ${count} package.nls*.json files to ${buildDir}`)
53+
})
54+
},
55+
},
56+
{
57+
name: "generate-package-json",
58+
setup(build) {
59+
build.onEnd(() => {
60+
const packageJson = JSON.parse(fs.readFileSync(path.join(srcDir, "package.json"), "utf8"))
61+
62+
const packageNightlyJson = JSON.parse(
63+
fs.readFileSync(path.join(__dirname, "package.nightly.json"), "utf8"),
64+
)
65+
66+
fs.writeFileSync(
67+
path.join(buildDir, "package.json"),
68+
JSON.stringify({ ...packageJson, ...packageNightlyJson }, null, 2),
69+
)
70+
71+
console.log(`[generate-package-json] Generated package.json from package.nightly.json`)
72+
})
73+
},
74+
},
75+
{
76+
name: "copy-wasms",
77+
setup(build) {
78+
build.onEnd(() => {
79+
copyWasms(srcDir, distDir)
80+
})
81+
},
82+
},
83+
{
84+
name: "copy-locales",
85+
setup(build) {
86+
build.onEnd(() => {
87+
copyLocales(srcDir, distDir)
88+
})
89+
},
90+
},
91+
{
92+
name: "copy-assets",
93+
setup(build) {
94+
build.onEnd(() => {
95+
copyAssets(srcDir, buildDir)
96+
})
97+
},
98+
},
99+
]
100+
101+
/**
102+
* @type {import('esbuild').BuildOptions}
103+
*/
104+
const extensionBuildOptions = {
105+
...buildOptions,
106+
plugins,
107+
entryPoints: [path.join(srcDir, "extension.ts")],
108+
outfile: path.join(distDir, "extension.js"),
109+
external: ["vscode"],
110+
}
111+
112+
/**
113+
* @type {import('esbuild').BuildOptions}
114+
*/
115+
const workerBuildOptions = {
116+
...buildOptions,
117+
entryPoints: [path.join(srcDir, "workers", "countTokens.ts")],
118+
outdir: path.join(distDir, "workers"),
119+
}
120+
121+
const [extensionBuildContext, workerBuildContext] = await Promise.all([
122+
esbuild.context(extensionBuildOptions),
123+
esbuild.context(workerBuildOptions),
124+
])
125+
126+
await Promise.all([
127+
extensionBuildContext.rebuild(),
128+
extensionBuildContext.dispose(),
129+
130+
workerBuildContext.rebuild(),
131+
workerBuildContext.dispose(),
132+
])
133+
}
134+
135+
main().catch((e) => {
136+
console.error(e)
137+
process.exit(1)
138+
})

apps/vscode-nightly/eslintrc.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": {
5+
"ecmaVersion": 6,
6+
"sourceType": "module"
7+
},
8+
"plugins": ["@typescript-eslint"],
9+
"rules": {
10+
"@typescript-eslint/naming-convention": [
11+
"warn",
12+
{
13+
"selector": "import",
14+
"format": ["camelCase", "PascalCase"]
15+
}
16+
],
17+
"@typescript-eslint/semi": "off",
18+
"no-unused-vars": "off",
19+
"@typescript-eslint/no-unused-vars": ["error", { "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" }],
20+
"eqeqeq": "warn",
21+
"no-throw-literal": "warn",
22+
"semi": "off"
23+
},
24+
"ignorePatterns": ["dist"]
25+
}

apps/vscode-nightly/package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@roo-code/vscode-nightly",
3+
"description": "Nightly build for the Roo Code VSCode extension.",
4+
"private": true,
5+
"packageManager": "[email protected]",
6+
"scripts": {
7+
"build": "rimraf build && pnpm --filter @roo-code/build build && node esbuild.mjs --production && pnpm --filter @roo-code/vscode-webview build --mode nightly",
8+
"vsix": "pnpm build && cd build && npx vsce package --no-dependencies --out ../../../bin",
9+
"clean": "rimraf build"
10+
},
11+
"dependencies": {
12+
"@roo-code/build": "workspace:^"
13+
},
14+
"devDependencies": {
15+
"esbuild": "^0.25.0",
16+
"mkdirp": "^3.0.1",
17+
"rimraf": "^6.0.1"
18+
}
19+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "roo-code-nightly",
3+
"publisher": "RooCodeInc",
4+
"version": "0.0.1",
5+
"scripts": {}
6+
}

packages/build/eslintrc.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": {
5+
"ecmaVersion": 6,
6+
"sourceType": "module"
7+
},
8+
"plugins": ["@typescript-eslint"],
9+
"rules": {
10+
"@typescript-eslint/naming-convention": [
11+
"warn",
12+
{
13+
"selector": "import",
14+
"format": ["camelCase", "PascalCase"]
15+
}
16+
],
17+
"@typescript-eslint/semi": "off",
18+
"no-unused-vars": "off",
19+
"@typescript-eslint/no-unused-vars": ["error", { "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" }],
20+
"eqeqeq": "warn",
21+
"no-throw-literal": "warn",
22+
"semi": "off"
23+
},
24+
"ignorePatterns": ["dist"]
25+
}

packages/build/package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "@roo-code/build",
3+
"description": "ESBuild utilities for Roo Code.",
4+
"private": true,
5+
"type": "module",
6+
"exports": "./dist/index.js",
7+
"scripts": {
8+
"build": "tsc"
9+
},
10+
"devDependencies": {
11+
"@types/node": "^22.15.20"
12+
}
13+
}

packages/build/src/index.ts

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
import * as fs from "fs"
2+
import * as path from "path"
3+
4+
/**
5+
* Copies all files or directories from source to destination
6+
* @param paths Array of file or directory paths to copy
7+
* @param srcDir Source directory path
8+
* @param dstDir Destination directory path
9+
*/
10+
export function copyPaths(paths: string[], srcDir: string, dstDir: string) {
11+
paths.forEach((fileOrDirectory) => {
12+
const stats = fs.lstatSync(path.join(srcDir, fileOrDirectory))
13+
14+
if (stats.isDirectory()) {
15+
const directory = fileOrDirectory
16+
const count = copyDir(path.join(srcDir, directory), path.join(dstDir, directory), 0)
17+
console.log(`[copy-src] Copied ${count} files from ${directory} to ${dstDir}`)
18+
} else {
19+
const file = fileOrDirectory
20+
fs.copyFileSync(path.join(srcDir, file), path.join(dstDir, file))
21+
console.log(`[copy-src] Copied ${file} to ${dstDir}`)
22+
}
23+
})
24+
}
25+
26+
/**
27+
* Recursively copies files from source directory to destination directory
28+
* @param srcDir Source directory path
29+
* @param dstDir Destination directory path
30+
* @param count Counter for number of files copied
31+
* @returns Updated count of files copied
32+
*/
33+
export function copyDir(srcDir: string, dstDir: string, count: number): number {
34+
const entries = fs.readdirSync(srcDir, { withFileTypes: true })
35+
36+
for (const entry of entries) {
37+
const srcPath = path.join(srcDir, entry.name)
38+
const dstPath = path.join(dstDir, entry.name)
39+
40+
if (entry.isDirectory()) {
41+
fs.mkdirSync(dstPath, { recursive: true })
42+
count = copyDir(srcPath, dstPath, count)
43+
} else {
44+
count = count + 1
45+
fs.copyFileSync(srcPath, dstPath)
46+
}
47+
}
48+
49+
return count
50+
}
51+
52+
/**
53+
* Copies WASM files from node_modules to the distribution directory
54+
* @param srcDir Source directory path
55+
* @param distDir Distribution directory path
56+
*/
57+
export function copyWasms(srcDir: string, distDir: string): void {
58+
const nodeModulesDir = path.join(srcDir, "node_modules")
59+
60+
fs.mkdirSync(distDir, { recursive: true })
61+
62+
// Tiktoken WASM file.
63+
fs.copyFileSync(
64+
path.join(nodeModulesDir, "tiktoken", "lite", "tiktoken_bg.wasm"),
65+
path.join(distDir, "tiktoken_bg.wasm"),
66+
)
67+
68+
console.log(`[copy-wasm-files] Copied tiktoken WASMs to ${distDir}`)
69+
70+
// Also copy Tiktoken WASMs to the workers directory.
71+
const workersDir = path.join(distDir, "workers")
72+
fs.mkdirSync(workersDir, { recursive: true })
73+
74+
fs.copyFileSync(
75+
path.join(nodeModulesDir, "tiktoken", "lite", "tiktoken_bg.wasm"),
76+
path.join(workersDir, "tiktoken_bg.wasm"),
77+
)
78+
79+
console.log(`[copy-wasm-files] Copied tiktoken WASMs to ${workersDir}`)
80+
81+
// Main tree-sitter WASM file.
82+
fs.copyFileSync(
83+
path.join(nodeModulesDir, "web-tree-sitter", "tree-sitter.wasm"),
84+
path.join(distDir, "tree-sitter.wasm"),
85+
)
86+
87+
console.log(`[copy-wasm-files] Copied tree-sitter.wasm to ${distDir}`)
88+
89+
// Copy language-specific WASM files.
90+
const languageWasmDir = path.join(nodeModulesDir, "tree-sitter-wasms", "out")
91+
92+
if (!fs.existsSync(languageWasmDir)) {
93+
throw new Error(`Directory does not exist: ${languageWasmDir}`)
94+
}
95+
96+
// Dynamically read all WASM files from the directory instead of using a hardcoded list.
97+
const wasmFiles = fs.readdirSync(languageWasmDir).filter((file) => file.endsWith(".wasm"))
98+
99+
wasmFiles.forEach((filename) => {
100+
fs.copyFileSync(path.join(languageWasmDir, filename), path.join(distDir, filename))
101+
})
102+
103+
console.log(`[copy-wasm-files] Copied ${wasmFiles.length} tree-sitter language wasms to ${distDir}`)
104+
}
105+
106+
/**
107+
* Copies locale files to the distribution directory
108+
* @param srcDir Source directory path
109+
* @param distDir Distribution directory path
110+
*/
111+
export function copyLocales(srcDir: string, distDir: string): void {
112+
const destDir = path.join(distDir, "i18n", "locales")
113+
fs.mkdirSync(destDir, { recursive: true })
114+
const count = copyDir(path.join(srcDir, "i18n", "locales"), destDir, 0)
115+
console.log(`[copy-locales-files] Copied ${count} locale files to ${destDir}`)
116+
}
117+
118+
/**
119+
* Copies asset files to the distribution directory
120+
* @param srcDir Source directory path
121+
* @param distDir Distribution directory path
122+
*/
123+
export function copyAssets(srcDir: string, distDir: string) {
124+
const copyPaths = [["node_modules/vscode-material-icons/generated", "assets/vscode-material-icons"]]
125+
126+
for (const [srcRelPath, dstRelPath] of copyPaths) {
127+
if (!srcRelPath || !dstRelPath) {
128+
throw new Error("Invalid copy path")
129+
}
130+
131+
const from = path.join(srcDir, srcRelPath)
132+
const to = path.join(distDir, dstRelPath)
133+
134+
if (!fs.existsSync(from)) {
135+
throw new Error(`Directory does not exist: ${from}`)
136+
}
137+
138+
if (fs.existsSync(to)) {
139+
fs.rmSync(to, { recursive: true })
140+
}
141+
142+
fs.mkdirSync(to, { recursive: true })
143+
const count = copyDir(from, to, 0)
144+
console.log(`[copy-assets] Copied ${count} assets: ${from} -> ${to}`)
145+
}
146+
}

0 commit comments

Comments
 (0)