claude-mpm 5.6.3__py3-none-any.whl → 5.6.16__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/agents/PM_INSTRUCTIONS.md +8 -3
- claude_mpm/cli/commands/commander.py +173 -3
- claude_mpm/cli/commands/skill_source.py +51 -2
- claude_mpm/cli/commands/skills.py +5 -3
- claude_mpm/cli/parsers/commander_parser.py +41 -8
- claude_mpm/cli/parsers/skill_source_parser.py +4 -0
- claude_mpm/cli/parsers/skills_parser.py +5 -0
- claude_mpm/cli/startup.py +10 -1
- claude_mpm/cli/startup_display.py +2 -1
- claude_mpm/commander/__init__.py +6 -0
- claude_mpm/commander/adapters/__init__.py +32 -3
- claude_mpm/commander/adapters/auggie.py +260 -0
- claude_mpm/commander/adapters/base.py +98 -1
- claude_mpm/commander/adapters/claude_code.py +32 -1
- claude_mpm/commander/adapters/codex.py +237 -0
- claude_mpm/commander/adapters/example_usage.py +310 -0
- claude_mpm/commander/adapters/mpm.py +389 -0
- claude_mpm/commander/adapters/registry.py +204 -0
- claude_mpm/commander/api/app.py +32 -16
- claude_mpm/commander/api/errors.py +21 -0
- claude_mpm/commander/api/routes/messages.py +11 -11
- claude_mpm/commander/api/routes/projects.py +20 -20
- claude_mpm/commander/api/routes/sessions.py +37 -26
- claude_mpm/commander/api/routes/work.py +86 -50
- claude_mpm/commander/api/schemas.py +4 -0
- claude_mpm/commander/chat/cli.py +4 -0
- claude_mpm/commander/core/__init__.py +10 -0
- claude_mpm/commander/core/block_manager.py +325 -0
- claude_mpm/commander/core/response_manager.py +323 -0
- claude_mpm/commander/daemon.py +206 -10
- claude_mpm/commander/env_loader.py +59 -0
- claude_mpm/commander/memory/__init__.py +45 -0
- claude_mpm/commander/memory/compression.py +347 -0
- claude_mpm/commander/memory/embeddings.py +230 -0
- claude_mpm/commander/memory/entities.py +310 -0
- claude_mpm/commander/memory/example_usage.py +290 -0
- claude_mpm/commander/memory/integration.py +325 -0
- claude_mpm/commander/memory/search.py +381 -0
- claude_mpm/commander/memory/store.py +657 -0
- claude_mpm/commander/registry.py +10 -4
- claude_mpm/commander/runtime/monitor.py +32 -2
- claude_mpm/commander/work/executor.py +38 -20
- claude_mpm/commander/workflow/event_handler.py +25 -3
- claude_mpm/config/skill_sources.py +16 -0
- claude_mpm/core/claude_runner.py +143 -0
- claude_mpm/core/config.py +27 -19
- claude_mpm/core/output_style_manager.py +34 -7
- claude_mpm/hooks/claude_hooks/__pycache__/__init__.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/__init__.cpython-312.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/__init__.cpython-314.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/auto_pause_handler.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/auto_pause_handler.cpython-312.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/auto_pause_handler.cpython-314.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__/event_handlers.cpython-312.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/event_handlers.cpython-314.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/hook_handler.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/hook_handler.cpython-312.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/hook_handler.cpython-314.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/installer.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/installer.cpython-314.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/memory_integration.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/memory_integration.cpython-312.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/memory_integration.cpython-314.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/response_tracking.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/response_tracking.cpython-312.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/response_tracking.cpython-314.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/tool_analysis.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/tool_analysis.cpython-312.pyc +0 -0
- claude_mpm/hooks/claude_hooks/__pycache__/tool_analysis.cpython-314.pyc +0 -0
- claude_mpm/hooks/claude_hooks/auto_pause_handler.py +29 -30
- claude_mpm/hooks/claude_hooks/event_handlers.py +80 -105
- claude_mpm/hooks/claude_hooks/hook_handler.py +0 -0
- claude_mpm/hooks/claude_hooks/installer.py +41 -0
- claude_mpm/hooks/claude_hooks/memory_integration.py +30 -21
- claude_mpm/hooks/claude_hooks/response_tracking.py +39 -58
- claude_mpm/hooks/claude_hooks/services/__pycache__/__init__.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/services/__pycache__/__init__.cpython-312.pyc +0 -0
- claude_mpm/hooks/claude_hooks/services/__pycache__/__init__.cpython-314.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__/connection_manager_http.cpython-312.pyc +0 -0
- claude_mpm/hooks/claude_hooks/services/__pycache__/connection_manager_http.cpython-314.pyc +0 -0
- claude_mpm/hooks/claude_hooks/services/__pycache__/duplicate_detector.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/services/__pycache__/duplicate_detector.cpython-312.pyc +0 -0
- claude_mpm/hooks/claude_hooks/services/__pycache__/duplicate_detector.cpython-314.pyc +0 -0
- claude_mpm/hooks/claude_hooks/services/__pycache__/state_manager.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/services/__pycache__/state_manager.cpython-312.pyc +0 -0
- claude_mpm/hooks/claude_hooks/services/__pycache__/state_manager.cpython-314.pyc +0 -0
- claude_mpm/hooks/claude_hooks/services/__pycache__/subagent_processor.cpython-311.pyc +0 -0
- claude_mpm/hooks/claude_hooks/services/__pycache__/subagent_processor.cpython-312.pyc +0 -0
- claude_mpm/hooks/claude_hooks/services/__pycache__/subagent_processor.cpython-314.pyc +0 -0
- claude_mpm/hooks/claude_hooks/services/connection_manager.py +23 -28
- claude_mpm/hooks/claude_hooks/services/connection_manager_http.py +22 -26
- claude_mpm/hooks/claude_hooks/services/state_manager.py +23 -36
- claude_mpm/hooks/claude_hooks/services/subagent_processor.py +47 -73
- claude_mpm/hooks/session_resume_hook.py +22 -18
- claude_mpm/hooks/templates/pre_tool_use_template.py +10 -2
- claude_mpm/scripts/claude-hook-handler.sh +5 -5
- claude_mpm/scripts/start_activity_logging.py +0 -0
- claude_mpm/services/agents/agent_selection_service.py +2 -2
- claude_mpm/services/agents/single_tier_deployment_service.py +4 -4
- claude_mpm/services/skills/git_skill_source_manager.py +79 -8
- claude_mpm/services/skills/selective_skill_deployer.py +28 -0
- claude_mpm/services/skills/skill_discovery_service.py +17 -1
- claude_mpm/services/skills_deployer.py +31 -5
- claude_mpm/skills/__init__.py +2 -1
- claude_mpm/skills/bundled/pm/mpm-session-pause/SKILL.md +170 -0
- claude_mpm/skills/registry.py +295 -90
- {claude_mpm-5.6.3.dist-info → claude_mpm-5.6.16.dist-info}/METADATA +5 -3
- {claude_mpm-5.6.3.dist-info → claude_mpm-5.6.16.dist-info}/RECORD +116 -58
- {claude_mpm-5.6.3.dist-info → claude_mpm-5.6.16.dist-info}/WHEEL +0 -0
- {claude_mpm-5.6.3.dist-info → claude_mpm-5.6.16.dist-info}/entry_points.txt +0 -0
- {claude_mpm-5.6.3.dist-info → claude_mpm-5.6.16.dist-info}/licenses/LICENSE +0 -0
- {claude_mpm-5.6.3.dist-info → claude_mpm-5.6.16.dist-info}/licenses/LICENSE-FAQ.md +0 -0
- {claude_mpm-5.6.3.dist-info → claude_mpm-5.6.16.dist-info}/top_level.txt +0 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -22,7 +22,7 @@ USAGE:
|
|
|
22
22
|
threshold_crossed = auto_pause.on_usage_update(metadata["usage"])
|
|
23
23
|
if threshold_crossed:
|
|
24
24
|
warning = auto_pause.emit_threshold_warning(threshold_crossed)
|
|
25
|
-
|
|
25
|
+
_log(f"\n⚠️ {warning}")
|
|
26
26
|
|
|
27
27
|
# Record actions during pause mode
|
|
28
28
|
if auto_pause.is_pause_active():
|
|
@@ -34,7 +34,6 @@ USAGE:
|
|
|
34
34
|
"""
|
|
35
35
|
|
|
36
36
|
import os
|
|
37
|
-
import sys
|
|
38
37
|
from datetime import datetime, timezone
|
|
39
38
|
from pathlib import Path
|
|
40
39
|
from typing import Any, Dict, Optional
|
|
@@ -45,6 +44,15 @@ from claude_mpm.services.infrastructure.context_usage_tracker import (
|
|
|
45
44
|
ContextUsageTracker,
|
|
46
45
|
)
|
|
47
46
|
|
|
47
|
+
# Try to import _log from hook_handler, fall back to no-op
|
|
48
|
+
try:
|
|
49
|
+
from claude_mpm.hooks.claude_hooks.hook_handler import _log
|
|
50
|
+
except ImportError:
|
|
51
|
+
|
|
52
|
+
def _log(msg: str) -> None:
|
|
53
|
+
pass # Silent fallback
|
|
54
|
+
|
|
55
|
+
|
|
48
56
|
logger = get_logger(__name__)
|
|
49
57
|
|
|
50
58
|
# Debug mode
|
|
@@ -100,11 +108,10 @@ class AutoPauseHandler:
|
|
|
100
108
|
self._previous_threshold = current_state.threshold_reached
|
|
101
109
|
|
|
102
110
|
if DEBUG:
|
|
103
|
-
|
|
111
|
+
_log(
|
|
104
112
|
f"AutoPauseHandler initialized: "
|
|
105
113
|
f"{current_state.percentage_used:.1f}% context used, "
|
|
106
|
-
f"threshold: {current_state.threshold_reached}"
|
|
107
|
-
file=sys.stderr,
|
|
114
|
+
f"threshold: {current_state.threshold_reached}"
|
|
108
115
|
)
|
|
109
116
|
except Exception as e:
|
|
110
117
|
logger.error(f"Failed to initialize AutoPauseHandler: {e}")
|
|
@@ -169,10 +176,9 @@ class AutoPauseHandler:
|
|
|
169
176
|
self._previous_threshold = current_threshold
|
|
170
177
|
|
|
171
178
|
if DEBUG:
|
|
172
|
-
|
|
179
|
+
_log(
|
|
173
180
|
f"Context threshold crossed: {current_threshold} "
|
|
174
|
-
f"({state.percentage_used:.1f}%)"
|
|
175
|
-
file=sys.stderr,
|
|
181
|
+
f"({state.percentage_used:.1f}%)"
|
|
176
182
|
)
|
|
177
183
|
|
|
178
184
|
# Trigger auto-pause if threshold reached
|
|
@@ -184,7 +190,7 @@ class AutoPauseHandler:
|
|
|
184
190
|
except Exception as e:
|
|
185
191
|
logger.error(f"Failed to update usage: {e}")
|
|
186
192
|
if DEBUG:
|
|
187
|
-
|
|
193
|
+
_log(f"❌ Usage update failed: {e}")
|
|
188
194
|
# Don't propagate error - auto-pause is optional
|
|
189
195
|
return None
|
|
190
196
|
|
|
@@ -220,12 +226,12 @@ class AutoPauseHandler:
|
|
|
220
226
|
)
|
|
221
227
|
|
|
222
228
|
if DEBUG:
|
|
223
|
-
|
|
229
|
+
_log(f"Recorded tool call during pause: {tool_name}")
|
|
224
230
|
|
|
225
231
|
except Exception as e:
|
|
226
232
|
logger.error(f"Failed to record tool call: {e}")
|
|
227
233
|
if DEBUG:
|
|
228
|
-
|
|
234
|
+
_log(f"❌ Failed to record tool call: {e}")
|
|
229
235
|
|
|
230
236
|
def on_assistant_response(self, response_summary: str) -> None:
|
|
231
237
|
"""Record an assistant response if auto-pause is active.
|
|
@@ -257,15 +263,14 @@ class AutoPauseHandler:
|
|
|
257
263
|
)
|
|
258
264
|
|
|
259
265
|
if DEBUG:
|
|
260
|
-
|
|
261
|
-
f"Recorded assistant response during pause (length: {len(summary)})"
|
|
262
|
-
file=sys.stderr,
|
|
266
|
+
_log(
|
|
267
|
+
f"Recorded assistant response during pause (length: {len(summary)})"
|
|
263
268
|
)
|
|
264
269
|
|
|
265
270
|
except Exception as e:
|
|
266
271
|
logger.error(f"Failed to record assistant response: {e}")
|
|
267
272
|
if DEBUG:
|
|
268
|
-
|
|
273
|
+
_log(f"❌ Failed to record assistant response: {e}")
|
|
269
274
|
|
|
270
275
|
def on_user_message(self, message_summary: str) -> None:
|
|
271
276
|
"""Record a user message if auto-pause is active.
|
|
@@ -297,15 +302,12 @@ class AutoPauseHandler:
|
|
|
297
302
|
)
|
|
298
303
|
|
|
299
304
|
if DEBUG:
|
|
300
|
-
|
|
301
|
-
f"Recorded user message during pause (length: {len(summary)})",
|
|
302
|
-
file=sys.stderr,
|
|
303
|
-
)
|
|
305
|
+
_log(f"Recorded user message during pause (length: {len(summary)})")
|
|
304
306
|
|
|
305
307
|
except Exception as e:
|
|
306
308
|
logger.error(f"Failed to record user message: {e}")
|
|
307
309
|
if DEBUG:
|
|
308
|
-
|
|
310
|
+
_log(f"❌ Failed to record user message: {e}")
|
|
309
311
|
|
|
310
312
|
def on_session_end(self) -> Optional[Path]:
|
|
311
313
|
"""Called when session ends. Finalizes any active pause.
|
|
@@ -318,7 +320,7 @@ class AutoPauseHandler:
|
|
|
318
320
|
"""
|
|
319
321
|
if not self.is_pause_active():
|
|
320
322
|
if DEBUG:
|
|
321
|
-
|
|
323
|
+
_log("No active pause to finalize")
|
|
322
324
|
return None
|
|
323
325
|
|
|
324
326
|
try:
|
|
@@ -326,14 +328,14 @@ class AutoPauseHandler:
|
|
|
326
328
|
session_path = self.pause_manager.finalize_pause(create_full_snapshot=True)
|
|
327
329
|
|
|
328
330
|
if session_path and DEBUG:
|
|
329
|
-
|
|
331
|
+
_log(f"✅ Session finalized: {session_path.name}")
|
|
330
332
|
|
|
331
333
|
return session_path
|
|
332
334
|
|
|
333
335
|
except Exception as e:
|
|
334
336
|
logger.error(f"Failed to finalize pause session: {e}")
|
|
335
337
|
if DEBUG:
|
|
336
|
-
|
|
338
|
+
_log(f"❌ Failed to finalize pause: {e}")
|
|
337
339
|
raise
|
|
338
340
|
|
|
339
341
|
def is_pause_active(self) -> bool:
|
|
@@ -417,9 +419,7 @@ class AutoPauseHandler:
|
|
|
417
419
|
# Check if pause is already active
|
|
418
420
|
if self.is_pause_active():
|
|
419
421
|
if DEBUG:
|
|
420
|
-
|
|
421
|
-
"Auto-pause already active, skipping trigger", file=sys.stderr
|
|
422
|
-
)
|
|
422
|
+
_log("Auto-pause already active, skipping trigger")
|
|
423
423
|
return
|
|
424
424
|
|
|
425
425
|
# Start incremental pause
|
|
@@ -429,16 +429,15 @@ class AutoPauseHandler:
|
|
|
429
429
|
)
|
|
430
430
|
|
|
431
431
|
if DEBUG:
|
|
432
|
-
|
|
432
|
+
_log(
|
|
433
433
|
f"✅ Auto-pause triggered: {session_id} "
|
|
434
|
-
f"({state.percentage_used:.1f}% context used)"
|
|
435
|
-
file=sys.stderr,
|
|
434
|
+
f"({state.percentage_used:.1f}% context used)"
|
|
436
435
|
)
|
|
437
436
|
|
|
438
437
|
except Exception as e:
|
|
439
438
|
logger.error(f"Failed to trigger auto-pause: {e}")
|
|
440
439
|
if DEBUG:
|
|
441
|
-
|
|
440
|
+
_log(f"❌ Failed to trigger auto-pause: {e}")
|
|
442
441
|
# Don't propagate - auto-pause is optional
|
|
443
442
|
|
|
444
443
|
def _summarize_dict(
|
|
@@ -8,12 +8,20 @@ Claude Code hook events.
|
|
|
8
8
|
import os
|
|
9
9
|
import re
|
|
10
10
|
import subprocess # nosec B404 - subprocess used for safe claude CLI version checking only
|
|
11
|
-
import sys
|
|
12
11
|
import uuid
|
|
13
12
|
from datetime import datetime, timezone
|
|
14
13
|
from pathlib import Path
|
|
15
14
|
from typing import Optional
|
|
16
15
|
|
|
16
|
+
# Import _log helper to avoid stderr writes (which cause hook errors)
|
|
17
|
+
try:
|
|
18
|
+
from .hook_handler import _log
|
|
19
|
+
except ImportError:
|
|
20
|
+
# Fallback for direct execution
|
|
21
|
+
def _log(message: str) -> None:
|
|
22
|
+
"""Fallback logger when hook_handler not available."""
|
|
23
|
+
|
|
24
|
+
|
|
17
25
|
# Import tool analysis with fallback for direct execution
|
|
18
26
|
try:
|
|
19
27
|
# Try relative import first (when imported as module)
|
|
@@ -34,8 +42,8 @@ except ImportError:
|
|
|
34
42
|
extract_tool_results,
|
|
35
43
|
)
|
|
36
44
|
|
|
37
|
-
# Debug mode
|
|
38
|
-
DEBUG = os.environ.get("CLAUDE_MPM_HOOK_DEBUG", "
|
|
45
|
+
# Debug mode - MUST match hook_handler.py default (false) to prevent stderr writes
|
|
46
|
+
DEBUG = os.environ.get("CLAUDE_MPM_HOOK_DEBUG", "false").lower() == "true"
|
|
39
47
|
|
|
40
48
|
# Import constants for configuration
|
|
41
49
|
try:
|
|
@@ -111,14 +119,22 @@ class EventHandlers:
|
|
|
111
119
|
"working_directory": working_dir,
|
|
112
120
|
}
|
|
113
121
|
if DEBUG:
|
|
114
|
-
|
|
115
|
-
f"Stored prompt for comprehensive tracking: session {session_id[:8]}..."
|
|
116
|
-
file=sys.stderr,
|
|
122
|
+
_log(
|
|
123
|
+
f"Stored prompt for comprehensive tracking: session {session_id[:8]}..."
|
|
117
124
|
)
|
|
118
125
|
except Exception: # nosec B110
|
|
119
126
|
# Response tracking is optional - silently continue if it fails
|
|
120
127
|
pass
|
|
121
128
|
|
|
129
|
+
# Record user message for auto-pause if active
|
|
130
|
+
auto_pause = getattr(self.hook_handler, "auto_pause_handler", None)
|
|
131
|
+
if auto_pause and auto_pause.is_pause_active():
|
|
132
|
+
try:
|
|
133
|
+
auto_pause.on_user_message(prompt)
|
|
134
|
+
except Exception as e:
|
|
135
|
+
if DEBUG:
|
|
136
|
+
_log(f"Auto-pause user message recording error: {e}")
|
|
137
|
+
|
|
122
138
|
# Emit normalized event (namespace no longer needed with normalized events)
|
|
123
139
|
self.hook_handler._emit_socketio_event("", "user_prompt", prompt_data)
|
|
124
140
|
|
|
@@ -133,11 +149,8 @@ class EventHandlers:
|
|
|
133
149
|
# Enhanced debug logging for session correlation
|
|
134
150
|
session_id = event.get("session_id", "")
|
|
135
151
|
if DEBUG:
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
file=sys.stderr,
|
|
139
|
-
)
|
|
140
|
-
print(f" - event keys: {list(event.keys())}", file=sys.stderr)
|
|
152
|
+
_log(f" - session_id: {session_id[:16] if session_id else 'None'}...")
|
|
153
|
+
_log(f" - event keys: {list(event.keys())}")
|
|
141
154
|
|
|
142
155
|
tool_name = event.get("tool_name", "")
|
|
143
156
|
tool_input = event.get("tool_input", {})
|
|
@@ -180,9 +193,8 @@ class EventHandlers:
|
|
|
180
193
|
|
|
181
194
|
CorrelationManager.store(session_id, tool_call_id, tool_name)
|
|
182
195
|
if DEBUG:
|
|
183
|
-
|
|
184
|
-
f" - Generated tool_call_id: {tool_call_id[:8]}... for session {session_id[:8]}..."
|
|
185
|
-
file=sys.stderr,
|
|
196
|
+
_log(
|
|
197
|
+
f" - Generated tool_call_id: {tool_call_id[:8]}... for session {session_id[:8]}..."
|
|
186
198
|
)
|
|
187
199
|
|
|
188
200
|
# Add delegation-specific data if this is a Task tool
|
|
@@ -196,7 +208,7 @@ class EventHandlers:
|
|
|
196
208
|
auto_pause.on_tool_call(tool_name, tool_input)
|
|
197
209
|
except Exception as e:
|
|
198
210
|
if DEBUG:
|
|
199
|
-
|
|
211
|
+
_log(f"Auto-pause tool recording error: {e}")
|
|
200
212
|
|
|
201
213
|
self.hook_handler._emit_socketio_event("", "pre_tool", pre_tool_data)
|
|
202
214
|
|
|
@@ -212,9 +224,8 @@ class EventHandlers:
|
|
|
212
224
|
}
|
|
213
225
|
self.hook_handler._emit_socketio_event("", "todo_updated", todo_data)
|
|
214
226
|
if DEBUG:
|
|
215
|
-
|
|
216
|
-
f" - Emitted todo_updated event with {len(tool_params['todos'])} todos for session {session_id[:8]}..."
|
|
217
|
-
file=sys.stderr,
|
|
227
|
+
_log(
|
|
228
|
+
f" - Emitted todo_updated event with {len(tool_params['todos'])} todos for session {session_id[:8]}..."
|
|
218
229
|
)
|
|
219
230
|
|
|
220
231
|
def _handle_task_delegation(
|
|
@@ -255,12 +266,9 @@ class EventHandlers:
|
|
|
255
266
|
|
|
256
267
|
# Track this delegation for SubagentStop correlation and response tracking
|
|
257
268
|
if DEBUG:
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
)
|
|
262
|
-
print(f" - agent_type: {agent_type}", file=sys.stderr)
|
|
263
|
-
print(f" - raw_agent_type: {raw_agent_type}", file=sys.stderr)
|
|
269
|
+
_log(f" - session_id: {session_id[:16] if session_id else 'None'}...")
|
|
270
|
+
_log(f" - agent_type: {agent_type}")
|
|
271
|
+
_log(f" - raw_agent_type: {raw_agent_type}")
|
|
264
272
|
|
|
265
273
|
if session_id and agent_type != "unknown":
|
|
266
274
|
# Prepare request data for response tracking correlation
|
|
@@ -272,24 +280,17 @@ class EventHandlers:
|
|
|
272
280
|
self.hook_handler._track_delegation(session_id, agent_type, request_data)
|
|
273
281
|
|
|
274
282
|
if DEBUG:
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
f" - Request data keys: {list(request_data.keys())}",
|
|
278
|
-
file=sys.stderr,
|
|
279
|
-
)
|
|
283
|
+
_log(" - Delegation tracked successfully")
|
|
284
|
+
_log(f" - Request data keys: {list(request_data.keys())}")
|
|
280
285
|
delegation_requests = getattr(
|
|
281
286
|
self.hook_handler, "delegation_requests", {}
|
|
282
287
|
)
|
|
283
|
-
|
|
284
|
-
f" - delegation_requests size: {len(delegation_requests)}",
|
|
285
|
-
file=sys.stderr,
|
|
286
|
-
)
|
|
288
|
+
_log(f" - delegation_requests size: {len(delegation_requests)}")
|
|
287
289
|
|
|
288
290
|
# Log important delegations for debugging
|
|
289
291
|
if DEBUG or agent_type in ["research", "engineer", "qa", "documentation"]:
|
|
290
|
-
|
|
291
|
-
f"Hook handler: Task delegation started - agent: '{agent_type}', session: '{session_id}'"
|
|
292
|
-
file=sys.stderr,
|
|
292
|
+
_log(
|
|
293
|
+
f"Hook handler: Task delegation started - agent: '{agent_type}', session: '{session_id}'"
|
|
293
294
|
)
|
|
294
295
|
|
|
295
296
|
# Trigger memory pre-delegation hook
|
|
@@ -359,10 +360,10 @@ class EventHandlers:
|
|
|
359
360
|
)
|
|
360
361
|
|
|
361
362
|
if DEBUG:
|
|
362
|
-
|
|
363
|
+
_log(f" - Agent prompt logged for {agent_type}")
|
|
363
364
|
except Exception as e:
|
|
364
365
|
if DEBUG:
|
|
365
|
-
|
|
366
|
+
_log(f" - Could not log agent prompt: {e}")
|
|
366
367
|
|
|
367
368
|
def _get_git_branch(self, working_dir: Optional[str] = None) -> str:
|
|
368
369
|
"""Get git branch for the given directory with caching."""
|
|
@@ -450,9 +451,8 @@ class EventHandlers:
|
|
|
450
451
|
|
|
451
452
|
tool_call_id = CorrelationManager.retrieve(session_id) if session_id else None
|
|
452
453
|
if DEBUG and tool_call_id:
|
|
453
|
-
|
|
454
|
-
f" - Retrieved tool_call_id: {tool_call_id[:8]}... for session {session_id[:8]}..."
|
|
455
|
-
file=sys.stderr,
|
|
454
|
+
_log(
|
|
455
|
+
f" - Retrieved tool_call_id: {tool_call_id[:8]}... for session {session_id[:8]}..."
|
|
456
456
|
)
|
|
457
457
|
|
|
458
458
|
post_tool_data = {
|
|
@@ -605,16 +605,25 @@ class EventHandlers:
|
|
|
605
605
|
_log(f"⚠️ Auto-pause threshold crossed: {warning}")
|
|
606
606
|
|
|
607
607
|
if DEBUG:
|
|
608
|
-
|
|
609
|
-
f" - Auto-pause threshold crossed: {threshold_crossed}"
|
|
610
|
-
file=sys.stderr,
|
|
608
|
+
_log(
|
|
609
|
+
f" - Auto-pause threshold crossed: {threshold_crossed}"
|
|
611
610
|
)
|
|
612
611
|
except Exception as e:
|
|
613
612
|
if DEBUG:
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
613
|
+
_log(f"Auto-pause error in handle_stop_fast: {e}")
|
|
614
|
+
|
|
615
|
+
# Finalize pause session if active
|
|
616
|
+
try:
|
|
617
|
+
if auto_pause.is_pause_active():
|
|
618
|
+
session_file = auto_pause.on_session_end()
|
|
619
|
+
if session_file:
|
|
620
|
+
if DEBUG:
|
|
621
|
+
_log(
|
|
622
|
+
f"✅ Auto-pause session finalized: {session_file.name}"
|
|
623
|
+
)
|
|
624
|
+
except Exception as e:
|
|
625
|
+
if DEBUG:
|
|
626
|
+
_log(f"❌ Failed to finalize auto-pause session: {e}")
|
|
618
627
|
|
|
619
628
|
# Track response if enabled
|
|
620
629
|
try:
|
|
@@ -656,24 +665,15 @@ class EventHandlers:
|
|
|
656
665
|
getattr(rtm, "response_tracker", None) is not None if rtm else False
|
|
657
666
|
)
|
|
658
667
|
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
file=sys.stderr,
|
|
662
|
-
)
|
|
663
|
-
print(
|
|
664
|
-
f" - response_tracker exists: {tracker_exists}",
|
|
665
|
-
file=sys.stderr,
|
|
666
|
-
)
|
|
668
|
+
_log(f" - response_tracking_enabled: {tracking_enabled}")
|
|
669
|
+
_log(f" - response_tracker exists: {tracker_exists}")
|
|
667
670
|
except Exception: # nosec B110
|
|
668
671
|
# If debug logging fails, just skip it
|
|
669
672
|
pass
|
|
670
673
|
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
)
|
|
675
|
-
print(f" - reason: {metadata['reason']}", file=sys.stderr)
|
|
676
|
-
print(f" - stop_type: {metadata['stop_type']}", file=sys.stderr)
|
|
674
|
+
_log(f" - session_id: {session_id[:8] if session_id else 'None'}...")
|
|
675
|
+
_log(f" - reason: {metadata['reason']}")
|
|
676
|
+
_log(f" - stop_type: {metadata['stop_type']}")
|
|
677
677
|
|
|
678
678
|
def _emit_stop_event(self, event: dict, session_id: str, metadata: dict) -> None:
|
|
679
679
|
"""Emit stop event data to Socket.IO."""
|
|
@@ -735,10 +735,7 @@ class EventHandlers:
|
|
|
735
735
|
# If exact match fails, try partial matching
|
|
736
736
|
if not request_info and session_id:
|
|
737
737
|
if DEBUG:
|
|
738
|
-
|
|
739
|
-
f" - Trying fuzzy match for session {session_id[:16]}...",
|
|
740
|
-
file=sys.stderr,
|
|
741
|
-
)
|
|
738
|
+
_log(f" - Trying fuzzy match for session {session_id[:16]}...")
|
|
742
739
|
# Try to find a session that matches the first 8-16 characters
|
|
743
740
|
for stored_sid in list(delegation_requests.keys()):
|
|
744
741
|
if (
|
|
@@ -751,10 +748,7 @@ class EventHandlers:
|
|
|
751
748
|
)
|
|
752
749
|
):
|
|
753
750
|
if DEBUG:
|
|
754
|
-
|
|
755
|
-
f" - ✅ Fuzzy match found: {stored_sid[:16]}...",
|
|
756
|
-
file=sys.stderr,
|
|
757
|
-
)
|
|
751
|
+
_log(f" - ✅ Fuzzy match found: {stored_sid[:16]}...")
|
|
758
752
|
request_info = delegation_requests.get(stored_sid) # nosec B113
|
|
759
753
|
# Update the key to use the current session_id for consistency
|
|
760
754
|
if request_info:
|
|
@@ -823,9 +817,8 @@ class EventHandlers:
|
|
|
823
817
|
)
|
|
824
818
|
|
|
825
819
|
if file_path and DEBUG:
|
|
826
|
-
|
|
827
|
-
f"✅ Tracked {agent_type} agent response on SubagentStop: {file_path.name}"
|
|
828
|
-
file=sys.stderr,
|
|
820
|
+
_log(
|
|
821
|
+
f"✅ Tracked {agent_type} agent response on SubagentStop: {file_path.name}"
|
|
829
822
|
)
|
|
830
823
|
|
|
831
824
|
# Clean up the request data
|
|
@@ -836,16 +829,13 @@ class EventHandlers:
|
|
|
836
829
|
del delegation_requests[session_id]
|
|
837
830
|
|
|
838
831
|
elif DEBUG:
|
|
839
|
-
|
|
840
|
-
f"No request data for SubagentStop session {session_id[:8]}..., agent: {agent_type}"
|
|
841
|
-
file=sys.stderr,
|
|
832
|
+
_log(
|
|
833
|
+
f"No request data for SubagentStop session {session_id[:8]}..., agent: {agent_type}"
|
|
842
834
|
)
|
|
843
835
|
|
|
844
836
|
except Exception as e:
|
|
845
837
|
if DEBUG:
|
|
846
|
-
|
|
847
|
-
f"❌ Failed to track response on SubagentStop: {e}", file=sys.stderr
|
|
848
|
-
)
|
|
838
|
+
_log(f"❌ Failed to track response on SubagentStop: {e}")
|
|
849
839
|
|
|
850
840
|
def handle_assistant_response(self, event):
|
|
851
841
|
"""Handle assistant response events for comprehensive response tracking.
|
|
@@ -872,7 +862,7 @@ class EventHandlers:
|
|
|
872
862
|
self._scan_for_delegation_patterns(event)
|
|
873
863
|
except Exception as e: # nosec B110
|
|
874
864
|
if DEBUG:
|
|
875
|
-
|
|
865
|
+
_log(f"Delegation scanning error: {e}")
|
|
876
866
|
|
|
877
867
|
# Get working directory and git branch
|
|
878
868
|
working_dir = event.get("cwd", "")
|
|
@@ -921,9 +911,8 @@ class EventHandlers:
|
|
|
921
911
|
|
|
922
912
|
# Debug logging
|
|
923
913
|
if DEBUG:
|
|
924
|
-
|
|
925
|
-
f"Hook handler: Processing AssistantResponse - session: '{session_id}', response_length: {len(response_text)}"
|
|
926
|
-
file=sys.stderr,
|
|
914
|
+
_log(
|
|
915
|
+
f"Hook handler: Processing AssistantResponse - session: '{session_id}', response_length: {len(response_text)}"
|
|
927
916
|
)
|
|
928
917
|
|
|
929
918
|
# Record assistant response for auto-pause if active
|
|
@@ -939,7 +928,7 @@ class EventHandlers:
|
|
|
939
928
|
auto_pause.on_assistant_response(summary)
|
|
940
929
|
except Exception as e:
|
|
941
930
|
if DEBUG:
|
|
942
|
-
|
|
931
|
+
_log(f"Auto-pause response recording error: {e}")
|
|
943
932
|
|
|
944
933
|
# Emit normalized event
|
|
945
934
|
self.hook_handler._emit_socketio_event(
|
|
@@ -990,22 +979,13 @@ class EventHandlers:
|
|
|
990
979
|
if pending_todos:
|
|
991
980
|
session_start_data["pending_autotodos"] = pending_todos
|
|
992
981
|
session_start_data["autotodos_count"] = len(pending_todos)
|
|
993
|
-
|
|
994
|
-
print(
|
|
995
|
-
f" - Auto-injected {len(pending_todos)} pending autotodos",
|
|
996
|
-
file=sys.stderr,
|
|
997
|
-
)
|
|
982
|
+
_log(f" - Auto-injected {len(pending_todos)} pending autotodos")
|
|
998
983
|
except Exception as e: # nosec B110
|
|
999
984
|
# Auto-injection is optional - continue if it fails
|
|
1000
|
-
|
|
1001
|
-
print(f" - Failed to auto-inject autotodos: {e}", file=sys.stderr)
|
|
985
|
+
_log(f" - Failed to auto-inject autotodos: {e}")
|
|
1002
986
|
|
|
1003
987
|
# Debug logging
|
|
1004
|
-
|
|
1005
|
-
print(
|
|
1006
|
-
f"Hook handler: Processing SessionStart - session: '{session_id}'",
|
|
1007
|
-
file=sys.stderr,
|
|
1008
|
-
)
|
|
988
|
+
_log(f"Hook handler: Processing SessionStart - session: '{session_id}'")
|
|
1009
989
|
|
|
1010
990
|
# Emit normalized event
|
|
1011
991
|
self.hook_handler._emit_socketio_event("", "session_start", session_start_data)
|
|
@@ -1048,10 +1028,8 @@ class EventHandlers:
|
|
|
1048
1028
|
|
|
1049
1029
|
# Debug logging
|
|
1050
1030
|
if DEBUG:
|
|
1051
|
-
|
|
1052
|
-
f"Hook handler: SubagentStart - agent_type='{agent_type}', "
|
|
1053
|
-
f"agent_id='{agent_id}', session_id='{session_id[:16]}...'",
|
|
1054
|
-
file=sys.stderr,
|
|
1031
|
+
_log(
|
|
1032
|
+
f"Hook handler: SubagentStart - agent_type='{agent_type}', agent_id='{agent_id}', session_id='{session_id[:16]}...'"
|
|
1055
1033
|
)
|
|
1056
1034
|
|
|
1057
1035
|
# Emit to /hook namespace as subagent_start (NOT session_start!)
|
|
@@ -1086,7 +1064,7 @@ class EventHandlers:
|
|
|
1086
1064
|
from claude_mpm.services.event_log import get_event_log
|
|
1087
1065
|
except ImportError:
|
|
1088
1066
|
if DEBUG:
|
|
1089
|
-
|
|
1067
|
+
_log("Delegation detector or event log not available")
|
|
1090
1068
|
return
|
|
1091
1069
|
|
|
1092
1070
|
response_text = event.get("response", "")
|
|
@@ -1125,7 +1103,4 @@ class EventHandlers:
|
|
|
1125
1103
|
)
|
|
1126
1104
|
|
|
1127
1105
|
if DEBUG:
|
|
1128
|
-
|
|
1129
|
-
f"⚠️ PM violation detected: {detection['original_text'][:60]}...",
|
|
1130
|
-
file=sys.stderr,
|
|
1131
|
-
)
|
|
1106
|
+
_log(f"⚠️ PM violation detected: {detection['original_text'][:60]}...")
|
|
File without changes
|
|
@@ -537,6 +537,44 @@ main "$@"
|
|
|
537
537
|
except Exception as e:
|
|
538
538
|
self.logger.warning(f"Could not clean up old settings file: {e}")
|
|
539
539
|
|
|
540
|
+
def _fix_status_line(self, settings: Dict) -> None:
|
|
541
|
+
"""Fix statusLine command to handle both output style schema formats.
|
|
542
|
+
|
|
543
|
+
The statusLine command receives input in different formats:
|
|
544
|
+
- Newer format: {"activeOutputStyle": "Claude MPM", ...}
|
|
545
|
+
- Older format: {"output_style": {"name": "Claude MPM"}, ...}
|
|
546
|
+
|
|
547
|
+
This method ensures the jq expression checks both locations.
|
|
548
|
+
|
|
549
|
+
Args:
|
|
550
|
+
settings: The settings dictionary to update
|
|
551
|
+
"""
|
|
552
|
+
if "statusLine" not in settings:
|
|
553
|
+
return
|
|
554
|
+
|
|
555
|
+
status_line = settings.get("statusLine", {})
|
|
556
|
+
if "command" not in status_line:
|
|
557
|
+
return
|
|
558
|
+
|
|
559
|
+
command = status_line["command"]
|
|
560
|
+
|
|
561
|
+
# Pattern to match: '.output_style.name // "default"'
|
|
562
|
+
# We need to update it to: '.output_style.name // .activeOutputStyle // "default"'
|
|
563
|
+
old_pattern = r'\.output_style\.name\s*//\s*"default"'
|
|
564
|
+
new_pattern = '.output_style.name // .activeOutputStyle // "default"'
|
|
565
|
+
|
|
566
|
+
# Check if the command needs updating
|
|
567
|
+
if re.search(old_pattern, command) and ".activeOutputStyle" not in command:
|
|
568
|
+
updated_command = re.sub(old_pattern, new_pattern, command)
|
|
569
|
+
settings["statusLine"]["command"] = updated_command
|
|
570
|
+
self.logger.info(
|
|
571
|
+
"Fixed statusLine command to handle both output style schemas"
|
|
572
|
+
)
|
|
573
|
+
else:
|
|
574
|
+
self.logger.debug(
|
|
575
|
+
"StatusLine command already supports both schemas or not present"
|
|
576
|
+
)
|
|
577
|
+
|
|
540
578
|
def _update_claude_settings(self, hook_script_path: Path) -> None:
|
|
541
579
|
"""Update Claude settings to use the installed hook."""
|
|
542
580
|
self.logger.info("Updating Claude settings...")
|
|
@@ -598,6 +636,9 @@ main "$@"
|
|
|
598
636
|
}
|
|
599
637
|
]
|
|
600
638
|
|
|
639
|
+
# Fix statusLine command to handle both output style schemas
|
|
640
|
+
self._fix_status_line(settings)
|
|
641
|
+
|
|
601
642
|
# Write settings to settings.json
|
|
602
643
|
with self.settings_file.open("w") as f:
|
|
603
644
|
json.dump(settings, f, indent=2)
|