Skip to content

Commit 8edfb70

Browse files
GeneAIclaude
authored andcommitted
feat: Release v3.0.1 - XML-Enhanced Prompts & Security Fixes
Major release with structured XML prompts system and critical security fixes: ## XML-Enhanced Prompts System - Structured XML prompt templates for consistent LLM interactions - Built-in templates: security-audit, code-review, research, bug-analysis - XmlPromptTemplate and PlainTextPromptTemplate classes - XmlResponseParser with safe defusedxml parsing (prevents XXE) - PromptContext dataclass with factory methods - Per-workflow XML configuration via .empathy/workflows.yaml ## Security Fixes (HIGH Priority) - Fixed command injection in VSCode extension EmpathyDashboardPanel.ts - Fixed command injection in extension.ts runEmpathyCommand functions - Replaced vulnerable cp.exec() with safe cp.execFile() using arrays - Created health_scan.py helper script to eliminate inline code - Removed insecure demo_key fallback in wizard_api.py - Updated .gitignore for nested .env files - Added defusedxml for secure XML parsing ## VSCode Dashboard Enhancements - 10 integrated workflows with input history persistence - File/folder picker integration for workflow inputs - Cost fetching from telemetry CLI with fallback - Error banner for improved debugging ## Documentation - Added XML-Enhanced Prompts section to README - Updated CHANGELOG with v3.0.0 and v3.0.1 entries - Added security notice to test fixtures 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 682451d commit 8edfb70

33 files changed

+2725
-205
lines changed

.claude/CLAUDE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Empathy Framework - Production Security Configuration
22
# Location: ./.claude/CLAUDE.md
3-
# Project: empathy-framework v2.2.7
3+
# Project: empathy-framework v3.0.1
44
# Classification: INTERNAL
55

66
# Import pattern library summary (auto-generated)
@@ -149,7 +149,7 @@ pytest tests/test_claude_memory.py -v
149149
"timestamp": "2025-11-24T03:30:00Z",
150150
"event_id": "evt_abc123",
151151
"project": "empathy-framework",
152-
"version": "2.2.7",
152+
"version": "3.0.1",
153153
"user_id": "[email protected]",
154154
"action": "llm_request",
155155

@@ -405,5 +405,5 @@ By working on this project, I confirm:
405405
---
406406
407407
*This configuration enforces enterprise security while enabling the five-level empathy system.*
408-
*Last updated: 2025-12-15*
409-
*Empathy Framework v2.2.7*
408+
*Last updated: 2025-12-22*
409+
*Empathy Framework v3.0.1*

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ __pycache__/
5050
# Security
5151
security_scan_results.json
5252
.env
53+
**/.env
54+
**/tests/.env
55+
*.env.local
56+
*.env.*.local
5357

5458
# MemDocs
5559
.memdocs/

