empathy-framework 4.7.1__py3-none-any.whl → 4.8.0__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 (90) hide show
  1. {empathy_framework-4.7.1.dist-info → empathy_framework-4.8.0.dist-info}/METADATA +65 -2
  2. {empathy_framework-4.7.1.dist-info → empathy_framework-4.8.0.dist-info}/RECORD +73 -52
  3. {empathy_framework-4.7.1.dist-info → empathy_framework-4.8.0.dist-info}/WHEEL +1 -1
  4. {empathy_framework-4.7.1.dist-info → empathy_framework-4.8.0.dist-info}/entry_points.txt +2 -1
  5. {empathy_framework-4.7.1.dist-info → empathy_framework-4.8.0.dist-info}/top_level.txt +0 -1
  6. empathy_os/__init__.py +2 -0
  7. empathy_os/cache/hash_only.py +6 -3
  8. empathy_os/cache/hybrid.py +6 -3
  9. empathy_os/cli/__init__.py +128 -238
  10. empathy_os/cli/__main__.py +5 -33
  11. empathy_os/cli/commands/__init__.py +1 -8
  12. empathy_os/cli/commands/help.py +331 -0
  13. empathy_os/cli/commands/info.py +140 -0
  14. empathy_os/cli/commands/inspect.py +437 -0
  15. empathy_os/cli/commands/metrics.py +92 -0
  16. empathy_os/cli/commands/orchestrate.py +184 -0
  17. empathy_os/cli/commands/patterns.py +207 -0
  18. empathy_os/cli/commands/provider.py +93 -81
  19. empathy_os/cli/commands/setup.py +96 -0
  20. empathy_os/cli/commands/status.py +235 -0
  21. empathy_os/cli/commands/sync.py +166 -0
  22. empathy_os/cli/commands/tier.py +121 -0
  23. empathy_os/cli/commands/workflow.py +574 -0
  24. empathy_os/cli/parsers/__init__.py +62 -0
  25. empathy_os/cli/parsers/help.py +41 -0
  26. empathy_os/cli/parsers/info.py +26 -0
  27. empathy_os/cli/parsers/inspect.py +66 -0
  28. empathy_os/cli/parsers/metrics.py +42 -0
  29. empathy_os/cli/parsers/orchestrate.py +61 -0
  30. empathy_os/cli/parsers/patterns.py +54 -0
  31. empathy_os/cli/parsers/provider.py +40 -0
  32. empathy_os/cli/parsers/setup.py +42 -0
  33. empathy_os/cli/parsers/status.py +47 -0
  34. empathy_os/cli/parsers/sync.py +31 -0
  35. empathy_os/cli/parsers/tier.py +33 -0
  36. empathy_os/cli/parsers/workflow.py +77 -0
  37. empathy_os/cli/utils/__init__.py +1 -0
  38. empathy_os/cli/utils/data.py +242 -0
  39. empathy_os/cli/utils/helpers.py +68 -0
  40. empathy_os/{cli.py → cli_legacy.py} +27 -27
  41. empathy_os/cli_minimal.py +662 -0
  42. empathy_os/cli_router.py +384 -0
  43. empathy_os/cli_unified.py +38 -2
  44. empathy_os/memory/__init__.py +19 -5
  45. empathy_os/memory/short_term.py +14 -404
  46. empathy_os/memory/types.py +437 -0
  47. empathy_os/memory/unified.py +61 -48
  48. empathy_os/models/fallback.py +1 -1
  49. empathy_os/models/provider_config.py +59 -344
  50. empathy_os/models/registry.py +31 -180
  51. empathy_os/monitoring/alerts.py +14 -20
  52. empathy_os/monitoring/alerts_cli.py +24 -7
  53. empathy_os/project_index/__init__.py +2 -0
  54. empathy_os/project_index/index.py +210 -5
  55. empathy_os/project_index/scanner.py +45 -14
  56. empathy_os/project_index/scanner_parallel.py +291 -0
  57. empathy_os/socratic/ab_testing.py +1 -1
  58. empathy_os/workflows/__init__.py +31 -2
  59. empathy_os/workflows/base.py +349 -325
  60. empathy_os/workflows/bug_predict.py +8 -0
  61. empathy_os/workflows/builder.py +273 -0
  62. empathy_os/workflows/caching.py +253 -0
  63. empathy_os/workflows/code_review_pipeline.py +1 -0
  64. empathy_os/workflows/history.py +510 -0
  65. empathy_os/workflows/output.py +410 -0
  66. empathy_os/workflows/perf_audit.py +125 -19
  67. empathy_os/workflows/progress.py +324 -22
  68. empathy_os/workflows/routing.py +168 -0
  69. empathy_os/workflows/secure_release.py +1 -0
  70. empathy_os/workflows/security_audit.py +190 -0
  71. empathy_os/workflows/security_audit_phase3.py +328 -0
  72. empathy_os/workflows/telemetry_mixin.py +269 -0
  73. empathy_os/dashboard/__init__.py +0 -15
  74. empathy_os/dashboard/server.py +0 -941
  75. patterns/README.md +0 -119
  76. patterns/__init__.py +0 -95
  77. patterns/behavior.py +0 -298
  78. patterns/code_review_memory.json +0 -441
  79. patterns/core.py +0 -97
  80. patterns/debugging.json +0 -3763
  81. patterns/empathy.py +0 -268
  82. patterns/health_check_memory.json +0 -505
  83. patterns/input.py +0 -161
  84. patterns/memory_graph.json +0 -8
  85. patterns/refactoring_memory.json +0 -1113
  86. patterns/registry.py +0 -663
  87. patterns/security_memory.json +0 -8
  88. patterns/structural.py +0 -415
  89. patterns/validation.py +0 -194
  90. {empathy_framework-4.7.1.dist-info → empathy_framework-4.8.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,262 +1,152 @@
1
- """Unified CLI for Empathy Framework.
1
+ """Empathy Framework CLI - Refactored modular structure.
2
2
 
3
- A single entry point for all Empathy Framework commands using Typer.
4
-
5
- Usage:
6
- empathy --help # Show all commands
7
- empathy memory status # Memory control panel
8
- empathy provider # Show provider config
9
- empathy scan . # Scan codebase
10
- empathy morning # Start-of-day briefing
3
+ Entry point for the empathy command-line interface.
11
4
 
12
5
  Copyright 2025 Smart-AI-Memory
13
6
  Licensed under Fair Source License 0.9
14
7
  """
15
8
 
16
- import subprocess
9
+ import argparse
17
10
  import sys
18
- from pathlib import Path
19
-
20
- import typer
21
-
22
- # Re-export legacy CLI functions for backward compatibility
23
- # These functions are defined in the sibling cli.py module (now cli_legacy)
24
- # Tests and other code may import them from empathy_os.cli
25
- try:
26
- # Import from the legacy module using relative import workaround
27
- # Since this package shadows cli.py, we need to import it explicitly
28
- import importlib.util
29
- import os
30
-
31
- _legacy_cli_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "cli.py")
32
- if os.path.exists(_legacy_cli_path):
33
- _spec = importlib.util.spec_from_file_location("cli_legacy", _legacy_cli_path)
34
- _cli_legacy = importlib.util.module_from_spec(_spec)
35
- _spec.loader.exec_module(_cli_legacy)
36
-
37
- # Re-export legacy functions
38
- cmd_info = _cli_legacy.cmd_info
39
- cmd_init = _cli_legacy.cmd_init
40
- cmd_version = _cli_legacy.cmd_version
41
- cmd_validate = _cli_legacy.cmd_validate
42
- cmd_patterns_list = _cli_legacy.cmd_patterns_list
43
- cmd_patterns_export = _cli_legacy.cmd_patterns_export
44
- cmd_metrics_show = _cli_legacy.cmd_metrics_show
45
- cmd_state_list = _cli_legacy.cmd_state_list
46
- cmd_run = _cli_legacy.cmd_run
47
- cmd_inspect = _cli_legacy.cmd_inspect
48
- cmd_export = _cli_legacy.cmd_export
49
- cmd_import = _cli_legacy.cmd_import
50
- cmd_workflow = _cli_legacy.cmd_workflow
51
- cmd_cheatsheet = _cli_legacy.cmd_cheatsheet
52
- cmd_frameworks = _cli_legacy.cmd_frameworks
53
- main_legacy = _cli_legacy.main
54
-
55
- # Export for backward compatibility
56
- __all__ = [
57
- "app",
58
- "main",
59
- "cmd_info",
60
- "cmd_init",
61
- "cmd_version",
62
- "cmd_validate",
63
- "cmd_patterns_list",
64
- "cmd_patterns_export",
65
- "cmd_metrics_show",
66
- "cmd_state_list",
67
- "cmd_run",
68
- "cmd_inspect",
69
- "cmd_export",
70
- "cmd_import",
71
- "cmd_workflow",
72
- "cmd_cheatsheet",
73
- "cmd_frameworks",
74
- ]
75
- except Exception: # noqa: BLE001
76
- # INTENTIONAL: If legacy import fails, functions won't be available.
77
- # New CLI still works; legacy re-exports are for backward compatibility only.
78
- pass
79
-
80
- from empathy_os.cli.commands import inspection
81
- from empathy_os.cli.commands.memory import memory_app
82
- from empathy_os.cli.commands.profiling import profile_app
83
- from empathy_os.cli.commands.provider import provider_app
84
- from empathy_os.cli.commands.utilities import utilities_app
85
- from empathy_os.cli.core import console, get_empathy_version, version_callback
86
-
87
- # Create the main Typer app
88
- app = typer.Typer(
89
- name="empathy",
90
- help="Empathy Framework - Predictive AI-Developer Collaboration",
91
- no_args_is_help=True,
92
- rich_markup_mode="rich",
93
- )
94
-
95
- # Register command group apps
96
- app.add_typer(memory_app, name="memory")
97
- app.add_typer(profile_app, name="profile")
98
- app.add_typer(provider_app, name="provider")
99
- app.add_typer(utilities_app, name="utilities")
100
- app.add_typer(utilities_app, name="utility", hidden=True) # Alias for common typo
101
-
102
-
103
- @app.callback()
104
- def callback(
105
- version: bool = typer.Option(
106
- None,
107
- "--version",
108
- "-v",
109
- callback=version_callback,
110
- is_eager=True,
111
- help="Show version and exit",
112
- ),
113
- ) -> None:
114
- """Empathy Framework - Predictive AI-Developer Collaboration
115
-
116
- The AI collaboration framework that predicts problems before they happen.
117
-
118
- [bold]Quick Start:[/bold]
119
- empathy morning Start-of-day briefing
120
- empathy health Quick health check
121
- empathy ship Pre-commit validation
122
-
123
- [bold]Memory:[/bold]
124
- empathy memory status Check memory system status
125
- empathy memory start Start Redis server
126
-
127
- [bold]Provider:[/bold]
128
- empathy provider Show current provider config
129
- empathy provider --set hybrid Configure provider
130
-
131
- [bold]Inspection:[/bold]
132
- empathy scan . Scan codebase for issues
133
- empathy inspect . Deep inspection with SARIF output
11
+
12
+ from empathy_os.discovery import show_tip_if_available
13
+ from empathy_os.logging_config import get_logger
14
+ from empathy_os.platform_utils import setup_asyncio_policy
15
+
16
+ logger = get_logger(__name__)
17
+
18
+
19
+ def get_version() -> str:
20
+ """Get package version.
21
+
22
+ Returns:
23
+ Version string or "dev" if not installed
134
24
  """
25
+ try:
26
+ from importlib.metadata import version
135
27
 
28
+ return version("empathy-framework")
29
+ except Exception: # noqa: BLE001
30
+ return "dev"
136
31
 
137
- # =============================================================================
138
- # SCAN/INSPECT COMMANDS (top-level)
139
- # =============================================================================
140
-
141
-
142
- @app.command("scan")
143
- def scan(
144
- path: Path = Path("."),
145
- format_out: str = "text",
146
- fix: bool = False,
147
- staged: bool = False,
148
- ) -> None:
149
- """Scan codebase for issues."""
150
- inspection.scan(path, format_out, fix, staged)
151
-
152
-
153
- @app.command("inspect")
154
- def inspect_cmd(
155
- path: Path = Path("."),
156
- format_out: str = "text",
157
- ) -> None:
158
- """Deep inspection with code analysis."""
159
- inspection.inspect_cmd(path, format_out)
160
-
161
-
162
- # =============================================================================
163
- # WORKFLOW COMMANDS (delegate to legacy CLI for now)
164
- # These will be extracted in Phase 2b
165
- # =============================================================================
166
-
167
-
168
- @app.command("ship")
169
- def ship(
170
- tests_only: bool = False,
171
- security_only: bool = False,
172
- skip_sync: bool = False,
173
- ) -> None:
174
- """Pre-commit validation (lint, format, tests, security)."""
175
- args = [sys.executable, "-m", "empathy_os.cli", "ship"]
176
- if tests_only:
177
- args.append("--tests-only")
178
- if security_only:
179
- args.append("--security-only")
180
- if skip_sync:
181
- args.append("--skip-sync")
182
- subprocess.run(args, check=False)
183
-
184
-
185
- @app.command("health")
186
- def health(
187
- deep: bool = False,
188
- fix: bool = False,
189
- ) -> None:
190
- """Quick health check (lint, types, tests)."""
191
- args = [sys.executable, "-m", "empathy_os.cli", "health"]
192
- if deep:
193
- args.append("--deep")
194
- if fix:
195
- args.append("--fix")
196
- subprocess.run(args, check=False)
197
-
198
-
199
- @app.command("fix-all")
200
- def fix_all() -> None:
201
- """Fix all lint and format issues."""
202
- subprocess.run([sys.executable, "-m", "empathy_os.cli", "fix-all"], check=False)
203
-
204
-
205
- @app.command("learn")
206
- def learn(analyze: int = 20) -> None:
207
- """Learn patterns from commit history."""
208
- subprocess.run(
209
- [sys.executable, "-m", "empathy_os.cli", "learn", "--analyze", str(analyze)],
210
- check=False,
211
- )
212
32
 
33
+ def main() -> int:
34
+ """Main CLI entry point.
35
+
36
+ This is the refactored CLI entry point that uses modular command
37
+ and parser organization instead of a monolithic 3,957-line file.
213
38
 
214
- @app.command("run")
215
- def run_repl() -> None:
216
- """Start interactive REPL mode."""
217
- subprocess.run([sys.executable, "-m", "empathy_os.cli", "run"], check=False)
39
+ Returns:
40
+ Exit code (0 for success, non-zero for error)
41
+ """
42
+ # Windows async compatibility
43
+ setup_asyncio_policy()
218
44
 
45
+ # Create main parser
46
+ parser = argparse.ArgumentParser(
47
+ prog="empathy", description="Empathy Framework - Context-aware development automation"
48
+ )
219
49
 
220
- # =============================================================================
221
- # REMAINING COMMAND GROUPS
222
- # Import directly from cli_unified.py for now - will be extracted later
223
- # =============================================================================
50
+ # Add global flags
51
+ parser.add_argument("--version", action="version", version=f"empathy {get_version()}")
224
52
 
225
- # Import and register remaining command groups from cli_unified.py
226
- # These are imported here to keep the transition incremental
227
- try:
228
- from empathy_os.cli_unified import (
229
- orchestrate_app,
230
- progressive_app,
231
- service_app,
232
- telemetry_app,
233
- tier_app,
234
- workflow_app,
53
+ # Create subparsers
54
+ subparsers = parser.add_subparsers(
55
+ dest="command", title="commands", description="Available commands"
235
56
  )
236
57
 
237
- app.add_typer(workflow_app, name="workflow")
238
- app.add_typer(orchestrate_app, name="orchestrate")
239
- app.add_typer(telemetry_app, name="telemetry")
240
- app.add_typer(service_app, name="service")
241
- app.add_typer(progressive_app, name="progressive")
242
- app.add_typer(tier_app, name="tier")
243
- except ImportError:
244
- # cli_unified.py may not have these exports yet
245
- pass
58
+ # Register all command parsers (modular!)
59
+ from .parsers import register_all_parsers
60
+
61
+ register_all_parsers(subparsers)
62
+
63
+ # TODO: Import and register remaining commands from cli.py
64
+ # This is a partial refactoring - additional commands still in cli.py
65
+ # For now, if command not found in new structure, fall back to old cli.py
66
+ #
67
+ # NOTE: Temporarily disabled to avoid conflicts with extracted commands.
68
+ # Commands that have been extracted:
69
+ # - help, tier, info, patterns, status (Phase 1)
70
+ # - workflow, inspect (run, inspect, export, import) (Phase 2)
71
+ # Once all commands are extracted, the old cli.py will be removed entirely.
72
+ #
73
+ # try:
74
+ # from empathy_os import cli as old_cli
75
+ # _register_legacy_commands(subparsers, old_cli)
76
+ # except ImportError:
77
+ # pass # Old cli.py not available or already moved
78
+
79
+ # Parse arguments
80
+ args = parser.parse_args()
81
+
82
+ # Execute command
83
+ if hasattr(args, "func"):
84
+ try:
85
+ result = args.func(args)
86
+
87
+ # Show discovery tips (except for dashboard/run)
88
+ if args.command and args.command not in ("dashboard", "run"):
89
+ try:
90
+ show_tip_if_available(args.command)
91
+ except Exception: # noqa: BLE001
92
+ logger.debug("Discovery tip not available")
93
+
94
+ return result if result is not None else 0
95
+
96
+ except KeyboardInterrupt:
97
+ print("\n\n⚠️ Interrupted by user")
98
+ return 130
99
+
100
+ except Exception as e: # noqa: BLE001
101
+ logger.exception(f"Unexpected error in command {args.command}")
102
+ print(f"\n❌ Error: {e}")
103
+ return 1
104
+
105
+ # No command specified
106
+ parser.print_help()
107
+ return 0
108
+
109
+
110
+ def _register_legacy_commands(subparsers, old_cli):
111
+ """Temporarily register commands not yet extracted from old cli.py.
112
+
113
+ This function provides backward compatibility during the refactoring process.
114
+ As commands are extracted into the new structure, they should be removed
115
+ from this registration.
116
+
117
+ Args:
118
+ subparsers: ArgumentParser subparsers object
119
+ old_cli: Reference to old cli module
120
+
121
+ Note:
122
+ This is a TEMPORARY function that will be removed once all commands
123
+ are extracted from the monolithic cli.py file.
124
+ """
125
+ # Import command functions that haven't been extracted yet
126
+ try:
127
+ # Patterns commands
128
+ from empathy_os.cli import cmd_patterns_export, cmd_patterns_list, cmd_patterns_resolve
129
+
130
+ patterns_parser = subparsers.add_parser("patterns", help="Pattern management")
131
+ patterns_sub = patterns_parser.add_subparsers(dest="patterns_command")
246
132
 
247
- # Register meta-workflow if available
248
- try:
249
- from empathy_os.meta_workflows.cli_meta_workflows import meta_workflow_app
133
+ p_list = patterns_sub.add_parser("list", help="List patterns")
134
+ p_list.set_defaults(func=cmd_patterns_list)
250
135
 
251
- app.add_typer(meta_workflow_app, name="meta-workflow")
252
- except ImportError:
253
- pass
136
+ p_export = patterns_sub.add_parser("export", help="Export patterns")
137
+ p_export.add_argument("output", help="Output file")
138
+ p_export.set_defaults(func=cmd_patterns_export)
254
139
 
140
+ p_resolve = patterns_sub.add_parser("resolve", help="Resolve pattern")
141
+ p_resolve.add_argument("pattern_id", help="Pattern ID")
142
+ p_resolve.set_defaults(func=cmd_patterns_resolve)
143
+ except (ImportError, AttributeError):
144
+ pass # Commands not available
255
145
 
256
- def main() -> None:
257
- """Entry point for the unified CLI."""
258
- app()
146
+ # Add other legacy commands as needed...
147
+ # This list will shrink as commands are extracted
259
148
 
260
149
 
150
+ # Preserve backward compatibility
261
151
  if __name__ == "__main__":
262
- main()
152
+ sys.exit(main())
@@ -1,40 +1,12 @@
1
- """Entry point for python -m empathy_os.cli.
1
+ """CLI entry point for python -m empathy_os.cli execution.
2
2
 
3
- Supports both the new Typer-based CLI and legacy CLI.
4
- New commands (profile, etc.) are in the Typer CLI.
5
- Legacy commands fall back to cli.py for compatibility.
3
+ Copyright 2025 Smart-AI-Memory
4
+ Licensed under Fair Source License 0.9
6
5
  """
7
6
 
8
7
  import sys
9
- from pathlib import Path
10
-
11
- # Commands that are only in the new Typer CLI
12
- NEW_CLI_COMMANDS = {"profile", "memory", "provider"}
13
-
14
-
15
- def main() -> None:
16
- """Route to appropriate CLI based on command."""
17
- # Check if we should use the new Typer CLI
18
- if len(sys.argv) > 1 and sys.argv[1] in NEW_CLI_COMMANDS:
19
- # Use the new Typer-based CLI
20
- from empathy_os.cli import app
21
-
22
- app()
23
- return
24
-
25
- # Fall back to legacy CLI for backward compatibility
26
- parent = Path(__file__).parent.parent
27
- if str(parent) not in sys.path:
28
- sys.path.insert(0, str(parent))
29
-
30
- import importlib.util
31
-
32
- cli_py_path = parent / "cli.py"
33
- spec = importlib.util.spec_from_file_location("cli_legacy", cli_py_path)
34
- cli_module = importlib.util.module_from_spec(spec)
35
- spec.loader.exec_module(cli_module)
36
- cli_module.main()
37
8
 
9
+ from . import main
38
10
 
39
11
  if __name__ == "__main__":
40
- main()
12
+ sys.exit(main())
@@ -1,8 +1 @@
1
- """CLI command modules for Empathy Framework.
2
-
3
- Each module contains a Typer app that can be registered with the main app.
4
- """
5
-
6
- from empathy_os.cli.commands import inspection, memory, provider, utilities
7
-
8
- __all__ = ["memory", "provider", "inspection", "utilities"]
1
+ """CLI command implementations."""