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(metaharness): _harness.mjs npx invocation + mint cwd-based scaffolding (iter 27)

ruvf5036f54b626
diff --git a/plugins/ruflo-metaharness/scripts/_harness.mjs b/plugins/ruflo-metaharness/scripts/_harness.mjs
index 38abcfac00..116873c531 100755
--- a/plugins/ruflo-metaharness/scripts/_harness.mjs
+++ b/plugins/ruflo-metaharness/scripts/_harness.mjs
@@ -20,15 +20,26 @@ import { spawnSync } from 'node:child_process';
const DEFAULT_TIMEOUT_MS = 60_000;
-function execCli(bin, args, opts = {}) {
+// ITER 27 β€” npx invocation hardening.
+// The pre-iter-27 implementation passed `'-y metaharness@latest'` as a
+// SINGLE argv element to npx (`spawnSync('npx', [bin, ...argv])` where
+// bin contained two whitespace-separated tokens). spawnSync with
+// shell:false does no word-splitting, so npx received a literal string
+// with an embedded space and either failed silently or treated the
+// whole thing as a package name. The graceful-degradation path then
+// reported `degraded: true` for every skill β€” masking the bug. Every
+// argv token must now be its own array element.
+function execCli(npxArgs, opts = {}) {
const start = Date.now();
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
const wantJson = opts.json !== false;
- const argv = wantJson && !args.includes('--json') ? [...args, '--json'] : [...args];
- const r = spawnSync('npx', [bin, ...argv], {
+ const argv = wantJson && !npxArgs.includes('--json') ? [...npxArgs, '--json'] : [...npxArgs];
+ const r = spawnSync('npx', argv, {
stdio: ['ignore', 'pipe', 'pipe'],
encoding: 'utf-8',
timeout: timeoutMs,
+ cwd: opts.cwd, // iter 27 β€” let callers redirect $CWD (mint.mjs needs this)
+ env: { ...process.env, ...(opts.env || {}) },
shell: process.platform === 'win32',
});
const durationMs = Date.now() - start;
@@ -54,7 +65,9 @@ function execCli(bin, args, opts = {}) {
}
export function runMetaharness(args, opts) {
- return execCli('-y metaharness@latest', args, opts);
+ // iter 27 β€” explicit argv tokens (was: '-y metaharness@latest' as one
+ // string, which silently degraded every skill).
+ return execCli(['-y', 'metaharness@latest', ...args], opts);
}
export function runHarness(args, opts) {
@@ -69,6 +82,8 @@ export function runHarness(args, opts) {
stdio: ['ignore', 'pipe', 'pipe'],
encoding: 'utf-8',
timeout: timeoutMs,
+ cwd: opts?.cwd, // iter 27 β€” same cwd-redirect support as runMetaharness
+ env: { ...process.env, ...(opts?.env || {}) },
shell: process.platform === 'win32',
});
const durationMs = Date.now() - start;
diff --git a/plugins/ruflo-metaharness/scripts/mint.mjs b/plugins/ruflo-metaharness/scripts/mint.mjs
index 4843791e6d..da70020ad4 100755
--- a/plugins/ruflo-metaharness/scripts/mint.mjs
+++ b/plugins/ruflo-metaharness/scripts/mint.mjs
@@ -16,8 +16,8 @@
// # β†’ actually scaffolds
import { runMetaharness, emitDegradedJsonAndExit } from './_harness.mjs';
-import { existsSync } from 'node:fs';
-import { resolve } from 'node:path';
+import { existsSync, mkdirSync } from 'node:fs';
+import { resolve, dirname, basename } from 'node:path';
import { tmpdir } from 'node:os';
const ARGS = (() => {
@@ -84,7 +84,20 @@ function main() {
console.error(`mint: target ${ARGS.target} already exists`);
process.exit(2);
}
- const r = runMetaharness(['new', ARGS.name, '--template', ARGS.template, '--host', ARGS.host, '--target', ARGS.target, '--yes'], { json: false });
+ // ITER 27 FIX β€” the metaharness CLI's --target flag is ignored at
+ // runtime: `metaharness new <name>` writes to $CWD/<name> regardless
+ // of --target (verified against [email protected], 2026-06-16). The
+ // safety check above resolves ARGS.target outside the calling repo;
+ // we now point the subprocess CWD at target's parent + pass
+ // basename(target) as the CLI-side name, so the scaffold lands at
+ // exactly ARGS.target.
+ const parentDir = dirname(ARGS.target);
+ const cliName = basename(ARGS.target);
+ mkdirSync(parentDir, { recursive: true });
+ const r = runMetaharness(
+ ['new', cliName, '--template', ARGS.template, '--host', ARGS.host],
+ { json: false, cwd: parentDir, timeoutMs: 180_000 },
+ );
if (r.degraded) { emitDegradedJsonAndExit(r.reason); return; }
if (r.exitCode !== 0) {
console.error(`mint: metaharness exited ${r.exitCode}`);