moai-adk 0.25.4__py3-none-any.whl → 0.32.8__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 moai-adk might be problematic. Click here for more details.

Files changed (378) hide show
  1. moai_adk/__init__.py +2 -5
  2. moai_adk/__main__.py +114 -82
  3. moai_adk/cli/__init__.py +6 -1
  4. moai_adk/cli/commands/__init__.py +1 -3
  5. moai_adk/cli/commands/analyze.py +5 -16
  6. moai_adk/cli/commands/doctor.py +6 -18
  7. moai_adk/cli/commands/init.py +56 -125
  8. moai_adk/cli/commands/language.py +14 -35
  9. moai_adk/cli/commands/status.py +9 -15
  10. moai_adk/cli/commands/update.py +1555 -190
  11. moai_adk/cli/prompts/init_prompts.py +112 -56
  12. moai_adk/cli/spec_status.py +263 -0
  13. moai_adk/cli/ui/__init__.py +44 -0
  14. moai_adk/cli/ui/progress.py +422 -0
  15. moai_adk/cli/ui/prompts.py +389 -0
  16. moai_adk/cli/ui/theme.py +129 -0
  17. moai_adk/cli/worktree/__init__.py +27 -0
  18. moai_adk/cli/worktree/__main__.py +31 -0
  19. moai_adk/cli/worktree/cli.py +672 -0
  20. moai_adk/cli/worktree/exceptions.py +89 -0
  21. moai_adk/cli/worktree/manager.py +490 -0
  22. moai_adk/cli/worktree/models.py +65 -0
  23. moai_adk/cli/worktree/registry.py +128 -0
  24. moai_adk/core/PHASE2_OPTIMIZATIONS.md +467 -0
  25. moai_adk/core/analysis/session_analyzer.py +17 -56
  26. moai_adk/core/claude_integration.py +26 -54
  27. moai_adk/core/command_helpers.py +10 -10
  28. moai_adk/core/comprehensive_monitoring_system.py +1183 -0
  29. moai_adk/core/config/auto_spec_config.py +5 -11
  30. moai_adk/core/config/migration.py +19 -9
  31. moai_adk/core/config/unified.py +436 -0
  32. moai_adk/core/context_manager.py +6 -12
  33. moai_adk/core/enterprise_features.py +1404 -0
  34. moai_adk/core/error_recovery_system.py +725 -112
  35. moai_adk/core/event_driven_hook_system.py +1371 -0
  36. moai_adk/core/git/__init__.py +8 -0
  37. moai_adk/core/git/branch_manager.py +3 -11
  38. moai_adk/core/git/checkpoint.py +1 -3
  39. moai_adk/core/git/conflict_detector.py +413 -0
  40. moai_adk/core/git/manager.py +91 -1
  41. moai_adk/core/hooks/post_tool_auto_spec_completion.py +56 -80
  42. moai_adk/core/input_validation_middleware.py +1006 -0
  43. moai_adk/core/integration/engine.py +6 -18
  44. moai_adk/core/integration/integration_tester.py +10 -9
  45. moai_adk/core/integration/utils.py +1 -1
  46. moai_adk/core/issue_creator.py +10 -28
  47. moai_adk/core/jit_context_loader.py +956 -0
  48. moai_adk/core/jit_enhanced_hook_manager.py +1987 -0
  49. moai_adk/core/language_config_resolver.py +485 -0
  50. moai_adk/core/language_validator.py +28 -41
  51. moai_adk/core/mcp/setup.py +15 -12
  52. moai_adk/core/merge/__init__.py +9 -0
  53. moai_adk/core/merge/analyzer.py +481 -0
  54. moai_adk/core/migration/alfred_to_moai_migrator.py +383 -0
  55. moai_adk/core/migration/backup_manager.py +78 -9
  56. moai_adk/core/migration/custom_element_scanner.py +358 -0
  57. moai_adk/core/migration/file_migrator.py +8 -17
  58. moai_adk/core/migration/interactive_checkbox_ui.py +488 -0
  59. moai_adk/core/migration/selective_restorer.py +470 -0
  60. moai_adk/core/migration/template_utils.py +74 -0
  61. moai_adk/core/migration/user_selection_ui.py +338 -0
  62. moai_adk/core/migration/version_detector.py +6 -10
  63. moai_adk/core/migration/version_migrator.py +3 -3
  64. moai_adk/core/performance/cache_system.py +8 -10
  65. moai_adk/core/phase_optimized_hook_scheduler.py +879 -0
  66. moai_adk/core/project/checker.py +2 -4
  67. moai_adk/core/project/detector.py +1 -3
  68. moai_adk/core/project/initializer.py +135 -23
  69. moai_adk/core/project/phase_executor.py +54 -81
  70. moai_adk/core/project/validator.py +6 -12
  71. moai_adk/core/quality/trust_checker.py +9 -27
  72. moai_adk/core/realtime_monitoring_dashboard.py +1724 -0
  73. moai_adk/core/robust_json_parser.py +611 -0
  74. moai_adk/core/rollback_manager.py +73 -148
  75. moai_adk/core/session_manager.py +10 -26
  76. moai_adk/core/skill_loading_system.py +579 -0
  77. moai_adk/core/spec/confidence_scoring.py +31 -100
  78. moai_adk/core/spec/ears_template_engine.py +351 -286
  79. moai_adk/core/spec/quality_validator.py +35 -69
  80. moai_adk/core/spec_status_manager.py +64 -74
  81. moai_adk/core/template/backup.py +45 -20
  82. moai_adk/core/template/config.py +112 -39
  83. moai_adk/core/template/merger.py +11 -19
  84. moai_adk/core/template/processor.py +253 -149
  85. moai_adk/core/template_engine.py +73 -40
  86. moai_adk/core/template_variable_synchronizer.py +417 -0
  87. moai_adk/core/unified_permission_manager.py +745 -0
  88. moai_adk/core/user_behavior_analytics.py +851 -0
  89. moai_adk/core/version_sync.py +429 -0
  90. moai_adk/foundation/__init__.py +56 -0
  91. moai_adk/foundation/backend.py +1027 -0
  92. moai_adk/foundation/database.py +1115 -0
  93. moai_adk/foundation/devops.py +1585 -0
  94. moai_adk/foundation/ears.py +431 -0
  95. moai_adk/foundation/frontend.py +870 -0
  96. moai_adk/foundation/git/commit_templates.py +4 -12
  97. moai_adk/foundation/git.py +376 -0
  98. moai_adk/foundation/langs.py +484 -0
  99. moai_adk/foundation/ml_ops.py +1162 -0
  100. moai_adk/foundation/testing.py +1524 -0
  101. moai_adk/foundation/trust/trust_principles.py +23 -72
  102. moai_adk/foundation/trust/validation_checklist.py +57 -162
  103. moai_adk/project/__init__.py +0 -0
  104. moai_adk/project/configuration.py +1084 -0
  105. moai_adk/project/documentation.py +566 -0
  106. moai_adk/project/schema.py +447 -0
  107. moai_adk/statusline/alfred_detector.py +1 -3
  108. moai_adk/statusline/config.py +13 -4
  109. moai_adk/statusline/enhanced_output_style_detector.py +23 -15
  110. moai_adk/statusline/main.py +51 -15
  111. moai_adk/statusline/renderer.py +104 -48
  112. moai_adk/statusline/update_checker.py +3 -9
  113. moai_adk/statusline/version_reader.py +140 -46
  114. moai_adk/templates/.claude/agents/moai/ai-nano-banana.md +549 -0
  115. moai_adk/templates/.claude/agents/moai/builder-agent.md +445 -0
  116. moai_adk/templates/.claude/agents/moai/builder-command.md +1132 -0
  117. moai_adk/templates/.claude/agents/moai/builder-skill.md +601 -0
  118. moai_adk/templates/.claude/agents/moai/expert-backend.md +831 -0
  119. moai_adk/templates/.claude/agents/moai/expert-database.md +774 -0
  120. moai_adk/templates/.claude/agents/moai/expert-debug.md +396 -0
  121. moai_adk/templates/.claude/agents/moai/expert-devops.md +711 -0
  122. moai_adk/templates/.claude/agents/moai/expert-frontend.md +666 -0
  123. moai_adk/templates/.claude/agents/moai/expert-security.md +474 -0
  124. moai_adk/templates/.claude/agents/moai/expert-uiux.md +1038 -0
  125. moai_adk/templates/.claude/agents/moai/manager-claude-code.md +429 -0
  126. moai_adk/templates/.claude/agents/moai/manager-docs.md +570 -0
  127. moai_adk/templates/.claude/agents/moai/manager-git.md +937 -0
  128. moai_adk/templates/.claude/agents/moai/manager-project.md +891 -0
  129. moai_adk/templates/.claude/agents/moai/manager-quality.md +598 -0
  130. moai_adk/templates/.claude/agents/moai/manager-spec.md +713 -0
  131. moai_adk/templates/.claude/agents/moai/manager-strategy.md +600 -0
  132. moai_adk/templates/.claude/agents/moai/manager-tdd.md +603 -0
  133. moai_adk/templates/.claude/agents/moai/mcp-context7.md +369 -0
  134. moai_adk/templates/.claude/agents/moai/mcp-figma.md +1567 -0
  135. moai_adk/templates/.claude/agents/moai/mcp-notion.md +749 -0
  136. moai_adk/templates/.claude/agents/moai/mcp-playwright.md +427 -0
  137. moai_adk/templates/.claude/agents/moai/mcp-sequential-thinking.md +994 -0
  138. moai_adk/templates/.claude/commands/moai/0-project.md +1143 -0
  139. moai_adk/templates/.claude/commands/moai/1-plan.md +1435 -0
  140. moai_adk/templates/.claude/commands/moai/2-run.md +883 -0
  141. moai_adk/templates/.claude/commands/moai/3-sync.md +993 -0
  142. moai_adk/templates/.claude/commands/moai/9-feedback.md +314 -0
  143. moai_adk/templates/.claude/hooks/__init__.py +8 -0
  144. moai_adk/templates/.claude/hooks/moai/__init__.py +8 -0
  145. moai_adk/templates/.claude/hooks/moai/lib/__init__.py +85 -0
  146. moai_adk/templates/.claude/hooks/moai/lib/checkpoint.py +244 -0
  147. moai_adk/templates/.claude/hooks/moai/lib/common.py +131 -0
  148. moai_adk/templates/.claude/hooks/moai/lib/config_manager.py +446 -0
  149. moai_adk/templates/.claude/hooks/moai/lib/config_validator.py +639 -0
  150. moai_adk/templates/.claude/hooks/moai/lib/example_config.json +104 -0
  151. moai_adk/templates/.claude/hooks/moai/lib/git_operations_manager.py +590 -0
  152. moai_adk/templates/.claude/hooks/moai/lib/language_validator.py +317 -0
  153. moai_adk/templates/.claude/hooks/moai/lib/models.py +102 -0
  154. moai_adk/templates/.claude/hooks/moai/lib/path_utils.py +28 -0
  155. moai_adk/templates/.claude/hooks/moai/lib/project.py +768 -0
  156. moai_adk/templates/.claude/hooks/moai/lib/test_hooks_improvements.py +443 -0
  157. moai_adk/templates/.claude/hooks/moai/lib/timeout.py +160 -0
  158. moai_adk/templates/.claude/hooks/moai/lib/unified_timeout_manager.py +530 -0
  159. moai_adk/templates/.claude/hooks/moai/session_end__auto_cleanup.py +862 -0
  160. moai_adk/templates/.claude/hooks/moai/session_start__show_project_info.py +921 -0
  161. moai_adk/templates/.claude/output-styles/moai/r2d2.md +380 -0
  162. moai_adk/templates/.claude/output-styles/moai/yoda.md +338 -0
  163. moai_adk/templates/.claude/settings.json +172 -0
  164. moai_adk/templates/.claude/skills/moai-docs-generation/SKILL.md +247 -0
  165. moai_adk/templates/.claude/skills/moai-docs-generation/modules/README.md +44 -0
  166. moai_adk/templates/.claude/skills/moai-docs-generation/modules/api-documentation.md +130 -0
  167. moai_adk/templates/.claude/skills/moai-docs-generation/modules/code-documentation.md +152 -0
  168. moai_adk/templates/.claude/skills/moai-docs-generation/modules/multi-format-output.md +178 -0
  169. moai_adk/templates/.claude/skills/moai-docs-generation/modules/user-guides.md +147 -0
  170. moai_adk/templates/.claude/skills/moai-domain-backend/SKILL.md +319 -0
  171. moai_adk/templates/.claude/skills/moai-domain-database/SKILL.md +320 -0
  172. moai_adk/templates/.claude/skills/moai-domain-database/modules/README.md +53 -0
  173. moai_adk/templates/.claude/skills/moai-domain-database/modules/mongodb.md +231 -0
  174. moai_adk/templates/.claude/skills/moai-domain-database/modules/postgresql.md +169 -0
  175. moai_adk/templates/.claude/skills/moai-domain-database/modules/redis.md +262 -0
  176. moai_adk/templates/.claude/skills/moai-domain-frontend/SKILL.md +496 -0
  177. moai_adk/templates/.claude/skills/moai-domain-uiux/SKILL.md +453 -0
  178. moai_adk/templates/.claude/skills/moai-domain-uiux/examples.md +560 -0
  179. moai_adk/templates/.claude/skills/moai-domain-uiux/modules/accessibility-wcag.md +260 -0
  180. moai_adk/templates/.claude/skills/moai-domain-uiux/modules/component-architecture.md +228 -0
  181. moai_adk/templates/.claude/skills/moai-domain-uiux/modules/design-system-tokens.md +405 -0
  182. moai_adk/templates/.claude/skills/moai-domain-uiux/modules/icon-libraries.md +401 -0
  183. moai_adk/templates/.claude/skills/moai-domain-uiux/modules/theming-system.md +373 -0
  184. moai_adk/templates/.claude/skills/moai-domain-uiux/reference.md +243 -0
  185. moai_adk/templates/.claude/skills/moai-formats-data/SKILL.md +491 -0
  186. moai_adk/templates/.claude/skills/moai-formats-data/modules/README.md +98 -0
  187. moai_adk/templates/.claude/skills/moai-formats-data/modules/SKILL-MODULARIZATION-TEMPLATE.md +278 -0
  188. moai_adk/templates/.claude/skills/moai-formats-data/modules/caching-performance.md +459 -0
  189. moai_adk/templates/.claude/skills/moai-formats-data/modules/data-validation.md +485 -0
  190. moai_adk/templates/.claude/skills/moai-formats-data/modules/json-optimization.md +374 -0
  191. moai_adk/templates/.claude/skills/moai-formats-data/modules/toon-encoding.md +308 -0
  192. moai_adk/templates/.claude/skills/moai-foundation-claude/SKILL.md +201 -0
  193. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/best-practices-checklist.md +616 -0
  194. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-custom-slash-commands-official.md +729 -0
  195. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-hooks-official.md +560 -0
  196. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-iam-official.md +635 -0
  197. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-memory-official.md +543 -0
  198. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-settings-official.md +663 -0
  199. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-skills-official.md +113 -0
  200. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-sub-agents-official.md +238 -0
  201. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/complete-configuration-guide.md +175 -0
  202. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/skill-examples.md +1674 -0
  203. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/skill-formatting-guide.md +729 -0
  204. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/sub-agents/sub-agent-examples.md +1513 -0
  205. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/sub-agents/sub-agent-formatting-guide.md +1086 -0
  206. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/sub-agents/sub-agent-integration-patterns.md +1100 -0
  207. moai_adk/templates/.claude/skills/moai-foundation-context/SKILL.md +438 -0
  208. moai_adk/templates/.claude/skills/moai-foundation-core/SKILL.md +515 -0
  209. moai_adk/templates/.claude/skills/moai-foundation-core/modules/README.md +296 -0
  210. moai_adk/templates/.claude/skills/moai-foundation-core/modules/agents-reference.md +346 -0
  211. moai_adk/templates/.claude/skills/moai-foundation-core/modules/commands-reference.md +432 -0
  212. moai_adk/templates/.claude/skills/moai-foundation-core/modules/delegation-patterns.md +757 -0
  213. moai_adk/templates/.claude/skills/moai-foundation-core/modules/execution-rules.md +687 -0
  214. moai_adk/templates/.claude/skills/moai-foundation-core/modules/modular-system.md +665 -0
  215. moai_adk/templates/.claude/skills/moai-foundation-core/modules/progressive-disclosure.md +649 -0
  216. moai_adk/templates/.claude/skills/moai-foundation-core/modules/spec-first-tdd.md +864 -0
  217. moai_adk/templates/.claude/skills/moai-foundation-core/modules/token-optimization.md +708 -0
  218. moai_adk/templates/.claude/skills/moai-foundation-core/modules/trust-5-framework.md +981 -0
  219. moai_adk/templates/.claude/skills/moai-foundation-quality/SKILL.md +362 -0
  220. moai_adk/templates/.claude/skills/moai-foundation-quality/examples.md +1232 -0
  221. moai_adk/templates/.claude/skills/moai-foundation-quality/modules/best-practices.md +261 -0
  222. moai_adk/templates/.claude/skills/moai-foundation-quality/modules/integration-patterns.md +194 -0
  223. moai_adk/templates/.claude/skills/moai-foundation-quality/modules/proactive-analysis.md +229 -0
  224. moai_adk/templates/.claude/skills/moai-foundation-quality/modules/trust5-validation.md +169 -0
  225. moai_adk/templates/.claude/skills/moai-foundation-quality/reference.md +1266 -0
  226. moai_adk/templates/.claude/skills/moai-foundation-quality/scripts/quality-gate.sh +668 -0
  227. moai_adk/templates/.claude/skills/moai-foundation-quality/templates/github-actions-quality.yml +481 -0
  228. moai_adk/templates/.claude/skills/moai-foundation-quality/templates/quality-config.yaml +519 -0
  229. moai_adk/templates/.claude/skills/moai-integration-mcp/SKILL.md +352 -0
  230. moai_adk/templates/.claude/skills/moai-integration-mcp/modules/README.md +52 -0
  231. moai_adk/templates/.claude/skills/moai-integration-mcp/modules/error-handling.md +334 -0
  232. moai_adk/templates/.claude/skills/moai-integration-mcp/modules/integration-patterns.md +310 -0
  233. moai_adk/templates/.claude/skills/moai-integration-mcp/modules/security-authentication.md +256 -0
  234. moai_adk/templates/.claude/skills/moai-integration-mcp/modules/server-architecture.md +253 -0
  235. moai_adk/templates/.claude/skills/moai-lang-unified/README.md +133 -0
  236. moai_adk/templates/.claude/skills/moai-lang-unified/SKILL.md +296 -0
  237. moai_adk/templates/.claude/skills/moai-lang-unified/examples.md +1269 -0
  238. moai_adk/templates/.claude/skills/moai-lang-unified/reference.md +331 -0
  239. moai_adk/templates/.claude/skills/moai-library-mermaid/SKILL.md +298 -0
  240. moai_adk/templates/.claude/skills/moai-library-mermaid/advanced-patterns.md +465 -0
  241. moai_adk/templates/.claude/skills/moai-library-mermaid/examples.md +270 -0
  242. moai_adk/templates/.claude/skills/moai-library-mermaid/optimization.md +440 -0
  243. moai_adk/templates/.claude/skills/moai-library-mermaid/reference.md +228 -0
  244. moai_adk/templates/.claude/skills/moai-library-nextra/SKILL.md +316 -0
  245. moai_adk/templates/.claude/skills/moai-library-nextra/advanced-patterns.md +336 -0
  246. moai_adk/templates/.claude/skills/moai-library-nextra/modules/advanced-deployment-patterns.md +182 -0
  247. moai_adk/templates/.claude/skills/moai-library-nextra/modules/advanced-patterns.md +17 -0
  248. moai_adk/templates/.claude/skills/moai-library-nextra/modules/configuration.md +57 -0
  249. moai_adk/templates/.claude/skills/moai-library-nextra/modules/content-architecture-optimization.md +162 -0
  250. moai_adk/templates/.claude/skills/moai-library-nextra/modules/deployment.md +52 -0
  251. moai_adk/templates/.claude/skills/moai-library-nextra/modules/framework-core-configuration.md +186 -0
  252. moai_adk/templates/.claude/skills/moai-library-nextra/modules/i18n-setup.md +55 -0
  253. moai_adk/templates/.claude/skills/moai-library-nextra/modules/mdx-components.md +52 -0
  254. moai_adk/templates/.claude/skills/moai-library-nextra/optimization.md +303 -0
  255. moai_adk/templates/.claude/skills/moai-library-shadcn/SKILL.md +370 -0
  256. moai_adk/templates/.claude/skills/moai-library-shadcn/examples.md +575 -0
  257. moai_adk/templates/.claude/skills/moai-library-shadcn/modules/advanced-patterns.md +394 -0
  258. moai_adk/templates/.claude/skills/moai-library-shadcn/modules/optimization.md +278 -0
  259. moai_adk/templates/.claude/skills/moai-library-shadcn/modules/shadcn-components.md +457 -0
  260. moai_adk/templates/.claude/skills/moai-library-shadcn/modules/shadcn-theming.md +373 -0
  261. moai_adk/templates/.claude/skills/moai-library-shadcn/reference.md +74 -0
  262. moai_adk/templates/.claude/skills/moai-platform-baas/README.md +186 -0
  263. moai_adk/templates/.claude/skills/moai-platform-baas/SKILL.md +290 -0
  264. moai_adk/templates/.claude/skills/moai-platform-baas/examples.md +1225 -0
  265. moai_adk/templates/.claude/skills/moai-platform-baas/reference.md +567 -0
  266. moai_adk/templates/.claude/skills/moai-platform-baas/scripts/provider-selector.py +323 -0
  267. moai_adk/templates/.claude/skills/moai-platform-baas/templates/stack-config.yaml +204 -0
  268. moai_adk/templates/.claude/skills/moai-workflow-jit-docs/SKILL.md +446 -0
  269. moai_adk/templates/.claude/skills/moai-workflow-jit-docs/advanced-patterns.md +379 -0
  270. moai_adk/templates/.claude/skills/moai-workflow-jit-docs/optimization.md +286 -0
  271. moai_adk/templates/.claude/skills/moai-workflow-project/README.md +190 -0
  272. moai_adk/templates/.claude/skills/moai-workflow-project/SKILL.md +387 -0
  273. moai_adk/templates/.claude/skills/moai-workflow-project/__init__.py +520 -0
  274. moai_adk/templates/.claude/skills/moai-workflow-project/complete_workflow_demo_fixed.py +574 -0
  275. moai_adk/templates/.claude/skills/moai-workflow-project/examples/complete_project_setup.py +317 -0
  276. moai_adk/templates/.claude/skills/moai-workflow-project/examples/complete_workflow_demo.py +663 -0
  277. moai_adk/templates/.claude/skills/moai-workflow-project/examples/config-migration-example.json +190 -0
  278. moai_adk/templates/.claude/skills/moai-workflow-project/examples/question-examples.json +135 -0
  279. moai_adk/templates/.claude/skills/moai-workflow-project/examples/quick_start.py +196 -0
  280. moai_adk/templates/.claude/skills/moai-workflow-project/modules/__init__.py +17 -0
  281. moai_adk/templates/.claude/skills/moai-workflow-project/modules/advanced-patterns.md +158 -0
  282. moai_adk/templates/.claude/skills/moai-workflow-project/modules/ask_user_integration.py +340 -0
  283. moai_adk/templates/.claude/skills/moai-workflow-project/modules/batch_questions.py +713 -0
  284. moai_adk/templates/.claude/skills/moai-workflow-project/modules/config_manager.py +538 -0
  285. moai_adk/templates/.claude/skills/moai-workflow-project/modules/documentation_manager.py +1336 -0
  286. moai_adk/templates/.claude/skills/moai-workflow-project/modules/language_initializer.py +730 -0
  287. moai_adk/templates/.claude/skills/moai-workflow-project/modules/migration_manager.py +608 -0
  288. moai_adk/templates/.claude/skills/moai-workflow-project/modules/template_optimizer.py +1005 -0
  289. moai_adk/templates/.claude/skills/moai-workflow-project/schemas/config-schema.json +316 -0
  290. moai_adk/templates/.claude/skills/moai-workflow-project/schemas/tab_schema.json +1362 -0
  291. moai_adk/templates/.claude/skills/moai-workflow-project/templates/config-template.json +71 -0
  292. moai_adk/templates/.claude/skills/moai-workflow-project/templates/doc-templates/product-template.md +44 -0
  293. moai_adk/templates/.claude/skills/moai-workflow-project/templates/doc-templates/structure-template.md +48 -0
  294. moai_adk/templates/.claude/skills/moai-workflow-project/templates/doc-templates/tech-template.md +71 -0
  295. moai_adk/templates/.claude/skills/moai-workflow-project/templates/question-templates/config-manager-setup.json +109 -0
  296. moai_adk/templates/.claude/skills/moai-workflow-project/templates/question-templates/language-initializer.json +228 -0
  297. moai_adk/templates/.claude/skills/moai-workflow-project/templates/question-templates/menu-project-config.json +130 -0
  298. moai_adk/templates/.claude/skills/moai-workflow-project/templates/question-templates/project-batch-questions.json +97 -0
  299. moai_adk/templates/.claude/skills/moai-workflow-project/templates/question-templates/spec-workflow-setup.json +150 -0
  300. moai_adk/templates/.claude/skills/moai-workflow-project/test_integration_simple.py +436 -0
  301. moai_adk/templates/.claude/skills/moai-workflow-templates/SKILL.md +374 -0
  302. moai_adk/templates/.claude/skills/moai-workflow-templates/modules/code-templates.md +124 -0
  303. moai_adk/templates/.claude/skills/moai-workflow-templates/modules/feedback-templates.md +100 -0
  304. moai_adk/templates/.claude/skills/moai-workflow-templates/modules/template-optimizer.md +138 -0
  305. moai_adk/templates/.claude/skills/moai-workflow-testing/LICENSE.txt +202 -0
  306. moai_adk/templates/.claude/skills/moai-workflow-testing/SKILL.md +453 -0
  307. moai_adk/templates/.claude/skills/moai-workflow-testing/advanced-patterns.md +576 -0
  308. moai_adk/templates/.claude/skills/moai-workflow-testing/examples/ai-powered-testing.py +294 -0
  309. moai_adk/templates/.claude/skills/moai-workflow-testing/examples/console_logging.py +35 -0
  310. moai_adk/templates/.claude/skills/moai-workflow-testing/examples/element_discovery.py +40 -0
  311. moai_adk/templates/.claude/skills/moai-workflow-testing/examples/static_html_automation.py +34 -0
  312. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/README.md +220 -0
  313. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/ai-debugging.md +845 -0
  314. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review.md +1416 -0
  315. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance-optimization.md +1234 -0
  316. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/smart-refactoring.md +1243 -0
  317. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/tdd-context7.md +1260 -0
  318. moai_adk/templates/.claude/skills/moai-workflow-testing/optimization.md +505 -0
  319. moai_adk/templates/.claude/skills/moai-workflow-testing/reference/playwright-best-practices.md +57 -0
  320. moai_adk/templates/.claude/skills/moai-workflow-testing/scripts/with_server.py +218 -0
  321. moai_adk/templates/.claude/skills/moai-workflow-testing/templates/alfred-integration.md +376 -0
  322. moai_adk/templates/.claude/skills/moai-workflow-testing/workflows/enterprise-testing-workflow.py +571 -0
  323. moai_adk/templates/.claude/skills/moai-worktree/SKILL.md +410 -0
  324. moai_adk/templates/.claude/skills/moai-worktree/examples.md +606 -0
  325. moai_adk/templates/.claude/skills/moai-worktree/modules/integration-patterns.md +982 -0
  326. moai_adk/templates/.claude/skills/moai-worktree/modules/parallel-development.md +778 -0
  327. moai_adk/templates/.claude/skills/moai-worktree/modules/worktree-commands.md +646 -0
  328. moai_adk/templates/.claude/skills/moai-worktree/modules/worktree-management.md +782 -0
  329. moai_adk/templates/.claude/skills/moai-worktree/reference.md +357 -0
  330. moai_adk/templates/.git-hooks/pre-commit +103 -41
  331. moai_adk/templates/.git-hooks/pre-push +116 -21
  332. moai_adk/templates/.github/workflows/ci-universal.yml +513 -0
  333. moai_adk/templates/.github/workflows/security-secrets-check.yml +179 -0
  334. moai_adk/templates/.gitignore +184 -44
  335. moai_adk/templates/.mcp.json +7 -9
  336. moai_adk/templates/.moai/cache/personalization.json +10 -0
  337. moai_adk/templates/.moai/config/config.yaml +344 -0
  338. moai_adk/templates/.moai/config/presets/manual.yaml +28 -0
  339. moai_adk/templates/.moai/config/presets/personal.yaml +30 -0
  340. moai_adk/templates/.moai/config/presets/team.yaml +33 -0
  341. moai_adk/templates/.moai/config/questions/_schema.yaml +79 -0
  342. moai_adk/templates/.moai/config/questions/tab1-user.yaml +108 -0
  343. moai_adk/templates/.moai/config/questions/tab2-project.yaml +122 -0
  344. moai_adk/templates/.moai/config/questions/tab3-git.yaml +542 -0
  345. moai_adk/templates/.moai/config/questions/tab4-quality.yaml +167 -0
  346. moai_adk/templates/.moai/config/questions/tab5-system.yaml +152 -0
  347. moai_adk/templates/.moai/config/sections/git-strategy.yaml +40 -0
  348. moai_adk/templates/.moai/config/sections/language.yaml +11 -0
  349. moai_adk/templates/.moai/config/sections/project.yaml +13 -0
  350. moai_adk/templates/.moai/config/sections/quality.yaml +15 -0
  351. moai_adk/templates/.moai/config/sections/system.yaml +14 -0
  352. moai_adk/templates/.moai/config/sections/user.yaml +5 -0
  353. moai_adk/templates/.moai/config/statusline-config.yaml +86 -0
  354. moai_adk/templates/.moai/scripts/setup-glm.py +136 -0
  355. moai_adk/templates/CLAUDE.md +382 -501
  356. moai_adk/utils/__init__.py +24 -1
  357. moai_adk/utils/banner.py +7 -10
  358. moai_adk/utils/common.py +16 -30
  359. moai_adk/utils/link_validator.py +4 -12
  360. moai_adk/utils/safe_file_reader.py +2 -6
  361. moai_adk/utils/timeout.py +160 -0
  362. moai_adk/utils/toon_utils.py +256 -0
  363. moai_adk/version.py +22 -0
  364. moai_adk-0.32.8.dist-info/METADATA +2478 -0
  365. moai_adk-0.32.8.dist-info/RECORD +396 -0
  366. {moai_adk-0.25.4.dist-info → moai_adk-0.32.8.dist-info}/WHEEL +1 -1
  367. {moai_adk-0.25.4.dist-info → moai_adk-0.32.8.dist-info}/entry_points.txt +1 -0
  368. moai_adk/cli/commands/backup.py +0 -82
  369. moai_adk/cli/commands/improve_user_experience.py +0 -348
  370. moai_adk/cli/commands/migrate.py +0 -158
  371. moai_adk/cli/commands/validate_links.py +0 -118
  372. moai_adk/templates/.github/workflows/moai-gitflow.yml +0 -413
  373. moai_adk/templates/.github/workflows/moai-release-create.yml +0 -100
  374. moai_adk/templates/.github/workflows/moai-release-pipeline.yml +0 -188
  375. moai_adk/utils/user_experience.py +0 -531
  376. moai_adk-0.25.4.dist-info/METADATA +0 -2279
  377. moai_adk-0.25.4.dist-info/RECORD +0 -112
  378. {moai_adk-0.25.4.dist-info → moai_adk-0.32.8.dist-info}/licenses/LICENSE +0 -0
