Skip to main content

skrills_intelligence/context/
mod.rs

1//! Project context analysis for skill recommendations.
2
3mod dependencies;
4mod detector;
5mod git_context;
6
7pub use dependencies::{parse_cargo_toml, parse_package_json, parse_pyproject_toml};
8pub use detector::{
9    analyze_project, analyze_project_with_options, detect_frameworks, detect_languages,
10    AnalyzeProjectOptions,
11};
12pub use git_context::extract_git_keywords;
13
14use serde::{Deserialize, Serialize};
15use std::collections::HashMap;
16use std::path::PathBuf;
17
18/// Project context profile.
19#[derive(Debug, Clone, Default, Serialize, Deserialize)]
20pub struct ProjectProfile {
21    /// Detected programming languages with file counts.
22    pub languages: HashMap<String, LanguageInfo>,
23    /// Project dependencies by ecosystem.
24    pub dependencies: HashMap<String, Vec<DependencyInfo>>,
25    /// Project description extracted from README.
26    pub description: Option<String>,
27    /// Keywords extracted from README and docs.
28    pub keywords: Vec<String>,
29    /// Recent commit message keywords.
30    pub git_keywords: Vec<String>,
31    /// Detected frameworks and tools.
32    pub frameworks: Vec<String>,
33    /// Project type classification.
34    pub project_type: ProjectType,
35    /// Root directory analyzed.
36    pub root: PathBuf,
37}
38
39/// Information about a detected programming language.
40#[derive(Debug, Clone, Serialize, Deserialize)]
41pub struct LanguageInfo {
42    /// Number of files in this language.
43    pub file_count: usize,
44    /// File extensions associated with this language.
45    pub extensions: Vec<String>,
46    /// Whether this is the primary language.
47    pub primary: bool,
48}
49
50/// Information about a project dependency.
51#[derive(Debug, Clone, Serialize, Deserialize)]
52pub struct DependencyInfo {
53    /// Dependency name.
54    pub name: String,
55    /// Version constraint if available.
56    pub version: Option<String>,
57    /// Whether this is a dev dependency.
58    pub dev: bool,
59}
60
61/// Classification of project type.
62#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]
63pub enum ProjectType {
64    /// Unknown project type.
65    #[default]
66    Unknown,
67    /// A library/package.
68    Library,
69    /// An application.
70    Application,
71    /// A plugin or extension.
72    Plugin,
73    /// A monorepo with multiple projects.
74    Monorepo,
75    /// A service or API.
76    Service,
77}