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

Commit 021b4c5

Browse files
committed
Performance optimization
1 parent 18acb96 commit 021b4c5

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

packages/core/src/custom-tools/__tests__/custom-tool-registry.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// pnpm --filter @roo-code/core test src/custom-tools/__tests__/custom-tool-registry.spec.ts
2+
13
import path from "path"
24
import { fileURLToPath } from "url"
35

packages/core/src/custom-tools/custom-tool-registry.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export class CustomToolRegistry {
235235
const stat = fs.statSync(absolutePath)
236236
const cacheKey = `${absolutePath}:${stat.mtimeMs}`
237237

238-
// Check if we have a cached version.
238+
// Check if we have a cached version in memory.
239239
if (this.tsCache.has(cacheKey)) {
240240
const cachedPath = this.tsCache.get(cacheKey)!
241241
return import(`file://${cachedPath}`)
@@ -247,6 +247,12 @@ export class CustomToolRegistry {
247247
const hash = createHash("sha256").update(cacheKey).digest("hex").slice(0, 16)
248248
const tempFile = path.join(this.cacheDir, `${hash}.mjs`)
249249

250+
// Check if we have a cached version on disk (from a previous run/instance).
251+
if (fs.existsSync(tempFile)) {
252+
this.tsCache.set(cacheKey, tempFile)
253+
return import(`file://${tempFile}`)
254+
}
255+
250256
// Bundle the TypeScript file with dependencies using esbuild CLI.
251257
await runEsbuild(
252258
{

0 commit comments

Comments
 (0)