claude-mpm 5.5.0__py3-none-any.whl → 5.6.2__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.
- claude_mpm/VERSION +1 -1
- claude_mpm/cli/commands/commander.py +46 -0
- claude_mpm/cli/commands/run.py +35 -3
- claude_mpm/cli/executor.py +9 -0
- claude_mpm/cli/parsers/base_parser.py +17 -0
- claude_mpm/cli/parsers/commander_parser.py +83 -0
- claude_mpm/cli/parsers/run_parser.py +10 -0
- claude_mpm/cli/utils.py +7 -3
- claude_mpm/commander/__init__.py +72 -0
- claude_mpm/commander/adapters/__init__.py +31 -0
- claude_mpm/commander/adapters/base.py +191 -0
- claude_mpm/commander/adapters/claude_code.py +361 -0
- claude_mpm/commander/adapters/communication.py +366 -0
- claude_mpm/commander/api/__init__.py +16 -0
- claude_mpm/commander/api/app.py +105 -0
- claude_mpm/commander/api/errors.py +112 -0
- claude_mpm/commander/api/routes/__init__.py +8 -0
- claude_mpm/commander/api/routes/events.py +184 -0
- claude_mpm/commander/api/routes/inbox.py +171 -0
- claude_mpm/commander/api/routes/messages.py +148 -0
- claude_mpm/commander/api/routes/projects.py +271 -0
- claude_mpm/commander/api/routes/sessions.py +215 -0
- claude_mpm/commander/api/routes/work.py +260 -0
- claude_mpm/commander/api/schemas.py +182 -0
- claude_mpm/commander/chat/__init__.py +7 -0
- claude_mpm/commander/chat/cli.py +107 -0
- claude_mpm/commander/chat/commands.py +96 -0
- claude_mpm/commander/chat/repl.py +310 -0
- claude_mpm/commander/config.py +49 -0
- claude_mpm/commander/config_loader.py +115 -0
- claude_mpm/commander/daemon.py +398 -0
- claude_mpm/commander/events/__init__.py +26 -0
- claude_mpm/commander/events/manager.py +332 -0
- claude_mpm/commander/frameworks/__init__.py +12 -0
- claude_mpm/commander/frameworks/base.py +143 -0
- claude_mpm/commander/frameworks/claude_code.py +58 -0
- claude_mpm/commander/frameworks/mpm.py +62 -0
- claude_mpm/commander/inbox/__init__.py +16 -0
- claude_mpm/commander/inbox/dedup.py +128 -0
- claude_mpm/commander/inbox/inbox.py +224 -0
- claude_mpm/commander/inbox/models.py +70 -0
- claude_mpm/commander/instance_manager.py +337 -0
- claude_mpm/commander/llm/__init__.py +6 -0
- claude_mpm/commander/llm/openrouter_client.py +167 -0
- claude_mpm/commander/llm/summarizer.py +70 -0
- claude_mpm/commander/models/__init__.py +18 -0
- claude_mpm/commander/models/events.py +121 -0
- claude_mpm/commander/models/project.py +162 -0
- claude_mpm/commander/models/work.py +214 -0
- claude_mpm/commander/parsing/__init__.py +20 -0
- claude_mpm/commander/parsing/extractor.py +132 -0
- claude_mpm/commander/parsing/output_parser.py +270 -0
- claude_mpm/commander/parsing/patterns.py +100 -0
- claude_mpm/commander/persistence/__init__.py +11 -0
- claude_mpm/commander/persistence/event_store.py +274 -0
- claude_mpm/commander/persistence/state_store.py +309 -0
- claude_mpm/commander/persistence/work_store.py +164 -0
- claude_mpm/commander/polling/__init__.py +13 -0
- claude_mpm/commander/polling/event_detector.py +104 -0
- claude_mpm/commander/polling/output_buffer.py +49 -0
- claude_mpm/commander/polling/output_poller.py +153 -0
- claude_mpm/commander/project_session.py +268 -0
- claude_mpm/commander/proxy/__init__.py +12 -0
- claude_mpm/commander/proxy/formatter.py +89 -0
- claude_mpm/commander/proxy/output_handler.py +191 -0
- claude_mpm/commander/proxy/relay.py +155 -0
- claude_mpm/commander/registry.py +404 -0
- claude_mpm/commander/runtime/__init__.py +10 -0
- claude_mpm/commander/runtime/executor.py +191 -0
- claude_mpm/commander/runtime/monitor.py +316 -0
- claude_mpm/commander/session/__init__.py +6 -0
- claude_mpm/commander/session/context.py +81 -0
- claude_mpm/commander/session/manager.py +59 -0
- claude_mpm/commander/tmux_orchestrator.py +361 -0
- claude_mpm/commander/web/__init__.py +1 -0
- claude_mpm/commander/work/__init__.py +30 -0
- claude_mpm/commander/work/executor.py +189 -0
- claude_mpm/commander/work/queue.py +405 -0
- claude_mpm/commander/workflow/__init__.py +27 -0
- claude_mpm/commander/workflow/event_handler.py +219 -0
- claude_mpm/commander/workflow/notifier.py +146 -0
- claude_mpm/config/agent_presets.py +2 -1
- claude_mpm/core/logger.py +1 -1
- claude_mpm/core/logging_utils.py +35 -13
- claude_mpm/core/unified_config.py +3 -2
- claude_mpm/core/unified_paths.py +68 -80
- claude_mpm/hooks/claude_hooks/hook_handler.py +67 -80
- claude_mpm/hooks/claude_hooks/installer.py +6 -3
- claude_mpm/hooks/claude_hooks/memory_integration.py +22 -11
- claude_mpm/services/skills/git_skill_source_manager.py +51 -2
- {claude_mpm-5.5.0.dist-info → claude_mpm-5.6.2.dist-info}/METADATA +13 -1
- {claude_mpm-5.5.0.dist-info → claude_mpm-5.6.2.dist-info}/RECORD +97 -37
- claude_mpm/hooks/claude_hooks/__pycache__/__init__.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/auto_pause_handler.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/correlation_manager.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/event_handlers.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/hook_handler.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/installer.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/memory_integration.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/response_tracking.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/tool_analysis.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/services/__pycache__/__init__.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/services/__pycache__/connection_manager.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/services/__pycache__/connection_manager_http.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/services/__pycache__/duplicate_detector.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/services/__pycache__/state_manager.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/services/__pycache__/subagent_processor.cpython-311.pyc +0 -0
- {claude_mpm-5.5.0.dist-info → claude_mpm-5.6.2.dist-info}/WHEEL +0 -0
- {claude_mpm-5.5.0.dist-info → claude_mpm-5.6.2.dist-info}/entry_points.txt +0 -0
- {claude_mpm-5.5.0.dist-info → claude_mpm-5.6.2.dist-info}/licenses/LICENSE +0 -0
- {claude_mpm-5.5.0.dist-info → claude_mpm-5.6.2.dist-info}/licenses/LICENSE-FAQ.md +0 -0
- {claude_mpm-5.5.0.dist-info → claude_mpm-5.6.2.dist-info}/top_level.txt +0 -0
claude_mpm/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
5.
|
|
1
|
+
5.6.2
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""Commander command handler for CLI."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import logging
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger(__name__)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def handle_commander_command(args) -> int:
|
|
10
|
+
"""Handle the commander command.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
args: Parsed command line arguments with:
|
|
14
|
+
- port: Port for internal services (default: 8765)
|
|
15
|
+
- state_dir: Optional state directory path
|
|
16
|
+
- debug: Enable debug logging
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
Exit code (0 for success, 1 for error)
|
|
20
|
+
"""
|
|
21
|
+
try:
|
|
22
|
+
# Import here to avoid circular dependencies
|
|
23
|
+
from claude_mpm.commander.chat.cli import run_commander
|
|
24
|
+
|
|
25
|
+
# Setup debug logging if requested
|
|
26
|
+
if getattr(args, "debug", False):
|
|
27
|
+
logging.basicConfig(
|
|
28
|
+
level=logging.DEBUG,
|
|
29
|
+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
# Get arguments
|
|
33
|
+
port = getattr(args, "port", 8765)
|
|
34
|
+
state_dir = getattr(args, "state_dir", None)
|
|
35
|
+
|
|
36
|
+
# Run commander
|
|
37
|
+
asyncio.run(run_commander(port=port, state_dir=state_dir))
|
|
38
|
+
|
|
39
|
+
return 0
|
|
40
|
+
|
|
41
|
+
except KeyboardInterrupt:
|
|
42
|
+
logger.info("Commander interrupted by user")
|
|
43
|
+
return 0
|
|
44
|
+
except Exception as e:
|
|
45
|
+
logger.error(f"Commander error: {e}", exc_info=True)
|
|
46
|
+
return 1
|
claude_mpm/cli/commands/run.py
CHANGED
|
@@ -13,7 +13,7 @@ DESIGN DECISIONS:
|
|
|
13
13
|
- Support multiple output formats (json, yaml, table, text)
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
|
-
import subprocess
|
|
16
|
+
import subprocess # nosec B404 - required for process management
|
|
17
17
|
import sys
|
|
18
18
|
from datetime import datetime, timezone
|
|
19
19
|
from typing import Optional
|
|
@@ -489,6 +489,18 @@ class RunCommand(BaseCommand):
|
|
|
489
489
|
if hasattr(args, "claude_args") and args.claude_args:
|
|
490
490
|
claude_args.extend(args.claude_args)
|
|
491
491
|
|
|
492
|
+
# Add --resume if flag is set
|
|
493
|
+
if getattr(args, "resume", False) and "--resume" not in claude_args:
|
|
494
|
+
claude_args.insert(0, "--resume")
|
|
495
|
+
|
|
496
|
+
# Add --chrome if flag is set
|
|
497
|
+
if getattr(args, "chrome", False) and "--chrome" not in claude_args:
|
|
498
|
+
claude_args.insert(0, "--chrome")
|
|
499
|
+
|
|
500
|
+
# Add --no-chrome if flag is set
|
|
501
|
+
if getattr(args, "no_chrome", False) and "--no-chrome" not in claude_args:
|
|
502
|
+
claude_args.insert(0, "--no-chrome")
|
|
503
|
+
|
|
492
504
|
# Create runner
|
|
493
505
|
runner = ClaudeRunner(
|
|
494
506
|
enable_tickets=enable_tickets,
|
|
@@ -553,7 +565,7 @@ class RunCommand(BaseCommand):
|
|
|
553
565
|
wrapper_path = get_scripts_dir() / "interactive_wrapper.py"
|
|
554
566
|
if wrapper_path.exists():
|
|
555
567
|
print("Starting interactive session with command interception...")
|
|
556
|
-
subprocess.run([sys.executable, str(wrapper_path)], check=False)
|
|
568
|
+
subprocess.run([sys.executable, str(wrapper_path)], check=False) # nosec B603 - trusted internal paths
|
|
557
569
|
else:
|
|
558
570
|
self.logger.warning(
|
|
559
571
|
"Interactive wrapper not found, falling back to normal mode"
|
|
@@ -907,6 +919,26 @@ def run_session_legacy(args):
|
|
|
907
919
|
else:
|
|
908
920
|
logger.info("[INFO]️ --resume already in claude_args")
|
|
909
921
|
|
|
922
|
+
# Add --chrome to claude_args if the flag is set
|
|
923
|
+
chrome_flag_present = getattr(args, "chrome", False)
|
|
924
|
+
if chrome_flag_present:
|
|
925
|
+
logger.info("📌 --chrome flag detected in args")
|
|
926
|
+
if "--chrome" not in raw_claude_args:
|
|
927
|
+
raw_claude_args = ["--chrome", *raw_claude_args]
|
|
928
|
+
logger.info("✅ Added --chrome to claude_args")
|
|
929
|
+
else:
|
|
930
|
+
logger.info("ℹ️ --chrome already in claude_args")
|
|
931
|
+
|
|
932
|
+
# Add --no-chrome to claude_args if the flag is set
|
|
933
|
+
no_chrome_flag_present = getattr(args, "no_chrome", False)
|
|
934
|
+
if no_chrome_flag_present:
|
|
935
|
+
logger.info("📌 --no-chrome flag detected in args")
|
|
936
|
+
if "--no-chrome" not in raw_claude_args:
|
|
937
|
+
raw_claude_args = ["--no-chrome", *raw_claude_args]
|
|
938
|
+
logger.info("✅ Added --no-chrome to claude_args")
|
|
939
|
+
else:
|
|
940
|
+
logger.info("ℹ️ --no-chrome already in claude_args")
|
|
941
|
+
|
|
910
942
|
# Filter out claude-mpm specific flags before passing to Claude CLI
|
|
911
943
|
logger.debug(f"Pre-filter claude_args: {raw_claude_args}")
|
|
912
944
|
claude_args = filter_claude_mpm_args(raw_claude_args)
|
|
@@ -1044,7 +1076,7 @@ def run_session_legacy(args):
|
|
|
1044
1076
|
wrapper_path = get_scripts_dir() / "interactive_wrapper.py"
|
|
1045
1077
|
if wrapper_path.exists():
|
|
1046
1078
|
print("Starting interactive session with command interception...")
|
|
1047
|
-
subprocess.run([sys.executable, str(wrapper_path)], check=False)
|
|
1079
|
+
subprocess.run([sys.executable, str(wrapper_path)], check=False) # nosec B603 - trusted internal paths
|
|
1048
1080
|
else:
|
|
1049
1081
|
logger.warning("Interactive wrapper not found, falling back to normal mode")
|
|
1050
1082
|
runner.run_interactive(context)
|
claude_mpm/cli/executor.py
CHANGED
|
@@ -127,6 +127,14 @@ def execute_command(command: str, args) -> int:
|
|
|
127
127
|
result = handle_verify(args)
|
|
128
128
|
return result if result is not None else 0
|
|
129
129
|
|
|
130
|
+
# Handle commander command with lazy import
|
|
131
|
+
if command == "commander":
|
|
132
|
+
# Lazy import to avoid loading unless needed
|
|
133
|
+
from .commands.commander import handle_commander_command
|
|
134
|
+
|
|
135
|
+
result = handle_commander_command(args)
|
|
136
|
+
return result if result is not None else 0
|
|
137
|
+
|
|
130
138
|
# Handle skill-source command with lazy import
|
|
131
139
|
if command == "skill-source":
|
|
132
140
|
# Lazy import to avoid loading unless needed
|
|
@@ -352,6 +360,7 @@ def execute_command(command: str, args) -> int:
|
|
|
352
360
|
CLICommands.SKILLS.value: manage_skills,
|
|
353
361
|
"debug": manage_debug, # Add debug command
|
|
354
362
|
"mpm-init": None, # Will be handled separately with lazy import
|
|
363
|
+
"commander": None, # Will be handled separately with lazy import
|
|
355
364
|
}
|
|
356
365
|
|
|
357
366
|
# Execute command if found
|
|
@@ -297,6 +297,16 @@ def add_top_level_run_arguments(parser: argparse.ArgumentParser) -> None:
|
|
|
297
297
|
action="store_true",
|
|
298
298
|
help="Force refresh agents and skills from remote repos, bypassing ETag cache",
|
|
299
299
|
)
|
|
300
|
+
run_group.add_argument(
|
|
301
|
+
"--chrome",
|
|
302
|
+
action="store_true",
|
|
303
|
+
help="Enable Claude in Chrome integration (passed to Claude Code)",
|
|
304
|
+
)
|
|
305
|
+
run_group.add_argument(
|
|
306
|
+
"--no-chrome",
|
|
307
|
+
action="store_true",
|
|
308
|
+
help="Disable Claude in Chrome integration (passed to Claude Code)",
|
|
309
|
+
)
|
|
300
310
|
|
|
301
311
|
# Dependency checking options (for backward compatibility at top level)
|
|
302
312
|
dep_group_top = parser.add_argument_group(
|
|
@@ -492,6 +502,13 @@ def create_parser(
|
|
|
492
502
|
except ImportError:
|
|
493
503
|
pass
|
|
494
504
|
|
|
505
|
+
try:
|
|
506
|
+
from .commander_parser import add_commander_subparser
|
|
507
|
+
|
|
508
|
+
add_commander_subparser(subparsers)
|
|
509
|
+
except ImportError:
|
|
510
|
+
pass
|
|
511
|
+
|
|
495
512
|
# Add uninstall command parser
|
|
496
513
|
try:
|
|
497
514
|
from ..commands.uninstall import add_uninstall_parser
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Commander parser module for claude-mpm CLI.
|
|
3
|
+
|
|
4
|
+
WHY: This module provides the commander subcommand for interactive instance management
|
|
5
|
+
and chat interface.
|
|
6
|
+
|
|
7
|
+
DESIGN DECISION: Uses subparser pattern consistent with other commands (run, agents, etc.)
|
|
8
|
+
to provide a clean interface for Commander mode.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import argparse
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def add_commander_subparser(subparsers: argparse._SubParsersAction) -> None:
|
|
16
|
+
"""
|
|
17
|
+
Add commander subcommand parser.
|
|
18
|
+
|
|
19
|
+
WHY: Provides interactive mode for managing and chatting with multiple Claude instances.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
subparsers: The subparsers object to add the commander parser to
|
|
23
|
+
"""
|
|
24
|
+
commander_parser = subparsers.add_parser(
|
|
25
|
+
"commander",
|
|
26
|
+
help="Interactive Commander mode for managing multiple Claude instances",
|
|
27
|
+
description="""
|
|
28
|
+
Commander Mode - Interactive Instance Management
|
|
29
|
+
|
|
30
|
+
Commander provides an interactive REPL interface for:
|
|
31
|
+
- Starting and stopping Claude Code/MPM instances in tmux
|
|
32
|
+
- Connecting to instances and sending natural language commands
|
|
33
|
+
- Managing multiple concurrent projects
|
|
34
|
+
- Viewing instance status and output
|
|
35
|
+
|
|
36
|
+
Commands:
|
|
37
|
+
list, ls, instances List active instances
|
|
38
|
+
start <path> Start new instance at path
|
|
39
|
+
--framework <cc|mpm> Specify framework (default: cc)
|
|
40
|
+
--name <name> Specify instance name (default: dir name)
|
|
41
|
+
stop <name> Stop an instance
|
|
42
|
+
connect <name> Connect to an instance
|
|
43
|
+
disconnect Disconnect from current instance
|
|
44
|
+
status Show current session status
|
|
45
|
+
help Show help message
|
|
46
|
+
exit, quit, q Exit Commander
|
|
47
|
+
|
|
48
|
+
Natural Language:
|
|
49
|
+
When connected to an instance, any input that is not a built-in
|
|
50
|
+
command will be sent to the connected instance as a message.
|
|
51
|
+
|
|
52
|
+
Examples:
|
|
53
|
+
claude-mpm commander
|
|
54
|
+
> start ~/myproject --framework cc --name myapp
|
|
55
|
+
> connect myapp
|
|
56
|
+
> Fix the authentication bug in login.py
|
|
57
|
+
> disconnect
|
|
58
|
+
> exit
|
|
59
|
+
""",
|
|
60
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
# Optional: Port for internal services
|
|
64
|
+
commander_parser.add_argument(
|
|
65
|
+
"--port",
|
|
66
|
+
type=int,
|
|
67
|
+
default=8765,
|
|
68
|
+
help="Port for internal services (default: 8765)",
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# Optional: State directory
|
|
72
|
+
commander_parser.add_argument(
|
|
73
|
+
"--state-dir",
|
|
74
|
+
type=Path,
|
|
75
|
+
help="Directory for state persistence (optional)",
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
# Debug mode
|
|
79
|
+
commander_parser.add_argument(
|
|
80
|
+
"--debug",
|
|
81
|
+
action="store_true",
|
|
82
|
+
help="Enable debug logging",
|
|
83
|
+
)
|
|
@@ -85,6 +85,16 @@ def add_run_arguments(parser: argparse.ArgumentParser) -> None:
|
|
|
85
85
|
action="store_true",
|
|
86
86
|
help="Pass --resume flag to Claude Code to resume the last conversation",
|
|
87
87
|
)
|
|
88
|
+
run_group.add_argument(
|
|
89
|
+
"--chrome",
|
|
90
|
+
action="store_true",
|
|
91
|
+
help="Enable Claude in Chrome integration (passed to Claude Code)",
|
|
92
|
+
)
|
|
93
|
+
run_group.add_argument(
|
|
94
|
+
"--no-chrome",
|
|
95
|
+
action="store_true",
|
|
96
|
+
help="Disable Claude in Chrome integration (passed to Claude Code)",
|
|
97
|
+
)
|
|
88
98
|
|
|
89
99
|
# Dependency checking options
|
|
90
100
|
dep_group = parser.add_argument_group("dependency options")
|
claude_mpm/cli/utils.py
CHANGED
|
@@ -107,7 +107,7 @@ def get_agent_versions_display() -> Optional[str]:
|
|
|
107
107
|
base_version_tuple
|
|
108
108
|
)
|
|
109
109
|
output_lines.append(f"\n Base Agent Version: {base_version_str}")
|
|
110
|
-
except Exception:
|
|
110
|
+
except Exception: # nosec B110 - intentional: version display is optional
|
|
111
111
|
pass
|
|
112
112
|
|
|
113
113
|
# Check for agents needing migration
|
|
@@ -173,8 +173,12 @@ def setup_logging(args) -> object:
|
|
|
173
173
|
if not hasattr(args, "logging") or args.logging is None:
|
|
174
174
|
args.logging = LogLevel.OFF.value
|
|
175
175
|
|
|
176
|
+
# Handle deprecated --verbose flag
|
|
177
|
+
if hasattr(args, "verbose") and args.verbose and args.logging == LogLevel.OFF.value:
|
|
178
|
+
args.logging = LogLevel.INFO.value
|
|
179
|
+
|
|
176
180
|
# Handle deprecated --debug flag
|
|
177
|
-
if hasattr(args, "debug") and args.debug
|
|
181
|
+
if hasattr(args, "debug") and args.debug:
|
|
178
182
|
args.logging = LogLevel.DEBUG.value
|
|
179
183
|
|
|
180
184
|
# Only setup logging if not OFF
|
|
@@ -204,7 +208,7 @@ def ensure_directories() -> None:
|
|
|
204
208
|
from ..init import ensure_directories as init_ensure_directories
|
|
205
209
|
|
|
206
210
|
init_ensure_directories()
|
|
207
|
-
except Exception:
|
|
211
|
+
except Exception: # nosec B110
|
|
208
212
|
# Continue even if initialization fails
|
|
209
213
|
# The individual commands will handle missing directories as needed
|
|
210
214
|
pass
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""MPM Commander - Multi-Project Orchestration.
|
|
2
|
+
|
|
3
|
+
This module provides the core infrastructure for managing multiple projects
|
|
4
|
+
with isolated state, work queues, and tool sessions.
|
|
5
|
+
|
|
6
|
+
Key Components:
|
|
7
|
+
- ProjectRegistry: Thread-safe project management
|
|
8
|
+
- Project models: Data structures for state and sessions
|
|
9
|
+
- TmuxOrchestrator: Tmux session and pane management
|
|
10
|
+
- Config loading: .claude-mpm/ directory configuration
|
|
11
|
+
- CommanderDaemon: Main daemon process for orchestration
|
|
12
|
+
- ProjectSession: Per-project lifecycle management
|
|
13
|
+
- InstanceManager: Framework selection and instance lifecycle
|
|
14
|
+
- Frameworks: Claude Code, MPM framework abstractions
|
|
15
|
+
|
|
16
|
+
Example:
|
|
17
|
+
>>> from claude_mpm.commander import ProjectRegistry
|
|
18
|
+
>>> registry = ProjectRegistry()
|
|
19
|
+
>>> project = registry.register("/path/to/project")
|
|
20
|
+
>>> registry.update_state(project.id, ProjectState.WORKING)
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
from claude_mpm.commander.config import DaemonConfig
|
|
24
|
+
from claude_mpm.commander.config_loader import load_project_config
|
|
25
|
+
from claude_mpm.commander.daemon import CommanderDaemon
|
|
26
|
+
from claude_mpm.commander.frameworks import (
|
|
27
|
+
BaseFramework,
|
|
28
|
+
ClaudeCodeFramework,
|
|
29
|
+
InstanceInfo,
|
|
30
|
+
MPMFramework,
|
|
31
|
+
)
|
|
32
|
+
from claude_mpm.commander.instance_manager import (
|
|
33
|
+
FrameworkNotFoundError,
|
|
34
|
+
InstanceAlreadyExistsError,
|
|
35
|
+
InstanceManager,
|
|
36
|
+
InstanceNotFoundError,
|
|
37
|
+
)
|
|
38
|
+
from claude_mpm.commander.models import (
|
|
39
|
+
Project,
|
|
40
|
+
ProjectState,
|
|
41
|
+
ThreadMessage,
|
|
42
|
+
ToolSession,
|
|
43
|
+
)
|
|
44
|
+
from claude_mpm.commander.project_session import ProjectSession, SessionState
|
|
45
|
+
from claude_mpm.commander.registry import ProjectRegistry
|
|
46
|
+
from claude_mpm.commander.tmux_orchestrator import (
|
|
47
|
+
TmuxNotFoundError,
|
|
48
|
+
TmuxOrchestrator,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
__all__ = [
|
|
52
|
+
"BaseFramework",
|
|
53
|
+
"ClaudeCodeFramework",
|
|
54
|
+
"CommanderDaemon",
|
|
55
|
+
"DaemonConfig",
|
|
56
|
+
"FrameworkNotFoundError",
|
|
57
|
+
"InstanceAlreadyExistsError",
|
|
58
|
+
"InstanceInfo",
|
|
59
|
+
"InstanceManager",
|
|
60
|
+
"InstanceNotFoundError",
|
|
61
|
+
"MPMFramework",
|
|
62
|
+
"Project",
|
|
63
|
+
"ProjectRegistry",
|
|
64
|
+
"ProjectSession",
|
|
65
|
+
"ProjectState",
|
|
66
|
+
"SessionState",
|
|
67
|
+
"ThreadMessage",
|
|
68
|
+
"TmuxNotFoundError",
|
|
69
|
+
"TmuxOrchestrator",
|
|
70
|
+
"ToolSession",
|
|
71
|
+
"load_project_config",
|
|
72
|
+
]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""Runtime adapters for MPM Commander.
|
|
2
|
+
|
|
3
|
+
This package provides adapters for different AI coding tools, allowing
|
|
4
|
+
the TmuxOrchestrator to interface with various runtimes in a uniform way.
|
|
5
|
+
|
|
6
|
+
Two types of adapters:
|
|
7
|
+
- RuntimeAdapter: Synchronous parsing and state detection
|
|
8
|
+
- CommunicationAdapter: Async I/O and state management
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from .base import Capability, ParsedResponse, RuntimeAdapter
|
|
12
|
+
from .claude_code import ClaudeCodeAdapter
|
|
13
|
+
from .communication import (
|
|
14
|
+
AdapterResponse,
|
|
15
|
+
AdapterState,
|
|
16
|
+
BaseCommunicationAdapter,
|
|
17
|
+
ClaudeCodeCommunicationAdapter,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
# Communication adapters (async I/O)
|
|
22
|
+
"AdapterResponse",
|
|
23
|
+
"AdapterState",
|
|
24
|
+
"BaseCommunicationAdapter",
|
|
25
|
+
# Runtime adapters (parsing)
|
|
26
|
+
"Capability",
|
|
27
|
+
"ClaudeCodeAdapter",
|
|
28
|
+
"ClaudeCodeCommunicationAdapter",
|
|
29
|
+
"ParsedResponse",
|
|
30
|
+
"RuntimeAdapter",
|
|
31
|
+
]
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"""Base runtime adapter interface for MPM Commander.
|
|
2
|
+
|
|
3
|
+
This module defines the abstract interface for runtime adapters that bridge
|
|
4
|
+
between the TmuxOrchestrator and various AI coding tools (Claude Code, Cursor, etc.).
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from abc import ABC, abstractmethod
|
|
8
|
+
from dataclasses import dataclass
|
|
9
|
+
from enum import Enum
|
|
10
|
+
from typing import List, Optional, Set
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Capability(Enum):
|
|
14
|
+
"""Capabilities that a runtime adapter can provide."""
|
|
15
|
+
|
|
16
|
+
TOOL_USE = "tool_use"
|
|
17
|
+
FILE_EDIT = "file_edit"
|
|
18
|
+
FILE_CREATE = "file_create"
|
|
19
|
+
GIT_OPERATIONS = "git_operations"
|
|
20
|
+
SHELL_COMMANDS = "shell_commands"
|
|
21
|
+
WEB_SEARCH = "web_search"
|
|
22
|
+
COMPLEX_REASONING = "complex_reasoning"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass
|
|
26
|
+
class ParsedResponse:
|
|
27
|
+
"""Parsed output from a runtime tool.
|
|
28
|
+
|
|
29
|
+
Attributes:
|
|
30
|
+
content: The extracted text content, with ANSI codes removed
|
|
31
|
+
is_complete: True if tool is waiting for input (idle state)
|
|
32
|
+
is_error: True if an error was detected in the output
|
|
33
|
+
error_message: The error message if is_error is True
|
|
34
|
+
is_question: True if tool is asking a question
|
|
35
|
+
question_text: The question text if is_question is True
|
|
36
|
+
options: List of options if presenting a choice
|
|
37
|
+
|
|
38
|
+
Example:
|
|
39
|
+
>>> response = ParsedResponse(
|
|
40
|
+
... content="File created successfully",
|
|
41
|
+
... is_complete=True,
|
|
42
|
+
... is_error=False,
|
|
43
|
+
... error_message=None,
|
|
44
|
+
... is_question=False,
|
|
45
|
+
... question_text=None,
|
|
46
|
+
... options=None
|
|
47
|
+
... )
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
content: str
|
|
51
|
+
is_complete: bool
|
|
52
|
+
is_error: bool
|
|
53
|
+
error_message: Optional[str] = None
|
|
54
|
+
is_question: bool = False
|
|
55
|
+
question_text: Optional[str] = None
|
|
56
|
+
options: Optional[List[str]] = None
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class RuntimeAdapter(ABC):
|
|
60
|
+
"""Abstract base class for runtime adapters.
|
|
61
|
+
|
|
62
|
+
A runtime adapter provides the interface between the TmuxOrchestrator
|
|
63
|
+
and a specific AI coding tool. It handles:
|
|
64
|
+
- Launching the tool with appropriate settings
|
|
65
|
+
- Formatting input messages
|
|
66
|
+
- Detecting tool states (idle, error, questioning)
|
|
67
|
+
- Parsing tool output into structured responses
|
|
68
|
+
|
|
69
|
+
Example:
|
|
70
|
+
>>> class MyAdapter(RuntimeAdapter):
|
|
71
|
+
... @property
|
|
72
|
+
... def name(self) -> str:
|
|
73
|
+
... return "my-tool"
|
|
74
|
+
...
|
|
75
|
+
... def build_launch_command(self, project_path: str) -> str:
|
|
76
|
+
... return f"cd {project_path} && my-tool --interactive"
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
@abstractmethod
|
|
80
|
+
def build_launch_command(
|
|
81
|
+
self, project_path: str, agent_prompt: Optional[str] = None
|
|
82
|
+
) -> str:
|
|
83
|
+
"""Generate shell command to start the tool.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
project_path: Absolute path to the project directory
|
|
87
|
+
agent_prompt: Optional system prompt to configure the agent
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
Shell command string ready to execute
|
|
91
|
+
|
|
92
|
+
Example:
|
|
93
|
+
>>> adapter.build_launch_command("/home/user/project", "You are a Python expert")
|
|
94
|
+
'cd /home/user/project && claude --system-prompt "You are a Python expert"'
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
@abstractmethod
|
|
98
|
+
def format_input(self, message: str) -> str:
|
|
99
|
+
"""Prepare message for tool's input format.
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
message: The user message to send
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
Formatted message ready to send to the tool
|
|
106
|
+
|
|
107
|
+
Example:
|
|
108
|
+
>>> adapter.format_input("Fix the bug in main.py")
|
|
109
|
+
'Fix the bug in main.py'
|
|
110
|
+
"""
|
|
111
|
+
|
|
112
|
+
@abstractmethod
|
|
113
|
+
def detect_idle(self, output: str) -> bool:
|
|
114
|
+
"""Recognize when tool is waiting for input.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
output: Raw output from the tool (may contain ANSI codes)
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
True if the tool is in an idle state awaiting input
|
|
121
|
+
|
|
122
|
+
Example:
|
|
123
|
+
>>> adapter.detect_idle("Done editing file.\\n> ")
|
|
124
|
+
True
|
|
125
|
+
>>> adapter.detect_idle("Processing request...")
|
|
126
|
+
False
|
|
127
|
+
"""
|
|
128
|
+
|
|
129
|
+
@abstractmethod
|
|
130
|
+
def detect_error(self, output: str) -> Optional[str]:
|
|
131
|
+
"""Recognize error states, return error message if found.
|
|
132
|
+
|
|
133
|
+
Args:
|
|
134
|
+
output: Raw output from the tool
|
|
135
|
+
|
|
136
|
+
Returns:
|
|
137
|
+
Error message string if error detected, None otherwise
|
|
138
|
+
|
|
139
|
+
Example:
|
|
140
|
+
>>> adapter.detect_error("Error: File not found: config.py")
|
|
141
|
+
'Error: File not found: config.py'
|
|
142
|
+
>>> adapter.detect_error("File edited successfully")
|
|
143
|
+
None
|
|
144
|
+
"""
|
|
145
|
+
|
|
146
|
+
@abstractmethod
|
|
147
|
+
def parse_response(self, output: str) -> ParsedResponse:
|
|
148
|
+
"""Extract meaningful content from output.
|
|
149
|
+
|
|
150
|
+
This method combines all detection logic (idle, error, questions)
|
|
151
|
+
into a single structured response.
|
|
152
|
+
|
|
153
|
+
Args:
|
|
154
|
+
output: Raw output from the tool
|
|
155
|
+
|
|
156
|
+
Returns:
|
|
157
|
+
ParsedResponse with all detected states and content
|
|
158
|
+
|
|
159
|
+
Example:
|
|
160
|
+
>>> response = adapter.parse_response("Error: Invalid input\\n> ")
|
|
161
|
+
>>> response.is_error
|
|
162
|
+
True
|
|
163
|
+
>>> response.is_complete
|
|
164
|
+
True
|
|
165
|
+
"""
|
|
166
|
+
|
|
167
|
+
@property
|
|
168
|
+
@abstractmethod
|
|
169
|
+
def capabilities(self) -> Set[Capability]:
|
|
170
|
+
"""What this tool can do.
|
|
171
|
+
|
|
172
|
+
Returns:
|
|
173
|
+
Set of Capability enums indicating supported features
|
|
174
|
+
|
|
175
|
+
Example:
|
|
176
|
+
>>> adapter.capabilities
|
|
177
|
+
{Capability.FILE_EDIT, Capability.TOOL_USE}
|
|
178
|
+
"""
|
|
179
|
+
|
|
180
|
+
@property
|
|
181
|
+
@abstractmethod
|
|
182
|
+
def name(self) -> str:
|
|
183
|
+
"""Runtime identifier.
|
|
184
|
+
|
|
185
|
+
Returns:
|
|
186
|
+
Unique name for this runtime adapter
|
|
187
|
+
|
|
188
|
+
Example:
|
|
189
|
+
>>> adapter.name
|
|
190
|
+
'claude-code'
|
|
191
|
+
"""
|