llman 0.0.26

A tool for managing LLM application rules(prompts) ...
Documentation
use super::config::{SddConfig, load_or_create_config};
use super::fs_utils::update_file_with_markers;
use super::templates::root_stub_content;
use crate::sdd::shared::constants::{LLMANSPEC_DIR_NAME, LLMANSPEC_MARKERS};
use anyhow::{Result, anyhow};
use std::path::Path;

pub fn run(target: &Path) -> Result<()> {
    let llmanspec_path = target.join(LLMANSPEC_DIR_NAME);
    if !llmanspec_path.exists() {
        return Err(anyhow!(
            "No llmanspec directory found. Run 'llman sdd init' first."
        ));
    }

    let config = load_or_create_config(&llmanspec_path)?;
    write_root_agents_file(target, &config)?;

    Ok(())
}

fn write_root_agents_file(target: &Path, config: &SddConfig) -> Result<()> {
    let agents_path = target.join("AGENTS.md");
    let content = root_stub_content(config, target)?;
    update_file_with_markers(
        &agents_path,
        &content,
        LLMANSPEC_MARKERS.start,
        LLMANSPEC_MARKERS.end,
    )?;
    Ok(())
}