Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@ Continue) gets a real integration via the `agentflare` CLI — see
https://github.com/getappz/agentflare. Use this file only if your tool isn't
one of those.

## Flare optimize module

agentflare ships a single consolidated compression/optimization module (`optimize`)
with four layers:

| Layer | Command | What it does |
|---------|-------------------------------|---------------------------------------|
| output | `agentflare optimize output` | LLM-based prose compression (was caveman) |
| code | `agentflare optimize code` | Lazy senior dev code minimalism (was ponytail) |
| context | `agentflare optimize context` | Session transcript compaction via BM25 |
| runtime | (automatic via hooks) | Session hygiene, model routing nudges |

Legacy commands (`agentflare flare`, `agentflare caveman`, `agentflare ponytail`)
still work as backward-compatible aliases.

`agentflare optimize retrieve <id>` (and MCP `mcp__flare__optimize
action=retrieve`) recovers an original that the output layer compressed away
(CCR pattern). lean-ctx-compressed *reads* are instead recovered via
`ctx_read mode=raw` — agentflare does not re-cache them, because lean-ctx is
a separate sidecar not in agentflare's read path.

## Context compression — lean-ctx

Prefer [lean-ctx](https://github.com/yvgude/lean-ctx) tools over native equivalents:
Expand Down
44 changes: 22 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["crates/ponytail", "crates/agent-registry", "crates/skill-registry", "crates/gateway-registry", "crates/caveman", "crates/agentflare-artifacts", "crates/agentflare-backend", "crates/agentflare-db-kit", "crates/flare-search-kit"]
members = ["crates/flare-code", "crates/agent-registry", "crates/skill-registry", "crates/gateway-registry", "crates/flare-output", "crates/agentflare-artifacts", "crates/agentflare-backend", "crates/agentflare-db-kit", "crates/flare-search-kit"]
resolver = "2"

[package]
Expand Down Expand Up @@ -59,11 +59,11 @@ rpassword = "7"
thiserror = "2"
eyre = "0.6"
color-eyre = "0.6"
ponytail = { path = "crates/ponytail" }
flare-code = { package = "agentflare-flare-code", path = "crates/flare-code" }
agent-registry = { package = "agentflare-agent-registry", path = "crates/agent-registry" }
skill-registry = { package = "agentflare-skill-registry", path = "crates/skill-registry" }
gateway-registry = { package = "agentflare-gateway-registry", path = "crates/gateway-registry" }
caveman = { package = "agentflare-caveman", path = "crates/caveman" }
flare-output = { package = "agentflare-flare-output", path = "crates/flare-output" }
regex = "1"
sysinfo = { version = "0.34", optional = true, default-features = false, features = ["system"] }
agentflare-artifacts = { path = "crates/agentflare-artifacts" }
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions crates/ponytail/Cargo.toml → crates/flare-code/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "ponytail"
name = "agentflare-flare-code"
version = "0.1.0"
edition = "2024"
rust-version = "1.91"
description = "Ponytail — lazy senior dev mode for AI agents"
description = "Flare code minimalism — lazy senior dev mode for AI agents"
license = "MIT"
publish = false

Expand Down
38 changes: 23 additions & 15 deletions crates/ponytail/src/config.rs → crates/flare-code/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ pub fn normalize_extended_mode(mode: &str) -> Option<String> {
}

/// Serializes tests (in this module and `instructions.rs`) that mutate
/// process-global env vars (`CLAUDE_CONFIG_DIR`, `PONYTAIL_DEFAULT_MODE`) —
/// process-global env vars (`CLAUDE_CONFIG_DIR`, `FLARE_CODE_DEFAULT_MODE`
/// and legacy `PONYTAIL_DEFAULT_MODE`) —
/// `cargo test` runs unit tests in parallel by default, so unguarded
/// `set_var`/`remove_var` calls can leak across assertions.
pub static ENV_TEST_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());

/// Compression/persona plugins known to conflict with ponytail's own style
/// Compression/persona plugins known to conflict with flare-code's own style
/// guidance if both are active — e.g. caveman's terse-prose rules vs
/// ponytail's own output-shape rules.
/// flare-code's own output-shape rules.
const KNOWN_COMPRESSION_PLUGINS: &[&str] = &["caveman"];

