🌊 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(mods): port the #4136 query-coverage route recall into the mod's ranked-context copy
r3102183cda04
diff --git a/plugins/ruflo-mods/.claude-plugin/plugin.json b/plugins/ruflo-mods/.claude-plugin/plugin.jsonindex d4c2d1eeb9..88d30dbcc5 100644--- a/plugins/ruflo-mods/.claude-plugin/plugin.json+++ b/plugins/ruflo-mods/.claude-plugin/plugin.json@@ -1,7 +1,7 @@{"name": "ruflo-mods","description": "ruflo as a Claude Code mod (function hooks, ADR-404): in-process prompt routing, edit learning signals, tighten-only tool checks from ruflo policy, the cost-tracker budget ladder, a mod trust gate for newly installed mods, and the $.ruflo noun other mods compose their status with. Opt-in and removable: the classic hook-handler hooks stay the default and take every event back whenever the mod is not loaded.",- "version": "0.6.1",+ "version": "0.6.2","author": {"name": "ruvnet","url": "https://github.com/ruvnet"diff --git a/plugins/ruflo-mods/CHANGELOG.md b/plugins/ruflo-mods/CHANGELOG.mdindex 204ec2e5da..cea9265c54 100644--- a/plugins/ruflo-mods/CHANGELOG.md+++ b/plugins/ruflo-mods/CHANGELOG.md@@ -2,6 +2,9 @@Newest first. One `## <version> — <date>` heading per version, then `feat:`, `fix:`, `breaking:` and `chore:` bullets (ADR-478). Built from git history; older versions: `git log -- plugins/ruflo-mods`.+## 0.6.2 — 2026-10-14+- fix: the mod's route context uses the same query-coverage scoring as hook-handler.cjs (inflection variants, IDF weights, coverage >= 0.15), so a short prompt finds a long memory entry and "migrations" finds "migration" (#4136, #4172); the ADR-404 parity test holds again+## 0.6.1 — 2026-10-12- fix: root-delete guard expands brace lists (`rm -rf {/*,}`), judges deep nesting by tokens instead of a literal phrase, catches fork-bomb definitions in any spacing or name, and keeps its option checks linear (#4093, thanks @proffesor-for-testing)- fix: the shared text screen now catches `.env` and e-mailed credentials, no longer flags a model's token talk (`--max-tokens`, `/oauth/token`, "token usage"), and no longer flags values that only name where a secret lives (`./service-account.json`, `--set-secrets=NAME=NAME:latest`); every rule stays linear (#4094, thanks @proffesor-for-testing)diff --git a/plugins/ruflo-mods/hooks/route/ranked-context.ts b/plugins/ruflo-mods/hooks/route/ranked-context.tsindex 99e252d268..289bde7e50 100644--- a/plugins/ruflo-mods/hooks/route/ranked-context.ts+++ b/plugins/ruflo-mods/hooks/route/ranked-context.ts@@ -1,6 +1,7 @@/*** Ranked-memory context for a prompt: the scoring of intelligence.cjs- * `getContext` (trigram Jaccard blended with PageRank, top 5 over 0.05),+ * `getContext` (query-coverage scoring over inflection variants with IDF+ * weights and a small PageRank blend, top 5 at coverage >= 0.15; #4136),* read-only.** Copied because a hooks module cannot import intelligence.cjs; the parity@@ -29,8 +30,7 @@ const plainText = (s: string): string =>.replace(/\s+/g, ' ').trim()-const ALPHA = 0.6-const MIN_THRESHOLD = 0.05+const MIN_COVERAGE = 0.15const TOP_K = 5export type RankedEntry = {@@ -59,15 +59,27 @@ export function trigrams(words: readonly string[]): Set<string> {return t}-function jaccard(a: ReadonlySet<string>, b: ReadonlySet<string>): number {- if (a.size === 0 && b.size === 0) return 0- let shared = 0- for (const item of a) if (b.has(item)) shared++- return shared / (a.size + b.size - shared)-}+/** An entry with its term set worked out once, when the file is read. */+export type PreparedEntry = RankedEntry & { readonly tri: ReadonlySet<string>; readonly terms: ReadonlySet<string> }-/** An entry with its trigrams worked out once, when the file is read. */-export type PreparedEntry = RankedEntry & { readonly tri: ReadonlySet<string> }+/**+ * Inflection variants of a prompt term (plural, -ed, -ing, -ion and their+ * stems), as in intelligence.cjs: "migrations" finds "migration", "deploying"+ * finds "deploy". The stem keeps at least 4 characters so short words stay exact.+ */+export function termVariants(word: string): string[] {+ const out = new Set<string>([word])+ for (const suffix of ['s', 'es', 'ed', 'ing', 'ion', 'ions']) out.add(word + suffix)+ for (const suffix of ['ions', 'ion', 'ing', 'ed', 'es', 's']) {+ if (word.length - suffix.length >= 4 && word.endsWith(suffix)) {+ const stem = word.slice(0, -suffix.length)+ out.add(stem)+ out.add(stem + 'e')+ out.add(stem + 's')+ }+ }+ return [...out]+}/*** Parses ranked-context.json text into its entries, each with its trigrams@@ -81,7 +93,10 @@ export function parseRanked(text: string): readonly PreparedEntry[] {if (!Array.isArray(entries)) return []return entries.filter((e): e is RankedEntry => e !== null && typeof e === 'object')- .map(e => ({ ...e, tri: trigrams(Array.isArray(e.words) ? e.words.filter(w => typeof w === 'string') : []) }))+ .map(e => {+ const words = Array.isArray(e.words) ? e.words.filter((w): w is string => typeof w === 'string') : []+ return { ...e, tri: trigrams(words), terms: new Set(words) }+ })} catch {return []}@@ -95,15 +110,38 @@ export function parseRanked(text: string): readonly PreparedEntry[] {*/export function rankedContext(prompt: string, entries: readonly PreparedEntry[]): string | null {if (!prompt || entries.length === 0) return null- const words = tokenize(prompt)- if (words.length === 0) return null- const promptTrigrams = trigrams(words)+ const promptWords = [...new Set(tokenize(prompt))]+ if (promptWords.length === 0) return null++ // Query coverage is independent of entry length; IDF downweights terms shared+ // by many entries; terms absent from every entry still count against coverage.+ const variants = promptWords.map(termVariants)+ const hasTerm = (terms: ReadonlySet<string>, i: number): boolean => variants[i].some(v => terms.has(v))+ const weights = promptWords.map((_word, i) => {+ let frequency = 0+ for (const entry of entries) if (hasTerm(entry.terms, i)) frequency+++ return Math.log1p((entries.length - frequency + 0.5) / (frequency + 0.5))+ })+ const totalWeight = weights.reduce((sum, weight) => sum + weight, 0)+ if (totalWeight === 0) return nullconst scored: Array<RankedEntry & { score: number }> = []for (const entry of entries) {- const pageRank = typeof entry.pageRank === 'number' ? entry.pageRank : 0- const score = ALPHA * jaccard(promptTrigrams, entry.tri) + (1 - ALPHA) * pageRank- if (score >= MIN_THRESHOLD) scored.push({ ...entry, score })+ let matchedWeight = 0+ let matchedTerms = 0+ for (let i = 0; i < promptWords.length; i++) {+ if (weights[i] > 0 && hasTerm(entry.terms, i)) {+ matchedWeight += weights[i]+ matchedTerms+++ }+ }+ // A single common word in a long prompt is not evidence of relevance.+ if (matchedTerms < Math.min(2, promptWords.length)) continue+ const coverage = matchedWeight / totalWeight+ if (coverage >= MIN_COVERAGE) {+ const pageRank = Math.max(0, Math.min(1, Number(entry.pageRank) || 0))+ scored.push({ ...entry, score: 0.9 * coverage + 0.1 * pageRank })+ }}if (scored.length === 0) return nulldiff --git a/plugins/ruflo-mods/scripts/smoke.sh b/plugins/ruflo-mods/scripts/smoke.shindex ea8d6f85df..d35d14dbbd 100755--- a/plugins/ruflo-mods/scripts/smoke.sh+++ b/plugins/ruflo-mods/scripts/smoke.sh@@ -1,5 +1,5 @@#!/usr/bin/env bash-# Structural + security smoke for ruflo-mods v0.6.1 (ADR-404, ADR-447).+# Structural + security smoke for ruflo-mods v0.6.2 (ADR-404, ADR-447).# Static only: CI has no Claude Code, so the hooks module's behaviour is held# by v3/@claude-flow/cli/__tests__/mods/*.test.ts and, where function hooks are# on, by `claude plugin test plugins/ruflo-mods`.@@ -12,9 +12,9 @@ ok() { printf "PASS\n"; PASS=$((PASS+1)); }bad() { printf "FAIL: %s\n" "$1"; FAIL=$((FAIL+1)); }HOOKS="$ROOT/hooks"-step "1. plugin.json declares ruflo-mods 0.6.1"+step "1. plugin.json declares ruflo-mods 0.6.2"grep -q '"name": "ruflo-mods"' "$ROOT/.claude-plugin/plugin.json" \- && grep -q '"version": "0.6.1"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"+ && grep -q '"version": "0.6.2"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"step "2. hooks.json names exactly one module and no classic hook commands"grep -q '"modules": \["./register.ts"\]' "$HOOKS/hooks.json" && ! grep -q '"command"' "$HOOKS/hooks.json" \