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
@@ -0,0 +1,1336 @@
1
+ """
2
+ MoAI Menu Project - Documentation Manager Module
3
+
4
+ Enhanced documentation management system with template-based generation,
5
+ multi-format output, and intelligent content organization.
6
+
7
+ Integrates patterns from moai-project-documentation skill with advanced
8
+ template processing and automation capabilities.
9
+ """
10
+
11
+ import shutil
12
+ from datetime import datetime
13
+ from pathlib import Path
14
+ from typing import Any, Dict, Optional
15
+
16
+
17
+ class DocumentationManager:
18
+ """Comprehensive documentation management system."""
19
+
20
+ def __init__(self, project_root: str, config: Dict[str, Any]):
21
+ self.project_root = Path(project_root)
22
+ self.config = config
23
+ self.docs_dir = self.project_root / "docs"
24
+ self.templates_dir = self.project_root / ".claude/skills/moai-menu-project/templates/doc-templates"
25
+ self._ensure_directories()
26
+
27
+ def _ensure_directories(self):
28
+ """Ensure all necessary directories exist."""
29
+ self.docs_dir.mkdir(parents=True, exist_ok=True)
30
+ self.templates_dir.mkdir(parents=True, exist_ok=True)
31
+ (self.docs_dir / "api").mkdir(exist_ok=True)
32
+ (self.docs_dir / "architecture").mkdir(exist_ok=True)
33
+ (self.docs_dir / "guides").mkdir(exist_ok=True)
34
+
35
+ def initialize_documentation_structure(self) -> Dict[str, Any]:
36
+ """
37
+ Initialize project documentation structure based on project type.
38
+
39
+ Returns:
40
+ Dict with initialization results and created files.
41
+ """
42
+ project_type = self._detect_project_type()
43
+ language = self.config.get("language", {}).get("conversation_language", "en")
44
+
45
+ # Initialize core documentation files
46
+ core_docs = {
47
+ "product.md": self._generate_product_doc(project_type, language),
48
+ "structure.md": self._generate_structure_doc(project_type, language),
49
+ "tech.md": self._generate_tech_doc(project_type, language),
50
+ }
51
+
52
+ created_files = []
53
+
54
+ for doc_name, content in core_docs.items():
55
+ doc_path = self.docs_dir / doc_name
56
+ if not doc_path.exists():
57
+ doc_path.write_text(content, encoding="utf-8")
58
+ created_files.append(str(doc_path))
59
+
60
+ # Create API documentation structure
61
+ api_structure = self._create_api_structure(project_type)
62
+
63
+ # Create guides structure
64
+ guides_structure = self._create_guides_structure(project_type, language)
65
+
66
+ return {
67
+ "project_type": project_type,
68
+ "language": language,
69
+ "created_files": created_files,
70
+ "api_structure": api_structure,
71
+ "guides_structure": guides_structure,
72
+ }
73
+
74
+ def _detect_project_type(self) -> str:
75
+ """Detect project type based on project structure and configuration."""
76
+
77
+ # Check for explicit project type in config
78
+ project_type = self.config.get("project", {}).get("type")
79
+ if project_type:
80
+ return project_type
81
+
82
+ # Analyze project structure
83
+ src_path = self.project_root / "src"
84
+ if not src_path.exists():
85
+ return "unknown"
86
+
87
+ # Web Application detection
88
+ if (src_path / "routes" or src_path / "controllers" or src_path / "api" or src_path / "web").exists():
89
+ if (self.project_root / "package.json").exists():
90
+ return "web_application"
91
+
92
+ # Mobile Application detection
93
+ if (
94
+ src_path / "android" or src_path / "ios" or src_path / "flutter" or self.project_root / "pubspec.yaml"
95
+ ).exists():
96
+ return "mobile_application"
97
+
98
+ # CLI Tool detection
99
+ main_files = list(src_path.glob("main.*")) + list(src_path.glob("cli.*")) + list(src_path.glob("index.*"))
100
+ if main_files and not (src_path / "web" or src_path / "api").exists():
101
+ return "cli_tool"
102
+
103
+ # Library/SDK detection
104
+ if (self.project_root / "setup.py").exists() or (self.project_root / "pyproject.toml").exists():
105
+ setup_content = ""
106
+ if (self.project_root / "setup.py").exists():
107
+ setup_content = (self.project_root / "setup.py").read_text()
108
+ if "library" in setup_content.lower() or "sdk" in setup_content.lower():
109
+ return "library_sdk"
110
+
111
+ # Data Science/ML detection
112
+ if (src_path / "models" or src_path / "data" or src_path / "ml" or src_path / "pipeline").exists():
113
+ return "data_science_ml"
114
+
115
+ return "web_application" # Default fallback
116
+
117
+ def _generate_product_doc(self, project_type: str, language: str) -> str:
118
+ """Generate product.md based on project type and language."""
119
+
120
+ templates = {
121
+ "en": {
122
+ "web_application": """# Mission & Strategy
123
+
124
+ ## What problem do we solve?
125
+ [Describe the core problem your web application solves]
126
+
127
+ ## Who are our users?
128
+ - Primary users: [Describe target user group]
129
+ - Secondary users: [Describe secondary user groups]
130
+ - User personas: [Link to user persona documents]
131
+
132
+ ## Value proposition
133
+ [What unique value does your application provide?]
134
+
135
+ # Success Metrics
136
+
137
+ ## Key Performance Indicators
138
+ - User adoption: [Target within timeframe]
139
+ - User retention: [Percentage and timeframe]
140
+ - Feature utilization: [Most important features to track]
141
+ - Performance metrics: [Response times, uptime targets]
142
+
143
+ ## Measurement frequency
144
+ - Daily: [Metrics tracked daily]
145
+ - Weekly: [Metrics tracked weekly]
146
+ - Monthly: [Metrics tracked monthly]
147
+
148
+ ## Success examples
149
+ - "80% user adoption within 2 weeks of launch"
150
+ - "95% uptime maintained for 3 consecutive months"
151
+ - "User satisfaction score > 4.5/5"
152
+
153
+ # Next Features (SPEC Backlog)
154
+
155
+ ## High Priority (Next 1-2 sprints)
156
+ - [SPEC-XXX] [Feature description]
157
+ - [SPEC-XXX] [Feature description]
158
+
159
+ ## Medium Priority (Next 3-4 sprints)
160
+ - [SPEC-XXX] [Feature description]
161
+ - [SPEC-XXX] [Feature description]
162
+
163
+ ## Future Considerations
164
+ - [SPEC-XXX] [Feature description]
165
+ - [SPEC-XXX] [Feature description]
166
+
167
+ ---
168
+
169
+ *Last updated: {timestamp}*
170
+ *Version: 1.0.0*
171
+ """,
172
+ "mobile_application": """# Mission & Strategy
173
+
174
+ ## What problem do we solve?
175
+ [Describe the core problem your mobile app solves]
176
+
177
+ ## Who are our users?
178
+ - Primary demographics: [Age, location, tech proficiency]
179
+ - Device preferences: [iOS, Android, or both]
180
+ - Usage patterns: [Daily, weekly, situational use]
181
+
182
+ ## Value proposition
183
+ [What makes your mobile app unique and valuable?]
184
+
185
+ # Success Metrics
186
+
187
+ ## App Store Performance
188
+ - Downloads: [Target number within timeframe]
189
+ - Ratings: [Target average rating]
190
+ - Reviews: [Target review count and sentiment]
191
+ - Store ranking: [Category ranking goals]
192
+
193
+ ## User Engagement
194
+ - Daily Active Users (DAU): [Target within timeframe]
195
+ - Monthly Active Users (MAU): [Target within timeframe]
196
+ - Session duration: [Average session length target]
197
+ - Retention rate: [Day 1, 7, 30 retention targets]
198
+
199
+ ## Performance Metrics
200
+ - App launch time: [Target launch speed]
201
+ - Crash rate: [Target crash percentage]
202
+ - Battery usage: [Battery consumption targets]
203
+
204
+ # Next Features (SPEC Backlog)
205
+
206
+ ## Critical Features (Next release)
207
+ - [SPEC-XXX] [Feature description]
208
+ - [SPEC-XXX] [Feature description]
209
+
210
+ ## User Experience Enhancements
211
+ - [SPEC-XXX] [Feature description]
212
+ - [SPEC-XXX] [Feature description]
213
+
214
+ ## Platform-Specific Features
215
+ - iOS: [SPEC-XXX] [iOS-specific feature]
216
+ - Android: [SPEC-XXX] [Android-specific feature]
217
+
218
+ ---
219
+
220
+ *Last updated: {timestamp}*
221
+ *Version: 1.0.0*
222
+ """,
223
+ },
224
+ "ko": {
225
+ "web_application": """# 미션 및 전략
226
+
227
+ ## 어떤 문제를 해결하나요?
228
+ [웹 애플리케이션이 해결하는 핵심 문제 설명]
229
+
230
+ ## 사용자는 누구인가요?
231
+ - 주요 사용자: [목표 사용자 그룹 설명]
232
+ - 보조 사용자: [보조 사용자 그룹 설명]
233
+ - 사용자 페르소나: [사용자 페르소나 문서 링크]
234
+
235
+ ## 가치 제안
236
+ [애플리케이션이 제공하는 고유한 가치는 무엇인가요?]
237
+
238
+ # 성공 지표
239
+
240
+ ## 핵심 성과 지표 (KPI)
241
+ - 사용자 도입률: [목표 및 기간]
242
+ - 사용자 유지율: [백분율 및 기간]
243
+ - 기능 활용도: [추적할 가장 중요한 기능들]
244
+ - 성능 지표: [응답 시간, 가동 시간 목표]
245
+
246
+ ## 측정 빈도
247
+ - 일간: [매일 추적되는 지표]
248
+ - 주간: [매주 추적되는 지표]
249
+ - 월간: [매월 추적되는 지표]
250
+
251
+ ## 성공 예시
252
+ - "출시 2주 내 80% 사용자 도입률"
253
+ - "3개월 연속 95% 가동 시간 유지"
254
+ - "사용자 만족도 점수 4.5/5 이상"
255
+
256
+ # 다음 기능들 (SPEC 백로그)
257
+
258
+ ## 높은 우선순위 (다음 1-2 스프린트)
259
+ - [SPEC-XXX] [기능 설명]
260
+ - [SPEC-XXX] [기능 설명]
261
+
262
+ ## 중간 우선순위 (다음 3-4 스프린트)
263
+ - [SPEC-XXX] [기능 설명]
264
+ - [SPEC-XXX] [기능 설명]
265
+
266
+ ## 미래 고려사항
267
+ - [SPEC-XXX] [기능 설명]
268
+ - [SPEC-XXX] [기능 설명]
269
+
270
+ ---
271
+
272
+ *최종 업데이트: {timestamp}*
273
+ *버전: 1.0.0*
274
+ """
275
+ },
276
+ }
277
+
278
+ lang_templates = templates.get(language, templates["en"])
279
+ template = lang_templates.get(project_type, lang_templates["web_application"])
280
+
281
+ return template.format(
282
+ timestamp=datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
283
+ project_name=self.config.get("project", {}).get("name", "My Project"),
284
+ )
285
+
286
+ def _generate_structure_doc(self, project_type: str, language: str) -> str:
287
+ """Generate structure.md based on project type."""
288
+
289
+ templates = {
290
+ "en": {
291
+ "web_application": """# System Architecture
292
+
293
+ ## Overall Design Pattern
294
+ [Describe the architectural pattern - e.g., MVC, Microservices, Serverless]
295
+
296
+ ## Layers and Interactions
297
+ ```mermaid
298
+ graph TB
299
+ A[Frontend] --> B[API Gateway]
300
+ B --> C[Backend Services]
301
+ C --> D[Database Layer]
302
+ C --> E[External APIs]
303
+ F[CDN] --> A
304
+ ```
305
+
306
+ ## Core Modules
307
+
308
+ ### Frontend Layer
309
+ - **Location**: `src/frontend/`
310
+ - **Responsibilities**: User interface, client-side logic
311
+ - **Technologies**: [React/Vue/Angular, etc.]
312
+
313
+ ### Backend API Layer
314
+ - **Location**: `src/api/`
315
+ - **Responsibilities**: REST/GraphQL endpoints, business logic
316
+ - **Technologies**: [FastAPI/Express/NestJS, etc.]
317
+
318
+ ### Database Layer
319
+ - **Location**: Database instances and migrations
320
+ - **Responsibilities**: Data persistence, relationships
321
+ - **Technologies**: [PostgreSQL/MongoDB/Redis, etc.]
322
+
323
+ # External Integrations
324
+
325
+ ## Third-party Services
326
+ - **Payment Provider**: [Stripe/PayPal/etc.]
327
+ - Authentication: OAuth 2.0 with API keys
328
+ - Failure modes: Timeout handling, retry logic
329
+ - Fallback: Manual payment processing
330
+
331
+ - **Email Service**: [SendGrid/SES/etc.]
332
+ - Authentication: API key based
333
+ - Failure modes: Queue for retry
334
+ - Rate limits: [Specific limits]
335
+
336
+ - **Analytics**: [Google Analytics/Mixpanel/etc.]
337
+ - Data flow: Client-side tracking
338
+ - Privacy: GDPR compliance
339
+ - Batch processing: Daily aggregation
340
+
341
+ # Traceability
342
+
343
+ ## SPEC to Code Mapping
344
+ - SPEC-001 → `src/api/auth/` (Authentication system)
345
+ - SPEC-002 → `src/frontend/components/` (User dashboard)
346
+ - SPEC-003 → `src/services/payment/` (Payment processing)
347
+
348
+ ## Change Tracking
349
+ - All changes reference SPEC IDs in commit messages
350
+ - Feature flags controlled via environment variables
351
+ - Database migrations numbered and tracked
352
+
353
+ ## TAG System
354
+ - `feat:` - New features
355
+ - `fix:` - Bug fixes
356
+ - `docs:` - Documentation updates
357
+ - `refactor:` - Code refactoring
358
+ - `perf:` - Performance improvements
359
+
360
+ ---
361
+
362
+ *Last updated: {timestamp}*
363
+ *Version: 1.0.0*
364
+ """
365
+ },
366
+ "ko": {
367
+ "web_application": """# 시스템 아키텍처
368
+
369
+ ## 전체 설계 패턴
370
+ [아키텍처 패턴 설명 - 예: MVC, 마이크로서비스, 서버리스]
371
+
372
+ ## 레이어 및 상호작용
373
+ ```mermaid
374
+ graph TB
375
+ A[프론트엔드] --> B[API 게이트웨이]
376
+ B --> C[백엔드 서비스]
377
+ C --> D[데이터베이스 레이어]
378
+ C --> E[외부 API]
379
+ F[CDN] --> A
380
+ ```
381
+
382
+ ## 핵심 모듈
383
+
384
+ ### 프론트엔드 레이어
385
+ - **위치**: `src/frontend/`
386
+ - **책임**: 사용자 인터페이스, 클라이언트 측 로직
387
+ - **기술**: [React/Vue/Angular 등]
388
+
389
+ ### 백엔드 API 레이어
390
+ - **위치**: `src/api/`
391
+ - **책임**: REST/GraphQL 엔드포인트, 비즈니스 로직
392
+ - **기술**: [FastAPI/Express/NestJS 등]
393
+
394
+ ### 데이터베이스 레이어
395
+ - **위치**: 데이터베이스 인스턴스 및 마이그레이션
396
+ - **책임**: 데이터 지속성, 관계
397
+ - **기술**: [PostgreSQL/MongoDB/Redis 등]
398
+
399
+ # 외부 통합
400
+
401
+ ## 서드파티 서비스
402
+ - **결제 제공업체**: [Stripe/PayPal 등]
403
+ - 인증: API 키와 OAuth 2.0
404
+ - 실패 모드: 타임아웃 처리, 재시도 로직
405
+ - 대체수단: 수동 결제 처리
406
+
407
+ - **이메일 서비스**: [SendGrid/SES 등]
408
+ - 인증: API 키 기반
409
+ - 실패 모드: 재시를 위한 큐
410
+ - 속도 제한: [구체적인 제한]
411
+
412
+ - **분석**: [Google Analytics/Mixpanel 등]
413
+ - 데이터 흐름: 클라이언트 측 추적
414
+ - 개인정보보호: GDPR 준수
415
+ - 일괄 처리: 일일 집계
416
+
417
+ # 추적성
418
+
419
+ ## SPEC-코드 매핑
420
+ - SPEC-001 → `src/api/auth/` (인증 시스템)
421
+ - SPEC-002 → `src/frontend/components/` (사용자 대시보드)
422
+ - SPEC-003 → `src/services/payment/` (결제 처리)
423
+
424
+ ## 변경 추적
425
+ - 모든 변경은 커밋 메시지에 SPEC ID 참조
426
+ - 기능 플래그는 환경 변수로 제어
427
+ - 데이터베이스 마이그레이션 번호화 및 추적
428
+
429
+ ## TAG 시스템
430
+ - `feat:` - 새로운 기능
431
+ - `fix:` - 버그 수정
432
+ - `docs:` - 문서 업데이트
433
+ - `refactor:` - 코드 리팩토링
434
+ - `perf:` - 성능 개선
435
+
436
+ ---
437
+
438
+ *최종 업데이트: {timestamp}*
439
+ *버전: 1.0.0*
440
+ """
441
+ },
442
+ }
443
+
444
+ lang_templates = templates.get(language, templates["en"])
445
+ template = lang_templates.get(project_type, lang_templates["web_application"])
446
+
447
+ return template.format(
448
+ timestamp=datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
449
+ project_name=self.config.get("project", {}).get("name", "My Project"),
450
+ )
451
+
452
+ def _generate_tech_doc(self, project_type: str, language: str) -> str:
453
+ """Generate tech.md based on project type."""
454
+
455
+ templates = {
456
+ "en": {
457
+ "web_application": """# Technology Stack
458
+
459
+ ## Programming Languages
460
+ - **Frontend**: TypeScript 5.0+ (React 18+)
461
+ - **Backend**: Python 3.11+ (FastAPI)
462
+ - **Database**: PostgreSQL 15+
463
+ - **Infrastructure**: Docker, Kubernetes
464
+
465
+ ## Framework Choices
466
+
467
+ ### Frontend Framework: React
468
+ - **Reason**: Component-based architecture, large ecosystem
469
+ - **Version**: 18.2.0+
470
+ - **Key Libraries**: React Router, Zustand, React Query
471
+
472
+ ### Backend Framework: FastAPI
473
+ - **Reason**: Modern Python, automatic API docs, async support
474
+ - **Version**: 0.104.0+
475
+ - **Key Features**: Pydantic validation, OpenAPI generation
476
+
477
+ ### Database ORM: SQLAlchemy
478
+ - **Reason**: Mature, powerful, database-agnostic
479
+ - **Version**: 2.0+
480
+ - **Features**: Migration support, relationship management
481
+
482
+ # Quality Gates
483
+
484
+ ## Required for Merge
485
+ - **Test Coverage**: Minimum 85% (pytest --cov)
486
+ - **Code Quality**: ruff linting (no warnings)
487
+ - **Security**: No high severity vulnerabilities (safety check)
488
+ - **Documentation**: All public APIs documented
489
+
490
+ ## Enforcement Tools
491
+ ```bash
492
+ # Pre-commit hooks
493
+ ruff check src/
494
+ pytest tests/ --cov=src/
495
+ safety check
496
+ mypy src/
497
+ ```
498
+
499
+ ## Failure Criteria
500
+ - Coverage < 85%: PR blocked
501
+ - Security vulnerabilities: PR blocked
502
+ - Linting errors: Auto-fix or PR blocked
503
+ - Missing documentation: Warning only
504
+
505
+ # Security Policy
506
+
507
+ ## Secret Management
508
+ - **Environment Variables**: All secrets in environment
509
+ - **Development**: .env file (gitignored)
510
+ - **Production**: Kubernetes secrets or AWS Secrets Manager
511
+ - **Rotation**: Quarterly secret rotation required
512
+
513
+ ## Vulnerability Handling
514
+ - **Monitoring**: Dependabot + security scanning
515
+ - **Response**: Critical patches within 24 hours
516
+ - **Testing**: Security tests in CI/CD pipeline
517
+
518
+ ## Incident Response
519
+ 1. **Detection**: Automated monitoring and alerts
520
+ 2. **Assessment**: Security team evaluation within 1 hour
521
+ 3. **Containment**: Isolate affected systems
522
+ 4. **Resolution**: Patch and deploy within 24 hours
523
+ 5. **Post-mortem**: Document and improve processes
524
+
525
+ # Deployment Strategy
526
+
527
+ ## Target Environments
528
+ - **Development**: Local Docker containers
529
+ - **Staging**: Kubernetes cluster (AWS EKS)
530
+ - **Production**: Kubernetes cluster (AWS EKS)
531
+
532
+ ## Release Process
533
+ ```yaml
534
+ # CI/CD Pipeline stages
535
+ stages:
536
+ - test # Run all quality gates
537
+ - build # Build Docker images
538
+ - security # Security scanning
539
+ - deploy_staging # Deploy to staging
540
+ - smoke_tests # Staging validation
541
+ - deploy_prod # Blue-green deployment
542
+ ```
543
+
544
+ ## Rollback Procedure
545
+ 1. **Immediate Rollback**: Kubernetes rollback to previous version
546
+ 2. **Database Rollback**: Migration rollback scripts
547
+ 3. **Monitoring**: Verify system health after rollback
548
+ 4. **Communication**: Notify team and stakeholders
549
+
550
+ ## Environment Profiles
551
+ - **Development**: Debug mode, local database
552
+ - **Staging**: Production-like, test data
553
+ - **Production**: Optimized, monitoring enabled
554
+
555
+ ---
556
+
557
+ *Last updated: {timestamp}*
558
+ *Version: 1.0.0*
559
+ """
560
+ },
561
+ "ko": {
562
+ "web_application": """# 기술 스택
563
+
564
+ ## 프로그래밍 언어
565
+ - **프론트엔드**: TypeScript 5.0+ (React 18+)
566
+ - **백엔드**: Python 3.11+ (FastAPI)
567
+ - **데이터베이스**: PostgreSQL 15+
568
+ - **인프라**: Docker, Kubernetes
569
+
570
+ ## 프레임워크 선택
571
+
572
+ ### 프론트엔드 프레임워크: React
573
+ - **이유**: 컴포넌트 기반 아키텍처, 큰 생태계
574
+ - **버전**: 18.2.0+
575
+ - **주요 라이브러리**: React Router, Zustand, React Query
576
+
577
+ ### 백엔드 프레임워크: FastAPI
578
+ - **이유**: 현대 Python, 자동 API 문서, 비동기 지원
579
+ - **버전**: 0.104.0+
580
+ - **주요 기능**: Pydantic 검증, OpenAPI 생성
581
+
582
+ ### 데이터베이스 ORM: SQLAlchemy
583
+ - **이유**: 성숙하고 강력하며 데이터베이스 독립적
584
+ - **버전**: 2.0+
585
+ - **기능**: 마이그레이션 지원, 관계 관리
586
+
587
+ # 품질 게이트
588
+
589
+ ## 병합 요구사항
590
+ - **테스트 커버리지**: 최소 85% (pytest --cov)
591
+ - **코드 품질**: ruff 린팅 (경고 없음)
592
+ - **보안**: 높은 심각도 취약점 없음 (safety check)
593
+ - **문서**: 모든 공개 API 문서화
594
+
595
+ ## 적용 도구
596
+ ```bash
597
+ # Pre-commit hooks
598
+ ruff check src/
599
+ pytest tests/ --cov=src/
600
+ safety check
601
+ mypy src/
602
+ ```
603
+
604
+ ## 실패 기준
605
+ - 커버리지 < 85%: PR 차단
606
+ - 보안 취약점: PR 차단
607
+ - 린팅 오류: 자동 수정 또는 PR 차단
608
+ - 문서 누락: 경고만
609
+
610
+ # 보안 정책
611
+
612
+ ## 시크릿 관리
613
+ - **환경 변수**: 모든 시크릿은 환경 변수
614
+ - **개발**: .env 파일 (gitignore)
615
+ - **프로덕션**: Kubernetes 시크릿 또는 AWS Secrets Manager
616
+ - **교체**: 분기별 시크릿 교체 필요
617
+
618
+ ## 취약점 처리
619
+ - **모니터링**: Dependabot + 보안 스캐닝
620
+ - **응답**: 중요 패치 24시간 내
621
+ - **테스트**: CI/CD 파이프라인에서 보안 테스트
622
+
623
+ ## 인시던트 응답
624
+ 1. **탐지**: 자동 모니터링 및 알림
625
+ 2. **평가**: 보안 팀 1시간 내 평가
626
+ 3. **격리**: 영향 받는 시스템 격리
627
+ 4. **해결**: 24시간 내 패치 및 배포
628
+ 5. **사후 분석**: 문서화 및 프로세스 개선
629
+
630
+ # 배포 전략
631
+
632
+ ## 대상 환경
633
+ - **개발**: 로컬 Docker 컨테이너
634
+ - **스테이징**: Kubernetes 클러스터 (AWS EKS)
635
+ - **프로덕션**: Kubernetes 클러스터 (AWS EKS)
636
+
637
+ ## 릴리스 프로세스
638
+ ```yaml
639
+ # CI/CD 파이프라인 단계
640
+ stages:
641
+ - test # 모든 품질 게이트 실행
642
+ - build # Docker 이미지 빌드
643
+ - security # 보안 스캐닝
644
+ - deploy_staging # 스테이징 배포
645
+ - smoke_tests # 스테이징 검증
646
+ - deploy_prod # 블루-그린 배포
647
+ ```
648
+
649
+ ## 롤백 절차
650
+ 1. **즉시 롤백**: Kubernetes 이전 버전 롤백
651
+ 2. **데이터베이스 롤백**: 마이그레이션 롤백 스크립트
652
+ 3. **모니터링**: 롤백 후 시스템 상태 확인
653
+ 4. **소통**: 팀 및 이해관계자 통보
654
+
655
+ ## 환경 프로필
656
+ - **개발**: 디버그 모드, 로컬 데이터베이스
657
+ - **스테이징**: 프로덕션 유사, 테스트 데이터
658
+ - **프로덕션**: 최적화, 모니터링 활성화
659
+
660
+ ---
661
+
662
+ *최종 업데이트: {timestamp}*
663
+ *버전: 1.0.0*
664
+ """
665
+ },
666
+ }
667
+
668
+ lang_templates = templates.get(language, templates["en"])
669
+ template = lang_templates.get(project_type, lang_templates["web_application"])
670
+
671
+ return template.format(
672
+ timestamp=datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
673
+ project_name=self.config.get("project", {}).get("name", "My Project"),
674
+ )
675
+
676
+ def _create_api_structure(self, project_type: str) -> Dict[str, Any]:
677
+ """Create API documentation structure."""
678
+
679
+ api_structure = {
680
+ "openapi_spec": self._generate_openapi_spec(project_type),
681
+ "endpoint_docs": {},
682
+ "schema_docs": {},
683
+ "authentication_guide": self._generate_auth_guide(project_type),
684
+ }
685
+
686
+ return api_structure
687
+
688
+ def _create_guides_structure(self, project_type: str, language: str) -> Dict[str, Any]:
689
+ """Create user guides structure."""
690
+
691
+ guides = {
692
+ "getting_started": self._generate_getting_started_guide(project_type, language),
693
+ "user_guide": self._generate_user_guide(project_type, language),
694
+ "developer_guide": self._generate_developer_guide(project_type, language),
695
+ "deployment_guide": self._generate_deployment_guide(project_type, language),
696
+ }
697
+
698
+ return guides
699
+
700
+ def _generate_openapi_spec(self, project_type: str) -> Dict[str, Any]:
701
+ """Generate OpenAPI specification template."""
702
+
703
+ base_spec = {
704
+ "openapi": "3.0.0",
705
+ "info": {
706
+ "title": self.config.get("project", {}).get("name", "API Documentation"),
707
+ "version": "1.0.0",
708
+ "description": f"API documentation for {project_type}",
709
+ },
710
+ "servers": [
711
+ {"url": "http://localhost:8000", "description": "Development server"},
712
+ {"url": "https://api.example.com", "description": "Production server"},
713
+ ],
714
+ "paths": {
715
+ "/health": {
716
+ "get": {
717
+ "summary": "Health check endpoint",
718
+ "responses": {
719
+ "200": {
720
+ "description": "Service is healthy",
721
+ "content": {
722
+ "application/json": {
723
+ "schema": {
724
+ "type": "object",
725
+ "properties": {
726
+ "status": {"type": "string"},
727
+ "timestamp": {"type": "string"},
728
+ },
729
+ }
730
+ }
731
+ },
732
+ }
733
+ },
734
+ }
735
+ }
736
+ },
737
+ "components": {
738
+ "securitySchemes": {
739
+ "BearerAuth": {
740
+ "type": "http",
741
+ "scheme": "bearer",
742
+ "bearerFormat": "JWT",
743
+ }
744
+ }
745
+ },
746
+ }
747
+
748
+ return base_spec
749
+
750
+ def _generate_auth_guide(self, project_type: str) -> str:
751
+ """Generate authentication guide."""
752
+
753
+ return """# Authentication Guide
754
+
755
+ ## Overview
756
+ This API uses JWT (JSON Web Tokens) for authentication.
757
+
758
+ ## Getting Started
759
+ 1. Register for an API key
760
+ 2. Obtain a JWT token
761
+ 3. Include token in requests
762
+
763
+ ## Token Usage
764
+ ```
765
+ Authorization: Bearer <your-jwt-token>
766
+ ```
767
+
768
+ ## Token Expiration
769
+ - Tokens expire after 24 hours
770
+ - Refresh tokens available for extended sessions
771
+ """
772
+
773
+ def _generate_getting_started_guide(self, project_type: str, language: str) -> str:
774
+ """Generate getting started guide."""
775
+
776
+ if language == "ko":
777
+ return f"""# 시작 가이드
778
+
779
+ ## {project_type} 프로젝트 설정
780
+
781
+ ### 1. 필수 요구사항
782
+ - Python 3.11+
783
+ - Node.js 18+
784
+ - Git
785
+
786
+ ### 2. 프로젝트 클론
787
+ ```bash
788
+ git clone <repository-url>
789
+ cd {self.config.get("project", {}).get("name", "my-project")}
790
+ ```
791
+
792
+ ### 3. 환경 설정
793
+ ```bash
794
+ # 가상환경 생성
795
+ python -m venv venv
796
+ source venv/bin/activate # Windows: venv\\Scripts\\activate
797
+
798
+ # 의존성 설치
799
+ pip install -r requirements.txt
800
+ npm install
801
+ ```
802
+
803
+ ### 4. 설정 파일
804
+ ```bash
805
+ cp .env.example .env
806
+ # .env 파일에 필요한 설정값 입력
807
+ ```
808
+
809
+ ### 5. 데이터베이스 설정
810
+ ```bash
811
+ # 데이터베이스 마이그레이션
812
+ alembic upgrade head
813
+ ```
814
+
815
+ ### 6. 개발 서버 시작
816
+ ```bash
817
+ # 백엔드 서버
818
+ uvicorn main:app --reload --port 8000
819
+
820
+ # 프론트엔드 개발 서버
821
+ npm run dev
822
+ ```
823
+
824
+ ## 다음 단계
825
+ - [API 문서](./api/) 살펴보기
826
+ - [사용자 가이드](./user-guide.md) 확인
827
+ - [개발자 가이드](./developer-guide.md) 참조
828
+ """
829
+ else:
830
+ return f"""# Getting Started
831
+
832
+ ## {project_type} Project Setup
833
+
834
+ ### 1. Prerequisites
835
+ - Python 3.11+
836
+ - Node.js 18+
837
+ - Git
838
+
839
+ ### 2. Clone Project
840
+ ```bash
841
+ git clone <repository-url>
842
+ cd {self.config.get("project", {}).get("name", "my-project")}
843
+ ```
844
+
845
+ ### 3. Environment Setup
846
+ ```bash
847
+ # Create virtual environment
848
+ python -m venv venv
849
+ source venv/bin/activate # Windows: venv\\Scripts\\activate
850
+
851
+ # Install dependencies
852
+ pip install -r requirements.txt
853
+ npm install
854
+ ```
855
+
856
+ ### 4. Configuration
857
+ ```bash
858
+ cp .env.example .env
859
+ # Add required configuration values to .env
860
+ ```
861
+
862
+ ### 5. Database Setup
863
+ ```bash
864
+ # Run database migrations
865
+ alembic upgrade head
866
+ ```
867
+
868
+ ### 6. Start Development Server
869
+ ```bash
870
+ # Backend server
871
+ uvicorn main:app --reload --port 8000
872
+
873
+ # Frontend dev server
874
+ npm run dev
875
+ ```
876
+
877
+ ## Next Steps
878
+ - Explore [API Documentation](./api/)
879
+ - Check [User Guide](./user-guide.md)
880
+ - Reference [Developer Guide](./developer-guide.md)
881
+ """
882
+
883
+ def _generate_user_guide(self, project_type: str, language: str) -> str:
884
+ """Generate user guide."""
885
+
886
+ if language == "ko":
887
+ return """# 사용자 가이드
888
+
889
+ ## 기본 기능
890
+ - 주요 기능 설명
891
+ - 사용 방법
892
+ - 팁과 요령
893
+
894
+ ## 고급 기능
895
+ - 전문가 기능
896
+ - 설정 옵션
897
+ - 자동화
898
+
899
+ ## 문제 해결
900
+ - 일반적인 문제
901
+ - FAQ
902
+ - 지원 연락처
903
+ """
904
+ else:
905
+ return """# User Guide
906
+
907
+ ## Basic Features
908
+ - Feature descriptions
909
+ - How to use
910
+ - Tips and tricks
911
+
912
+ ## Advanced Features
913
+ - Expert functionality
914
+ - Configuration options
915
+ - Automation
916
+
917
+ ## Troubleshooting
918
+ - Common issues
919
+ - FAQ
920
+ - Support contacts
921
+ """
922
+
923
+ def _generate_developer_guide(self, project_type: str, language: str) -> str:
924
+ """Generate developer guide."""
925
+
926
+ if language == "ko":
927
+ return """# 개발자 가이드
928
+
929
+ ## 개발 환경
930
+ - IDE 설정
931
+ - 디버깅
932
+ - 테스트
933
+
934
+ ## 코드 기여
935
+ - 코드 스타일
936
+ - PR 프로세스
937
+ - 코드 리뷰
938
+
939
+ ## 아키텍처
940
+ - 시스템 설계
941
+ - 모듈 구조
942
+ - 데이터 흐름
943
+ """
944
+ else:
945
+ return """# Developer Guide
946
+
947
+ ## Development Environment
948
+ - IDE setup
949
+ - Debugging
950
+ - Testing
951
+
952
+ ## Contributing Code
953
+ - Code style
954
+ - PR process
955
+ - Code review
956
+
957
+ ## Architecture
958
+ - System design
959
+ - Module structure
960
+ - Data flow
961
+ """
962
+
963
+ def _generate_deployment_guide(self, project_type: str, language: str) -> str:
964
+ """Generate deployment guide."""
965
+
966
+ if language == "ko":
967
+ return """# 배포 가이드
968
+
969
+ ## 환경 설정
970
+ - 개발 환경
971
+ - 스테이징 환경
972
+ - 프로덕션 환경
973
+
974
+ ## 배포 프로세스
975
+ - CI/CD 파이프라인
976
+ - 릴리스 절차
977
+ - 롤백
978
+
979
+ ## 모니터링
980
+ - 로깅
981
+ - 메트릭
982
+ - 알림
983
+ """
984
+ else:
985
+ return """# Deployment Guide
986
+
987
+ ## Environment Setup
988
+ - Development environment
989
+ - Staging environment
990
+ - Production environment
991
+
992
+ ## Deployment Process
993
+ - CI/CD pipeline
994
+ - Release procedure
995
+ - Rollback
996
+
997
+ ## Monitoring
998
+ - Logging
999
+ - Metrics
1000
+ - Alerts
1001
+ """
1002
+
1003
+ def generate_documentation_from_spec(self, spec_data: Dict[str, Any]) -> Dict[str, Any]:
1004
+ """
1005
+ Generate documentation based on SPEC data.
1006
+
1007
+ Args:
1008
+ spec_data: SPEC specification data
1009
+
1010
+ Returns:
1011
+ Dict with generated documentation results
1012
+ """
1013
+
1014
+ spec_id = spec_data.get("id", "SPEC-001")
1015
+ spec_data.get("title", "Untitled Feature")
1016
+ spec_data.get("description", "")
1017
+
1018
+ # Generate feature documentation
1019
+ feature_doc = self._generate_feature_documentation(spec_data)
1020
+
1021
+ # Generate API documentation if applicable
1022
+ api_doc = self._generate_api_documentation(spec_data)
1023
+
1024
+ # Update product.md with new feature
1025
+ self._update_product_documentation(spec_data)
1026
+
1027
+ # Update structure.md if architecture changes
1028
+ self._update_structure_documentation(spec_data)
1029
+
1030
+ # Update tech.md if new technologies introduced
1031
+ self._update_tech_documentation(spec_data)
1032
+
1033
+ return {
1034
+ "spec_id": spec_id,
1035
+ "feature_documentation": feature_doc,
1036
+ "api_documentation": api_doc,
1037
+ "updated_files": [
1038
+ "docs/product.md",
1039
+ "docs/structure.md",
1040
+ "docs/tech.md",
1041
+ f"docs/features/{spec_id.lower()}.md",
1042
+ ],
1043
+ }
1044
+
1045
+ def _generate_feature_documentation(self, spec_data: Dict[str, Any]) -> str:
1046
+ """Generate feature documentation from SPEC."""
1047
+
1048
+ spec_id = spec_data.get("id", "SPEC-001")
1049
+ title = spec_data.get("title", "Untitled Feature")
1050
+ description = spec_data.get("description", "")
1051
+ requirements = spec_data.get("requirements", [])
1052
+
1053
+ doc_content = f"""# {title}
1054
+
1055
+ ## Overview
1056
+ {description}
1057
+
1058
+ ## Requirements
1059
+ """
1060
+
1061
+ for i, req in enumerate(requirements, 1):
1062
+ doc_content += f"{i}. {req}\n"
1063
+
1064
+ doc_content += f"""
1065
+ ## Implementation Details
1066
+ - **SPEC ID**: {spec_id}
1067
+ - **Status**: {spec_data.get("status", "Planned")}
1068
+ - **Priority**: {spec_data.get("priority", "Medium")}
1069
+
1070
+ ## Usage Examples
1071
+ [Add usage examples here]
1072
+
1073
+ ## Testing
1074
+ - Test cases: [Link to test files]
1075
+ - Coverage requirements: [Percentage requirements]
1076
+ - Performance tests: [Performance criteria]
1077
+
1078
+ ## Related Documentation
1079
+ - [API Documentation](../api/)
1080
+ - [Architecture Guide](../structure.md)
1081
+ - [Technical Stack](../tech.md)
1082
+
1083
+ ---
1084
+
1085
+ *Generated from: {spec_id}*
1086
+ *Last updated: {datetime.now().strftime("%Y-%m-%d %H:%M:%S")}*
1087
+ """
1088
+
1089
+ return doc_content
1090
+
1091
+ def _generate_api_documentation(self, spec_data: Dict[str, Any]) -> Optional[Dict[str, Any]]:
1092
+ """Generate API documentation if SPEC includes API changes."""
1093
+
1094
+ if "api_endpoints" not in spec_data:
1095
+ return None
1096
+
1097
+ api_doc = {"endpoints": [], "schemas": [], "examples": []}
1098
+
1099
+ for endpoint in spec_data.get("api_endpoints", []):
1100
+ api_doc["endpoints"].append(
1101
+ {
1102
+ "path": endpoint.get("path", ""),
1103
+ "method": endpoint.get("method", "GET"),
1104
+ "description": endpoint.get("description", ""),
1105
+ "parameters": endpoint.get("parameters", []),
1106
+ "responses": endpoint.get("responses", {}),
1107
+ }
1108
+ )
1109
+
1110
+ return api_doc
1111
+
1112
+ def _update_product_documentation(self, spec_data: Dict[str, Any]):
1113
+ """Update product.md with new feature information."""
1114
+
1115
+ product_path = self.docs_dir / "product.md"
1116
+ if not product_path.exists():
1117
+ return
1118
+
1119
+ content = product_path.read_text(encoding="utf-8")
1120
+
1121
+ # Find SPEC Backlog section
1122
+ spec_id = spec_data.get("id", "SPEC-001")
1123
+ title = spec_data.get("title", "Untitled Feature")
1124
+
1125
+ # Add to next features section
1126
+ spec_entry = f"- [{spec_id}] {title}\n"
1127
+
1128
+ if "# Next Features (SPEC Backlog)" in content:
1129
+ # Find insertion point after High Priority
1130
+ insertion_point = content.find("## High Priority")
1131
+ if insertion_point != -1:
1132
+ # Find end of High Priority section
1133
+ end_point = content.find("##", insertion_point + 1)
1134
+ if end_point == -1:
1135
+ end_point = len(content)
1136
+
1137
+ new_content = content[:end_point] + spec_entry + content[end_point:]
1138
+ product_path.write_text(new_content, encoding="utf-8")
1139
+
1140
+ def _update_structure_documentation(self, spec_data: Dict[str, Any]):
1141
+ """Update structure.md with architecture changes."""
1142
+
1143
+ if "architecture_changes" not in spec_data:
1144
+ return
1145
+
1146
+ structure_path = self.docs_dir / "structure.md"
1147
+ if not structure_path.exists():
1148
+ return
1149
+
1150
+ # Implementation for updating architecture documentation
1151
+ # This would be more sophisticated in practice
1152
+
1153
+ def _update_tech_documentation(self, spec_data: Dict[str, Any]):
1154
+ """Update tech.md with new technologies."""
1155
+
1156
+ if "technologies" not in spec_data:
1157
+ return
1158
+
1159
+ tech_path = self.docs_dir / "tech.md"
1160
+ if not tech_path.exists():
1161
+ return
1162
+
1163
+ # Implementation for updating technology stack documentation
1164
+ # This would be more sophisticated in practice
1165
+
1166
+ def export_documentation(self, format_type: str = "markdown") -> Dict[str, Any]:
1167
+ """
1168
+ Export documentation in specified format.
1169
+
1170
+ Args:
1171
+ format_type: Export format (markdown, html, pdf)
1172
+
1173
+ Returns:
1174
+ Dict with export results
1175
+ """
1176
+
1177
+ export_results = {
1178
+ "format": format_type,
1179
+ "files": [],
1180
+ "output_directory": "",
1181
+ "success": False,
1182
+ }
1183
+
1184
+ if format_type == "markdown":
1185
+ export_results = self._export_markdown()
1186
+ elif format_type == "html":
1187
+ export_results = self._export_html()
1188
+ elif format_type == "pdf":
1189
+ export_results = self._export_pdf()
1190
+ else:
1191
+ export_results["error"] = f"Unsupported format: {format_type}"
1192
+
1193
+ return export_results
1194
+
1195
+ def _export_markdown(self) -> Dict[str, Any]:
1196
+ """Export documentation as markdown bundle."""
1197
+
1198
+ output_dir = self.project_root / "docs-export"
1199
+ output_dir.mkdir(exist_ok=True)
1200
+
1201
+ # Copy all markdown files
1202
+ markdown_files = list(self.docs_dir.glob("**/*.md"))
1203
+
1204
+ exported_files = []
1205
+ for md_file in markdown_files:
1206
+ relative_path = md_file.relative_to(self.docs_dir)
1207
+ output_path = output_dir / relative_path
1208
+ output_path.parent.mkdir(parents=True, exist_ok=True)
1209
+ shutil.copy2(md_file, output_path)
1210
+ exported_files.append(str(output_path))
1211
+
1212
+ return {
1213
+ "format": "markdown",
1214
+ "files": exported_files,
1215
+ "output_directory": str(output_dir),
1216
+ "success": True,
1217
+ }
1218
+
1219
+ def _export_html(self) -> Dict[str, Any]:
1220
+ """Export documentation as HTML."""
1221
+
1222
+ # Check for markdown to HTML converter
1223
+ try:
1224
+ import jinja2 # noqa: F401 - availability check
1225
+ import markdown
1226
+ except ImportError:
1227
+ return {
1228
+ "format": "html",
1229
+ "error": "Required packages not found: markdown, jinja2",
1230
+ "success": False,
1231
+ }
1232
+
1233
+ output_dir = self.project_root / "docs-html"
1234
+ output_dir.mkdir(exist_ok=True)
1235
+
1236
+ # Generate HTML from markdown files
1237
+ exported_files = []
1238
+ markdown_files = list(self.docs_dir.glob("**/*.md"))
1239
+
1240
+ for md_file in markdown_files:
1241
+ html_content = markdown.markdown(
1242
+ md_file.read_text(encoding="utf-8"),
1243
+ extensions=["toc", "codehilite", "tables"],
1244
+ )
1245
+
1246
+ relative_path = md_file.relative_to(self.docs_dir)
1247
+ html_path = output_dir / relative_path.with_suffix(".html")
1248
+ html_path.parent.mkdir(parents=True, exist_ok=True)
1249
+
1250
+ html_path.write_text(html_content, encoding="utf-8")
1251
+ exported_files.append(str(html_path))
1252
+
1253
+ return {
1254
+ "format": "html",
1255
+ "files": exported_files,
1256
+ "output_directory": str(output_dir),
1257
+ "success": True,
1258
+ }
1259
+
1260
+ def _export_pdf(self) -> Dict[str, Any]:
1261
+ """Export documentation as PDF."""
1262
+
1263
+ # Check for PDF converter
1264
+ try:
1265
+ import markdown
1266
+ import weasyprint
1267
+ except ImportError:
1268
+ return {
1269
+ "format": "pdf",
1270
+ "error": "Required packages not found: markdown, weasyprint",
1271
+ "success": False,
1272
+ }
1273
+
1274
+ output_dir = self.project_root / "docs-pdf"
1275
+ output_dir.mkdir(exist_ok=True)
1276
+
1277
+ # Generate PDF from main documentation files
1278
+ main_files = ["product.md", "structure.md", "tech.md"]
1279
+ exported_files = []
1280
+
1281
+ for filename in main_files:
1282
+ md_path = self.docs_dir / filename
1283
+ if md_path.exists():
1284
+ html_content = markdown.markdown(
1285
+ md_path.read_text(encoding="utf-8"),
1286
+ extensions=["toc", "codehilite", "tables"],
1287
+ )
1288
+
1289
+ pdf_path = output_dir / filename.replace(".md", ".pdf")
1290
+
1291
+ # Convert HTML to PDF
1292
+ weasyprint.HTML(string=html_content).write_pdf(pdf_path)
1293
+ exported_files.append(str(pdf_path))
1294
+
1295
+ return {
1296
+ "format": "pdf",
1297
+ "files": exported_files,
1298
+ "output_directory": str(output_dir),
1299
+ "success": True,
1300
+ }
1301
+
1302
+ def get_documentation_status(self) -> Dict[str, Any]:
1303
+ """Get current documentation status and metrics."""
1304
+
1305
+ status = {
1306
+ "total_files": 0,
1307
+ "file_types": {},
1308
+ "last_updated": None,
1309
+ "missing_sections": [],
1310
+ "quality_metrics": {},
1311
+ }
1312
+
1313
+ if not self.docs_dir.exists():
1314
+ return status
1315
+
1316
+ # Count files by type
1317
+ for file_path in self.docs_dir.rglob("*"):
1318
+ if file_path.is_file():
1319
+ status["total_files"] += 1
1320
+ suffix = file_path.suffix.lower()
1321
+ status["file_types"][suffix] = status["file_types"].get(suffix, 0) + 1
1322
+
1323
+ # Check for required documentation files
1324
+ required_files = ["product.md", "structure.md", "tech.md"]
1325
+ for req_file in required_files:
1326
+ if not (self.docs_dir / req_file).exists():
1327
+ status["missing_sections"].append(req_file)
1328
+
1329
+ # Get last update time
1330
+ try:
1331
+ latest_file = max(self.docs_dir.rglob("*"), key=lambda f: f.stat().st_mtime)
1332
+ status["last_updated"] = datetime.fromtimestamp(latest_file.stat().st_mtime).isoformat()
1333
+ except ValueError:
1334
+ pass
1335
+
1336
+ return status