@claude-flow/cli 3.16.3 → 3.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/src/commands/metaharness.d.ts.map +1 -1
  2. package/dist/src/commands/metaharness.js +9 -3
  3. package/dist/src/commands/metaharness.js.map +1 -1
  4. package/dist/src/mcp-tools/agentdb-tools.d.ts.map +1 -1
  5. package/dist/src/mcp-tools/agentdb-tools.js +52 -1
  6. package/dist/src/mcp-tools/agentdb-tools.js.map +1 -1
  7. package/dist/src/mcp-tools/browser-session-tools.d.ts +5 -1
  8. package/dist/src/mcp-tools/browser-session-tools.d.ts.map +1 -1
  9. package/dist/src/mcp-tools/browser-session-tools.js +92 -18
  10. package/dist/src/mcp-tools/browser-session-tools.js.map +1 -1
  11. package/dist/src/mcp-tools/hooks-tools.d.ts +1 -0
  12. package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
  13. package/dist/src/mcp-tools/hooks-tools.js +131 -0
  14. package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
  15. package/dist/src/mcp-tools/metaharness-tools.d.ts +7 -0
  16. package/dist/src/mcp-tools/metaharness-tools.d.ts.map +1 -1
  17. package/dist/src/mcp-tools/metaharness-tools.js +89 -0
  18. package/dist/src/mcp-tools/metaharness-tools.js.map +1 -1
  19. package/dist/src/mcp-tools/neural-tools.d.ts.map +1 -1
  20. package/dist/src/mcp-tools/neural-tools.js +119 -84
  21. package/dist/src/mcp-tools/neural-tools.js.map +1 -1
  22. package/dist/src/memory/memory-bridge.d.ts +15 -2
  23. package/dist/src/memory/memory-bridge.d.ts.map +1 -1
  24. package/dist/src/memory/memory-bridge.js +64 -10
  25. package/dist/src/memory/memory-bridge.js.map +1 -1
  26. package/dist/src/ruvector/output-verifier.d.ts +83 -0
  27. package/dist/src/ruvector/output-verifier.d.ts.map +1 -0
  28. package/dist/src/ruvector/output-verifier.js +277 -0
  29. package/dist/src/ruvector/output-verifier.js.map +1 -0
  30. package/dist/src/ruvector/trajectory-tree.d.ts +113 -0
  31. package/dist/src/ruvector/trajectory-tree.d.ts.map +1 -0
  32. package/dist/src/ruvector/trajectory-tree.js +237 -0
  33. package/dist/src/ruvector/trajectory-tree.js.map +1 -0
  34. package/dist/tsconfig.tsbuildinfo +1 -1
  35. package/package.json +5 -5
  36. package/plugins/ruflo-metaharness/README.md +2 -0
  37. package/plugins/ruflo-metaharness/agents/metaharness-architect.md +1 -1
  38. package/plugins/ruflo-metaharness/commands/ruflo-metaharness.md +5 -3
  39. package/plugins/ruflo-metaharness/scripts/_darwin.mjs +51 -41
  40. package/plugins/ruflo-metaharness/scripts/_harness.mjs +173 -104
  41. package/plugins/ruflo-metaharness/scripts/_invoke.mjs +231 -0
  42. package/plugins/ruflo-metaharness/scripts/_redblue.mjs +37 -70
  43. package/plugins/ruflo-metaharness/scripts/evolve.mjs +163 -3
  44. package/plugins/ruflo-metaharness/scripts/gepa.mjs +153 -0
  45. package/plugins/ruflo-metaharness/scripts/learn.mjs +127 -0
  46. package/plugins/ruflo-metaharness/scripts/smoke.sh +107 -51
  47. package/plugins/ruflo-metaharness/scripts/test-graceful-degradation.mjs +16 -0
  48. package/plugins/ruflo-metaharness/scripts/test-mcp-tools.mjs +24 -5
  49. package/plugins/ruflo-metaharness/skills/harness-evolve/SKILL.md +42 -3
  50. package/plugins/ruflo-metaharness/skills/harness-gepa/SKILL.md +65 -0
  51. package/plugins/ruflo-metaharness/skills/harness-learn/SKILL.md +65 -0
  52. package/plugins/ruflo-metaharness/skills/harness-mcp-scan/SKILL.md +3 -1
  53. package/plugins/ruflo-metaharness/skills/harness-score/SKILL.md +1 -1
  54. package/plugins/ruflo-metaharness/skills/harness-security-bench/SKILL.md +1 -1
  55. package/plugins/ruflo-metaharness/skills/harness-threat-model/SKILL.md +3 -1
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: harness-evolve
3
3
  description: Run `@metaharness/darwin evolve <repo>` to mutate a harness's seven policy surfaces (planner/contextBuilder/reviewer/retryPolicy/toolPolicy/memoryPolicy/scorePolicy), sandbox-score each variant, and promote only measured wins. The model is frozen; the harness evolves. Closes the loop ADR-150 opens (score+genome describe; evolve changes). Degrades gracefully when @metaharness/darwin is absent (ADR-150 + ADR-153 architectural constraints).