CHANGELOG.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,73 @@ 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+
## [3.0.1] - 2025-12-22
9+
10+
### Added
11+
12+
**XML-Enhanced Prompts System**
13+
- Structured XML prompt templates for consistent LLM interactions
14+
- Built-in templates: `security-audit`, `code-review`, `research`, `bug-analysis`
15+
- `XmlPromptTemplate` and `PlainTextPromptTemplate` classes for flexible rendering
16+
- `XmlResponseParser` with automatic XML extraction from markdown code blocks
17+
- `PromptContext` dataclass with factory methods for common workflows
18+
- Per-workflow XML configuration via `.empathy/workflows.yaml`
19+
- Fallback to plain text when XML parsing fails (configurable)
20+
21+
**VSCode Dashboard Enhancements**
22+
- 10 integrated workflows: Research, Code Review, Debug, Refactor, Test Generation, Documentation, Security Scan, Performance, Explain Code, Morning Briefing
23+
- Workflow input history persistence across sessions
24+
- File/folder picker integration for workflow inputs
25+
- Cost fetching from telemetry CLI with fallback
26+
- Error banner for improved debugging visibility
27+
28+
### Fixed
29+
30+
**Security Vulnerabilities (HIGH Priority)**
31+
- Fixed command injection in VSCode extension `EmpathyDashboardPanel.ts`
32+
- Fixed command injection in `extension.ts` runEmpathyCommand functions
33+
- Replaced vulnerable `cp.exec()` with safe `cp.execFile()` using array arguments
34+
- Created `health_scan.py` helper script to eliminate inline code execution
35+
- Removed insecure `demo_key` fallback in `wizard_api.py`
36+
37+
**Security Hardening**
38+
- Updated `.gitignore` to cover nested `.env` files (`**/.env`, `**/tests/.env`)
39+
- Added security notice documentation to test fixtures with intentional vulnerabilities
40+
41+
### Changed
42+
43+
- Workflows now show provider name in output
44+
- Workflows auto-load `.env` files for API key configuration
45+
46+
---
47+
48+
## [3.0.0] - 2025-12-22
49+
50+
### Added
51+
52+
**Multi-Model Provider System**
53+
- Provider configuration: Anthropic, OpenAI, Ollama, Hybrid
54+
- Auto-detection of API keys from environment and `.env` files
55+
- CLI commands: `python -m empathy_os.models.cli provider`
56+
- Single, hybrid, and custom provider modes
57+
58+
**Smart Tier Routing (80-96% Cost Savings)**
59+
- Cheap tier: GPT-4o-mini/Haiku for summarization
60+
- Capable tier: GPT-4o/Sonnet for bug fixing, code review
61+
- Premium tier: o1/Opus for architecture decisions
62+
63+
**VSCode Dashboard - Complete Overhaul**
64+
- 6 Quick Action commands for common tasks
65+
- Real-time health score, costs, and workflow monitoring
66+
67+
### Changed
68+
69+
- README refresh with "Become a Power User" 5-level progression
70+
- Comprehensive CLI reference
71+
- Updated comparison table
72+
73+
---
74+
875
## [2.5.0] - 2025-12-20
976

1077
### Added

README.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
pip install empathy-framework[full]
1313
```
1414

15-
## What's New in v3.0.0
15+
## What's New in v3.0.1
1616

17+
- **XML-Enhanced Prompts** — Structured prompts for consistent, parseable LLM responses
1718
- **Multi-Model Provider System** — Choose Anthropic, OpenAI, Ollama, or Hybrid mode
1819
- **80-96% Cost Savings** — Smart tier routing: cheap models detect, best models decide
19-
- **VSCode Dashboard** — Real-time health, costs, and workflow monitoring
20+
- **VSCode Dashboard** — 10 integrated workflows with input history persistence
21+
- **Security Hardening** — Fixed command injection vulnerabilities in VSCode extension
2022
- **Provider Auto-Detection** — Automatically configures based on your API keys
2123

2224
---
@@ -108,6 +110,7 @@ Install the Empathy VSCode extension for:
108110
- **Real-time Dashboard** — Health score, costs, patterns
109111
- **One-Click Workflows** — Research, code review, debugging
110112
- **Visual Cost Tracking** — See savings in real-time
113+
- See also: `docs/dashboard-costs-by-tier.md` for interpreting the **By tier (7 days)** cost breakdown.
111114

112115
### Level 5: Custom Agents
113116
```python
@@ -167,6 +170,43 @@ empathy-inspect . --staged # Only staged changes
167170

168171
---
169172

173+
## XML-Enhanced Prompts
174+
175+
Enable structured XML prompts for consistent, parseable LLM responses:
176+
177+
```yaml
178+
# .empathy/workflows.yaml
179+
xml_prompt_defaults:
180+
enabled: false # Set true to enable globally
181+
182+
workflow_xml_configs:
183+
security-audit:
184+
enabled: true
185+
enforce_response_xml: true
186+
template_name: "security-audit"
187+
code-review:
188+
enabled: true
189+
template_name: "code-review"
190+
```
191+
192+
Built-in templates: `security-audit`, `code-review`, `research`, `bug-analysis`
193+
194+
```python
195+
from empathy_os.prompts import get_template, XmlResponseParser, PromptContext
196+
197+
# Use a built-in template
198+
template = get_template("security-audit")
199+
context = PromptContext.for_security_audit(code="def foo(): pass")
200+
prompt = template.render(context)
201+
202+
# Parse XML responses
203+
parser = XmlResponseParser(fallback_on_error=True)
204+
result = parser.parse(llm_response)
205+
print(result.summary, result.findings, result.checklist)
206+
```
207+
208+
---
209+
170210
## Install Options
171211

