empathy-framework 4.6.3__py3-none-any.whl → 4.6.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. {empathy_framework-4.6.3.dist-info → empathy_framework-4.6.5.dist-info}/METADATA +53 -11
  2. {empathy_framework-4.6.3.dist-info → empathy_framework-4.6.5.dist-info}/RECORD +32 -57
  3. empathy_llm_toolkit/agent_factory/crews/health_check.py +7 -4
  4. empathy_llm_toolkit/agent_factory/decorators.py +3 -2
  5. empathy_llm_toolkit/agent_factory/memory_integration.py +6 -2
  6. empathy_llm_toolkit/contextual_patterns.py +5 -2
  7. empathy_llm_toolkit/git_pattern_extractor.py +8 -4
  8. empathy_llm_toolkit/providers.py +4 -3
  9. empathy_os/__init__.py +1 -1
  10. empathy_os/cli/__init__.py +306 -0
  11. empathy_os/cli/__main__.py +26 -0
  12. empathy_os/cli/commands/__init__.py +8 -0
  13. empathy_os/cli/commands/inspection.py +48 -0
  14. empathy_os/cli/commands/memory.py +56 -0
  15. empathy_os/cli/commands/provider.py +86 -0
  16. empathy_os/cli/commands/utilities.py +94 -0
  17. empathy_os/cli/core.py +32 -0
  18. empathy_os/cli.py +18 -6
  19. empathy_os/cli_unified.py +19 -3
  20. empathy_os/memory/short_term.py +12 -2
  21. empathy_os/project_index/scanner.py +151 -49
  22. empathy_os/socratic/visual_editor.py +9 -4
  23. empathy_os/workflows/bug_predict.py +70 -1
  24. empathy_os/workflows/pr_review.py +6 -0
  25. empathy_os/workflows/security_audit.py +13 -0
  26. empathy_os/workflows/tier_tracking.py +50 -2
  27. wizards/discharge_summary_wizard.py +4 -2
  28. wizards/incident_report_wizard.py +4 -2
  29. empathy_os/meta_workflows/agent_creator 2.py +0 -254
  30. empathy_os/meta_workflows/builtin_templates 2.py +0 -567
  31. empathy_os/meta_workflows/cli_meta_workflows 2.py +0 -1551
  32. empathy_os/meta_workflows/form_engine 2.py +0 -304
  33. empathy_os/meta_workflows/intent_detector 2.py +0 -298
  34. empathy_os/meta_workflows/pattern_learner 2.py +0 -754
  35. empathy_os/meta_workflows/session_context 2.py +0 -398
  36. empathy_os/meta_workflows/template_registry 2.py +0 -229
  37. empathy_os/meta_workflows/workflow 2.py +0 -980
  38. empathy_os/orchestration/pattern_learner 2.py +0 -699
  39. empathy_os/orchestration/real_tools 2.py +0 -938
  40. empathy_os/socratic/__init__ 2.py +0 -273
  41. empathy_os/socratic/ab_testing 2.py +0 -969
  42. empathy_os/socratic/blueprint 2.py +0 -532
  43. empathy_os/socratic/cli 2.py +0 -689
  44. empathy_os/socratic/collaboration 2.py +0 -1112
  45. empathy_os/socratic/domain_templates 2.py +0 -916
  46. empathy_os/socratic/embeddings 2.py +0 -734
  47. empathy_os/socratic/engine 2.py +0 -729
  48. empathy_os/socratic/explainer 2.py +0 -663
  49. empathy_os/socratic/feedback 2.py +0 -767
  50. empathy_os/socratic/forms 2.py +0 -624
  51. empathy_os/socratic/generator 2.py +0 -716
  52. empathy_os/socratic/llm_analyzer 2.py +0 -635
  53. empathy_os/socratic/mcp_server 2.py +0 -751
  54. empathy_os/socratic/session 2.py +0 -306
  55. empathy_os/socratic/storage 2.py +0 -635
  56. empathy_os/socratic/success 2.py +0 -719
  57. empathy_os/socratic/visual_editor 2.py +0 -812
  58. empathy_os/socratic/web_ui 2.py +0 -925
  59. empathy_os/workflows/batch_processing 2.py +0 -310
  60. empathy_os/workflows/release_prep_crew 2.py +0 -968
  61. empathy_os/workflows/test_coverage_boost_crew 2.py +0 -848
  62. {empathy_framework-4.6.3.dist-info → empathy_framework-4.6.5.dist-info}/WHEEL +0 -0
  63. {empathy_framework-4.6.3.dist-info → empathy_framework-4.6.5.dist-info}/entry_points.txt +0 -0
  64. {empathy_framework-4.6.3.dist-info → empathy_framework-4.6.5.dist-info}/licenses/LICENSE +0 -0
  65. {empathy_framework-4.6.3.dist-info → empathy_framework-4.6.5.dist-info}/top_level.txt +0 -0
