claude-mpm 4.15.6__py3-none-any.whl → 4.21.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.

Potentially problematic release.


This version of claude-mpm might be problematic. Click here for more details.

Files changed (194) hide show
  1. claude_mpm/VERSION +1 -1
  2. claude_mpm/agents/BASE_ENGINEER.md +286 -0
  3. claude_mpm/agents/BASE_PM.md +272 -23
  4. claude_mpm/agents/PM_INSTRUCTIONS.md +49 -0
  5. claude_mpm/agents/agent_loader.py +4 -4
  6. claude_mpm/agents/templates/engineer.json +5 -1
  7. claude_mpm/agents/templates/php-engineer.json +10 -4
  8. claude_mpm/agents/templates/python_engineer.json +8 -3
  9. claude_mpm/agents/templates/rust_engineer.json +12 -7
  10. claude_mpm/agents/templates/svelte-engineer.json +225 -0
  11. claude_mpm/cli/commands/__init__.py +2 -0
  12. claude_mpm/cli/commands/mpm_init/__init__.py +73 -0
  13. claude_mpm/cli/commands/mpm_init/core.py +525 -0
  14. claude_mpm/cli/commands/mpm_init/display.py +341 -0
  15. claude_mpm/cli/commands/mpm_init/git_activity.py +427 -0
  16. claude_mpm/cli/commands/mpm_init/modes.py +397 -0
  17. claude_mpm/cli/commands/mpm_init/prompts.py +442 -0
  18. claude_mpm/cli/commands/mpm_init_cli.py +396 -0
  19. claude_mpm/cli/commands/mpm_init_handler.py +67 -1
  20. claude_mpm/cli/commands/skills.py +488 -0
  21. claude_mpm/cli/executor.py +2 -0
  22. claude_mpm/cli/parsers/base_parser.py +7 -0
  23. claude_mpm/cli/parsers/mpm_init_parser.py +42 -0
  24. claude_mpm/cli/parsers/skills_parser.py +137 -0
  25. claude_mpm/cli/startup.py +57 -0
  26. claude_mpm/commands/mpm-auto-configure.md +52 -0
  27. claude_mpm/commands/mpm-help.md +3 -0
  28. claude_mpm/commands/mpm-init.md +112 -6
  29. claude_mpm/commands/mpm-version.md +113 -0
  30. claude_mpm/commands/mpm.md +1 -0
  31. claude_mpm/config/agent_config.py +2 -2
  32. claude_mpm/constants.py +12 -0
  33. claude_mpm/core/config.py +42 -0
  34. claude_mpm/core/factories.py +1 -1
  35. claude_mpm/core/interfaces.py +56 -1
  36. claude_mpm/core/optimized_agent_loader.py +3 -3
  37. claude_mpm/hooks/__init__.py +8 -0
  38. claude_mpm/hooks/claude_hooks/response_tracking.py +35 -1
  39. claude_mpm/hooks/session_resume_hook.py +121 -0
  40. claude_mpm/models/resume_log.py +340 -0
  41. claude_mpm/services/agents/auto_config_manager.py +1 -1
  42. claude_mpm/services/agents/deployment/agent_configuration_manager.py +1 -1
  43. claude_mpm/services/agents/deployment/agent_record_service.py +1 -1
  44. claude_mpm/services/agents/deployment/agent_validator.py +17 -1
  45. claude_mpm/services/agents/deployment/async_agent_deployment.py +1 -1
  46. claude_mpm/services/agents/deployment/local_template_deployment.py +1 -1
  47. claude_mpm/services/agents/local_template_manager.py +1 -1
  48. claude_mpm/services/agents/recommender.py +47 -0
  49. claude_mpm/services/cli/resume_service.py +617 -0
  50. claude_mpm/services/cli/session_manager.py +87 -0
  51. claude_mpm/services/cli/session_pause_manager.py +504 -0
  52. claude_mpm/services/cli/session_resume_helper.py +372 -0
  53. claude_mpm/services/core/interfaces.py +56 -1
  54. claude_mpm/services/core/models/agent_config.py +3 -0
  55. claude_mpm/services/core/models/process.py +4 -0
  56. claude_mpm/services/core/path_resolver.py +1 -1
  57. claude_mpm/services/diagnostics/models.py +21 -0
  58. claude_mpm/services/infrastructure/resume_log_generator.py +439 -0
  59. claude_mpm/services/local_ops/__init__.py +2 -0
  60. claude_mpm/services/mcp_config_manager.py +7 -131
  61. claude_mpm/services/mcp_gateway/auto_configure.py +31 -25
  62. claude_mpm/services/mcp_gateway/core/process_pool.py +19 -10
  63. claude_mpm/services/mcp_gateway/tools/external_mcp_services.py +26 -21
  64. claude_mpm/services/session_manager.py +205 -1
  65. claude_mpm/services/unified/deployment_strategies/local.py +1 -1
  66. claude_mpm/services/version_service.py +104 -1
  67. claude_mpm/skills/__init__.py +21 -0
  68. claude_mpm/skills/agent_skills_injector.py +324 -0
  69. claude_mpm/skills/bundled/LICENSE_ATTRIBUTIONS.md +79 -0
  70. claude_mpm/skills/bundled/api-documentation.md +393 -0
  71. claude_mpm/skills/bundled/async-testing.md +571 -0
  72. claude_mpm/skills/bundled/code-review.md +143 -0
  73. claude_mpm/skills/bundled/collaboration/brainstorming/SKILL.md +79 -0
  74. claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/SKILL.md +178 -0
  75. claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/agent-prompts.md +577 -0
  76. claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/coordination-patterns.md +467 -0
  77. claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/examples.md +537 -0
  78. claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/troubleshooting.md +730 -0
  79. claude_mpm/skills/bundled/collaboration/requesting-code-review/SKILL.md +112 -0
  80. claude_mpm/skills/bundled/collaboration/requesting-code-review/references/code-reviewer-template.md +146 -0
  81. claude_mpm/skills/bundled/collaboration/requesting-code-review/references/review-examples.md +412 -0
  82. claude_mpm/skills/bundled/collaboration/writing-plans/SKILL.md +81 -0
  83. claude_mpm/skills/bundled/collaboration/writing-plans/references/best-practices.md +362 -0
  84. claude_mpm/skills/bundled/collaboration/writing-plans/references/plan-structure-templates.md +312 -0
  85. claude_mpm/skills/bundled/database-migration.md +199 -0
  86. claude_mpm/skills/bundled/debugging/root-cause-tracing/SKILL.md +152 -0
  87. claude_mpm/skills/bundled/debugging/root-cause-tracing/references/advanced-techniques.md +668 -0
  88. claude_mpm/skills/bundled/debugging/root-cause-tracing/references/examples.md +587 -0
  89. claude_mpm/skills/bundled/debugging/root-cause-tracing/references/integration.md +438 -0
  90. claude_mpm/skills/bundled/debugging/root-cause-tracing/references/tracing-techniques.md +391 -0
  91. claude_mpm/skills/bundled/debugging/systematic-debugging/CREATION-LOG.md +119 -0
  92. claude_mpm/skills/bundled/debugging/systematic-debugging/SKILL.md +148 -0
  93. claude_mpm/skills/bundled/debugging/systematic-debugging/references/anti-patterns.md +483 -0
  94. claude_mpm/skills/bundled/debugging/systematic-debugging/references/examples.md +452 -0
  95. claude_mpm/skills/bundled/debugging/systematic-debugging/references/troubleshooting.md +449 -0
  96. claude_mpm/skills/bundled/debugging/systematic-debugging/references/workflow.md +411 -0
  97. claude_mpm/skills/bundled/debugging/systematic-debugging/test-academic.md +14 -0
  98. claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-1.md +58 -0
  99. claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-2.md +68 -0
  100. claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-3.md +69 -0
  101. claude_mpm/skills/bundled/debugging/verification-before-completion/SKILL.md +131 -0
  102. claude_mpm/skills/bundled/debugging/verification-before-completion/references/gate-function.md +325 -0
  103. claude_mpm/skills/bundled/debugging/verification-before-completion/references/integration-and-workflows.md +490 -0
  104. claude_mpm/skills/bundled/debugging/verification-before-completion/references/red-flags-and-failures.md +425 -0
  105. claude_mpm/skills/bundled/debugging/verification-before-completion/references/verification-patterns.md +499 -0
  106. claude_mpm/skills/bundled/docker-containerization.md +194 -0
  107. claude_mpm/skills/bundled/express-local-dev.md +1429 -0
  108. claude_mpm/skills/bundled/fastapi-local-dev.md +1199 -0
  109. claude_mpm/skills/bundled/git-workflow.md +414 -0
  110. claude_mpm/skills/bundled/imagemagick.md +204 -0
  111. claude_mpm/skills/bundled/json-data-handling.md +223 -0
  112. claude_mpm/skills/bundled/main/artifacts-builder/SKILL.md +86 -0
  113. claude_mpm/skills/bundled/main/internal-comms/SKILL.md +43 -0
  114. claude_mpm/skills/bundled/main/internal-comms/examples/3p-updates.md +47 -0
  115. claude_mpm/skills/bundled/main/internal-comms/examples/company-newsletter.md +65 -0
  116. claude_mpm/skills/bundled/main/internal-comms/examples/faq-answers.md +30 -0
  117. claude_mpm/skills/bundled/main/internal-comms/examples/general-comms.md +16 -0
  118. claude_mpm/skills/bundled/main/mcp-builder/SKILL.md +160 -0
  119. claude_mpm/skills/bundled/main/mcp-builder/reference/design_principles.md +412 -0
  120. claude_mpm/skills/bundled/main/mcp-builder/reference/evaluation.md +602 -0
  121. claude_mpm/skills/bundled/main/mcp-builder/reference/mcp_best_practices.md +915 -0
  122. claude_mpm/skills/bundled/main/mcp-builder/reference/node_mcp_server.md +916 -0
  123. claude_mpm/skills/bundled/main/mcp-builder/reference/python_mcp_server.md +752 -0
  124. claude_mpm/skills/bundled/main/mcp-builder/reference/workflow.md +1237 -0
  125. claude_mpm/skills/bundled/main/mcp-builder/scripts/connections.py +157 -0
  126. claude_mpm/skills/bundled/main/mcp-builder/scripts/evaluation.py +425 -0
  127. claude_mpm/skills/bundled/main/skill-creator/SKILL.md +189 -0
  128. claude_mpm/skills/bundled/main/skill-creator/references/best-practices.md +500 -0
  129. claude_mpm/skills/bundled/main/skill-creator/references/creation-workflow.md +464 -0
  130. claude_mpm/skills/bundled/main/skill-creator/references/examples.md +619 -0
  131. claude_mpm/skills/bundled/main/skill-creator/references/progressive-disclosure.md +437 -0
  132. claude_mpm/skills/bundled/main/skill-creator/references/skill-structure.md +231 -0
  133. claude_mpm/skills/bundled/main/skill-creator/scripts/init_skill.py +303 -0
  134. claude_mpm/skills/bundled/main/skill-creator/scripts/package_skill.py +113 -0
  135. claude_mpm/skills/bundled/main/skill-creator/scripts/quick_validate.py +72 -0
  136. claude_mpm/skills/bundled/nextjs-local-dev.md +807 -0
  137. claude_mpm/skills/bundled/pdf.md +141 -0
  138. claude_mpm/skills/bundled/performance-profiling.md +567 -0
  139. claude_mpm/skills/bundled/php/espocrm-development/SKILL.md +170 -0
  140. claude_mpm/skills/bundled/php/espocrm-development/references/architecture.md +602 -0
  141. claude_mpm/skills/bundled/php/espocrm-development/references/common-tasks.md +821 -0
  142. claude_mpm/skills/bundled/php/espocrm-development/references/development-workflow.md +742 -0
  143. claude_mpm/skills/bundled/php/espocrm-development/references/frontend-customization.md +726 -0
  144. claude_mpm/skills/bundled/php/espocrm-development/references/hooks-and-services.md +764 -0
  145. claude_mpm/skills/bundled/php/espocrm-development/references/testing-debugging.md +831 -0
  146. claude_mpm/skills/bundled/refactoring-patterns.md +180 -0
  147. claude_mpm/skills/bundled/rust/desktop-applications/SKILL.md +226 -0
  148. claude_mpm/skills/bundled/rust/desktop-applications/references/architecture-patterns.md +901 -0
  149. claude_mpm/skills/bundled/rust/desktop-applications/references/native-gui-frameworks.md +901 -0
  150. claude_mpm/skills/bundled/rust/desktop-applications/references/platform-integration.md +775 -0
  151. claude_mpm/skills/bundled/rust/desktop-applications/references/state-management.md +937 -0
  152. claude_mpm/skills/bundled/rust/desktop-applications/references/tauri-framework.md +770 -0
  153. claude_mpm/skills/bundled/rust/desktop-applications/references/testing-deployment.md +961 -0
  154. claude_mpm/skills/bundled/security-scanning.md +327 -0
  155. claude_mpm/skills/bundled/systematic-debugging.md +473 -0
  156. claude_mpm/skills/bundled/test-driven-development.md +378 -0
  157. claude_mpm/skills/bundled/testing/condition-based-waiting/SKILL.md +119 -0
  158. claude_mpm/skills/bundled/testing/condition-based-waiting/references/patterns-and-implementation.md +253 -0
  159. claude_mpm/skills/bundled/testing/test-driven-development/SKILL.md +145 -0
  160. claude_mpm/skills/bundled/testing/test-driven-development/references/anti-patterns.md +543 -0
  161. claude_mpm/skills/bundled/testing/test-driven-development/references/examples.md +741 -0
  162. claude_mpm/skills/bundled/testing/test-driven-development/references/integration.md +470 -0
  163. claude_mpm/skills/bundled/testing/test-driven-development/references/philosophy.md +458 -0
  164. claude_mpm/skills/bundled/testing/test-driven-development/references/workflow.md +639 -0
  165. claude_mpm/skills/bundled/testing/testing-anti-patterns/SKILL.md +140 -0
  166. claude_mpm/skills/bundled/testing/testing-anti-patterns/references/completeness-anti-patterns.md +572 -0
  167. claude_mpm/skills/bundled/testing/testing-anti-patterns/references/core-anti-patterns.md +411 -0
  168. claude_mpm/skills/bundled/testing/testing-anti-patterns/references/detection-guide.md +569 -0
  169. claude_mpm/skills/bundled/testing/testing-anti-patterns/references/tdd-connection.md +695 -0
  170. claude_mpm/skills/bundled/testing/webapp-testing/SKILL.md +184 -0
  171. claude_mpm/skills/bundled/testing/webapp-testing/decision-tree.md +459 -0
  172. claude_mpm/skills/bundled/testing/webapp-testing/examples/console_logging.py +35 -0
  173. claude_mpm/skills/bundled/testing/webapp-testing/examples/element_discovery.py +44 -0
  174. claude_mpm/skills/bundled/testing/webapp-testing/examples/static_html_automation.py +34 -0
  175. claude_mpm/skills/bundled/testing/webapp-testing/playwright-patterns.md +479 -0
  176. claude_mpm/skills/bundled/testing/webapp-testing/reconnaissance-pattern.md +687 -0
  177. claude_mpm/skills/bundled/testing/webapp-testing/scripts/with_server.py +129 -0
  178. claude_mpm/skills/bundled/testing/webapp-testing/server-management.md +758 -0
  179. claude_mpm/skills/bundled/testing/webapp-testing/troubleshooting.md +868 -0
  180. claude_mpm/skills/bundled/vite-local-dev.md +1061 -0
  181. claude_mpm/skills/bundled/web-performance-optimization.md +2305 -0
  182. claude_mpm/skills/bundled/xlsx.md +157 -0
  183. claude_mpm/skills/registry.py +97 -9
  184. claude_mpm/skills/skills_registry.py +348 -0
  185. claude_mpm/skills/skills_service.py +739 -0
  186. claude_mpm/utils/agent_dependency_loader.py +2 -2
  187. {claude_mpm-4.15.6.dist-info → claude_mpm-4.21.0.dist-info}/METADATA +211 -33
  188. {claude_mpm-4.15.6.dist-info → claude_mpm-4.21.0.dist-info}/RECORD +192 -60
  189. claude_mpm/agents/INSTRUCTIONS_OLD_DEPRECATED.md +0 -602
  190. claude_mpm/cli/commands/mpm_init.py +0 -2008
  191. {claude_mpm-4.15.6.dist-info → claude_mpm-4.21.0.dist-info}/WHEEL +0 -0
  192. {claude_mpm-4.15.6.dist-info → claude_mpm-4.21.0.dist-info}/entry_points.txt +0 -0
  193. {claude_mpm-4.15.6.dist-info → claude_mpm-4.21.0.dist-info}/licenses/LICENSE +0 -0
  194. {claude_mpm-4.15.6.dist-info → claude_mpm-4.21.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,396 @@
1
+ """
2
+ MPM-Init Command - Initialize projects for optimal Claude Code and Claude MPM success.
3
+
4
+ This command delegates to the Agentic Coder Optimizer agent to establish clear,
5
+ single-path project standards for documentation, tooling, and workflows.
6
+
7
+ Enhanced with AST inspection capabilities for generating comprehensive developer
8
+ documentation with code structure analysis.
9
+ """
10
+
11
+ import sys
12
+ from pathlib import Path
13
+
14
+ import click
15
+ from rich.console import Console
16
+ from rich.prompt import Confirm
17
+ from rich.table import Table
18
+
19
+ # Import the core command class from the mpm_init subpackage
20
+ from claude_mpm.cli.commands.mpm_init.core import MPMInitCommand
21
+ from claude_mpm.core.enums import OperationResult
22
+
23
+ console = Console()
24
+
25
+
26
+ @click.group(name="mpm-init", invoke_without_command=True)
27
+ @click.option(
28
+ "--project-type",
29
+ type=click.Choice(
30
+ ["web", "api", "cli", "library", "mobile", "desktop", "fullstack"]
31
+ ),
32
+ help="Type of project to initialize",
33
+ )
34
+ @click.option(
35
+ "--framework",
36
+ type=str,
37
+ help="Specific framework (e.g., react, django, fastapi, express)",
38
+ )
39
+ @click.option(
40
+ "--force",
41
+ is_flag=True,
42
+ help="Force reinitialization even if project is already configured",
43
+ )
44
+ @click.option(
45
+ "--update",
46
+ is_flag=True,
47
+ help="Update existing CLAUDE.md instead of recreating",
48
+ )
49
+ @click.option(
50
+ "--review",
51
+ is_flag=True,
52
+ help="Review project state without making changes",
53
+ )
54
+ @click.option(
55
+ "--organize",
56
+ is_flag=True,
57
+ help="Automatically organize misplaced files into proper directories",
58
+ )
59
+ @click.option(
60
+ "--auto-safe/--no-auto-safe",
61
+ default=True,
62
+ help="Only move files with high confidence (default: safe mode on)",
63
+ )
64
+ @click.option(
65
+ "--preserve-custom/--no-preserve-custom",
66
+ default=True,
67
+ help="Preserve custom sections when updating (default: preserve)",
68
+ )
69
+ @click.option(
70
+ "--skip-archive",
71
+ is_flag=True,
72
+ help="Skip archiving existing files before updating",
73
+ )
74
+ @click.option(
75
+ "--verbose", is_flag=True, help="Show detailed output during initialization"
76
+ )
77
+ @click.option(
78
+ "--ast-analysis/--no-ast-analysis",
79
+ default=True,
80
+ help="Enable/disable AST analysis for enhanced documentation (default: enabled)",
81
+ )
82
+ @click.option(
83
+ "--quick-update",
84
+ is_flag=True,
85
+ help="Perform lightweight update based on recent git activity (default: 30 days)",
86
+ )
87
+ @click.option(
88
+ "--catchup",
89
+ is_flag=True,
90
+ help="Show recent commit history from all branches for PM context",
91
+ )
92
+ @click.option(
93
+ "--non-interactive",
94
+ is_flag=True,
95
+ help="Non-interactive mode - display report only without prompting (use with --quick-update)",
96
+ )
97
+ @click.option(
98
+ "--days",
99
+ type=int,
100
+ default=30,
101
+ help="Number of days for git history analysis in quick update mode (default: 30)",
102
+ )
103
+ @click.option(
104
+ "--export",
105
+ type=str,
106
+ default=None,
107
+ help="Export activity report to file (default: docs/reports/activity-report-{timestamp}.md)",
108
+ )
109
+ @click.argument(
110
+ "project_path",
111
+ type=click.Path(exists=True, file_okay=False, dir_okay=True),
112
+ required=False,
113
+ default=".",
114
+ )
115
+ @click.pass_context
116
+ def mpm_init(
117
+ ctx,
118
+ project_type,
119
+ framework,
120
+ force,
121
+ update,
122
+ review,
123
+ organize,
124
+ auto_safe,
125
+ preserve_custom,
126
+ skip_archive,
127
+ verbose,
128
+ ast_analysis,
129
+ quick_update,
130
+ catchup,
131
+ non_interactive,
132
+ days,
133
+ export,
134
+ project_path,
135
+ ):
136
+ """
137
+ Initialize or update a project for optimal use with Claude Code and Claude MPM.
138
+
139
+ This command uses the Agentic Coder Optimizer agent to:
140
+ - Create or update comprehensive CLAUDE.md documentation
141
+ - Establish single-path workflows (ONE way to do ANYTHING)
142
+ - Configure development tools and standards
143
+ - Set up memory systems for project knowledge
144
+ - Optimize for AI agent understanding
145
+ - Perform AST analysis for enhanced developer documentation
146
+
147
+ Context Management:
148
+ - resume: Analyze git history to provide context for resuming work
149
+ - --catchup: Show recent commit history for PM context
150
+
151
+ Update Mode:
152
+ When CLAUDE.md exists, the command offers to update rather than recreate,
153
+ preserving custom content while refreshing standard sections.
154
+
155
+ Examples:
156
+ claude-mpm mpm-init # Initialize/update current directory
157
+ claude-mpm mpm-init --catchup # Show recent git history for context
158
+ claude-mpm mpm-init --review # Review project state without changes
159
+ claude-mpm mpm-init --update # Force update mode
160
+ claude-mpm mpm-init --organize # Organize misplaced files
161
+ claude-mpm mpm-init --project-type web # Initialize as web project
162
+ claude-mpm mpm-init /path/to/project --force # Force reinitialize project
163
+ """
164
+ # If a subcommand is being invoked, don't run the main command
165
+ if ctx.invoked_subcommand is not None:
166
+ return
167
+
168
+ try:
169
+ # Create command instance
170
+ command = MPMInitCommand(Path(project_path))
171
+
172
+ # Run initialization (now synchronous)
173
+ result = command.initialize_project(
174
+ project_type=project_type,
175
+ framework=framework,
176
+ force=force,
177
+ verbose=verbose,
178
+ ast_analysis=ast_analysis,
179
+ update_mode=update,
180
+ review_only=review,
181
+ organize_files=organize,
182
+ preserve_custom=preserve_custom,
183
+ skip_archive=skip_archive,
184
+ quick_update=quick_update,
185
+ catchup=catchup,
186
+ non_interactive=non_interactive,
187
+ days=days,
188
+ export=export,
189
+ )
190
+
191
+ # Exit with appropriate code
192
+ if result["status"] == OperationResult.SUCCESS:
193
+ sys.exit(0)
194
+ else:
195
+ sys.exit(1)
196
+
197
+ except KeyboardInterrupt:
198
+ console.print("\n[yellow]Initialization cancelled by user[/yellow]")
199
+ sys.exit(130)
200
+ except Exception as e:
201
+ console.print(f"[red]Initialization failed: {e}[/red]")
202
+ sys.exit(1)
203
+
204
+
205
+ @mpm_init.command(name="context")
206
+ @click.option(
207
+ "--session-id",
208
+ "-i",
209
+ type=str,
210
+ help="Unused (for compatibility) - will be removed in future version",
211
+ )
212
+ @click.option(
213
+ "--days",
214
+ type=int,
215
+ default=7,
216
+ help="Number of days of git history to analyze (default: 7)",
217
+ )
218
+ @click.argument(
219
+ "project_path",
220
+ type=click.Path(exists=True, file_okay=False, dir_okay=True),
221
+ required=False,
222
+ default=".",
223
+ )
224
+ def context_command(session_id, days, project_path):
225
+ """
226
+ Provide intelligent context for resuming work based on git history.
227
+
228
+ Analyzes recent git history and generates a Research agent delegation
229
+ prompt for intelligent project context reconstruction.
230
+
231
+ Examples:
232
+ claude-mpm mpm-init context # Analyze last 7 days
233
+ claude-mpm mpm-init context --days 14 # Analyze last 14 days
234
+ claude-mpm mpm-init context --days 30 # Analyze last 30 days
235
+
236
+ Note: 'resume' is deprecated, use 'context' instead.
237
+ """
238
+ try:
239
+ command = MPMInitCommand(Path(project_path))
240
+
241
+ result = command.handle_context(session_id=session_id, days=days)
242
+
243
+ if (
244
+ result["status"] == OperationResult.SUCCESS
245
+ or result["status"] == OperationResult.CONTEXT_READY
246
+ ):
247
+ sys.exit(0)
248
+ else:
249
+ sys.exit(1)
250
+
251
+ except KeyboardInterrupt:
252
+ console.print("\n[yellow]Context analysis cancelled by user[/yellow]")
253
+ sys.exit(130)
254
+ except Exception as e:
255
+ console.print(f"[red]Context analysis failed: {e}[/red]")
256
+ sys.exit(1)
257
+
258
+
259
+ # Resume command - NEW: reads from stop event logs
260
+ @mpm_init.command(name="resume")
261
+ @click.option(
262
+ "--list",
263
+ "list_sessions",
264
+ is_flag=True,
265
+ help="List available sessions from logs",
266
+ )
267
+ @click.option(
268
+ "--session-id",
269
+ "-s",
270
+ type=str,
271
+ help="Resume specific session by ID",
272
+ )
273
+ @click.option(
274
+ "--last",
275
+ type=int,
276
+ help="Show last N sessions",
277
+ )
278
+ @click.argument(
279
+ "project_path",
280
+ type=click.Path(exists=True, file_okay=False, dir_okay=True),
281
+ required=False,
282
+ default=".",
283
+ )
284
+ def resume_command(list_sessions, session_id, last, project_path):
285
+ """
286
+ Resume work from previous session using stop event logs.
287
+
288
+ Reads from:
289
+ - .claude-mpm/resume-logs/ (structured summaries, preferred)
290
+ - .claude-mpm/responses/ (raw conversation logs, fallback)
291
+
292
+ Examples:
293
+ claude-mpm mpm-init resume # Show latest session
294
+ claude-mpm mpm-init resume --list # List all sessions
295
+ claude-mpm mpm-init resume --session-id ID # Resume specific session
296
+ claude-mpm mpm-init resume --last 5 # Show last 5 sessions
297
+ """
298
+ from claude_mpm.services.cli.resume_service import ResumeService
299
+
300
+ try:
301
+ service = ResumeService(Path(project_path))
302
+
303
+ # Handle --list flag
304
+ if list_sessions:
305
+ sessions = service.list_sessions()
306
+ if not sessions:
307
+ console.print("[yellow]No sessions found in response logs.[/yellow]")
308
+ console.print(
309
+ "[dim]Sessions are stored in .claude-mpm/responses/[/dim]\n"
310
+ )
311
+ sys.exit(1)
312
+
313
+ # Limit by --last if specified
314
+ if last and last > 0:
315
+ sessions = sessions[:last]
316
+
317
+ console.print(
318
+ f"\n[bold cyan]📋 Available Sessions ({len(sessions)})[/bold cyan]\n"
319
+ )
320
+
321
+ table = Table(show_header=True, header_style="bold magenta")
322
+ table.add_column("Session ID", style="cyan", width=25)
323
+ table.add_column("Time", style="yellow", width=20)
324
+ table.add_column("Agent", style="green", width=15)
325
+ table.add_column("Stop Reason", style="white", width=20)
326
+ table.add_column("Tokens", style="dim", width=10)
327
+
328
+ for session in sessions:
329
+ time_str = session.timestamp.strftime("%Y-%m-%d %H:%M")
330
+ tokens_str = (
331
+ f"{session.token_usage // 1000}k"
332
+ if session.token_usage > 0
333
+ else "-"
334
+ )
335
+
336
+ table.add_row(
337
+ session.session_id,
338
+ time_str,
339
+ session.last_agent,
340
+ session.stop_reason,
341
+ tokens_str,
342
+ )
343
+
344
+ console.print(table)
345
+ console.print()
346
+ sys.exit(0)
347
+
348
+ # Handle --session-id
349
+ if session_id:
350
+ context = service.get_session_context(session_id)
351
+ if not context:
352
+ console.print(f"[red]Session '{session_id}' not found.[/red]")
353
+ console.print("[dim]Use --list to see available sessions.[/dim]\n")
354
+ sys.exit(1)
355
+ else:
356
+ # Default: get latest session
357
+ context = service.get_latest_session()
358
+ if not context:
359
+ console.print("[yellow]No sessions found in logs.[/yellow]")
360
+ console.print(
361
+ "[dim]Sessions are stored in .claude-mpm/responses/[/dim]\n"
362
+ )
363
+ sys.exit(1)
364
+
365
+ # Display context
366
+ display_text = service.format_resume_display(context)
367
+ console.print(display_text)
368
+
369
+ # Ask if user wants to continue
370
+ should_continue = Confirm.ask(
371
+ "\n[bold]Would you like to continue this work?[/bold]", default=True
372
+ )
373
+
374
+ if should_continue:
375
+ console.print(
376
+ "\n[green]✅ Great! Use this context to continue your work.[/green]\n"
377
+ )
378
+ sys.exit(0)
379
+ else:
380
+ console.print("\n[cyan]Starting fresh session instead.[/cyan]\n")
381
+ sys.exit(0)
382
+
383
+ except KeyboardInterrupt:
384
+ console.print("\n[yellow]Resume cancelled by user[/yellow]")
385
+ sys.exit(130)
386
+ except Exception as e:
387
+ from claude_mpm.core.logging_utils import get_logger
388
+
389
+ logger = get_logger(__name__)
390
+ logger.error(f"Resume failed: {e}")
391
+ console.print(f"[red]Resume failed: {e}[/red]")
392
+ sys.exit(1)
393
+
394
+
395
+ # Export for CLI registration
396
+ __all__ = ["mpm_init"]
@@ -25,7 +25,7 @@ def manage_mpm_init(args):
25
25
  """
26
26
  try:
27
27
  # Import the command implementation
28
- from .mpm_init import MPMInitCommand
28
+ from .mpm_init.core import MPMInitCommand
29
29
 
30
30
  # Handle context subcommands
31
31
  subcommand = getattr(args, "subcommand", None)
@@ -60,6 +60,72 @@ def manage_mpm_init(args):
60
60
  return 0
61
61
  return 1
62
62
 
63
+ if subcommand == "pause":
64
+ # Handle pause subcommand
65
+ from datetime import datetime, timezone
66
+
67
+ from claude_mpm.services.cli.session_pause_manager import (
68
+ SessionPauseManager,
69
+ )
70
+
71
+ # Get project path
72
+ project_path = (
73
+ Path(args.project_path) if hasattr(args, "project_path") else Path.cwd()
74
+ )
75
+
76
+ console.print("\n[cyan]Creating session pause...[/cyan]")
77
+
78
+ # Create pause session
79
+ pause_manager = SessionPauseManager(project_path)
80
+ session_id = pause_manager.create_pause_session(
81
+ message=getattr(args, "message", None),
82
+ skip_commit=getattr(args, "no_commit", False),
83
+ export_path=getattr(args, "export", None),
84
+ )
85
+
86
+ # Display success message
87
+ console.print()
88
+ console.print("[green]✅ Session Paused Successfully[/green]", style="bold")
89
+ console.print()
90
+ console.print(f"[cyan]Session ID:[/cyan] {session_id}")
91
+ console.print(
92
+ f"[cyan]Paused At:[/cyan] {datetime.now(timezone.utc).strftime('%Y-%m-%d %H:%M:%S %Z')}"
93
+ )
94
+ console.print(f"[cyan]Location:[/cyan] .claude-mpm/sessions/{session_id}.*")
95
+
96
+ # Show what was captured
97
+ console.print()
98
+ console.print("[blue]📝 Files Created:[/blue]")
99
+ console.print(f" • [dim]{session_id}.json[/dim] - Machine-readable data")
100
+ console.print(f" • [dim]{session_id}.yaml[/dim] - Human-readable config")
101
+ console.print(f" • [dim]{session_id}.md[/dim] - Full documentation")
102
+ console.print(" • [dim]LATEST-SESSION.txt[/dim] - Quick reference pointer")
103
+
104
+ # Git commit info
105
+ if not getattr(args, "no_commit", False) and pause_manager._is_git_repo():
106
+ console.print()
107
+ console.print("[green]✓[/green] Git commit created")
108
+
109
+ # Export info
110
+ if getattr(args, "export", None):
111
+ console.print()
112
+ console.print(f"[green]✓[/green] Exported to: {args.export}")
113
+
114
+ # Show message if provided
115
+ if getattr(args, "message", None):
116
+ console.print()
117
+ console.print(f"[yellow]Context:[/yellow] {args.message}")
118
+
119
+ # Resume instructions
120
+ console.print()
121
+ console.print("[yellow]Resume with:[/yellow] claude-mpm mpm-init context")
122
+ console.print(
123
+ "[yellow]Quick view:[/yellow] cat .claude-mpm/sessions/LATEST-SESSION.txt"
124
+ )
125
+ console.print()
126
+
127
+ return 0
128
+
63
129
  # Handle special flags
64
130
  if getattr(args, "list_templates", False):
65
131
  # List available templates