4
- argument-hint: "--repo <path> [--generations 3] [--children 3] [--concurrency 2] [--sandbox real|mock|agent] [--selection pareto|quality-diversity|...] [--mutator deterministic|ruvllm] [--confirm]"
4
+ argument-hint: "--repo <path> [--generations 3] [--children 3] [--concurrency 2] [--sandbox real|mock|agent] [--selection pareto|quality-diversity|...] [--mutator deterministic|ruvllm] [--diagnose] [--confirm]"
5
5
  allowed-tools: Bash
6
6
  ---
7
7
 
@@ -35,7 +35,7 @@ Implementation: [`scripts/evolve.mjs`](../../scripts/evolve.mjs).
35
35
  ≤ 20, `--concurrency` ≤ 8, sandbox/selection/mutator are known values).
36
36
  2. Without `--confirm`: print plan + exit 0 (mirrors `harness-mint` safety
37
37
  convention; defense in depth over the upstream `safety.ts` checks).
38
- 3. With `--confirm`: shell to `npx -y @metaharness/darwin@~0.3.1 metaharness-darwin evolve <repo> ...`
38
+ 3. With `--confirm`: shell to `npx -y @metaharness/darwin@~0.8.0 metaharness-darwin evolve <repo> ...`
39
39
  via the shared `_darwin.mjs` async helper. Per-generation progress is
40
40
  forwarded to stderr; final champion JSON is captured from stdout.
