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
60 changes: 60 additions & 0 deletions .github/workflows/harmony-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Code Harmony Check

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
harmony-check:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'

- name: Install Python Code Harmonizer
run: |
python -m pip install --upgrade pip
pip install .

- name: Run Harmony Analysis
run: |
echo "========================================"
echo "Python Code Harmonizer - CI/CD Check"
echo "========================================"

# Analyze all Python files in src/ directory
harmonizer src/**/*.py || true

# Note: Currently harmonizer doesn't set exit codes based on scores
# Future enhancement: fail build if critical disharmony detected

echo ""
echo "✅ Harmony check completed"
echo "Review output above for any disharmony warnings"

- name: Analyze specific modules (optional)
run: |
# Example: Analyze specific critical modules with comments
echo ""
echo "Analyzing critical modules..."

# Add your critical files here
# harmonizer src/core/important.py
# harmonizer src/api/endpoints.py
continue-on-error: true

# Note: To make this workflow fail on high disharmony scores,
# you'll need to wrap harmonizer in a script that checks scores
# and exits with non-zero code if threshold exceeded.
#
# Example future enhancement:
# - name: Check harmony with threshold
# run: python scripts/ci_harmony_check.py --threshold 0.8 --fail-on-high
125 changes: 125 additions & 0 deletions .harmonizer.yml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Python Code Harmonizer Configuration Template
#
# NOTE: Configuration file support is planned for future release
# This template shows what configuration will look like when implemented
#
# Copy this file to .harmonizer.yml in your project root
# The harmonizer will read this configuration automatically

# Disharmony threshold (functions above this are flagged)
# Default: 0.5
# Range: 0.0 (very strict) to 2.0 (very lenient)
threshold: 0.5

# Output format
# Options: table, json, csv
# Default: table
output_format: table

# Severity level definitions
severity_levels:
critical: 1.2 # Score >= 1.2
high: 0.8 # Score >= 0.8
medium: 0.5 # Score >= 0.5
low: 0.3 # Score >= 0.3
excellent: 0.0 # Score < 0.3

# Files and patterns to ignore
ignore_patterns:
- "**/test_*.py" # Test files
- "**/tests/*.py" # Test directories
- "**/migrations/*.py" # Database migrations
- "**/*_test.py" # Alternative test naming
- "**/conftest.py" # Pytest configuration
- "**/__pycache__/**" # Python cache
- "**/.venv/**" # Virtual environments

# Files and patterns to include (overrides ignore if specified)
include_patterns:
- "src/**/*.py" # Source files
- "app/**/*.py" # Application files
# - "scripts/**/*.py" # Uncomment to include scripts

# Fail build in CI/CD if any function exceeds this threshold
# Set to null to never fail builds
# Default: null (warnings only)
fail_threshold: null
# fail_threshold: 1.0 # Uncomment to fail on critical disharmony

# Enable verbose output
# Default: false
verbose: false

# Show function details in output
# Default: true
show_function_details: true

# Sort results by score (descending)
# Default: true
sort_by_score: true

# Color output (for terminal)
# Default: true
color_output: true

# Custom vocabulary extensions
# Add domain-specific semantic mappings
# (Advanced: requires understanding of DIVE-V2 engine)
custom_vocabulary:
# Example: Map domain-specific terms
# "authenticate": "justice"
# "authorize": "power"
# "notify": "love"

# Report options
report:
# Show summary statistics
show_summary: true

# Show only disharmonious functions
only_show_disharmony: false

# Include harmonious functions in output
include_harmonious: true

# Maximum functions to display (0 = unlimited)
max_display: 0

# Future enhancement placeholders
# These will be implemented in upcoming versions

# auto_fix:
# enabled: false
# suggestions: true

# metrics:
# track_over_time: false
# output_file: "harmony_metrics.json"

# integrations:
# github:
# create_review_comments: false
# jira:
# create_tickets_for_critical: false

---

# Example configurations for different use cases:

# STRICT MODE (for new projects)
# threshold: 0.3
# fail_threshold: 0.5

# LENIENT MODE (for legacy code cleanup)
# threshold: 0.8
# fail_threshold: 1.2

# CI/CD MODE (fail on critical only)
# threshold: 0.5
# fail_threshold: 1.0
# only_show_disharmony: true

# DEVELOPMENT MODE (show everything)
# threshold: 0.5
# verbose: true
# show_function_details: true
51 changes: 51 additions & 0 deletions .pre-commit-config.yaml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Python Code Harmonizer - Pre-commit Hook Template
#
# Copy this file to .pre-commit-config.yaml in your project root
# Install pre-commit: pip install pre-commit
# Install hooks: pre-commit install
# Run manually: pre-commit run --all-files

repos:
# Standard pre-commit hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-merge-conflict
- id: check-python-syntax

# Python Code Formatting
- repo: https://github.com/psf/black
rev: 24.1.1
hooks:
- id: black
language_version: python3

# Python Linting
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8

# Python Code Harmonizer (Semantic Analysis)
- repo: local
hooks:
- id: harmonizer
name: Python Code Harmonizer
entry: harmonizer
language: system
types: [python]
pass_filenames: true
# Note: Install harmonizer first: pip install /path/to/Python-Code-Harmonizer

# Usage Notes:
# - This checks code harmony before every commit
# - To skip temporarily: git commit --no-verify
# - To run manually: pre-commit run harmonizer --all-files
#
# Customization:
# - Adjust 'pass_filenames: false' to check all files every time
# - Add 'args: ["--threshold", "0.8"]' when threshold support is added
71 changes: 71 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Harmonizer: Check Current File",
"type": "shell",
"command": "harmonizer",
"args": [
"${file}"
],
"problemMatcher": [],
"presentation": {
"reveal": "always",
"panel": "new",
"clear": true
},
"group": {
"kind": "test",
"isDefault": false
}
},
{
"label": "Harmonizer: Check All Source Files",
"type": "shell",
"command": "harmonizer",
"args": [
"src/**/*.py"
],
"problemMatcher": [],
"presentation": {
"reveal": "always",
"panel": "new",
"clear": true
},
"group": {
"kind": "test",
"isDefault": false
}
},
{
"label": "Harmonizer: Check Workspace",
"type": "shell",
"command": "find",
"args": [
".",
"-name",
"*.py",
"-not",
"-path",
"*/venv/*",
"-not",
"-path",
"*/.venv/*",
"-exec",
"harmonizer",
"{}",
";"
],
"problemMatcher": [],
"presentation": {
"reveal": "always",
"panel": "new",
"clear": true
},
"group": {
"kind": "test",
"isDefault": false
}
}
]
}
Loading
Loading