@@ -12,6 +12,7 @@ Enhanced with:
12
12
 
13
13
  from __future__ import annotations
14
14
 
15
+ import json
15
16
  import logging
16
17
  import re
17
18
  import shutil
@@ -61,23 +62,13 @@ class TemplateProcessorConfig:
61
62
  return cls(
62
63
  version_cache_ttl_seconds=config_dict.get("version_cache_ttl_seconds", 120),
63
64
  version_fallback=config_dict.get("version_fallback", "unknown"),
64
- version_format_regex=config_dict.get(
65
- "version_format_regex", r"^v?(\d+\.\d+\.\d+(-[a-zA-Z0-9]+)?)$"
66
- ),
67
- enable_version_validation=config_dict.get(
68
- "enable_version_validation", True
69
- ),
65
+ version_format_regex=config_dict.get("version_format_regex", r"^v?(\d+\.\d+\.\d+(-[a-zA-Z0-9]+)?)$"),
66
+ enable_version_validation=config_dict.get("enable_version_validation", True),
70
67
  preserve_user_version=config_dict.get("preserve_user_version", True),
71
- validate_template_variables=config_dict.get(
72
- "validate_template_variables", True
73
- ),
68
+ validate_template_variables=config_dict.get("validate_template_variables", True),
74
69
  max_variable_length=config_dict.get("max_variable_length", 50),
75
- allowed_variable_pattern=config_dict.get(
76
- "allowed_variable_pattern", r"^[A-Z_]+$"
77
- ),
78
- enable_substitution_warnings=config_dict.get(
79
- "enable_substitution_warnings", True
80
- ),
70
+ allowed_variable_pattern=config_dict.get("allowed_variable_pattern", r"^[A-Z_]+$"),
71
+ enable_substitution_warnings=config_dict.get("enable_substitution_warnings", True),
81
72
  enable_caching=config_dict.get("enable_caching", True),
82
73
  cache_size=config_dict.get("cache_size", 100),
83
74
  async_operations=config_dict.get("async_operations", False),
@@ -95,7 +86,7 @@ class TemplateProcessor:
95
86
  ".moai/reports/", # User reports
96
87
  ".moai/project/", # User project documents (product/structure/tech.md)
97
88
  # config.json is now FORCE OVERWRITTEN (backup in .moai-backups/)
98
- # Merge via /alfred:0-project when optimized=false
89
+ # Merge via /moai:0-project when optimized=false
99
90
  ]
