Skip to content

Add a new @roo-code/types package and use it everywhere #3912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
May 26, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ else
pnpm_cmd="pnpm"
fi

"$pnpm_cmd" --filter roo-cline generate-types

if [ -n "$(git diff --name-only src/exports/roo-code.d.ts)" ]; then
echo "Error: There are unstaged changes to roo-code.d.ts after running 'pnpm --filter roo-cline generate-types'."
echo "Please review and stage the changes before committing."
exit 1
fi

# Detect if running on Windows and use npx.cmd, otherwise use npx.
if [ "$OS" = "Windows_NT" ]; then
npx_cmd="npx.cmd"
Expand Down
6 changes: 3 additions & 3 deletions apps/vscode-e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
"private": true,
"scripts": {
"lint": "eslint src --ext=ts --max-warnings=0",
"check-types": "tsc --noEmit",
"check-types": "tsc -p tsconfig.esm.json --noEmit",
"format": "prettier --write src",
"test:ci": "pnpm --filter roo-cline build:development && pnpm test:run",
"test:ci": "pnpm -w bundle && pnpm test:run",
"test:run": "rimraf out && tsc -p tsconfig.json && npx dotenvx run -f .env.local -- node ./out/runTest.js",
"clean": "rimraf out .turbo"
},
"devDependencies": {
"@roo-code/config-eslint": "workspace:^",
"@roo-code/config-typescript": "workspace:^",
"@roo-code/types": "^1.12.0",
"@roo-code/types": "workspace:^",
"@types/mocha": "^10.0.10",
"@types/node": "^22.14.1",
"@types/vscode": "^1.95.0",
Expand Down
8 changes: 2 additions & 6 deletions apps/vscode-e2e/src/suite/extension.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import * as assert from "assert"
import * as vscode from "vscode"

import { Package } from "@roo-code/types"

suite("Roo Code Extension", () => {
test("Commands should be registered", async () => {
const expectedCommands = [
Expand Down Expand Up @@ -36,12 +34,10 @@ suite("Roo Code Extension", () => {
"terminalExplainCommand",
]

const commands = new Set(
(await vscode.commands.getCommands(true)).filter((cmd) => cmd.startsWith(Package.name)),
)
const commands = new Set((await vscode.commands.getCommands(true)).filter((cmd) => cmd.startsWith("roo-cline")))

for (const command of expectedCommands) {
assert.ok(commands.has(`${Package.name}.${command}`), `Command ${command} should be registered`)
assert.ok(commands.has(`roo-cline.${command}`), `Command ${command} should be registered`)
}
})
})
6 changes: 3 additions & 3 deletions apps/vscode-e2e/src/suite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Mocha from "mocha"
import { glob } from "glob"
import * as vscode from "vscode"

import { type RooCodeAPI, Package } from "@roo-code/types"
import type { RooCodeAPI } from "@roo-code/types"

import { waitFor } from "./utils"

Expand All @@ -12,7 +12,7 @@ declare global {
}

export async function run() {
const extension = vscode.extensions.getExtension<RooCodeAPI>(`${Package.publisher}.${Package.name}`)
const extension = vscode.extensions.getExtension<RooCodeAPI>("RooVeterinaryInc.roo-cline")

if (!extension) {
throw new Error("Extension not found")
Expand All @@ -26,7 +26,7 @@ export async function run() {
openRouterModelId: "google/gemini-2.0-flash-001",
})

await vscode.commands.executeCommand(`${Package.name}.SidebarProvider.focus`)
await vscode.commands.executeCommand("roo-cline.SidebarProvider.focus")
await waitFor(() => api.isReady())

// @ts-expect-error - Expose the API to the tests.
Expand Down
4 changes: 2 additions & 2 deletions apps/vscode-e2e/src/suite/subtasks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ suite.skip("Roo Code Subtasks", () => {
// The parent task should not have resumed yet, so we shouldn't see
// "Parent task resumed".
assert.ok(
messages[parentTaskId].find(({ type, text }) => type === "say" && text === "Parent task resumed") ===
messages[parentTaskId]?.find(({ type, text }) => type === "say" && text === "Parent task resumed") ===
undefined,
"Parent task should not have resumed after subtask cancellation",
)
Expand All @@ -63,7 +63,7 @@ suite.skip("Roo Code Subtasks", () => {

// The parent task should still not have resumed.
assert.ok(
messages[parentTaskId].find(({ type, text }) => type === "say" && text === "Parent task resumed") ===
messages[parentTaskId]?.find(({ type, text }) => type === "say" && text === "Parent task resumed") ===
undefined,
"Parent task should not have resumed after subtask cancellation",
)
Expand Down
8 changes: 8 additions & 0 deletions apps/vscode-e2e/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "@roo-code/config-typescript/base.json",
"compilerOptions": {
"outDir": "out"
},
"include": ["src"],
"exclude": ["node_modules"]
}
2 changes: 1 addition & 1 deletion apps/vscode-e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"useUnknownInCatchVariables": false,
"outDir": "out"
},
"include": ["src", "../src/exports/roo-code.d.ts"],
"include": ["src"],
"exclude": [".vscode-test", "**/node_modules/**", "out"]
}
31 changes: 21 additions & 10 deletions apps/vscode-nightly/esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

async function main() {
const name = "extension-nightly"
const production = process.argv.includes("--production")
const minify = production
const sourcemap = !production

const overrideJson = JSON.parse(fs.readFileSync(path.join(__dirname, "package.nightly.json"), "utf8"))
console.log(`[main] name: ${overrideJson.name}`)
console.log(`[main] version: ${overrideJson.version}`)
console.log(`[${name}] name: ${overrideJson.name}`)
console.log(`[${name}] version: ${overrideJson.version}`)

const gitSha = getGitSha()
console.log(`[main] gitSha: ${gitSha}`)
console.log(`[${name}] gitSha: ${gitSha}`)

/**
* @type {import('esbuild').BuildOptions}
Expand All @@ -43,12 +44,22 @@ async function main() {
const buildDir = path.join(__dirname, "build")
const distDir = path.join(buildDir, "dist")

console.log(`[${name}] srcDir: ${srcDir}`)
console.log(`[${name}] buildDir: ${buildDir}`)
console.log(`[${name}] distDir: ${distDir}`)

// Clean build directory before starting new build
if (fs.existsSync(buildDir)) {
console.log(`[${name}] Cleaning build directory: ${buildDir}`)
fs.rmSync(buildDir, { recursive: true, force: true })
}

/**
* @type {import('esbuild').Plugin[]}
*/
const plugins = [
{
name: "copy-files",
name: "copyPaths",
setup(build) {
build.onEnd(() => {
copyPaths(
Expand All @@ -69,7 +80,7 @@ async function main() {
},
},
{
name: "generate-package-json",
name: "generatePackageJson",
setup(build) {
build.onEnd(() => {
const packageJson = JSON.parse(fs.readFileSync(path.join(srcDir, "package.json"), "utf8"))
Expand All @@ -81,7 +92,7 @@ async function main() {
})

fs.writeFileSync(path.join(buildDir, "package.json"), JSON.stringify(generatedPackageJson, null, 2))
console.log(`[generate-package-json] Generated package.json`)
console.log(`[generatePackageJson] Generated package.json`)

let count = 0

Expand All @@ -92,7 +103,7 @@ async function main() {
}
})

console.log(`[copy-src] Copied ${count} package.nls*.json files to ${buildDir}`)
console.log(`[generatePackageJson] Copied ${count} package.nls*.json files to ${buildDir}`)

const nlsPkg = JSON.parse(fs.readFileSync(path.join(srcDir, "package.nls.json"), "utf8"))

Expand All @@ -105,18 +116,18 @@ async function main() {
JSON.stringify({ ...nlsPkg, ...nlsNightlyPkg }, null, 2),
)

console.log(`[copy-src] Generated package.nls.json`)
console.log(`[generatePackageJson] Generated package.nls.json`)
})
},
},
{
name: "copy-wasms",
name: "copyWasms",
setup(build) {
build.onEnd(() => copyWasms(srcDir, distDir))
},
},
{
name: "copy-locales",
name: "copyLocales",
setup(build) {
build.onEnd(() => copyLocales(srcDir, distDir))
},
Expand Down
5 changes: 2 additions & 3 deletions apps/vscode-nightly/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
"private": true,
"packageManager": "[email protected]",
"scripts": {
"bundle": "pnpm clean && pnpm --filter @roo-code/build build && node esbuild.mjs",
"build": "pnpm bundle --production && pnpm --filter @roo-code/vscode-webview build --mode nightly",
"vsix": "pnpm build && cd build && mkdirp ../../../bin && npx vsce package --no-dependencies --out ../../../bin",
"bundle:nightly": "node esbuild.mjs",
"vsix:nightly": "cd build && mkdirp ../../../bin && npx vsce package --no-dependencies --out ../../../bin",
"clean": "rimraf build .turbo"
},
"devDependencies": {
Expand Down
Loading