@@ -1,532 +0,0 @@
1
- """Agent and Workflow Blueprints
2
-
3
- Intermediate representation for generating agents and workflows.
4
-
5
- Blueprints capture the design decisions made through Socratic questioning
6
- before actual agent generation. This allows for:
7
- - Review before generation
8
- - Modification of the design
9
- - Serialization/persistence
10
- - Template reuse
11
-
12
- Copyright 2026 Smart-AI-Memory
13
- Licensed under Fair Source License 0.9
14
- """
15
-
16
- from __future__ import annotations
17
-
18
- import uuid
19
- from dataclasses import dataclass, field
20
- from enum import Enum
21
- from typing import Any
22
-
23
-
24
- class AgentRole(Enum):
25
- """Standard agent roles for team composition."""
26
-
27
- # Analysis agents
28
- ANALYZER = "analyzer" # Examines input, identifies patterns
29
- REVIEWER = "reviewer" # Evaluates quality, finds issues
30
- AUDITOR = "auditor" # Deep-dive security/compliance checks
31
-
32
- # Action agents
33
- GENERATOR = "generator" # Creates new content/code
34
- FIXER = "fixer" # Applies corrections and improvements
35
- REFACTORER = "refactorer" # Restructures without changing behavior
36
-
37
- # Coordination agents
38
- ORCHESTRATOR = "orchestrator" # Coordinates other agents
39
- VALIDATOR = "validator" # Verifies outputs and quality
40
- REPORTER = "reporter" # Synthesizes and presents results
41
-
42
- # Specialized agents
43
- SPECIALIST = "specialist" # Domain-specific expertise
44
- ASSISTANT = "assistant" # General-purpose helper
45
-
46
-
47
- class ToolCategory(Enum):
48
- """Categories of tools agents can use."""
49
-
50
- # Code intelligence
51
- CODE_ANALYSIS = "code_analysis" # AST parsing, complexity metrics
52
- CODE_SEARCH = "code_search" # Grep, file search
53
- CODE_MODIFICATION = "code_modification" # Edit, write, refactor
54
-
55
- # Quality tools
56
- TESTING = "testing" # Run tests, coverage
57
- LINTING = "linting" # Static analysis
58
- SECURITY = "security" # Security scanners
59
-
60
- # Documentation
61
- DOCUMENTATION = "documentation" # Doc generation, README
62
- KNOWLEDGE = "knowledge" # Pattern library, memory
63
-
64
- # External
65
- API = "api" # External API calls
66
- DATABASE = "database" # Data storage/retrieval
67
- FILESYSTEM = "filesystem" # File operations
68
-
69
-
70
- @dataclass
71
- class ToolSpec:
72
- """Specification for a tool an agent can use.
73
-
74
- Example:
75
- >>> tool = ToolSpec(
76
- ... id="grep_codebase",
77
- ... name="Code Search",
78
- ... category=ToolCategory.CODE_SEARCH,
79
- ... description="Search codebase for patterns",
80
- ... parameters={
81
- ... "pattern": {"type": "string", "required": True},
82
- ... "file_type": {"type": "string", "required": False}
83
- ... }
84
- ... )
85
- """
86
-
87
- # Unique tool identifier
88
- id: str
89
-
90
- # Display name
91
- name: str
92
-
93
- # Tool category
94
- category: ToolCategory
95
-
96
- # Description of what the tool does
97
- description: str
98
-
99
- # Parameter schema
100
- parameters: dict[str, dict[str, Any]] = field(default_factory=dict)
101
-
102
- # Whether tool requires confirmation before use
103
- requires_confirmation: bool = False
104
-
105
- # Whether tool can modify state
106
- is_mutating: bool = False
107
-
108
- # Cost tier (for expensive operations)
109
- cost_tier: str = "cheap" # cheap, moderate, expensive
110
-
111
- def to_dict(self) -> dict[str, Any]:
112
- """Serialize to dictionary."""
113
- return {
114
- "id": self.id,
115
- "name": self.name,
116
- "category": self.category.value,
117
- "description": self.description,
118
- "parameters": self.parameters,
119
- "requires_confirmation": self.requires_confirmation,
120
- "is_mutating": self.is_mutating,
121
- "cost_tier": self.cost_tier,
122
- }
123
-
124
-
125
- @dataclass
126
- class AgentSpec:
127
- """Specification for a single agent.
128
-
129
- Example:
130
- >>> agent = AgentSpec(
131
- ... id="security_reviewer",
132
- ... name="Security Reviewer",
133
- ... role=AgentRole.REVIEWER,
134
- ... goal="Identify security vulnerabilities in code",
135
- ... backstory="Expert in OWASP Top 10 and secure coding",
136
- ... tools=[security_scan_tool, grep_tool],
137
- ... quality_focus=["security"],
138
- ... model_tier="capable"
139
- ... )
140
- """
141
-
142
- # Unique agent identifier
143
- id: str
144
-
145
- # Display name
146
- name: str
147
-
148
- # Agent's role in the team
149
- role: AgentRole
150
-
151
- # What this agent aims to achieve
152
- goal: str
153
-
154
- # Agent's expertise and personality
155
- backstory: str
156
-
157
- # Tools this agent can use
158
- tools: list[ToolSpec] = field(default_factory=list)
159
-
160
- # Quality attributes this agent focuses on
161
- quality_focus: list[str] = field(default_factory=list)
162
-
163
- # Model tier for this agent (cheap, capable, premium)
164
- model_tier: str = "capable"
165
-
166
- # Custom instructions for this agent
167
- custom_instructions: list[str] = field(default_factory=list)
168
-
169
- # Languages this agent specializes in
170
- languages: list[str] = field(default_factory=list)
171
-
172
- # Whether this agent is optional in the workflow
173
- is_optional: bool = False
174
-
175
- # Conditions for including this agent
176
- include_when: dict[str, Any] | None = None
177
-
178
- # Priority (higher = runs earlier in parallel execution)
179
- priority: int = 5
180
-
181
- # Maximum retries on failure
182
- max_retries: int = 2
183
-
184
- def to_dict(self) -> dict[str, Any]:
185
- """Serialize to dictionary."""
186
- return {
187
- "id": self.id,
188
- "name": self.name,
189
- "role": self.role.value,
190
- "goal": self.goal,
191
- "backstory": self.backstory,
192
- "tools": [t.to_dict() for t in self.tools],
193
- "quality_focus": self.quality_focus,
194
- "model_tier": self.model_tier,
195
- "custom_instructions": self.custom_instructions,
196
- "languages": self.languages,
197
- "is_optional": self.is_optional,
198
- "include_when": self.include_when,
199
- "priority": self.priority,
200
- "max_retries": self.max_retries,
201
- }
202
-
203
-
204
- @dataclass
205
- class StageSpec:
206
- """Specification for a workflow stage.
207
-
208
- Stages define when and how agents execute in the workflow.
209
- """
210
-
211
- # Stage identifier
212
- id: str
213
-
214
- # Display name
215
- name: str
216
-
217
- # Description of what happens in this stage
218
- description: str
219
-
220
- # Agents that execute in this stage (can be parallel)
221
- agent_ids: list[str]
222
-
223
- # Whether agents in this stage run in parallel
224
- parallel: bool = False
225
-
226
- # Conditions for running this stage
227
- run_when: dict[str, Any] | None = None
228
-
229
- # Stage this must complete before
230
- depends_on: list[str] = field(default_factory=list)
231
-
232
- # Data passed to agents in this stage
233
- input_mapping: dict[str, str] = field(default_factory=dict)
234
-
235
- # How to combine outputs from parallel agents
236
- output_aggregation: str = "merge" # merge, first, vote, custom
237
-
238
- # Timeout for this stage (seconds)
239
- timeout: int = 300
240
-
241
- def to_dict(self) -> dict[str, Any]:
242
- """Serialize to dictionary."""
243
- return {
244
- "id": self.id,
245
- "name": self.name,
246
- "description": self.description,
247
- "agent_ids": self.agent_ids,
248
- "parallel": self.parallel,
249
- "run_when": self.run_when,
250
- "depends_on": self.depends_on,
251
- "input_mapping": self.input_mapping,
252
- "output_aggregation": self.output_aggregation,
253
- "timeout": self.timeout,
254
- }
255
-
256
-
257
- @dataclass
258
- class AgentBlueprint:
259
- """Blueprint for generating an agent.
260
-
261
- Contains all information needed to instantiate an agent.
262
- """
263
-
264
- # The agent specification
265
- spec: AgentSpec
266
-
267
- # Generation metadata
268
- generated_from: str = "socratic" # socratic, template, manual
269
-
270
- # Template ID if based on a template
271
- template_id: str | None = None
272
-
273
- # Customizations applied
274
- customizations: dict[str, Any] = field(default_factory=dict)
275
-
276
- # Validation status
277
- validated: bool = False
278
-
279
- # Validation errors if any
280
- validation_errors: list[str] = field(default_factory=list)
281
-
282
- def validate(self) -> bool:
283
- """Validate the blueprint.
284
-
285
- Returns:
286
- True if valid, False otherwise
287
- """
288
- self.validation_errors = []
289
-
290
- if not self.spec.id:
291
- self.validation_errors.append("Agent must have an ID")
292
-
293
- if not self.spec.name:
294
- self.validation_errors.append("Agent must have a name")
295
-
296
- if not self.spec.goal:
297
- self.validation_errors.append("Agent must have a goal")
298
-
299
- if not self.spec.backstory:
300
- self.validation_errors.append("Agent must have a backstory")
301
-
302
- self.validated = len(self.validation_errors) == 0
303
- return self.validated
304
-
305
-
306
- @dataclass
307
- class WorkflowBlueprint:
308
- """Blueprint for a complete workflow with agents.
309
-
310
- Example:
311
- >>> blueprint = WorkflowBlueprint(
312
- ... id="code_review_workflow",
313
- ... name="Automated Code Review",
314
- ... description="Multi-agent code review pipeline",
315
- ... agents=[security_agent, style_agent, complexity_agent],
316
- ... stages=[analysis_stage, synthesis_stage],
317
- ... success_criteria=success_spec
318
- ... )
319
- """
320
-
321
- # Unique workflow identifier
322
- id: str = field(default_factory=lambda: str(uuid.uuid4()))
323
-
324
- # Workflow name
325
- name: str = ""
326
-
327
- # Description of what this workflow does
328
- description: str = ""
329
-
330
- # Agent blueprints in this workflow
331
- agents: list[AgentBlueprint] = field(default_factory=list)
332
-
333
- # Stage definitions
334
- stages: list[StageSpec] = field(default_factory=list)
335
-
336
- # Success criteria specification
337
- success_criteria: Any = None # SuccessCriteria, imported lazily
338
-
339
- # Input schema (what the workflow accepts)
340
- input_schema: dict[str, Any] = field(default_factory=dict)
341
-
342
- # Output schema (what the workflow produces)
343
- output_schema: dict[str, Any] = field(default_factory=dict)
344
-
345
- # Domain this workflow is for
346
- domain: str = "general"
347
-
348
- # Languages this workflow supports
349
- supported_languages: list[str] = field(default_factory=list)
350
-
351
- # Quality attributes this workflow optimizes for
352
- quality_focus: list[str] = field(default_factory=list)
353
-
354
- # Automation level
355
- automation_level: str = "semi_auto"
356
-
357
- # Estimated cost tier
358
- cost_tier: str = "moderate"
359
-
360
- # Version for tracking changes
361
- version: str = "1.0.0"
362
-
363
- # Generation timestamp
364
- generated_at: str = ""
365
-
366
- # Source session ID
367
- source_session_id: str | None = None
368
-
369
- # Additional metadata
370
- metadata: dict[str, Any] = field(default_factory=dict)
371
-
372
- def get_agent_by_id(self, agent_id: str) -> AgentBlueprint | None:
373
- """Get an agent blueprint by ID."""
374
- for agent in self.agents:
375
- if agent.spec.id == agent_id:
376
- return agent
377
- return None
378
-
379
- def get_stage_by_id(self, stage_id: str) -> StageSpec | None:
380
- """Get a stage specification by ID."""
381
- for stage in self.stages:
382
- if stage.id == stage_id:
383
- return stage
384
- return None
385
-
386
- def validate(self) -> tuple[bool, list[str]]:
387
- """Validate the entire blueprint.
388
-
389
- Returns:
390
- Tuple of (is_valid, list of error messages)
391
- """
392
- errors = []
393
-
394
- if not self.name:
395
- errors.append("Workflow must have a name")
396
-
397
- if not self.agents:
398
- errors.append("Workflow must have at least one agent")
399
-
400
- if not self.stages:
401
- errors.append("Workflow must have at least one stage")
402
-
403
- # Validate all agents
404
- for agent in self.agents:
405
- if not agent.validate():
406
- errors.extend(
407
- f"Agent '{agent.spec.id}': {e}" for e in agent.validation_errors
408
- )
409
-
410
- # Validate stages reference valid agents
411
- agent_ids = {a.spec.id for a in self.agents}
412
- for stage in self.stages:
413
- for agent_id in stage.agent_ids:
414
- if agent_id not in agent_ids:
415
- errors.append(
416
- f"Stage '{stage.id}' references unknown agent '{agent_id}'"
417
- )
418
-
419
- # Validate stage dependencies
420
- stage_ids = {s.id for s in self.stages}
421
- for stage in self.stages:
422
- for dep in stage.depends_on:
423
- if dep not in stage_ids:
424
- errors.append(
425
- f"Stage '{stage.id}' depends on unknown stage '{dep}'"
426
- )
427
-
428
- return len(errors) == 0, errors
429
-
430
- def to_dict(self) -> dict[str, Any]:
431
- """Serialize to dictionary."""
432
- return {
433
- "id": self.id,
434
- "name": self.name,
435
- "description": self.description,
436
- "agents": [
437
- {
438
- "spec": a.spec.to_dict(),
439
- "generated_from": a.generated_from,
440
- "template_id": a.template_id,
441
- "customizations": a.customizations,
442
- }
443
- for a in self.agents
444
- ],
445
- "stages": [s.to_dict() for s in self.stages],
446
- "input_schema": self.input_schema,
447
- "output_schema": self.output_schema,
448
- "domain": self.domain,
449
- "supported_languages": self.supported_languages,
450
- "quality_focus": self.quality_focus,
451
- "automation_level": self.automation_level,
452
- "cost_tier": self.cost_tier,
453
- "version": self.version,
454
- "generated_at": self.generated_at,
455
- "source_session_id": self.source_session_id,
456
- "metadata": self.metadata,
457
- }
458
-
459
- @classmethod
460
- def from_dict(cls, data: dict[str, Any]) -> WorkflowBlueprint:
461
- """Deserialize from dictionary."""
462
- blueprint = cls(
463
- id=data.get("id", str(uuid.uuid4())),
464
- name=data.get("name", ""),
465
- description=data.get("description", ""),
466
- domain=data.get("domain", "general"),
467
- supported_languages=data.get("supported_languages", []),
468
- quality_focus=data.get("quality_focus", []),
469
- automation_level=data.get("automation_level", "semi_auto"),
470
- cost_tier=data.get("cost_tier", "moderate"),
471
- version=data.get("version", "1.0.0"),
472
- generated_at=data.get("generated_at", ""),
473
- source_session_id=data.get("source_session_id"),
474
- metadata=data.get("metadata", {}),
475
- input_schema=data.get("input_schema", {}),
476
- output_schema=data.get("output_schema", {}),
477
- )
478
-
479
- # Parse agents
480
- for agent_data in data.get("agents", []):
481
- spec_data = agent_data.get("spec", {})
482
- spec = AgentSpec(
483
- id=spec_data.get("id", ""),
484
- name=spec_data.get("name", ""),
485
- role=AgentRole(spec_data.get("role", "specialist")),
486
- goal=spec_data.get("goal", ""),
487
- backstory=spec_data.get("backstory", ""),
488
- quality_focus=spec_data.get("quality_focus", []),
489
- model_tier=spec_data.get("model_tier", "capable"),
490
- custom_instructions=spec_data.get("custom_instructions", []),
491
- languages=spec_data.get("languages", []),
492
- is_optional=spec_data.get("is_optional", False),
493
- priority=spec_data.get("priority", 5),
494
- max_retries=spec_data.get("max_retries", 2),
495
- )
496
-
497
- # Parse tools
498
- for tool_data in spec_data.get("tools", []):
499
- spec.tools.append(ToolSpec(
500
- id=tool_data.get("id", ""),
501
- name=tool_data.get("name", ""),
502
- category=ToolCategory(tool_data.get("category", "code_analysis")),
503
- description=tool_data.get("description", ""),
504
- parameters=tool_data.get("parameters", {}),
505
- requires_confirmation=tool_data.get("requires_confirmation", False),
506
- is_mutating=tool_data.get("is_mutating", False),
507
- cost_tier=tool_data.get("cost_tier", "cheap"),
508
- ))
509
-
510
- blueprint.agents.append(AgentBlueprint(
511
- spec=spec,
512
- generated_from=agent_data.get("generated_from", "socratic"),
513
- template_id=agent_data.get("template_id"),
514
- customizations=agent_data.get("customizations", {}),
515
- ))
516
-
517
- # Parse stages
518
- for stage_data in data.get("stages", []):
519
- blueprint.stages.append(StageSpec(
520
- id=stage_data.get("id", ""),
521
- name=stage_data.get("name", ""),
522
- description=stage_data.get("description", ""),
523
- agent_ids=stage_data.get("agent_ids", []),
524
- parallel=stage_data.get("parallel", False),
525
- run_when=stage_data.get("run_when"),
526
- depends_on=stage_data.get("depends_on", []),
527
- input_mapping=stage_data.get("input_mapping", {}),
528
- output_aggregation=stage_data.get("output_aggregation", "merge"),
529
- timeout=stage_data.get("timeout", 300),
530
- ))
531
-
532
- return blueprint