100
91
 
101
92
  # Paths excluded from backups
@@ -103,11 +94,10 @@ class TemplateProcessor:
103
94
 
104
95
  # Common template variables with validation hints
105
96
  COMMON_TEMPLATE_VARIABLES = {
106
- "PROJECT_DIR": "Cross-platform project path (run /alfred:0-project to set)",
107
- "HOOK_PROJECT_DIR": "Cross-platform hook path (deprecated, use PROJECT_DIR instead)",
108
- "PROJECT_NAME": "Project name (run /alfred:0-project to set)",
109
- "AUTHOR": "Project author (run /alfred:0-project to set)",
110
- "CONVERSATION_LANGUAGE": "Interface language (run /alfred:0-project to set)",
97
+ "PROJECT_DIR": "Cross-platform project path (run /moai:0-project to set)",
98
+ "PROJECT_NAME": "Project name (run /moai:0-project to set)",
99
+ "AUTHOR": "Project author (run /moai:0-project to set)",
100
+ "CONVERSATION_LANGUAGE": "Interface language (run /moai:0-project to set)",
111
101
  "MOAI_VERSION": "MoAI-ADK version (should be set automatically)",
112
102
  "MOAI_VERSION_SHORT": "Short MoAI-ADK version (without 'v' prefix)",
113
103
  "MOAI_VERSION_DISPLAY": "Display version with proper formatting",
@@ -119,9 +109,7 @@ class TemplateProcessor:
119
109
  "CREATION_TIMESTAMP": "Project creation timestamp",
120
110
  }
