Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 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
58 changes: 58 additions & 0 deletions .roo/tools/__tests__/system-time.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
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("definition", () => {
it("should have a description", () => {
expect(systemTime.description).toBe(
"Returns the current system date and time in a friendly, human-readable format.",
)
})

it("should have optional timezone parameter", () => {
expect(systemTime.parameters).toBeDefined()
const shape = systemTime.parameters!.shape
expect(shape.timezone).toBeDefined()
expect(shape.timezone.isOptional()).toBe(true)
})
})

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}/)
})

it("should use system timezone when no timezone provided", async () => {
const result = await systemTime.execute({}, mockContext)
expect(result).toMatch(/[A-Z]{2,5}$/)
})

it("should format with specified timezone", async () => {
const result = await systemTime.execute({ timezone: "UTC" }, mockContext)
expect(result).toMatch(/^The current date and time is:/)
expect(result).toMatch(/UTC/)
})

it("should work with different timezone formats", async () => {
const result = await systemTime.execute({ timezone: "America/New_York" }, mockContext)
expect(result).toMatch(/^The current date and time is:/)
expect(result).toMatch(/(EST|EDT)/)
})

it("should throw error for invalid timezone", async () => {
await expect(systemTime.execute({ timezone: "Invalid/Timezone" }, mockContext)).rejects.toThrow()
})
})
})
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"
}
}
43 changes: 43 additions & 0 deletions .roo/tools/system-time.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { defineCustomTool, parametersSchema } from "@roo-code/types"

/**
* A simple custom tool that returns the current date and time in a friendly format.
*
* To create your own custom tools:
* 1. Install @roo-code/types: npm install @roo-code/types
* 2. Create a .ts file in .roo/tools/
* 3. Export a default tool definition using defineCustomTool()
*
* Note that `parametersSchema` is just an alias for `z` (from zod).
*/
export default defineCustomTool({
name: "system-time",
description: "Returns the current system date and time in a friendly, human-readable format.",
parameters: parametersSchema.object({
timezone: parametersSchema
.string()
.optional()
.describe("Optional timezone to display the time in (e.g., 'America/New_York', 'Europe/London')"),
}),
async execute(args) {
const options: Intl.DateTimeFormatOptions = {
weekday: "long",
year: "numeric",
month: "long",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
timeZoneName: "short",
}

if (args.timezone) {
options.timeZone = args.timezone
}

const now = new Date()
const formatted = now.toLocaleString("en-US", options)

return `The current date and time is: ${formatted}`
},
})
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,
},
})
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]
25 changes: 25 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"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",
"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