forge-coder
Production-grade coding agent runtime — repo understanding, code search, dependency awareness, plan/implement/review cycles, and test verification loops
Production-grade coding agent runtime — repo understanding, code search, dependency awareness, plan/implement/review cycles, and test verification loops
Package contract
| Field | Value |
|---|---|
| Language | rust |
| Source version | 0.2.0 |
| Manifest | forge-rs/crates/forge-coder/Cargo.toml |
| Source files | 6 |
| Evidence | Source reference; registry publication and runtime conformance are separate checks |
Import boundary
use forge_coder;Use a source checkout or your verified private registry. Manifest coordinates identify the package; they do not establish that a public registry release exists.
Crate boundary
The following entries are taken from src/lib.rs. Feature conditions in the exact source still apply.
#[cfg(not(target_arch = "wasm32"))]
pub mod code_search;
#[cfg(not(target_arch = "wasm32"))]
pub mod cycle;
#[cfg(not(target_arch = "wasm32"))]
pub mod dependency;
pub mod error;
#[cfg(not(target_arch = "wasm32"))]
pub mod repo;
pub mod prelude;
#[cfg(not(target_arch = "wasm32"))]
pub use crate::code_search::{
CodeSearchEngine, SearchQuery, SearchResult, SearchScope, SymbolDefinition, SymbolKind,
};
#[cfg(not(target_arch = "wasm32"))]
pub use crate::cycle::{
CodingCycle, CodingTask, CyclePhase, PhaseArtifact, ReviewResult, TestRunResult,
};
#[cfg(not(target_arch = "wasm32"))]
pub use crate::dependency::{DependencyEdge, DependencyGraph, PackageNode};
pub use crate::error::{ForgeCoderError, ForgeCoderResult};
#[cfg(not(target_arch = "wasm32"))]
pub use crate::repo::{
DetectedBuildSystem, DetectedFramework, DetectedLanguage, RepoLayout, RepoProfile,
RepoScanner,
};Source reference
Download package reference JSON. Each original source file and generated declaration artifact has its own SHA-256 digest. Function bodies and constant values are omitted from downloads. These are source declaration inventories, not compiler-resolved rustdoc, TypeDoc, DocC, or Dokka output. Private modules can contain public declarations that are not reachable through the package boundary; consult the entry point before importing.
code_search.rs
Read declaration text · 10 declaration entries
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum SearchScope {
/// Search all files in the repository.
AllFiles,
/// Search only files with the given extensions.
Extensions(Vec<String>),
/// Search only within specific directories.
Directories(Vec<PathBuf>),
/// Search a specific file.
SingleFile(PathBuf),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchQuery {
/// The search pattern (literal string or regex).
pub pattern: String,
/// The scope to search within.
pub scope: SearchScope,
/// Maximum number of results to return.
pub max_results: usize,
/// Whether the search is case-sensitive.
pub case_sensitive: bool
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchResult {
/// The file path where the match was found.
pub path: PathBuf,
/// The 1-indexed line number of the match.
pub line_number: usize,
/// The content of the matching line.
pub line_content: String,
/// Optional column offset of the match within the line.
pub column: Option<usize>
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SymbolDefinition {
/// The symbol name.
pub name: String,
/// The kind of symbol (function, struct, enum, trait, etc.).
pub kind: SymbolKind,
/// The file where the symbol is defined.
pub file: PathBuf,
/// The line number of the definition.
pub line: usize,
/// The full line of the definition.
pub definition_line: String
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum SymbolKind {
/// A function or method.
Function,
/// A struct or class.
Struct,
/// An enum or enum variant.
Enum,
/// A trait or interface.
Trait,
/// A type alias.
TypeAlias,
/// A constant.
Constant,
/// A module or namespace.
Module,
/// A macro.
Macro,
/// An import or use statement.
Import,
/// Unknown symbol kind.
Unknown,
}
pub struct CodeSearchEngine {
}
pub fn new(root: &Path) -> Self;
pub async fn search(&self, query: SearchQuery) -> ForgeCoderResult<Vec<SearchResult>>;
pub async fn find_symbol(&self, symbol_name: &str) -> ForgeCoderResult<Vec<SymbolDefinition>>;
pub async fn read_lines(
&self,
path: &Path,
start_line: usize,
end_line: usize,
) -> ForgeCoderResult<Vec<(usize, String)>>;cycle.rs
Read declaration text · 24 declaration entries
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CodingTask {
/// Unique identifier for the task.
pub id: String,
/// Short title of the task.
pub title: String,
/// Detailed description of what needs to be done.
pub description: String,
/// Files that are expected to be modified.
pub target_files: Vec<PathBuf>,
/// Acceptance criteria that must be met.
pub acceptance_criteria: Vec<String>
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum CyclePhase {
/// Planning phase: understanding the task and creating an implementation plan.
Planning,
/// Implementation phase: writing the code.
Implementing,
/// Review phase: reviewing the changes for correctness and quality.
Reviewing,
/// Testing phase: running tests to verify the changes.
Testing,
/// The cycle completed successfully.
Completed,
/// The cycle failed and cannot proceed.
Failed,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReviewResult {
/// Whether the review approved the changes.
pub approved: bool,
/// The reviewer's DID.
pub reviewer_did: String,
/// Comments from the reviewer.
pub comments: Vec<String>,
/// Specific files flagged for revision.
pub flagged_files: Vec<PathBuf>
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TestRunResult {
/// Whether all tests passed.
pub all_passed: bool,
/// Total number of tests run.
pub total_tests: usize,
/// Number of tests that passed.
pub passed: usize,
/// Number of tests that failed.
pub failed: usize,
/// Number of tests that were skipped.
pub skipped: usize,
/// Failure messages for failed tests.
pub failure_messages: Vec<String>,
/// The test command that was run.
pub command: String,
/// The exit code of the test command.
pub exit_code: i32
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PhaseArtifact {
/// The phase that produced this artifact.
pub phase: CyclePhase,
/// Description of the artifact.
pub description: String,
/// The content of the artifact.
pub content: String,
/// When the artifact was produced.
pub produced_at: DateTime<Utc>
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CodingCycle {
}
pub fn new(agent_did: impl Into<String>, task: CodingTask) -> Self;
pub fn with_max_revisions(mut self, max: u32) -> Self;
pub fn with_max_fixes(mut self, max: u32) -> Self;
pub fn id(&self) -> &str;
pub fn agent_did(&self) -> &str;
pub fn task(&self) -> &CodingTask;
pub fn phase(&self) -> CyclePhase;
pub fn artifacts(&self) -> &[PhaseArtifact];
pub fn revision_count(&self) -> u32;
pub fn fix_count(&self) -> u32;
pub fn review_result(&self) -> Option<&ReviewResult>;
pub fn test_result(&self) -> Option<&TestRunResult>;
pub fn advance_to_implementing(&mut self, plan: String) -> Result<(), String>;
pub fn advance_to_reviewing(&mut self, change_summary: String) -> Result<(), String>;
pub fn record_review(&mut self, result: ReviewResult) -> Result<(), String>;
pub fn record_test_result(&mut self, result: TestRunResult) -> Result<(), String>;
pub fn mark_failed(&mut self, reason: &str);
pub fn is_terminal(&self) -> bool;dependency.rs
Read declaration text · 14 declaration entries
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PackageNode {
/// The package name.
pub name: String,
/// The path to the package directory.
pub path: PathBuf,
/// The path to the manifest file.
pub manifest_path: PathBuf,
/// The version string.
pub version: Option<String>
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DependencyEdge {
/// The package that depends on another (the "from" side).
pub from: String,
/// The package being depended on (the "to" side).
pub to: String,
/// Whether this is a dev-dependency.
pub is_dev: bool,
/// Whether this is a build-dependency.
pub is_build: bool
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DependencyGraph {
}
pub fn new() -> Self;
pub fn add_package(&mut self, node: PackageNode);
pub fn add_edge(&mut self, edge: DependencyEdge);
pub fn dependencies(&self, package: &str) -> Vec<&DependencyEdge>;
pub fn reverse_dependencies(&self, package: &str) -> Vec<&DependencyEdge>;
pub fn change_impact(&self, package: &str) -> Vec<String>;
pub fn packages(&self) -> Vec<&PackageNode>;
pub fn get_package(&self, name: &str) -> Option<&PackageNode>;
pub fn package_count(&self) -> usize;
pub fn edge_count(&self) -> usize;
pub async fn from_cargo_workspace(workspace_root: &Path) -> ForgeCoderResult<Self>;error.rs
Read declaration text · 2 declaration entries
#[derive(Debug, Error)]
pub enum ForgeCoderError {
/// Repository scanning failed.
#[error("repo scan failed for '{repo_path}': {reason}")]
RepoScanFailed {
/// The repo path that was being scanned.
repo_path: PathBuf,
/// What went wrong.
reason: String,
},
/// A code search operation failed.
#[error("code search failed in '{repo_path}' for query '{query}': {reason}")]
CodeSearchFailed {
/// The repo path that was being searched.
repo_path: PathBuf,
/// The search query.
query: String,
/// What went wrong.
reason: String,
},
/// Symbol lookup failed.
#[error("symbol '{symbol_name}' not found in '{repo_path}': searched {files_searched} files across {languages_searched} languages")]
SymbolNotFound {
/// The symbol being looked up.
symbol_name: String,
/// The repo path that was searched.
repo_path: PathBuf,
/// Number of files searched.
files_searched: usize,
/// Number of languages searched.
languages_searched: usize,
},
/// Dependency resolution failed.
#[error("dependency resolution failed for '{package_name}' in '{manifest_path}': {reason}")]
DependencyResolutionFailed {
/// The package that could not be resolved.
package_name: String,
/// The manifest file path.
manifest_path: PathBuf,
/// What went wrong.
reason: String,
},
/// The plan/implement/review cycle failed.
#[error(
"coding cycle '{cycle_id}' failed at phase '{phase}' for agent '{agent_did}': {reason}"
)]
CodingCycleFailed {
/// The cycle identifier.
cycle_id: String,
/// The phase that failed (plan, implement, review, test).
phase: String,
/// The DID of the agent running the cycle.
agent_did: String,
/// What went wrong.
reason: String,
},
/// Test execution failed.
#[error("test execution failed in '{test_path}': exit_code={exit_code}, {reason}")]
TestExecutionFailed {
/// The path to the test file or test target.
test_path: PathBuf,
/// The exit code of the test process.
exit_code: i32,
/// Description of what failed.
reason: String,
},
/// The context budget was exceeded.
#[error("context budget exceeded for agent '{agent_did}': used {tokens_used} of {budget} tokens; reduce scope or split across multiple cycles")]
ContextBudgetExceeded {
/// The DID of the agent that exceeded the budget.
agent_did: String,
/// Tokens consumed.
tokens_used: u64,
/// The budget that was set.
budget: u64,
},
/// The coder runtime failed to initialize.
#[error("coder runtime initialization failed for repo '{repo_path}': {reason}")]
InitializationFailed {
/// The repo where initialization was attempted.
repo_path: PathBuf,
/// What went wrong.
reason: String,
},
/// A crate/package skill pack could not be loaded.
#[error("skill pack '{skill_name}' could not be loaded for '{target_crate}': {reason}")]
SkillLoadFailed {
/// The skill pack that failed to load.
skill_name: String,
/// The target crate the skill was for.
target_crate: String,
/// What went wrong.
reason: String,
},
/// Provider routing for a coding task failed.
#[error("provider routing failed for coding task '{task_type}': {reason}")]
ProviderRoutingFailed {
/// The type of coding task.
task_type: String,
/// What went wrong.
reason: String,
},
/// Safety layer error (wraps forge-code-safety).
#[error("safety error: {0}")]
Safety(#[from] forge_code_safety::error::CodeSafetyError),
/// Core Forge error.
#[error("core error: {0}")]
Core(#[from] forge_core::error::ForgeError),
/// Agent runtime error.
#[error("agent error: {0}")]
Agent(#[from] forge_agent::error::ForgeAgentError),
/// Tool execution error.
#[error("tool error: {0}")]
Tool(#[from] forge_tool::error::ForgeToolError),
}
pub type ForgeCoderResult<T> = Result<T, ForgeCoderError>;lib.rs
Read declaration text · 11 declaration entries
#[cfg(not(target_arch = "wasm32"))]
pub mod code_search;
#[cfg(not(target_arch = "wasm32"))]
pub mod cycle;
#[cfg(not(target_arch = "wasm32"))]
pub mod dependency;
pub mod error;
#[cfg(not(target_arch = "wasm32"))]
pub mod repo;
pub mod prelude;
#[cfg(not(target_arch = "wasm32"))]
pub use crate::code_search::{
CodeSearchEngine, SearchQuery, SearchResult, SearchScope, SymbolDefinition, SymbolKind,
};
#[cfg(not(target_arch = "wasm32"))]
pub use crate::cycle::{
CodingCycle, CodingTask, CyclePhase, PhaseArtifact, ReviewResult, TestRunResult,
};
#[cfg(not(target_arch = "wasm32"))]
pub use crate::dependency::{DependencyEdge, DependencyGraph, PackageNode};
pub use crate::error::{ForgeCoderError, ForgeCoderResult};
#[cfg(not(target_arch = "wasm32"))]
pub use crate::repo::{
DetectedBuildSystem, DetectedFramework, DetectedLanguage, RepoLayout, RepoProfile,
RepoScanner,
};repo.rs
Read declaration text · 21 declaration entries
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DetectedLanguage {
/// The language name (e.g., "Rust", "TypeScript", "Python").
pub name: String,
/// The file extensions associated with this language.
pub extensions: Vec<String>,
/// The number of files detected for this language.
pub file_count: usize
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DetectedBuildSystem {
/// The build system name (e.g., "cargo", "npm", "go", "pip").
pub name: String,
/// The manifest file that identified this build system.
pub manifest_path: PathBuf,
/// Whether this is a workspace/monorepo manifest.
pub is_workspace: bool
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DetectedFramework {
/// The framework name (e.g., "tokio", "actix-web", "React", "FastAPI").
pub name: String,
/// The language this framework is associated with.
pub language: String,
/// How the framework was detected (manifest dependency, import, config file).
pub detection_method: String
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum RepoLayout {
/// A single-package repository.
SinglePackage,
/// A multi-package workspace (e.g., Cargo workspace, npm workspaces).
Workspace,
/// A monorepo with multiple independent packages.
Monorepo,
/// The layout could not be determined.
Unknown,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RepoProfile {
}
pub fn repo_root(&self) -> &Path;
pub fn languages(&self) -> &[DetectedLanguage];
pub fn build_systems(&self) -> &[DetectedBuildSystem];
pub fn frameworks(&self) -> &[DetectedFramework];
pub fn layout(&self) -> RepoLayout;
pub fn total_files(&self) -> usize;
pub fn total_directories(&self) -> usize;
pub fn key_directories(&self) -> &[PathBuf];
pub fn primary_language(&self) -> Option<&DetectedLanguage>;
pub fn uses_language(&self, name: &str) -> bool;
pub fn uses_build_system(&self, name: &str) -> bool;
pub struct RepoScanner {
}
pub fn new(root: &Path) -> Self;
pub fn with_max_depth(mut self, depth: usize) -> Self;
pub fn skip_directory(mut self, name: impl Into<String>) -> Self;
pub async fn scan(&self) -> ForgeCoderResult<RepoProfile>;