mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-12-05 23:11:43 +09:00
Each plugin gets a tighten-only tool.call guard on its own tools (secrets and credential fields out of messages/templates, hostile URLs and exfiltration scripts out of the browser, pub: channels only for the ChatGPT publisher), a local slash command (/bbs-mod, /browser-mod, /pods-mod, /chatgpt-mod), a .claude-flow/<short>-mod/status.json, userConfig, tests, smoke steps M1-M3 and an "As a mod" README section. Versions: bbs 0.3.0, browser 0.3.0, pods 0.2.0, chatgpt 0.2.0. Co-Authored-By: RuFlo <ruv@ruv.net>
26 lines
949 B
TypeScript
26 lines
949 B
TypeScript
/** Counters the mod keeps for the session and writes to `.claude-flow/browser-mod/status.json` for the console. */
|
|
export type Stats = {
|
|
/** Calls to this plugin's tools the guard looked at. */
|
|
checked: number
|
|
/** Calls it refused. */
|
|
blocked: number
|
|
/** Refusals by rule name (never by value). */
|
|
byRule: Record<string, number>
|
|
lastRule?: string
|
|
}
|
|
|
|
export const newStats = (): Stats => ({ checked: 0, blocked: 0, byRule: {} })
|
|
|
|
export const STATUS_PATH = '.claude-flow/browser-mod/status.json'
|
|
|
|
export function noteBlocked(stats: Stats, rule: string): void {
|
|
stats.blocked++
|
|
stats.byRule[rule] = (stats.byRule[rule] ?? 0) + 1
|
|
stats.lastRule = rule
|
|
}
|
|
|
|
/** The file's text; `version` lets the console refuse a shape it does not know. */
|
|
export function statusText(stats: Stats, mode: Record<string, unknown>, nowMs: number): string {
|
|
return `${JSON.stringify({ version: 1, updatedMs: nowMs, ...mode, ...stats }, null, 2)}\n`
|
|
}
|