172212
```bash

backend/api/wizard_api.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,17 @@
9494

9595
# Initialize shared LLM instance for domain wizards
9696
def get_llm_instance():
97-
"""Get or create EmpathyLLM instance"""
97+
"""Get or create EmpathyLLM instance.
98+
99+
Raises:
100+
ValueError: If ANTHROPIC_API_KEY environment variable is not set.
101+
"""
98102
api_key = os.getenv("ANTHROPIC_API_KEY")
99103
if not api_key:
100-
logger.warning("ANTHROPIC_API_KEY not set - domain wizards will use demo mode")
101-
api_key = "demo_key"
104+
raise ValueError(
105+
"ANTHROPIC_API_KEY environment variable is required. "
106+
"Set it in your .env file or environment before starting the API."
107+
)
102108

103109
return EmpathyLLM(
104110
provider="anthropic", api_key=api_key, enable_security=True, enable_audit_logging=True

docs/dashboard-costs-by-tier.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Understanding By Tier (7 days) in the Empathy Dashboard
2+
3+
The Empathy VS Code dashboard includes a **Cost Details** panel that shows how model routing is saving you money over the last 7 days.
4+
5+
When you click **View Costs** in the Power tab, you’ll see:
6+
7+
- **Saved** – Total dollars saved over the last 7 days compared to always using the premium model.
8+
- **Reduction** – Percentage reduction in cost compared to the premium-only baseline.
9+
- **Actual** – Actual dollars spent on API calls in the last 7 days.
10+
11+
Below the summary, the **By tier (7 days)** section breaks those savings down by model tier:
12+
13+
- **Cheap** – Requests routed to the cheapest tier (e.g., Haiku-level models). Best for simple tasks like short summaries.
14+
- **Capable** – Requests routed to the middle tier (e.g., Sonnet-level models). Used for most code and reasoning tasks.
15+
- **Premium** – Requests routed to the most powerful tier (e.g., Opus-level models). Reserved for the hardest or most critical tasks.
16+
17+
For each tier, you’ll see:
18+
19+
- **Requests** – How many API calls used this tier in the last 7 days.
20+
- **Cost** – Actual dollars spent on that tier.
21+
- **+Saved** – How many dollars you saved by using this tier instead of always using the premium model for those same requests.
22+
23+
Use this section to answer questions like:
24+
25+
- Are most of my requests using **cheap** or **capable** models instead of premium?
26+
- Which tier is responsible for the **largest share of savings**?
27+
- Do I have many **premium** calls that could safely be moved down to capable or cheap?
28+
29+
If the **cheap** and **capable** tiers show healthy savings and most requests, your routing is working well. If **premium** dominates both cost and request count, consider revisiting your task-type to tier mapping in `ModelRouter` or your workflow configuration.

docs/marketing/drafts/DEVTO_ARTICLE.md

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
2-
title: Give Claude Persistent Memory in 10 Lines of Python
2+
title: Give Claude Persistent Memory in 10 Lines of Python (Now with 80% Cost Savings)
33
published: false
4-
description: How to make Claude remember your preferences across sessions using the Empathy Framework
5-
tags: python, ai, claude, anthropic
4+
description: How to make Claude remember your preferences across sessions using the Empathy Framework v3.0.0
5+
tags: python, ai, claude, anthropic, openai
66
cover_image:
77
---
88

99
# Give Claude Persistent Memory in 10 Lines of Python
1010

1111
Every conversation with Claude starts from scratch. Tell it you prefer concise code examples, and next session? It's forgotten.
1212

13-
Here's how to fix that—plus save 80% on API costs.
13+
Here's how to fix that—plus save 80% on API costs with v3.0.0's multi-provider system.
1414

1515
## The Problem
1616

@@ -28,7 +28,7 @@ Claude's API is stateless. Each request is independent. For simple Q&A, that's f
2828
from empathy_llm_toolkit import EmpathyLLM
2929

3030
llm = EmpathyLLM(
31-
provider="anthropic",
31+
provider="anthropic", # or "openai", "ollama", "hybrid"
3232
api_key="your-key",
3333
memory_enabled=True
3434
)
@@ -42,6 +42,27 @@ response = await llm.interact(
4242

4343
That's it. Next time this user connects—even days later—Claude remembers.
4444

45+
## New in v3.0.0: Multi-Provider Support
46+
47+
Choose your provider—or mix them:
48+
49+
```bash
50+
# Check available providers (auto-detects API keys)
51+
python -m empathy_os.models.cli provider status
52+
53+
# Switch providers
54+
python -m empathy_os.models.cli provider set openai
55+
56+
# Enable hybrid mode (best model from each provider)
57+
python -m empathy_os.models.cli provider set hybrid
58+
```
59+
60+
Supported providers:
61+
- **Anthropic** — Claude (Haiku/Sonnet/Opus)
62+
- **OpenAI** — GPT (GPT-4o-mini/GPT-4o/o1)
63+
- **Ollama** — Local models (Llama 3.2)
64+
- **Hybrid** — Best of each provider per tier
65+
4566
## Real-World Example: Debugging Wizard
4667

4768
Here's what persistent memory enables. I built a debugging wizard that correlates current bugs with historical patterns:
@@ -113,23 +134,25 @@ On a real codebase (364 debt items, 81 security findings):
113134
- **Security noise reduction**: 84% (81 → 13 findings after learning)
114135
- **Tech debt tracking**: Trajectory predicts 2x growth in 170 days
115136

116-
## NEW in v2.3: Smart Model Routing (80% Cost Savings)
137+
## v3.0.0: Smart Model Routing (80% Cost Savings)
138+
139+
Why pay Opus prices for simple tasks? The ModelRouter automatically picks the right model across any provider.
117140

118-
Why pay Opus prices for simple tasks? The new ModelRouter automatically picks the right model:
141+
*API users save money. Subscription users (Max/Pro) preserve their premium model quota for complex tasks.*
119142

120143
```python
121144
llm = EmpathyLLM(
122-
provider="anthropic",
123-
enable_model_routing=True # NEW!
145+
provider="anthropic", # or "openai", "ollama", "hybrid"
146+
enable_model_routing=True
124147
)
125148

