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 all commits
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
82 changes: 0 additions & 82 deletions .github/scripts/overwrite_changeset_changelog.py

This file was deleted.

52 changes: 14 additions & 38 deletions .github/workflows/code-qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,6 @@ env:
PNPM_VERSION: 10.8.1

jobs:
compile:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Check types
run: pnpm check-types
- name: Lint
run: pnpm lint

check-translations:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -72,11 +51,8 @@ jobs:
- name: Run knip checks
run: pnpm knip

test-extension:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
compile:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -91,11 +67,12 @@ jobs:
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Run unit tests
working-directory: src
run: pnpm test
- name: Lint
run: pnpm lint
- name: Check types
run: pnpm check-types

test-webview:
platform-unit-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -115,16 +92,8 @@ jobs:
- name: Install dependencies
run: pnpm install
- name: Run unit tests
working-directory: webview-ui
run: pnpm test

unit-test:
needs: [test-extension, test-webview]
runs-on: ubuntu-latest
steps:
- name: NO-OP
run: echo "All unit tests passed."

check-openrouter-api-key:
runs-on: ubuntu-latest
outputs:
Expand Down Expand Up @@ -164,3 +133,10 @@ jobs:
- name: Run integration tests
working-directory: apps/vscode-e2e
run: xvfb-run -a pnpm test:ci

unit-test:
needs: [platform-unit-test] # [platform-unit-test, integration-test]
runs-on: ubuntu-latest
steps:
- name: NO-OP
run: echo "All tests passed."
8 changes: 0 additions & 8 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ else
fi
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 --filter @roo-code/vscode-webview build && 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`)
}
})
})
13 changes: 4 additions & 9 deletions apps/vscode-e2e/src/suite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@ 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"

declare global {
let api: RooCodeAPI
}

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 @@ -23,13 +19,12 @@ export async function run() {
await api.setConfiguration({
apiProvider: "openrouter" as const,
openRouterApiKey: process.env.OPENROUTER_API_KEY!,
openRouterModelId: "google/gemini-2.0-flash-001",
openRouterModelId: "openai/gpt-4.1",
})

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.
globalThis.api = api

// Add all the tests to the runner.
Expand Down
10 changes: 2 additions & 8 deletions apps/vscode-e2e/src/suite/modes.test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import * as assert from "assert"

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

import { waitUntilCompleted } from "./utils"

suite("Roo Code Modes", () => {
test("Should handle switching modes correctly", async () => {
// @ts-expect-error - Expose the API to the tests.
const api = globalThis.api as RooCodeAPI

/**
* Switch modes.
*/
const api = globalThis.api

const switchModesPrompt =
"For each mode (Architect, Ask, Debug) respond with the mode name and what it specializes in after switching to that mode."

const messages: ClineMessage[] = []

const modeSwitches: string[] = []

api.on("taskModeSwitched", (_taskId, mode) => {
Expand Down
9 changes: 4 additions & 5 deletions apps/vscode-e2e/src/suite/subtasks.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import * as assert from "assert"

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

import { sleep, waitFor, waitUntilCompleted } from "./utils"

suite.skip("Roo Code Subtasks", () => {
test("Should handle subtask cancellation and resumption correctly", async () => {
// @ts-expect-error - Expose the API to the tests.
const api = globalThis.api as RooCodeAPI
const api = globalThis.api

const messages: Record<string, ClineMessage[]> = {}

Expand Down Expand Up @@ -49,7 +48,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 +62,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
5 changes: 2 additions & 3 deletions apps/vscode-e2e/src/suite/task.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import * as assert from "assert"

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

import { waitUntilCompleted } from "./utils"

suite("Roo Code Task", () => {
test("Should handle prompt and response correctly", async () => {
// @ts-expect-error - Expose the API to the tests.
const api = globalThis.api as RooCodeAPI
const api = globalThis.api

const messages: ClineMessage[] = []

Expand Down
8 changes: 8 additions & 0 deletions apps/vscode-e2e/src/types/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { RooCodeAPI } from "@roo-code/types"

declare global {
// eslint-disable-next-line no-var
var api: RooCodeAPI
}

export {}
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"]
}
Loading