difflore-cli 0.1.0

Your AI coding agent, taught by your team's PR reviews — a local-first, open-source MCP server that turns past review comments into rules your agent follows automatically.
Documentation
use std::sync::OnceLock;

use clap::CommandFactory;

use crate::style;

use super::Cli;

// Built in code (not via `#[derive]`) so the help / version templates
// can use the truecolor wordmark, computed lazily at first use.
pub(crate) fn build_cli() -> clap::Command {
    let cmd = Cli::command();
    cmd.override_help(help_template()).version(version_string())
}

static HELP_TEMPLATE: OnceLock<String> = OnceLock::new();
static VERSION_STRING: OnceLock<String> = OnceLock::new();

// Clap prefixes the command name (`difflore`) onto whatever we return
// here, so we just supply the bare version.
fn version_string() -> &'static str {
    VERSION_STRING
        .get_or_init(|| env!("CARGO_PKG_VERSION").to_owned())
        .as_str()
}

// Hand-rolled help template (clap `override_help`) keeps the top-level
// surface curated while still honoring `NO_COLOR`.
fn help_template() -> &'static str {
    HELP_TEMPLATE
        .get_or_init(|| {
            let start = style::pewter("START").to_string();
            let use_ = style::pewter("USE").to_string();
            let support = style::pewter("SUPPORT").to_string();
            let more = format!(
                "{} Run any command with --help for details · docs.difflore.dev",
                style::emerald(style::sym::TIP),
            );
            format!(
                "\
AI review memory for local coding agents.
Agents remember team judgment before they code, so reviews repeat less.

USAGE
  difflore [COMMAND]
  difflore                      {tip} show local memory status

{start}
  try                 See it work on a bundled sample
  init                First-time setup for this repo
  status              Show local memory status and the next command
  agents              Wire local agents and inspect install state
  cloud               Log in, sync, and view team impact
  providers           Choose the local AI backend for fixes
  embeddings          Optional semantic search for better recall
  import-reviews      Draft local rules from past GitHub PR reviews

{use_}
  recall              Preview memories agents would see on this change
  fix                 Preview/apply local patches, including PR diffs
  ask                 Ask why the team usually reviews something

{support}
  doctor              Diagnose readiness and blockers

{more}
",
                tip = style::emerald(style::sym::TIP),
            )
        })
        .as_str()
}