126-
# Summarization → Haiku ($0.25/M tokens)
149+
# Summarization → Haiku/GPT-4o-mini ($0.25/M tokens)
127150
await llm.interact(user_id="dev", user_input="Summarize this", task_type="summarize")
128151

129-
# Code generation → Sonnet ($3/M tokens)
152+
# Code generation → Sonnet/GPT-4o ($3/M tokens)
130153
await llm.interact(user_id="dev", user_input="Write a function", task_type="generate_code")
131154

132-
# Architecture → Opus ($15/M tokens)
155+
# Architecture → Opus/o1 ($15/M tokens)
133156
await llm.interact(user_id="dev", user_input="Design the system", task_type="architectural_decision")
134157
```
135158

@@ -138,13 +161,33 @@ await llm.interact(user_id="dev", user_input="Design the system", task_type="arc
138161
- With routing (tiered): $0.83/complex task
139162
- **Savings: 80%**
140163

164+
## v3.0.0: VSCode Dashboard
165+
166+
The biggest addition in v3.0.0 is a complete VSCode Dashboard with **10 integrated workflows**:
167+
168+
1. **Research Synthesis** — Deep dive research with citations
169+
2. **Code Review** — Comprehensive PR analysis
170+
3. **Debug Assistant** — Smart error diagnosis
171+
4. **Refactor Advisor** — Code improvement suggestions
172+
5. **Test Generator** — Automated test creation
173+
6. **Documentation Writer** — Auto-generate docs
174+
7. **Security Scanner** — Vulnerability detection
175+
8. **Performance Analyzer** — Bottleneck identification
176+
9. **Explain Code** — Code explanation for onboarding
177+
10. **Morning Briefing** — Daily project status report
178+
179+
Plus **6 Quick Action commands** for common tasks.
180+
181+
All with real-time cost tracking showing your savings.
182+
141183
## Get Started
142184

143185
```bash
144186
pip install empathy-framework
145187
```
146188

147189
**Resources:**
190+
- **PyPI:** 3,400+ monthly downloads
148191
- [GitHub](https://github.com/Smart-AI-Memory/empathy-framework)
149192
- [Documentation](https://www.smartaimemory.com/docs)
150193
- [Live Demo](https://www.smartaimemory.com/tools/debug-wizard)

0 commit comments

Comments
 (0)