Skip to content
Open
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
62 changes: 62 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Pre-commit configuration for bash.d
# Install: pip install pre-commit && pre-commit install

repos:
# Python code formatting
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
types_or: [python, pyi]
- id: ruff-format
types_or: [python, pyi]

# General file checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
exclude: '\.md$'
- id: end-of-file-fixer
exclude: '\.md$'
- id: check-yaml
args: [--unsafe]
- id: check-json
- id: check-toml
- id: check-added-large-files
args: ['--maxkb=500']
- id: check-merge-conflict
- id: detect-private-key
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable

# Shell script linting
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
args: [--severity=warning]
types: [shell]
exclude: '(bash_history\.d|bash_secrets\.d)'

# Python type checking (optional, may be slow)
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.13.0
# hooks:
# - id: mypy
# args: [--ignore-missing-imports]
# additional_dependencies: [pydantic>=2.0]

# Commit message formatting
- repo: https://github.com/commitizen-tools/commitizen
rev: v4.1.0
hooks:
- id: commitizen
stages: [commit-msg]

# CI configuration
ci:
autofix_commit_msg: 'style: auto-fixes from pre-commit hooks'
autofix_prs: true
autoupdate_schedule: monthly
247 changes: 247 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
# bash.d - Makefile for project automation
# Usage: make [target]

.PHONY: help install install-dev test test-cov lint format clean docs \
check health agents-list agents-validate setup-hooks \
build docker-build docker-run index update-deps
Comment on lines +4 to +6
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟑 Minor

Add check to .PHONY declaration.

The check target on line 89 is not declared as .PHONY. If a file named check ever exists in the repo root, Make will skip executing this target. Add it to the PHONY list for correctness.

πŸ”§ Proposed fix
-.PHONY: help install install-dev test test-cov lint format clean docs \
-        check health agents-list agents-validate setup-hooks \
+.PHONY: help install install-dev test test-cov lint format clean docs check \
+        health agents-list agents-validate setup-hooks \
         build docker-build docker-run index update-deps

Also applies to: 89-89

🧰 Tools
πŸͺ› checkmake (0.2.2)

[warning] 4-4: Missing required phony target "all"

(minphony)

πŸ€– Prompt for AI Agents
In `@Makefile` around lines 4 - 6, The Makefile's .PHONY list is missing the check
target, so update the .PHONY declaration to include check (the .PHONY line that
currently lists help install install-dev test test-cov lint format clean docs
...). Add "check" to that comma/space-separated list so the Make target check is
always executed even if a file named check exists in the repo root.


# Default target
.DEFAULT_GOAL := help