121
111
 
122
- def __init__(
123
- self, target_path: Path, config: Optional[TemplateProcessorConfig] = None
124
- ) -> None:
112
+ def __init__(self, target_path: Path, config: Optional[TemplateProcessorConfig] = None) -> None:
125
113
  """Initialize the processor with enhanced configuration.
126
114
 
127
115
  Args:
@@ -135,16 +123,14 @@ class TemplateProcessor:
135
123
  self.context: dict[str, str] = {} # Template variable substitution context
136
124
  self._version_reader: VersionReader | None = None
137
125
  self.config = config or TemplateProcessorConfig()
138
- self._substitution_cache: Dict[str, str] = {} # Cache for substitution results
139
- self._variable_validation_cache: Dict[str, bool] = (
140
- {}
141
- ) # Cache for variable validation
126
+ self._substitution_cache: Dict[
127
+ int, tuple[str, list[str]]
128
+ ] = {} # Cache for substitution results (key: hash, value: (content, warnings))
129
+ self._variable_validation_cache: Dict[str, bool] = {} # Cache for variable validation
142
130
  self.logger = logging.getLogger(__name__)
143
131
 
144
132
  if self.config.verbose_logging:
145
- self.logger.info(
146
- f"TemplateProcessor initialized with config: {self.config}"
147
- )
133
+ self.logger.info(f"TemplateProcessor initialized with config: {self.config}")
148
134
 
149
135
  def set_context(self, context: dict[str, str]) -> None:
150
136
  """Set variable substitution context with enhanced validation.
