Skip to content

Commit e66136f

Browse files
authored
Add a new @roo-code/types package and use it everywhere (#3912)
1 parent ce6cc6f commit e66136f

File tree

217 files changed

+1571
-5277
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

217 files changed

+1571
-5277
lines changed

.github/scripts/overwrite_changeset_changelog.py

Lines changed: 0 additions & 82 deletions
This file was deleted.

.github/workflows/code-qa.yml

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,6 @@ env:
1313
PNPM_VERSION: 10.8.1
1414

1515
jobs:
16-
compile:
17-
runs-on: ubuntu-latest
18-
steps:
19-
- name: Checkout code
20-
uses: actions/checkout@v4
21-
- name: Install pnpm
22-
uses: pnpm/action-setup@v4
23-
with:
24-
version: ${{ env.PNPM_VERSION }}
25-
- name: Setup Node.js
26-
uses: actions/setup-node@v4
27-
with:
28-
node-version: ${{ env.NODE_VERSION }}
29-
cache: 'pnpm'
30-
- name: Install dependencies
31-
run: pnpm install
32-
- name: Check types
33-
run: pnpm check-types
34-
- name: Lint
35-
run: pnpm lint
36-
3716
check-translations:
3817
runs-on: ubuntu-latest
3918
steps:
@@ -72,11 +51,8 @@ jobs:
7251
- name: Run knip checks
7352
run: pnpm knip
7453

75-
test-extension:
76-
runs-on: ${{ matrix.os }}
77-
strategy:
78-
matrix:
79-
os: [ubuntu-latest, windows-latest]
54+
compile:
55+
runs-on: ubuntu-latest
8056
steps:
8157
- name: Checkout code
8258
uses: actions/checkout@v4
@@ -91,11 +67,12 @@ jobs:
9167
cache: 'pnpm'
9268
- name: Install dependencies
9369
run: pnpm install
94-
- name: Run unit tests
95-
working-directory: src
96-
run: pnpm test
70+
- name: Lint
71+
run: pnpm lint
72+
- name: Check types
73+
run: pnpm check-types
9774

98-
test-webview:
75+
platform-unit-test:
9976
runs-on: ${{ matrix.os }}
10077
strategy:
10178
matrix:
@@ -115,16 +92,8 @@ jobs:
11592
- name: Install dependencies
11693
run: pnpm install
11794
- name: Run unit tests
118-
working-directory: webview-ui
11995
run: pnpm test
12096

121-
unit-test:
122-
needs: [test-extension, test-webview]
123-
runs-on: ubuntu-latest
124-
steps:
125-
- name: NO-OP
126-
run: echo "All unit tests passed."
127-
12897
check-openrouter-api-key:
12998
runs-on: ubuntu-latest
13099
outputs:
@@ -164,3 +133,10 @@ jobs:
164133
- name: Run integration tests
165134
working-directory: apps/vscode-e2e
166135
run: xvfb-run -a pnpm test:ci
136+
137+
unit-test:
138+
needs: [platform-unit-test] # [platform-unit-test, integration-test]
139+
runs-on: ubuntu-latest
140+
steps:
141+
- name: NO-OP
142+
run: echo "All tests passed."

.husky/pre-commit

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ else
1616
fi
1717
fi
1818

19-
$pnpm_cmd --filter roo-cline generate-types
20-
21-
if [ -n "$(git diff --name-only src/exports/roo-code.d.ts)" ]; then
22-
echo "Error: There are unstaged changes to roo-code.d.ts after running 'pnpm --filter roo-cline generate-types'."
23-
echo "Please review and stage the changes before committing."
24-
exit 1
25-
fi
26-
2719
# Detect if running on Windows and use npx.cmd, otherwise use npx.
2820
if [ "$OS" = "Windows_NT" ]; then
2921
npx_cmd="npx.cmd"

apps/vscode-e2e/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
"private": true,
44
"scripts": {
55
"lint": "eslint src --ext=ts --max-warnings=0",
6-
"check-types": "tsc --noEmit",
6+
"check-types": "tsc -p tsconfig.esm.json --noEmit",
77
"format": "prettier --write src",
8-
"test:ci": "pnpm --filter roo-cline build:development && pnpm test:run",
8+
"test:ci": "pnpm -w bundle && pnpm --filter @roo-code/vscode-webview build && pnpm test:run",
99
"test:run": "rimraf out && tsc -p tsconfig.json && npx dotenvx run -f .env.local -- node ./out/runTest.js",
1010
"clean": "rimraf out .turbo"
1111
},
1212
"devDependencies": {
1313
"@roo-code/config-eslint": "workspace:^",
1414
"@roo-code/config-typescript": "workspace:^",
15-
"@roo-code/types": "^1.12.0",
15+
"@roo-code/types": "workspace:^",
1616
"@types/mocha": "^10.0.10",
1717
"@types/node": "^22.14.1",
1818
"@types/vscode": "^1.95.0",

apps/vscode-e2e/src/suite/extension.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import * as assert from "assert"
22
import * as vscode from "vscode"
33

4-
import { Package } from "@roo-code/types"
5-
64
suite("Roo Code Extension", () => {
75
test("Commands should be registered", async () => {
86
const expectedCommands = [
@@ -36,12 +34,10 @@ suite("Roo Code Extension", () => {
3634
"terminalExplainCommand",
3735
]
3836

39-
const commands = new Set(
40-
(await vscode.commands.getCommands(true)).filter((cmd) => cmd.startsWith(Package.name)),
41-
)
37+
const commands = new Set((await vscode.commands.getCommands(true)).filter((cmd) => cmd.startsWith("roo-cline")))
4238

4339
for (const command of expectedCommands) {
44-
assert.ok(commands.has(`${Package.name}.${command}`), `Command ${command} should be registered`)
40+
assert.ok(commands.has(`roo-cline.${command}`), `Command ${command} should be registered`)
4541
}
4642
})
4743
})

apps/vscode-e2e/src/suite/index.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@ import Mocha from "mocha"
33
import { glob } from "glob"
44
import * as vscode from "vscode"
55

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

88
import { waitFor } from "./utils"
99

10-
declare global {
11-
let api: RooCodeAPI
12-
}
13-
1410
export async function run() {
15-
const extension = vscode.extensions.getExtension<RooCodeAPI>(`${Package.publisher}.${Package.name}`)
11+
const extension = vscode.extensions.getExtension<RooCodeAPI>("RooVeterinaryInc.roo-cline")
1612

1713
if (!extension) {
1814
throw new Error("Extension not found")
@@ -23,13 +19,12 @@ export async function run() {
2319
await api.setConfiguration({
2420
apiProvider: "openrouter" as const,
2521
openRouterApiKey: process.env.OPENROUTER_API_KEY!,
26-
openRouterModelId: "google/gemini-2.0-flash-001",
22+
openRouterModelId: "openai/gpt-4.1",
2723
})
2824

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

32-
// @ts-expect-error - Expose the API to the tests.
3328
globalThis.api = api
3429

3530
// Add all the tests to the runner.

apps/vscode-e2e/src/suite/modes.test.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
import * as assert from "assert"
22

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

55
import { waitUntilCompleted } from "./utils"
66

77
suite("Roo Code Modes", () => {
88
test("Should handle switching modes correctly", async () => {
9-
// @ts-expect-error - Expose the API to the tests.
10-
const api = globalThis.api as RooCodeAPI
11-
12-
/**
13-
* Switch modes.
14-
*/
9+
const api = globalThis.api
1510

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

1914
const messages: ClineMessage[] = []
20-
2115
const modeSwitches: string[] = []
2216

2317
api.on("taskModeSwitched", (_taskId, mode) => {

apps/vscode-e2e/src/suite/subtasks.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import * as assert from "assert"
22

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

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

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

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

@@ -49,7 +48,7 @@ suite.skip("Roo Code Subtasks", () => {
4948
// The parent task should not have resumed yet, so we shouldn't see
5049
// "Parent task resumed".
5150
assert.ok(
52-
messages[parentTaskId].find(({ type, text }) => type === "say" && text === "Parent task resumed") ===
51+
messages[parentTaskId]?.find(({ type, text }) => type === "say" && text === "Parent task resumed") ===
5352
undefined,
5453
"Parent task should not have resumed after subtask cancellation",
5554
)
@@ -63,7 +62,7 @@ suite.skip("Roo Code Subtasks", () => {
6362

6463
// The parent task should still not have resumed.
6564
assert.ok(
66-
messages[parentTaskId].find(({ type, text }) => type === "say" && text === "Parent task resumed") ===
65+
messages[parentTaskId]?.find(({ type, text }) => type === "say" && text === "Parent task resumed") ===
6766
undefined,
6867
"Parent task should not have resumed after subtask cancellation",
6968
)

apps/vscode-e2e/src/suite/task.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import * as assert from "assert"
22

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

55
import { waitUntilCompleted } from "./utils"
66

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

1211
const messages: ClineMessage[] = []
1312

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { RooCodeAPI } from "@roo-code/types"
2+
3+
declare global {
4+
// eslint-disable-next-line no-var
5+
var api: RooCodeAPI
6+
}
7+
8+
export {}

0 commit comments

Comments
 (0)