# Colors for terminal output
BLUE := \033[34m
GREEN := \033[32m
YELLOW := \033[33m
RED := \033[31m
RESET := \033[0m

# Project paths
BASHD_HOME := $(shell pwd)
PYTHON := python3
PIP := pip3
PYTEST := $(PYTHON) -m pytest

#------------------------------------------------------------------------------
# Help
#------------------------------------------------------------------------------
help: ## Show this help message
@echo "$(BLUE)bash.d - Modular Bash Configuration Framework$(RESET)"
@echo ""
@echo "$(GREEN)Usage:$(RESET) make [target]"
@echo ""
@echo "$(YELLOW)Targets:$(RESET)"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-20s$(RESET) %s\n", $$1, $$2}'

#------------------------------------------------------------------------------
# Installation
#------------------------------------------------------------------------------
install: ## Install bash.d to ~/.bash.d
@echo "$(BLUE)Installing bash.d...$(RESET)"
./install.sh
@echo "$(GREEN)βœ“ Installation complete$(RESET)"

install-dev: ## Install development dependencies
@echo "$(BLUE)Installing development dependencies...$(RESET)"
$(PIP) install -r requirements.txt
$(PIP) install pre-commit
@echo "$(GREEN)βœ“ Development dependencies installed$(RESET)"

install-all: install install-dev setup-hooks ## Full installation with dev tools and hooks

#------------------------------------------------------------------------------
# Testing
#------------------------------------------------------------------------------
test: ## Run all tests
@echo "$(BLUE)Running tests...$(RESET)"
$(PYTEST) tests/ -v
@echo "$(GREEN)βœ“ Tests complete$(RESET)"

test-cov: ## Run tests with coverage report
@echo "$(BLUE)Running tests with coverage...$(RESET)"
$(PYTEST) tests/ -v --cov=agents --cov=tools --cov-report=term-missing --cov-report=html
@echo "$(GREEN)βœ“ Coverage report generated in htmlcov/$(RESET)"

test-quick: ## Run tests quickly (no verbose)
@$(PYTEST) tests/ -q

test-watch: ## Run tests in watch mode (requires pytest-watch)
$(PYTHON) -m pytest_watch tests/

#------------------------------------------------------------------------------
# Code Quality
#------------------------------------------------------------------------------
lint: ## Run linting checks
@echo "$(BLUE)Running linters...$(RESET)"
@$(PYTHON) -m ruff check agents/ tools/ tests/ --fix || true
@echo "$(GREEN)βœ“ Linting complete$(RESET)"

format: ## Format code with ruff
@echo "$(BLUE)Formatting code...$(RESET)"
@$(PYTHON) -m ruff format agents/ tools/ tests/
@echo "$(GREEN)βœ“ Formatting complete$(RESET)"

typecheck: ## Run type checking with mypy
@echo "$(BLUE)Running type checks...$(RESET)"
@$(PYTHON) -m mypy agents/ tools/ --ignore-missing-imports || true
@echo "$(GREEN)βœ“ Type checking complete$(RESET)"
Comment on lines +74 to +87
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Silencing linter/type-checker failures masks real issues.

The || true on lines 76 and 86 means make lint and make typecheck always exit 0, even when there are legitimate errors. This defeats the purpose of running these checks in CI or pre-commit. If a file has actual type errors or lint violations, you'll never know.

Either remove || true so failures propagate, or use a warning-only mode explicitly (e.g., --exit-zero for ruff if that's the intent).

πŸ”§ Proposed fix
 lint: ## Run linting checks
 	`@echo` "$(BLUE)Running linters...$(RESET)"
-	@$(PYTHON) -m ruff check agents/ tools/ tests/ --fix || true
+	@$(PYTHON) -m ruff check agents/ tools/ tests/ --fix
 	`@echo` "$(GREEN)βœ“ Linting complete$(RESET)"
 
 ...
 
 typecheck: ## Run type checking with mypy
 	`@echo` "$(BLUE)Running type checks...$(RESET)"
-	@$(PYTHON) -m mypy agents/ tools/ --ignore-missing-imports || true
+	@$(PYTHON) -m mypy agents/ tools/ --ignore-missing-imports
 	`@echo` "$(GREEN)βœ“ Type checking complete$(RESET)"
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
lint: ## Run linting checks
@echo "$(BLUE)Running linters...$(RESET)"
@$(PYTHON) -m ruff check agents/ tools/ tests/ --fix || true
@echo "$(GREEN)βœ“ Linting complete$(RESET)"
format: ## Format code with ruff
@echo "$(BLUE)Formatting code...$(RESET)"
@$(PYTHON) -m ruff format agents/ tools/ tests/
@echo "$(GREEN)βœ“ Formatting complete$(RESET)"
typecheck: ## Run type checking with mypy
@echo "$(BLUE)Running type checks...$(RESET)"
@$(PYTHON) -m mypy agents/ tools/ --ignore-missing-imports || true
@echo "$(GREEN)βœ“ Type checking complete$(RESET)"
lint: ## Run linting checks
`@echo` "$(BLUE)Running linters...$(RESET)"
@$(PYTHON) -m ruff check agents/ tools/ tests/ --fix
`@echo` "$(GREEN)βœ“ Linting complete$(RESET)"
format: ## Format code with ruff
`@echo` "$(BLUE)Formatting code...$(RESET)"
@$(PYTHON) -m ruff format agents/ tools/ tests/
`@echo` "$(GREEN)βœ“ Formatting complete$(RESET)"
typecheck: ## Run type checking with mypy
`@echo` "$(BLUE)Running type checks...$(RESET)"
@$(PYTHON) -m mypy agents/ tools/ --ignore-missing-imports
`@echo` "$(GREEN)βœ“ Type checking complete$(RESET)"
πŸ€– Prompt for AI Agents
In `@Makefile` around lines 74 - 87, The Makefile targets lint and typecheck
currently append "|| true" which masks failures; update the lint and typecheck
recipes (targets "lint" and "typecheck") to remove "|| true" so ruff and mypy
return nonzero on real errors, or if you intend to allow warnings keep "|| true"
but replace it with an explicit warning mode flag (e.g., ruff's --exit-zero) so
failures are intentional and visible in CI; adjust the commands invoking "ruff
check" and "mypy" accordingly to propagate failures or use the proper exit-zero
flag.


check: lint typecheck test ## Run all checks (lint, typecheck, test)

#------------------------------------------------------------------------------
# Project Health
#------------------------------------------------------------------------------
health: ## Check project health and status
@echo "$(BLUE)Checking project health...$(RESET)"
@$(PYTHON) scripts/project_health.py 2>/dev/null || $(PYTHON) -c "\
import os, glob, json; \
print('πŸ“Š Project Statistics:'); \
py_files = glob.glob('**/*.py', recursive=True); \
sh_files = glob.glob('**/*.sh', recursive=True); \
print(f' Python files: {len(py_files)}'); \
print(f' Shell scripts: {len(sh_files)}'); \
print(f' Agent modules: {len(glob.glob(\"agents/**/*.py\", recursive=True))}'); \
print(f' Test files: {len(glob.glob(\"tests/*.py\"))}'); \
print(f' Documentation: {len(glob.glob(\"**/*.md\", recursive=True))}'); \
"
@echo "$(GREEN)βœ“ Health check complete$(RESET)"
Comment on lines +94 to +107
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | πŸ”΅ Trivial

Inline Python fallback is functional but consider maintainability.

The health target's inline Python fallback works, but multi-line Python embedded in Makefiles is fragileβ€”escaping and quoting issues can be subtle. The primary path (scripts/project_health.py) is the right approach; just ensure that script is always available.

The 2>/dev/null suppression on line 96 silently hides why project_health.py failed. Consider logging a brief message before falling back.

πŸ€– Prompt for AI Agents
In `@Makefile` around lines 94 - 107, The health target currently silences errors
from running scripts/project_health.py with `2>/dev/null`, which hides why the
primary check failed; update the Makefile health target to not drop stderr and
instead log a brief error message before executing the inline fallback (e.g.,
run "$(PYTHON) scripts/project_health.py" and on failure echo
"scripts/project_health.py failed: <error>" or similar), and ensure
scripts/project_health.py is declared as the canonical, version-controlled
checker (or added as a Makefile prerequisite) so the fallback inline Python is
only a last-resort and easier to maintain.


outdated: ## Check for outdated dependencies
@echo "$(BLUE)Checking for outdated packages...$(RESET)"
@$(PIP) list --outdated 2>/dev/null | head -20 || echo "Unable to check"

validate: ## Validate all configurations
@echo "$(BLUE)Validating configurations...$(RESET)"
@$(PYTHON) -c "from agents import BaseAgent, AgentType; print('βœ“ Agent imports OK')"
@$(PYTHON) -c "from tools import ToolRegistry; print('βœ“ Tool imports OK')" 2>/dev/null || echo "⚠ Tool registry not found"
@bash -n bashrc && echo "βœ“ bashrc syntax OK" || echo "βœ— bashrc syntax error"
@echo "$(GREEN)βœ“ Validation complete$(RESET)"

#------------------------------------------------------------------------------
# Agents
#------------------------------------------------------------------------------
agents-list: ## List all available agents
@echo "$(BLUE)Available Agents:$(RESET)"
@find agents -name "*_agent.py" -type f | sed 's/agents\// /' | sed 's/_agent.py//' | sort

agents-validate: ## Validate all agent definitions
@echo "$(BLUE)Validating agents...$(RESET)"
@$(PYTHON) validate_master_agent.py 2>/dev/null || echo "Validation script not configured"

agents-demo: ## Run agent demo
@echo "$(BLUE)Running agent demo...$(RESET)"
@$(PYTHON) -m agents.demo_multiagent 2>/dev/null || echo "Demo not available"

#------------------------------------------------------------------------------
# Documentation
#------------------------------------------------------------------------------
docs: ## Generate documentation
@echo "$(BLUE)Generating documentation...$(RESET)"
@$(PYTHON) scripts/generate_docs.py 2>/dev/null || \
echo "Documentation generator not found. Creating basic index..."
@$(MAKE) docs-index
@echo "$(GREEN)βœ“ Documentation generated$(RESET)"

docs-index: ## Generate documentation index
@echo "$(BLUE)Generating docs index...$(RESET)"
@find docs -name "*.md" -type f | sort | \
awk '{print "- ["$$0"]("$$0")"}' > docs/INDEX.md 2>/dev/null || true
@echo "$(GREEN)βœ“ Index created at docs/INDEX.md$(RESET)"

docs-serve: ## Serve documentation locally (requires mkdocs)
@mkdocs serve 2>/dev/null || echo "mkdocs not installed. Run: pip install mkdocs"

#------------------------------------------------------------------------------
# Index & Search
#------------------------------------------------------------------------------
index: ## Build search index
@echo "$(BLUE)Building search index...$(RESET)"
@bash -c 'source bashrc 2>/dev/null && bashd_index_build' 2>/dev/null || \
bash lib/indexer.sh build 2>/dev/null || \
echo "Indexer not available"
@echo "$(GREEN)βœ“ Index built$(RESET)"

index-stats: ## Show index statistics
@bash -c 'source bashrc 2>/dev/null && bashd_index_stats' 2>/dev/null || \
echo "Index stats not available"

#------------------------------------------------------------------------------
# Cleanup
#------------------------------------------------------------------------------
clean: ## Clean generated files and caches
@echo "$(BLUE)Cleaning...$(RESET)"
@find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name ".mypy_cache" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name ".ruff_cache" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name "htmlcov" -exec rm -rf {} + 2>/dev/null || true
@find . -type f -name "*.pyc" -delete 2>/dev/null || true
@find . -type f -name ".coverage" -delete 2>/dev/null || true
@echo "$(GREEN)βœ“ Cleaned$(RESET)"

clean-all: clean ## Deep clean including index and logs
@rm -rf .bashd_index.json .bashd_cache 2>/dev/null || true
@find . -type d -name "logs_*" -exec rm -rf {} + 2>/dev/null || true
@echo "$(GREEN)βœ“ Deep clean complete$(RESET)"

#------------------------------------------------------------------------------
# Docker
#------------------------------------------------------------------------------
docker-build: ## Build Docker image
@echo "$(BLUE)Building Docker image...$(RESET)"
docker build -t bashd:latest .
@echo "$(GREEN)βœ“ Docker image built$(RESET)"

docker-run: ## Run Docker container
docker run -it --rm bashd:latest

docker-compose-up: ## Start all services with docker-compose
docker-compose up -d

docker-compose-down: ## Stop all services
docker-compose down

#------------------------------------------------------------------------------
# Git Hooks
#------------------------------------------------------------------------------
setup-hooks: ## Setup pre-commit hooks
@echo "$(BLUE)Setting up git hooks...$(RESET)"
@if command -v pre-commit >/dev/null 2>&1; then \
pre-commit install; \
echo "$(GREEN)βœ“ Pre-commit hooks installed$(RESET)"; \
else \
echo "$(YELLOW)⚠ pre-commit not found. Installing...$(RESET)"; \
$(PIP) install pre-commit && pre-commit install; \
fi

#------------------------------------------------------------------------------
# Updates
#------------------------------------------------------------------------------
update-deps: ## Update all dependencies to latest versions
@echo "$(BLUE)Updating dependencies...$(RESET)"
$(PIP) install --upgrade -r requirements.txt
@echo "$(GREEN)βœ“ Dependencies updated$(RESET)"

update-repo: ## Pull latest changes and update
@echo "$(BLUE)Updating repository...$(RESET)"
git pull origin main
$(MAKE) install-dev
@echo "$(GREEN)βœ“ Repository updated$(RESET)"
Comment on lines +225 to +229
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | πŸ”΅ Trivial

Hardcoded main branch in update-repo may cause issues.

Line 227 hardcodes git pull origin main. If someone uses master or another default branch, this will fail or pull the wrong branch. Consider using the current branch or making it configurable.

πŸ”§ Proposed fix
 update-repo: ## Pull latest changes and update
 	`@echo` "$(BLUE)Updating repository...$(RESET)"
-	git pull origin main
+	git pull origin $$(git rev-parse --abbrev-ref HEAD)
 	$(MAKE) install-dev
 	`@echo` "$(GREEN)βœ“ Repository updated$(RESET)"
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
update-repo: ## Pull latest changes and update
@echo "$(BLUE)Updating repository...$(RESET)"
git pull origin main
$(MAKE) install-dev
@echo "$(GREEN)βœ“ Repository updated$(RESET)"
update-repo: ## Pull latest changes and update
`@echo` "$(BLUE)Updating repository...$(RESET)"
git pull origin $$(git rev-parse --abbrev-ref HEAD)
$(MAKE) install-dev
`@echo` "$(GREEN)βœ“ Repository updated$(RESET)"
πŸ€– Prompt for AI Agents
In `@Makefile` around lines 225 - 229, The update-repo Makefile target currently
hardcodes "git pull origin main" which breaks when the repo's default branch
differs; change update-repo to pull the current branch or a configurable
variable insteadβ€”replace the literal "git pull origin main" with a command that
uses the current branch (e.g., deriving it with git rev-parse --abbrev-ref HEAD)
or use a Make variable like BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
and then run "git pull origin $(BRANCH)"; update references to the update-repo
target accordingly so maintainers can override BRANCH when needed.


#------------------------------------------------------------------------------
# Development Shortcuts
#------------------------------------------------------------------------------
dev: ## Start development environment
@echo "$(BLUE)Starting development environment...$(RESET)"
@$(MAKE) validate
@$(MAKE) test-quick
@echo "$(GREEN)βœ“ Development environment ready$(RESET)"

ci: clean lint test ## Run CI pipeline locally
@echo "$(GREEN)βœ“ CI pipeline passed$(RESET)"

release: check ## Prepare for release
@echo "$(BLUE)Preparing release...$(RESET)"
@$(MAKE) clean
@$(MAKE) docs
@echo "$(GREEN)βœ“ Ready for release$(RESET)"
25 changes: 22 additions & 3 deletions agents/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,32 @@
for the distributed multi-agent system.
"""

__version__ = "0.1.0"
__version__ = "1.0.0"

from .base import BaseAgent, AgentType, AgentSpecialization, AgentStatus
from .base import (
BaseAgent,
AgentType,
AgentStatus,
AgentCapability,
AgentConfig,
AgentMessage,
AgentMetrics,
Task,
TaskPriority,
TaskStatus,
CommunicationProtocol,
)

__all__ = [
"BaseAgent",
"AgentType",
"AgentSpecialization",
"AgentStatus",
"AgentCapability",
"AgentConfig",
"AgentMessage",
"AgentMetrics",
"Task",
"TaskPriority",
"TaskStatus",
"CommunicationProtocol",
]
Loading
Loading