Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- **Dead code removed (#790).** About 500 lines that nothing used are gone, among them the YAML agent-config path, an unused `IssueType` enum, unused graph helpers and five error variants that were never created, and the 60 `#[allow(dead_code)]` attributes that hid them. The compiler now reports unused code again; the few items that are written but not wired in yet carry a narrow, commented allow that points to #792. `cora install --yes` is still accepted but has no effect (`install` never asks questions), and its help says so.
- **A README and docs that are easier to read.** The README opens with a diagram of how cora works and a three-command quick start, groups the features (review, code intelligence, agents and CI), tucks upgrade and Gatekeeper details into a collapsed section and shows the timings as a chart next to the table. `docs/usage.md` shows how a review runs and `docs/agent-integration.md` how an agent uses cora, each with a diagram. The four SVG diagrams (`docs/public/diagrams/`) carry their own light and dark colors, a title and a description, and are checked by `tests/docs_drift.rs` (accessible, self-contained, used somewhere, and the chart matches the README table).

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion docs/cli-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Complete command reference for the cora CLI.
| `cora install --agents` `"cline,cursor"` | Install specific agents |
| `cora install --dry-run` | Show what would be changed |
| `cora install --force` | Overwrite existing cora entry |
| `cora install --yes` | Install ALL detected agents (non-interactive) |
| `cora install --yes` | Accepted for compatibility: `cora install` already installs every detected agent without asking |
| `cora mcp` | Start the MCP server (22 tools, incl. agent-as-reviewer: `cora.review_prepare`/`review_finalize`, `cora.scan_prepare`/`scan_finalize`; no LLM key needed in cora). See [Review with your agent](./usage#review-with-your-agent-no-llm-setup) |
| `claude mcp add cora -- cora mcp` | Register the MCP server with Claude Code (`cora install` only adds its `/cora-review` skill) |
| `cora hook install` | Install pre-commit hook |
Expand Down
48 changes: 3 additions & 45 deletions src/commands/agent_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ use std::path::Path;
pub enum ConfigFormat {
Json,
Jsonc,
#[allow(dead_code)]
Yaml,
}

/// The Cora MCP server entry injected into agent configs.
Expand Down Expand Up @@ -205,7 +203,6 @@ pub fn json_add_cora(config: &mut serde_json::Value) -> Result<()> {
}

/// Remove the `mcpServers.cora` entry. Returns `true` if it was present.
#[allow(dead_code)]
pub fn json_remove_cora(config: &mut serde_json::Value) -> bool {
if let Some(servers) = config.get_mut("mcpServers").and_then(|m| m.as_object_mut()) {
servers.remove("cora").is_some()
Expand All @@ -216,21 +213,8 @@ pub fn json_remove_cora(config: &mut serde_json::Value) -> bool {

// ─── Public API: YAML ────────────────────────────────────────────────

/// Read a YAML config file into a `serde_yaml_ng::Value`.
pub fn read_yaml_config(path: &Path) -> Result<serde_yaml_ng::Value> {
let raw = fs_read(path)?;
let no_bom = strip_bom(&raw);
serde_yaml_ng::from_str(no_bom)
.with_context(|| format!("Failed to parse YAML in {}", path.display()))
}

/// Write a YAML config.
pub fn write_yaml_config(path: &Path, config: &serde_yaml_ng::Value) -> Result<()> {
let output = serde_yaml_ng::to_string(config)?;
fs_write(path, &output)
}

/// Check whether a YAML config already contains a `mcpServers.cora` entry.
#[cfg(test)]
pub fn yaml_has_cora(config: &serde_yaml_ng::Value) -> bool {
config
.get("mcpServers")
Expand All @@ -239,6 +223,7 @@ pub fn yaml_has_cora(config: &serde_yaml_ng::Value) -> bool {
}

/// Insert or overwrite the `mcpServers.cora` entry in a YAML config.
#[cfg(test)]
pub fn yaml_add_cora(config: &mut serde_yaml_ng::Value) -> Result<()> {
let mapping = config
.as_mapping_mut()
Expand Down Expand Up @@ -267,7 +252,7 @@ pub fn yaml_add_cora(config: &mut serde_yaml_ng::Value) -> Result<()> {
}

/// Remove the `mcpServers.cora` entry from YAML. Returns `true` if present.
#[allow(dead_code)]
#[cfg(test)]
pub fn yaml_remove_cora(config: &mut serde_yaml_ng::Value) -> bool {
if let Some(mapping) = config
.get_mut("mcpServers")
Expand All @@ -282,33 +267,6 @@ pub fn yaml_remove_cora(config: &mut serde_yaml_ng::Value) -> bool {

// ─── Format-agnostic helpers ─────────────────────────────────────────

/// Read a config file, dispatching on the detected format.
#[allow(dead_code)]
pub fn read_config(path: &Path, format: ConfigFormat) -> Result<serde_json::Value> {
match format {
ConfigFormat::Json | ConfigFormat::Jsonc => read_json_config(path),
ConfigFormat::Yaml => {
let yaml = read_yaml_config(path)?;
// Convert YAML → JSON for a unified return type
let json_str = serde_yaml_ng::to_string(&yaml)?;
Ok(serde_json::from_str(&json_str)?)
}
}
}

/// Write a config file in the specified format.
#[allow(dead_code)]
pub fn write_config(path: &Path, format: ConfigFormat, config: &serde_json::Value) -> Result<()> {
match format {
ConfigFormat::Json | ConfigFormat::Jsonc => write_json_config(path, config),
ConfigFormat::Yaml => {
let yaml_str = serde_json::to_string(config)?;
let yaml: serde_yaml_ng::Value = serde_yaml_ng::from_str(&yaml_str)?;
write_yaml_config(path, &yaml)
}
}
}

// ─── File I/O wrappers with context ──────────────────────────────────

fn fs_read(path: &Path) -> Result<String> {
Expand Down
63 changes: 0 additions & 63 deletions src/commands/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ pub struct InstallOptions {
pub dry_run: bool,
/// Overwrite existing cora entry.
pub force: bool,
/// Non-interactive mode.
#[allow(dead_code)]
pub yes: bool,
/// Remove cora MCP entry (uninstall mode).
pub remove: bool,
/// Validate agent configs after install/remove.
Expand Down Expand Up @@ -192,58 +189,6 @@ fn install_agent(agent: &AgentInfo, opts: &InstallOptions) -> Result<String> {
install_json_agent(&agent.config_path, opts.force, opts.dry_run)
}
}
ConfigFormat::Yaml => {
use super::agent_config;
let mut config = agent_config::read_yaml_config(&agent.config_path)?;

if opts.remove {
if !agent_config::yaml_has_cora(&config) {
return Ok(format!(
" {} {} — no cora entry found",
"⏭ ".dimmed(),
agent.config_path.display()
));
}
agent_config::yaml_remove_cora(&mut config);
if opts.dry_run {
Ok(format!(
" {} {} — would remove cora MCP server entry",
"🔍 ".cyan(),
agent.config_path.display()
))
} else {
agent_config::write_yaml_config(&agent.config_path, &config)?;
Ok(format!(
" {} {} — cora MCP server entry removed",
"✓ ".green(),
agent.config_path.display()
))
}
} else {
if agent_config::yaml_has_cora(&config) && !opts.force {
return Ok(format!(
" {} {} — cora entry already exists (use --force to overwrite)",
"⏭ ".dimmed(),
agent.config_path.display()
));
}
agent_config::yaml_add_cora(&mut config)?;
if opts.dry_run {
Ok(format!(
" {} {} — would write cora MCP server entry",
"🔍 ".cyan(),
agent.config_path.display()
))
} else {
agent_config::write_yaml_config(&agent.config_path, &config)?;
Ok(format!(
" {} {} — cora MCP server entry added",
"✓ ".green(),
agent.config_path.display()
))
}
}
}
}
}

Expand Down Expand Up @@ -426,13 +371,6 @@ pub fn execute_install(opts: &InstallOptions) -> Result<String> {
));
}
}
ConfigFormat::Yaml => {
lines.push(format!(
" {} {} — skipped (YAML validation not implemented)",
"⏭ ".dimmed(),
agent.config_path.display()
));
}
}
}
if errors > 0 {
Expand Down Expand Up @@ -469,7 +407,6 @@ mod tests {
agents: None,
dry_run: false,
force: false,
yes: true,
remove: false,
validate: false,
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ mod tests {
(conn, pid)
}

fn edge(caller: &str, callee: &str, line: u32) -> crate::index::CallEdge {
crate::index::CallEdge {
fn edge(caller: &str, callee: &str, line: u32) -> crate::index::graph::CallEdge {
crate::index::graph::CallEdge {
caller: caller.into(),
callee: callee.into(),
file: "src/main.rs".into(),
Expand Down
1 change: 0 additions & 1 deletion src/engine/bundling/grouping.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[allow(dead_code)]
/// Grouping strategies for bundling files into LLM-friendly groups.
use std::collections::HashMap;

Expand Down
5 changes: 3 additions & 2 deletions src/engine/bundling/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[allow(dead_code, unused)]
/// File bundling engine — groups files into cohesive units for LLM review.
///
/// Instead of arbitrary batching by character count alone, the bundling engine
Expand Down Expand Up @@ -26,8 +25,10 @@
/// // send content to LLM
/// }
/// ```
// The grouping engine is not called by review yet (#792).
#[allow(dead_code)]
pub mod grouping;
#[allow(dead_code)]
pub mod types;

#[allow(dead_code, unused)]
pub use types::GroupingStrategy;
1 change: 0 additions & 1 deletion src/engine/bundling/types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[allow(dead_code)]
/// Bundling types — configuration and data structures for file grouping.
use serde::{Deserialize, Serialize};

Expand Down
16 changes: 1 addition & 15 deletions src/engine/context/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,13 +734,6 @@ fn find_fn_in_file_cached(
find_pattern_with_body(&content, &pattern, MAX_FN_LINES)
}

/// Generic function search (for languages without specific patterns).
#[allow(dead_code)]
fn find_fn_generic(path: &Path, name: &str) -> Option<(u32, u32)> {
let content = std::fs::read_to_string(path).ok()?;
find_pattern_with_body(&content, &format!("fn {name}"), MAX_FN_LINES)
}

/// Cached version of `find_fn_generic`.
fn find_fn_generic_cached(
path: &Path,
Expand All @@ -751,13 +744,6 @@ fn find_fn_generic_cached(
find_pattern_with_body(&content, &format!("fn {name}"), MAX_FN_LINES)
}

/// Find a pattern (like `struct Foo`) and determine its extent.
#[allow(dead_code)]
fn find_pattern_in_file(path: &Path, pattern: &str) -> Option<(u32, u32)> {
let content = std::fs::read_to_string(path).ok()?;
find_pattern_with_body(&content, pattern, MAX_TYPE_LINES)
}

/// Cached version of `find_pattern_in_file`.
fn find_pattern_in_file_cached(
path: &Path,
Expand Down Expand Up @@ -907,7 +893,7 @@ fn find_go_package_file(dir: &Path, import_path: &str) -> Option<ContextEntry> {
/// never scanned, and is bounded by [`MAX_CALLER_FILES_SCAN`] files and
/// [`MAX_CALLERS_PER_SYMBOL`] call-sites per symbol. Caller slices are tiny
/// (the call line + 1 line of context) to stay token-economical.
#[allow(dead_code)]
#[cfg(test)]
fn resolve_callers(
defs: &[DefinedSymbol],
config: &ContextConfig,
Expand Down
5 changes: 3 additions & 2 deletions src/engine/context/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,16 @@ impl std::fmt::Display for SymbolKind {

/// A single symbol extracted from a changed line, with source location.
#[derive(Debug, Clone)]
#[allow(dead_code)] // fields consumed in v0.5 when bundling wired
pub struct ExtractedSymbol {
/// What kind of symbol this is.
pub kind: SymbolKind,
/// The file path where the symbol was found.
pub file: String,
/// Line number in the file (1-indexed).
#[allow(dead_code)] // set, never read until bundling is wired (#792)
pub line: u32,
/// The raw text that matched (for debugging).
#[allow(dead_code)] // same (#792)
pub raw: String,
}

Expand Down Expand Up @@ -210,11 +211,11 @@ pub struct ContextStats {

/// The fully assembled context chain, ready for prompt injection.
#[derive(Debug, Clone, Default)]
#[allow(dead_code)] // stats consumed in v0.5 when bundling wired
pub struct ContextChain {
/// Formatted text to inject into the prompt.
pub text: String,
/// Build statistics.
#[allow(dead_code)] // set, never read until bundling is wired (#792)
pub stats: ContextStats,
}

Expand Down
2 changes: 1 addition & 1 deletion src/engine/diff_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ pub fn detect_language(path: &str) -> &'static str {
/// Extract all added lines from parsed file chunks.
///
/// Returns `(file_path, line_number, content)` triples.
#[allow(dead_code)] // used by bundling in v0.5
#[allow(dead_code)] // for the bundling engine, not wired yet (#792)
pub fn extract_added_lines(chunks: &[FileChunk]) -> Vec<(String, u32, String)> {
let mut result = Vec::new();

Expand Down
28 changes: 3 additions & 25 deletions src/engine/index_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ impl IndexBridge {
}

/// The resolved project id (if available).
#[allow(dead_code)]
#[inline]
#[cfg(test)]
pub fn project_id(&self) -> Option<i64> {
self.project_id
}
Expand Down Expand Up @@ -264,7 +264,7 @@ impl IndexBridge {
///
/// Returns up to `limit` [`crate::index::brain::BrainResult`] entries.
/// Returns an empty vec if the bridge is unavailable.
#[allow(dead_code)]
#[cfg(test)]
pub fn brain_search(&self, query: &str, limit: usize) -> Vec<crate::index::brain::BrainResult> {
let conn = match self.conn.as_ref() {
Some(c) => c,
Expand All @@ -278,34 +278,12 @@ impl IndexBridge {
crate::index::brain::brain_search(conn, pid, query, limit).unwrap_or_default()
}

/// Run an impact analysis (blast radius) for the given symbol.
///
/// Returns [`crate::index::graph::ImpactNode`] entries up to `depth`.
/// Returns an empty vec if the bridge is unavailable.
#[allow(dead_code)]
pub fn impact_analysis(
&self,
symbol_name: &str,
depth: u32,
) -> Vec<crate::index::graph::ImpactNode> {
let conn = match self.conn.as_ref() {
Some(c) => c,
None => return Vec::new(),
};
let pid = match self.project_id {
Some(id) => id,
None => return Vec::new(),
};

crate::index::graph::impact_analysis(conn, pid, symbol_name, depth).unwrap_or_default()
}

/// Direct access to the underlying connection (if available).
///
/// Used by callers that need raw SQL beyond the typed helpers above.
/// Returns `None` if the bridge is unavailable.
#[allow(dead_code)]
#[inline]
#[cfg(test)]
pub fn connection(&self) -> Option<&Connection> {
self.conn.as_ref()
}
Expand Down
2 changes: 1 addition & 1 deletion src/engine/language_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn build_language_context_from_chunks(chunks: &[diff_parser::FileChunk]) ->
}

/// Build language-specific context string from raw diff text.
#[allow(dead_code)]
#[cfg(test)]
pub fn build_language_context(diff_text: &str) -> String {
let chunks = diff_parser::parse_diff(diff_text);
let languages = detect_languages(&chunks);
Expand Down
4 changes: 2 additions & 2 deletions src/engine/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Default for MemoryBackend {

impl MemoryBackend {
/// Create a new memory backend with the given namespace.
#[allow(dead_code)]
#[cfg(test)]
pub fn new(namespace: &str) -> Self {
Self {
enabled: false,
Expand Down Expand Up @@ -135,7 +135,7 @@ impl MemoryBackend {
/// Save false positive feedback to Uteke.
///
/// Calls: `uteke remember "cora:{project}:fp:{issue_id}" --tags cora,false-positive`
#[allow(dead_code)]
#[cfg(test)]
pub fn save_feedback(&self, project: &str, issue_id: &str, feedback: &str) {
if !self.enabled {
return;
Expand Down
Loading
Loading