Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 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

fix(cost-tracker): add Windows shim ruflo-hook.cjs (#1902/#1903/#1904, #2132)

ruv147145c8b8a1
diff --git a/plugins/ruflo-cost-tracker/scripts/ruflo-hook.cjs b/plugins/ruflo-cost-tracker/scripts/ruflo-hook.cjs
new file mode 100755
index 0000000000..86c911fbb0
--- /dev/null
+++ b/plugins/ruflo-cost-tracker/scripts/ruflo-hook.cjs
@@ -0,0 +1,56 @@
+#!/usr/bin/env node
+/**
+ * ruflo-hook.cjs β€” cross-platform Windows shim for cost-tracker's Stop hook (#2132)
+ *
+ * The cost-tracker hooks.json declares `"_platform": "posix"` because its
+ * Stop hook uses bash:
+ *
+ * /bin/bash -c 'TRACK_QUIET=1 node "${CLAUDE_PLUGIN_ROOT}/scripts/track.mjs" >/dev/null 2>&1 || true'
+ *
+ * On Windows, `ruflo init` writes a `.claude/settings.json` that overrides
+ * the Stop hook to invoke this shim instead β€” `node ruflo-hook.cjs` β€”
+ * so cost tracking continues to capture session data without bash.
+ *
+ * Behaviour mirrors the bash hook:
+ * 1. Reads hook event payload from stdin (best effort β€” discarded).
+ * 2. Spawns track.mjs with TRACK_QUIET=1 and swallows all output.
+ * 3. Always exits 0 β€” telemetry is best-effort, must NEVER block a turn.
+ * 4. Times out at 30s so a hung track.mjs can't stall session shutdown.
+ *
+ * Usage: node ruflo-hook.cjs [hook-args ignored]
+ */
+
+'use strict';
+
+const { spawnSync } = require('child_process');
+const fs = require('fs');
+const path = require('path');
+
+function done() {
+ process.exit(0);
+}
+
+// Best-effort drain of stdin so the pipe doesn't EPIPE on the parent
+try {
+ fs.readFileSync(0);
+} catch {
+ /* ignore */
+}
+
+// CLAUDE_PLUGIN_ROOT is set by Claude Code; fall back to this script's parent
+const pluginRoot = process.env.CLAUDE_PLUGIN_ROOT
+ || path.resolve(__dirname, '..');
+const trackScript = path.join(pluginRoot, 'scripts', 'track.mjs');
+
+if (!fs.existsSync(trackScript)) {
+ // Plugin layout drifted β€” exit clean, never block the turn
+ done();
+}
+
+spawnSync(process.execPath, [trackScript], {
+ env: { ...process.env, TRACK_QUIET: '1' },
+ stdio: 'ignore',
+ timeout: 30_000,
+});
+
+done();