🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix(cli-core): measure JSON memory size in UTF-8 bytes
Rudy Celeklic7314d700a31
diff --git a/tests/json-memory-size.test.mjs b/tests/json-memory-size.test.mjsnew file mode 100644index 0000000000..61f12ebcca--- /dev/null+++ b/tests/json-memory-size.test.mjs@@ -0,0 +1,10 @@+import test from 'node:test';+import assert from 'node:assert/strict';+import { mkdtempSync, rmSync, statSync } from 'node:fs';+import { join } from 'node:path';+import { tmpdir } from 'node:os';+import { JsonMemoryBackend } from '../v3/@claude-flow/cli-core/src/memory/json-backend.ts';+for (const value of ['plain ASCII', '東京🙂'.repeat(100)]) test(`sizeBytes matches actual UTF-8 file size for ${value.slice(0, 8)}`, async () => {+ const dir = mkdtempSync(join(tmpdir(), 'json-size-')); const path = join(dir, 'memory.json');+ try { const b = new JsonMemoryBackend({ path }); await b.store('key', value); assert.equal((await b.stats()).sizeBytes, statSync(path).size); } finally { rmSync(dir, { recursive: true, force: true }); }+});diff --git a/v3/@claude-flow/cli-core/src/memory/json-backend.ts b/v3/@claude-flow/cli-core/src/memory/json-backend.tsindex 50fe873ec2..cb16c3c660 100644--- a/v3/@claude-flow/cli-core/src/memory/json-backend.ts+++ b/v3/@claude-flow/cli-core/src/memory/json-backend.ts@@ -193,7 +193,7 @@ export class JsonMemoryBackend implements MemoryBackend {const entries = Object.values(state.entries);const namespaces = [...new Set(entries.map((e) => e.namespace))].sort();const sizeBytes = existsSync(this.path)- ? readFileSync(this.path, 'utf-8').length+ ? Buffer.byteLength(readFileSync(this.path, 'utf-8'), 'utf-8'): 0;return {totalEntries: entries.length,