Skip to content

Commit bd62458

Browse files
GeneAIclaude
authored andcommitted
feat: Release v3.3.2 - Memory Panel Beta, Redis Config, Windows Compat
## Memory Panel (Beta) - Re-enabled Memory panel with graceful fallback for no backend - Added "(Beta)" labels to Memory view, commands, and settings - Users configure their own Redis via REDIS_URL environment variable ## Redis Configuration - Added REDIS_PUBLIC_URL support for Railway deployments - Enhanced config source detection for Redis Labs, Railway, Heroku ## Windows Compatibility - Added platform_utils module for cross-platform support - Platform detection (is_windows, is_macos, is_linux) - Platform-specific default directories - asyncio event loop policy setup for Windows - CI integration test for cross-platform compatibility ## VSCode Extension - Excluded test files from compilation (glob/mocha compat issues) - Full extension compilation verified 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 2464f73 commit bd62458

Some content is hidden

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

55 files changed

+9136
-184
lines changed

.claude/CLAUDE.md

Lines changed: 404 additions & 8 deletions
Large diffs are not rendered by default.
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Cost Optimization Skill
2+
3+
Use this skill when optimizing LLM costs in the Empathy Framework.
4+
5+
## Smart Tier System
6+
7+
### Tier Overview
8+
| Tier | Models | Cost/1M tokens | Use Case |
9+
|------|--------|----------------|----------|
10+
| **cheap** | GPT-4o-mini, Haiku | ~$0.15 | Summarization, extraction |
11+
| **capable** | GPT-4o, Sonnet 4.5 | ~$3.00 | Code review, bug fixing |
12+
| **premium** | o1, Opus 4.5 | ~$15.00 | Architecture decisions |
13+
14+
### Potential Savings
15+
- Using `cheap` instead of `capable`: **80-95% savings**
16+
- Using `capable` instead of `premium`: **75-80% savings**
17+
18+
## Task-to-Tier Mapping
19+
20+
```python
21+
TASK_TIER_RECOMMENDATIONS = {
22+
# CHEAP tier tasks
23+
"summarize": "cheap",
24+
"extract_keywords": "cheap",
25+
"format_text": "cheap",
26+
"simple_classification": "cheap",
27+
"count_items": "cheap",
28+
29+
# CAPABLE tier tasks
30+
"code_review": "capable",
31+
"bug_fix": "capable",
32+
"write_tests": "capable",
33+
"explain_code": "capable",
34+
"refactor": "capable",
35+
36+
# PREMIUM tier tasks
37+
"architecture_design": "premium",
38+
"security_audit": "premium",
39+
"complex_reasoning": "premium",
40+
"multi_step_planning": "premium",
41+
}
42+
```
43+
44+
## Implementation Pattern
45+
46+
```python
47+
async def optimized_workflow(self) -> WorkflowResult:
48+
total_cost = 0.0
49+
50+
# Step 1: Use CHEAP for initial extraction (saves 90%+)
51+
extraction = await self.executor.execute(
52+
prompt="Extract key points from this text...",
53+
tier="cheap"
54+
)
55+
total_cost += extraction.cost
56+
57+
# Step 2: Use CAPABLE for analysis (main task)
58+
analysis = await self.executor.execute(
59+
prompt=f"Analyze these points: {extraction.content}",
60+
tier="capable"
61+
)
62+
total_cost += analysis.cost
63+
64+
# Step 3: Use CHEAP for formatting (saves 90%+)
65+
formatted = await self.executor.execute(
66+
prompt=f"Format this as markdown: {analysis.content}",
67+
tier="cheap"
68+
)
69+
total_cost += formatted.cost
70+
71+
return WorkflowResult(cost=total_cost, ...)
72+
```
73+
74+
## Cost Monitoring
75+
76+
```bash
77+
# Check workflow costs
78+
python -m empathy_os.cli workflow code-review --path ./src
79+
80+
# View cost breakdown in output
81+
# Example output:
82+
# Completed in 2450ms | Cost: $0.0234
83+
```
84+
85+
## Token Estimation
86+
87+
Before running expensive operations, estimate tokens:
88+
89+
```python
90+
from empathy_os.models.token_estimator import estimate_tokens, estimate_cost
91+
92+
tokens = estimate_tokens(my_prompt)
93+
estimated_cost = estimate_cost(tokens, model="claude-sonnet-4-5-20250514")
94+
print(f"Estimated cost: ${estimated_cost:.4f}")
95+
```
96+
97+
## Cost Reduction Strategies
98+
99+
1. **Batch Similar Tasks**: Combine multiple small prompts into one
100+
2. **Cache Responses**: Don't re-query for identical inputs
101+
3. **Truncate Context**: Only include relevant context, not full files
102+
4. **Use Streaming**: For long outputs, stream to catch early errors
103+
5. **Tier Fallback**: Start with `cheap`, only upgrade if quality insufficient