41
41
  4. Compute timeout from `generations × children × per-variant` (per-variant
@@ -73,7 +73,46 @@ Reports land under `<repo>/.metaharness/`:
73
73
  reports/winner.json # final champion + score delta vs parent
74
74
  ```
75
75
 
76
- Skill stdout = JSON `{success, data: {champion, plan, durationMs, improved}}`.
76
+ Skill stdout = JSON `{success, data: {champion, plan, durationMs, improved}}`
77
+ (plus `data.diagnosis` when `--diagnose` is passed — see below).
78
+
79
+ ## Failure diagnosis (`--diagnose`)
80
+
81
+ GEPA's key trick is natural-language failure diagnosis from execution traces
82
+ feeding the next mutation — not just scalar fitness. `--diagnose` adds a
83
+ modest slice of that: after the evolution completes, the losing / failed
84
+ variants' transcripts are run through darwin's GEPA library ops
85
+ (`analyzeTranscript` + `classifyFailure`, via the shared `importGepa`
86
+ resolver in `scripts/_darwin.mjs`) and a `diagnosis` section is appended to
87
+ the emitted JSON:
88
+
89
+ ```json
90
+ "diagnosis": {
91
+ "available": true,
92
+ "scope": "losing-variants",
93
+ "variants": [
94
+ { "id": "g1_v0", "transcripts": 2,
95
+ "failureClasses": { "exploration-loop": 1, "edit-mechanics": 1 },
96
+ "dominantClass": "exploration-loop" }
97
+ ],
98
+ "totals": { "exploration-loop": 1, "edit-mechanics": 1 }
99
+ }
100
+ ```
101
+
102
+ Upstream shape caveats (verified against `@metaharness/darwin@0.8.0`):
103
+
104
+ - `metaharness-darwin evolve --json` prints a TEXT leaderboard — the stdout
105
+ carries no JSON and no transcripts. Per-variant run records live at
106
+ `<repo>/.metaharness/runs/<id>.json`.
107
+ - Those run records hold sandbox exec traces (`{taskId, exitCode, stdout,
108
+ stderr}`), which are NOT GEPA `{actionRaw, obs}` transcripts. Diagnosis
109
+ therefore uses GEPA-shaped transcripts when a run record embeds them
110
+ (agent sandbox / future upstream), falls back to the champion's transcript,
111
+ and otherwise emits `diagnosis: {available: false, reason, traceSummary}`
112
+ where `traceSummary` is a mechanical per-variant tally (tasks / failed /
113
+ timedOut / blockedActions).
114
+ - `--diagnose` NEVER fails the run — any internal error degrades to
115
+ `{available: false, reason: "diagnosis-failed: ..."}`.
77
116
 
78
117
  ## Exit codes
79
118
 
@@ -0,0 +1,65 @@
1
+ ---
2
+ name: harness-gepa
3
+ description: Inspect and audit GEPA genomes via the `@metaharness/darwin/gepa` library entry (darwin 0.8.0) — load/validate a genome (default: the shipped cand-6 promotion), render the system prompt a genome compiles to, or classify failure modes in a run transcript. The `gepaOptimize` loop itself is library-only (bring your own evaluator) and not surfaced here — use `harness-evolve` for sandbox-scored evolution. Degrades gracefully when @metaharness/darwin is absent.
4
+ argument-hint: "--op genome|validate|render|analyze [--path <genome.json>] [--transcript <t.json>] [--alert-on-invalid]"
5
+ allowed-tools: Bash
6
+ ---
7
+
8
+ Surfaces the GEPA (genetic-evolution prompt-adaptation) *library* exports
9
+ from `@metaharness/darwin/gepa`. Unlike the other skills in this plugin
10
+ there is no CLI binary behind this — the script dynamic-imports the library
11
+ (local resolution first, versioned cache install as fallback) and calls the
12
+ subprocess-safe subset.
13
+
14
+ ## When to use
15
+
16
+ - **Adopting an evolved policy**: `--op render` shows the actual system
17
+ prompt a genome compiles to — read THAT, not the raw JSON, before
18
+ wiring a genome into a harness.
19
+ - **Auditing a promotion**: `--op genome` loads + validates the shipped
20
+ cand-6 genome (first holdout-confirmed cheap-tier promotion; provenance
21
+ ships in the package) or any genome file you point at.
22
+ - **CI gate on genome edits**: `--op validate --alert-on-invalid` exits 1
23
+ on structural errors.
24
+ - **Debugging a bad run**: `--op analyze --transcript run.json` classifies
25
+ failure modes (GEPA's failure-class taxonomy) from a transcript array.
26
+
27
+ ## What is deliberately NOT here
28
+
29
+ `gepaOptimize` — the optimization loop takes an in-process
30
+ `evaluate(candidate)` callback ("bring your own evaluator") that cannot
31
+ cross a subprocess boundary. Two supported paths instead:
32
+
33
+ 1. **Library consumers**: `import { gepaOptimize, loadCand6Genome } from '@metaharness/darwin/gepa'`
34
+ 2. **Sandbox-scored evolution**: `harness-evolve` (darwin CLI `evolve`),
35
+ which pairs GEPA with its own sandbox evaluators.
36
+
37
+ ## Algorithm
38
+
39
+ Implementation: [`scripts/gepa.mjs`](../../scripts/gepa.mjs).
40
+
41
+ 1. `import('@metaharness/darwin/gepa')`; on MODULE_NOT_FOUND fall back to a
42
+ one-time `npm install --prefix ~/.ruflo/darwin-cache-0.8.0` and import
43
+ the cached `dist/gepa/index.js` (versioned dir → pin bumps invalidate).
44
+ 2. Dispatch `--op`:
45
+ - `genome` → `loadGenome(fs, path)` or `loadCand6Genome()` + `validateGenome`
46
+ - `validate` → `validateGenome(rawJson)` (raw parse so broken files reach
47
+ the validator instead of throwing in the loader)
48
+ - `render` → `buildSystemFromGenome(genome, ext?, glob?)`
49
+ - `analyze` → `analyzeTranscript(entries)`
50
+ 3. Emit one JSON object; exit 0 (or 1 under `--alert-on-invalid`, 2 on bad input).
51
+
52
+ ## Examples
53
+
54
+ ```bash
55
+ node scripts/gepa.mjs --op genome # cand-6 + validation
56
+ node scripts/gepa.mjs --op render | jq -r .system # what does cand-6 SAY?
57
+ node scripts/gepa.mjs --op validate --path my-genome.json --alert-on-invalid
58
+ node scripts/gepa.mjs --op analyze --transcript run.json
59
+ ```
60
+
61
+ ## Exit codes
62
+
63
+ - `0` — op completed (or degraded — darwin not installable)
64
+ - `1` — `--alert-on-invalid` and validation found errors
65
+ - `2` — config error (unknown op, missing/broken input file)
@@ -0,0 +1,65 @@
1
+ ---
2
+ name: harness-learn
3
+ description: Run a GEPA learning cycle via `metaharness learn` (upstream ADR-235, metaharness@0.3.0) — optimizes a harness genome against a SWE-bench-style slice manifest. $0 dry-run by default; `--run` is the explicit spend opt-in. Requires a metaharness repo checkout (`--repo` or $METAHARNESS_REPO) — without one it reports `checkout-required` with clone instructions. Degrades gracefully when metaharness is absent.
4
+ argument-hint: "--host <h> --model <m> --slice <manifest> [--repo <checkout>] [--run] [--alert-on-fail]"
5
+ allowed-tools: Bash
6
+ ---
7
+
8
+ Surfaces `metaharness learn` — the upstream GEPA learning harness that
9
+ evolves harness policy genomes against a scored task corpus instead of
10
+ hand-editing prompts. Candidates are scored on held-out slices and only
11
+ measured winners promote (the shipped cand-6 genome is the first such
12
+ promotion: holdout gold 2/12 → 3/12, zero regressions).
13
+
14
+ ## When to use
15
+
16
+ - A harness's policy prompt underperforms on a task family and you want a
17
+ measured improvement loop rather than manual prompt iteration.
18
+ - Pricing a learning run before committing spend — the default dry-run
19
+ resolves the slice manifest and reports cost without any model calls.
20
+ - After a learn run promotes a genome: pair with `harness-gepa --op render`
21
+ to inspect what the promoted policy actually says.
22
+
23
+ ## Preconditions (upstream design)
24
+
25
+ The learning harness (GEPA + SWE-bench + Docker) is too heavy for the npm
26
+ package, so `learn` needs a local clone:
27
+
28
+ ```bash
29
+ git clone https://github.com/ruvnet/metaharness.git
30
+ node scripts/learn.mjs --repo ./metaharness --host claude-code --model haiku --slice slices/lite.json
31
+ ```
32
+
33
+ Without a checkout the script emits `{status: "checkout-required"}` and
34
+ exits 0 — a precondition report, not an error (distinct from
35
+ `degraded: true`, which means the npm package itself is absent). The
36
+ managed-service path (gateway-side learn jobs, no checkout) is upstream's
37
+ ADR-235 follow-up and not available yet.
38
+
39
+ ## Algorithm
40
+
41
+ Implementation: [`scripts/learn.mjs`](../../scripts/learn.mjs).
42
+
43
+ 1. Validate `--repo` exists when given; export it as `$METAHARNESS_REPO`.
44
+ 2. Invoke the pinned `metaharness` binary (`metaharness@~0.3.0`, local install
45
+ or one-time versioned cache — never `@latest`): `metaharness learn --host <h>
46
+ --model <m> --slice <s> [--run]` via `_harness.mjs` (graceful degradation,
47
+ hard timeout).
48
+ 3. Default timeouts: 120s dry-run, 600s with `--run` — real runs on larger
49
+ slices need an explicit `--timeout-ms` matched to slice size × model cost.
50
+ 4. Detect the checkout-required message → structured payload, exit 0.
51
+ 5. Parse the trailing JSON report when upstream emits one; otherwise return
52
+ the raw report text under `rawReport`.
53
+
54
+ ## Cost note
55
+
56
+ `--run` is the ONLY path that spends. Everything else — dry-run, checkout
57
+ probe, degraded path — is $0. The MCP tool (`metaharness_learn`) has a 120s
58
+ subprocess budget; run real learning cycles from a terminal via
59
+ `ruflo metaharness learn ... --run --timeout-ms <big>`.
60
+
61
+ ## Exit codes
62
+
63
+ - `0` — report produced (or dry-run, checkout-required, degraded)
64
+ - `1` — `--alert-on-fail` and the learn run reported failure
65
+ - `2` — config error (bad `--repo` path)
@@ -13,7 +13,9 @@ tool; pure static analysis.
13
13
 
14
14
  Implementation: [`scripts/mcp-scan.mjs`](../../scripts/mcp-scan.mjs).
15
15
 
16
- 1. Shell `npx -p metaharness@latest harness mcp-scan <path> --json`.
16
+ 1. Invoke the pinned `harness` binary (`metaharness@~0.3.0`, resolved from a
17
+ local install or the one-time `~/.ruflo/metaharness-cache-<pin>` cache —
18
+ never `@latest`): `harness mcp-scan <path> --json`.
17
19
  2. Parse `findings[]` with `{ severity, id, server, tool, message }`.
18
20
  3. `--fail-on <severity>`: exit 1 when any finding is at or above that
19
21
  level. Default `high`.
@@ -58,7 +58,7 @@ no network, registry unreachable), the script emits:
58
58
  {
59
59
  "degraded": true,
60
60
  "reason": "metaharness-not-available",
61
- "hint": "Install metaharness manually with `npm i -D metaharness` or run `npx metaharness@latest --version` to verify network access."
61
+ "hint": "Install with `npm i -D metaharness@~0.3.0` (pinned range this plugin never fetches @latest) or verify network access for the one-time cache install."
62
62
  }
63
63
  ```
64
64
 
@@ -29,7 +29,7 @@ ground-truth set. Running this nightly gives us:
29
29
 
30
30
  Implementation: [`scripts/security-bench.mjs`](../../scripts/security-bench.mjs).
31
31
 
32
- 1. Shell to `npx -y @metaharness/darwin@~0.3.1 metaharness-darwin security bench --population N --cycles N [--seed S]`.
32
+ 1. Shell to `npx -y @metaharness/darwin@~0.8.0 metaharness-darwin security bench --population N --cycles N [--seed S]`.
33
33
  2. Default timeout = `3s × 19 evaluations × population × cycles + 30s overhead`.
34
34
  At default `--population 2 --cycles 1` ≈ 144s; at `--population 4 --cycles 3` ≈ 12 min.
35
35
  3. Parse the markdown report — overall PASS/FAIL plus per-gate
@@ -13,7 +13,9 @@ categorized report suitable for sharing with an InfoSec team.
13
13
 
14
14
  Implementation: [`scripts/threat-model.mjs`](../../scripts/threat-model.mjs).
15
15
 
16
- 1. Shell `npx -p metaharness@latest harness threat-model <path> --json`.
16
+ 1. Invoke the pinned `harness` binary (`metaharness@~0.3.0`, resolved from a
17
+ local install or the one-time `~/.ruflo/metaharness-cache-<pin>` cache —
18
+ never `@latest`): `harness threat-model <path> --json`.
17
19
  2. Parse `{ worst, findings[] }`.
18
20
  3. `--fail-on <severity>`: exit 1 when `worst >= fail-on`. Default `high`.
19
21