π 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(hooks): reconcile diverged CLI-package helper copies (FIX 2/4/5)
tjaiyene7783f2f0e8f
diff --git a/v3/@claude-flow/cli/.claude/helpers/auto-memory-hook.mjs b/v3/@claude-flow/cli/.claude/helpers/auto-memory-hook.mjsindex 3b3881bb0f..94c4574147 100755--- a/v3/@claude-flow/cli/.claude/helpers/auto-memory-hook.mjs+++ b/v3/@claude-flow/cli/.claude/helpers/auto-memory-hook.mjs@@ -31,6 +31,27 @@ const log = (msg) => console.log(`${CYAN}[AutoMemory] ${msg}${RESET}`);const success = (msg) => console.log(`${GREEN}[AutoMemory] β ${msg}${RESET}`);const dim = (msg) => console.log(` ${DIM}${msg}${RESET}`);+const DEBUG = !!(process.env.RUFLO_DEBUG || process.env.DEBUG);++// ββ Graceful shutdown (FIX 3) βββββββββββββββββββββββββββββββββββββββββββββββ+// Track the backend in use so a SIGTERM/SIGINT mid-run can still flush it+// (the JSON backend persists; a SQLite-backed one closes/flushes WAL) instead+// of leaving a half-written store or a stale lock behind.+let activeBackend = null;+let shuttingDown = false;+function trackBackend(b) { activeBackend = b; return b; }+async function gracefulExit(signal) {+ if (shuttingDown) return;+ shuttingDown = true;+ if (DEBUG) process.stderr.write(`[AutoMemory] received ${signal}, flushing backend before exit\n`);+ try {+ if (activeBackend && typeof activeBackend.shutdown === 'function') await activeBackend.shutdown();+ } catch { /* best effort β never block exit on cleanup */ }+ process.exit(0);+}+process.on('SIGTERM', () => { gracefulExit('SIGTERM'); });+process.on('SIGINT', () => { gracefulExit('SIGINT'); });+// Ensure data dirif (!existsSync(DATA_DIR)) mkdirSync(DATA_DIR, { recursive: true });@@ -219,7 +240,7 @@ async function doImport() {}const config = readConfig();- const backend = new JsonFileBackend(STORE_PATH);+ const backend = trackBackend(new JsonFileBackend(STORE_PATH));await backend.initialize();const bridgeConfig = {@@ -272,7 +293,7 @@ async function doSync() {}const config = readConfig();- const backend = new JsonFileBackend(STORE_PATH);+ const backend = trackBackend(new JsonFileBackend(STORE_PATH));await backend.initialize();const entryCount = await backend.count();@@ -348,8 +369,17 @@ async function doStatus() {const command = process.argv[2] || 'status';-// Suppress unhandled rejection warnings from dynamic import() failures-process.on('unhandledRejection', () => {});+// Dynamic import() failures can surface as unhandled rejections on a later+// microtask even when the awaiting call site already caught them, which would+// otherwise force a non-zero exit. Swallow to keep hooks exit-0, but surface the+// reason under RUFLO_DEBUG/DEBUG so genuine async bugs aren't silently hidden+// (FIX 2 β the previous `() => {}` discarded every rejection process-wide).+process.on('unhandledRejection', (reason) => {+ if (DEBUG) {+ const detail = reason && reason.message ? reason.message : String(reason);+ process.stderr.write(`[AutoMemory] unhandledRejection (suppressed): ${detail}\n`);+ }+});try {switch (command) {diff --git a/v3/@claude-flow/cli/.claude/helpers/intelligence.cjs b/v3/@claude-flow/cli/.claude/helpers/intelligence.cjsindex e013264a94..f77fb58d8b 100644--- a/v3/@claude-flow/cli/.claude/helpers/intelligence.cjs+++ b/v3/@claude-flow/cli/.claude/helpers/intelligence.cjs@@ -318,7 +318,11 @@ function bootstrapFromMemoryFiles() {// For the projects dir, scope to CURRENT project only (not all 51+ dirs)if (base.endsWith('projects')) {try {- const projectSlug = cwd.replace(/^\//, '').replace(/\//g, '-');+ // Match Claude Code's project-dir slug: every non-alphanumeric char -> '-'+ // (e.g. "G:\\My Drive\\TJ_Vault" -> "G--My-Drive-TJ-Vault"). The old version+ // only handled POSIX '/', so on Windows the slug kept ':' and '\\' and never+ // matched the real <projects>/<slug>/memory dir β bootstrap found nothing (FIX 5).+ const projectSlug = cwd.replace(/[^a-zA-Z0-9]/g, '-');const memDir = path.join(base, projectSlug, 'memory');if (fs.existsSync(memDir)) {parseMemoryDir(memDir, entries);@@ -332,6 +336,16 @@ function bootstrapFromMemoryFiles() {return entries;}+// Truncation transparency (FIX 4): mark the cut with an ellipsis and warn under+// debug, so later reasoning isn't silently built on severed text.+const CLIP_DEBUG = !!(process.env.RUFLO_DEBUG || process.env.DEBUG);+function clip(text, max, label) {+ text = text == null ? '' : String(text);+ if (text.length <= max) return text;+ if (CLIP_DEBUG) process.stderr.write(`[INTELLIGENCE] WARN: truncated ${label || 'value'} from ${text.length} to ${max} chars\n`);+ return text.slice(0, max - 1) + 'β¦';+}+function parseMemoryDir(dir, entries) {try {const files = fs.readdirSync(dir).filter(f => f.endsWith('.md'));@@ -353,7 +367,7 @@ function parseMemoryDir(dir, entries) {entries.push({id,key: title.toLowerCase().replace(/[^a-z0-9]+/g, '-').slice(0, 50),- content: body.slice(0, 500),+ content: clip(body, 500, 'memory content'),summary: title,namespace: file === 'MEMORY.md' ? 'core' : file.replace('.md', ''),type: 'semantic',