@@ -213,21 +199,15 @@ class TemplateProcessor:
213
199
 
214
200
  # Check variable length
215
201
  if len(var_name) > self.config.max_variable_length:
216
- warning_messages.append(
217
- f"Variable name '{var_name}' exceeds maximum length"
218
- )
202
+ warning_messages.append(f"Variable name '{var_name}' exceeds maximum length")
219
203
 
220
204
  # Check variable value length
221
205
  if len(var_value) > self.config.max_variable_length * 2:
222
- warning_messages.append(
223
- f"Variable value '{var_value[:20]}...' is very long"
224
- )
206
+ warning_messages.append(f"Variable value '{var_value[:20]}...' is very long")
225
207
 
226
208
  # Check for potentially dangerous values
227
209
  if "{{" in var_value or "}}" in var_value:
228
- warning_messages.append(
229
- f"Variable '{var_name}' contains placeholder patterns"
230
- )
210
+ warning_messages.append(f"Variable '{var_name}' contains placeholder patterns")
231
211
 
232
212
  # Check for common variables that should be present
233
213
  missing_common_vars = []
@@ -236,28 +216,20 @@ class TemplateProcessor:
236
216
  missing_common_vars.append(common_var)
237
217
 
238
218
  if missing_common_vars and self.config.enable_substitution_warnings:
