moai-adk 0.4.5__py3-none-any.whl → 0.20.1__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 (433) hide show
  1. moai_adk/__init__.py +1 -1
  2. moai_adk/__main__.py +74 -1
  3. moai_adk/cli/commands/__init__.py +1 -1
  4. moai_adk/cli/commands/analyze.py +119 -0
  5. moai_adk/cli/commands/backup.py +25 -1
  6. moai_adk/cli/commands/doctor.py +31 -5
  7. moai_adk/cli/commands/improve_user_experience.py +307 -0
  8. moai_adk/cli/commands/init.py +111 -10
  9. moai_adk/cli/commands/status.py +33 -3
  10. moai_adk/cli/commands/update.py +921 -130
  11. moai_adk/cli/commands/validate_links.py +120 -0
  12. moai_adk/cli/prompts/init_prompts.py +22 -87
  13. moai_adk/core/analysis/__init__.py +9 -0
  14. moai_adk/core/analysis/session_analyzer.py +388 -0
  15. moai_adk/core/analysis/tag_chain_analyzer.py +344 -0
  16. moai_adk/core/analysis/tag_chain_repair.py +879 -0
  17. moai_adk/core/config/__init__.py +19 -0
  18. moai_adk/core/config/migration.py +235 -0
  19. moai_adk/core/git/__init__.py +1 -1
  20. moai_adk/core/git/branch.py +1 -1
  21. moai_adk/core/git/commit.py +1 -1
  22. moai_adk/core/git/manager.py +1 -1
  23. moai_adk/core/issue_creator.py +313 -0
  24. moai_adk/core/mcp/setup.py +56 -0
  25. moai_adk/core/mcp/setup_old.py +296 -0
  26. moai_adk/core/project/backup_utils.py +1 -1
  27. moai_adk/core/project/checker.py +2 -2
  28. moai_adk/core/project/detector.py +211 -12
  29. moai_adk/core/project/initializer.py +85 -15
  30. moai_adk/core/project/phase_executor.py +76 -13
  31. moai_adk/core/project/validator.py +13 -13
  32. moai_adk/core/quality/__init__.py +1 -1
  33. moai_adk/core/quality/trust_checker.py +1 -1
  34. moai_adk/core/quality/validators/__init__.py +1 -1
  35. moai_adk/core/quality/validators/base_validator.py +1 -1
  36. moai_adk/core/tags/__init__.py +86 -0
  37. moai_adk/core/tags/auto_corrector.py +693 -0
  38. moai_adk/core/tags/ci_validator.py +463 -0
  39. moai_adk/core/tags/cli.py +283 -0
  40. moai_adk/core/tags/generator.py +109 -0
  41. moai_adk/core/tags/inserter.py +99 -0
  42. moai_adk/core/tags/mapper.py +126 -0
  43. moai_adk/core/tags/parser.py +76 -0
  44. moai_adk/core/tags/policy_validator.py +580 -0
  45. moai_adk/core/tags/pre_commit_validator.py +421 -0
  46. moai_adk/core/tags/reporter.py +956 -0
  47. moai_adk/core/tags/rollback_manager.py +525 -0
  48. moai_adk/core/tags/tags.py +149 -0
  49. moai_adk/core/tags/validator.py +897 -0
  50. moai_adk/core/template/__init__.py +1 -1
  51. moai_adk/core/template/backup.py +1 -1
  52. moai_adk/core/template/merger.py +50 -1
  53. moai_adk/core/template/processor.py +119 -13
  54. moai_adk/core/template_engine.py +268 -0
  55. moai_adk/templates/.claude/agents/alfred/backend-expert.md +348 -0
  56. moai_adk/templates/.claude/agents/alfred/cc-manager.md +209 -944
  57. moai_adk/templates/.claude/agents/alfred/database-expert.md +352 -0
  58. moai_adk/templates/.claude/agents/alfred/debug-helper.md +34 -5
  59. moai_adk/templates/.claude/agents/alfred/devops-expert.md +464 -0
  60. moai_adk/templates/.claude/agents/alfred/doc-syncer.md +38 -8
  61. moai_adk/templates/.claude/agents/alfred/format-expert.md +469 -0
  62. moai_adk/templates/.claude/agents/alfred/frontend-expert.md +357 -0
  63. moai_adk/templates/.claude/agents/alfred/git-manager.md +128 -9
  64. moai_adk/templates/.claude/agents/alfred/implementation-planner.md +104 -6
  65. moai_adk/templates/.claude/agents/alfred/project-manager.md +88 -16
  66. moai_adk/templates/.claude/agents/alfred/quality-gate.md +36 -9
  67. moai_adk/templates/.claude/agents/alfred/security-expert.md +270 -0
  68. moai_adk/templates/.claude/agents/alfred/skill-factory.md +865 -0
  69. moai_adk/templates/.claude/agents/alfred/spec-builder.md +214 -43
  70. moai_adk/templates/.claude/agents/alfred/tag-agent.md +111 -9
  71. moai_adk/templates/.claude/agents/alfred/tdd-implementer.md +309 -160
  72. moai_adk/templates/.claude/agents/alfred/trust-checker.md +36 -7
  73. moai_adk/templates/.claude/agents/alfred/ui-ux-expert.md +605 -0
  74. moai_adk/templates/.claude/commands/alfred/0-project.md +393 -966
  75. moai_adk/templates/.claude/commands/alfred/1-plan.md +651 -367
  76. moai_adk/templates/.claude/commands/alfred/2-run.md +388 -241
  77. moai_adk/templates/.claude/commands/alfred/3-sync.md +1921 -410
  78. moai_adk/templates/.claude/commands/alfred/9-feedback.md +153 -0
  79. moai_adk/templates/.claude/commands/alfred/release-new.md +3604 -0
  80. moai_adk/templates/.claude/hooks/alfred/core/project.py +484 -20
  81. moai_adk/templates/.claude/hooks/alfred/core/timeout.py +136 -0
  82. moai_adk/templates/.claude/hooks/alfred/core/ttl_cache.py +108 -0
  83. moai_adk/templates/.claude/hooks/alfred/core/version_cache.py +198 -0
  84. moai_adk/templates/.claude/hooks/alfred/handlers/__init__.py +14 -6
  85. moai_adk/templates/.claude/hooks/alfred/post_tool__enable_streaming_ui.py +50 -0
  86. moai_adk/templates/.claude/hooks/alfred/post_tool__log_changes.py +93 -0
  87. moai_adk/templates/.claude/hooks/alfred/post_tool__tag_auto_corrector.py +407 -0
  88. moai_adk/templates/.claude/hooks/alfred/pre_tool__auto_checkpoint.py +99 -0
  89. moai_adk/templates/.claude/hooks/alfred/pre_tool__realtime_tag_monitor.py +335 -0
  90. moai_adk/templates/.claude/hooks/alfred/pre_tool__tag_policy_validator.py +325 -0
  91. moai_adk/templates/.claude/hooks/alfred/session_end__cleanup.py +93 -0
  92. moai_adk/templates/.claude/hooks/alfred/session_start__auto_cleanup.py +580 -0
  93. moai_adk/templates/.claude/hooks/alfred/session_start__show_project_info.py +298 -0
  94. moai_adk/templates/.claude/hooks/alfred/shared/core/__init__.py +170 -0
  95. moai_adk/templates/.claude/hooks/alfred/{core → shared/core}/checkpoint.py +3 -3
  96. moai_adk/templates/.claude/hooks/alfred/{core → shared/core}/context.py +5 -5
  97. moai_adk/templates/.claude/hooks/alfred/shared/core/project.py +749 -0
  98. moai_adk/templates/.claude/hooks/alfred/shared/core/tags.py +230 -0
  99. moai_adk/templates/.claude/hooks/alfred/shared/core/version_cache.py +198 -0
  100. moai_adk/templates/.claude/hooks/alfred/shared/handlers/__init__.py +21 -0
  101. moai_adk/templates/.claude/hooks/alfred/shared/handlers/daily_analysis.py +351 -0
  102. moai_adk/templates/.claude/hooks/alfred/shared/handlers/notification.py +154 -0
  103. moai_adk/templates/.claude/hooks/alfred/shared/handlers/session.py +174 -0
  104. moai_adk/templates/.claude/hooks/alfred/shared/handlers/tool.py +87 -0
  105. moai_adk/templates/.claude/hooks/alfred/shared/handlers/user.py +61 -0
  106. moai_adk/templates/.claude/hooks/alfred/user_prompt__jit_load_docs.py +111 -0
  107. moai_adk/templates/.claude/hooks/alfred/utils/__init__.py +1 -0
  108. moai_adk/templates/.claude/hooks/alfred/utils/hook_config.py +94 -0
  109. moai_adk/templates/.claude/hooks/alfred/utils/timeout.py +161 -0
  110. moai_adk/templates/.claude/output-styles/alfred/alfred-moai-adk-beginner.md +267 -0
  111. moai_adk/templates/.claude/output-styles/alfred/keating-personal-tutor.md +440 -0
  112. moai_adk/templates/.claude/output-styles/alfred/r2d2-agentic-coding.md +583 -0
  113. moai_adk/templates/.claude/settings.json +96 -14
  114. moai_adk/templates/.claude/skills/moai-alfred-agent-guide/SKILL.md +70 -0
  115. moai_adk/templates/.claude/skills/moai-alfred-agent-guide/examples.md +62 -0
  116. moai_adk/templates/.claude/skills/moai-alfred-agent-guide/reference.md +242 -0
  117. moai_adk/templates/.claude/skills/moai-alfred-ask-user-questions/SKILL.md +237 -0
  118. moai_adk/templates/.claude/skills/moai-alfred-ask-user-questions/examples.md +871 -0
  119. moai_adk/templates/.claude/skills/moai-alfred-ask-user-questions/reference.md +653 -0
  120. moai_adk/templates/.claude/skills/moai-alfred-clone-pattern/README.md +162 -0
  121. moai_adk/templates/.claude/skills/moai-alfred-clone-pattern/SKILL.md +227 -0
  122. moai_adk/templates/.claude/skills/moai-alfred-clone-pattern/examples.md +354 -0
  123. moai_adk/templates/.claude/skills/moai-alfred-clone-pattern/reference.md +158 -0
  124. moai_adk/templates/.claude/skills/moai-alfred-code-reviewer/SKILL.md +179 -79
  125. moai_adk/templates/.claude/skills/moai-alfred-code-reviewer/examples.md +117 -0
  126. moai_adk/templates/.claude/skills/moai-alfred-code-reviewer/scripts/pre-review-check.sh +62 -0
  127. moai_adk/templates/.claude/skills/moai-alfred-config-schema/SKILL.md +132 -0
  128. moai_adk/templates/.claude/skills/moai-alfred-config-schema/examples.md +28 -0
  129. moai_adk/templates/.claude/skills/moai-alfred-config-schema/reference.md +444 -0
  130. moai_adk/templates/.claude/skills/moai-alfred-context-budget/SKILL.md +62 -0
  131. moai_adk/templates/.claude/skills/moai-alfred-context-budget/examples.md +28 -0
  132. moai_adk/templates/.claude/skills/moai-alfred-context-budget/reference.md +405 -0
  133. moai_adk/templates/.claude/skills/moai-alfred-dev-guide/SKILL.md +51 -0
  134. moai_adk/templates/.claude/skills/moai-alfred-dev-guide/examples.md +355 -0
  135. moai_adk/templates/.claude/skills/moai-alfred-dev-guide/reference.md +239 -0
  136. moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/SKILL.md +323 -0
  137. moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/examples.md +286 -0
  138. moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/reference.md +126 -0
  139. moai_adk/templates/.claude/skills/moai-alfred-issue-labels/SKILL.md +229 -0
  140. moai_adk/templates/.claude/skills/moai-alfred-issue-labels/examples.md +4 -0
  141. moai_adk/templates/.claude/skills/moai-alfred-issue-labels/reference.md +150 -0
  142. moai_adk/templates/.claude/skills/moai-alfred-language-detection/SKILL.md +87 -73
  143. moai_adk/templates/.claude/skills/moai-alfred-language-detection/examples.md +29 -0
  144. moai_adk/templates/.claude/skills/moai-alfred-language-detection/reference.md +28 -0
  145. moai_adk/templates/.claude/skills/moai-alfred-personas/README.md +42 -0
  146. moai_adk/templates/.claude/skills/moai-alfred-personas/SKILL.md +429 -0
  147. moai_adk/templates/.claude/skills/moai-alfred-personas/examples.md +520 -0
  148. moai_adk/templates/.claude/skills/moai-alfred-personas/reference.md +405 -0
  149. moai_adk/templates/.claude/skills/moai-alfred-practices/SKILL.md +89 -0
  150. moai_adk/templates/.claude/skills/moai-alfred-practices/examples.md +122 -0
  151. moai_adk/templates/.claude/skills/moai-alfred-practices/reference.md +369 -0
  152. moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/SKILL.md +508 -0
  153. moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/examples.md +481 -0
  154. moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/reference.md +100 -0
  155. moai_adk/templates/.claude/skills/moai-alfred-rules/SKILL.md +77 -0
  156. moai_adk/templates/.claude/skills/moai-alfred-rules/examples.md +265 -0
  157. moai_adk/templates/.claude/skills/moai-alfred-rules/reference.md +539 -0
  158. moai_adk/templates/.claude/skills/moai-alfred-session-state/SKILL.md +320 -0
  159. moai_adk/templates/.claude/skills/moai-alfred-session-state/examples.md +4 -0
  160. moai_adk/templates/.claude/skills/moai-alfred-session-state/reference.md +84 -0
  161. moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/README.md +137 -0
  162. moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/SKILL.md +219 -0
  163. moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/examples/validate-spec.sh +161 -0
  164. moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/examples.md +541 -0
  165. moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/reference.md +622 -0
  166. moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/SKILL.md +19 -0
  167. moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/examples.md +4 -0
  168. moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/reference.md +211 -0
  169. moai_adk/templates/.claude/skills/moai-alfred-workflow/SKILL.md +288 -0
  170. moai_adk/templates/.claude/skills/moai-cc-agents/SKILL.md +269 -0
  171. moai_adk/templates/.claude/skills/moai-cc-agents/templates/agent-template.md +32 -0
  172. moai_adk/templates/.claude/skills/moai-cc-claude-md/SKILL.md +298 -0
  173. moai_adk/templates/.claude/skills/moai-cc-claude-md/templates/CLAUDE-template.md +26 -0
  174. moai_adk/templates/.claude/skills/moai-cc-commands/SKILL.md +307 -0
  175. moai_adk/templates/.claude/skills/moai-cc-commands/templates/command-template.md +21 -0
  176. moai_adk/templates/.claude/skills/moai-cc-hooks/SKILL.md +252 -0
  177. moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/pre-bash-check.sh +19 -0
  178. moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/preserve-permissions.sh +19 -0
  179. moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/validate-bash-command.py +24 -0
  180. moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/SKILL.md +199 -0
  181. moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/templates/settings-mcp-template.json +39 -0
  182. moai_adk/templates/.claude/skills/moai-cc-memory/SKILL.md +316 -0
  183. moai_adk/templates/.claude/skills/moai-cc-memory/templates/session-summary-template.md +18 -0
  184. moai_adk/templates/.claude/skills/moai-cc-settings/SKILL.md +263 -0
  185. moai_adk/templates/.claude/skills/moai-cc-settings/templates/settings-complete-template.json +30 -0
  186. moai_adk/templates/.claude/skills/moai-cc-skill-factory/CHECKLIST.md +482 -0
  187. moai_adk/templates/.claude/skills/moai-cc-skill-factory/EXAMPLES.md +303 -0
  188. moai_adk/templates/.claude/skills/moai-cc-skill-factory/INTERACTIVE-DISCOVERY.md +524 -0
  189. moai_adk/templates/.claude/skills/moai-cc-skill-factory/METADATA.md +477 -0
  190. moai_adk/templates/.claude/skills/moai-cc-skill-factory/PARALLEL-ANALYSIS-REPORT.md +429 -0
  191. moai_adk/templates/.claude/skills/moai-cc-skill-factory/PYTHON-VERSION-MATRIX.md +391 -0
  192. moai_adk/templates/.claude/skills/moai-cc-skill-factory/SKILL-FACTORY-WORKFLOW.md +431 -0
  193. moai_adk/templates/.claude/skills/moai-cc-skill-factory/SKILL-UPDATE-ADVISOR.md +577 -0
  194. moai_adk/templates/.claude/skills/moai-cc-skill-factory/SKILL.md +273 -0
  195. moai_adk/templates/.claude/skills/moai-cc-skill-factory/STEP-BY-STEP-GUIDE.md +466 -0
  196. moai_adk/templates/.claude/skills/moai-cc-skill-factory/STRUCTURE.md +583 -0
  197. moai_adk/templates/.claude/skills/moai-cc-skill-factory/WEB-RESEARCH.md +526 -0
  198. moai_adk/templates/.claude/skills/moai-cc-skill-factory/reference.md +608 -0
  199. moai_adk/templates/.claude/skills/moai-cc-skill-factory/scripts/generate-structure.sh +328 -0
  200. moai_adk/templates/.claude/skills/moai-cc-skill-factory/scripts/validate-skill.sh +312 -0
  201. moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/SKILL_TEMPLATE.md +245 -0
  202. moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/examples-template.md +285 -0
  203. moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/reference-template.md +278 -0
  204. moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/scripts-template.sh +303 -0
  205. moai_adk/templates/.claude/skills/moai-cc-skills/SKILL.md +291 -0
  206. moai_adk/templates/.claude/skills/moai-cc-skills/templates/SKILL-template.md +15 -0
  207. moai_adk/templates/.claude/skills/moai-change-logger/SKILL.md +563 -0
  208. moai_adk/templates/.claude/skills/moai-design-systems/SKILL.md +802 -0
  209. moai_adk/templates/.claude/skills/moai-design-systems/examples.md +1238 -0
  210. moai_adk/templates/.claude/skills/moai-design-systems/reference.md +673 -0
  211. moai_adk/templates/.claude/skills/moai-domain-backend/SKILL.md +234 -43
  212. moai_adk/templates/.claude/skills/moai-domain-backend/examples.md +1633 -0
  213. moai_adk/templates/.claude/skills/moai-domain-backend/reference.md +660 -0
  214. moai_adk/templates/.claude/skills/moai-domain-cli-tool/SKILL.md +97 -69
  215. moai_adk/templates/.claude/skills/moai-domain-cli-tool/examples.md +29 -0
  216. moai_adk/templates/.claude/skills/moai-domain-cli-tool/reference.md +30 -0
  217. moai_adk/templates/.claude/skills/moai-domain-data-science/SKILL.md +97 -72
  218. moai_adk/templates/.claude/skills/moai-domain-data-science/examples.md +29 -0
  219. moai_adk/templates/.claude/skills/moai-domain-data-science/reference.md +30 -0
  220. moai_adk/templates/.claude/skills/moai-domain-database/SKILL.md +97 -74
  221. moai_adk/templates/.claude/skills/moai-domain-database/examples.md +29 -0
  222. moai_adk/templates/.claude/skills/moai-domain-database/reference.md +30 -0
  223. moai_adk/templates/.claude/skills/moai-domain-devops/SKILL.md +98 -74
  224. moai_adk/templates/.claude/skills/moai-domain-devops/examples.md +29 -0
  225. moai_adk/templates/.claude/skills/moai-domain-devops/reference.md +31 -0
  226. moai_adk/templates/.claude/skills/moai-domain-frontend/SKILL.md +102 -73
  227. moai_adk/templates/.claude/skills/moai-domain-frontend/examples.md +29 -0
  228. moai_adk/templates/.claude/skills/moai-domain-frontend/reference.md +31 -0
  229. moai_adk/templates/.claude/skills/moai-domain-ml/SKILL.md +97 -73
  230. moai_adk/templates/.claude/skills/moai-domain-ml/examples.md +29 -0
  231. moai_adk/templates/.claude/skills/moai-domain-ml/reference.md +30 -0
  232. moai_adk/templates/.claude/skills/moai-domain-mobile-app/SKILL.md +97 -67
  233. moai_adk/templates/.claude/skills/moai-domain-mobile-app/examples.md +29 -0
  234. moai_adk/templates/.claude/skills/moai-domain-mobile-app/reference.md +30 -0
  235. moai_adk/templates/.claude/skills/moai-domain-security/SKILL.md +97 -79
  236. moai_adk/templates/.claude/skills/moai-domain-security/examples.md +29 -0
  237. moai_adk/templates/.claude/skills/moai-domain-security/reference.md +30 -0
  238. moai_adk/templates/.claude/skills/moai-domain-web-api/SKILL.md +97 -71
  239. moai_adk/templates/.claude/skills/moai-domain-web-api/examples.md +29 -0
  240. moai_adk/templates/.claude/skills/moai-domain-web-api/reference.md +30 -0
  241. moai_adk/templates/.claude/skills/moai-essentials-debug/SKILL.md +265 -64
  242. moai_adk/templates/.claude/skills/moai-essentials-debug/examples.md +1064 -0
  243. moai_adk/templates/.claude/skills/moai-essentials-debug/reference.md +1047 -0
  244. moai_adk/templates/.claude/skills/moai-essentials-perf/SKILL.md +87 -78
  245. moai_adk/templates/.claude/skills/moai-essentials-perf/examples.md +29 -0
  246. moai_adk/templates/.claude/skills/moai-essentials-perf/reference.md +28 -0
  247. moai_adk/templates/.claude/skills/moai-essentials-refactor/SKILL.md +87 -70
  248. moai_adk/templates/.claude/skills/moai-essentials-refactor/examples.md +29 -0
  249. moai_adk/templates/.claude/skills/moai-essentials-refactor/reference.md +28 -0
  250. moai_adk/templates/.claude/skills/moai-essentials-review/SKILL.md +87 -86
  251. moai_adk/templates/.claude/skills/moai-essentials-review/examples.md +29 -0
  252. moai_adk/templates/.claude/skills/moai-essentials-review/reference.md +28 -0
  253. moai_adk/templates/.claude/skills/moai-foundation-ears/SKILL.md +80 -62
  254. moai_adk/templates/.claude/skills/moai-foundation-ears/examples.md +29 -0
  255. moai_adk/templates/.claude/skills/moai-foundation-ears/reference.md +28 -0
  256. moai_adk/templates/.claude/skills/moai-foundation-git/SKILL.md +207 -50
  257. moai_adk/templates/.claude/skills/moai-foundation-git/examples.md +29 -0
  258. moai_adk/templates/.claude/skills/moai-foundation-git/reference.md +29 -0
  259. moai_adk/templates/.claude/skills/moai-foundation-langs/SKILL.md +90 -71
  260. moai_adk/templates/.claude/skills/moai-foundation-langs/examples.md +29 -0
  261. moai_adk/templates/.claude/skills/moai-foundation-langs/reference.md +28 -0
  262. moai_adk/templates/.claude/skills/moai-foundation-specs/SKILL.md +78 -58
  263. moai_adk/templates/.claude/skills/moai-foundation-specs/examples.md +29 -0
  264. moai_adk/templates/.claude/skills/moai-foundation-specs/reference.md +28 -0
  265. moai_adk/templates/.claude/skills/moai-foundation-tags/SKILL.md +78 -51
  266. moai_adk/templates/.claude/skills/moai-foundation-tags/examples.md +29 -0
  267. moai_adk/templates/.claude/skills/moai-foundation-tags/reference.md +28 -0
  268. moai_adk/templates/.claude/skills/moai-foundation-trust/.!11330!examples.md +0 -0
  269. moai_adk/templates/.claude/skills/moai-foundation-trust/SKILL.md +253 -32
  270. moai_adk/templates/.claude/skills/moai-foundation-trust/examples.md +0 -0
  271. moai_adk/templates/.claude/skills/moai-foundation-trust/reference.md +1099 -0
  272. moai_adk/templates/.claude/skills/moai-jit-docs-enhanced/SKILL.md +460 -0
  273. moai_adk/templates/.claude/skills/moai-lang-c/SKILL.md +98 -74
  274. moai_adk/templates/.claude/skills/moai-lang-c/examples.md +29 -0
  275. moai_adk/templates/.claude/skills/moai-lang-c/reference.md +31 -0
  276. moai_adk/templates/.claude/skills/moai-lang-cpp/SKILL.md +98 -76
  277. moai_adk/templates/.claude/skills/moai-lang-cpp/examples.md +29 -0
  278. moai_adk/templates/.claude/skills/moai-lang-cpp/reference.md +31 -0
  279. moai_adk/templates/.claude/skills/moai-lang-csharp/SKILL.md +2358 -70
  280. moai_adk/templates/.claude/skills/moai-lang-csharp/examples.md +29 -0
  281. moai_adk/templates/.claude/skills/moai-lang-csharp/reference.md +30 -0
  282. moai_adk/templates/.claude/skills/moai-lang-dart/SKILL.md +2962 -68
  283. moai_adk/templates/.claude/skills/moai-lang-dart/examples.md +29 -0
  284. moai_adk/templates/.claude/skills/moai-lang-dart/reference.md +30 -0
  285. moai_adk/templates/.claude/skills/moai-lang-go/SKILL.md +1898 -70
  286. moai_adk/templates/.claude/skills/moai-lang-go/examples.md +29 -0
  287. moai_adk/templates/.claude/skills/moai-lang-go/reference.md +31 -0
  288. moai_adk/templates/.claude/skills/moai-lang-java/SKILL.md +1465 -68
  289. moai_adk/templates/.claude/skills/moai-lang-java/examples.md +29 -0
  290. moai_adk/templates/.claude/skills/moai-lang-java/reference.md +31 -0
  291. moai_adk/templates/.claude/skills/moai-lang-javascript/SKILL.md +2364 -66
  292. moai_adk/templates/.claude/skills/moai-lang-javascript/examples.md +29 -0
  293. moai_adk/templates/.claude/skills/moai-lang-javascript/reference.md +32 -0
  294. moai_adk/templates/.claude/skills/moai-lang-kotlin/SKILL.md +1630 -69
  295. moai_adk/templates/.claude/skills/moai-lang-kotlin/examples.md +29 -0
  296. moai_adk/templates/.claude/skills/moai-lang-kotlin/reference.md +31 -0
  297. moai_adk/templates/.claude/skills/moai-lang-php/SKILL.md +89 -61
  298. moai_adk/templates/.claude/skills/moai-lang-php/examples.md +29 -0
  299. moai_adk/templates/.claude/skills/moai-lang-php/reference.md +30 -0
  300. moai_adk/templates/.claude/skills/moai-lang-python/SKILL.md +735 -66
  301. moai_adk/templates/.claude/skills/moai-lang-python/examples.md +624 -0
  302. moai_adk/templates/.claude/skills/moai-lang-python/reference.md +316 -0
  303. moai_adk/templates/.claude/skills/moai-lang-r/SKILL.md +97 -73
  304. moai_adk/templates/.claude/skills/moai-lang-r/examples.md +29 -0
  305. moai_adk/templates/.claude/skills/moai-lang-r/reference.md +30 -0
  306. moai_adk/templates/.claude/skills/moai-lang-ruby/SKILL.md +98 -73
  307. moai_adk/templates/.claude/skills/moai-lang-ruby/examples.md +29 -0
  308. moai_adk/templates/.claude/skills/moai-lang-ruby/reference.md +31 -0
  309. moai_adk/templates/.claude/skills/moai-lang-rust/SKILL.md +1834 -70
  310. moai_adk/templates/.claude/skills/moai-lang-rust/examples.md +29 -0
  311. moai_adk/templates/.claude/skills/moai-lang-rust/reference.md +31 -0
  312. moai_adk/templates/.claude/skills/moai-lang-scala/SKILL.md +99 -74
  313. moai_adk/templates/.claude/skills/moai-lang-scala/examples.md +29 -0
  314. moai_adk/templates/.claude/skills/moai-lang-scala/reference.md +30 -0
  315. moai_adk/templates/.claude/skills/moai-lang-shell/SKILL.md +97 -74
  316. moai_adk/templates/.claude/skills/moai-lang-shell/examples.md +29 -0
  317. moai_adk/templates/.claude/skills/moai-lang-shell/reference.md +30 -0
  318. moai_adk/templates/.claude/skills/moai-lang-sql/SKILL.md +98 -74
  319. moai_adk/templates/.claude/skills/moai-lang-sql/examples.md +29 -0
  320. moai_adk/templates/.claude/skills/moai-lang-sql/reference.md +31 -0
  321. moai_adk/templates/.claude/skills/moai-lang-swift/SKILL.md +1959 -69
  322. moai_adk/templates/.claude/skills/moai-lang-swift/examples.md +29 -0
  323. moai_adk/templates/.claude/skills/moai-lang-swift/reference.md +30 -0
  324. moai_adk/templates/.claude/skills/moai-lang-template/SKILL.md +348 -0
  325. moai_adk/templates/.claude/skills/moai-lang-template/VARIABLES.md +98 -0
  326. moai_adk/templates/.claude/skills/moai-lang-typescript/SKILL.md +1230 -66
  327. moai_adk/templates/.claude/skills/moai-lang-typescript/examples.md +29 -0
  328. moai_adk/templates/.claude/skills/moai-lang-typescript/reference.md +34 -0
  329. moai_adk/templates/.claude/skills/moai-learning-optimizer/SKILL.md +575 -0
  330. moai_adk/templates/.claude/skills/moai-project-batch-questions/README.md +50 -0
  331. moai_adk/templates/.claude/skills/moai-project-batch-questions/SKILL.md +304 -0
  332. moai_adk/templates/.claude/skills/moai-project-batch-questions/examples.md +417 -0
  333. moai_adk/templates/.claude/skills/moai-project-batch-questions/reference.md +704 -0
  334. moai_adk/templates/.claude/skills/moai-project-config-manager/README.md +87 -0
  335. moai_adk/templates/.claude/skills/moai-project-config-manager/SKILL.md +552 -0
  336. moai_adk/templates/.claude/skills/moai-project-config-manager/examples.md +1109 -0
  337. moai_adk/templates/.claude/skills/moai-project-config-manager/reference.md +514 -0
  338. moai_adk/templates/.claude/skills/moai-project-config-manager/validate.py +106 -0
  339. moai_adk/templates/.claude/skills/moai-project-documentation/README.md +11 -0
  340. moai_adk/templates/.claude/skills/moai-project-documentation/SKILL.md +622 -0
  341. moai_adk/templates/.claude/skills/moai-project-documentation/examples.md +20 -0
  342. moai_adk/templates/.claude/skills/moai-project-documentation/reference.md +12 -0
  343. moai_adk/templates/.claude/skills/moai-project-language-initializer/README.md +152 -0
  344. moai_adk/templates/.claude/skills/moai-project-language-initializer/SKILL.md +285 -0
  345. moai_adk/templates/.claude/skills/moai-project-language-initializer/examples.md +333 -0
  346. moai_adk/templates/.claude/skills/moai-project-language-initializer/reference.md +386 -0
  347. moai_adk/templates/.claude/skills/moai-project-template-optimizer/README.md +49 -0
  348. moai_adk/templates/.claude/skills/moai-project-template-optimizer/SKILL.md +319 -0
  349. moai_adk/templates/.claude/skills/moai-project-template-optimizer/examples.md +58 -0
  350. moai_adk/templates/.claude/skills/moai-project-template-optimizer/reference.md +123 -0
  351. moai_adk/templates/.claude/skills/moai-session-info/SKILL.md +314 -0
  352. moai_adk/templates/.claude/skills/moai-streaming-ui/SKILL.md +552 -0
  353. moai_adk/templates/.claude/skills/moai-tag-policy-validator/SKILL.md +570 -0
  354. moai_adk/templates/.git-hooks/pre-commit +66 -0
  355. moai_adk/templates/.git-hooks/pre-push +255 -0
  356. moai_adk/templates/.github/workflows/c-tag-validation.yml +11 -0
  357. moai_adk/templates/.github/workflows/cpp-tag-validation.yml +11 -0
  358. moai_adk/templates/.github/workflows/csharp-tag-validation.yml +11 -0
  359. moai_adk/templates/.github/workflows/dart-tag-validation.yml +11 -0
  360. moai_adk/templates/.github/workflows/go-tag-validation.yml +130 -0
  361. moai_adk/templates/.github/workflows/java-tag-validation.yml +11 -0
  362. moai_adk/templates/.github/workflows/javascript-tag-validation.yml +135 -0
  363. moai_adk/templates/.github/workflows/kotlin-tag-validation.yml +11 -0
  364. moai_adk/templates/.github/workflows/moai-gitflow.yml +166 -3
  365. moai_adk/templates/.github/workflows/moai-release-create.yml +100 -0
  366. moai_adk/templates/.github/workflows/moai-release-pipeline.yml +188 -0
  367. moai_adk/templates/.github/workflows/php-tag-validation.yml +11 -0
  368. moai_adk/templates/.github/workflows/python-tag-validation.yml +118 -0
  369. moai_adk/templates/.github/workflows/release.yml +118 -0
  370. moai_adk/templates/.github/workflows/ruby-tag-validation.yml +11 -0
  371. moai_adk/templates/.github/workflows/rust-tag-validation.yml +11 -0
  372. moai_adk/templates/.github/workflows/shell-tag-validation.yml +11 -0
  373. moai_adk/templates/.github/workflows/spec-issue-sync.yml +338 -0
  374. moai_adk/templates/.github/workflows/swift-tag-validation.yml +11 -0
  375. moai_adk/templates/.github/workflows/tag-report.yml +269 -0
  376. moai_adk/templates/.github/workflows/tag-validation.yml +186 -0
  377. moai_adk/templates/.github/workflows/typescript-tag-validation.yml +154 -0
  378. moai_adk/templates/.mcp.json +31 -0
  379. moai_adk/templates/.moai/config.json +80 -7
  380. moai_adk/templates/CLAUDE.md +562 -546
  381. moai_adk/utils/banner.py +5 -5
  382. moai_adk/utils/common.py +294 -0
  383. moai_adk/utils/link_validator.py +235 -0
  384. moai_adk/utils/logger.py +8 -8
  385. moai_adk/utils/user_experience.py +451 -0
  386. moai_adk-0.20.1.dist-info/METADATA +233 -0
  387. moai_adk-0.20.1.dist-info/RECORD +404 -0
  388. moai_adk/templates/.claude/hooks/alfred/README.md +0 -230
  389. moai_adk/templates/.claude/hooks/alfred/alfred_hooks.py +0 -156
  390. moai_adk/templates/.claude/hooks/alfred/core/__init__.py +0 -85
  391. moai_adk/templates/.claude/hooks/alfred/handlers/notification.py +0 -25
  392. moai_adk/templates/.claude/hooks/alfred/handlers/session.py +0 -92
  393. moai_adk/templates/.claude/hooks/alfred/handlers/tool.py +0 -70
  394. moai_adk/templates/.claude/hooks/alfred/handlers/user.py +0 -41
  395. moai_adk/templates/.claude/output-styles/alfred/agentic-coding.md +0 -636
  396. moai_adk/templates/.claude/output-styles/alfred/moai-adk-learning.md +0 -692
  397. moai_adk/templates/.claude/output-styles/alfred/study-with-alfred.md +0 -470
  398. moai_adk/templates/.claude/skills/moai-alfred-debugger-pro/SKILL.md +0 -103
  399. moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/SKILL.md +0 -103
  400. moai_adk/templates/.claude/skills/moai-alfred-git-workflow/SKILL.md +0 -95
  401. moai_adk/templates/.claude/skills/moai-alfred-performance-optimizer/SKILL.md +0 -105
  402. moai_adk/templates/.claude/skills/moai-alfred-refactoring-coach/SKILL.md +0 -97
  403. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/SKILL.md +0 -97
  404. moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/SKILL.md +0 -90
  405. moai_adk/templates/.claude/skills/moai-alfred-trust-validation/SKILL.md +0 -99
  406. moai_adk/templates/.claude/skills/moai-alfred-tui-survey/SKILL.md +0 -87
  407. moai_adk/templates/.claude/skills/moai-alfred-tui-survey/examples.md +0 -62
  408. moai_adk/templates/.claude/skills/moai-claude-code/SKILL.md +0 -94
  409. moai_adk/templates/.claude/skills/moai-claude-code/examples.md +0 -513
  410. moai_adk/templates/.claude/skills/moai-claude-code/reference.md +0 -433
  411. moai_adk/templates/.claude/skills/moai-claude-code/templates/agent-full.md +0 -332
  412. moai_adk/templates/.claude/skills/moai-claude-code/templates/command-full.md +0 -384
  413. moai_adk/templates/.claude/skills/moai-claude-code/templates/plugin-full.json +0 -363
  414. moai_adk/templates/.claude/skills/moai-claude-code/templates/settings-full.json +0 -595
  415. moai_adk/templates/.claude/skills/moai-claude-code/templates/skill-full.md +0 -496
  416. moai_adk/templates/.claude/skills/moai-lang-clojure/SKILL.md +0 -100
  417. moai_adk/templates/.claude/skills/moai-lang-elixir/SKILL.md +0 -99
  418. moai_adk/templates/.claude/skills/moai-lang-haskell/SKILL.md +0 -100
  419. moai_adk/templates/.claude/skills/moai-lang-julia/SKILL.md +0 -98
  420. moai_adk/templates/.claude/skills/moai-lang-lua/SKILL.md +0 -98
  421. moai_adk/templates/.github/PULL_REQUEST_TEMPLATE.md +0 -69
  422. moai_adk/templates/.moai/memory/development-guide.md +0 -344
  423. moai_adk/templates/.moai/memory/gitflow-protection-policy.md +0 -220
  424. moai_adk/templates/.moai/memory/spec-metadata.md +0 -356
  425. moai_adk/templates/.moai/project/product.md +0 -161
  426. moai_adk/templates/.moai/project/structure.md +0 -156
  427. moai_adk/templates/.moai/project/tech.md +0 -227
  428. moai_adk/templates/__init__.py +0 -2
  429. moai_adk-0.4.5.dist-info/METADATA +0 -369
  430. moai_adk-0.4.5.dist-info/RECORD +0 -152
  431. {moai_adk-0.4.5.dist-info → moai_adk-0.20.1.dist-info}/WHEEL +0 -0
  432. {moai_adk-0.4.5.dist-info → moai_adk-0.20.1.dist-info}/entry_points.txt +0 -0
  433. {moai_adk-0.4.5.dist-info → moai_adk-0.20.1.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,525 @@
1
+ #!/usr/bin/env python3
2
+ # @CODE:TAG-ROLLBACK-MANAGER-001 | @SPEC:TAG-ROLLBACK-001
3
+ """TAG 시스템 롤백 관리자
4
+
5
+ TAG 정책 시스템에서 문제 발생 시 안전한 롤백을 제공하는 관리자.
6
+ 체크포인트 기반 복구와 이력 추적 기능을 지원.
7
+
8
+ 주요 기능:
9
+ - 체크포인트 생성 및 관리
10
+ - 안전한 롤백 실행
11
+ - 이력 추적 및 로깅
12
+ - 비상 복구 시스템
13
+
14
+ @SPEC:TAG-ROLLBACK-001
15
+ """
16
+
17
+ import json
18
+ import shutil
19
+ import time
20
+ from dataclasses import dataclass, field
21
+ from datetime import datetime
22
+ from pathlib import Path
23
+ from typing import Any, Dict, List, Optional
24
+
25
+
26
+ @dataclass
27
+ class Checkpoint:
28
+ """체크포인트 정보
29
+
30
+ Attributes:
31
+ id: 고유 체크포인트 ID
32
+ timestamp: 생성 시간
33
+ description: 체크포인트 설명
34
+ file_states: 파일 상태 정보
35
+ metadata: 추가 메타데이터
36
+ """
37
+ id: str
38
+ timestamp: datetime
39
+ description: str
40
+ file_states: Dict[str, str] # {file_path: content_hash}
41
+ metadata: Dict[str, Any] = field(default_factory=dict)
42
+
43
+ def to_dict(self) -> Dict[str, Any]:
44
+ """딕셔너리로 변환"""
45
+ return {
46
+ "id": self.id,
47
+ "timestamp": self.timestamp.isoformat(),
48
+ "description": self.description,
49
+ "file_states": self.file_states,
50
+ "metadata": self.metadata
51
+ }
52
+
53
+
54
+ @dataclass
55
+ class RollbackConfig:
56
+ """롤백 시스템 설정
57
+
58
+ Attributes:
59
+ checkpoints_dir: 체크포인트 저장 디렉토리
60
+ max_checkpoints: 최대 체크포인트 수
61
+ auto_cleanup: 자동 정리 활성화
62
+ backup_before_rollback: 롤백 전 백업 생성
63
+ rollback_timeout: 롤백 타임아웃 (초)
64
+ """
65
+ checkpoints_dir: str = ".moai/checkpoints"
66
+ max_checkpoints: int = 10
67
+ auto_cleanup: bool = True
68
+ backup_before_rollback: bool = True
69
+ rollback_timeout: int = 30
70
+
71
+
72
+ class RollbackManager:
73
+ """TAG 시스템 롤백 관리자
74
+
75
+ 체크포인트 기반 롤백 시스템을 제공하여 TAG 정책 시스템의 안정성 보장.
76
+ 문제 발생 시 신속하고 안전한 복구를 지원.
77
+
78
+ Usage:
79
+ config = RollbackConfig()
80
+ manager = RollbackManager(config=config)
81
+
82
+ # 체크포인트 생성
83
+ checkpoint_id = manager.create_checkpoint("작업 전 상태")
84
+
85
+ # 롤백 실행
86
+ success = manager.rollback_to_checkpoint(checkpoint_id)
87
+
88
+ # 최신 체크포인트로 롤백
89
+ success = manager.rollback_to_latest()
90
+ """
91
+
92
+ def __init__(self, config: Optional[RollbackConfig] = None):
93
+ """초기화
94
+
95
+ Args:
96
+ config: 롤백 설정 (기본: RollbackConfig())
97
+ """
98
+ self.config = config or RollbackConfig()
99
+ self.checkpoints_dir = Path(self.config.checkpoints_dir)
100
+ self.checkpoints_dir.mkdir(parents=True, exist_ok=True)
101
+
102
+ def create_checkpoint(self, description: str,
103
+ files: Optional[List[str]] = None,
104
+ metadata: Optional[Dict[str, Any]] = None) -> str:
105
+ """체크포인트 생성
106
+
107
+ Args:
108
+ description: 체크포인트 설명
109
+ files: 포함할 파일 목록 (None이면 자동 탐지)
110
+ metadata: 추가 메타데이터
111
+
112
+ Returns:
113
+ 생성된 체크포인트 ID
114
+ """
115
+ checkpoint_id = self._generate_checkpoint_id()
116
+ timestamp = datetime.now()
117
+
118
+ # 파일 상태 수집
119
+ if files is None:
120
+ files = self._discover_project_files()
121
+
122
+ file_states = self._collect_file_states(files)
123
+
124
+ # 체크포인트 생성
125
+ checkpoint = Checkpoint(
126
+ id=checkpoint_id,
127
+ timestamp=timestamp,
128
+ description=description,
129
+ file_states=file_states,
130
+ metadata=metadata or {}
131
+ )
132
+
133
+ # 체크포인트 저장
134
+ self._save_checkpoint(checkpoint)
135
+
136
+ # 파일 백업 생성
137
+ self._backup_files(checkpoint_id, files)
138
+
139
+ # 오래된 체크포인트 정리
140
+ if self.config.auto_cleanup:
141
+ self._cleanup_old_checkpoints()
142
+
143
+ return checkpoint_id
144
+
145
+ def rollback_to_checkpoint(self, checkpoint_id: str) -> bool:
146
+ """특정 체크포인트로 롤백
147
+
148
+ Args:
149
+ checkpoint_id: 롤백할 체크포인트 ID
150
+
151
+ Returns:
152
+ 성공 여부
153
+ """
154
+ try:
155
+ checkpoint = self._load_checkpoint(checkpoint_id)
156
+ if not checkpoint:
157
+ return False
158
+
159
+ # 롤백 전 백업 생성
160
+ if self.config.backup_before_rollback:
161
+ self._create_rollback_backup(checkpoint_id)
162
+
163
+ # 파일 복원
164
+ success = self._restore_files(checkpoint)
165
+
166
+ if success:
167
+ # 롤백 로그 기록
168
+ self._log_rollback(checkpoint_id, checkpoint)
169
+
170
+ return success
171
+
172
+ except Exception:
173
+ return False
174
+
175
+ def rollback_to_latest(self) -> bool:
176
+ """최신 체크포인트로 롤백
177
+
178
+ Returns:
179
+ 성공 여부
180
+ """
181
+ latest_id = self.get_latest_checkpoint_id()
182
+ if not latest_id:
183
+ return False
184
+
185
+ return self.rollback_to_checkpoint(latest_id)
186
+
187
+ def list_checkpoints(self) -> List[Dict[str, Any]]:
188
+ """체크포인트 목록 조회
189
+
190
+ Returns:
191
+ 체크포인트 정보 목록
192
+ """
193
+ checkpoints = []
194
+
195
+ for checkpoint_file in self.checkpoints_dir.glob("checkpoint_*.json"):
196
+ try:
197
+ with open(checkpoint_file, 'r', encoding='utf-8') as f:
198
+ checkpoint_data = json.load(f)
199
+ checkpoints.append(checkpoint_data)
200
+ except Exception:
201
+ continue
202
+
203
+ # 시간순 정렬 (최신 먼저)
204
+ checkpoints.sort(key=lambda x: x.get('timestamp', ''), reverse=True)
205
+
206
+ return checkpoints
207
+
208
+ def get_latest_checkpoint_id(self) -> Optional[str]:
209
+ """최신 체크포인트 ID 조회
210
+
211
+ Returns:
212
+ 최신 체크포인트 ID 또는 None
213
+ """
214
+ checkpoints = self.list_checkpoints()
215
+ return checkpoints[0]['id'] if checkpoints else None
216
+
217
+ def delete_checkpoint(self, checkpoint_id: str) -> bool:
218
+ """체크포인트 삭제
219
+
220
+ Args:
221
+ checkpoint_id: 삭제할 체크포인트 ID
222
+
223
+ Returns:
224
+ 성공 여부
225
+ """
226
+ try:
227
+ # 체크포인트 파일 삭제
228
+ checkpoint_file = self.checkpoints_dir / f"checkpoint_{checkpoint_id}.json"
229
+ if checkpoint_file.exists():
230
+ checkpoint_file.unlink()
231
+
232
+ # 백업 파일 삭제
233
+ backup_dir = self.checkpoints_dir / f"backup_{checkpoint_id}"
234
+ if backup_dir.exists():
235
+ shutil.rmtree(backup_dir)
236
+
237
+ return True
238
+
239
+ except Exception:
240
+ return False
241
+
242
+ def emergency_rollback(self) -> bool:
243
+ """비상 롤백
244
+
245
+ 모든 변경 사항을 취소하고 가장 안전한 상태로 복귀.
246
+
247
+ Returns:
248
+ 성공 여부
249
+ """
250
+ try:
251
+ # 가장 오래된 안정 체크포인트 찾기
252
+ stable_checkpoints = self._find_stable_checkpoints()
253
+ if not stable_checkpoints:
254
+ return False
255
+
256
+ # 가장 오래된 안정 체크포인트로 롤백
257
+ oldest_stable = stable_checkpoints[-1] # 오래된 순서 정렬
258
+ return self.rollback_to_checkpoint(oldest_stable['id'])
259
+
260
+ except Exception:
261
+ return False
262
+
263
+ def validate_checkpoint_integrity(self, checkpoint_id: str) -> bool:
264
+ """체크포인트 무결성 검증
265
+
266
+ Args:
267
+ checkpoint_id: 검증할 체크포인트 ID
268
+
269
+ Returns:
270
+ 무결성 여부
271
+ """
272
+ try:
273
+ checkpoint = self._load_checkpoint(checkpoint_id)
274
+ if not checkpoint:
275
+ return False
276
+
277
+ # 파일 무결성 검증
278
+ backup_dir = self.checkpoints_dir / f"backup_{checkpoint_id}"
279
+ if not backup_dir.exists():
280
+ return False
281
+
282
+ # 백업 파일 존재 확인
283
+ for file_path in checkpoint.file_states.keys():
284
+ backup_file = backup_dir / file_path.replace('/', '_')
285
+ if not backup_file.exists():
286
+ return False
287
+
288
+ return True
289
+
290
+ except Exception:
291
+ return False
292
+
293
+ def _generate_checkpoint_id(self) -> str:
294
+ """체크포인트 ID 생성
295
+
296
+ Returns:
297
+ 고유 체크포인트 ID
298
+ """
299
+ timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
300
+ random_suffix = str(int(time.time() * 1000))[-6:]
301
+ return f"ckpt_{timestamp}_{random_suffix}"
302
+
303
+ def _discover_project_files(self) -> List[str]:
304
+ """프로젝트 파일 자동 탐지
305
+
306
+ Returns:
307
+ 프로젝트 파일 경로 목록
308
+ """
309
+ files = []
310
+ important_patterns = [
311
+ "src/**/*.py",
312
+ "tests/**/*.py",
313
+ "**/*.md",
314
+ "**/*.json",
315
+ "**/*.yml",
316
+ "**/*.yaml",
317
+ ".claude/**/*",
318
+ ".moai/**/*"
319
+ ]
320
+
321
+ for pattern in important_patterns:
322
+ for path in Path(".").glob(pattern):
323
+ if path.is_file():
324
+ files.append(str(path))
325
+
326
+ return list(set(files)) # 중복 제거
327
+
328
+ def _collect_file_states(self, files: List[str]) -> Dict[str, str]:
329
+ """파일 상태 수집
330
+
331
+ Args:
332
+ files: 파일 경로 목록
333
+
334
+ Returns:
335
+ {file_path: content_hash} 딕셔너리
336
+ """
337
+ file_states = {}
338
+
339
+ for file_path in files:
340
+ try:
341
+ path = Path(file_path)
342
+ if path.exists():
343
+ content = path.read_text(encoding="utf-8", errors="ignore")
344
+ # 간단한 해시 (실제로는 hashlib 사용 권장)
345
+ content_hash = str(hash(content))
346
+ file_states[file_path] = content_hash
347
+ except Exception:
348
+ continue
349
+
350
+ return file_states
351
+
352
+ def _save_checkpoint(self, checkpoint: Checkpoint) -> None:
353
+ """체크포인트 저장
354
+
355
+ Args:
356
+ checkpoint: 저장할 체크포인트
357
+ """
358
+ checkpoint_file = self.checkpoints_dir / f"checkpoint_{checkpoint.id}.json"
359
+ with open(checkpoint_file, 'w', encoding='utf-8') as f:
360
+ json.dump(checkpoint.to_dict(), f, indent=2, ensure_ascii=False)
361
+
362
+ def _backup_files(self, checkpoint_id: str, files: List[str]) -> None:
363
+ """파일 백업 생성
364
+
365
+ Args:
366
+ checkpoint_id: 체크포인트 ID
367
+ files: 백업할 파일 목록
368
+ """
369
+ backup_dir = self.checkpoints_dir / f"backup_{checkpoint_id}"
370
+ backup_dir.mkdir(exist_ok=True)
371
+
372
+ for file_path in files:
373
+ try:
374
+ path = Path(file_path)
375
+ if path.exists():
376
+ # 파일명에 /를 _로 변경하여 유효한 파일명으로 변환
377
+ backup_name = file_path.replace('/', '_')
378
+ backup_file = backup_dir / backup_name
379
+ shutil.copy2(path, backup_file)
380
+ except Exception:
381
+ continue
382
+
383
+ def _load_checkpoint(self, checkpoint_id: str) -> Optional[Checkpoint]:
384
+ """체크포인트 로드
385
+
386
+ Args:
387
+ checkpoint_id: 로드할 체크포인트 ID
388
+
389
+ Returns:
390
+ Checkpoint 객체 또는 None
391
+ """
392
+ try:
393
+ checkpoint_file = self.checkpoints_dir / f"checkpoint_{checkpoint_id}.json"
394
+ if not checkpoint_file.exists():
395
+ return None
396
+
397
+ with open(checkpoint_file, 'r', encoding='utf-8') as f:
398
+ data = json.load(f)
399
+
400
+ return Checkpoint(
401
+ id=data['id'],
402
+ timestamp=datetime.fromisoformat(data['timestamp']),
403
+ description=data['description'],
404
+ file_states=data['file_states'],
405
+ metadata=data.get('metadata', {})
406
+ )
407
+
408
+ except Exception:
409
+ return None
410
+
411
+ def _restore_files(self, checkpoint: Checkpoint) -> bool:
412
+ """파일 복원
413
+
414
+ Args:
415
+ checkpoint: 복원할 체크포인트
416
+
417
+ Returns:
418
+ 성공 여부
419
+ """
420
+ backup_dir = self.checkpoints_dir / f"backup_{checkpoint.id}"
421
+ if not backup_dir.exists():
422
+ return False
423
+
424
+ success_count = 0
425
+ total_files = len(checkpoint.file_states)
426
+
427
+ for file_path in checkpoint.file_states.keys():
428
+ try:
429
+ backup_name = file_path.replace('/', '_')
430
+ backup_file = backup_dir / backup_name
431
+ target_file = Path(file_path)
432
+
433
+ if backup_file.exists():
434
+ # 대상 디렉토리 생성
435
+ target_file.parent.mkdir(parents=True, exist_ok=True)
436
+ # 파일 복원
437
+ shutil.copy2(backup_file, target_file)
438
+ success_count += 1
439
+
440
+ except Exception:
441
+ continue
442
+
443
+ return success_count == total_files
444
+
445
+ def _create_rollback_backup(self, checkpoint_id: str) -> None:
446
+ """롤백 전 백업 생성
447
+
448
+ Args:
449
+ checkpoint_id: 롤백할 체크포인트 ID
450
+ """
451
+ backup_id = self._generate_checkpoint_id()
452
+ self.create_checkpoint(
453
+ description=f"롤백 전 백업 (from {checkpoint_id})",
454
+ metadata={"rollback_from": checkpoint_id}
455
+ )
456
+
457
+ def _cleanup_old_checkpoints(self) -> None:
458
+ """오래된 체크포인트 정리"""
459
+ checkpoints = self.list_checkpoints()
460
+
461
+ if len(checkpoints) > self.config.max_checkpoints:
462
+ # 가장 오래된 체크포인트 삭제
463
+ old_checkpoints = checkpoints[self.config.max_checkpoints:]
464
+ for checkpoint in old_checkpoints:
465
+ self.delete_checkpoint(checkpoint['id'])
466
+
467
+ def _find_stable_checkpoints(self) -> List[Dict[str, Any]]:
468
+ """안정적인 체크포인트 찾기
469
+
470
+ Returns:
471
+ 안정적인 체크포인트 목록
472
+ """
473
+ checkpoints = self.list_checkpoints()
474
+ stable_checkpoints = []
475
+
476
+ for checkpoint in checkpoints:
477
+ # 무결성 검증 통과한 체크포인트만 선택
478
+ if self.validate_checkpoint_integrity(checkpoint['id']):
479
+ stable_checkpoints.append(checkpoint)
480
+
481
+ return stable_checkpoints
482
+
483
+ def _log_rollback(self, checkpoint_id: str, checkpoint: Checkpoint) -> None:
484
+ """롤백 로그 기록
485
+
486
+ Args:
487
+ checkpoint_id: 롤백한 체크포인트 ID
488
+ checkpoint: 체크포인트 정보
489
+ """
490
+ log_file = self.checkpoints_dir / "rollback.log"
491
+
492
+ log_entry = {
493
+ "timestamp": datetime.now().isoformat(),
494
+ "checkpoint_id": checkpoint_id,
495
+ "description": checkpoint.description,
496
+ "file_count": len(checkpoint.file_states)
497
+ }
498
+
499
+ try:
500
+ with open(log_file, 'a', encoding='utf-8') as f:
501
+ f.write(json.dumps(log_entry, ensure_ascii=False) + '\n')
502
+ except Exception:
503
+ pass
504
+
505
+ def get_rollback_history(self) -> List[Dict[str, Any]]:
506
+ """롤백 이력 조회
507
+
508
+ Returns:
509
+ 롤백 이력 목록
510
+ """
511
+ log_file = self.checkpoints_dir / "rollback.log"
512
+ history = []
513
+
514
+ if log_file.exists():
515
+ try:
516
+ with open(log_file, 'r', encoding='utf-8') as f:
517
+ for line in f:
518
+ if line.strip():
519
+ history.append(json.loads(line.strip()))
520
+ except Exception:
521
+ pass
522
+
523
+ # 최신 이력부터 정렬
524
+ history.sort(key=lambda x: x.get('timestamp', ''), reverse=True)
525
+ return history
@@ -0,0 +1,149 @@
1
+ # @CODE:VAL-002
2
+ """TAG suggestion and validation orchestrator.
3
+
4
+ Combines parser, generator, mapper, and inserter modules to provide
5
+ high-level TAG suggestion functionality for documentation files.
6
+
7
+ @SPEC:DOC-TAG-001: @DOC tag automatic generation infrastructure
8
+ """
9
+
10
+ from dataclasses import dataclass
11
+ from pathlib import Path
12
+ from typing import Optional
13
+
14
+ from moai_adk.core.tags.generator import detect_duplicates, generate_doc_tag
15
+ from moai_adk.core.tags.mapper import calculate_confidence, find_related_spec
16
+ from moai_adk.core.tags.parser import parse_domain
17
+
18
+
19
+ @dataclass
20
+ class TagSuggestion:
21
+ """Suggested TAG for a documentation file.
22
+
23
+ Attributes:
24
+ tag_id: Generated TAG ID (e.g., "@DOC:AUTH-001")
25
+ chain_ref: Chain reference to SPEC (e.g., "@SPEC:AUTH-004")
26
+ confidence: Confidence score (0.0 to 1.0)
27
+ domain: Extracted domain (e.g., "AUTH")
28
+ file_path: Path to documentation file
29
+ """
30
+
31
+ tag_id: str
32
+ chain_ref: Optional[str]
33
+ confidence: float
34
+ domain: str
35
+ file_path: Path
36
+
37
+
38
+ def suggest_tag_for_file(
39
+ doc_path: Path, search_path: Path = Path("docs/")
40
+ ) -> TagSuggestion:
41
+ """Suggest TAG ID for documentation file.
42
+
43
+ Combines domain detection, SPEC mapping, and TAG generation to
44
+ provide a complete TAG suggestion with chain reference.
45
+
46
+ Args:
47
+ doc_path: Path to documentation file
48
+ search_path: Directory to search for existing tags
49
+
50
+ Returns:
51
+ TagSuggestion with generated TAG and chain reference
52
+
53
+ Examples:
54
+ >>> suggestion = suggest_tag_for_file(Path("docs/auth/guide.md"))
55
+ >>> suggestion.tag_id
56
+ '@DOC:AUTH-001'
57
+ >>> suggestion.chain_ref
58
+ '@SPEC:AUTH-004'
59
+ >>> suggestion.confidence
60
+ 0.85
61
+ """
62
+ # Find related SPEC
63
+ spec_id = find_related_spec(doc_path)
64
+
65
+ # Extract domain
66
+ if spec_id:
67
+ domain = parse_domain(spec_id)
68
+ chain_ref = f"@SPEC:{spec_id}"
69
+ confidence = calculate_confidence(spec_id, doc_path)
70
+ else:
71
+ # Infer domain from file path if no SPEC found
72
+ domain = _infer_domain_from_path(doc_path)
73
+ chain_ref = None
74
+ confidence = 0.3
75
+
76
+ # Detect existing TAGs in the domain
77
+ existing_ids = detect_duplicates(domain, str(search_path))
78
+
79
+ # Generate next TAG ID
80
+ tag_id = generate_doc_tag(domain, existing_ids)
81
+
82
+ return TagSuggestion(
83
+ tag_id=tag_id,
84
+ chain_ref=chain_ref,
85
+ confidence=confidence,
86
+ domain=domain,
87
+ file_path=doc_path,
88
+ )
89
+
90
+
91
+ def _infer_domain_from_path(doc_path: Path) -> str:
92
+ """Infer domain from file path.
93
+
94
+ Args:
95
+ doc_path: Path to documentation file
96
+
97
+ Returns:
98
+ Inferred domain (uppercase)
99
+
100
+ Examples:
101
+ >>> _infer_domain_from_path(Path("docs/auth/guide.md"))
102
+ 'AUTH'
103
+ >>> _infer_domain_from_path(Path("docs/cli-tool/commands.md"))
104
+ 'CLI-TOOL'
105
+ """
106
+ path_parts = doc_path.parts
107
+ if len(path_parts) < 2:
108
+ return "DOC"
109
+
110
+ # Get first directory under 'docs/' as domain
111
+ domain = path_parts[1] if path_parts[0] == "docs" else path_parts[0]
112
+ return domain.upper().replace("_", "-")
113
+
114
+
115
+ def validate_tag_chain(tag_id: str, chain_ref: str) -> bool:
116
+ """Validate TAG chain reference consistency.
117
+
118
+ Checks that TAG domain matches SPEC domain in chain reference.
119
+
120
+ Args:
121
+ tag_id: TAG ID (e.g., "@DOC:AUTH-001")
122
+ chain_ref: Chain reference (e.g., "@SPEC:AUTH-004 -> @DOC:AUTH-001")
123
+
124
+ Returns:
125
+ True if chain is valid
126
+
127
+ Examples:
128
+ >>> validate_tag_chain("@DOC:AUTH-001", "@SPEC:AUTH-004 -> @DOC:AUTH-001")
129
+ True
130
+ >>> validate_tag_chain("@DOC:AUTH-001", "@SPEC:API-001 -> @DOC:AUTH-001")
131
+ False
132
+ """
133
+ # Check if chain contains TAG ID
134
+ if tag_id not in chain_ref:
135
+ return False
136
+
137
+ # Extract TAG domain (e.g., "@DOC:AUTH-001" -> "AUTH")
138
+ tag_domain = tag_id.split(":")[1].rsplit("-", 1)[0]
139
+
140
+ # Extract SPEC part from chain (e.g., "@SPEC:AUTH-004" or "@SPEC:API-001")
141
+ import re
142
+ spec_match = re.search(r"@SPEC:([A-Z0-9-]+)-\d{3}", chain_ref)
143
+ if not spec_match:
144
+ return False
145
+
146
+ spec_domain = spec_match.group(1)
147
+
148
+ # Domains must match
149
+ return spec_domain == tag_domain