.claude/skills/debugging.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Debugging Skill
2+
3+
Use this skill when debugging issues in the Empathy Framework.
4+
5+
## Common Issue Categories
6+
7+
### 1. Model/Provider Issues
8+
- **API Key Missing**: Check `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, or `OLLAMA_BASE_URL`
9+
- **Model Not Found**: Verify model ID in `src/empathy_os/models/registry.py`
10+
- **Rate Limits**: Check provider quotas, implement backoff
11+
12+
### 2. Workflow Failures
13+
- **Import Errors**: Ensure workflow is registered in `workflows/__init__.py`
14+
- **Type Errors**: Run `python -m mypy src/empathy_os/`
15+
- **Missing Dependencies**: Check `pyproject.toml` dependencies
16+
17+
### 3. VSCode Extension Issues
18+
- **Panel Not Loading**: Check webview HTML in `EmpathyDashboardPanel.ts`
19+
- **Commands Not Working**: Verify registration in `extension.ts` and `package.json`
20+
- **Message Passing**: Debug `_setWebviewMessageListener` handlers
21+
22+
### 4. Cost Calculation Issues
23+
- **Zero Cost**: Ensure `result.cost` is accumulated from executor calls
24+
- **Token Estimation**: Check tiktoken encoding in `token_estimator.py`
25+
26+
## Debugging Commands
27+
28+
```bash
29+
# Type checking
30+
python -m mypy src/empathy_os/ --ignore-missing-imports
31+
32+
# Linting
33+
ruff check src/empathy_os/
34+
35+
# Run specific test
36+
python -m pytest tests/test_specific.py -v --tb=long
37+
38+
# Check workflow registration
39+
python -c "from empathy_os.workflows import WORKFLOWS; print(list(WORKFLOWS.keys()))"
40+
41+
# Test executor
42+
python -c "
43+
import asyncio
44+
from empathy_os.models.executor import get_executor
45+
async def test():
46+
ex = get_executor()
47+
r = await ex.execute('Say hello', tier='cheap')
48+
print(f'Response: {r.content[:100]}...')
49+
print(f'Cost: ${r.cost:.6f}')
50+
asyncio.run(test())
51+
"
52+
```
53+
54+
## Log Locations
55+
- Audit logs: `/var/log/empathy/audit.jsonl`
56+
- Test output: `pytest --tb=long`
57+
- VSCode extension: Developer Tools Console
58+
59+
## Quick Fixes
60+
61+
| Symptom | Likely Cause | Fix |
62+
|---------|--------------|-----|
63+
| `ModuleNotFoundError` | Not installed in dev mode | `pip install -e .` |
64+
| `AttributeError: 'NoneType'` | Missing config/env | Check `.env` file |
65+
| `TypeError: cannot unpack` | API response changed | Check model provider docs |
66+
| `asyncio.TimeoutError` | Slow model response | Increase timeout or use faster tier |

.claude/skills/security-review.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Security Review Skill
2+
3+
Use this skill when reviewing code for security issues in the Empathy Framework.
4+
5+
## Security Classification
6+
7+
### Data Classification Levels
8+
- **PUBLIC**: General patterns, safe to share
9+
- **INTERNAL**: Proprietary algorithms, company-only
10+
- **SENSITIVE**: Healthcare/HIPAA data, requires encryption
11+
12+
### PII Patterns to Detect
13+
```python
14+
# Healthcare PII (HIPAA)
15+
HEALTHCARE_PII = {
16+
"mrn": r'\bMRN:?\s*\d{6,10}\b', # Medical Record Number
17+
"patient_id": r'\bPT\d{6,10}\b', # Patient ID
18+
"insurance_id": r'\bINS\d{8,12}\b', # Insurance ID
19+
"dob": r'\b\d{1,2}/\d{1,2}/\d{4}\b', # Date of birth
20+
}
21+
22+
# Software PII
23+
SOFTWARE_PII = {
24+
"internal_id": r'\b[A-Z]{2,4}-\d{4,6}\b', # JIRA tickets
25+
"database_conn": r'(postgresql|mysql|mongodb)://[^"\s]+',
26+
}
27+
```
28+
29+
## Security Checklist
30+
31+
### API Keys & Secrets
32+
- [ ] No hardcoded API keys
33+
- [ ] Secrets loaded from environment variables
34+
- [ ] `.env` files in `.gitignore`
35+
- [ ] No secrets in logs or error messages
36+
37+
### Input Validation
38+
- [ ] User input sanitized before use
39+
- [ ] SQL injection prevention (parameterized queries)
40+
- [ ] Command injection prevention (no `shell=True` with user input)
41+
- [ ] Path traversal prevention (validate file paths)
42+
43+
### Healthcare Wizards (HIPAA)
44+
- [ ] All data classified as SENSITIVE
45+
- [ ] Encryption enabled for storage
46+
- [ ] 90-day retention policy enforced
47+
- [ ] Audit logging for all accesses
48+
49+
### Dependencies
50+
- [ ] Run `pip-audit` for vulnerability scan
51+
- [ ] Check for outdated packages with known CVEs
52+
- [ ] Review new dependencies before adding
53+
54+
## Security Tests
55+
56+
```bash
57+
# Run security test suite
58+
pytest tests/test_security_controls.py -v
59+
pytest tests/test_pii_scrubbing.py -v
60+
pytest tests/test_secrets_detection.py -v
61+
pytest tests/test_pattern_classification.py -v
62+
63+
# Scan for secrets in git history
64+
git log -p | grep -E "(api_key|password|secret|token)" --color
65+
66+
# Check for hardcoded credentials
67+
grep -r "api_key\s*=" --include="*.py" | grep -v "os.getenv"
68+
```
69+
70+
## Compliance Requirements
71+
72+
| Standard | Requirement | Implementation |
73+
|----------|-------------|----------------|
74+
| GDPR | Data minimization | Scrub PII before storage |
75+
| HIPAA | PHI protection | SENSITIVE classification + encryption |
76+
| SOC2 | Audit trails | All LLM interactions logged |
77+
78+
## Reporting Security Issues
79+
80+
1. Do NOT commit the vulnerability
81+
2. Contact: [email protected]
82+
3. Use secure communication channel
83+
4. Provide reproduction steps
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Workflow Development Skill
2+
3+
Use this skill when creating or modifying Empathy Framework workflows.
4+
5+
## Context
6+
7+
Empathy Framework workflows are in `src/empathy_os/workflows/`. Each workflow:
8+
- Inherits from `EmpathyWorkflow` base class
9+
- Implements `execute()` async method
10+
- Returns a dataclass result with `cost`, `duration_seconds`, and formatted `report`
11+
- Uses the multi-tier executor for cost optimization
12+
13+
## Workflow Structure
14+
15+
```python
16+
from dataclasses import dataclass
17+
from empathy_os.workflows.base import EmpathyWorkflow, WorkflowResult
18+
19+
@dataclass
20+
class MyWorkflowResult(WorkflowResult):
21+
"""Custom result fields."""
22+
specific_data: str = ""
23+
24+
def format_report(self) -> str:
25+
"""Format as human-readable report."""
26+
lines = [
27+
"# My Workflow Report",
28+
"",
29+
f"**Result**: {self.specific_data}",
30+
"",
31+
"---",
32+
f"Completed in {self.duration_seconds * 1000:.0f}ms | Cost: ${self.cost:.4f}"
33+
]
34+
return "\n".join(lines)
35+
36+
class MyWorkflow(EmpathyWorkflow[MyWorkflowResult]):
37+
"""Description of what this workflow does."""
38+
39+
name = "my-workflow"
40+
description = "Brief description"
41+
42+
async def execute(self, **kwargs) -> MyWorkflowResult:
43+
start_time = time.time()
44+
total_cost = 0.0
45+
46+
# Use appropriate tier for each task
47+
# cheap: summarization, simple extraction
48+
# capable: code review, bug fixing
49+
# premium: architecture decisions
50+
51+
result = await self.executor.execute(
52+
prompt="...",
53+
tier="capable"
54+
)
55+
total_cost += result.cost
56+
57+
duration = time.time() - start_time
58+
return MyWorkflowResult(
59+
success=True,
60+
cost=total_cost,
61+
duration_seconds=duration,
62+
specific_data=result.content
63+
)
64+
```
65+
66+
## Key Patterns
67+
68+
1. **Tier Selection**: Use `cheap` for 80-96% cost savings on simple tasks
69+
2. **Cost Tracking**: Always accumulate `result.cost` from each executor call
70+
3. **Report Format**: Use milliseconds for duration, 4 decimal places for cost
71+
4. **Error Handling**: Set `success=False` and include error in report
72+
73+
## Registration
74+
75+
Add to `src/empathy_os/workflows/__init__.py`:
76+
```python
77+
from .my_workflow import MyWorkflow
78+
WORKFLOWS["my-workflow"] = MyWorkflow
79+
```
80+
81+
## Testing
82+
83+
```bash
84+
python -m empathy_os.cli workflow my-workflow --arg value
85+
```

CHANGELOG.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,57 @@ 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+
## [Unreleased]
9+
10+
### Added
11+
12+
**Windows Compatibility**
13+
- New `platform_utils` module for cross-platform support
14+
- Platform detection functions (`is_windows()`, `is_macos()`, `is_linux()`)
15+
- Platform-appropriate directory functions for logs, data, config, and cache
16+
- Asyncio Windows event loop policy handling (`setup_asyncio_policy()`)
17+
- UTF-8 encoding utilities for text files
18+
- Path normalization helpers
19+
- Cross-platform compatibility checker script (`scripts/check_platform_compat.py`)
20+
- Detects hardcoded Unix paths, missing encoding, asyncio issues
21+
- JSON output mode for CI integration
22+
- `--fix` mode with suggested corrections
23+
- CI integration for platform compatibility checks in GitHub Actions
24+
- Pre-commit hook for platform compatibility (manual stage)
25+
- Pytest integration test for platform compatibility (`test_platform_compat_ci.py`)
26+
27+
### Fixed
28+
29+
- Hardcoded Unix paths in `audit_logger.py` now use platform-appropriate defaults
30+
- Added `setup_asyncio_policy()` call in CLI entry point for Windows compatibility
31+
32+
### Changed
33+
34+
- Updated `.claude/python-standards.md` with cross-platform coding guidelines
35+
36+
---
37+
38+
## [3.3.1] - 2025-12-27
39+
40+
### Fixed
41+
42+
- Updated Anthropic capable tier from Sonnet 4 to Sonnet 4.5 (`claude-sonnet-4-5-20250514`)
43+
- Fixed model references in token_estimator and executor
44+
- Fixed Setup button not opening Initialize Wizard (added `force` parameter)
45+
- Fixed Cost Simulator layout for narrow panels (single-column layout)
46+
- Fixed cost display inconsistency between workflow report and CLI footer
47+
- Unified timing display to use milliseconds across all workflow reports
48+
- Removed redundant CLI footer (workflow reports now contain complete timing/cost info)
49+
- Fixed all mypy type errors across empathy_os and empathy_llm_toolkit
50+
- Fixed ruff linting warnings (unused variables in dependency_check.py, document_gen.py)
51+
52+
### Changed
53+
54+
- All workflow reports now display duration in milliseconds (e.g., `Review completed in 15041ms`)
55+
- Consistent footer format: `{Workflow} completed in {ms}ms | Cost: ${cost:.4f}`
56+
57+
---
58+
859
## [3.2.3] - 2025-12-24
960

1061
### Fixed

0 commit comments

Comments
 (0)