use crate::config::Platform;
use crate::error::Result;
use crate::generate::{self, Artifact};
use crate::index::IndexedWorkspace;
pub fn apply_overlays(
workspace: &IndexedWorkspace,
artifacts: &mut Vec<Artifact>,
platforms: &[Platform],
) -> Result<()> {
for platform in platforms {
match platform {
Platform::Context7 => {
let body = generate::render_context7_manifest(workspace);
artifacts.push(Artifact::in_workspace_root("context7.json", body));
}
Platform::DeepWiki => {
let body = generate::render_deepwiki_manifest(workspace);
artifacts.push(Artifact::in_workspace_root(".devin/wiki.json", body));
}
Platform::AnthropicStyle => {
apply_anthropic_style(artifacts);
}
}
}
Ok(())
}
fn apply_anthropic_style(artifacts: &mut [Artifact]) {
for artifact in artifacts.iter_mut() {
if !is_markdown_target(&artifact.path) {
continue;
}
let link = if artifact.path.contains('/') {
"../llms.txt"
} else {
"llms.txt"
};
let hint = format!("> Fetch the complete documentation index at: {link}\n\n");
let mut new_body = String::with_capacity(hint.len() + artifact.body.len());
new_body.push_str(&hint);
new_body.push_str(&artifact.body);
artifact.body = new_body;
}
}
fn is_markdown_target(path: &str) -> bool {
path.ends_with(".md") || path == "llms-full.txt"
}