239
- warning_messages.append(
240
- f"Common variables missing: {', '.join(missing_common_vars[:3])}"
241
- )
219
+ warning_messages.append(f"Common variables missing: {', '.join(missing_common_vars[:3])}")
242
220
 
243
221
  # Report validation results
244
222
  if validation_errors and not self.config.graceful_degradation:
245
- raise ValueError(
246
- f"Template variable validation failed: {validation_errors}"
247
- )
223
+ raise ValueError(f"Template variable validation failed: {validation_errors}")
248
224
 
249
225
  if validation_errors and self.config.graceful_degradation:
250
- self.logger.warning(
251
- f"Template variable validation warnings: {validation_errors}"
252
- )
226
+ self.logger.warning(f"Template variable validation warnings: {validation_errors}")
253
227
 
254
228
  if warning_messages and self.config.enable_substitution_warnings:
255
229
  self.logger.warning(f"Template variable warnings: {warning_messages}")
256
230
 
257
231
  if self.config.verbose_logging:
258
- self.logger.debug(
259
- f"Template variables validated: {len(context)} variables checked"
260
- )
232
+ self.logger.debug(f"Template variables validated: {len(context)} variables checked")
261
233
 
262
234
  def get_enhanced_version_context(self) -> dict[str, str]:
263
235
  """
@@ -278,28 +250,16 @@ class TemplateProcessor:
278
250
 
279
251
  # Basic version information
280
252
  version_context["MOAI_VERSION"] = moai_version
281
- version_context["MOAI_VERSION_SHORT"] = self._format_short_version(
282
- moai_version
283
- )
284
- version_context["MOAI_VERSION_DISPLAY"] = self._format_display_version(
285
- moai_version
286
- )
253
+ version_context["MOAI_VERSION_SHORT"] = self._format_short_version(moai_version)
254
+ version_context["MOAI_VERSION_DISPLAY"] = self._format_display_version(moai_version)
287
255
 
288
256
  # Enhanced formatting options
289
- version_context["MOAI_VERSION_TRIMMED"] = self._format_trimmed_version(
290
- moai_version, max_length=10
291
- )
292
- version_context["MOAI_VERSION_SEMVER"] = self._format_semver_version(
293
- moai_version
294
- )
257
+ version_context["MOAI_VERSION_TRIMMED"] = self._format_trimmed_version(moai_version, max_length=10)
258
+ version_context["MOAI_VERSION_SEMVER"] = self._format_semver_version(moai_version)
295
259
 
296
260
  # Validation and source information
297
- version_context["MOAI_VERSION_VALID"] = (
298
- "true" if moai_version != "unknown" else "false"
299
- )
300
- version_context["MOAI_VERSION_SOURCE"] = self._get_version_source(
301
- version_reader
302
- )
261
+ version_context["MOAI_VERSION_VALID"] = "true" if moai_version != "unknown" else "false"
262
+ version_context["MOAI_VERSION_SOURCE"] = self._get_version_source(version_reader)
303
263
 
304
264
  # Performance metrics
305
265
  cache_age = version_reader.get_cache_age_seconds()
@@ -311,9 +271,7 @@ class TemplateProcessor:
311
271
  # Additional metadata
312
272
  if self.config.enable_version_validation:
313
273
  is_valid = self._is_valid_version_format(moai_version)
314
- version_context["MOAI_VERSION_FORMAT_VALID"] = (
315
- "true" if is_valid else "false"
316
- )
274
+ version_context["MOAI_VERSION_FORMAT_VALID"] = "true" if is_valid else "false"
317
275
 
318
276
  if self.config.verbose_logging:
319
277
  logger.debug(f"Enhanced version context generated: {version_context}")
@@ -323,21 +281,11 @@ class TemplateProcessor:
323
281
  # Use fallback version with comprehensive formatting
324
282
  fallback_version = self.config.version_fallback
325
283
  version_context["MOAI_VERSION"] = fallback_version
326
- version_context["MOAI_VERSION_SHORT"] = self._format_short_version(
327
- fallback_version
328
- )
329
- version_context["MOAI_VERSION_DISPLAY"] = self._format_display_version(
330
- fallback_version
331
- )
332
- version_context["MOAI_VERSION_TRIMMED"] = self._format_trimmed_version(
333
- fallback_version, max_length=10
334
- )
335
- version_context["MOAI_VERSION_SEMVER"] = self._format_semver_version(
336
- fallback_version
337
- )
338
- version_context["MOAI_VERSION_VALID"] = (
339
- "false" if fallback_version == "unknown" else "true"
340
- )
284
+ version_context["MOAI_VERSION_SHORT"] = self._format_short_version(fallback_version)
285
+ version_context["MOAI_VERSION_DISPLAY"] = self._format_display_version(fallback_version)
286
+ version_context["MOAI_VERSION_TRIMMED"] = self._format_trimmed_version(fallback_version, max_length=10)
287
+ version_context["MOAI_VERSION_SEMVER"] = self._format_semver_version(fallback_version)
288
+ version_context["MOAI_VERSION_VALID"] = "false" if fallback_version == "unknown" else "true"
341
289
  version_context["MOAI_VERSION_SOURCE"] = "fallback_config"
342
290
  version_context["MOAI_VERSION_CACHE_AGE"] = "unavailable"
343
291
  version_context["MOAI_VERSION_FORMAT_VALID"] = "false"
@@ -466,14 +414,6 @@ class TemplateProcessor:
466
414
  package_root = current_file.parent.parent.parent
467
415
  return package_root / "templates"
468
416
 
469
- def set_context(self, context: dict[str, str]) -> None:
470
- """Set variable substitution context.
471
-
472
- Args:
473
- context: Dictionary of template variables.
474
- """
475
- self.context = context
476
-
477
417
  def _substitute_variables(self, content: str) -> tuple[str, list[str]]:
478
418
  """
479
419
  Substitute template variables in content with enhanced validation and caching.
@@ -503,9 +443,7 @@ class TemplateProcessor:
503
443
  if self.config.validate_template_variables:
504
444
  # Validate variable before substitution
505
445
  if not self._is_valid_template_variable(key, value):
506
- warnings.append(
507
- f"Invalid variable {key} - skipped substitution"
508
- )
446
+ warnings.append(f"Invalid variable {key} - skipped substitution")
509
447
  continue
510
448
 
511
449
  safe_value = self._sanitize_value(value)
@@ -527,17 +465,13 @@ class TemplateProcessor:
527
465
  suggestion = self.COMMON_TEMPLATE_VARIABLES[var]
528
466
  warning_parts.append(f"{{{{{var}}}}} → {suggestion}")
529
467
  else:
530
- warning_parts.append(
531
- f"{{{{{var}}}}} → Unknown variable (check template)"
532
- )
468
+ warning_parts.append(f"{{{{{var}}}}} → Unknown variable (check template)")
533
469
 
534
470
  warnings.append("Template variables not substituted:")
535
471
  warnings.extend(f" • {part}" for part in warning_parts)
536
472
 
537
473
  if self.config.enable_substitution_warnings:
538
- warnings.append(
539
- "💡 Run 'uv run moai-adk update' to fix template variables"
540
- )
474
+ warnings.append("💡 Run 'uv run moai-adk update' to fix template variables")
541
475
 
542
476
  # Add performance information if verbose logging is enabled
543
477
  if self.config.verbose_logging:
@@ -668,7 +602,7 @@ class TemplateProcessor:
668
602
  Returns:
669
603
  Content with localized descriptions.
670
604
  """
671
- import yaml
605
+ import yaml # type: ignore[import-untyped]
672
606
 
673
607
  # Pattern to match YAML frontmatter
674
608
  frontmatter_pattern = r"^---\n(.*?)\n---"
@@ -712,6 +646,8 @@ class TemplateProcessor:
712
646
  Returns:
713
647
  List of warnings.
714
648
  """
649
+ import stat
650
+
715
651
  warnings = []
