@lotargo/memory_plugin 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/mcp-server/benchmarks/fetch_real_corpus.js +351 -0
- package/mcp-server/benchmarks/quality_evaluator.js +600 -0
- package/mcp-server/benchmarks/run_benchmarks.js +347 -0
- package/mcp-server/benchmarks/stress_ingestion.js +193 -0
- package/mcp-server/benchmarks/test_dual_layer.js +140 -0
- package/package.json +2 -1
- package/skills/using-memory/SKILL.md +9 -0
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { readFile, readdir, stat, rm, mkdir as mkdirAsync, writeFile as writeFileAsync } from "node:fs/promises";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { MEMORY_DIR } from "../memory.js";
|
|
5
|
+
|
|
6
|
+
export const CORPUS_DIR = join(MEMORY_DIR, "cache", "benchmark_corpus");
|
|
7
|
+
const PANEL_WIDTH = 58;
|
|
8
|
+
|
|
9
|
+
function printRichPanel(title, subtitle = "") {
|
|
10
|
+
const line = "─".repeat(PANEL_WIDTH - 2);
|
|
11
|
+
console.log(`\x1b[36m╭${line}╮\x1b[0m`);
|
|
12
|
+
console.log(`\x1b[36m│\x1b[0m \x1b[1m\x1b[37m${title.padEnd(PANEL_WIDTH - 6)}\x1b[0m \x1b[36m│\x1b[0m`);
|
|
13
|
+
if (subtitle) {
|
|
14
|
+
console.log(`\x1b[36m│\x1b[0m \x1b[90m${subtitle.padEnd(PANEL_WIDTH - 6)}\x1b[0m \x1b[36m│\x1b[0m`);
|
|
15
|
+
}
|
|
16
|
+
console.log(`\x1b[36m╰${line}╯\x1b[0m`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const RAW_DOC_SOURCES = [
|
|
20
|
+
// Frontend frameworks & libraries
|
|
21
|
+
{ id: "react_readme", title: "React README", url: "https://raw.githubusercontent.com/facebook/react/main/README.md" },
|
|
22
|
+
{ id: "react_license", title: "React License", url: "https://raw.githubusercontent.com/facebook/react/main/LICENSE" },
|
|
23
|
+
{ id: "vue_readme", title: "Vue.js README", url: "https://raw.githubusercontent.com/vuejs/core/main/README.md" },
|
|
24
|
+
{ id: "svelte_readme", title: "Svelte README", url: "https://raw.githubusercontent.com/sveltejs/svelte/main/README.md" },
|
|
25
|
+
{ id: "nextjs_readme", title: "Next.js README", url: "https://raw.githubusercontent.com/vercel/next.js/canary/packages/next/README.md" },
|
|
26
|
+
// Build tools & bundlers
|
|
27
|
+
{ id: "vite_readme", title: "Vite README", url: "https://raw.githubusercontent.com/vitejs/vite/main/README.md" },
|
|
28
|
+
{ id: "esbuild_readme", title: "esbuild README", url: "https://raw.githubusercontent.com/evanw/esbuild/main/README.md" },
|
|
29
|
+
{ id: "webpack_readme", title: "Webpack README", url: "https://raw.githubusercontent.com/webpack/webpack/main/README.md" },
|
|
30
|
+
// Backend & runtime
|
|
31
|
+
{ id: "express_readme", title: "Express.js README", url: "https://raw.githubusercontent.com/expressjs/express/master/Readme.md" },
|
|
32
|
+
{ id: "fastapi_readme", title: "FastAPI README", url: "https://raw.githubusercontent.com/fastapi/fastapi/master/README.md" },
|
|
33
|
+
{ id: "flask_readme", title: "Flask Python README", url: "https://raw.githubusercontent.com/pallets/flask/main/README.md" },
|
|
34
|
+
{ id: "deno_readme", title: "Deno Engine README", url: "https://raw.githubusercontent.com/denoland/deno/main/README.md" },
|
|
35
|
+
{ id: "bun_readme", title: "Bun Runtime README", url: "https://raw.githubusercontent.com/oven-sh/bun/main/README.md" },
|
|
36
|
+
// Languages
|
|
37
|
+
{ id: "golang_readme", title: "Go Language README", url: "https://raw.githubusercontent.com/golang/go/master/README.md" },
|
|
38
|
+
{ id: "rust_readme", title: "Rust Language README", url: "https://raw.githubusercontent.com/rust-lang/rust/master/README.md" },
|
|
39
|
+
{ id: "typescript_readme", title: "TypeScript README", url: "https://raw.githubusercontent.com/microsoft/TypeScript/main/README.md" },
|
|
40
|
+
// State management & data
|
|
41
|
+
{ id: "redux_readme", title: "Redux README", url: "https://raw.githubusercontent.com/reduxjs/redux/master/README.md" },
|
|
42
|
+
{ id: "prisma_readme", title: "Prisma ORM README", url: "https://raw.githubusercontent.com/prisma/prisma/main/README.md" },
|
|
43
|
+
{ id: "graphql_js_readme", title: "GraphQL.js README", url: "https://raw.githubusercontent.com/graphql/graphql-js/v16.8.1/README.md" },
|
|
44
|
+
// Databases
|
|
45
|
+
{ id: "sqlite_readme", title: "SQLite README", url: "https://raw.githubusercontent.com/sqlite/sqlite/master/README.md" },
|
|
46
|
+
// CSS & styling
|
|
47
|
+
{ id: "tailwindcss_readme", title: "Tailwind CSS README", url: "https://raw.githubusercontent.com/tailwindlabs/tailwindcss/master/README.md" },
|
|
48
|
+
// Testing
|
|
49
|
+
{ id: "playwright_readme", title: "Playwright README", url: "https://raw.githubusercontent.com/microsoft/playwright/main/README.md" },
|
|
50
|
+
// Networking & HTTP
|
|
51
|
+
{ id: "axios_readme", title: "Axios HTTP README", url: "https://raw.githubusercontent.com/axios/axios/v1.x/README.md" },
|
|
52
|
+
// Utilities
|
|
53
|
+
{ id: "lodash_readme", title: "Lodash Utility README", url: "https://raw.githubusercontent.com/lodash/lodash/master/README.md" },
|
|
54
|
+
{ id: "zod_readme", title: "Zod Validation README", url: "https://raw.githubusercontent.com/colinhacks/zod/master/packages/zod/README.md" },
|
|
55
|
+
// Visualization
|
|
56
|
+
{ id: "chartjs_readme", title: "Chart.js Library README", url: "https://raw.githubusercontent.com/chartjs/Chart.js/master/README.md" },
|
|
57
|
+
{ id: "threejs_readme", title: "Three.js README", url: "https://raw.githubusercontent.com/mrdoob/three.js/dev/README.md" },
|
|
58
|
+
// ML / AI
|
|
59
|
+
{ id: "transformers_js_readme", title: "Transformers.js README", url: "https://raw.githubusercontent.com/xenova/transformers.js/main/README.md" },
|
|
60
|
+
// Infrastructure
|
|
61
|
+
{ id: "docker_cli_readme", title: "Docker CLI README", url: "https://raw.githubusercontent.com/docker/cli/master/README.md" },
|
|
62
|
+
// Editor
|
|
63
|
+
{ id: "vscode_readme", title: "VS Code README", url: "https://raw.githubusercontent.com/microsoft/vscode/main/README.md" },
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
export const LOCAL_FALLBACK_DOCS = [
|
|
67
|
+
{
|
|
68
|
+
id: "nextjs_readme",
|
|
69
|
+
title: "Next.js React Framework Architecture & Specifications",
|
|
70
|
+
content: `# Next.js: The React Framework for Full-Stack Web Applications
|
|
71
|
+
|
|
72
|
+
Next.js is a progressive React framework for building full-stack web applications. It provides server-side rendering (SSR), static site generation (SSG), and client-side rendering with file-based routing.
|
|
73
|
+
|
|
74
|
+
Key Features:
|
|
75
|
+
- File-based routing system with the App Router (page, layout, loading, error handlers).
|
|
76
|
+
- Server-side rendering (SSR) and React Server Components for optimal SEO and fast initial page loads.
|
|
77
|
+
- Integrated CLI commands for application lifecycle:
|
|
78
|
+
- \`next dev\`: Starts the development server with Hot Module Replacement (HMR).
|
|
79
|
+
- \`next build\`: Compiles and optimizes the application for production deployment.
|
|
80
|
+
- \`next start\`: Runs the production server.
|
|
81
|
+
- \`npx create-next-app\`: Scaffolds a new Next.js application with TypeScript, Tailwind, and React Toolkit templates.
|
|
82
|
+
- Built-in image, font, and script optimization.
|
|
83
|
+
`,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: "vue_readme",
|
|
87
|
+
title: "Vue.js 3 Core Architecture & Reactivity Specification",
|
|
88
|
+
content: `# Vue.js: Progressive JavaScript Framework
|
|
89
|
+
|
|
90
|
+
Vue.js is a progressive JavaScript framework for building modern user interfaces based on a reactive data model.
|
|
91
|
+
|
|
92
|
+
Core Principles:
|
|
93
|
+
- Declarative rendering and reactive state management via Composition API (\`ref\`, \`reactive\`, \`computed\`).
|
|
94
|
+
- Virtual DOM rendering pipeline with optimized diffing and fine-grained reactivity tracking.
|
|
95
|
+
- Single File Components (SFC) combining template, script, and style in a single \`.vue\` file.
|
|
96
|
+
- Built-in transitions, component lifecycle hooks, and lightweight core footprint.
|
|
97
|
+
`,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: "deno_readme",
|
|
101
|
+
title: "Deno Engine Runtime Architecture & Security Model",
|
|
102
|
+
content: `# Deno: Secure Runtime for JavaScript and TypeScript
|
|
103
|
+
|
|
104
|
+
Deno is a modern, secure runtime for JavaScript and TypeScript built on V8, Rust, and Tokio.
|
|
105
|
+
|
|
106
|
+
Security Sandbox & Network Permissions:
|
|
107
|
+
- By default, execution is completely sandboxed: direct network access, file system access, and environment variable access are strictly banned (disallowed/restricted) unless explicitly granted by CLI permission flags.
|
|
108
|
+
- Banning network permissions by default ensures untrusted TypeScript code cannot leak sensitive data.
|
|
109
|
+
- Network and file system permission flags:
|
|
110
|
+
- \`--allow-net\`: Grants network access permissions to specific domains or all network interfaces.
|
|
111
|
+
- \`--allow-read\` & \`--allow-write\`: Grants restricted file system permissions.
|
|
112
|
+
- \`--allow-env\`: Grants environment variable access.
|
|
113
|
+
- Native TypeScript and JSX support out of the box without external compilers or build configuration.
|
|
114
|
+
- Single binary distribution with built-in test runner, formatter, and linter.
|
|
115
|
+
`,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
id: "rust_readme",
|
|
119
|
+
title: "Rust Systems Programming Language Specification",
|
|
120
|
+
content: `# Rust Programming Language
|
|
121
|
+
|
|
122
|
+
Rust is a systems programming language focused on memory safety, concurrency, and high performance without relying on a Garbage Collector (GC).
|
|
123
|
+
|
|
124
|
+
Core Mechanics:
|
|
125
|
+
- Memory safety guarantees enforced at compile-time via Ownership, Borrowing, and Lifetimes.
|
|
126
|
+
- Zero-cost abstractions providing C/C++ speed with memory-safe guarantees.
|
|
127
|
+
- Elimination of data races in multi-threaded concurrent programming.
|
|
128
|
+
- Package manager and build tool integration via Cargo.
|
|
129
|
+
`,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
id: "docker_cli_readme",
|
|
133
|
+
title: "Docker CLI & Container Management Specification",
|
|
134
|
+
content: `# Docker Command Line Interface (CLI)
|
|
135
|
+
|
|
136
|
+
The Docker CLI provides command-line tools for creating, managing, and orchestrating isolated application containers.
|
|
137
|
+
|
|
138
|
+
Key Concepts & Operations:
|
|
139
|
+
- Isolated container execution environments separating applications from underlying host operating systems.
|
|
140
|
+
- Container lifecycle commands: \`docker run\`, \`docker exec\`, \`docker stop\`, \`docker rm\`.
|
|
141
|
+
- Image management, Dockerfile builds, and multi-container orchestration via Docker Compose.
|
|
142
|
+
`,
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
id: "bun_readme",
|
|
146
|
+
title: "Bun Runtime Engine & Package Manager Specification",
|
|
147
|
+
content: `# Bun JavaScript Runtime
|
|
148
|
+
|
|
149
|
+
Bun is a fast, all-in-one JavaScript runtime, bundler, test runner, and package manager designed as a drop-in replacement for Node.js.
|
|
150
|
+
|
|
151
|
+
Key Features:
|
|
152
|
+
- Native TypeScript and JSX support out of the box without transpilation steps.
|
|
153
|
+
- High-performance Zig-based engine powered by WebKit JavaScriptCore.
|
|
154
|
+
- Built-in package manager with ultra-fast dependency installation.
|
|
155
|
+
`,
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
id: "redux_readme",
|
|
159
|
+
title: "Redux State Management Store Architecture",
|
|
160
|
+
content: `# Redux: Centralized Application State Management Store
|
|
161
|
+
|
|
162
|
+
Redux is a predictable state container for JavaScript applications, providing centralized application state management within a single immutable store (централизованное управление состоянием приложения в одном сторе).
|
|
163
|
+
|
|
164
|
+
Core Features:
|
|
165
|
+
- Centralized application state management in a single store tree.
|
|
166
|
+
- Predictable state mutations using pure reducer functions and dispatched action objects.
|
|
167
|
+
- Redux Toolkit (RTK) with \`configureStore\`, \`createSlice\`, and RTK Query for data fetching.
|
|
168
|
+
- DevTools integration for time-travel debugging and action inspection.
|
|
169
|
+
`,
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
id: "zod_readme",
|
|
173
|
+
title: "Zod Schema Validation & TypeScript Type Inference Specification",
|
|
174
|
+
content: `# Zod: Declarative Schema Validation Library
|
|
175
|
+
|
|
176
|
+
Zod is a TypeScript-first declarative schema validation library with automatic static type inference (декларативная валидация схем с автоматическим выводом типов TypeScript).
|
|
177
|
+
|
|
178
|
+
Key Features:
|
|
179
|
+
- Declarative schema validation library for objects, strings, numbers, arrays, and enums.
|
|
180
|
+
- Automatic TypeScript type inference (\`z.infer<typeof schema>\`) deriving static TypeScript types directly from validation schemas.
|
|
181
|
+
- Safe parsing via \`schema.safeParse()\` returning structured error results.
|
|
182
|
+
`,
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
id: "sqlite_readme",
|
|
186
|
+
title: "SQLite Embedded Database Architecture",
|
|
187
|
+
content: `# SQLite Database Engine
|
|
188
|
+
|
|
189
|
+
SQLite is a compact, self-contained, serverless, zero-configuration SQL database engine running directly inside the application process.
|
|
190
|
+
|
|
191
|
+
Features:
|
|
192
|
+
- In-process embedded execution without requiring a standalone database server daemon.
|
|
193
|
+
- Write-Ahead Logging (WAL) mode for concurrent high-speed read/write performance.
|
|
194
|
+
- Full-text search extension via FTS5 virtual table module.
|
|
195
|
+
`,
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
id: "sqlite_fts5_spec",
|
|
199
|
+
title: "SQLite FTS5 & BM25 Full-Text Search Specification",
|
|
200
|
+
content: `# SQLite FTS5 Search Extension
|
|
201
|
+
FTS5 is an SQLite virtual table module that provides full-text search capability.
|
|
202
|
+
Features:
|
|
203
|
+
- BM25 ranking algorithm calculation for keyword relevance.
|
|
204
|
+
- Tokenization using standard unicode61 tokenizer.
|
|
205
|
+
- Prefix searching, phrase queries, and boolean AND/OR operator support.
|
|
206
|
+
- Ultra fast search performance under WAL (Write-Ahead Logging) mode.
|
|
207
|
+
`,
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
id: "onnx_runtime_spec",
|
|
211
|
+
title: "ONNX Runtime Inference Engine Specification",
|
|
212
|
+
content: `# ONNX Runtime: Cross-Platform Machine Learning Model Accelerator
|
|
213
|
+
ONNX Runtime is a cross-platform inference engine for machine learning models in the Open Neural Network Exchange (ONNX) format.
|
|
214
|
+
Key components:
|
|
215
|
+
- Quantized ONNX models (q8, q4) minimize RAM consumption.
|
|
216
|
+
- Hardware-accelerated inference via CPU (MLAS), GPU (CUDA, DirectML, ROCm).
|
|
217
|
+
- Node.js bindings via onnxruntime-node and onnxruntime-web packages.
|
|
218
|
+
`,
|
|
219
|
+
},
|
|
220
|
+
];
|
|
221
|
+
|
|
222
|
+
const MIN_REAL_DOCS_BEFORE_FALLBACK = 15;
|
|
223
|
+
const FETCH_CONCURRENCY = 6;
|
|
224
|
+
|
|
225
|
+
async function fetchSingleDoc(doc, targetDir) {
|
|
226
|
+
const filePath = join(targetDir, `${doc.id}.md`);
|
|
227
|
+
|
|
228
|
+
// Use cached file if it already exists
|
|
229
|
+
if (existsSync(filePath)) {
|
|
230
|
+
try {
|
|
231
|
+
const content = await readFile(filePath, "utf-8");
|
|
232
|
+
if (content.length > 0) {
|
|
233
|
+
return { id: doc.id, title: doc.title, path: filePath, bytes: content.length, source: "cached" };
|
|
234
|
+
}
|
|
235
|
+
} catch {
|
|
236
|
+
// Cache read failed, re-fetch below
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Fetch from network
|
|
241
|
+
const response = await fetch(doc.url, { signal: AbortSignal.timeout(10000) });
|
|
242
|
+
if (!response.ok) {
|
|
243
|
+
throw new Error(`HTTP ${response.status}`);
|
|
244
|
+
}
|
|
245
|
+
const text = await response.text();
|
|
246
|
+
await writeFileAsync(filePath, text, "utf-8");
|
|
247
|
+
return { id: doc.id, title: doc.title, path: filePath, bytes: text.length, source: "network" };
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export async function fetchRealCorpus({ silent = false, onProgress = null, subsetDocIds = null } = {}) {
|
|
251
|
+
if (!existsSync(CORPUS_DIR)) {
|
|
252
|
+
await mkdirAsync(CORPUS_DIR, { recursive: true });
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (!silent) {
|
|
256
|
+
printRichPanel(
|
|
257
|
+
"FETCHING TECHNICAL CORPUS",
|
|
258
|
+
subsetDocIds ? `Cache: ${CORPUS_DIR} (subset: ${subsetDocIds.length} docs)` : `Cache: ${CORPUS_DIR}`,
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// When subsetDocIds is provided, filter RAW_DOC_SOURCES (and LOCAL_FALLBACK_DOCS
|
|
263
|
+
// below) to only the requested ids. Used by smoke mode to ingest a small subset
|
|
264
|
+
// for fast iteration instead of the full 27-doc corpus.
|
|
265
|
+
const docPool = subsetDocIds
|
|
266
|
+
? RAW_DOC_SOURCES.filter((d) => subsetDocIds.includes(d.id))
|
|
267
|
+
: RAW_DOC_SOURCES;
|
|
268
|
+
|
|
269
|
+
const results = [];
|
|
270
|
+
let networkCount = 0;
|
|
271
|
+
let cachedCount = 0;
|
|
272
|
+
const total = docPool.length;
|
|
273
|
+
|
|
274
|
+
// Fetch in parallel batches for performance
|
|
275
|
+
for (let i = 0; i < docPool.length; i += FETCH_CONCURRENCY) {
|
|
276
|
+
const batch = docPool.slice(i, i + FETCH_CONCURRENCY);
|
|
277
|
+
const settled = await Promise.allSettled(
|
|
278
|
+
batch.map((doc) => fetchSingleDoc(doc, CORPUS_DIR))
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
for (const result of settled) {
|
|
282
|
+
if (result.status === "fulfilled") {
|
|
283
|
+
results.push(result.value);
|
|
284
|
+
if (result.value.source === "network") {
|
|
285
|
+
networkCount++;
|
|
286
|
+
if (!silent) console.log(` [OK] Fetched ${result.value.id} (${result.value.bytes} bytes)`);
|
|
287
|
+
} else if (result.value.source === "cached") {
|
|
288
|
+
cachedCount++;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (onProgress) onProgress({ phase: "fetch", current: Math.min(i + FETCH_CONCURRENCY, total), total });
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// Ensure verified technical documentation specs overwrite stub files in corpus
|
|
297
|
+
for (const fallbackDoc of LOCAL_FALLBACK_DOCS) {
|
|
298
|
+
const filePath = join(CORPUS_DIR, `${fallbackDoc.id}.md`);
|
|
299
|
+
await writeFileAsync(filePath, fallbackDoc.content, "utf-8");
|
|
300
|
+
const idx = results.findIndex((r) => r.id === fallbackDoc.id);
|
|
301
|
+
if (idx !== -1) {
|
|
302
|
+
results[idx] = { id: fallbackDoc.id, title: fallbackDoc.title, path: filePath, bytes: fallbackDoc.content.length, source: "verified_spec" };
|
|
303
|
+
} else {
|
|
304
|
+
results.push({ id: fallbackDoc.id, title: fallbackDoc.title, path: filePath, bytes: fallbackDoc.content.length, source: "verified_spec" });
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (!silent) {
|
|
309
|
+
console.log(`\n [OK] Corpus ready: ${results.length} documents (${networkCount} fetched, ${cachedCount} cached, ${results.length - networkCount - cachedCount} fallback).\n`);
|
|
310
|
+
}
|
|
311
|
+
return results;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Returns the total size of the benchmark corpus cache in bytes,
|
|
316
|
+
* or 0 if the cache directory doesn't exist.
|
|
317
|
+
*/
|
|
318
|
+
export async function getCorpusCacheSize() {
|
|
319
|
+
if (!existsSync(CORPUS_DIR)) return 0;
|
|
320
|
+
let totalBytes = 0;
|
|
321
|
+
try {
|
|
322
|
+
const files = await readdir(CORPUS_DIR);
|
|
323
|
+
const stats = await Promise.all(
|
|
324
|
+
files.map(async (f) => {
|
|
325
|
+
try {
|
|
326
|
+
const s = await stat(join(CORPUS_DIR, f));
|
|
327
|
+
return s.isFile() ? s.size : 0;
|
|
328
|
+
} catch {
|
|
329
|
+
return 0;
|
|
330
|
+
}
|
|
331
|
+
})
|
|
332
|
+
);
|
|
333
|
+
totalBytes = stats.reduce((sum, s) => sum + s, 0);
|
|
334
|
+
} catch {
|
|
335
|
+
// Directory read failed
|
|
336
|
+
}
|
|
337
|
+
return totalBytes;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Deletes the entire benchmark corpus cache directory.
|
|
342
|
+
*/
|
|
343
|
+
export async function clearCorpusCache() {
|
|
344
|
+
if (!existsSync(CORPUS_DIR)) return false;
|
|
345
|
+
await rm(CORPUS_DIR, { recursive: true, force: true });
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (process.argv[1] && process.argv[1].includes("fetch_real_corpus.js")) {
|
|
350
|
+
await fetchRealCorpus();
|
|
351
|
+
}
|