Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 2aff8f8

Browse files
committed
More cleanup
1 parent 2212a3a commit 2aff8f8

5 files changed

Lines changed: 8 additions & 161 deletions

File tree

.roo/tools/__tests__/system-time.spec.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,6 @@ const mockContext: CustomToolContext = {
88
}
99

1010
describe("system-time tool", () => {
11-
describe("definition", () => {
12-
it("should have a description", () => {
13-
expect(systemTime.description).toBe(
14-
"Returns the current system date and time in a friendly, human-readable format.",
15-
)
16-
})
17-
18-
it("should have optional timezone parameter", () => {
19-
expect(systemTime.parameters).toBeDefined()
20-
const shape = systemTime.parameters!.shape
21-
expect(shape.timezone).toBeDefined()
22-
expect(shape.timezone.isOptional()).toBe(true)
23-
})
24-
})
25-
2611
describe("execute", () => {
2712
it("should return a formatted date/time string", async () => {
2813
const result = await systemTime.execute({}, mockContext)
@@ -33,26 +18,5 @@ describe("system-time tool", () => {
3318
)
3419
expect(result).toMatch(/\d{1,2}:\d{2}:\d{2}/)
3520
})
36-
37-
it("should use system timezone when no timezone provided", async () => {
38-
const result = await systemTime.execute({}, mockContext)
39-
expect(result).toMatch(/[A-Z]{2,5}$/)
40-
})
41-
42-
it("should format with specified timezone", async () => {
43-
const result = await systemTime.execute({ timezone: "UTC" }, mockContext)
44-
expect(result).toMatch(/^The current date and time is:/)
45-
expect(result).toMatch(/UTC/)
46-
})
47-
48-
it("should work with different timezone formats", async () => {
49-
const result = await systemTime.execute({ timezone: "America/New_York" }, mockContext)
50-
expect(result).toMatch(/^The current date and time is:/)
51-
expect(result).toMatch(/(EST|EDT)/)
52-
})
53-
54-
it("should throw error for invalid timezone", async () => {
55-
await expect(systemTime.execute({ timezone: "Invalid/Timezone" }, mockContext)).rejects.toThrow()
56-
})
5721
})
5822
})

.roo/tools/system-time.ts

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
1-
import { defineCustomTool, parametersSchema } from "@roo-code/types"
1+
import { parametersSchema, defineCustomTool } from "@roo-code/types"
22

3-
/**
4-
* A simple custom tool that returns the current date and time in a friendly format.
5-
*
6-
* To create your own custom tools:
7-
* 1. Install @roo-code/types: npm install @roo-code/types
8-
* 2. Create a .ts file in .roo/tools/
9-
* 3. Export a default tool definition using defineCustomTool()
10-
*
11-
* Note that `parametersSchema` is just an alias for `z` (from zod).
12-
*/
133
export default defineCustomTool({
14-
name: "system-time",
4+
name: "system_time",
155
description: "Returns the current system date and time in a friendly, human-readable format.",
16-
parameters: parametersSchema.object({
17-
timezone: parametersSchema
18-
.string()
19-
.optional()
20-
.describe("Optional timezone to display the time in (e.g., 'America/New_York', 'Europe/London')"),
21-
}),
22-
async execute(args) {
23-
const options: Intl.DateTimeFormatOptions = {
6+
parameters: parametersSchema.object({}),
7+
async execute() {
8+
const systemTime = new Date().toLocaleString("en-US", {
249
weekday: "long",
2510
year: "numeric",
2611
month: "long",
@@ -29,15 +14,9 @@ export default defineCustomTool({
2914
minute: "2-digit",
3015
second: "2-digit",
3116
timeZoneName: "short",
32-
}
17+
timeZone: "America/Los_Angeles",
18+
})
3319

34-
if (args.timezone) {
35-
options.timeZone = args.timezone
36-
}
37-
38-
const now = new Date()
39-
const formatted = now.toLocaleString("en-US", options)
40-
41-
return `The current date and time is: ${formatted}`
20+
return `The current date and time is: ${systemTime}`
4221
},
4322
})

packages/core/src/custom-tools/__tests__/__snapshots__/format-native.spec.ts.snap

Lines changed: 0 additions & 59 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/src/custom-tools/__tests__/fixtures/system-time.ts

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

packages/core/src/custom-tools/__tests__/format-native.spec.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import cachedTool from "./fixtures/cached.js"
1010
import legacyTool from "./fixtures/legacy.js"
1111
import { toolA, toolB } from "./fixtures/multi.js"
1212
import { validTool as mixedValidTool } from "./fixtures/mixed.js"
13-
import systemTimeTool from "./fixtures/system-time.js"
1413

1514
const fixtureTools = {
1615
simple: simpleTool,
@@ -19,7 +18,6 @@ const fixtureTools = {
1918
multi_toolA: toolA,
2019
multi_toolB: toolB,
2120
mixed_validTool: mixedValidTool,
22-
systemTime: systemTimeTool,
2321
}
2422

2523
describe("formatNative", () => {
@@ -244,12 +242,6 @@ describe("Native Protocol snapshots", () => {
244242
expect(result).toMatchSnapshot()
245243
})
246244

247-
it("should generate correct native definition for system time tool", () => {
248-
const serialized = serializeCustomTool(fixtureTools.systemTime)
249-
const result = formatNative(serialized)
250-
expect(result).toMatchSnapshot()
251-
})
252-
253245
it("should generate correct native definitions for all fixtures combined", () => {
254246
const allSerialized = Object.values(fixtureTools).map(serializeCustomTool)
255247
const result = allSerialized.map(formatNative)

0 commit comments

Comments
 (0)