716
652
 
717
653
  # Text files: read, substitute, write
@@ -721,9 +657,7 @@ class TemplateProcessor:
721
657
  content, file_warnings = self._substitute_variables(content)
722
658
 
723
659
  # Apply description localization for command/output-style files
724
- if src.suffix == ".md" and (
725
- "commands/alfred" in str(src) or "output-styles/alfred" in str(src)
726
- ):
660
+ if src.suffix == ".md" and ("commands/alfred" in str(src) or "output-styles/alfred" in str(src)):
727
661
  lang = self.context.get("CONVERSATION_LANGUAGE", "en")
728
662
  content = self._localize_yaml_description(content, lang)
729
663
 
@@ -736,6 +670,12 @@ class TemplateProcessor:
736
670
  # Binary file or no context: simple copy
737
671
  shutil.copy2(src, dst)
738
672
 
673
+ # Ensure executable permission for shell scripts
674
+ if src.suffix == ".sh":
675
+ # Always make shell scripts executable regardless of source permissions
676
+ dst_mode = dst.stat().st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
677
+ dst.chmod(dst_mode)
678
+
739
679
  return warnings
740
680
 
741
681
  def _copy_dir_with_substitution(self, src: Path, dst: Path) -> None:
@@ -781,6 +721,7 @@ class TemplateProcessor:
781
721
  self._copy_github(silent)
782
722
  self._copy_claude_md(silent)
783
723
  self._copy_gitignore(silent)
724
+ self._copy_mcp_json(silent)
784
725
 
785
726
  if not silent:
786
727
  console.print("✅ Templates copied successfully")
@@ -849,16 +790,21 @@ class TemplateProcessor:
849
790
  # Create .claude directory if not exists
850
791
  dst.mkdir(parents=True, exist_ok=True)
851
792
 
