Skip to content
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
22 changes: 22 additions & 0 deletions .roo/tools/__tests__/system-time.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { CustomToolContext, TaskLike } from "@roo-code/types"

import systemTime from "../system-time.js"

const mockContext: CustomToolContext = {
mode: "code",
task: { taskId: "test-task-id" } as unknown as TaskLike,
}

describe("system-time tool", () => {
describe("execute", () => {
it("should return a formatted date/time string", async () => {
const result = await systemTime.execute({}, mockContext)
expect(result).toMatch(/^The current date and time is:/)
expect(result).toMatch(/(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)/)
expect(result).toMatch(
/(January|February|March|April|May|June|July|August|September|October|November|December)/,
)
expect(result).toMatch(/\d{1,2}:\d{2}:\d{2}/)
})
})
})
4 changes: 4 additions & 0 deletions .roo/tools/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { config } from "@roo-code/config-eslint/base"

/** @type {import("eslint").Linter.Config} */
export default [...config]
18 changes: 18 additions & 0 deletions .roo/tools/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@roo-code/custom-tools",
"version": "0.0.0",
"private": true,
"type": "module",
"description": "Custom tools for the Roo Code project itself",
"scripts": {
"lint": "eslint . --ext=ts --max-warnings=0",
"check-types": "tsc --noEmit",
"test": "vitest run"
},
"devDependencies": {
"@roo-code/config-eslint": "workspace:^",
"@roo-code/config-typescript": "workspace:^",
"@roo-code/types": "workspace:^",
"vitest": "^3.2.3"
}
}
22 changes: 22 additions & 0 deletions .roo/tools/system-time.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { parametersSchema, defineCustomTool } from "@roo-code/types"

export default defineCustomTool({
name: "system_time",
description: "Returns the current system date and time in a friendly, human-readable format.",
parameters: parametersSchema.object({}),
async execute() {
const systemTime = new Date().toLocaleString("en-US", {
weekday: "long",
year: "numeric",
month: "long",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
timeZoneName: "short",
timeZone: "America/Los_Angeles",
})

return `The current date and time is: ${systemTime}`
},
})
9 changes: 9 additions & 0 deletions .roo/tools/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "@roo-code/config-typescript/base.json",
"compilerOptions": {
"noEmit": true,
"types": ["vitest/globals"]
},
"include": ["*.ts", "__tests__/*.ts"],
"exclude": ["node_modules"]
}
9 changes: 9 additions & 0 deletions .roo/tools/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from "vitest/config"

export default defineConfig({
test: {
globals: true,
environment: "node",
watch: false,
},
})
52 changes: 52 additions & 0 deletions packages/build/src/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,58 @@ export function copyWasms(srcDir: string, distDir: string): void {
})

console.log(`[copyWasms] Copied ${wasmFiles.length} tree-sitter language wasms to ${distDir}`)

// Copy esbuild-wasm files for custom tool transpilation (cross-platform).
copyEsbuildWasmFiles(nodeModulesDir, distDir)
}

/**
* Copy esbuild-wasm files to the dist/bin directory.
*
* This function copies the esbuild-wasm CLI and WASM binary, which provides
* a cross-platform esbuild implementation that works on all platforms.
*
* Files copied:
* - bin/esbuild (Node.js CLI script)
* - esbuild.wasm (WASM binary)
* - wasm_exec_node.js (Go WASM runtime for Node.js)
* - wasm_exec.js (Go WASM runtime dependency)
*/
function copyEsbuildWasmFiles(nodeModulesDir: string, distDir: string): void {
const esbuildWasmDir = path.join(nodeModulesDir, "esbuild-wasm")

if (!fs.existsSync(esbuildWasmDir)) {
throw new Error(`Directory does not exist: ${esbuildWasmDir}`)
}

// Create bin directory in dist.
const binDir = path.join(distDir, "bin")
fs.mkdirSync(binDir, { recursive: true })

// Files to copy - the esbuild CLI script expects wasm_exec_node.js and esbuild.wasm
// to be one directory level up from the bin directory (i.e., in distDir directly).
// wasm_exec_node.js requires wasm_exec.js, so we need to copy that too.
const filesToCopy = [
{ src: path.join(esbuildWasmDir, "bin", "esbuild"), dest: path.join(binDir, "esbuild") },
{ src: path.join(esbuildWasmDir, "esbuild.wasm"), dest: path.join(distDir, "esbuild.wasm") },
{ src: path.join(esbuildWasmDir, "wasm_exec_node.js"), dest: path.join(distDir, "wasm_exec_node.js") },
{ src: path.join(esbuildWasmDir, "wasm_exec.js"), dest: path.join(distDir, "wasm_exec.js") },
]

for (const { src, dest } of filesToCopy) {
fs.copyFileSync(src, dest)

// Make CLI executable.
if (src.endsWith("esbuild")) {
try {
fs.chmodSync(dest, 0o755)
} catch {
// Ignore chmod errors on Windows.
}
}
}

console.log(`[copyWasms] Copied ${filesToCopy.length} esbuild-wasm files to ${distDir}`)
}

export function copyLocales(srcDir: string, distDir: string): void {
Expand Down
4 changes: 4 additions & 0 deletions packages/core/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { config } from "@roo-code/config-eslint/base"

/** @type {import("eslint").Linter.Config} */
export default [...config]
26 changes: 26 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@roo-code/core",
"description": "Platform agnostic core functionality for Roo Code.",
"version": "0.0.0",
"type": "module",
"exports": "./src/index.ts",
"scripts": {
"lint": "eslint src --ext=ts --max-warnings=0",
"check-types": "tsc --noEmit",
"test": "vitest run",
"clean": "rimraf .turbo"
},
"dependencies": {
"@roo-code/types": "workspace:^",
"esbuild": "^0.25.0",
"execa": "^9.5.2",
"openai": "^5.12.2",
"zod": "^3.25.61"
},
"devDependencies": {
"@roo-code/config-eslint": "workspace:^",
"@roo-code/config-typescript": "workspace:^",
"@types/node": "^24.1.0",
"vitest": "^3.2.3"
}
}
Loading
Loading