moai-adk 0.15.0__py3-none-any.whl → 0.25.4__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 (417) hide show
  1. moai_adk/__init__.py +1 -2
  2. moai_adk/__main__.py +85 -2
  3. moai_adk/cli/__init__.py +0 -1
  4. moai_adk/cli/commands/__init__.py +0 -1
  5. moai_adk/cli/commands/analyze.py +127 -0
  6. moai_adk/cli/commands/backup.py +5 -3
  7. moai_adk/cli/commands/doctor.py +35 -11
  8. moai_adk/cli/commands/improve_user_experience.py +348 -0
  9. moai_adk/cli/commands/init.py +150 -23
  10. moai_adk/cli/commands/language.py +269 -0
  11. moai_adk/cli/commands/migrate.py +158 -0
  12. moai_adk/cli/commands/status.py +13 -12
  13. moai_adk/cli/commands/update.py +364 -60
  14. moai_adk/cli/commands/validate_links.py +118 -0
  15. moai_adk/cli/main.py +3 -2
  16. moai_adk/cli/prompts/init_prompts.py +79 -82
  17. moai_adk/core/__init__.py +0 -1
  18. moai_adk/core/analysis/__init__.py +9 -0
  19. moai_adk/core/analysis/session_analyzer.py +439 -0
  20. moai_adk/core/claude_integration.py +421 -0
  21. moai_adk/core/command_helpers.py +270 -0
  22. moai_adk/core/config/__init__.py +6 -0
  23. moai_adk/core/config/auto_spec_config.py +346 -0
  24. moai_adk/core/config/migration.py +133 -12
  25. moai_adk/core/context_manager.py +279 -0
  26. moai_adk/core/diagnostics/slash_commands.py +0 -1
  27. moai_adk/core/error_recovery_system.py +1289 -0
  28. moai_adk/core/git/__init__.py +0 -1
  29. moai_adk/core/git/branch.py +0 -1
  30. moai_adk/core/git/branch_manager.py +4 -4
  31. moai_adk/core/git/checkpoint.py +1 -5
  32. moai_adk/core/git/commit.py +0 -1
  33. moai_adk/core/git/event_detector.py +3 -5
  34. moai_adk/core/git/manager.py +0 -1
  35. moai_adk/core/hooks/post_tool_auto_spec_completion.py +925 -0
  36. moai_adk/core/integration/__init__.py +22 -0
  37. moai_adk/core/integration/engine.py +169 -0
  38. moai_adk/core/integration/integration_tester.py +225 -0
  39. moai_adk/core/integration/models.py +88 -0
  40. moai_adk/core/integration/utils.py +211 -0
  41. moai_adk/core/issue_creator.py +28 -18
  42. moai_adk/core/language_config.py +202 -0
  43. moai_adk/core/language_validator.py +556 -0
  44. moai_adk/core/mcp/setup.py +113 -0
  45. moai_adk/core/migration/__init__.py +18 -0
  46. moai_adk/core/migration/backup_manager.py +208 -0
  47. moai_adk/core/migration/file_migrator.py +218 -0
  48. moai_adk/core/migration/version_detector.py +143 -0
  49. moai_adk/core/migration/version_migrator.py +228 -0
  50. moai_adk/core/performance/__init__.py +6 -0
  51. moai_adk/core/performance/cache_system.py +318 -0
  52. moai_adk/core/performance/parallel_processor.py +116 -0
  53. moai_adk/core/project/__init__.py +0 -1
  54. moai_adk/core/project/backup_utils.py +2 -7
  55. moai_adk/core/project/checker.py +3 -3
  56. moai_adk/core/project/detector.py +20 -40
  57. moai_adk/core/project/initializer.py +42 -17
  58. moai_adk/core/project/phase_executor.py +415 -58
  59. moai_adk/core/project/validator.py +6 -25
  60. moai_adk/core/quality/__init__.py +1 -1
  61. moai_adk/core/quality/trust_checker.py +64 -110
  62. moai_adk/core/quality/validators/__init__.py +1 -1
  63. moai_adk/core/quality/validators/base_validator.py +1 -1
  64. moai_adk/core/rollback_manager.py +993 -0
  65. moai_adk/core/session_manager.py +667 -0
  66. moai_adk/core/spec/confidence_scoring.py +749 -0
  67. moai_adk/core/spec/ears_template_engine.py +1182 -0
  68. moai_adk/core/spec/quality_validator.py +721 -0
  69. moai_adk/core/spec_status_manager.py +488 -0
  70. moai_adk/core/template/__init__.py +0 -1
  71. moai_adk/core/template/backup.py +41 -1
  72. moai_adk/core/template/config.py +11 -12
  73. moai_adk/core/template/languages.py +0 -1
  74. moai_adk/core/template/merger.py +79 -22
  75. moai_adk/core/template/processor.py +614 -40
  76. moai_adk/core/template_engine.py +36 -27
  77. moai_adk/foundation/git/commit_templates.py +565 -0
  78. moai_adk/foundation/trust/trust_principles.py +725 -0
  79. moai_adk/foundation/trust/validation_checklist.py +1678 -0
  80. moai_adk/statusline/__init__.py +38 -0
  81. moai_adk/statusline/alfred_detector.py +107 -0
  82. moai_adk/statusline/config.py +364 -0
  83. moai_adk/statusline/enhanced_output_style_detector.py +364 -0
  84. moai_adk/statusline/git_collector.py +190 -0
  85. moai_adk/statusline/main.py +228 -0
  86. moai_adk/statusline/metrics_tracker.py +78 -0
  87. moai_adk/statusline/renderer.py +327 -0
  88. moai_adk/statusline/update_checker.py +135 -0
  89. moai_adk/statusline/version_reader.py +647 -0
  90. moai_adk/templates/.git-hooks/pre-commit +66 -0
  91. moai_adk/templates/.git-hooks/pre-push +116 -4
  92. moai_adk/templates/.github/workflows/moai-gitflow.yml +1 -7
  93. moai_adk/templates/.github/workflows/spec-issue-sync.yml +0 -1
  94. moai_adk/templates/.gitignore +44 -0
  95. moai_adk/templates/.mcp.json +22 -0
  96. moai_adk/templates/CLAUDE.md +450 -1071
  97. moai_adk/utils/__init__.py +0 -1
  98. moai_adk/utils/banner.py +0 -1
  99. moai_adk/utils/common.py +308 -0
  100. moai_adk/utils/link_validator.py +249 -0
  101. moai_adk/utils/logger.py +4 -9
  102. moai_adk/utils/safe_file_reader.py +210 -0
  103. moai_adk/utils/user_experience.py +531 -0
  104. moai_adk-0.25.4.dist-info/METADATA +2279 -0
  105. moai_adk-0.25.4.dist-info/RECORD +112 -0
  106. moai_adk/core/tags/__init__.py +0 -86
  107. moai_adk/core/tags/ci_validator.py +0 -463
  108. moai_adk/core/tags/cli.py +0 -283
  109. moai_adk/core/tags/generator.py +0 -109
  110. moai_adk/core/tags/inserter.py +0 -99
  111. moai_adk/core/tags/mapper.py +0 -126
  112. moai_adk/core/tags/parser.py +0 -76
  113. moai_adk/core/tags/pre_commit_validator.py +0 -393
  114. moai_adk/core/tags/reporter.py +0 -956
  115. moai_adk/core/tags/tags.py +0 -149
  116. moai_adk/core/tags/validator.py +0 -897
  117. moai_adk/templates/.claude/agents/alfred/backend-expert.md +0 -319
  118. moai_adk/templates/.claude/agents/alfred/cc-manager.md +0 -316
  119. moai_adk/templates/.claude/agents/alfred/debug-helper.md +0 -208
  120. moai_adk/templates/.claude/agents/alfred/devops-expert.md +0 -464
  121. moai_adk/templates/.claude/agents/alfred/doc-syncer.md +0 -214
  122. moai_adk/templates/.claude/agents/alfred/frontend-expert.md +0 -357
  123. moai_adk/templates/.claude/agents/alfred/git-manager.md +0 -406
  124. moai_adk/templates/.claude/agents/alfred/implementation-planner.md +0 -423
  125. moai_adk/templates/.claude/agents/alfred/project-manager.md +0 -312
  126. moai_adk/templates/.claude/agents/alfred/quality-gate.md +0 -343
  127. moai_adk/templates/.claude/agents/alfred/skill-factory.md +0 -865
  128. moai_adk/templates/.claude/agents/alfred/spec-builder.md +0 -392
  129. moai_adk/templates/.claude/agents/alfred/tag-agent.md +0 -361
  130. moai_adk/templates/.claude/agents/alfred/tdd-implementer.md +0 -428
  131. moai_adk/templates/.claude/agents/alfred/trust-checker.md +0 -375
  132. moai_adk/templates/.claude/agents/alfred/ui-ux-expert.md +0 -571
  133. moai_adk/templates/.claude/commands/alfred/0-project.md +0 -1525
  134. moai_adk/templates/.claude/commands/alfred/1-plan.md +0 -802
  135. moai_adk/templates/.claude/commands/alfred/2-run.md +0 -709
  136. moai_adk/templates/.claude/commands/alfred/3-sync.md +0 -1009
  137. moai_adk/templates/.claude/commands/alfred/9-feedback.md +0 -149
  138. moai_adk/templates/.claude/hooks/alfred/core/project.py +0 -748
  139. moai_adk/templates/.claude/hooks/alfred/core/timeout.py +0 -136
  140. moai_adk/templates/.claude/hooks/alfred/core/ttl_cache.py +0 -108
  141. moai_adk/templates/.claude/hooks/alfred/core/version_cache.py +0 -198
  142. moai_adk/templates/.claude/hooks/alfred/handlers/__init__.py +0 -29
  143. moai_adk/templates/.claude/hooks/alfred/post_tool__log_changes.py +0 -94
  144. moai_adk/templates/.claude/hooks/alfred/pre_tool__auto_checkpoint.py +0 -100
  145. moai_adk/templates/.claude/hooks/alfred/session_end__cleanup.py +0 -94
  146. moai_adk/templates/.claude/hooks/alfred/session_start__show_project_info.py +0 -94
  147. moai_adk/templates/.claude/hooks/alfred/shared/core/__init__.py +0 -170
  148. moai_adk/templates/.claude/hooks/alfred/shared/core/checkpoint.py +0 -271
  149. moai_adk/templates/.claude/hooks/alfred/shared/core/context.py +0 -67
  150. moai_adk/templates/.claude/hooks/alfred/shared/core/project.py +0 -749
  151. moai_adk/templates/.claude/hooks/alfred/shared/core/tags.py +0 -230
  152. moai_adk/templates/.claude/hooks/alfred/shared/core/version_cache.py +0 -198
  153. moai_adk/templates/.claude/hooks/alfred/shared/handlers/__init__.py +0 -21
  154. moai_adk/templates/.claude/hooks/alfred/shared/handlers/notification.py +0 -154
  155. moai_adk/templates/.claude/hooks/alfred/shared/handlers/session.py +0 -174
  156. moai_adk/templates/.claude/hooks/alfred/shared/handlers/tool.py +0 -87
  157. moai_adk/templates/.claude/hooks/alfred/shared/handlers/user.py +0 -61
  158. moai_adk/templates/.claude/hooks/alfred/user_prompt__jit_load_docs.py +0 -112
  159. moai_adk/templates/.claude/hooks/alfred/utils/__init__.py +0 -1
  160. moai_adk/templates/.claude/hooks/alfred/utils/timeout.py +0 -161
  161. moai_adk/templates/.claude/settings.json +0 -144
  162. moai_adk/templates/.claude/skills/moai-alfred-agent-guide/SKILL.md +0 -70
  163. moai_adk/templates/.claude/skills/moai-alfred-agent-guide/examples.md +0 -62
  164. moai_adk/templates/.claude/skills/moai-alfred-agent-guide/reference.md +0 -242
  165. moai_adk/templates/.claude/skills/moai-alfred-config-schema/SKILL.md +0 -56
  166. moai_adk/templates/.claude/skills/moai-alfred-config-schema/examples.md +0 -28
  167. moai_adk/templates/.claude/skills/moai-alfred-config-schema/reference.md +0 -444
  168. moai_adk/templates/.claude/skills/moai-alfred-context-budget/SKILL.md +0 -62
  169. moai_adk/templates/.claude/skills/moai-alfred-context-budget/examples.md +0 -28
  170. moai_adk/templates/.claude/skills/moai-alfred-context-budget/reference.md +0 -405
  171. moai_adk/templates/.claude/skills/moai-alfred-dev-guide/SKILL.md +0 -51
  172. moai_adk/templates/.claude/skills/moai-alfred-dev-guide/examples.md +0 -355
  173. moai_adk/templates/.claude/skills/moai-alfred-dev-guide/reference.md +0 -239
  174. moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/SKILL.md +0 -113
  175. moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/examples.md +0 -29
  176. moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/reference.md +0 -28
  177. moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/SKILL.md +0 -323
  178. moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/examples.md +0 -286
  179. moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/reference.md +0 -126
  180. moai_adk/templates/.claude/skills/moai-alfred-git-workflow/SKILL.md +0 -122
  181. moai_adk/templates/.claude/skills/moai-alfred-git-workflow/examples.md +0 -29
  182. moai_adk/templates/.claude/skills/moai-alfred-git-workflow/reference.md +0 -29
  183. moai_adk/templates/.claude/skills/moai-alfred-gitflow-policy/SKILL.md +0 -74
  184. moai_adk/templates/.claude/skills/moai-alfred-gitflow-policy/examples.md +0 -4
  185. moai_adk/templates/.claude/skills/moai-alfred-gitflow-policy/reference.md +0 -269
  186. moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/SKILL.md +0 -237
  187. moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/examples.md +0 -615
  188. moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/reference.md +0 -653
  189. moai_adk/templates/.claude/skills/moai-alfred-issue-labels/SKILL.md +0 -19
  190. moai_adk/templates/.claude/skills/moai-alfred-issue-labels/examples.md +0 -4
  191. moai_adk/templates/.claude/skills/moai-alfred-issue-labels/reference.md +0 -150
  192. moai_adk/templates/.claude/skills/moai-alfred-language-detection/SKILL.md +0 -113
  193. moai_adk/templates/.claude/skills/moai-alfred-language-detection/examples.md +0 -29
  194. moai_adk/templates/.claude/skills/moai-alfred-language-detection/reference.md +0 -28
  195. moai_adk/templates/.claude/skills/moai-alfred-persona-roles/SKILL.md +0 -198
  196. moai_adk/templates/.claude/skills/moai-alfred-persona-roles/examples.md +0 -431
  197. moai_adk/templates/.claude/skills/moai-alfred-persona-roles/reference.md +0 -141
  198. moai_adk/templates/.claude/skills/moai-alfred-practices/SKILL.md +0 -89
  199. moai_adk/templates/.claude/skills/moai-alfred-practices/examples.md +0 -122
  200. moai_adk/templates/.claude/skills/moai-alfred-practices/reference.md +0 -369
  201. moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/SKILL.md +0 -508
  202. moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/examples.md +0 -481
  203. moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/reference.md +0 -100
  204. moai_adk/templates/.claude/skills/moai-alfred-reporting/SKILL.md +0 -273
  205. moai_adk/templates/.claude/skills/moai-alfred-rules/SKILL.md +0 -77
  206. moai_adk/templates/.claude/skills/moai-alfred-rules/examples.md +0 -265
  207. moai_adk/templates/.claude/skills/moai-alfred-rules/reference.md +0 -539
  208. moai_adk/templates/.claude/skills/moai-alfred-session-state/SKILL.md +0 -19
  209. moai_adk/templates/.claude/skills/moai-alfred-session-state/examples.md +0 -4
  210. moai_adk/templates/.claude/skills/moai-alfred-session-state/reference.md +0 -84
  211. moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/README.md +0 -137
  212. moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/SKILL.md +0 -219
  213. moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/examples/validate-spec.sh +0 -161
  214. moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/examples.md +0 -541
  215. moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/reference.md +0 -622
  216. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-extended/SKILL.md +0 -115
  217. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-extended/examples.md +0 -4
  218. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-extended/reference.md +0 -348
  219. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/SKILL.md +0 -113
  220. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/examples.md +0 -29
  221. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/reference.md +0 -28
  222. moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/SKILL.md +0 -113
  223. moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/examples.md +0 -29
  224. moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/reference.md +0 -28
  225. moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/SKILL.md +0 -19
  226. moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/examples.md +0 -4
  227. moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/reference.md +0 -211
  228. moai_adk/templates/.claude/skills/moai-alfred-trust-validation/SKILL.md +0 -113
  229. moai_adk/templates/.claude/skills/moai-alfred-trust-validation/examples.md +0 -29
  230. moai_adk/templates/.claude/skills/moai-alfred-trust-validation/reference.md +0 -28
  231. moai_adk/templates/.claude/skills/moai-alfred-workflow/SKILL.md +0 -288
  232. moai_adk/templates/.claude/skills/moai-cc-agents/SKILL.md +0 -269
  233. moai_adk/templates/.claude/skills/moai-cc-agents/templates/agent-template.md +0 -32
  234. moai_adk/templates/.claude/skills/moai-cc-claude-md/SKILL.md +0 -298
  235. moai_adk/templates/.claude/skills/moai-cc-claude-md/templates/CLAUDE-template.md +0 -26
  236. moai_adk/templates/.claude/skills/moai-cc-commands/SKILL.md +0 -307
  237. moai_adk/templates/.claude/skills/moai-cc-commands/templates/command-template.md +0 -21
  238. moai_adk/templates/.claude/skills/moai-cc-hooks/SKILL.md +0 -252
  239. moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/pre-bash-check.sh +0 -19
  240. moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/preserve-permissions.sh +0 -19
  241. moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/validate-bash-command.py +0 -24
  242. moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/SKILL.md +0 -199
  243. moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/templates/settings-mcp-template.json +0 -39
  244. moai_adk/templates/.claude/skills/moai-cc-memory/SKILL.md +0 -316
  245. moai_adk/templates/.claude/skills/moai-cc-memory/templates/session-summary-template.md +0 -18
  246. moai_adk/templates/.claude/skills/moai-cc-settings/SKILL.md +0 -263
  247. moai_adk/templates/.claude/skills/moai-cc-settings/templates/settings-complete-template.json +0 -30
  248. moai_adk/templates/.claude/skills/moai-cc-skill-descriptions/SKILL.md +0 -19
  249. moai_adk/templates/.claude/skills/moai-cc-skill-descriptions/examples.md +0 -4
  250. moai_adk/templates/.claude/skills/moai-cc-skill-descriptions/reference.md +0 -218
  251. moai_adk/templates/.claude/skills/moai-cc-skill-factory/CHECKLIST.md +0 -482
  252. moai_adk/templates/.claude/skills/moai-cc-skill-factory/EXAMPLES.md +0 -278
  253. moai_adk/templates/.claude/skills/moai-cc-skill-factory/INTERACTIVE-DISCOVERY.md +0 -524
  254. moai_adk/templates/.claude/skills/moai-cc-skill-factory/METADATA.md +0 -477
  255. moai_adk/templates/.claude/skills/moai-cc-skill-factory/PARALLEL-ANALYSIS-REPORT.md +0 -429
  256. moai_adk/templates/.claude/skills/moai-cc-skill-factory/PYTHON-VERSION-MATRIX.md +0 -391
  257. moai_adk/templates/.claude/skills/moai-cc-skill-factory/SKILL-FACTORY-WORKFLOW.md +0 -431
  258. moai_adk/templates/.claude/skills/moai-cc-skill-factory/SKILL-UPDATE-ADVISOR.md +0 -577
  259. moai_adk/templates/.claude/skills/moai-cc-skill-factory/SKILL.md +0 -271
  260. moai_adk/templates/.claude/skills/moai-cc-skill-factory/STEP-BY-STEP-GUIDE.md +0 -466
  261. moai_adk/templates/.claude/skills/moai-cc-skill-factory/STRUCTURE.md +0 -583
  262. moai_adk/templates/.claude/skills/moai-cc-skill-factory/WEB-RESEARCH.md +0 -526
  263. moai_adk/templates/.claude/skills/moai-cc-skill-factory/reference.md +0 -465
  264. moai_adk/templates/.claude/skills/moai-cc-skill-factory/scripts/generate-structure.sh +0 -328
  265. moai_adk/templates/.claude/skills/moai-cc-skill-factory/scripts/validate-skill.sh +0 -312
  266. moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/SKILL_TEMPLATE.md +0 -245
  267. moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/examples-template.md +0 -285
  268. moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/reference-template.md +0 -278
  269. moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/scripts-template.sh +0 -303
  270. moai_adk/templates/.claude/skills/moai-cc-skills/SKILL.md +0 -291
  271. moai_adk/templates/.claude/skills/moai-cc-skills/templates/SKILL-template.md +0 -15
  272. moai_adk/templates/.claude/skills/moai-design-systems/SKILL.md +0 -802
  273. moai_adk/templates/.claude/skills/moai-design-systems/examples.md +0 -1238
  274. moai_adk/templates/.claude/skills/moai-design-systems/reference.md +0 -673
  275. moai_adk/templates/.claude/skills/moai-domain-backend/SKILL.md +0 -290
  276. moai_adk/templates/.claude/skills/moai-domain-backend/examples.md +0 -1633
  277. moai_adk/templates/.claude/skills/moai-domain-backend/reference.md +0 -660
  278. moai_adk/templates/.claude/skills/moai-domain-cli-tool/SKILL.md +0 -123
  279. moai_adk/templates/.claude/skills/moai-domain-cli-tool/examples.md +0 -29
  280. moai_adk/templates/.claude/skills/moai-domain-cli-tool/reference.md +0 -30
  281. moai_adk/templates/.claude/skills/moai-domain-data-science/SKILL.md +0 -123
  282. moai_adk/templates/.claude/skills/moai-domain-data-science/examples.md +0 -29
  283. moai_adk/templates/.claude/skills/moai-domain-data-science/reference.md +0 -30
  284. moai_adk/templates/.claude/skills/moai-domain-database/SKILL.md +0 -123
  285. moai_adk/templates/.claude/skills/moai-domain-database/examples.md +0 -29
  286. moai_adk/templates/.claude/skills/moai-domain-database/reference.md +0 -30
  287. moai_adk/templates/.claude/skills/moai-domain-devops/SKILL.md +0 -124
  288. moai_adk/templates/.claude/skills/moai-domain-devops/examples.md +0 -29
  289. moai_adk/templates/.claude/skills/moai-domain-devops/reference.md +0 -31
  290. moai_adk/templates/.claude/skills/moai-domain-frontend/SKILL.md +0 -128
  291. moai_adk/templates/.claude/skills/moai-domain-frontend/examples.md +0 -29
  292. moai_adk/templates/.claude/skills/moai-domain-frontend/reference.md +0 -31
  293. moai_adk/templates/.claude/skills/moai-domain-ml/SKILL.md +0 -123
  294. moai_adk/templates/.claude/skills/moai-domain-ml/examples.md +0 -29
  295. moai_adk/templates/.claude/skills/moai-domain-ml/reference.md +0 -30
  296. moai_adk/templates/.claude/skills/moai-domain-mobile-app/SKILL.md +0 -123
  297. moai_adk/templates/.claude/skills/moai-domain-mobile-app/examples.md +0 -29
  298. moai_adk/templates/.claude/skills/moai-domain-mobile-app/reference.md +0 -30
  299. moai_adk/templates/.claude/skills/moai-domain-security/SKILL.md +0 -123
  300. moai_adk/templates/.claude/skills/moai-domain-security/examples.md +0 -29
  301. moai_adk/templates/.claude/skills/moai-domain-security/reference.md +0 -30
  302. moai_adk/templates/.claude/skills/moai-domain-web-api/SKILL.md +0 -123
  303. moai_adk/templates/.claude/skills/moai-domain-web-api/examples.md +0 -29
  304. moai_adk/templates/.claude/skills/moai-domain-web-api/reference.md +0 -30
  305. moai_adk/templates/.claude/skills/moai-essentials-debug/SKILL.md +0 -303
  306. moai_adk/templates/.claude/skills/moai-essentials-debug/examples.md +0 -1064
  307. moai_adk/templates/.claude/skills/moai-essentials-debug/reference.md +0 -1047
  308. moai_adk/templates/.claude/skills/moai-essentials-perf/SKILL.md +0 -113
  309. moai_adk/templates/.claude/skills/moai-essentials-perf/examples.md +0 -29
  310. moai_adk/templates/.claude/skills/moai-essentials-perf/reference.md +0 -28
  311. moai_adk/templates/.claude/skills/moai-essentials-refactor/SKILL.md +0 -113
  312. moai_adk/templates/.claude/skills/moai-essentials-refactor/examples.md +0 -29
  313. moai_adk/templates/.claude/skills/moai-essentials-refactor/reference.md +0 -28
  314. moai_adk/templates/.claude/skills/moai-essentials-review/SKILL.md +0 -113
  315. moai_adk/templates/.claude/skills/moai-essentials-review/examples.md +0 -29
  316. moai_adk/templates/.claude/skills/moai-essentials-review/reference.md +0 -28
  317. moai_adk/templates/.claude/skills/moai-foundation-ears/SKILL.md +0 -116
  318. moai_adk/templates/.claude/skills/moai-foundation-ears/examples.md +0 -29
  319. moai_adk/templates/.claude/skills/moai-foundation-ears/reference.md +0 -28
  320. moai_adk/templates/.claude/skills/moai-foundation-git/SKILL.md +0 -122
  321. moai_adk/templates/.claude/skills/moai-foundation-git/examples.md +0 -29
  322. moai_adk/templates/.claude/skills/moai-foundation-git/reference.md +0 -29
  323. moai_adk/templates/.claude/skills/moai-foundation-langs/SKILL.md +0 -113
  324. moai_adk/templates/.claude/skills/moai-foundation-langs/examples.md +0 -29
  325. moai_adk/templates/.claude/skills/moai-foundation-langs/reference.md +0 -28
  326. moai_adk/templates/.claude/skills/moai-foundation-specs/SKILL.md +0 -113
  327. moai_adk/templates/.claude/skills/moai-foundation-specs/examples.md +0 -29
  328. moai_adk/templates/.claude/skills/moai-foundation-specs/reference.md +0 -28
  329. moai_adk/templates/.claude/skills/moai-foundation-tags/SKILL.md +0 -113
  330. moai_adk/templates/.claude/skills/moai-foundation-tags/examples.md +0 -29
  331. moai_adk/templates/.claude/skills/moai-foundation-tags/reference.md +0 -28
  332. moai_adk/templates/.claude/skills/moai-foundation-trust/SKILL.md +0 -307
  333. moai_adk/templates/.claude/skills/moai-foundation-trust/examples.md +0 -0
  334. moai_adk/templates/.claude/skills/moai-foundation-trust/reference.md +0 -1099
  335. moai_adk/templates/.claude/skills/moai-lang-c/SKILL.md +0 -124
  336. moai_adk/templates/.claude/skills/moai-lang-c/examples.md +0 -29
  337. moai_adk/templates/.claude/skills/moai-lang-c/reference.md +0 -31
  338. moai_adk/templates/.claude/skills/moai-lang-cpp/SKILL.md +0 -124
  339. moai_adk/templates/.claude/skills/moai-lang-cpp/examples.md +0 -29
  340. moai_adk/templates/.claude/skills/moai-lang-cpp/reference.md +0 -31
  341. moai_adk/templates/.claude/skills/moai-lang-csharp/SKILL.md +0 -123
  342. moai_adk/templates/.claude/skills/moai-lang-csharp/examples.md +0 -29
  343. moai_adk/templates/.claude/skills/moai-lang-csharp/reference.md +0 -30
  344. moai_adk/templates/.claude/skills/moai-lang-dart/SKILL.md +0 -123
  345. moai_adk/templates/.claude/skills/moai-lang-dart/examples.md +0 -29
  346. moai_adk/templates/.claude/skills/moai-lang-dart/reference.md +0 -30
  347. moai_adk/templates/.claude/skills/moai-lang-go/SKILL.md +0 -127
  348. moai_adk/templates/.claude/skills/moai-lang-go/examples.md +0 -29
  349. moai_adk/templates/.claude/skills/moai-lang-go/reference.md +0 -31
  350. moai_adk/templates/.claude/skills/moai-lang-java/SKILL.md +0 -126
  351. moai_adk/templates/.claude/skills/moai-lang-java/examples.md +0 -29
  352. moai_adk/templates/.claude/skills/moai-lang-java/reference.md +0 -31
  353. moai_adk/templates/.claude/skills/moai-lang-javascript/SKILL.md +0 -125
  354. moai_adk/templates/.claude/skills/moai-lang-javascript/examples.md +0 -29
  355. moai_adk/templates/.claude/skills/moai-lang-javascript/reference.md +0 -32
  356. moai_adk/templates/.claude/skills/moai-lang-kotlin/SKILL.md +0 -124
  357. moai_adk/templates/.claude/skills/moai-lang-kotlin/examples.md +0 -29
  358. moai_adk/templates/.claude/skills/moai-lang-kotlin/reference.md +0 -31
  359. moai_adk/templates/.claude/skills/moai-lang-php/SKILL.md +0 -126
  360. moai_adk/templates/.claude/skills/moai-lang-php/examples.md +0 -29
  361. moai_adk/templates/.claude/skills/moai-lang-php/reference.md +0 -30
  362. moai_adk/templates/.claude/skills/moai-lang-python/SKILL.md +0 -433
  363. moai_adk/templates/.claude/skills/moai-lang-python/examples.md +0 -624
  364. moai_adk/templates/.claude/skills/moai-lang-python/reference.md +0 -316
  365. moai_adk/templates/.claude/skills/moai-lang-r/SKILL.md +0 -123
  366. moai_adk/templates/.claude/skills/moai-lang-r/examples.md +0 -29
  367. moai_adk/templates/.claude/skills/moai-lang-r/reference.md +0 -30
  368. moai_adk/templates/.claude/skills/moai-lang-ruby/SKILL.md +0 -124
  369. moai_adk/templates/.claude/skills/moai-lang-ruby/examples.md +0 -29
  370. moai_adk/templates/.claude/skills/moai-lang-ruby/reference.md +0 -31
  371. moai_adk/templates/.claude/skills/moai-lang-rust/SKILL.md +0 -127
  372. moai_adk/templates/.claude/skills/moai-lang-rust/examples.md +0 -29
  373. moai_adk/templates/.claude/skills/moai-lang-rust/reference.md +0 -31
  374. moai_adk/templates/.claude/skills/moai-lang-scala/SKILL.md +0 -125
  375. moai_adk/templates/.claude/skills/moai-lang-scala/examples.md +0 -29
  376. moai_adk/templates/.claude/skills/moai-lang-scala/reference.md +0 -30
  377. moai_adk/templates/.claude/skills/moai-lang-shell/SKILL.md +0 -123
  378. moai_adk/templates/.claude/skills/moai-lang-shell/examples.md +0 -29
  379. moai_adk/templates/.claude/skills/moai-lang-shell/reference.md +0 -30
  380. moai_adk/templates/.claude/skills/moai-lang-sql/SKILL.md +0 -124
  381. moai_adk/templates/.claude/skills/moai-lang-sql/examples.md +0 -29
  382. moai_adk/templates/.claude/skills/moai-lang-sql/reference.md +0 -31
  383. moai_adk/templates/.claude/skills/moai-lang-swift/SKILL.md +0 -123
  384. moai_adk/templates/.claude/skills/moai-lang-swift/examples.md +0 -29
  385. moai_adk/templates/.claude/skills/moai-lang-swift/reference.md +0 -30
  386. moai_adk/templates/.claude/skills/moai-lang-typescript/SKILL.md +0 -133
  387. moai_adk/templates/.claude/skills/moai-lang-typescript/examples.md +0 -29
  388. moai_adk/templates/.claude/skills/moai-lang-typescript/reference.md +0 -34
  389. moai_adk/templates/.claude/skills/moai-project-documentation.md +0 -622
  390. moai_adk/templates/.github/workflows/c-tag-validation.yml +0 -11
  391. moai_adk/templates/.github/workflows/cpp-tag-validation.yml +0 -11
  392. moai_adk/templates/.github/workflows/csharp-tag-validation.yml +0 -11
  393. moai_adk/templates/.github/workflows/dart-tag-validation.yml +0 -11
  394. moai_adk/templates/.github/workflows/go-tag-validation.yml +0 -130
  395. moai_adk/templates/.github/workflows/java-tag-validation.yml +0 -11
  396. moai_adk/templates/.github/workflows/javascript-tag-validation.yml +0 -135
  397. moai_adk/templates/.github/workflows/kotlin-tag-validation.yml +0 -11
  398. moai_adk/templates/.github/workflows/php-tag-validation.yml +0 -11
  399. moai_adk/templates/.github/workflows/python-tag-validation.yml +0 -118
  400. moai_adk/templates/.github/workflows/release.yml +0 -118
  401. moai_adk/templates/.github/workflows/ruby-tag-validation.yml +0 -11
  402. moai_adk/templates/.github/workflows/rust-tag-validation.yml +0 -11
  403. moai_adk/templates/.github/workflows/shell-tag-validation.yml +0 -11
  404. moai_adk/templates/.github/workflows/swift-tag-validation.yml +0 -11
  405. moai_adk/templates/.github/workflows/tag-report.yml +0 -269
  406. moai_adk/templates/.github/workflows/tag-validation.yml +0 -186
  407. moai_adk/templates/.github/workflows/typescript-tag-validation.yml +0 -154
  408. moai_adk/templates/.moai/config.json +0 -115
  409. moai_adk/templates/workflows/go-tag-validation.yml +0 -30
  410. moai_adk/templates/workflows/javascript-tag-validation.yml +0 -41
  411. moai_adk/templates/workflows/python-tag-validation.yml +0 -42
  412. moai_adk/templates/workflows/typescript-tag-validation.yml +0 -31
  413. moai_adk-0.15.0.dist-info/METADATA +0 -3079
  414. moai_adk-0.15.0.dist-info/RECORD +0 -365
  415. {moai_adk-0.15.0.dist-info → moai_adk-0.25.4.dist-info}/WHEEL +0 -0
  416. {moai_adk-0.15.0.dist-info → moai_adk-0.25.4.dist-info}/entry_points.txt +0 -0
  417. {moai_adk-0.15.0.dist-info → moai_adk-0.25.4.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,421 @@
1
+ """
2
+ Claude Code CLI integration for advanced variable substitution and automation.
3
+
4
+ Enables headless operation with template variable processing, JSON streaming,
5
+ and multi-language support for commands, agents, and output styles.
6
+ """
7
+
8
+ import json
9
+ import subprocess
10
+ import tempfile
11
+ from pathlib import Path
12
+ from typing import Any, Dict, Optional, Union
13
+
14
+ from .language_config import get_language_info
15
+ from .template_engine import TemplateEngine
16
+
17
+
18
+ class ClaudeCLIIntegration:
19
+ """
20
+ Advanced Claude CLI integration with template variable processing.
21
+
22
+ Features:
23
+ - Template variable substitution using MoAI-ADK's TemplateEngine
24
+ - JSON streaming input/output support
25
+ - Multi-language description processing
26
+ - Headless automation capabilities
27
+ - Configuration file generation and management
28
+ """
29
+
30
+ def __init__(self, template_engine: Optional[TemplateEngine] = None):
31
+ """Initialize Claude CLI integration.
32
+
33
+ Args:
34
+ template_engine: TemplateEngine instance for variable processing
35
+ """
36
+ self.template_engine = template_engine or TemplateEngine()
37
+
38
+ def generate_claude_settings(
39
+ self, variables: Dict[str, Any], output_path: Optional[Path] = None
40
+ ) -> Path:
41
+ """Generate Claude settings JSON file with variables.
42
+
43
+ Args:
44
+ variables: Template variables to include
45
+ output_path: Path for settings file (auto-generated if None)
46
+
47
+ Returns:
48
+ Path to generated settings file
49
+ """
50
+ if output_path is None:
51
+ temp_file = tempfile.NamedTemporaryFile(
52
+ mode="w", suffix=".json", delete=False
53
+ )
54
+ output_path = Path(temp_file.name)
55
+ temp_file.close()
56
+
57
+ settings = {
58
+ "variables": variables,
59
+ "template_context": {
60
+ "conversation_language": variables.get("CONVERSATION_LANGUAGE", "en"),
61
+ "conversation_language_name": variables.get(
62
+ "CONVERSATION_LANGUAGE_NAME", "English"
63
+ ),
64
+ "project_name": variables.get("PROJECT_NAME", ""),
65
+ "codebase_language": variables.get("CODEBASE_LANGUAGE", "python"),
66
+ },
67
+ }
68
+
69
+ output_path.write_text(json.dumps(settings, indent=2, ensure_ascii=False))
70
+ return output_path
71
+
72
+ def process_template_command(
73
+ self,
74
+ command_template: str,
75
+ variables: Dict[str, Any],
76
+ print_mode: bool = True,
77
+ output_format: str = "json",
78
+ ) -> Dict[str, Any]:
79
+ """Process Claude command with template variables.
80
+
81
+ Args:
82
+ command_template: Command template with {{VARIABLE}} placeholders
83
+ variables: Variables for substitution
84
+ print_mode: Use --print flag for non-interactive execution
85
+ output_format: Output format (text, json, stream-json)
86
+
87
+ Returns:
88
+ Process result dictionary
89
+ """
90
+ try:
91
+ # Process template variables
92
+ processed_command = self.template_engine.render_string(
93
+ command_template, variables
94
+ )
95
+
96
+ # Build Claude CLI command
97
+ cmd_parts = ["claude"]
98
+
99
+ if print_mode:
100
+ cmd_parts.extend(["--print"])
101
+ cmd_parts.extend(["--output-format", output_format])
102
+
103
+ # Add variable settings
104
+ settings_file = self.generate_claude_settings(variables)
105
+ cmd_parts.extend(["--settings", str(settings_file)])
106
+
107
+ # Add processed command
108
+ cmd_parts.append(processed_command)
109
+
110
+ # Execute Claude CLI
111
+ result = subprocess.run(
112
+ cmd_parts, capture_output=True, text=True, encoding="utf-8"
113
+ )
114
+
115
+ # Cleanup settings file
116
+ try:
117
+ settings_file.unlink()
118
+ except:
119
+ pass # Ignore cleanup errors
120
+
121
+ return {
122
+ "success": result.returncode == 0,
123
+ "stdout": result.stdout,
124
+ "stderr": result.stderr,
125
+ "returncode": result.returncode,
126
+ "processed_command": processed_command,
127
+ "variables_used": variables,
128
+ }
129
+
130
+ except Exception as e:
131
+ return {
132
+ "success": False,
133
+ "error": str(e),
134
+ "processed_command": command_template,
135
+ "variables_used": variables,
136
+ }
137
+
138
+ def generate_multilingual_descriptions(
139
+ self,
140
+ base_descriptions: Dict[str, str],
141
+ target_languages: Optional[list[str]] = None,
142
+ ) -> Dict[str, Dict[str, str]]:
143
+ """Generate multilingual descriptions for commands/agents.
144
+
145
+ Args:
146
+ base_descriptions: English base descriptions
147
+ target_languages: Target language codes (auto-detected if None)
148
+
149
+ Returns:
150
+ Multilingual descriptions dictionary
151
+ """
152
+ if target_languages is None:
153
+ # Auto-detect from variables or use common languages
154
+ target_languages = ["en", "ko", "ja", "es", "fr", "de"]
155
+
156
+ multilingual = {}
157
+
158
+ for item_id, base_desc in base_descriptions.items():
159
+ multilingual[item_id] = {"en": base_desc}
160
+
161
+ # Generate descriptions for target languages
162
+ for lang_code in target_languages:
163
+ if lang_code == "en":
164
+ continue # Already have base
165
+
166
+ lang_info = get_language_info(lang_code)
167
+ if not lang_info:
168
+ continue
169
+
170
+ # Create language-specific description prompt
171
+ translation_prompt = f"""Translate the following Claude Code description to {lang_info['native_name']}.
172
+ Keep technical terms in English. Provide only the translation without explanation:
173
+
174
+ Original: {base_desc}
175
+
176
+ Translation:"""
177
+
178
+ # Use Claude CLI for translation
179
+ translation_result = self.process_template_command(
180
+ translation_prompt,
181
+ {"CONVERSATION_LANGUAGE": lang_code},
182
+ print_mode=True,
183
+ output_format="text",
184
+ )
185
+
186
+ if translation_result["success"]:
187
+ # Extract translation from output
188
+ translation = translation_result["stdout"].strip()
189
+ if translation:
190
+ multilingual[item_id][lang_code] = translation
191
+
192
+ return multilingual
193
+
194
+ def create_agent_with_multilingual_support(
195
+ self,
196
+ agent_name: str,
197
+ base_description: str,
198
+ tools: list[str],
199
+ model: str = "sonnet",
200
+ target_languages: Optional[list[str]] = None,
201
+ ) -> Dict[str, Any]:
202
+ """Create Claude agent with multilingual description support.
203
+
204
+ Args:
205
+ agent_name: Agent name (kebab-case)
206
+ base_description: English base description
207
+ tools: List of required tools
208
+ model: Claude model to use
209
+ target_languages: Target languages for descriptions
210
+
211
+ Returns:
212
+ Agent configuration dictionary
213
+ """
214
+ if target_languages is None:
215
+ target_languages = ["en", "ko", "ja", "es", "fr", "de"]
216
+
217
+ # Generate multilingual descriptions
218
+ descriptions = self.generate_multilingual_descriptions(
219
+ {agent_name: base_description}, target_languages
220
+ )
221
+
222
+ agent_config = {
223
+ "name": agent_name,
224
+ "description": descriptions[agent_name][
225
+ "en"
226
+ ], # Primary English description
227
+ "tools": tools,
228
+ "model": model,
229
+ "descriptions": descriptions[agent_name], # All language versions
230
+ "multilingual_support": True,
231
+ }
232
+
233
+ return agent_config
234
+
235
+ def create_command_with_multilingual_support(
236
+ self,
237
+ command_name: str,
238
+ base_description: str,
239
+ argument_hint: list[str],
240
+ tools: list[str],
241
+ model: str = "haiku",
242
+ target_languages: Optional[list[str]] = None,
243
+ ) -> Dict[str, Any]:
244
+ """Create Claude command with multilingual description support.
245
+
246
+ Args:
247
+ command_name: Command name (kebab-case)
248
+ base_description: English base description
249
+ argument_hint: List of argument hints
250
+ tools: List of required tools
251
+ model: Claude model to use
252
+ target_languages: Target languages for descriptions
253
+
254
+ Returns:
255
+ Command configuration dictionary
256
+ """
257
+ if target_languages is None:
258
+ target_languages = ["en", "ko", "ja", "es", "fr", "de"]
259
+
260
+ # Generate multilingual descriptions
261
+ descriptions = self.generate_multilingual_descriptions(
262
+ {command_name: base_description}, target_languages
263
+ )
264
+
265
+ command_config = {
266
+ "name": command_name,
267
+ "description": descriptions[command_name][
268
+ "en"
269
+ ], # Primary English description
270
+ "argument-hint": argument_hint,
271
+ "tools": tools,
272
+ "model": model,
273
+ "descriptions": descriptions[command_name], # All language versions
274
+ "multilingual_support": True,
275
+ }
276
+
277
+ return command_config
278
+
279
+ def process_json_stream_input(
280
+ self,
281
+ input_data: Union[Dict[str, Any], str],
282
+ variables: Optional[Dict[str, Any]] = None,
283
+ ) -> Dict[str, Any]:
284
+ """Process JSON stream input for Claude CLI.
285
+
286
+ Args:
287
+ input_data: JSON data as dict or JSON string
288
+ variables: Additional variables for processing
289
+
290
+ Returns:
291
+ Processed input data
292
+ """
293
+ if isinstance(input_data, str):
294
+ try:
295
+ input_data = json.loads(input_data)
296
+ except json.JSONDecodeError as e:
297
+ raise ValueError(f"Invalid JSON input: {e}")
298
+
299
+ if variables:
300
+ # Process any string values in input_data with variables
301
+ for key, value in input_data.items():
302
+ if isinstance(value, str) and "{{" in value and "}}" in value:
303
+ input_data[key] = self.template_engine.render_string(
304
+ value, variables
305
+ )
306
+
307
+ return input_data
308
+
309
+ def execute_headless_command(
310
+ self,
311
+ prompt_template: str,
312
+ variables: Dict[str, Any],
313
+ input_format: str = "stream-json",
314
+ output_format: str = "stream-json",
315
+ additional_options: Optional[list[str]] = None,
316
+ ) -> Dict[str, Any]:
317
+ """Execute Claude command in headless mode with full variable processing.
318
+
319
+ Args:
320
+ prompt_template: Prompt template with variables
321
+ variables: Variables for substitution
322
+ input_format: Input format (text, stream-json)
323
+ output_format: Output format (text, json, stream-json)
324
+ additional_options: Additional CLI options
325
+
326
+ Returns:
327
+ Command execution result
328
+ """
329
+ try:
330
+ # Process prompt template
331
+ processed_prompt = self.template_engine.render_string(
332
+ prompt_template, variables
333
+ )
334
+
335
+ # Build Claude command
336
+ cmd_parts = ["claude", "--print"]
337
+ cmd_parts.extend(["--input-format", input_format])
338
+ cmd_parts.extend(["--output-format", output_format])
339
+
340
+ # Add settings
341
+ settings_file = self.generate_claude_settings(variables)
342
+ cmd_parts.extend(["--settings", str(settings_file)])
343
+
344
+ # Add additional options
345
+ if additional_options:
346
+ cmd_parts.extend(additional_options)
347
+
348
+ # Add processed prompt
349
+ cmd_parts.append(processed_prompt)
350
+
351
+ # Execute with streaming support
352
+ if output_format == "stream-json":
353
+ # For streaming, use subprocess with real-time output
354
+ process = subprocess.Popen(
355
+ cmd_parts,
356
+ stdout=subprocess.PIPE,
357
+ stderr=subprocess.PIPE,
358
+ text=True,
359
+ encoding="utf-8",
360
+ )
361
+
362
+ stdout_lines = []
363
+ stderr_lines = []
364
+
365
+ # Stream output in real-time
366
+ while True:
367
+ stdout_line = process.stdout.readline()
368
+ stderr_line = process.stderr.readline()
369
+
370
+ if (
371
+ stdout_line == ""
372
+ and stderr_line == ""
373
+ and process.poll() is not None
374
+ ):
375
+ break
376
+
377
+ if stdout_line:
378
+ stdout_lines.append(stdout_line.strip())
379
+ # You can process each line here for real-time handling
380
+
381
+ if stderr_line:
382
+ stderr_lines.append(stderr_line.strip())
383
+
384
+ returncode = process.poll()
385
+
386
+ else:
387
+ # Non-streaming execution
388
+ result = subprocess.run(
389
+ cmd_parts, capture_output=True, text=True, encoding="utf-8"
390
+ )
391
+
392
+ stdout_lines = (
393
+ result.stdout.strip().split("\n") if result.stdout else []
394
+ )
395
+ stderr_lines = (
396
+ result.stderr.strip().split("\n") if result.stderr else []
397
+ )
398
+ returncode = result.returncode
399
+
400
+ # Cleanup
401
+ try:
402
+ settings_file.unlink()
403
+ except:
404
+ pass
405
+
406
+ return {
407
+ "success": returncode == 0,
408
+ "stdout": stdout_lines,
409
+ "stderr": stderr_lines,
410
+ "returncode": returncode,
411
+ "processed_prompt": processed_prompt,
412
+ "variables": variables,
413
+ }
414
+
415
+ except Exception as e:
416
+ return {
417
+ "success": False,
418
+ "error": str(e),
419
+ "prompt_template": prompt_template,
420
+ "variables": variables,
421
+ }
@@ -0,0 +1,270 @@
1
+ """
2
+ Command Helper Utilities
3
+
4
+ Provides helper functions for commands to interact with ContextManager
5
+ and perform common operations like context extraction and validation.
6
+ """
7
+
8
+ import json
9
+ import os
10
+ from datetime import datetime, timezone
11
+ from typing import Any, Dict, List, Optional
12
+
13
+ # Conditional import of ContextManager
14
+ try:
15
+ from moai_adk.core.context_manager import (
16
+ ContextManager,
17
+ validate_and_convert_path,
18
+ validate_no_template_vars,
19
+ )
20
+
21
+ CONTEXT_MANAGER_AVAILABLE = True
22
+ except ImportError:
23
+ CONTEXT_MANAGER_AVAILABLE = False
24
+
25
+
26
+ def extract_project_metadata(project_root: str) -> Dict[str, Any]:
27
+ """
28
+ Extract project metadata from config.json.
29
+
30
+ Args:
31
+ project_root: Root directory of the project
32
+
33
+ Returns:
34
+ Dictionary containing project metadata
35
+
36
+ Raises:
37
+ FileNotFoundError: If config.json doesn't exist
38
+ json.JSONDecodeError: If config.json is invalid
39
+ """
40
+ config_path = os.path.join(project_root, ".moai", "config", "config.json")
41
+
42
+ if not os.path.exists(config_path):
43
+ raise FileNotFoundError(f"Config file not found: {config_path}")
44
+
45
+ with open(config_path, "r") as f:
46
+ config = json.load(f)
47
+
48
+ # Extract key metadata
49
+ metadata = {
50
+ "project_name": config.get("project", {}).get("name", "Unknown"),
51
+ "mode": config.get("project", {}).get("mode", "personal"),
52
+ "owner": config.get("project", {}).get("owner", "@user"),
53
+ "language": config.get("language", {}).get("conversation_language", "en"),
54
+ "tech_stack": [], # To be detected separately
55
+ }
56
+
57
+ return metadata
58
+
59
+
60
+ def detect_tech_stack(project_root: str) -> List[str]:
61
+ """
62
+ Detect primary tech stack from project structure.
63
+
64
+ Checks for common project indicator files.
65
+
66
+ Args:
67
+ project_root: Root directory of the project
68
+
69
+ Returns:
70
+ List of detected languages/frameworks
71
+ """
72
+ indicators = {
73
+ "pyproject.toml": "python",
74
+ "package.json": "javascript",
75
+ "go.mod": "go",
76
+ "Cargo.toml": "rust",
77
+ "pom.xml": "java",
78
+ "Gemfile": "ruby",
79
+ }
80
+
81
+ tech_stack = []
82
+
83
+ for indicator_file, language in indicators.items():
84
+ if os.path.exists(os.path.join(project_root, indicator_file)):
85
+ tech_stack.append(language)
86
+
87
+ # Default to python if nothing detected
88
+ if not tech_stack:
89
+ tech_stack.append("python")
90
+
91
+ return tech_stack
92
+
93
+
94
+ def build_phase_result(
95
+ phase_name: str,
96
+ status: str,
97
+ outputs: Dict[str, Any],
98
+ files_created: List[str],
99
+ next_phase: Optional[str] = None,
100
+ ) -> Dict[str, Any]:
101
+ """
102
+ Build standardized phase result dictionary.
103
+
104
+ Args:
105
+ phase_name: Name of the phase (e.g., "0-project")
106
+ status: Phase status (completed/error/interrupted)
107
+ outputs: Dictionary of phase outputs
108
+ files_created: List of created files (absolute paths)
109
+ next_phase: Optional next phase name
110
+
111
+ Returns:
112
+ Standardized phase result dictionary
113
+ """
114
+ phase_result = {
115
+ "phase": phase_name,
116
+ "timestamp": datetime.now(timezone.utc).isoformat().replace("+00:00", "Z"),
117
+ "status": status,
118
+ "outputs": outputs,
119
+ "files_created": files_created,
120
+ }
121
+
122
+ if next_phase:
123
+ phase_result["next_phase"] = next_phase
124
+
125
+ return phase_result
126
+
127
+
128
+ def validate_phase_files(relative_paths: List[str], project_root: str) -> List[str]:
129
+ """
130
+ Validate and convert relative file paths to absolute paths.
131
+
132
+ Handles errors gracefully by logging warnings and skipping invalid paths.
133
+
134
+ Args:
135
+ relative_paths: List of relative file paths
136
+ project_root: Project root directory
137
+
138
+ Returns:
139
+ List of validated absolute paths
140
+ """
141
+ if not CONTEXT_MANAGER_AVAILABLE:
142
+ # Fallback: simple absolute path conversion
143
+ return [os.path.abspath(os.path.join(project_root, p)) for p in relative_paths]
144
+
145
+ absolute_paths = []
146
+
147
+ for rel_path in relative_paths:
148
+ try:
149
+ abs_path = validate_and_convert_path(rel_path, project_root)
150
+ absolute_paths.append(abs_path)
151
+ except (ValueError, FileNotFoundError) as e:
152
+ # Log warning but continue processing
153
+ print(f"Warning: Could not validate path '{rel_path}': {e}")
154
+
155
+ return absolute_paths
156
+
157
+
158
+ def _prepare_phase_data(
159
+ phase_name: str,
160
+ status: str,
161
+ outputs: Dict[str, Any],
162
+ absolute_paths: List[str],
163
+ next_phase: Optional[str],
164
+ ) -> Dict[str, Any]:
165
+ """
166
+ Prepare phase data for saving.
167
+
168
+ Args:
169
+ phase_name: Name of the phase
170
+ status: Phase status
171
+ outputs: Phase outputs
172
+ absolute_paths: List of absolute file paths
173
+ next_phase: Optional next phase
174
+
175
+ Returns:
176
+ Phase data dictionary ready for saving
177
+ """
178
+ phase_data = build_phase_result(
179
+ phase_name=phase_name,
180
+ status=status,
181
+ outputs=outputs,
182
+ files_created=absolute_paths,
183
+ next_phase=next_phase,
184
+ )
185
+
186
+ # Validate no unsubstituted template variables
187
+ phase_json = json.dumps(phase_data)
188
+ validate_no_template_vars(phase_json)
189
+
190
+ return phase_data
191
+
192
+
193
+ def _validate_and_save(context_mgr: Any, phase_data: Dict[str, Any]) -> str:
194
+ """
195
+ Validate and save phase data.
196
+
197
+ Args:
198
+ context_mgr: ContextManager instance
199
+ phase_data: Phase data to save
200
+
201
+ Returns:
202
+ Path to saved file
203
+ """
204
+ saved_path = context_mgr.save_phase_result(phase_data)
205
+ print(f"✓ Phase context saved: {os.path.basename(saved_path)}")
206
+ return saved_path
207
+
208
+
209
+ def save_command_context(
210
+ phase_name: str,
211
+ project_root: str,
212
+ outputs: Dict[str, Any],
213
+ files_created: List[str],
214
+ next_phase: Optional[str] = None,
215
+ status: str = "completed",
216
+ ) -> Optional[str]:
217
+ """
218
+ Save command phase context using ContextManager.
219
+
220
+ This is a convenience wrapper for commands to save phase results
221
+ with proper error handling.
222
+
223
+ Args:
224
+ phase_name: Name of the phase (e.g., "0-project")
225
+ project_root: Project root directory
226
+ outputs: Phase-specific outputs
227
+ files_created: List of relative file paths
228
+ next_phase: Optional next phase recommendation
229
+ status: Phase status (default: "completed")
230
+
231
+ Returns:
232
+ Path to saved file, or None if save failed
233
+ """
234
+ if not CONTEXT_MANAGER_AVAILABLE:
235
+ print("Warning: ContextManager not available. Phase context not saved.")
236
+ return None
237
+
238
+ try:
239
+ context_mgr = ContextManager(project_root)
240
+ absolute_paths = validate_phase_files(files_created, project_root)
241
+ phase_data = _prepare_phase_data(
242
+ phase_name, status, outputs, absolute_paths, next_phase
243
+ )
244
+ return _validate_and_save(context_mgr, phase_data)
245
+
246
+ except Exception as e:
247
+ print(f"Warning: Failed to save phase context: {e}")
248
+ print("Command execution continues normally.")
249
+ return None
250
+
251
+
252
+ def load_previous_phase(project_root: str) -> Optional[Dict[str, Any]]:
253
+ """
254
+ Load the most recent phase result.
255
+
256
+ Args:
257
+ project_root: Project root directory
258
+
259
+ Returns:
260
+ Phase result dictionary, or None if unavailable
261
+ """
262
+ if not CONTEXT_MANAGER_AVAILABLE:
263
+ return None
264
+
265
+ try:
266
+ context_mgr = ContextManager(project_root)
267
+ return context_mgr.load_latest_phase()
268
+ except Exception as e:
269
+ print(f"Warning: Could not load previous phase: {e}")
270
+ return None
@@ -3,11 +3,17 @@
3
3
  from moai_adk.core.config.migration import (
4
4
  get_conversation_language,
5
5
  get_conversation_language_name,
6
+ get_report_generation_config,
7
+ get_spec_git_workflow,
8
+ migrate_config_schema_v0_17_0,
6
9
  migrate_config_to_nested_structure,
7
10
  )
8
11
 
9
12
  __all__ = [
10
13
  "migrate_config_to_nested_structure",
14
+ "migrate_config_schema_v0_17_0",
11
15
  "get_conversation_language",
12
16
  "get_conversation_language_name",
17
+ "get_report_generation_config",
18
+ "get_spec_git_workflow",
13
19
  ]