852
- # Alfred folders to copy wholesale (overwrite)
853
- alfred_folders = [
793
+ # Alfred and Moai folders to copy wholesale (overwrite)
794
+ # Including both legacy alfred/ and new moai/ structure
795
+ alfred_moai_folders = [
854
796
  "hooks/alfred",
797
+ "hooks/moai",
855
798
  "commands/alfred", # Contains 0-project.md, 1-plan.md, 2-run.md, 3-sync.md
856
- "output-styles/alfred",
799
+ "commands/moai",
800
+ "output-styles/moai",
857
801
  "agents/alfred",
802
+ "agents/moai",
803
+ "skills", # NEW: Complete replacement for skills folder
858
804
  ]
859
805
 
860
- # 1. Copy Alfred folders wholesale (backup before delete & overwrite)
861
- for folder in alfred_folders:
806
+ # 1. Copy Alfred and Moai folders wholesale (backup before delete & overwrite)
807
+ for folder in alfred_moai_folders:
862
808
  src_folder = src / folder
863
809
  dst_folder = dst / folder
864
810
 
@@ -873,7 +819,35 @@ class TemplateProcessor:
873
819
  if not silent:
874
820
  console.print(f" ✅ .claude/{folder}/ overwritten")
875
821
 
876
- # 2. Copy other files/folders individually (smart merge for settings.json)
822
+ # 1.5 Copy other subdirectories in parent folders (e.g., output-styles/moai, hooks/shared)
823
+ # This ensures non-alfred subdirectories are also copied
824
+ parent_folders_with_subdirs = ["output-styles", "hooks", "commands", "agents"]
825
+ for parent_name in parent_folders_with_subdirs:
826
+ src_parent = src / parent_name
827
+ if not src_parent.exists():
828
+ continue
829
+
830
+ for subdir in src_parent.iterdir():
831
+ if not subdir.is_dir():
832
+ continue
833
+
834
+ # Skip alfred subdirectories (already handled above)
835
+ if subdir.name == "alfred":
836
+ continue
837
+
838
+ rel_subdir = f"{parent_name}/{subdir.name}"
839
+ dst_subdir = dst / parent_name / subdir.name
840
+
841
+ if dst_subdir.exists():
842
+ # For non-alfred directories, overwrite with merge if necessary
843
+ shutil.rmtree(dst_subdir)
844
+
845
+ # Copy the subdirectory
846
+ shutil.copytree(subdir, dst_subdir)
847
+ if not silent:
848
+ console.print(f" ✅ .claude/{rel_subdir}/ copied")
849
+
850
+ # 2. Copy other files/folders individually (smart merge for settings.json and config.json)
877
851
  all_warnings = []
878
852
  for item in src.iterdir():
879
853
  rel_path = item.relative_to(src)
@@ -899,9 +873,12 @@ class TemplateProcessor:
899
873
  dst_item.write_text(content, encoding="utf-8")
900
874
  all_warnings.extend(file_warnings)
901
875
  if not silent:
902
- console.print(
903
- " 🔄 settings.json merged (Hook paths configured for your OS)"
904
- )
876
+ console.print(" 🔄 settings.json merged (Hook paths configured for your OS)")
877
+ # Smart merge for config.json
878
+ elif item.name == "config.json":
879
+ self._merge_config_json(item, dst_item)
880
+ if not silent:
881
+ console.print(" 🔄 config.json merged (user preferences preserved)")
905
882
  else:
906
883
  # FORCE OVERWRITE: Always copy other files (no skip)
907
884
  warnings = self._copy_file_with_substitution(item, dst_item)
@@ -984,12 +961,10 @@ class TemplateProcessor:
984
961
  self._copy_dir_with_substitution(src, dst)
985
962
 
986
963
  if not silent:
987
- console.print(
988
- " 🔄 .github/ merged (user workflows preserved, variables substituted)"
989
- )
964
+ console.print(" 🔄 .github/ merged (user workflows preserved, variables substituted)")
990
965
 
991
966
  def _copy_claude_md(self, silent: bool = False) -> None:
992
- """Copy CLAUDE.md with smart merge (preserves \"## Project Information\" section)."""
967
+ """Copy CLAUDE.md with complete replacement (no merge)."""
993
968
  src = self.template_root / "CLAUDE.md"
994
969
  dst = self.target_path / "CLAUDE.md"
995
970
 
@@ -998,27 +973,11 @@ class TemplateProcessor:
998
973
  console.print("⚠️ CLAUDE.md template not found")
999
974
  return
1000
975
 
1001
- # Smart merge: preserve existing "## Project Information" section
1002
- if dst.exists():
1003
- self._merge_claude_md(src, dst)
1004
- # Substitute variables in the merged content
1005
- if self.context:
1006
- content = dst.read_text(encoding="utf-8")
1007
- content, warnings = self._substitute_variables(content)
1008
- dst.write_text(content, encoding="utf-8")
1009
- if warnings and not silent:
1010
- console.print("[yellow]⚠️ Template warnings:[/yellow]")
1011
- for warning in set(warnings):
1012
- console.print(f" {warning}")
1013
- if not silent:
1014
- console.print(
1015
- " 🔄 CLAUDE.md merged (project information preserved, variables substituted)"
1016
- )
1017
- else:
1018
- # First time: just copy
1019
- self._copy_file_with_substitution(src, dst)
1020
- if not silent:
1021
- console.print(" ✅ CLAUDE.md created")
976
+ # Simple copy with substitution (no merge)
977
+ self._copy_file_with_substitution(src, dst)
978
+
979
+ if not silent:
980
+ console.print(" ✅ CLAUDE.md replaced (use CLAUDE.local.md for personal instructions)")
1022
981
 
1023
982
  def _merge_claude_md(self, src: Path, dst: Path) -> None:
1024
983
  """Delegate the smart merge for CLAUDE.md.
@@ -1047,15 +1006,119 @@ class TemplateProcessor:
1047
1006
  """
1048
1007
  # Find the latest backup for user settings extraction
1049
1008
  backup_path = None
1050
- if self.backup.backup_dir.exists():
1051
- backups = sorted(self.backup.backup_dir.iterdir(), reverse=True)
1052
- if backups:
1053
- backup_settings = backups[0] / ".claude" / "settings.json"
1054
- if backup_settings.exists():
1055
- backup_path = backup_settings
1009
+ latest_backup = self.backup.get_latest_backup()
1010
+ if latest_backup:
1011
+ backup_settings = latest_backup / ".claude" / "settings.json"
1012
+ if backup_settings.exists():
1013
+ backup_path = backup_settings
1056
1014
 
1057
1015
  self.merger.merge_settings_json(src, dst, backup_path)
1058
1016
 
1017
+ def _merge_config_json(self, src: Path, dst: Path) -> None:
1018
+ """Smart merge for config.json using LanguageConfigResolver priority system.
1019
+
1020
+ Args:
1021
+ src: Template config.json.
1022
+ dst: Project config.json.
1023
+ """
1024
+ import json
1025
+
1026
+ # Load template config
1027
+ try:
1028
+ template_config = json.loads(src.read_text(encoding="utf-8"))
1029
+ except (json.JSONDecodeError, FileNotFoundError) as e:
1030
+ console.print(f"⚠️ Warning: Could not read template config.json: {e}")
1031
+ return
1032
+
1033
+ # Find latest backup config.json
1034
+ latest_backup = self.backup.get_latest_backup()
1035
+ if latest_backup:
1036
+ backup_config_path = latest_backup / ".moai" / "config" / "config.json"
1037
+ if backup_config_path.exists():
1038
+ try:
1039
+ json.loads(backup_config_path.read_text(encoding="utf-8"))
1040
+ except json.JSONDecodeError as e:
1041
+ console.print(f"⚠️ Warning: Could not read backup config.json: {e}")
1042
+
1043
+ # Load existing project config.json
1044
+ existing_config = {}
1045
+ if dst.exists():
1046
+ try:
1047
+ existing_config = json.loads(dst.read_text(encoding="utf-8"))
1048
+ except json.JSONDecodeError as e:
1049
+ console.print(f"⚠️ Warning: Could not read existing config.json: {e}")
1050
+
1051
+ # Merge with priority system: Environment > Existing User > Template
1052
+ # We'll use LanguageConfigResolver to handle this properly
1053
+ try:
1054
+ # Import LanguageConfigResolver for priority-based merging
1055
+ from moai_adk.core.language_config_resolver import LanguageConfigResolver
1056
+
1057
+ # Create temporary resolver to handle merging
1058
+ temp_project_path = self.target_path / ".moai" / "config"
1059
+ temp_project_path.mkdir(parents=True, exist_ok=True)
1060
+
1061
+ # Start with template config as base
1062
+ merged_config = template_config.copy()
1063
+
1064
+ # Apply existing user config (higher priority than template)
1065
+ for key, value in existing_config.items():
1066
+ if key not in ["config_source"]: # Skip metadata
1067
+ if key in merged_config and isinstance(merged_config[key], dict) and isinstance(value, dict):
1068
+ # Deep merge for nested objects
1069
+ merged_config[key].update(value)
1070
+ else:
1071
+ merged_config[key] = value
1072
+
1073
+ # Apply environment variables (highest priority)
1074
+ import os
1075
+
1076
+ env_mappings = {
1077
+ "MOAI_USER_NAME": ("user", "name"),
1078
+ "MOAI_CONVERSATION_LANG": ("language", "conversation_language"),
1079
+ "MOAI_AGENT_PROMPT_LANG": ("language", "agent_prompt_language"),
1080
+ "MOAI_CONVERSATION_LANG_NAME": (
1081
+ "language",
1082
+ "conversation_language_name",
1083
+ ),
1084
+ "MOAI_GIT_COMMIT_MESSAGES_LANG": ("language", "git_commit_messages"),
1085
+ "MOAI_CODE_COMMENTS_LANG": ("language", "code_comments"),
1086
+ "MOAI_DOCUMENTATION_LANG": ("language", "documentation"),
1087
+ "MOAI_ERROR_MESSAGES_LANG": ("language", "error_messages"),
1088
+ }
1089
+
1090
+ for env_var, (section, key) in env_mappings.items():
1091
+ env_value = os.getenv(env_var)
1092
+ if env_value:
1093
+ if section not in merged_config:
1094
+ merged_config[section] = {}
1095
+ merged_config[section][key] = env_value
1096
+
1097
+ # Ensure consistency
1098
+ resolver = LanguageConfigResolver(str(self.target_path))
1099
+ merged_config = resolver._ensure_consistency(merged_config)
1100
+
1101
+ # Write merged config
1102
+ dst.write_text(
1103
+ json.dumps(merged_config, indent=2, ensure_ascii=False) + "\n",
1104
+ encoding="utf-8",
1105
+ )
1106
+
1107
+ except ImportError:
1108
+ # Fallback: simple merge without LanguageConfigResolver
1109
+ merged_config = template_config.copy()
1110
+
1111
+ # Apply existing config
1112
+ for key, value in existing_config.items():
1113
+ if key not in ["config_source"]:
1114
+ merged_config[key] = value
1115
+
1116
+ dst.write_text(
1117
+ json.dumps(merged_config, indent=2, ensure_ascii=False) + "\n",
1118
+ encoding="utf-8",
1119
+ )
1120
+ console.print(" ⚠️ Warning: Using simple merge (LanguageConfigResolver not available)")
1121
+
1059
1122
  def _copy_gitignore(self, silent: bool = False) -> None:
1060
1123
  """.gitignore copy (optional)."""
1061
1124
  src = self.template_root / ".gitignore"
@@ -1083,6 +1146,47 @@ class TemplateProcessor:
1083
1146
  """
1084
1147
  self.merger.merge_gitignore(src, dst)
1085
1148
 
1149
+ def _copy_mcp_json(self, silent: bool = False) -> None:
1150
+ """.mcp.json copy (smart merge with existing MCP server configuration)."""
1151
+ src = self.template_root / ".mcp.json"
1152
+ dst = self.target_path / ".mcp.json"
1153
+
1154
+ if not src.exists():
1155
+ return
1156
+
1157
+ # Merge with existing .mcp.json when present (preserve user-added MCP servers)
1158
+ if dst.exists():
1159
+ self._merge_mcp_json(src, dst)
1160
+ if not silent:
1161
+ console.print(" 🔄 .mcp.json merged (user MCP servers preserved)")
1162
+ else:
1163
+ shutil.copy2(src, dst)
1164
+ if not silent:
1165
+ console.print(" ✅ .mcp.json copy complete")
1166
+
1167
+ def _merge_mcp_json(self, src: Path, dst: Path) -> None:
1168
+ """Smart merge for .mcp.json (preserve user-added MCP servers).
1169
+
1170
+ Args:
1171
+ src: Template .mcp.json.
1172
+ dst: Project .mcp.json.
1173
+ """
1174
+ try:
1175
+ src_data = json.loads(src.read_text(encoding="utf-8"))
1176
+ dst_data = json.loads(dst.read_text(encoding="utf-8"))
1177
+
1178
+ # Merge mcpServers: preserve user servers, update template servers
1179
+ if "mcpServers" in src_data:
1180
+ if "mcpServers" not in dst_data:
1181
+ dst_data["mcpServers"] = {}
1182
+ # Update with template servers (preserves existing user servers)
1183
+ dst_data["mcpServers"].update(src_data["mcpServers"])
1184
+
1185
+ # Write merged result back
1186
+ dst.write_text(json.dumps(dst_data, indent=2, ensure_ascii=False), encoding="utf-8")
1187
+ except json.JSONDecodeError as e:
1188
+ console.print(f"[yellow]⚠️ Failed to merge .mcp.json: {e}[/yellow]")
1189
+
1086
1190
  def merge_config(self, detected_language: str | None = None) -> dict[str, str]:
1087
1191
  """Delegate the smart merge for config.json.
1088
1192