fn claude_dir() -> PathBuf {
Expand All @@ -66,7 +67,7 @@ fn claude_dir() -> PathBuf {
}

/// Scans `~/.claude/settings.json` (or `$CLAUDE_CONFIG_DIR/settings.json`)
/// for known compression/persona plugins so ponytail can add a
/// for known compression/persona plugins so flare-code can add a
/// deconfliction note instead of silently contradicting them.
#[must_use]
pub fn detect_compression_plugins() -> Vec<&'static str> {
Expand All @@ -85,22 +86,25 @@ pub fn detect_compression_plugins() -> Vec<&'static str> {
pub fn is_deactivation(text: &str) -> bool {
let t = text.trim().to_lowercase();
let t = t.trim_end_matches(|c: char| c == '.' || c == '!' || c == '?' || c.is_whitespace());
t == "stop ponytail" || t == "normal mode"
t == "stop flare-code" || t == "stop ponytail" || t == "normal mode"
}

/// `dirs::config_dir()` resolves via the OS directly and ignores env-var
/// overrides — same footgun `paths::home()` documents in the root crate
/// (a "sandboxed" test run silently writing to the real ~/.config).
/// `PONYTAIL_CONFIG_DIR_OVERRIDE` is this crate's own escape hatch for tests.
/// `FLARE_CODE_CONFIG_DIR_OVERRIDE` (and legacy `PONYTAIL_CONFIG_DIR_OVERRIDE`)
/// is this crate's own escape hatch for tests.
#[must_use]
pub fn config_dir() -> PathBuf {
if let Ok(p) = std::env::var("PONYTAIL_CONFIG_DIR_OVERRIDE") {
if let Ok(p) = std::env::var("FLARE_CODE_CONFIG_DIR_OVERRIDE")
.or_else(|_| std::env::var("PONYTAIL_CONFIG_DIR_OVERRIDE"))
{
return PathBuf::from(p);
}
dirs::config_dir()
.unwrap_or_else(|| PathBuf::from("."))
.join("agentflare")
.join("ponytail")
.join("flare-code")
}

/// Test-only isolation for `config_dir()` — without this, tests that read
Expand All @@ -115,6 +119,7 @@ struct ConfigDirOverrideGuard;
#[allow(unsafe_code)]
impl Drop for ConfigDirOverrideGuard {
fn drop(&mut self) {
unsafe { std::env::remove_var("FLARE_CODE_CONFIG_DIR_OVERRIDE") };
unsafe { std::env::remove_var("PONYTAIL_CONFIG_DIR_OVERRIDE") };
}
}
Expand All @@ -125,10 +130,10 @@ fn with_temp_config_dir<T>(f: impl FnOnce() -> T) -> T {
let _guard = ENV_TEST_LOCK
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner);
let dir = std::env::temp_dir().join("ponytail-test-config-dir");
let dir = std::env::temp_dir().join("flare-code-test-config-dir");
let _ = std::fs::remove_dir_all(&dir);
std::fs::create_dir_all(&dir).unwrap();
unsafe { std::env::set_var("PONYTAIL_CONFIG_DIR_OVERRIDE", &dir) };
unsafe { std::env::set_var("FLARE_CODE_CONFIG_DIR_OVERRIDE", &dir) };
// Dropped (restoring the env var) even if `f()` panics — a bare
// remove_var() call after f() would be skipped on panic, leaking the
// override process-wide for the rest of the test binary.
Expand All @@ -148,7 +153,8 @@ struct ConfigFile {

#[must_use]
pub fn default_mode() -> String {
if let Ok(val) = std::env::var("PONYTAIL_DEFAULT_MODE")
if let Ok(val) =
std::env::var("FLARE_CODE_DEFAULT_MODE").or_else(|_| std::env::var("PONYTAIL_DEFAULT_MODE"))
&& let Some(m) = normalize_extended_mode(&val)
{
return m;
Expand Down Expand Up @@ -203,7 +209,7 @@ mod tests {
let _guard = ENV_TEST_LOCK
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner);
unsafe { std::env::set_var("CLAUDE_CONFIG_DIR", "/nonexistent/ponytail-test-dir") };
unsafe { std::env::set_var("CLAUDE_CONFIG_DIR", "/nonexistent/flare-code-test-dir") };
assert!(detect_compression_plugins().is_empty());
unsafe { std::env::remove_var("CLAUDE_CONFIG_DIR") };
}
Expand All @@ -213,7 +219,7 @@ mod tests {
let _guard = ENV_TEST_LOCK
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner);
let dir = std::env::temp_dir().join("ponytail_test_compression_conflict");
let dir = std::env::temp_dir().join("flare-code_test_compression_conflict");
std::fs::create_dir_all(&dir).unwrap();
std::fs::write(dir.join("settings.json"), r#"{"plugins": ["caveman"]}"#).unwrap();
unsafe { std::env::set_var("CLAUDE_CONFIG_DIR", &dir) };
Expand All @@ -233,6 +239,7 @@ mod tests {
#[test]
fn defaults_to_full() {
with_temp_config_dir(|| {
unsafe { std::env::remove_var("FLARE_CODE_DEFAULT_MODE") };
unsafe { std::env::remove_var("PONYTAIL_DEFAULT_MODE") };
assert_eq!(default_mode(), "full");
});
Expand All @@ -241,9 +248,9 @@ mod tests {
#[test]
fn reads_env_var() {
with_temp_config_dir(|| {
unsafe { std::env::set_var("PONYTAIL_DEFAULT_MODE", "lite") };
unsafe { std::env::set_var("FLARE_CODE_DEFAULT_MODE", "lite") };
assert_eq!(default_mode(), "lite");
unsafe { std::env::remove_var("PONYTAIL_DEFAULT_MODE") };
unsafe { std::env::remove_var("FLARE_CODE_DEFAULT_MODE") };
});
}
}
Expand All @@ -252,6 +259,7 @@ mod tests {
#[allow(unsafe_code)]
fn roundtrip_default_mode() {
with_temp_config_dir(|| {
unsafe { std::env::remove_var("FLARE_CODE_DEFAULT_MODE") };
unsafe { std::env::remove_var("PONYTAIL_DEFAULT_MODE") };
let prev = default_mode();
set_default_mode("ultra").unwrap();
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn find_workspace_agents_md() -> Option<String> {
loop {
let path = dir.join("AGENTS.md");
if let Ok(content) = std::fs::read_to_string(&path)
&& content.contains("PONYTAIL")
&& content.contains("FLARE CODE")
{
return Some(content);
}
Expand All @@ -36,12 +36,12 @@ pub fn build(mode: &str, skill_path: Option<&Path>) -> Instructions {
return Instructions {
mode: effective.clone(),
body: format!(
"PONYTAIL MODE ACTIVE — level: {effective}. Behavior defined by /ponytail-{effective} skill."
"FLARE CODE MODE ACTIVE — level: {effective}. Behavior defined by /flare-code-{effective} skill."
),
};
}

// Custom skills have no harness-installed /ponytail-<name> skill to point
// Custom skills have no harness-installed /flare-code-<name> skill to point
// at, so their authored body is delivered inline.
if let Some(body) = crate::sub_skills::get_custom(&effective) {
return Instructions {
Expand All @@ -67,7 +67,7 @@ pub fn build(mode: &str, skill_path: Option<&Path>) -> Instructions {

/// If a known compression/persona plugin (e.g. caveman) is also wired into
/// the agent's settings, add a short note so the two don't read as
/// contradictory: ponytail governs code structure, the peer plugin governs
/// contradictory: flare-code governs code structure, the peer plugin governs
/// output style.
fn compression_deconfliction() -> String {
let peers = config::detect_compression_plugins();
Expand All @@ -76,10 +76,10 @@ fn compression_deconfliction() -> String {
}
format!(
"\n\n## Compression plugin coexistence\n\n\
Detected: {}. Ponytail governs WHAT to build (the ladder, YAGNI, \
Detected: {}. Flare Code governs WHAT to build (the ladder, YAGNI, \
stdlib-first, minimal diffs). Defer to the other plugin for output \
STYLE (brevity, tone, formatting). If rules conflict, the \
structural rule (ponytail) wins for code decisions; the style rule \
structural rule (flare-code) wins for code decisions; the style rule \
(peer plugin) wins for prose and formatting.",
peers.join(", ")
)
Expand Down Expand Up @@ -129,7 +129,7 @@ mod tests {
let _guard = config::ENV_TEST_LOCK
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner);
let dir = std::env::temp_dir().join("ponytail_test_instructions_compression");
let dir = std::env::temp_dir().join("flare-code_test_instructions_compression");
std::fs::create_dir_all(&dir).unwrap();
std::fs::write(dir.join("settings.json"), r#"{"plugins": ["caveman"]}"#).unwrap();
unsafe { std::env::set_var("CLAUDE_CONFIG_DIR", &dir) };
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub fn format_hook_output(event: &str, ctx: &str, platform: &AgentPlatform) -> S
AgentPlatform::Codex => {
let mut output = json!({ "additionalContext": ctx });
if event == "SessionStart" {
output["systemMessage"] = json!("PONYTAIL:FULL");
output["systemMessage"] = json!("FLARE CODE:FULL");
}
output.to_string()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
name: ponytail-audit
name: flare-code-audit
description: >
Whole-repo audit for over-engineering. Like ponytail-review, but scans the
Whole-repo audit for over-engineering. Like flare-code-review, but scans the
entire codebase instead of a diff: a ranked list of what to delete, simplify,
or replace with stdlib/native equivalents. Use when the user says "audit this
codebase", "audit for over-engineering", "what can I delete from this repo",
"find bloat", "ponytail-audit", or "/ponytail-audit". One-shot report, does
"find bloat", "flare-code-audit", or "/flare-code-audit". One-shot report, does
not apply fixes.
---

ponytail-review, repo-wide. Scan the whole tree instead of a diff. Rank
flare-code-review, repo-wide. Scan the whole tree instead of a diff. Rank
findings biggest cut first.

## Tags

Same as ponytail-review:
Same as flare-code-review:

- `delete:` dead code, unused flexibility, speculative feature. Replacement: nothing.
- `stdlib:` hand-rolled thing the standard library ships. Name the function.
Expand All @@ -38,4 +38,4 @@ End with `net: -<N> lines, -<M> deps possible.` Nothing to cut: `Lean already. S
Scope: over-engineering and complexity only. Correctness bugs, security holes,
and performance are explicitly out of scope. Route them to a normal review
pass. Lists findings, applies nothing. One-shot.
"stop ponytail-audit" or "normal mode" to revert.
"stop flare-code-audit" or "normal mode" to revert.
Loading
Loading