mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-24 14:16:34 +09:00
fix(cli): extract suppression to side-effect module imported FIRST
3.6.18 smoke test caught that the [AgentDB Patch] warning still leaked through the ruflo wrapper — even after iteration #11's "move to src/index.ts" attempt. Root cause: ES module imports hoist above any top-level code in the same module, so the inline suppression block ran AFTER `import { commands } from './commands/index.js'`, by which point agentic-flow had already been loaded transitively and emitted its warning. Fix: extracted the patch into `src/log-filters.ts` as a side-effect module and imported it as the FIRST import statement in src/index.ts: import './log-filters.js'; // ← evaluated first in import graph import { readFileSync } from 'fs'; import { commands } from './commands/index.js'; ... ES module evaluation order is the source order of imports, so log-filters.js runs its side effect (patches console.warn/log) before any sibling import can transitively load agentic-flow. bin/cli.js and bin/mcp-server.js keep their inline suppression as defense-in-depth (covers cases where the bin file's own crypto/etc. imports run before src/index.js loads). Verified via ruflo wrapper: $ node ruflo/bin/ruflo.js --version ruflo v3.6.18 # no warning prefix anymore Co-Authored-By: RuFlo <ruv@ruv.net>
This commit is contained in:
1 parent
28fed919bd
commit
aeeeff72f5
2 files changed
+42
-25
No files matched your search
@@ -5,31 +5,13 @@
|
||||
* Created with ❤️ by ruv.io
|
||||
*/
|
||||
|
||||
// MUST run before any agentic-flow / agentdb imports — this file is
|
||||
// imported by every entry point (bin/cli.js, ruflo/bin/ruflo.js via
|
||||
// dist/src/index.js, and tests). Patching the console here ensures the
|
||||
// suppression applies regardless of how the CLI was invoked. Previously
|
||||
// the suppression lived only in bin/cli.js, so the ruflo wrapper (which
|
||||
// imports dist/src/index.js directly) leaked the cosmetic warning.
|
||||
//
|
||||
// Tight match: requires BOTH "[AgentDB Patch]" AND "Controller index not
|
||||
// found" so other [AgentDB Patch] messages (real issues) still flow.
|
||||
{
|
||||
const _isCosmeticAgentdbPatchNoise = (msg: unknown): boolean => {
|
||||
const s = String(msg ?? '');
|
||||
return s.includes('[AgentDB Patch]') && s.includes('Controller index not found');
|
||||
};
|
||||
const _origWarn = console.warn.bind(console);
|
||||
const _origLog = console.log.bind(console);
|
||||
console.warn = (...args: unknown[]) => {
|
||||
if (_isCosmeticAgentdbPatchNoise(args[0])) return;
|
||||
_origWarn(...args);
|
||||
};
|
||||
console.log = (...args: unknown[]) => {
|
||||
if (_isCosmeticAgentdbPatchNoise(args[0])) return;
|
||||
_origLog(...args);
|
||||
};
|
||||
}
|
||||
// MUST be the first import — installs console filter for the cosmetic
|
||||
// "[AgentDB Patch] Controller index not found" warning before any
|
||||
// agentic-flow / agentdb code can load. ES module imports are evaluated
|
||||
// in source order, so this file runs its side effects before any other
|
||||
// import in this module's import graph (including transitive imports of
|
||||
// agentic-flow via commands/index.js).
|
||||
import './log-filters.js';
|
||||
|
||||
import { readFileSync } from 'fs';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Console filter for the cosmetic "[AgentDB Patch] Controller index not found"
|
||||
* warning emitted by agentic-flow's runtime patch (it expects agentdb v1.x
|
||||
* layout but we use v3). This file MUST be imported as the first side-effect
|
||||
* import in any entry point so the patch is in place before agentic-flow
|
||||
* (and anything that transitively imports it) loads.
|
||||
*
|
||||
* The previous attempt put the suppression as a top-level code block inside
|
||||
* src/index.ts, but ES module imports are evaluated before the file's own
|
||||
* top-level code, so transitive imports of agentic-flow were still
|
||||
* triggering the warning before the suppression took effect. A dedicated
|
||||
* side-effect module imported FIRST avoids that.
|
||||
*
|
||||
* Tight match: requires BOTH "[AgentDB Patch]" AND "Controller index not
|
||||
* found". Other [AgentDB Patch] messages (real issues) flow through.
|
||||
* Audit log audit_1776483149979 flagged the previous broad filter as too
|
||||
* aggressive — this one is tight enough to be safe.
|
||||
*/
|
||||
|
||||
const isCosmeticAgentdbPatchNoise = (msg: unknown): boolean => {
|
||||
const s = String(msg ?? '');
|
||||
return s.includes('[AgentDB Patch]') && s.includes('Controller index not found');
|
||||
};
|
||||
|
||||
const origWarn = console.warn.bind(console);
|
||||
const origLog = console.log.bind(console);
|
||||
|
||||
console.warn = (...args: unknown[]) => {
|
||||
if (isCosmeticAgentdbPatchNoise(args[0])) return;
|
||||
origWarn(...args);
|
||||
};
|
||||
console.log = (...args: unknown[]) => {
|
||||
if (isCosmeticAgentdbPatchNoise(args[0])) return;
|
||||
origLog(...args);
|
||||
};
|
||||
Reference in new issue
Block a user