Skip to content

Bruno-Cunha-Souza/ValarMindSkills / skills/context-optimization

context-optimization

Unverified

Lifecycle context audit/optimize/plan. Audit mode (Phase 0..6) + Guide mode (catalog lookup). Targets long-conv agents, RAG pipelines, sub-agents, large-doc workflows. Detects bloat/dedup/cache/masking/partition opportunities. Emits findings (SAFE/REVIEW/BREAKING) + optimization plan + token delta. Read-only — LGTM if sound. Triggers: 'optimize context', 'compact context', 'auditar contexto', 'otimizar contexto', '/context-optimization'.

scripts/ctxopt/tests/integration.rs

View on GitHub
//! Smoke tests for ctxopt subcommands. Build + invoke binary against a tiny fixture.

use std::process::Command;

fn ctxopt_bin() -> std::path::PathBuf {
    // Cargo sets CARGO_BIN_EXE_<name> to the test binary path.
    std::path::PathBuf::from(env!("CARGO_BIN_EXE_ctxopt"))
}

#[test]
fn version_prints_on_stdout() {
    let out = Command::new(ctxopt_bin())
        .arg("--version")
        .output()
        .expect("ctxopt --version");
    assert!(out.status.success());
    let s = String::from_utf8_lossy(&out.stdout);
    assert!(s.contains("ctxopt"));
}

#[test]
fn help_lists_all_subcommands() {
    let out = Command::new(ctxopt_bin())
        .arg("--help")
        .output()
        .expect("ctxopt --help");
    assert!(out.status.success());
    let s = String::from_utf8_lossy(&out.stdout);
    for sub in ["scan", "count", "dedup", "run-all", "report"] {
        assert!(s.contains(sub), "--help missing subcommand `{sub}`");
    }
}

#[test]
fn scan_against_tiny_corpus_emits_findings() {
    let fixture = tempfile::tempdir().expect("tmp");
    let out_dir = tempfile::tempdir().expect("tmp out");
    let big = fixture.path().join("big.md");
    let payload = "# Big\n".repeat(2000);
    std::fs::write(&big, payload).unwrap();

    let status = Command::new(ctxopt_bin())
        .args([
            "scan",
            fixture.path().to_str().unwrap(),
            "--out-dir",
            out_dir.path().to_str().unwrap(),
            "--format",
            "jsonl",
            "--quiet",
        ])
        .status()
        .expect("ctxopt scan");
    assert!(status.success(), "ctxopt scan failed");

    let findings = out_dir.path().join("findings.jsonl");
    let body = std::fs::read_to_string(findings).expect("read findings.jsonl");
    assert!(body.contains("CTX-SCAN-"));
    assert!(body.contains("big.md"));
}

#[test]
fn run_all_writes_report_md_and_summaries() {
    let fixture = tempfile::tempdir().expect("tmp");
    let out_dir = tempfile::tempdir().expect("tmp out");
    std::fs::write(
        fixture.path().join("a.md"),
        "Lorem ipsum dolor sit amet consectetur adipiscing elit.\n".repeat(10),
    )
    .unwrap();
    std::fs::write(
        fixture.path().join("b.md"),
        "Lorem ipsum dolor sit amet consectetur adipiscing elit.\n".repeat(10),
    )
    .unwrap();

    let status = Command::new(ctxopt_bin())
        .args([
            "run-all",
            fixture.path().to_str().unwrap(),
            "--out-dir",
            out_dir.path().to_str().unwrap(),
            "--format",
            "toon",
            "--quiet",
        ])
        .status()
        .expect("ctxopt run-all");
    assert!(status.success(), "ctxopt run-all failed");

    assert!(out_dir.path().join("findings.toon").exists());
    assert!(out_dir.path().join("findings.jsonl").exists()); // sidecar for aggregation
    assert!(out_dir.path().join("summary.json").exists());
    assert!(out_dir.path().join("summary.toon").exists());
    assert!(out_dir.path().join("report.md").exists());

    let toon = std::fs::read_to_string(out_dir.path().join("findings.toon")).unwrap();
    assert!(
        toon.starts_with("findings["),
        "TOON header missing: {}",
        &toon[..toon.len().min(60)]
    );
}
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall