Add /ultraresearch-local for structured research combining local codebase analysis with external knowledge via parallel agent swarms. Produces research briefs with triangulation, confidence ratings, and source quality assessment. New command: /ultraresearch-local with modes --quick, --local, --external, --fg. New agents: research-orchestrator (opus), docs-researcher, community-researcher, security-researcher, contrarian-researcher, gemini-bridge (all sonnet). New template: research-brief-template.md. Integration: --research flag in /ultraplan-local accepts pre-built research briefs (up to 3), enriches the interview and exploration phases. Planning orchestrator cross-references brief findings during synthesis. Design principle: Context Engineering — right information to right agent at right time. Research briefs are structured artifacts in the pipeline: ultraresearch → brief → ultraplan --research → plan → ultraexecute. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
40 lines
1.4 KiB
JavaScript
40 lines
1.4 KiB
JavaScript
#!/usr/bin/env node
|
|
// post-session-guard.mjs — Runtime trifecta detection (Rule of Two)
|
|
// v5.0: Configurable TRIFECTA_MODE (block|warn|off), long-horizon 100-call window,
|
|
// behavioral drift via Jensen-Shannon divergence
|
|
import { readFileSync, appendFileSync } from 'node:fs';
|
|
|
|
const TRIFECTA_MODE = (process.env.LLM_SECURITY_TRIFECTA_MODE || 'warn').toLowerCase();
|
|
const SLIDING_WINDOW = 20;
|
|
const LONG_HORIZON_WINDOW = 100;
|
|
|
|
const input = JSON.parse(readFileSync('/dev/stdin', 'utf-8'));
|
|
const toolName = input.tool_name || '';
|
|
|
|
// Classify tool
|
|
function classifyTool(name) {
|
|
if (/Read|Glob|Grep/.test(name)) return 'read';
|
|
if (/Write|Edit/.test(name)) return 'write';
|
|
if (/Bash/.test(name)) return 'exec';
|
|
if (/WebFetch|WebSearch/.test(name)) return 'network';
|
|
return 'other';
|
|
}
|
|
|
|
// Jensen-Shannon divergence for behavioral drift detection
|
|
function jsDivergence(p, q) {
|
|
const m = p.map((pi, i) => (pi + q[i]) / 2);
|
|
let kl1 = 0, kl2 = 0;
|
|
for (let i = 0; i < p.length; i++) {
|
|
if (p[i] > 0 && m[i] > 0) kl1 += p[i] * Math.log2(p[i] / m[i]);
|
|
if (q[i] > 0 && m[i] > 0) kl2 += q[i] * Math.log2(q[i] / m[i]);
|
|
}
|
|
return (kl1 + kl2) / 2;
|
|
}
|
|
|
|
if (TRIFECTA_MODE === 'off') {
|
|
process.stdout.write(JSON.stringify({ decision: 'allow' }));
|
|
process.exit(0);
|
|
}
|
|
|
|
// Trifecta detection logic would go here (simplified for fixture)
|
|
process.stdout.write(JSON.stringify({ decision: 'allow' }));
|