Skip to content

Commit 0ea7fb0

Browse files
feat: ModelRouter integration for cost optimization (#11)
Integrates ModelRouter for cost-optimized model selection. Routes tasks to CHEAP (Haiku), CAPABLE (Sonnet), or PREMIUM (Opus) tiers based on task_type parameter. Changes: - Add enable_model_routing and task_type parameters to EmpathyLLM - Route summarize/classify tasks to Haiku (cheap) - Route code generation/bug fixing to Sonnet (capable) - Route coordination/synthesis to Opus (premium) - Add 10 new tests for routing integration - Fix httpx import for test compatibility Saves ~80-96% on API costs for appropriate tasks.
1 parent 940f25a commit 0ea7fb0

File tree

136 files changed

+8365
-704
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+8365
-704
lines changed

.claude/CLAUDE copy.md

Lines changed: 0 additions & 406 deletions
This file was deleted.

.claude/CLAUDE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,10 @@ result = storage.store_pattern(
386386
387387
## 📞 Project Contacts
388388
389-
**Security Questions:** security-team@company.com
390-
**HIPAA Compliance:** hipaa-officer@company.com
391-
**Code Review:** tech-lead@company.com
392-
**General:** empathy-framework@company.com
389+
**Security Questions:** admin@smartaimemory.com
390+
**HIPAA Compliance:** admin@smartaimemory.com
391+
**Code Review:** admin@smartaimemory.com
392+
**General:** admin@smartaimemory.com
393393
394394
---
395395
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
paths: **/*.py, **/*.js, **/*.ts
3+
---
4+
5+
# Bug Patterns (Auto-generated by Empathy)
6+
Last sync: 2025-12-18 23:11
7+
8+
These patterns help identify and fix common bugs based on your team's history.
9+
10+
## Async Timing Bugs
11+
12+
### When you see: `Promise { <pending> } returned instead of resolved value`
13+
14+
### When you see: `UnhandledPromiseRejection: await undefined`
15+
16+
## Null Reference Bugs
17+
18+
### When you see: `TypeError: Cannot read property 'map' of undefined`
19+
20+
### When you see: `TypeError: Cannot read property 'map' of undefined`
21+
**Root cause:** API returned null instead of empty array
22+
**Fix:** Added default empty array fallback: data?.items ?? []
23+
24+
### When you see: `TypeError: Cannot read property 'map' of undefined`
25+
**Root cause:** API returns undefined instead of empty array
26+
**Fix:** Added optional chaining and default array fallback
27+
28+
### When you see: `TypeError: Cannot read property 'length' of undefined`
29+
30+
### When you see: `TypeError: Cannot read property 'length' of undefined`
31+
32+
## Unknown Bugs
33+
34+
### When you see: `ReferenceError: fetchUser is not defined`
35+
36+
## Type Mismatch Bugs
37+
38+
### When you see: `TypeError: expected str but got bytes`
39+
40+
## Import Error Bugs
41+
42+
### When you see: `ModuleNotFoundError: No module named 'pandas'`
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
paths: **/*
3+
---
4+
5+
# Coding Patterns (Auto-generated by Empathy)
6+
Last sync: 2025-12-18 23:11
7+
8+
Coding patterns and quality findings from automated inspection.
9+
10+
## Debt
11+
12+
- # Use temporary directory for test logs
13+
14+
## General
15+
16+
- Historical import_error bugs suggest testing gaps
17+
- Historical unknown bugs suggest testing gaps
18+
- Historical import_error bugs suggest testing gaps
19+
- Historical async_timing bugs suggest testing gaps
20+
- Historical null_reference bugs suggest testing gaps
21+
22+
## Review
23+
24+
- Potential null/undefined reference
25+
- Potential null/undefined reference (historical: bug_20250915_abc123)
26+
- Potential null/undefined reference (historical: bug_20251212_97c0f72f)
27+
- Potential null/undefined reference (historical: bug_null_001)
28+
- Potential null/undefined reference (historical: bug_20251212_3c5b9951)
29+
- Potential null/undefined reference (historical: bug_20251212_a9b6ec41)
30+
- Potential null/undefined reference (historical: bug_20251212_a0871d53)
31+
- Potential null/undefined reference (historical: bug_20250822_def456)
32+
33+
## Debugging
34+
35+
- Unresolved bug: null_reference
36+
37+
## Format
38+
39+
- File needs reformatting
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
paths: **/*.py, **/*.js, **/*.ts
3+
---
4+
5+
# Security Decisions (Auto-generated by Empathy)
6+
Last sync: 2025-12-18 23:11
7+
8+
Team security decisions and accepted risks. Reference these before flagging issues.
9+
10+
## Accepted Risks
11+
12+
- **unknown**:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
paths: **/*
3+
---
4+
5+
# Tech Debt Hotspots (Auto-generated by Empathy)
6+
Last sync: 2025-12-18 23:11
7+
8+
Areas of the codebase with accumulated technical debt.

.github/preview-trigger.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Trigger preview

CHANGELOG.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,93 @@ All notable changes to the Empathy Framework will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.2.10] - 2025-12-18
9+
10+
### Added
11+
12+
**Dev Wizards Web Backend**
13+
- New FastAPI backend for wizards.smartaimemory.com deployment
14+
- API endpoints for Memory-Enhanced Debugging, Security Analysis, Code Review, and Code Inspection
15+
- Interactive dashboard UI with demo capabilities
16+
- Railway deployment configuration (railway.toml, nixpacks.toml)
17+
18+
### Fixed
19+
- PyPI documentation now reflects current README and features
20+
21+
---
22+
23+
## [2.2.9] - 2025-12-18
24+
25+
### Added
26+
27+
**Code Inspection Pipeline**
28+
- **`empathy-inspect` CLI** - Unified code inspection command combining lint, security, tests, and tech debt analysis
29+
- `empathy-inspect .` - Inspect current directory with default settings
30+
- `empathy-inspect . --format sarif` - Output SARIF 2.1.0 for GitHub Actions/GitLab/Azure DevOps
31+
- `empathy-inspect . --format html` - Generate visual dashboard report
32+
- `empathy-inspect . --staged` - Inspect only git-staged changes
33+
- `empathy-inspect . --fix` - Auto-fix safe issues (formatting, imports)
34+
35+
**SARIF 2.1.0 Output Format**
36+
- Industry-standard static analysis format for CI/CD integration
37+
- GitHub code scanning annotations on pull requests
38+
- Compatible with GitLab, Azure DevOps, Bitbucket, and other SARIF-compliant platforms
39+
- Proper severity mapping: critical/high → error, medium → warning, low/info → note
40+
41+
**HTML Dashboard Reports**
42+
- Professional visual reports for stakeholders
43+
- Color-coded health score gauge (green/yellow/red)
44+
- Six category breakdown cards (Lint, Security, Tests, Tech Debt, Code Review, Debugging)
45+
- Sortable findings table with severity and priority
46+
- Prioritized recommendations section
47+
- Export-ready for sprint reviews and security audits
48+
49+
**Baseline/Suppression System**
50+
- **Inline suppressions** for surgical control:
51+
- `# empathy:disable RULE reason="..."` - Suppress for current line
52+
- `# empathy:disable-next-line RULE` - Suppress for next line
53+
- `# empathy:disable-file RULE` - Suppress for entire file
54+
- **JSON baseline file** (`.empathy-baseline.json`) for project-wide policies:
55+
- Rule-level suppressions with reasons
56+
- File-level suppressions for legacy code
57+
- TTL-based expiring suppressions with `expires_at`
58+
- **CLI commands**:
59+
- `--no-baseline` - Show all findings (for audits)
60+
- `--baseline-init` - Create empty baseline file
61+
- `--baseline-cleanup` - Remove expired suppressions
62+
63+
**Language-Aware Code Review**
64+
- Integration with CrossLanguagePatternLibrary for intelligent pattern matching
65+
- Language-specific analysis for Python, JavaScript/TypeScript, Rust, Go, Java
66+
- Cross-language insights: "This Python None check is like the JavaScript undefined bug you fixed"
67+
- No false positives from applying wrong-language patterns
68+
69+
### Changed
70+
71+
**Five-Phase Pipeline Architecture**
72+
1. **Static Analysis** (Parallel) - Lint, security, tech debt, test quality run simultaneously
73+
2. **Dynamic Analysis** (Conditional) - Code review, debugging only if Phase 1 finds triggers
74+
3. **Cross-Analysis** (Sequential) - Correlate findings across tools for priority boosting
75+
4. **Learning** (Optional) - Extract patterns for future inspections
76+
5. **Reporting** (Always) - Unified health score and recommendations
77+
78+
**VCS Flexibility**
79+
- Optimized for GitHub but works with GitLab, Bitbucket, Azure DevOps, self-hosted Git
80+
- Git-native pattern storage in `patterns/` directory
81+
- SARIF output compatible with any CI/CD platform supporting the standard
82+
83+
### Fixed
84+
- Marked 5 demo bug patterns from 2025-12-16 with `demo: true` field
85+
- Type errors in baseline.py stats dictionary and suppression entry typing
86+
- Type cast for suppressed count in reporting.py
87+
88+
### Documentation
89+
- Updated [CLI_GUIDE.md](docs/CLI_GUIDE.md) with full `empathy-inspect` documentation
90+
- Updated [README.md](README.md) with Code Inspection Pipeline section
91+
- Created blog post draft: `drafts/blog-code-inspection-pipeline.md`
92+
93+
---
94+
895
## [2.2.7] - 2025-12-15
996

1097
### Fixed

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ empathy-memory serve
1919
- **Dual-layer architecture** — Redis for millisecond short-term ops, pattern storage for long-term knowledge
2020
- **AI that learns across sessions** — Patterns discovered today inform decisions tomorrow
2121
- **Cross-team knowledge sharing** — What one agent learns, all agents can use
22+
- **Git-native storage** — Optimized for GitHub, works with any VCS (GitLab, Bitbucket, Azure DevOps, self-hosted)
2223

2324
### Enterprise-Ready
2425
- **Your data stays local** — Nothing leaves your infrastructure
@@ -147,6 +148,48 @@ The API server runs at `http://localhost:8765` with endpoints for status, stats,
147148

148149
**VS Code Extension:** A visual panel for monitoring memory is available in `vscode-memory-panel/`.
149150

151+
## Code Inspection Pipeline (New in v2.2.9)
152+
153+
Unified code quality with cross-tool intelligence:
154+
155+
```bash
156+
# Run inspection
157+
empathy-inspect .
158+
159+
# Multiple output formats
160+
empathy-inspect . --format json # For CI/CD
161+
empathy-inspect . --format sarif # For GitHub Actions
162+
empathy-inspect . --format html # Visual dashboard
163+
164+
# Filter targets
165+
empathy-inspect . --staged # Only staged changes
166+
empathy-inspect . --changed # Only modified files
167+
168+
# Auto-fix safe issues
169+
empathy-inspect . --fix
170+
171+
# Suppress false positives
172+
empathy-inspect . --baseline-init # Create baseline file
173+
empathy-inspect . --no-baseline # Show all findings
174+
```
175+
176+
**Pipeline phases:**
177+
1. Static Analysis (parallel) — Lint, security, debt, test quality
178+
2. Dynamic Analysis (conditional) — Code review, debugging
179+
3. Cross-Analysis — Correlate findings across tools
180+
4. Learning — Extract patterns for future use
181+
5. Reporting — Unified health score
182+
183+
**GitHub Actions SARIF integration:**
184+
```yaml
185+
- run: empathy-inspect . --format sarif --output results.sarif
186+
- uses: github/codeql-action/upload-sarif@v2
187+
with:
188+
sarif_file: results.sarif
189+
```
190+
191+
[Full documentation →](docs/CLI_GUIDE.md#code-inspection-pipeline-new-in-v229)
192+
150193
## License
151194
152195
**Fair Source License 0.9** - Free for students, educators, and teams ≤5 employees. Commercial license ($99/dev/year) for larger organizations. [Details →](LICENSE)

agents/book_production/__init__.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,20 @@
2020
Licensed under Fair Source 0.9
2121
"""
2222

23-
from .base import AgentConfig, BaseAgent, MemDocsConfig, OpusAgent, RedisConfig, SonnetAgent
23+
from .base import (
24+
AgentConfig,
25+
BaseAgent,
26+
MemDocsConfig,
27+
OpusAgent,
28+
RedisConfig,
29+
SonnetAgent,
30+
)
2431
from .editor_agent import EditorAgent
25-
from .learning import (
26-
# Pattern Extraction
32+
from .learning import ( # Pattern Extraction; Feedback Loop; Quality Gap Detection; SBAR Handoffs
2733
ExtractedPattern,
28-
# Feedback Loop
2934
FeedbackEntry,
3035
FeedbackLoop,
31-
# Quality Gap Detection
3236
GapSeverity,
33-
# SBAR Handoffs
3437
HandoffType,
3538
PatternExtractor,
3639
QualityGap,

0 commit comments

Comments
 (0)