{
  "name": "forge-codebase",
  "language": "rust",
  "version": "0.2.0",
  "description": "Codebase intelligence primitives for the Forge SDK \u2014 repo understanding, dependency graphs, file relevance, and change impact analysis",
  "manifest": "forge-rs/crates/forge-codebase/Cargo.toml",
  "manifestSha256": "fde21c62cb34a37605a069b89d910814c08e98c469873fd0df626096f22b86a1",
  "status": "source-reference",
  "registryPublicationVerified": false,
  "route": "/libraries/rust/forge-codebase",
  "features": {},
  "files": [
    {
      "path": "forge-rs/crates/forge-codebase/src/error.rs",
      "sha256": "116abd8a59ff4af2837a5c1776d07b4f081a92664dc0651e2085b3958d261e17",
      "artifactSha256": "d3efd22af2d1233a4bcdc4444fc3223a91aea44ff2aa840182cd7b08d3964328",
      "url": "/reference/source/forge-rs/crates/forge-codebase/src/error.rs.txt",
      "declarations": [
        {
          "name": "::CodebaseError",
          "line": 9,
          "signature": "#[derive(Debug, Error)]\npub enum CodebaseError {\n    /// The repository path does not exist or is not a directory.\n    #[error(\n        \"repository path '{path}' does not exist or is not a directory; \\\n         provide an absolute path to a valid repository root\"\n    )]\n    InvalidRepoPath {\n        /// The path that was provided.\n        path: String,\n    },\n\n    /// A file could not be read.\n    #[error(\"failed to read file '{path}': {reason}\")]\n    FileReadFailed {\n        /// The file path.\n        path: String,\n        /// Why the read failed.\n        reason: String,\n    },\n\n    /// Dependency manifest parsing failed.\n    #[error(\"failed to parse dependency manifest '{path}': {reason}\")]\n    ManifestParseFailed {\n        /// The manifest file path.\n        path: String,\n        /// The parse error.\n        reason: String,\n    },\n\n    /// The task description for file ranking was empty.\n    #[error(\"task description must not be empty for file relevance ranking\")]\n    EmptyTaskDescription,\n\n    /// The file path for impact prediction was empty or invalid.\n    #[error(\"changed file path must not be empty for impact prediction\")]\n    EmptyChangedFile,\n\n    /// The crate/package name for context assembly was not found.\n    #[error(\n        \"crate or package '{name}' not found in repository at '{repo_path}'; \\\n         verify the name matches a Cargo.toml [package] name or package.json name\"\n    )]\n    CrateNotFound {\n        /// The crate/package name.\n        name: String,\n        /// The repository path.\n        repo_path: String,\n    },\n\n    /// An I/O error occurred.\n    #[error(\"I/O error during codebase analysis: {reason}\")]\n    IoError {\n        /// What went wrong.\n        reason: String,\n    },\n}",
          "documentation": "Errors that can occur during codebase analysis operations."
        },
        {
          "name": "::CodebaseResult",
          "line": 67,
          "signature": "pub type CodebaseResult<T> = Result<T, CodebaseError>;",
          "documentation": "A specialized `Result` type for `forge-codebase` operations."
        }
      ]
    },
    {
      "path": "forge-rs/crates/forge-codebase/src/lib.rs",
      "sha256": "64387f04a8c463e9be44a15914db583030763984b98f863a5cdb22712257f2e1",
      "artifactSha256": "d54bb78380aeabd32b8f647c7f2cfb520c1757d92b0354e3e987296ec7c3ee4a",
      "url": "/reference/source/forge-rs/crates/forge-codebase/src/lib.rs.txt",
      "declarations": [
        {
          "name": "error",
          "line": 61,
          "signature": "pub mod error;",
          "documentation": "# forge-codebase\n\nCodebase intelligence primitives for the Forge SDK.\n\nThis crate provides reusable runtime services for understanding codebases:\nrepository structure analysis, dependency graph awareness, file relevance\nranking, change impact heuristics, and crate/package-level context assembly.\n\nThese are **runtime services** -- not one-off prompt tricks. They produce\nstructured data that agents can consume for planning, implementation,\nreview, and impact analysis.\n\n# Capabilities\n\n| Service | Description |\n|---------|-------------|\n| **Repo Structure** | Directory tree, file classification, language detection |\n| **Dependency Graph** | Parse Cargo.toml, package.json, go.mod for dependency relationships |\n| **File Relevance** | Given a task description, rank files by likely relevance |\n| **Change Impact** | Given a changed file, predict what else is affected |\n| **Context Assembly** | Gather all relevant context for a crate/package |\n\n# Architecture\n\n```text\nRepoRoot (path to repository)\n    |\n    v\nRepoAnalyzer\n    +--> analyze_structure()    --> RepoStructure\n    +--> parse_dependencies()   --> DependencyGraph\n    +--> rank_files()           --> Vec<RankedFile>\n    +--> predict_impact()       --> ImpactReport\n    +--> assemble_context()     --> CrateContext\n    |\n    v\nTool Registration (register_codebase_tools)\n```\n\n# Tool Classification\n\nAll codebase tools are classified as `ToolTier::External` (Tier 2) because\nthey access the filesystem outside the WASM sandbox.\n\n# Examples\n\n```\nuse forge_codebase::tools::register_codebase_tools;\nuse forge_tool::registry::ToolRegistry;\n\nlet mut registry = ToolRegistry::new();\nregister_codebase_tools(&mut registry).unwrap();\nassert!(registry.contains(\"repo_structure\"));\nassert!(registry.contains(\"dependency_graph\"));\nassert!(registry.contains(\"rank_files\"));\nassert!(registry.contains(\"predict_impact\"));\nassert!(registry.contains(\"assemble_context\"));\n```"
        },
        {
          "name": "structure",
          "line": 62,
          "signature": "pub mod structure;",
          "documentation": ""
        },
        {
          "name": "tools",
          "line": 63,
          "signature": "pub mod tools;",
          "documentation": ""
        },
        {
          "name": "types",
          "line": 64,
          "signature": "pub mod types;",
          "documentation": ""
        },
        {
          "name": "prelude",
          "line": 67,
          "signature": "pub mod prelude;",
          "documentation": "Re-exports of the most commonly used types."
        },
        {
          "name": "pub use crate::error::{CodebaseError, CodebaseResult};",
          "line": 68,
          "signature": "pub use crate::error::{CodebaseError, CodebaseResult};",
          "documentation": ""
        },
        {
          "name": "pub use crate::structure::{classify_file, detect_language, FileClassification, Language};",
          "line": 69,
          "signature": "pub use crate::structure::{classify_file, detect_language, FileClassification, Language};",
          "documentation": ""
        },
        {
          "name": "pub use crate::tools::{register_codebase_tools, CODEBASE_TOOL_NAMES};",
          "line": 70,
          "signature": "pub use crate::tools::{register_codebase_tools, CODEBASE_TOOL_NAMES};",
          "documentation": ""
        },
        {
          "name": "pub use crate::types::{\n        CrateContext, DependencyEntry, DependencyGraph, FileEntry, ImpactReport, RankedFile,\n        RepoStructure,\n    };",
          "line": 71,
          "signature": "pub use crate::types::{\n        CrateContext, DependencyEntry, DependencyGraph, FileEntry, ImpactReport, RankedFile,\n        RepoStructure,\n    };",
          "documentation": ""
        }
      ]
    },
    {
      "path": "forge-rs/crates/forge-codebase/src/structure.rs",
      "sha256": "400b2cb202ba288730043722575a531691282f55e11bb9efd584bf52fbc4b03f",
      "artifactSha256": "6c28044115719b634654deb46f4f18b0fad8eacf44d00c1e1742a82fa5173f7e",
      "url": "/reference/source/forge-rs/crates/forge-codebase/src/structure.rs.txt",
      "declarations": [
        {
          "name": "::FileClassification",
          "line": 33,
          "signature": "#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]\n#[serde(rename_all = \"snake_case\")]\npub enum FileClassification {\n    /// Source code files (.rs, .ts, .go, .py, etc.)\n    Source,\n    /// Test files (files in test directories or with test suffixes)\n    Test,\n    /// Configuration files (Cargo.toml, package.json, .env, etc.)\n    Config,\n    /// Documentation files (.md, .txt, .rst, etc.)\n    Documentation,\n    /// Build artifacts and generated files\n    Generated,\n    /// CI/CD configuration (.github/workflows, .gitlab-ci.yml, etc.)\n    Ci,\n    /// Data files (.json, .yaml, .csv, .sql, etc.)\n    Data,\n    /// Media files (images, fonts, etc.)\n    Media,\n    /// Lock files (Cargo.lock, package-lock.json, etc.)\n    Lock,\n    /// Schema files (.json schema, .proto, .graphql, etc.)\n    Schema,\n    /// Unknown file type\n    Unknown,\n}",
          "documentation": "Classification of a file's role in a codebase.\n\n# Examples\n\n```\nuse forge_codebase::structure::FileClassification;\n\nlet cls = FileClassification::Source;\nassert_eq!(cls.as_str(), \"source\");\n```"
        },
        {
          "name": "::FileClassification::as_str",
          "line": 60,
          "signature": "pub fn as_str(&self) -> &'static str;",
          "documentation": "Returns the string representation of this classification."
        },
        {
          "name": "::Language",
          "line": 95,
          "signature": "#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]\n#[serde(rename_all = \"snake_case\")]\npub enum Language {\n    /// Rust (.rs)\n    Rust,\n    /// TypeScript (.ts, .tsx)\n    TypeScript,\n    /// JavaScript (.js, .jsx, .mjs, .cjs)\n    JavaScript,\n    /// Go (.go)\n    Go,\n    /// Python (.py)\n    Python,\n    /// Swift (.swift)\n    Swift,\n    /// Kotlin (.kt, .kts)\n    Kotlin,\n    /// Java (.java)\n    Java,\n    /// C (.c, .h)\n    C,\n    /// C++ (.cpp, .cc, .cxx, .hpp, .hh)\n    Cpp,\n    /// Shell (.sh, .bash, .zsh)\n    Shell,\n    /// SQL (.sql)\n    Sql,\n    /// HTML (.html, .htm)\n    Html,\n    /// CSS (.css, .scss, .sass, .less)\n    Css,\n    /// TOML (.toml)\n    Toml,\n    /// YAML (.yaml, .yml)\n    Yaml,\n    /// JSON (.json)\n    Json,\n    /// Markdown (.md)\n    Markdown,\n    /// Protocol Buffers (.proto)\n    Protobuf,\n    /// GraphQL (.graphql, .gql)\n    GraphQL,\n    /// Zig (.zig)\n    Zig,\n}",
          "documentation": "Programming language detected from a file path.\n\n# Examples\n\n```\nuse forge_codebase::structure::Language;\n\nlet lang = Language::Rust;\nassert_eq!(lang.as_str(), \"rust\");\n```"
        },
        {
          "name": "::Language::as_str",
          "line": 142,
          "signature": "pub fn as_str(&self) -> &'static str;",
          "documentation": "Returns the string representation of this language."
        },
        {
          "name": "::classify_file",
          "line": 200,
          "signature": "pub fn classify_file(path: &str) -> FileClassification;",
          "documentation": "Classifies a file based on its path and name.\n\nUses extension, directory patterns, and well-known file names to determine\nthe file's role in the codebase.\n\n# Arguments\n\n* `path` - The file path (relative or absolute).\n\n# Returns\n\nA [`FileClassification`] indicating the file's role.\n\n# Examples\n\n```\nuse forge_codebase::structure::{classify_file, FileClassification};\n\nassert_eq!(classify_file(\"src/main.rs\"), FileClassification::Source);\nassert_eq!(classify_file(\"tests/unit_test.rs\"), FileClassification::Test);\nassert_eq!(classify_file(\"Cargo.toml\"), FileClassification::Config);\nassert_eq!(classify_file(\"README.md\"), FileClassification::Documentation);\nassert_eq!(classify_file(\"Cargo.lock\"), FileClassification::Lock);\nassert_eq!(classify_file(\".github/workflows/ci.yml\"), FileClassification::Ci);\n```"
        },
        {
          "name": "::detect_language",
          "line": 368,
          "signature": "pub fn detect_language(path: &str) -> Option<Language>;",
          "documentation": "Detects the programming language of a file from its path.\n\n# Arguments\n\n* `path` - The file path (relative or absolute).\n\n# Returns\n\n`Some(Language)` if the language could be detected, `None` otherwise.\n\n# Examples\n\n```\nuse forge_codebase::structure::{detect_language, Language};\n\nassert_eq!(detect_language(\"main.rs\"), Some(Language::Rust));\nassert_eq!(detect_language(\"app.tsx\"), Some(Language::TypeScript));\nassert_eq!(detect_language(\"go.mod\"), Some(Language::Go));\nassert_eq!(detect_language(\"image.png\"), None);\n```"
        }
      ]
    },
    {
      "path": "forge-rs/crates/forge-codebase/src/tools.rs",
      "sha256": "c29d39239e7e6ff55f0934e9d3f10955989e5077e316f0951e34cbef28234f93",
      "artifactSha256": "8a4e0b2aa2f6eede939a177dbb9fb840a88f8bb97ab53fc06b4d99d2996b55d4",
      "url": "/reference/source/forge-rs/crates/forge-codebase/src/tools.rs.txt",
      "declarations": [
        {
          "name": "::CODEBASE_TOOL_NAMES",
          "line": 38,
          "signature": "pub const CODEBASE_TOOL_NAMES: &[&str];",
          "documentation": "The names of all codebase intelligence tools."
        },
        {
          "name": "::codebase_tool_definitions",
          "line": 60,
          "signature": "pub fn codebase_tool_definitions() -> Vec<ToolDefinition>;",
          "documentation": "Returns the tool definitions for all codebase intelligence tools.\n\n# Returns\n\nA `Vec` of 5 [`ToolDefinition`] values.\n\n# Examples\n\n```\nuse forge_codebase::tools::codebase_tool_definitions;\n\nlet defs = codebase_tool_definitions();\nassert_eq!(defs.len(), 5);\n```"
        },
        {
          "name": "::register_codebase_tools",
          "line": 94,
          "signature": "pub fn register_codebase_tools(registry: &mut ToolRegistry) -> Result<(), ForgeToolError>;",
          "documentation": "Registers all 5 codebase intelligence tools into the given [`ToolRegistry`].\n\n# Arguments\n\n* `registry` - The tool registry to register tools into.\n\n# Returns\n\n`Ok(())` if all tools are registered successfully.\n\n# Errors\n\nReturns [`ForgeToolError::RegistryError`] if any tool name is already registered.\n\n# Examples\n\n```\nuse forge_codebase::tools::register_codebase_tools;\nuse forge_tool::registry::ToolRegistry;\n\nlet mut registry = ToolRegistry::new();\nregister_codebase_tools(&mut registry).unwrap();\nassert!(registry.contains(\"repo_structure\"));\n```"
        }
      ]
    },
    {
      "path": "forge-rs/crates/forge-codebase/src/types.rs",
      "sha256": "5af4d4780007cb40ca7487484c243707a317bc76178ae5a0c565e5527efd7c5e",
      "artifactSha256": "75f1f7f6c793fb7e5f18c9ce7f859e3a5ffc0a05b2e92d1a4c66c71673727ee7",
      "url": "/reference/source/forge-rs/crates/forge-codebase/src/types.rs.txt",
      "declarations": [
        {
          "name": "::FileEntry",
          "line": 27,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct FileEntry {\n/// Relative path from the repository root.\n\npub path: String,\n/// Classification of the file's role.\n\npub classification: FileClassification,\n/// Programming language, if detected.\n\npub language: Option<Language>,\n/// File size in bytes.\n\npub size_bytes: u64\n}",
          "documentation": "A single file entry in the repository structure.\n\n# Examples\n\n```\nuse forge_codebase::types::FileEntry;\nuse forge_codebase::structure::{FileClassification, Language};\n\nlet entry = FileEntry {\n    path: \"src/main.rs\".to_string(),\n    classification: FileClassification::Source,\n    language: Some(Language::Rust),\n    size_bytes: 1024,\n};\nassert_eq!(entry.path, \"src/main.rs\");\n```"
        },
        {
          "name": "::RepoStructure",
          "line": 60,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct RepoStructure {\n/// Absolute path to the repository root.\n\npub root_path: String,\n/// All files in the repository.\n\npub files: Vec<FileEntry>,\n/// Total number of files.\n\npub total_files: usize,\n/// Total size of all files in bytes.\n\npub total_size_bytes: u64,\n/// Count of files per detected language.\n\npub language_counts: std::collections::BTreeMap<String, usize>,\n/// Count of files per classification.\n\npub classification_counts: std::collections::BTreeMap<String, usize>,\n/// Top-level directories.\n\npub directories: Vec<String>\n}",
          "documentation": "The complete structure of a repository.\n\nContains all files organized by classification, with language statistics\nand directory structure.\n\n# Examples\n\n```\nuse forge_codebase::types::RepoStructure;\n\nlet structure = RepoStructure {\n    root_path: \"/repo\".to_string(),\n    files: vec![],\n    total_files: 0,\n    total_size_bytes: 0,\n    language_counts: std::collections::BTreeMap::new(),\n    classification_counts: std::collections::BTreeMap::new(),\n    directories: vec![],\n};\nassert_eq!(structure.total_files, 0);\n```"
        },
        {
          "name": "::DependencyEntry",
          "line": 95,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct DependencyEntry {\n/// The dependency name.\n\npub name: String,\n/// The version requirement or resolved version.\n\npub version: Option<String>,\n/// The source (e.g., \"crates.io\", \"npm\", \"path\", \"git\").\n\npub source: String,\n/// Whether this is a dev-only dependency.\n\npub is_dev: bool,\n/// Whether this comes from a workspace declaration.\n\npub is_workspace: bool,\n/// Path dependency location, if applicable.\n\npub path: Option<String>\n}",
          "documentation": "A dependency entry parsed from a manifest file.\n\n# Examples\n\n```\nuse forge_codebase::types::DependencyEntry;\n\nlet dep = DependencyEntry {\n    name: \"serde\".to_string(),\n    version: Some(\"1.0\".to_string()),\n    source: \"crates.io\".to_string(),\n    is_dev: false,\n    is_workspace: false,\n    path: None,\n};\nassert_eq!(dep.name, \"serde\");\n```"
        },
        {
          "name": "::DependencyGraph",
          "line": 127,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct DependencyGraph {\n/// Path to the manifest file.\n\npub manifest_path: String,\n/// Type of manifest (\"cargo\", \"npm\", \"go\", \"python\").\n\npub manifest_type: String,\n/// The package/crate name from the manifest.\n\npub package_name: Option<String>,\n/// All declared dependencies.\n\npub dependencies: Vec<DependencyEntry>,\n/// Workspace members (for Cargo workspaces or npm workspaces).\n\npub workspace_members: Vec<String>\n}",
          "documentation": "A dependency graph parsed from manifest files.\n\n# Examples\n\n```\nuse forge_codebase::types::DependencyGraph;\n\nlet graph = DependencyGraph {\n    manifest_path: \"Cargo.toml\".to_string(),\n    manifest_type: \"cargo\".to_string(),\n    package_name: Some(\"my-crate\".to_string()),\n    dependencies: vec![],\n    workspace_members: vec![],\n};\nassert_eq!(graph.manifest_type, \"cargo\");\n```"
        },
        {
          "name": "::RankedFile",
          "line": 155,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct RankedFile {\n/// The file path relative to the repository root.\n\npub path: String,\n/// Relevance score (0.0 to 1.0, higher = more relevant).\n\npub relevance_score: f64,\n/// Human-readable reasons for the ranking.\n\npub reasons: Vec<String>\n}",
          "documentation": "A file ranked by relevance to a given task.\n\n# Examples\n\n```\nuse forge_codebase::types::RankedFile;\n\nlet ranked = RankedFile {\n    path: \"src/auth.rs\".to_string(),\n    relevance_score: 0.85,\n    reasons: vec![\"filename matches task keyword 'auth'\".to_string()],\n};\nassert!(ranked.relevance_score > 0.5);\n```"
        },
        {
          "name": "::ImpactReport",
          "line": 182,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct ImpactReport {\n/// The file that was changed.\n\npub changed_file: String,\n/// Files that directly import/use the changed file.\n\npub directly_affected: Vec<String>,\n/// Files that are transitively affected.\n\npub transitively_affected: Vec<String>,\n/// Test files that should be re-run.\n\npub affected_tests: Vec<String>,\n/// Risk level: \"low\", \"medium\", \"high\", \"critical\".\n\npub risk_level: String,\n/// Human-readable summary of the impact.\n\npub summary: String\n}",
          "documentation": "An impact report predicting what is affected by a change.\n\n# Examples\n\n```\nuse forge_codebase::types::ImpactReport;\n\nlet report = ImpactReport {\n    changed_file: \"src/auth.rs\".to_string(),\n    directly_affected: vec![\"src/api/handler.rs\".to_string()],\n    transitively_affected: vec![],\n    affected_tests: vec![\"tests/auth_test.rs\".to_string()],\n    risk_level: \"medium\".to_string(),\n    summary: \"Changes to auth.rs affect 1 direct dependent\".to_string(),\n};\nassert_eq!(report.risk_level, \"medium\");\n```"
        },
        {
          "name": "::CrateContext",
          "line": 221,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct CrateContext {\n/// The crate/package name.\n\npub name: String,\n/// Path to the crate root directory.\n\npub root_path: String,\n/// Path to the manifest file (Cargo.toml, package.json, etc.).\n\npub manifest_path: String,\n/// Source code files in this crate.\n\npub source_files: Vec<String>,\n/// Test files for this crate.\n\npub test_files: Vec<String>,\n/// Documentation files for this crate.\n\npub doc_files: Vec<String>,\n/// Dependencies of this crate.\n\npub dependencies: Vec<DependencyEntry>,\n/// Other crates/packages that depend on this one.\n\npub dependents: Vec<String>,\n/// Approximate total lines of source code.\n\npub total_lines: u64\n}",
          "documentation": "Assembled context for a specific crate or package.\n\nContains everything an agent needs to understand a crate: its manifest,\nsource files, tests, dependencies, and documentation.\n\n# Examples\n\n```\nuse forge_codebase::types::CrateContext;\n\nlet ctx = CrateContext {\n    name: \"forge-tool\".to_string(),\n    root_path: \"crates/forge-tool\".to_string(),\n    manifest_path: \"crates/forge-tool/Cargo.toml\".to_string(),\n    source_files: vec![\"src/lib.rs\".to_string()],\n    test_files: vec![],\n    doc_files: vec![\"README.md\".to_string()],\n    dependencies: vec![],\n    dependents: vec![],\n    total_lines: 500,\n};\nassert_eq!(ctx.name, \"forge-tool\");\n```"
        }
      ]
    }
  ]
}
