diff --git a/src/core/tools/code-metrics.xml b/src/core/tools/code-metrics.xml new file mode 100644 index 00000000..ed31c137 --- /dev/null +++ b/src/core/tools/code-metrics.xml @@ -0,0 +1,111 @@ + + + Analyze codebase for size, complexity, and quality metrics + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Find all files matching include patterns + Exclude directories from exclude list + Build file list for analysis + + + + For each file, count total, code, blank, comment lines + Aggregate totals by file type + + + + Parse functions/methods in each file + Calculate cyclomatic complexity per function + Identify deeply nested code blocks + + + + Detect duplicate code blocks + Find long functions (> 50 lines) + Find large files (> 500 lines) + Count TODO/FIXME comments + + + + Format metrics according to output parameter + Include recommendations for concerning metrics + + + + + ``` + Code Metrics Report + =================== + Project: {project_name} + Path: {path} + Date: {date} + + Size Metrics: + - Total Files: {total_files} + - Lines of Code: {lines_of_code} + - Blank Lines: {blank_lines} + - Comment Lines: {comment_lines} + - Comment Ratio: {comment_ratio}% + + Complexity Metrics: + - Avg Cyclomatic Complexity: {avg_complexity} + - Max Complexity: {max_complexity} ({max_complexity_file}) + - Deep Nesting Issues: {deep_nesting_count} + + Quality Metrics: + - Duplicate Code Blocks: {duplicate_count} + - Long Functions (>50 lines): {long_functions_count} + - Large Files (>500 lines): {large_files_count} + - TODO/FIXME Count: {todo_count} + + Structure: + - Avg File Size: {avg_file_size} lines + - Avg Function Size: {avg_function_size} lines + + Breakdown by Language: + {for each language} + - {language}: {file_count} files, {line_count} lines + {end for} + + Recommendations: + {recommendations} + ``` + + diff --git a/src/core/tools/context-extractor.xml b/src/core/tools/context-extractor.xml new file mode 100644 index 00000000..498d5362 --- /dev/null +++ b/src/core/tools/context-extractor.xml @@ -0,0 +1,123 @@ + + + Extract key context from codebase for AI agent consumption (patterns, conventions, critical files) + + + + + + + + + + Key directories and their purposes + + Directory listing (depth 3) + README.md + package.json / setup.py / Cargo.toml + + + + + Common patterns used in the codebase + + Import patterns + Naming conventions + Error handling patterns + Async patterns + + + + + Key dependencies and their usage + + package.json dependencies + Import frequency analysis + + + + + Coding conventions and style + + .eslintrc / .prettierrc + tsconfig.json / jsconfig.json + editorconfig + Observed patterns in code + + + + + Most important files to understand + + Entry points (index, main, app) + Configuration files + Type definitions + Shared utilities + + + + + + + List directories up to depth 3 + Identify key directory patterns (src, lib, tests, etc.) + Note technology indicators (package.json, Cargo.toml, etc.) + + + + Find entry files (index.ts, main.py, main.go, etc.) + Extract high-level architecture from imports + + + + Parse linter/formatter configs + Sample 10 representative files for pattern analysis + Identify naming conventions (camelCase, snake_case, etc.) + + + + Extract key dependencies from package manager files + Identify most-imported modules + Note framework/library choices + + + + Compile findings within max_tokens budget + Prioritize most critical information + Format for AI agent consumption + + + + + ```markdown + # Project Context + + ## Technology Stack + - Language: {language} + - Framework: {framework} + - Key Libraries: {libraries} + + ## Project Structure + ``` + {directory_tree} + ``` + + ## Entry Points + {entry_points} + + ## Coding Conventions + - Naming: {naming_convention} + - Formatting: {formatting_rules} + - Imports: {import_pattern} + + ## Key Patterns + {patterns} + + ## Critical Files + {critical_files} + + ## Dependencies + {key_dependencies} + ``` + + diff --git a/src/core/tools/dependency-check.xml b/src/core/tools/dependency-check.xml new file mode 100644 index 00000000..77718755 --- /dev/null +++ b/src/core/tools/dependency-check.xml @@ -0,0 +1,68 @@ + + + Scan project dependencies for outdated packages and known vulnerabilities + + + + + + + + + + + + + + + + + + + + + Scan {path} for package manager files + Identify primary package manager from detected files + Report: "No supported package manager detected" + + + + Execute audit command for detected package manager + Capture stdout and stderr + Parse output for vulnerabilities + + + + Run outdated check command (e.g., npm outdated, pip list --outdated) + Parse output for package versions + + + + Filter by severity_threshold + Format output according to output_format + + + + + ``` + Dependency Check Report + ======================= + Project: {project_name} + Package Manager: {package_manager} + Date: {date} + + Vulnerabilities: + - Critical: {critical_count} + - High: {high_count} + - Medium: {medium_count} + - Low: {low_count} + + Outdated Packages: {outdated_count} + + Top Issues: + 1. {top_issue_1} + 2. {top_issue_2} + 3. {top_issue_3} + ``` + + diff --git a/src/core/tools/schema-validator.xml b/src/core/tools/schema-validator.xml new file mode 100644 index 00000000..a78d4518 --- /dev/null +++ b/src/core/tools/schema-validator.xml @@ -0,0 +1,81 @@ + + + Validate JSON/YAML files against schemas (JSON Schema, OpenAPI, etc.) + + + + + + + + + + + + + + + + + + Read file content + Detect file format (JSON or YAML) + Parse content into object + Return: "Syntax error: {error_message}" + + + + + Check for $schema property (JSON Schema) + Check for openapi property (OpenAPI) + Check for asyncapi property (AsyncAPI) + Default to json-schema if detected + + + + + + Load schema from {schema} path + + + Use built-in schema for detected type + + + + + Run validation against schema + Collect all validation errors + Format error messages with line numbers (if possible) + + + + Return: "Valid {schema_type} document" + Return: "Validation errors: {errors}" + + + + + ``` + Schema Validation Report + ======================== + File: {file} + Schema Type: {schema_type} + Status: {valid|invalid} + + {if errors} + Errors ({error_count}): + {for each error} + - Line {line}: {path} + {message} + {end for} + {end if} + + {if warnings} + Warnings ({warning_count}): + {for each warning} + - {path}: {message} + {end for} + {end if} + ``` + +