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
@@ -1,33 +1,33 @@
1
1
  ---
2
2
  name: alfred:3-sync
3
- description: Document synchronization + PR Ready conversion
4
- argument-hint: "Mode target path - Mode: auto (default)|force|status|project, target path: Synchronization target path"
3
+ description: "Synchronize documentation and finalize PR"
4
+ argument-hint: 'Mode target path - Mode: auto (default)|force|status|project, target
5
+ path: Synchronization target path'
5
6
  allowed-tools:
6
- - Read
7
- - Write
8
- - Edit
9
- - MultiEdit
10
- - Bash(git:*)
11
- - Bash(gh:*)
12
- - Bash(python3:*)
13
- - Task
14
- - Grep
15
- - Glob
16
- - TodoWrite
7
+ - Read
8
+ - Write
9
+ - Edit
10
+ - MultiEdit
11
+ - Bash(git:*)
12
+ - Bash(gh:*)
13
+ - Bash(python3:*)
14
+ - Task
15
+ - Grep
16
+ - Glob
17
+ - TodoWrite
17
18
  ---
18
19
 
19
20
  # 📚 MoAI-ADK Step 3: Document Synchronization (+Optional PR Ready)
20
- > Interactive prompts rely on `Skill("moai-alfred-tui-survey")` so AskUserQuestion renders TUI selection menus for user surveys and approvals.
21
21
 
22
- ## 🚀 START HERE
22
+ > **Note**: Interactive prompts use `AskUserQuestion tool (documented in moai-alfred-ask-user-questions skill)` for TUI selection menus. The skill is loaded on-demand when user interaction is required.
23
+ >
24
+ > **Batched Design**: All AskUserQuestion calls follow batched design principles (1-4 questions per call) to minimize user interaction turns. See CLAUDE.md section "Alfred Command Completion Pattern" for details.
23
25
 
24
- **CRITICAL**: Load the TUI Survey Skill FIRST before any user interaction:
26
+ <!-- @CODE:ALF-WORKFLOW-003:CMD-SYNC -->
25
27
 
26
- ```
27
- Skill("moai-alfred-tui-survey")
28
- ```
28
+ **4-Step Workflow Integration**: This command implements Step 4 of Alfred's workflow (Report & Commit with conditional report generation). See CLAUDE.md for full workflow details.
29
29
 
30
- This Skill MUST be loaded at the very beginning to enable TUI menu rendering for AskUserQuestion calls throughout this workflow.
30
+ ---
31
31
 
32
32
  ## 🎯 Command Purpose
33
33
 
@@ -35,29 +35,35 @@ Synchronize code changes to Living Documents and verify @TAG system to ensure co
35
35
 
36
36
  **Document sync to**: $ARGUMENTS
37
37
 
38
- > **Standard two-step workflow** (see `CLAUDE.md` - "Alfred Command Execution Pattern" for details)
38
+ > **Standard workflow**: STEP 1 (Analysis & Planning) User Approval STEP 2 (Document Sync) → STEP 3 (Git Commit & PR)
39
+
40
+ ---
41
+
42
+ ## 📋 Execution Modes
39
43
 
40
- ## 📋 Execution flow
44
+ This command supports **4 operational modes**:
41
45
 
42
- **Phase 0: Skill Loading** (IMMEDIATE)
43
- - Load `Skill("moai-alfred-tui-survey")` at the very start
44
- - This enables TUI menu rendering for all user interactions
46
+ | Mode | Scope | PR Processing | Use Case |
47
+ |------|-------|---------------|----------|
48
+ | **auto** (default) | Smart selective sync | PR Ready conversion | Daily development workflow |
49
+ | **force** | Full project re-sync | Full regeneration | Error recovery, major refactoring |
50
+ | **status** | Status check only | Report only | Quick health check |
51
+ | **project** | Integrated project-wide | Project-level updates | Milestone completion, periodic sync |
45
52
 
46
- **Phase 1: Analysis & Planning**
47
- 1. **Project status analysis**: Git changes and TAG system verification
48
- 2. **Determine the scope of synchronization**: Full/partial/selective synchronization strategy
49
- 3. **User Confirmation**: Review and approve synchronization plan via AskUserQuestion (TUI menu)
53
+ **Command usage examples**:
54
+ - `/alfred:3-sync` Auto-sync (PR Ready only)
55
+ - `/alfred:3-sync --auto-merge` PR auto-merge + branch cleanup
56
+ - `/alfred:3-sync force` Force full synchronization
57
+ - `/alfred:3-sync status` → Check synchronization status
58
+ - `/alfred:3-sync project` → Integrated project synchronization
59
+ - `/alfred:3-sync auto src/auth/` → Specific path synchronization
50
60
 
51
- **Phase 2: Conditional Execution** (based on user choice)
52
- 4. **Document Synchronization**: Living Document updates and TAG integrity guaranteed (IF user selects "Proceed")
53
- 5. **Git operations**: Commit and PR state transitions via git-manager (IF user selects "Proceed")
54
- - OR abort workflow (IF user selects "Abort")
55
- - OR revise plan (IF user selects "Modify")
61
+ ---
56
62
 
57
63
  ## 🧠 Associated Skills & Agents
58
64
 
59
65
  | Agent | Core Skill | Purpose |
60
- | ----- | -------- | ------- |
66
+ | ------------ | ------------------------------ | ------------------------------ |
61
67
  | tag-agent | `moai-alfred-tag-scanning` | Verify TAG system integrity |
62
68
  | quality-gate | `moai-alfred-trust-validation` | Check code quality before sync |
63
69
  | doc-syncer | `moai-alfred-tag-scanning` | Synchronize Living Documents |
@@ -65,521 +71,2026 @@ Synchronize code changes to Living Documents and verify @TAG system to ensure co
65
71
 
66
72
  **Note**: TUI Survey Skill is loaded once at Phase 0 and reused throughout all user interactions.
67
73
 
68
- ## 🔗 Associated Agent
74
+ ---
69
75
 
70
- - **Phase 1**: quality-gate (🛡️ Quality Assurance Engineer) - Quality verification before synchronization (conditional)
71
- - **Primary**: doc-syncer (📖 Technical Writer) - Dedicated to document synchronization
72
- - **Secondary**: git-manager (🚀 Release Engineer) - Dedicated to Git commits/PR
76
+ ## 🚀 OVERALL WORKFLOW STRUCTURE
73
77
 
74
- ## 💡 Example of use
78
+ ```
79
+ ┌──────────────────────────────────────────────────────────┐
80
+ │ STEP 0: Load Skills (IMMEDIATE) │
81
+ │ → Load moai-alfred-ask-user-questions Skill │
82
+ │ → Enable TUI menu rendering │
83
+ └──────────────────────────────────────────────────────────┘
84
+
85
+ ┌──────────────────────────────────────────────────────────┐
86
+ │ STEP 1: Analysis & Planning │
87
+ │ STEP 1.1: Verify prerequisites │
88
+ │ STEP 1.2: Analyze project status (Git + TAG) │
89
+ │ STEP 1.3: Determine sync scope (mode-specific) │
90
+ │ STEP 1.4: (Optional) TAG chain navigation │
91
+ │ STEP 1.5: Create synchronization plan │
92
+ │ STEP 1.6: Request user approval (AskUserQuestion) │
93
+ └──────────────────────────────────────────────────────────┘
94
+
95
+ ┌───────────────┴───────────────┐
96
+ │ │
97
+ User chooses User chooses
98
+ "Proceed" "Abort/Modify"
99
+ │ │
100
+ ↓ ↓
101
+ ┌─────────────────────────┐ ┌──────────────────────┐
102
+ │ STEP 2: Execute Sync │ │ STEP 4: Graceful Exit│
103
+ │ STEP 2.1: Safety backup│ │ → Display abort msg │
104
+ │ STEP 2.2: Living Doc │ │ → OR re-analyze │
105
+ │ STEP 2.3: TAG update │ └──────────────────────┘
106
+ │ STEP 2.4: SPEC sync │
107
+ │ STEP 2.5: Domain sync │
108
+ │ STEP 2.6: Completion │
109
+ └─────────────────────────┘
110
+
111
+ ┌──────────────────────────────────────────────────────────┐
112
+ │ STEP 3: Git Operations & PR │
113
+ │ STEP 3.1: Commit document changes (git-manager) │
114
+ │ STEP 3.2: (Optional) PR Ready transition │
115
+ │ STEP 3.3: (Optional) PR auto-merge (--auto-merge flag) │
116
+ │ STEP 3.4: (Optional) Branch cleanup │
117
+ │ STEP 3.5: Display completion report │
118
+ └──────────────────────────────────────────────────────────┘
119
+ ```
75
120
 
76
- Users can run the command as follows:
77
- - `/alfred:3-sync` - Auto-sync (PR Ready only)
78
- - `/alfred:3-sync --auto-merge` - PR auto-merge + branch cleanup
79
- - `/alfred:3-sync force` - Force full synchronization
80
- - `/alfred:3-sync status` - Check synchronization status
81
- - `/alfred:3-sync project` - Integrated project synchronization
121
+ ---
82
122
 
83
- ### 🚀 Fully automated GitFlow (--auto-merge)
123
+ ## 🔧 STEP 0: Load Skills (IMMEDIATE)
84
124
 
85
- **Automatically performs the following actions when used in Team mode**:
86
- 1. Document synchronization complete
87
- 2. Switch to PR Ready
88
- 3. Check CI/CD status
89
- 4. PR automatic merge (squash)
90
- 5. Develop checkout and synchronization
91
- 6. Organizing local feature branches
92
- 7. **Ready for next task** ✅
125
+ **Your task**: Load the TUI Survey Skill at the very beginning to enable interactive menus.
93
126
 
94
- **Recommended use time**: When you want to complete the merge in one go after completing TDD implementation.
127
+ **Steps**:
95
128
 
96
- **Personal mode**: Automate local main/develop merges and branch cleanups
129
+ 1. **Load the skill immediately**:
130
+ ```
131
+ Invoke Skill: moai-alfred-ask-user-questions
132
+ ```
97
133
 
98
- ## 🔍 STEP 1: Analyze synchronization scope and establish plan
134
+ 2. **Why this matters**:
135
+ - This skill provides TUI menu rendering capabilities
136
+ - Must be loaded BEFORE any user interaction
137
+ - Used in STEP 1.6, STEP 2.6, and STEP 3.5
99
138
 
100
- Analyze project status to determine synchronization scope, develop a systematic synchronization plan, and receive user confirmation.
139
+ **Result**: TUI menu system ready for all subsequent user interactions.
101
140
 
102
- **The doc-syncer agent automatically scans the TAG chain and identifies and analyzes Git changes.**
141
+ **Next step**: Go to STEP 1.1
103
142
 
104
- ### 🔍 TAG chain navigation (optional)
143
+ ---
105
144
 
106
- **If your TAG chain is complex or extensive**, utilize the Explore agent first:
145
+ ## 📊 STEP 1: Analysis & Planning
107
146
 
108
- ```
109
- Invoking the Task tool (Explore agent):
110
- - subagent_type: "Explore"
111
- - description: "Scan entire TAG system"
112
- - prompt: "Please scan @TAG system throughout the project:
113
- - @SPEC TAG location (.moai/specs/)
114
- - @TEST TAG location (tests/)
115
- - @CODE TAG location (src/)
116
- - @DOC TAG location (docs/)
117
- - Detect orphan TAGs and broken references
118
- Thoroughness level: very thorough"
119
- ```
147
+ ### STEP 1.1: Verify Prerequisites
120
148
 
121
- **Explore Agent When to Use**:
122
- - ✅ Large projects (100+ files)
123
- - ✅ When TAG chain integrity verification is required
124
- - ✅ Changes across multiple SPECs
125
- - ❌ Simple changes to a single SPEC
149
+ **Your task**: Check that all required components exist before starting synchronization analysis.
126
150
 
127
- ### ⚙️ How to call an agent
151
+ **Steps**:
128
152
 
129
- **In STEP 1, call doc-syncer and tag-agent using the Task tool**:
153
+ 1. **Check MoAI-ADK project structure**:
154
+ - Directory to check: `.moai/` and `.claude/`
155
+ - IF `.moai/` does NOT exist → Print error and exit:
156
+ ```
157
+ ❌ Error: Not a MoAI-ADK project
130
158
 
131
- ```
132
- 1. Tag-agent call (TAG verification):
133
- - subagent_type: "tag-agent"
134
- - description: "Verify TAG system"
135
- - prompt: "Please verify the integrity of the entire TAG chain.
136
- Please verify the integrity of @SPEC, @TEST, @CODE, @DOC TAGs
137
- and orphan TAGs.
138
- (Optional) Explore results: $EXPLORE_RESULTS"
139
-
140
- 2. doc-syncer call (synchronization plan):
141
- - subagent_type: "doc-syncer"
142
- - description: "Establish a document synchronization plan"
143
- - prompt: "Please analyze Git changes and establish a document synchronization plan.
144
- $ARGUMENTS
145
- (Optional) TAG validation results: $TAG_VALIDATION_RESULTS"
146
- ```
159
+ This command requires MoAI-ADK structure:
160
+ - .moai/config.json (project configuration)
161
+ - .moai/specs/ (SPEC documents)
162
+ - .claude/ (Claude Code configuration)
147
163
 
148
- ### Synchronization analysis in progress
164
+ Run `/alfred:0-project init` to initialize a project.
165
+ ```
149
166
 
150
- 1. **Check project status**
151
- - Git status and changed file list
152
- - Code-document consistency check
153
- - @TAG system verification (using tag-agent or Explore)
154
- - (Optional) Extensive TAG scan based on Explore results
167
+ 2. **Check Git repository status**:
168
+ - Execute: `git rev-parse --is-inside-work-tree`
169
+ - IF NOT a Git repository → Print error and exit:
170
+ ```
171
+ Error: Not a Git repository
155
172
 
156
- 2. **Determine the scope of synchronization**
157
- - Living Document area requiring update
158
- - TAG index need to be updated
159
- - PR status transition possibility (team mode)
173
+ This command requires Git version control.
174
+ Initialize with: git init
175
+ ```
160
176
 
161
- 3. **Establish a synchronization strategy**
162
- - Synchronization approach for each mode
163
- - Estimated work time and priorities
164
- - Identify potential risks
177
+ 3. **Verify Python environment** (for TAG verification):
178
+ - Execute: `which python3`
179
+ - IF python3 NOT found → Print warning (non-fatal):
180
+ ```
181
+ ⚠️ Warning: Python3 not found
165
182
 
166
- ### Phase 1 Details: Quality pre-verification (conditional automatic execution)
183
+ TAG verification scripts may not run.
184
+ Synchronization will continue with limited TAG checks.
185
+ ```
167
186
 
168
- Quickly check code quality before synchronization.
187
+ 4. **Print prerequisites status**:
188
+ ```
189
+ ✅ Prerequisites verified:
190
+ - MoAI-ADK structure: OK
191
+ - Git repository: OK
192
+ - Python environment: OK (or WARNING)
193
+ ```
169
194
 
170
- **Differences from Phase 3 (2-build)**:
171
- - **Phase 3**: In-depth verification after completion of TDD implementation (test coverage, code quality, security)
172
- - **Phase 1**: Quick scan before synchronization (file corruption, critical issues only)
195
+ **Result**: All prerequisites validated. Ready for analysis.
173
196
 
174
- **Purpose**: Prevent documentation of code with quality issues
197
+ **Next step**: Go to STEP 1.2
175
198
 
176
- **Execution conditions (automatic judgment)**:
177
- - Check the number of code change lines with Git diff
178
- - Changed lines > 50 lines: Automatically run
179
- - Changed lines ≤ 50 lines: Skip
180
- - Change only document: Skip
199
+ ---
200
+
201
+ ### STEP 1.2: Analyze Project Status
202
+
203
+ **Your task**: Gather Git changes and project metadata to determine synchronization scope.
204
+
205
+ **Steps**:
206
+
207
+ 1. **Check Git status**:
208
+ - Execute: `git status --porcelain`
209
+ - Store result in variable: `$GIT_STATUS`
210
+
211
+ 2. **Get list of changed files**:
212
+ - Execute: `git diff --name-only HEAD`
213
+ - Store result in variable: `$CHANGED_FILES`
214
+
215
+ 3. **Count changes by type**:
216
+ - Python files changed: Count files matching `*.py` in `$CHANGED_FILES`
217
+ - Test files changed: Count files in `tests/` directory
218
+ - Document files changed: Count files matching `*.md` in `$CHANGED_FILES`
219
+ - SPEC files changed: Count files in `.moai/specs/` directory
220
+
221
+ 4. **Read project configuration**:
222
+ - Read file: `.moai/config.json`
223
+ - Extract values:
224
+ - `git_strategy.mode` → Store as `$PROJECT_MODE` (Personal/Team)
225
+ - `git_strategy.spec_git_workflow` → Store as `$WORKFLOW` (feature_branch/develop_direct)
226
+ - `language.conversation_language` → Store as `$LANG`
181
227
 
182
- **Verification items**:
183
- - **Verify only changed files**: File targets verified by Git diff
184
- - **TRUST principle verification**: Run trust-checker script
185
- - **Code style**: Run linter (changed files only)
186
- - **TAG chain**: Verify changed TAG integrity
228
+ 5. **Determine if changes are code-heavy or document-heavy**:
229
+ - IF Python files changed > 50 lines `$CHANGE_TYPE = "code-heavy"`
230
+ - ELSE IF document files changed > 10 lines → `$CHANGE_TYPE = "doc-heavy"`
231
+ - ELSE `$CHANGE_TYPE = "mixed"`
187
232
 
188
- **How ​​it works**:
189
- Alfred automatically calls the quality-gate agent when there are a lot of code changes to perform quick quality verification before document synchronization.
233
+ 6. **Print analysis summary**:
234
+ ```
235
+ 📊 Project Status Analysis
190
236
 
191
- **Handling verification results**:
237
+ Git Status:
238
+ - Changed files: [count from $CHANGED_FILES]
239
+ - Python files: [count]
240
+ - Test files: [count]
241
+ - Documents: [count]
242
+ - SPEC files: [count]
192
243
 
193
- **PASS (0 Critical)**: Synchronization in progress
244
+ Project Configuration:
245
+ - Mode: $PROJECT_MODE (Personal/Team)
246
+ - Workflow: $WORKFLOW
247
+ - Language: $LANG
248
+ - Change type: $CHANGE_TYPE
249
+ ```
194
250
 
195
- ⚠️ **WARNING (0 Critical, Warning included)**: Synchronization proceeds after displaying warning.
251
+ **Result**: Project status analyzed and stored in variables.
196
252
 
197
- **CRITICAL (1 or more Critical)**: Synchronization stopped, correction recommended
198
- - Critical issue found: Synchronization stopped, correction recommended
199
- - User selection: “Retry after modification” or “Force proceed”
253
+ **Next step**: Go to STEP 1.3
200
254
 
201
- **Skip verification option**:
202
- To skip pre-verification, use the `/alfred:3-sync --skip-pre-check` option.
255
+ ---
256
+
257
+ ### STEP 1.3: Determine Sync Scope (Mode-Specific)
258
+
259
+ **Your task**: Determine which files and documents need synchronization based on the selected mode.
260
+
261
+ **Steps**:
262
+
263
+ 1. **Read mode from $ARGUMENTS**:
264
+ - Parse first argument: `$1` → Store as `$MODE`
265
+ - IF `$MODE` is empty → Set `$MODE = "auto"`
266
+ - Valid modes: `auto`, `force`, `status`, `project`
267
+
268
+ 2. **IF mode is "status"**:
269
+ - **Your task**: Perform quick status check only (no synchronization)
270
+ - Execute: `python3 .moai/scripts/tag_scanner.py --status-only`
271
+ - Read file: `.moai/reports/sync-report-latest.md` (if exists)
272
+ - Print status:
273
+ ```
274
+ 📊 Synchronization Status
275
+
276
+ Last sync: [date from sync-report-latest.md]
277
+
278
+ TAG System Health:
279
+ - @SPEC TAGs: [count] found
280
+ - @CODE TAGs: [count] found
281
+ - @TEST TAGs: [count] found
282
+ - @DOC TAGs: [count] found
283
+ - Orphan TAGs: [count] (if any)
284
+
285
+ Git Status:
286
+ - Changed files since last sync: [count]
287
+ - Uncommitted changes: [yes/no]
288
+
289
+ Recommendation: [Sync needed / Up to date]
290
+ ```
291
+ - **STOP HERE** → Exit command (status mode complete)
292
+
293
+ 3. **IF mode is "force"**:
294
+ - **Your task**: Force full re-synchronization of all documents
295
+ - Set scope variables:
296
+ - `$SYNC_SCOPE = "full"`
297
+ - `$TARGET_DIRS = "src/ tests/ docs/ .moai/specs/"`
298
+ - `$REGENERATE_ALL = true`
299
+ - Print:
300
+ ```
301
+ 🔄 Force Mode Activated
302
+
303
+ Synchronization scope: FULL PROJECT
304
+ - All source files will be scanned
305
+ - All documents will be regenerated
306
+ - All TAG chains will be re-verified
307
+ ```
308
+
309
+ 4. **IF mode is "project"**:
310
+ - **Your task**: Project-wide integrated synchronization
311
+ - Set scope variables:
312
+ - `$SYNC_SCOPE = "project"`
313
+ - `$TARGET_DIRS = "src/ tests/ docs/ .moai/specs/ README.md"`
314
+ - `$UPDATE_PROJECT_DOCS = true`
315
+ - Print:
316
+ ```
317
+ 🏢 Project Mode Activated
318
+
319
+ Synchronization scope: INTEGRATED PROJECT
320
+ - README.md will be updated (full feature list)
321
+ - docs/architecture.md will be updated
322
+ - docs/api/ will be unified
323
+ - .moai/indexes/ will be rebuilt
324
+ ```
325
+
326
+ 5. **IF mode is "auto"** (default):
327
+ - **Your task**: Smart selective synchronization based on Git changes
328
+ - Set scope variables:
329
+ - `$SYNC_SCOPE = "selective"`
330
+ - `$TARGET_DIRS = [directories from $CHANGED_FILES]`
331
+ - `$UPDATE_PROJECT_DOCS = false`
332
+ - Determine selective scope:
333
+ - IF `$CHANGE_TYPE = "code-heavy"` → Include `src/`, `tests/`, related SPEC
334
+ - IF `$CHANGE_TYPE = "doc-heavy"` → Include `docs/`, `.moai/specs/`
335
+ - IF `$CHANGE_TYPE = "mixed"` → Include all changed directories
336
+ - Print:
337
+ ```
338
+ 🎯 Auto Mode Activated
339
+
340
+ Synchronization scope: SELECTIVE
341
+ - Target directories: $TARGET_DIRS
342
+ - Changed files: [count]
343
+ - Estimated sync time: [based on change count]
344
+ ```
345
+
346
+ 6. **Parse additional flags from $ARGUMENTS**:
347
+ - Search for `--auto-merge` flag → Set `$AUTO_MERGE = true` (default: false)
348
+ - Search for `--skip-pre-check` flag → Set `$SKIP_PRE_CHECK = true` (default: false)
349
+ - Search for `--skip-quality-check` flag → Set `$SKIP_QUALITY_CHECK = true` (default: false)
350
+
351
+ **Result**: Synchronization scope determined and stored in variables.
352
+
353
+ **Next step**:
354
+ - IF mode was "status" → EXIT (already completed)
355
+ - ELSE → Go to STEP 1.4
203
356
 
204
357
  ---
205
358
 
206
- ### User verification steps
359
+ ### STEP 1.4: (Optional) TAG Chain Navigation
360
+
361
+ **Your task**: Optionally perform comprehensive TAG chain exploration for large projects.
362
+
363
+ **Decision point**:
364
+
365
+ 1. **Determine if TAG exploration is needed**:
366
+ - IF `$MODE = "force"` OR `$MODE = "project"` → TAG exploration REQUIRED
367
+ - ELSE IF changed files > 100 → TAG exploration RECOMMENDED
368
+ - ELSE IF `$SYNC_SCOPE = "selective"` → SKIP exploration (go to STEP 1.5)
369
+
370
+ 2. **IF TAG exploration is REQUIRED or RECOMMENDED**:
371
+ - Print:
372
+ ```
373
+ 🔍 TAG Chain Navigation
374
+
375
+ Performing comprehensive TAG system scan...
376
+ This may take a few moments for large projects.
377
+ ```
378
+
379
+ 3. **Invoke Explore agent for TAG scanning**:
380
+ - **Your task**: Call the Explore agent to scan entire TAG system
381
+ - Use Task tool:
382
+ - `subagent_type`: "Explore"
383
+ - `description`: "Scan entire TAG system across project"
384
+ - `prompt`:
385
+ ```
386
+ Please scan the entire @TAG system across the project:
387
+
388
+ Scan scope:
389
+ - @SPEC TAG locations (.moai/specs/)
390
+ - @TEST TAG locations (tests/)
391
+ - @CODE TAG locations (src/)
392
+ - @DOC TAG locations (docs/)
393
+
394
+ Validation items:
395
+ - Detect orphan TAGs
396
+ - Detect broken references
397
+ - Detect duplicate TAGs
398
+
399
+ Thoroughness level: very thorough
400
+
401
+ Output format:
402
+ - Complete TAG inventory list
403
+ - List of problematic TAGs (with locations)
404
+ - Recommended fixes
405
+ ```
406
+
407
+ 4. **Store Explore agent results**:
408
+ - Read response from Explore agent
409
+ - Store in variable: `$EXPLORE_RESULTS`
410
+ - Print summary:
411
+ ```
412
+ ✅ TAG exploration complete
413
+
414
+ TAG inventory:
415
+ - @SPEC TAGs found: [count]
416
+ - @CODE TAGs found: [count]
417
+ - @TEST TAGs found: [count]
418
+ - @DOC TAGs found: [count]
419
+
420
+ Issues detected:
421
+ - Orphan TAGs: [count]
422
+ - Broken references: [count]
423
+ - Duplicate TAGs: [count]
424
+ ```
425
+
426
+ 5. **IF TAG exploration was SKIPPED**:
427
+ - Set `$EXPLORE_RESULTS = null`
428
+ - Print:
429
+ ```
430
+ ⏩ TAG exploration skipped (not needed for selective sync)
431
+ ```
432
+
433
+ **Result**: TAG chain exploration completed (or skipped). Results stored in `$EXPLORE_RESULTS`.
434
+
435
+ **Next step**: Go to STEP 1.5
436
+
437
+ ---
207
438
 
208
- After reviewing your sync plan, `Skill("moai-alfred-tui-survey")` presents the following options for user decision:
209
- - **"Proceed"** or **"Start"**: Start synchronization as planned
210
- - **"Modify [Contents]"**: Request modifications to your sync plan
211
- - **"Abort"**: Abort the sync operation
439
+ ### STEP 1.5: Create Synchronization Plan
440
+
441
+ **Your task**: Call tag-agent and doc-syncer to verify TAG integrity and establish a detailed synchronization plan.
442
+
443
+ **This phase runs TWO agents sequentially**:
444
+
445
+ 1. **Tag-agent call (TAG verification across ENTIRE PROJECT)**:
446
+
447
+ - **Your task**: Invoke tag-agent to verify TAG system integrity
448
+ - Use Task tool:
449
+ - `subagent_type`: "tag-agent"
450
+ - `description`: "Verify TAG system across entire project"
451
+ - `prompt`:
452
+ ```
453
+ Please perform comprehensive @TAG system verification across the entire project.
454
+
455
+ **Required Scope**: Scan ALL source files, not just changed files.
456
+
457
+ **Verification Items**:
458
+ 1. @SPEC TAGs in .moai/specs/ directory
459
+ 2. @TEST TAGs in tests/ directory
460
+ 3. @CODE TAGs in src/ directory
461
+ 4. @DOC TAGs in docs/ directory
462
+
463
+ **Orphan Detection** (Required):
464
+ - Detect @CODE TAGs with no matching @SPEC
465
+ - Detect @SPEC TAGs with no matching @CODE
466
+ - Detect @TEST TAGs with no matching @SPEC
467
+ - Detect @DOC TAGs with no matching @SPEC/@CODE
468
+
469
+ **Output Format**:
470
+ - Provide complete list of orphan TAGs with locations
471
+ - TAG chain integrity assessment (Healthy / Issues Detected)
472
+
473
+ (Optional) Exploration results: $EXPLORE_RESULTS
474
+ ```
475
+
476
+ - **Wait for tag-agent response**
477
+ - Store response in variable: `$TAG_VALIDATION_RESULTS`
478
+ - Print summary:
479
+ ```
480
+ ✅ TAG verification complete
481
+
482
+ TAG chain integrity: [Healthy / Issues Detected]
483
+
484
+ Issues found (if any):
485
+ - Orphan @CODE TAGs: [list]
486
+ - Orphan @SPEC TAGs: [list]
487
+ - Broken references: [list]
488
+ ```
489
+
490
+ 2. **Doc-syncer call (synchronization plan establishment)**:
491
+
492
+ - **Your task**: Invoke doc-syncer to analyze Git changes and create sync plan
493
+ - Use Task tool:
494
+ - `subagent_type`: "doc-syncer"
495
+ - `description`: "Establish a document synchronization plan"
496
+ - `prompt`:
497
+ ```
498
+ You are the doc-syncer agent.
499
+
500
+ Language settings:
501
+ - conversation_language: $LANG
502
+ - language_name: [Korean/English/Japanese based on $LANG]
503
+
504
+ Important instructions:
505
+ Document updates must respect the conversation language:
506
+ - User-facing docs (README, guides): $LANG
507
+ - SPEC documents (spec.md, plan.md, acceptance.md): $LANG
508
+ - Code comments: $LANG (except technical keywords)
509
+ - Technical docs and YAML frontmatter: English
510
+
511
+ Skill invocations:
512
+ Use explicit Skill() calls as needed:
513
+ - Skill("moai-foundation-tags") - TAG chain validation
514
+ - Skill("moai-foundation-trust") - Quality gate inspection
515
+ - Skill("moai-alfred-tag-scanning") - TAG inventory update
516
+
517
+ Tasks:
518
+ Analyze Git changes and establish document synchronization plan.
519
+ Ensure all document updates align with conversation language settings.
520
+
521
+ Synchronization mode: $MODE
522
+ Synchronization scope: $SYNC_SCOPE
523
+ Target directories: $TARGET_DIRS
524
+ Changed files: $CHANGED_FILES
525
+
526
+ (Required) TAG verification results: $TAG_VALIDATION_RESULTS
527
+ (Optional) Exploration results: $EXPLORE_RESULTS
528
+ ```
529
+
530
+ - **Wait for doc-syncer response**
531
+ - Store response in variable: `$SYNC_PLAN`
532
+ - Print summary:
533
+ ```
534
+ 📋 Synchronization Plan Created
535
+
536
+ Documents to update:
537
+ - Living Documents: [list]
538
+ - SPEC documents: [list]
539
+ - TAG indexes: [list]
540
+
541
+ Estimated work:
542
+ - Files to update: [count]
543
+ - New files to create: [count]
544
+ - TAG repairs needed: [count]
545
+ - Estimated time: [based on change count]
546
+ ```
547
+
548
+ **Result**: TAG validation results and synchronization plan stored in variables.
549
+
550
+ **Next step**: Go to STEP 1.6
212
551
 
213
552
  ---
214
553
 
215
- ## 🚀 STEP 2: Execute document synchronization (after user approval)
554
+ ### STEP 1.6: Request User Approval
555
+
556
+ **Your task**: Present the synchronization plan to the user and request approval to proceed.
557
+
558
+ **Steps**:
559
+
560
+ 1. **Display comprehensive plan report**:
561
+ ```
562
+ ═══════════════════════════════════════════════════════
563
+ 📚 Document Synchronization Plan Report
564
+ ═══════════════════════════════════════════════════════
565
+
566
+ 📊 Project Analysis:
567
+ - Mode: $MODE
568
+ - Scope: $SYNC_SCOPE
569
+ - Changed files: [count from $CHANGED_FILES]
570
+ - Project mode: $PROJECT_MODE (Personal/Team)
571
+
572
+ 🎯 Synchronization Strategy:
573
+ - Living Documents to update: [list from $SYNC_PLAN]
574
+ - SPEC documents to sync: [list]
575
+ - TAG repairs needed: [count from $TAG_VALIDATION_RESULTS]
576
+ - Domain-specific sync: [if applicable]
577
+
578
+ ⚠️ TAG System Status:
579
+ - TAG chain integrity: [Healthy / Issues Detected]
580
+ - Orphan TAGs: [count]
581
+ - Broken references: [count]
582
+
583
+ ✅ Expected Deliverables:
584
+ - sync-report.md: Summary of synchronization results
585
+ - tags.db: Updated TAG index
586
+ - Living Documents: [list]
587
+ - PR Status: [if Team mode: Draft → Ready transition]
588
+
589
+ ═══════════════════════════════════════════════════════
590
+ ```
591
+
592
+ 2. **Ask user for approval using AskUserQuestion**:
593
+ - **Your task**: Use the AskUserQuestion tool to gather user decision
594
+ - Tool call:
595
+ - `questions`: Array with 1 question
596
+ - Question details:
597
+ - `question`: "Synchronization plan is ready. How would you like to proceed?"
598
+ - `header`: "Plan Approval"
599
+ - `multiSelect`: false
600
+ - `options`: Array with 4 choices:
601
+ 1. Label: "✅ Proceed with Sync", Description: "Execute document synchronization as planned"
602
+ 2. Label: "🔄 Request Modifications", Description: "Specify changes to the synchronization strategy"
603
+ 3. Label: "🔍 Review Details", Description: "Re-examine TAG validation results and changes"
604
+ 4. Label: "❌ Abort", Description: "Cancel synchronization, keep current state"
605
+
606
+ 3. **Wait for user response**:
607
+ - Store response in variable: `$USER_DECISION`
608
+ - Read value from: `$USER_DECISION["0"]` (first question answer)
609
+
610
+ 4. **Process user response**:
611
+
612
+ **IF user chose "✅ Proceed with Sync"**:
613
+ - Print:
614
+ ```
615
+ ✅ User approved synchronization plan
616
+
617
+ Proceeding to document synchronization...
618
+ ```
619
+ - **Next step**: Go to STEP 2.1
620
+
621
+ **IF user chose "🔄 Request Modifications"**:
622
+ - Print:
623
+ ```
624
+ 🔄 User requested modifications to plan
625
+
626
+ Please specify what changes you'd like to the synchronization strategy:
627
+ ```
628
+ - Wait for user input (freeform text)
629
+ - Store input in variable: `$MODIFICATION_REQUEST`
630
+ - Print:
631
+ ```
632
+ Re-analyzing with requested modifications...
633
+ ```
634
+ - **Next step**: Go back to STEP 1.5 (re-create plan with modifications)
635
+
636
+ **IF user chose "🔍 Review Details"**:
637
+ - Print detailed TAG validation results:
638
+ ```
639
+ 🔍 Detailed TAG Validation Results
640
+
641
+ $TAG_VALIDATION_RESULTS (full output)
642
+
643
+ Detailed synchronization plan:
644
+
645
+ $SYNC_PLAN (full output)
646
+ ```
647
+ - After displaying details, re-present the approval question
648
+ - **Next step**: Go back to STEP 1.6 (re-ask approval)
649
+
650
+ **IF user chose "❌ Abort"**:
651
+ - Print:
652
+ ```
653
+ ❌ Synchronization aborted by user
654
+
655
+ No changes were made to documents or Git history.
656
+ Current branch state maintained.
657
+ ```
658
+ - **Next step**: Go to STEP 4 (Graceful Exit)
659
+
660
+ **Result**: User decision captured. Command proceeds or exits based on choice.
661
+
662
+ **Next step**: Based on user decision (see above)
216
663
 
217
- After user approval (collected via `Skill("moai-alfred-tui-survey")`), the doc-syncer agent performs **Living Document synchronization and @TAG updates**, and optionally executes PR Ready transitions only in team mode.
664
+ ---
665
+
666
+ ## 🚀 STEP 2: Execute Document Synchronization
218
667
 
219
- ### Phase 2 Details: SPEC Completion Processing (Automatic)
668
+ ### STEP 2.1: Create Safety Backup
220
669
 
221
- The doc-syncer agent automatically determines whether TDD implementation is complete and updates SPEC metadata.
670
+ **Your task**: Create a safety backup of current document state before making any changes.
222
671
 
223
- **Automatic update conditions**:
224
- - SPEC with status `draft`
225
- - RED → GREEN → REFACTOR commit exists
226
- - @TEST and @CODE TAG exist
672
+ **Steps**:
227
673
 
228
- **Update details**:
229
- - `status: draft` → `status: completed`
230
- - `version: 0.0.x` → `version: 0.1.0`
231
- - Automatic addition of HISTORY section
674
+ 1. **Create backup directory with timestamp**:
675
+ - Generate timestamp: `date +%Y-%m-%d-%H%M%S` Store as `$TIMESTAMP`
676
+ - Create directory: `.moai-backups/sync-$TIMESTAMP/`
677
+ - Execute: `mkdir -p .moai-backups/sync-$TIMESTAMP/`
232
678
 
233
- **If conditions are not met**: Phase 2 detailed work is automatically skipped
679
+ 2. **Copy current documents to backup**:
680
+ - Copy README.md: `cp README.md .moai-backups/sync-$TIMESTAMP/` (if exists)
681
+ - Copy docs/: `cp -r docs/ .moai-backups/sync-$TIMESTAMP/` (if exists)
682
+ - Copy .moai/specs/: `cp -r .moai/specs/ .moai-backups/sync-$TIMESTAMP/`
683
+ - Copy .moai/indexes/: `cp -r .moai/indexes/ .moai-backups/sync-$TIMESTAMP/` (if exists)
234
684
 
235
- ## function
685
+ 3. **Verify backup creation**:
686
+ - Execute: `ls -la .moai-backups/sync-$TIMESTAMP/`
687
+ - IF backup directory is empty → Print error and exit:
688
+ ```
689
+ ❌ Error: Backup creation failed
236
690
 
237
- - **Automatic Document Synchronization**: The doc-syncer agent performs Living Document synchronization and @TAG updates. Optionally implements the PR Ready transition only in team mode.
691
+ Unable to create safety backup at:
692
+ .moai-backups/sync-$TIMESTAMP/
238
693
 
239
- ## Synchronization output
694
+ Synchronization aborted to prevent data loss.
695
+ ```
696
+ - ELSE → Print success:
697
+ ```
698
+ 💾 Safety backup created
240
699
 
241
- - `.moai/reports/sync-report.md` creation/update
242
- - TAG chain verification: Direct code scan (`rg '@TAG' -n src/ tests/`)
700
+ Backup location: .moai-backups/sync-$TIMESTAMP/
701
+ Files backed up: [count]
243
702
 
244
- ## Execution method by mode
703
+ You can restore from this backup if needed.
704
+ ```
245
705
 
246
- ## 📋 STEP 1 Implementation Guide: Analyzing the scope of synchronization and establishing a plan
706
+ **Result**: Safety backup created. Safe to proceed with document modifications.
247
707
 
248
- ### 1. Project status analysis
708
+ **Next step**: Go to STEP 2.2
249
709
 
250
- Alfred calls the doc-syncer agent to analyze synchronization targets and scopes.
710
+ ---
251
711
 
252
- #### Analysis Checklist
712
+ ### STEP 2.2: Synchronize Living Documents
253
713
 
254
- - [ ] **Git status**: Changed files, branch status, commit history
255
- - [ ] **Document consistency**: Need for code-to-document synchronization
256
- - [ ] **TAG system**: @TAG scheme verification and broken links
257
- - [ ] **Sync scope**: Full vs partial vs specific path synchronization
714
+ **Your task**: Call doc-syncer agent to perform Living Document synchronization and TAG updates.
258
715
 
259
- ### 2. Determine synchronization strategy
716
+ **Steps**:
260
717
 
261
- #### Mode-specific synchronization approach
718
+ 1. **Invoke doc-syncer agent for synchronization execution**:
719
+ - **Your task**: Call doc-syncer to execute the approved synchronization plan
720
+ - Use Task tool:
721
+ - `subagent_type`: "doc-syncer"
722
+ - `description`: "Execute Living Document synchronization"
723
+ - `prompt`:
724
+ ```
725
+ You are the doc-syncer agent.
262
726
 
263
- | mode | Synchronization range | PR processing | Key Features |
264
- | ------------ | ------------------------------- | ---------------------- | ---------------------- |
265
- | **Personal** | Local document synchronization | checkpoint only | Focus on personal work |
266
- | **Team** | Full Sync + TAG | PR Ready conversion | Collaboration support |
267
- | **Auto** | Intelligent automatic selection | Decisions by situation | Optimal strategy |
268
- | **Force** | Force full sync | Full regeneration | For error recovery |
727
+ Language settings:
728
+ - conversation_language: $LANG
269
729
 
270
- #### Expected scope of work
730
+ **Execute Approved Synchronization Plan**:
271
731
 
272
- - **Living Document**: API documentation, README, architecture document
273
- - **TAG index**: Update `.moai/indexes/tags.db`
274
- - **Sync report**: `.moai/reports/sync-report.md`
275
- - **PR status**: Draft Ready for Review transition
732
+ Previous analysis results:
733
+ - TAG verification results: $TAG_VALIDATION_RESULTS
734
+ - Synchronization plan: $SYNC_PLAN
735
+ - Exploration results: $EXPLORE_RESULTS (if available)
276
736
 
277
- ### 3. Generate synchronization plan report
737
+ **Task Instructions**:
278
738
 
279
- Present your plan in the following format:
739
+ 1. Living Document synchronization:
740
+ - Reflect changed code in documentation
741
+ - Auto-generate/update API documentation
742
+ - Update README (if needed)
743
+ - Synchronize Architecture documents
280
744
 
281
- ```
282
- ## Document Synchronization Plan Report: [TARGET]
745
+ 2. @TAG system updates:
746
+ - Update TAG index (.moai/indexes/tags.db)
747
+ - Repair orphan TAGs (if possible)
748
+ - Restore broken references
283
749
 
284
- ### 📊 Health Analysis Results
285
- - **Changed Files**: [Number and Type]
286
- - **Synchronization Required**: [High/Medium/Low]
287
- - **TAG System Status**: [Healthy/Problem Detected]
750
+ 3. Document-code consistency verification:
751
+ - Verify SPEC CODE synchronization
752
+ - Verify TEST ↔ CODE matching
753
+ - Verify DOC CODE references
288
754
 
289
- ### 🎯 Sync Strategy
290
- - **Selected Mode**: [auto/force/status/project]
291
- - **Sync Scope**: [Full/Partial/Selective]
292
- - **PR Handling**: [Maintain/Switch Ready/Create New PR]
755
+ 4. Generate synchronization report:
756
+ - File location: .moai/reports/sync-report-$TIMESTAMP.md
757
+ - Include content: Updated file list, TAG repair history, remaining issues
293
758
 
294
- ### ⚠️ Notes
295
- - **Potential conflicts**: [Possible document conflicts]
296
- - **TAG issues**: [Broken links, duplicate TAGs]
297
- - **Performance impact**: [Estimated time for large synchronization]
759
+ **Important**: Use conversation_language($LANG) for all document creation/modification.
298
760
 
299
- ### Expected deliverables
300
- - **sync-report.md**: [Summary of sync results]
301
- - **tags.db**: [Updated TAG index]
302
- - **Living Documents**: [Updated document list]
303
- - **PR Status**: [PR transition in team mode]
761
+ Execute the approved plan precisely and report results in detail.
762
+ ```
763
+
764
+ 2. **Wait for doc-syncer completion**:
765
+ - Monitor doc-syncer agent execution
766
+ - Store results in variable: `$SYNC_RESULTS`
767
+
768
+ 3. **Verify synchronization results**:
769
+ - Read file: `.moai/reports/sync-report-$TIMESTAMP.md`
770
+ - IF file does NOT exist → Print error:
771
+ ```
772
+ ⚠️ Warning: Sync report not generated
773
+
774
+ doc-syncer may have encountered an issue.
775
+ Checking for partial sync results...
776
+ ```
777
+ - ELSE → Print success:
778
+ ```
779
+ ✅ Living Document synchronization complete
780
+
781
+ Sync report: .moai/reports/sync-report-$TIMESTAMP.md
782
+ ```
783
+
784
+ 4. **Print synchronization summary**:
785
+ ```
786
+ 📚 Synchronization Results:
787
+
788
+ Documents updated:
789
+ - [list from $SYNC_RESULTS]
790
+
791
+ TAG repairs:
792
+ - [count] orphan TAGs fixed
793
+ - [count] broken references repaired
794
+
795
+ New files created:
796
+ - [list]
797
+
798
+ Sync report: .moai/reports/sync-report-$TIMESTAMP.md
799
+ ```
800
+
801
+ **Result**: Living Documents synchronized. TAG system updated.
802
+
803
+ **Next step**: Go to STEP 2.3
304
804
 
305
805
  ---
306
- **Approval Request**: Do you want to proceed with synchronization using the above plan?
307
- (select “Proceed”, “Modify [Content]”, or “Abort”)
308
- ```
806
+
807
+ ### STEP 2.3: Update TAG Index
808
+
809
+ **Your task**: Update the TAG traceability index to reflect current state.
810
+
811
+ **Steps**:
812
+
813
+ 1. **Check if TAG scanner script exists**:
814
+ - Check file: `.moai/scripts/tag_scanner.py`
815
+ - IF file does NOT exist → Print warning and skip:
816
+ ```
817
+ ⚠️ Warning: TAG scanner script not found
818
+
819
+ Skipping TAG index update.
820
+ TAG verification was performed by doc-syncer agent.
821
+ ```
822
+ - IF file exists → Proceed to next step
823
+
824
+ 2. **Run TAG scanner to update index**:
825
+ - Execute: `python3 .moai/scripts/tag_scanner.py --update-index`
826
+ - Store exit code in variable: `$TAG_SCANNER_EXIT`
827
+
828
+ 3. **Verify TAG scanner success**:
829
+ - IF `$TAG_SCANNER_EXIT != 0` → Print warning:
830
+ ```
831
+ ⚠️ Warning: TAG scanner encountered issues
832
+
833
+ Exit code: $TAG_SCANNER_EXIT
834
+
835
+ TAG index may be incomplete. Check:
836
+ .moai/logs/tag-scanner.log
837
+ ```
838
+ - ELSE → Print success:
839
+ ```
840
+ ✅ TAG index updated
841
+
842
+ Index location: .moai/indexes/tags.db
843
+ ```
844
+
845
+ 4. **Verify TAG chain integrity**:
846
+ - Execute: `rg '@TAG' -n src/ tests/` (direct code scan)
847
+ - Store output in variable: `$TAG_SCAN_OUTPUT`
848
+ - Count TAGs by type:
849
+ - `@SPEC` TAGs: Count lines matching `@SPEC`
850
+ - `@CODE` TAGs: Count lines matching `@CODE`
851
+ - `@TEST` TAGs: Count lines matching `@TEST`
852
+ - `@DOC` TAGs: Count lines matching `@DOC`
853
+ - Print:
854
+ ```
855
+ 🔗 TAG Chain Verification:
856
+ - @SPEC TAGs: [count]
857
+ - @CODE TAGs: [count]
858
+ - @TEST TAGs: [count]
859
+ - @DOC TAGs: [count]
860
+
861
+ TAG chain integrity: [PASS / ISSUES]
862
+ ```
863
+
864
+ **Result**: TAG index updated and verified.
865
+
866
+ **Next step**: Go to STEP 2.4
309
867
 
310
868
  ---
311
869
 
312
- ## 🚀 STEP 2 Implementation Guide: Document Synchronization (After Approval)
870
+ ### STEP 2.4: SPEC Document Synchronization (CRITICAL)
871
+
872
+ **Your task**: Ensure that SPEC documents are updated to match code changes.
873
+
874
+ **Important note**: This step is CRITICAL. Any code changes MUST be reflected in SPEC documents to maintain specification alignment.
875
+
876
+ **Steps**:
877
+
878
+ 1. **Analyze Git diff for functional changes**:
879
+ - Execute: `git diff HEAD --unified=3`
880
+ - Store output in variable: `$GIT_DIFF`
881
+ - Identify functional impacts:
882
+ - Function signature changes (parameters, return values)
883
+ - Behavior changes (logic flow, edge cases)
884
+ - Performance characteristics (latency, throughput)
885
+ - External dependencies (new APIs, services)
886
+
887
+ 2. **Determine which SPECs need updates**:
888
+ - Parse changed files from `$CHANGED_FILES`
889
+ - For each changed file in `src/`:
890
+ - Search for `@CODE:SPEC-{ID}` TAG in file
891
+ - Extract SPEC ID
892
+ - Add to list: `$SPECS_TO_UPDATE`
893
+ - Print:
894
+ ```
895
+ 📋 SPEC Documents Requiring Synchronization:
896
+
897
+ $SPECS_TO_UPDATE (list of SPEC IDs)
898
+ ```
899
+
900
+ 3. **For each SPEC in $SPECS_TO_UPDATE**:
901
+
902
+ a. **Read current SPEC documents**:
903
+ - Read file: `.moai/specs/SPEC-{ID}/spec.md`
904
+ - Read file: `.moai/specs/SPEC-{ID}/plan.md`
905
+ - Read file: `.moai/specs/SPEC-{ID}/acceptance.md`
906
+
907
+ b. **Compare SPEC requirements with actual code implementation**:
908
+ - **Your task**: Verify each SPEC requirement matches code behavior
909
+ - Check:
910
+ - Do EARS statements match function signatures?
911
+ - Are acceptance criteria still valid?
912
+ - Were edge cases discovered during implementation?
913
+ - Did implementation strategy change from plan.md?
914
+
915
+ c. **Identify spec-to-code divergence**:
916
+ - IF divergence detected → Mark for update
917
+ - Store divergence details in variable: `$SPEC_DIVERGENCE`
918
+
919
+ d. **Update SPEC documents to match implementation**:
920
+ - **IF spec.md needs update**:
921
+ - Update EARS statements to match actual code behavior
922
+ - Add edge cases discovered during implementation
923
+ - Update @CODE TAG references if files moved
924
+ - **IF acceptance.md needs update**:
925
+ - Add new test cases for edge cases
926
+ - Update acceptance criteria for behavior changes
927
+ - Link with @TEST TAGs from test files
928
+ - **IF plan.md needs update**:
929
+ - Document implementation changes
930
+ - Explain deviations from original plan
931
+ - Update technical approach if changed
932
+
933
+ e. **Update SPEC metadata if implementation is complete**:
934
+ - Check if SPEC status is `draft`
935
+ - Check if RED → GREEN → REFACTOR commits exist
936
+ - Check if @TEST and @CODE TAGs exist
937
+ - **IF all conditions met**:
938
+ - Update: `status: draft` → `status: completed`
939
+ - Update: `version: 0.0.x` → `version: 0.1.0`
940
+ - Add HISTORY section with completion date
941
+
942
+ 4. **Verify SPEC-Code alignment**:
943
+ - For each updated SPEC:
944
+ - **Verify**: All EARS statements match implementation
945
+ - **Verify**: Acceptance criteria valid for current code
946
+ - **Verify**: @CODE/@TEST TAGs point to correct locations
947
+ - **Verify**: No spec-code divergence remains
948
+
949
+ 5. **Print SPEC synchronization results**:
950
+ ```
951
+ ✅ SPEC Document Synchronization Complete
952
+
953
+ SPECs updated: [count]
954
+
955
+ Details:
956
+ - SPEC-001: spec.md, acceptance.md updated (edge case added)
957
+ - SPEC-002: plan.md updated (implementation approach changed)
958
+ - SPEC-003: Status → completed (v0.1.0)
959
+
960
+ SPEC-Code alignment: VERIFIED
961
+ ```
962
+
963
+ 6. **IF no SPECs required updates**:
964
+ - Print:
965
+ ```
966
+ ℹ️ No SPEC updates needed
967
+
968
+ All SPEC documents are aligned with current code.
969
+ ```
970
+
971
+ **Result**: SPEC documents synchronized with code. Specification alignment maintained.
972
+
973
+ **Next step**: Go to STEP 2.5
974
+
975
+ ---
313
976
 
314
- Only when the user selects **"Proceed"** or **"Start"** will Alfred call the doc-syncer agent to perform Living Document synchronization and TAG updates.
977
+ ### STEP 2.5: Domain-Based Sync Routing (Automatic)
978
+
979
+ **Your task**: Route documentation sync to domain-specific experts based on changed file patterns.
980
+
981
+ **Steps**:
982
+
983
+ 1. **Detect domains from changed files**:
984
+ - Read variable: `$CHANGED_FILES`
985
+ - Initialize empty array: `$DETECTED_DOMAINS`
986
+
987
+ 2. **Check for Frontend changes**:
988
+ - Search `$CHANGED_FILES` for patterns:
989
+ - `*.tsx`, `*.jsx`, `*.vue`
990
+ - `src/components/*`, `src/pages/*`
991
+ - IF any match found → Add "frontend" to `$DETECTED_DOMAINS`
992
+
993
+ 3. **Check for Backend changes**:
994
+ - Search `$CHANGED_FILES` for patterns:
995
+ - `src/api/*`, `src/models/*`, `src/routes/*`, `src/services/*`
996
+ - IF any match found → Add "backend" to `$DETECTED_DOMAINS`
997
+
998
+ 4. **Check for DevOps changes**:
999
+ - Search `$CHANGED_FILES` for patterns:
1000
+ - `Dockerfile`, `docker-compose.yml`
1001
+ - `.github/workflows/*`, `terraform/*`, `k8s/*`
1002
+ - IF any match found → Add "devops" to `$DETECTED_DOMAINS`
1003
+
1004
+ 5. **Check for Database changes**:
1005
+ - Search `$CHANGED_FILES` for patterns:
1006
+ - `src/database/*`, `migrations/*`, `*.sql`, `schema/*`
1007
+ - IF any match found → Add "database" to `$DETECTED_DOMAINS`
1008
+
1009
+ 6. **Check for Data Science changes**:
1010
+ - Search `$CHANGED_FILES` for patterns:
1011
+ - `notebooks/*`, `src/pipelines/*`, `*.ipynb`, `src/models/ml/*`
1012
+ - IF any match found → Add "datascience" to `$DETECTED_DOMAINS`
1013
+
1014
+ 7. **Check for Mobile changes**:
1015
+ - Search `$CHANGED_FILES` for patterns:
1016
+ - `src/mobile/*`, `ios/*`, `android/*`, `*.swift`, `*.kt`
1017
+ - IF any match found → Add "mobile" to `$DETECTED_DOMAINS`
1018
+
1019
+ 8. **IF no domains detected**:
1020
+ - Print:
1021
+ ```
1022
+ ℹ️ No domain-specific sync needed
1023
+
1024
+ Using standard sync templates.
1025
+ ```
1026
+ - **Skip to STEP 2.6**
1027
+
1028
+ 9. **IF domains detected**:
1029
+ - Print:
1030
+ ```
1031
+ 🎯 Domain-specific sync routing activated
1032
+
1033
+ Detected domains: $DETECTED_DOMAINS
1034
+
1035
+ Generating domain-specific documentation...
1036
+ ```
1037
+
1038
+ 10. **For each domain in $DETECTED_DOMAINS**:
1039
+
1040
+ **IF domain is "frontend"**:
1041
+ - Invoke Explore agent:
1042
+ - `subagent_type`: "Explore"
1043
+ - `prompt`:
1044
+ ```
1045
+ Act as frontend-expert. Provide sync documentation.
1046
+
1047
+ Changed Files: [list frontend files from $CHANGED_FILES]
1048
+
1049
+ Provide frontend-specific documentation:
1050
+ 1. Component documentation updates
1051
+ 2. Storybook story generation (if applicable)
1052
+ 3. UI architecture diagram updates
1053
+ 4. Accessibility compliance notes
1054
+ 5. Component prop documentation
1055
+
1056
+ Output format: Markdown document
1057
+ Save to: .moai/reports/sync-frontend-$TIMESTAMP.md
1058
+ ```
1059
+
1060
+ **IF domain is "backend"**:
1061
+ - Invoke Explore agent:
1062
+ - `subagent_type`: "Explore"
1063
+ - `prompt`:
1064
+ ```
1065
+ Act as backend-expert. Provide sync documentation.
1066
+
1067
+ Changed Files: [list backend files from $CHANGED_FILES]
1068
+
1069
+ Provide backend-specific documentation:
1070
+ 1. OpenAPI spec generation/updates
1071
+ 2. Schema documentation updates
1072
+ 3. Error handling documentation
1073
+ 4. API endpoint examples
1074
+ 5. Performance characteristics
1075
+
1076
+ Output format: Markdown document
1077
+ Save to: .moai/reports/sync-backend-$TIMESTAMP.md
1078
+ ```
1079
+
1080
+ **IF domain is "devops"**:
1081
+ - Invoke Explore agent:
1082
+ - `subagent_type`: "Explore"
1083
+ - `prompt`:
1084
+ ```
1085
+ Act as devops-expert. Provide sync documentation.
1086
+
1087
+ Changed Files: [list devops files from $CHANGED_FILES]
1088
+
1089
+ Provide DevOps-specific documentation:
1090
+ 1. Deployment documentation updates
1091
+ 2. CI/CD pipeline changes
1092
+ 3. Infrastructure diagrams
1093
+ 4. Configuration management notes
1094
+ 5. Monitoring/alerting setup
1095
+
1096
+ Output format: Markdown document
1097
+ Save to: .moai/reports/sync-devops-$TIMESTAMP.md
1098
+ ```
1099
+
1100
+ **IF domain is "database"**:
1101
+ - Invoke Explore agent:
1102
+ - `subagent_type`: "Explore"
1103
+ - `prompt`:
1104
+ ```
1105
+ Act as database-expert. Provide sync documentation.
1106
+
1107
+ Changed Files: [list database files from $CHANGED_FILES]
1108
+
1109
+ Provide database-specific documentation:
1110
+ 1. Schema documentation updates
1111
+ 2. Migration logs
1112
+ 3. Query optimization notes
1113
+ 4. Index strategies
1114
+ 5. Data integrity constraints
1115
+
1116
+ Output format: Markdown document
1117
+ Save to: .moai/reports/sync-database-$TIMESTAMP.md
1118
+ ```
1119
+
1120
+ **IF domain is "datascience"**:
1121
+ - Invoke Explore agent:
1122
+ - `subagent_type`: "Explore"
1123
+ - `prompt`:
1124
+ ```
1125
+ Act as datascience-expert. Provide sync documentation.
1126
+
1127
+ Changed Files: [list data science files from $CHANGED_FILES]
1128
+
1129
+ Provide data science-specific documentation:
1130
+ 1. Pipeline documentation
1131
+ 2. Model cards (for ML models)
1132
+ 3. Data validation rules
1133
+ 4. Feature engineering notes
1134
+ 5. Experiment tracking
1135
+
1136
+ Output format: Markdown document
1137
+ Save to: .moai/reports/sync-datascience-$TIMESTAMP.md
1138
+ ```
1139
+
1140
+ **IF domain is "mobile"**:
1141
+ - Invoke Explore agent:
1142
+ - `subagent_type`: "Explore"
1143
+ - `prompt`:
1144
+ ```
1145
+ Act as mobile-expert. Provide sync documentation.
1146
+
1147
+ Changed Files: [list mobile files from $CHANGED_FILES]
1148
+
1149
+ Provide mobile-specific documentation:
1150
+ 1. Platform-specific documentation (iOS/Android)
1151
+ 2. App lifecycle documentation
1152
+ 3. Native module documentation
1153
+ 4. Push notification setup
1154
+ 5. Deep linking configuration
1155
+
1156
+ Output format: Markdown document
1157
+ Save to: .moai/reports/sync-mobile-$TIMESTAMP.md
1158
+ ```
1159
+
1160
+ 11. **Wait for all domain-specific sync agents to complete**:
1161
+ - Monitor each Explore agent execution
1162
+ - Store results in array: `$DOMAIN_SYNC_RESULTS`
1163
+
1164
+ 12. **Create combined sync report**:
1165
+ - **Your task**: Consolidate all domain-specific reports into master report
1166
+ - Read all domain-specific report files
1167
+ - Write combined report to: `.moai/reports/sync-report-$TIMESTAMP.md`
1168
+ - Include sections:
1169
+ - Changed Files Summary
1170
+ - Domain-Specific Sync Results (with links to detailed reports)
1171
+ - @TAG Verification
1172
+ - Next Steps
1173
+
1174
+ 13. **Print domain sync summary**:
1175
+ ```
1176
+ ✅ Domain-specific sync complete
1177
+
1178
+ Domains processed:
1179
+ - Frontend: [count] files → sync-frontend-$TIMESTAMP.md
1180
+ - Backend: [count] files → sync-backend-$TIMESTAMP.md
1181
+ - DevOps: [count] files → sync-devops-$TIMESTAMP.md
1182
+
1183
+ Combined report: sync-report-$TIMESTAMP.md
1184
+ ```
1185
+
1186
+ **Result**: Domain-specific documentation generated. Combined sync report created.
1187
+
1188
+ **Next step**: Go to STEP 2.6
315
1189
 
316
- ### Sync step-by-step guide
1190
+ ---
317
1191
 
318
- 1. **Living Document Synchronization**: Code → Document automatically reflected
319
- 2. **TAG System Verification**: @TAG System Integrity Verification
320
- 3. **Index Update**: Traceability Matrix Update
321
- 4. **Create Report**: Create a summary of synchronization results
1192
+ ### STEP 2.6: Display Synchronization Completion Report
322
1193
 
323
- ### Agent collaboration structure
1194
+ **Your task**: Present comprehensive synchronization results to the user.
324
1195
 
325
- - **Step 1**: The `doc-syncer` agent is dedicated to Living Document synchronization and @TAG management.
326
- - **Step 2**: The `git-manager` agent is dedicated to all Git commits, PR state transitions, and synchronization.
327
- - **Single Responsibility Principle**: doc-syncer only performs document tasks, and git-manager only performs Git tasks.
328
- - **Sequential execution**: Executes in the order doc-syncer → git-manager to maintain clear dependencies.
329
- - **No inter-agent calls**: Each agent does not directly call other agents, and executes commands. Runs sequentially in levels only.
1196
+ **Steps**:
330
1197
 
331
- ## 🚀 Optimized parallel/sequential hybrid workflow
1198
+ 1. **Read synchronization results**:
1199
+ - Read file: `.moai/reports/sync-report-$TIMESTAMP.md`
1200
+ - Store content in variable: `$SYNC_REPORT_CONTENT`
332
1201
 
333
- ### Phase 1: Quick status check (parallel execution)
1202
+ 2. **Calculate synchronization metrics**:
1203
+ - Count updated files from `$SYNC_RESULTS`
1204
+ - Count TAG repairs from `$TAG_VALIDATION_RESULTS`
1205
+ - Count domain-specific reports from `$DETECTED_DOMAINS`
334
1206
 
335
- Do the following **simultaneously**:
1207
+ 3. **Print comprehensive completion report**:
1208
+ ```
1209
+ ═══════════════════════════════════════════════════════
1210
+ ✅ Document Synchronization Complete
1211
+ ═══════════════════════════════════════════════════════
336
1212
 
337
- ```
338
- Task 1 (haiku): Check Git status
339
- ├── Collect list of changed files
340
- ├── Check branch status
341
- └── Determine need for synchronization
342
-
343
- Task 2 (sonnet): Analyze document structure
344
- ├── Detect project type
345
- ├── Collect TAG list
346
- └── Determine synchronization scope
347
- ```
1213
+ 📊 Synchronization Summary:
1214
+ - Mode: $MODE
1215
+ - Scope: $SYNC_SCOPE
1216
+ - Files updated: [count]
1217
+ - Files created: [count]
1218
+ - TAG repairs: [count]
348
1219
 
349
- ### Phase 2: Document synchronization (sequential execution)
1220
+ 📚 Documents Updated:
1221
+ - Living Documents: [list]
1222
+ - SPEC documents: [list]
1223
+ - Domain-specific reports: [count]
350
1224
 
351
- The `doc-syncer` agent (sonnet) handles intensive processing:
1225
+ 🔗 TAG System Status:
1226
+ - @SPEC TAGs: [count]
1227
+ - @CODE TAGs: [count]
1228
+ - @TEST TAGs: [count]
1229
+ - @DOC TAGs: [count]
1230
+ - TAG chain integrity: [PASS / WARNING]
352
1231
 
353
- - Living Document synchronization
354
- - @TAG system verification and update
355
- - Document-code consistency check
356
- - TAG traceability matrix update
357
-
358
- ### Phase 3: Git task processing (sequential execution)
359
-
360
- Final processing by the `git-manager` agent (haiku):
361
-
362
- - Commit document changes
363
- - Apply synchronization strategy for each mode
364
- - Switch PR Ready in Team mode
365
- - Automatically assign reviewers (using gh CLI)
366
-
367
- ### Phase 4: PR merge and branch cleanup (optional)
368
-
369
- Additional processing by `git-manager` when using the `--auto-merge` flag:
370
-
371
- **Team mode (GitFlow)**:
372
- 1. Check PR status (CI/CD pass check)
373
- 2. PR automatic merge (to develop branch)
374
- 3. Delete remote feature branch
375
- 4. Local develop checkout and synchronization
376
- 5. Organizing local feature branches
377
- 6. Notification that the next task is ready
1232
+ 📄 Reports Generated:
1233
+ - Master sync report: .moai/reports/sync-report-$TIMESTAMP.md
1234
+ - Domain reports: [list if any]
378
1235
 
379
- **Personal Mode**:
380
- 1. Local main/develop merge
381
- 2. Delete feature branch
382
- 3. Check out the base branch
383
- 4. Notification that the next task is ready
1236
+ 💾 Backup Location:
1237
+ - Safety backup: .moai-backups/sync-$TIMESTAMP/
384
1238
 
385
- **Performance improvements**: Minimize latency by parallelizing the initial verification step
1239
+ ═══════════════════════════════════════════════════════
1240
+ ```
386
1241
 
387
- ### Argument handling
1242
+ 4. **IF TAG issues remain**:
1243
+ - Print warning:
1244
+ ```
1245
+ ⚠️ Remaining TAG Issues:
388
1246
 
389
- - **$1 (mode)**: `$1` `auto` (default)|`force`|`status`|`project`
390
- - **$2 (path)**: `$2` → Sync target path (optional)
391
- - **flags**:
392
- - `--auto-merge`: Enable PR automatic merge and branch cleanup (Team mode)
393
- - `--skip-pre-check`: Skip pre-quality check
394
- - `--skip-quality-check`: Skip final quality check
1247
+ The following issues could not be automatically resolved:
1248
+ - Orphan @CODE TAGs: [list]
1249
+ - Broken references: [list]
395
1250
 
396
- **Command usage example**:
397
- - `/alfred:3-sync` - Basic automatic synchronization (optimized by mode)
398
- - `/alfred:3-sync --auto-merge` - PR automatic merge + branch cleanup (Team mode recommended)
399
- - `/alfred:3-sync force` - Force full synchronization
400
- - `/alfred:3-sync status` - Check synchronization status
401
- - `/alfred:3-sync project` - Integrated project synchronization
402
- - `/alfred:3-sync auto src/auth/` - Specific path Synchronization
403
- - `/alfred:3-sync --auto-merge --skip-pre-check` - Fast merge
1251
+ Manual review recommended.
1252
+ ```
404
1253
 
405
- ### Agent role separation
1254
+ 5. **Print next step guidance**:
1255
+ ```
1256
+ 🚀 Next Steps:
406
1257
 
407
- #### doc-syncer dedicated area
1258
+ 1. Review sync report: .moai/reports/sync-report-$TIMESTAMP.md
1259
+ 2. Commit changes: Git operations will be handled next
1260
+ 3. PR handling: [if Team mode] Ready for PR transition
1261
+ ```
408
1262
 
409
- - Living Document synchronization (code document)
410
- - @TAG system verification and update
411
- - Automatic creation/update of API document
412
- - README and architecture document synchronization
413
- - Verification of document-code consistency
1263
+ **Result**: User informed of synchronization results. Ready for Git operations.
414
1264
 
415
- #### git-manager dedicated area
1265
+ **Next step**: Go to STEP 3.1
416
1266
 
417
- - All Git commit operations (add, commit, push)
418
- - Apply synchronization strategy for each mode
419
- - PR status transition (Draft → Ready)
420
- - **PR auto merge** (when --auto-merge flag)
421
- - Check CI/CD status
422
- - Conflict verification
423
- - Execute Squash merge
424
- - Remote branch deletion
425
- - **Branch cleanup and conversion**
426
- - Local develop checkout
427
- - Remote synchronization (git pull)
428
- - Local feature branch deletion
429
- - Automatic assignment and labeling of reviewers
430
- - GitHub CLI integration and remote synchronization
1267
+ ---
431
1268
 
432
- ### 🧪 Personal Mode
1269
+ ## 🔧 STEP 3: Git Operations & PR
433
1270
 
434
- - The git-manager agent automatically creates checkpoints before and after synchronization
435
- - The README, in-depth documentation, and PR body are organized manually according to the checklist.
1271
+ ### STEP 3.1: Commit Document Changes
436
1272
 
437
- ### 🏢 Team Mode
1273
+ **Your task**: Call git-manager agent to commit all document changes with proper commit message.
438
1274
 
439
- - Full synchronization of Living Document + @TAG verification/correction
440
- - Optionally perform PR Ready conversion and labeling only when gh CLI is set
441
- - Fully automated when using **--auto-merge flag**:
442
- 1. Document synchronization complete.
443
- 2. git push origin feature/SPEC-{ID}
444
- 3. gh pr ready {PR_NUMBER}
445
- 4. Check CI/CD status (gh pr checks)
446
- 5. gh pr merge --squash --delete-branch
447
- 6. git checkout develop && git pull origin develop
448
- 7. Notification that the next task is ready
1275
+ **Steps**:
449
1276
 
450
- **Important**: All Git operations (commit, sync, PR management) are handled by the git-manager agent, so this command does not run Git operations directly.
1277
+ 1. **Prepare commit summary**:
1278
+ - Read variable: `$SYNC_RESULTS`
1279
+ - Create summary text:
1280
+ ```
1281
+ docs: sync documentation with code changes
451
1282
 
452
- **Branch Policy**:
453
- - Base branch: `develop` (GitFlow standard)
454
- - After merge: automatically checkout `develop`
455
- - Next `/alfred:1-plan` automatically starts in `develop`
1283
+ Synchronized Living Documents:
1284
+ - [list from $SYNC_RESULTS]
456
1285
 
457
- ## Synchronization Details (Summary)
1286
+ TAG system updates:
1287
+ - [TAG repair count] repairs
1288
+ - TAG index updated
458
1289
 
459
- 1. Project analysis and TAG verification → Check broken/duplicate/orphaned TAG
460
- 2. Code ↔ Document synchronization → API/README/architecture document update, SPEC Code TODO synchronization
461
- 3. TAG chain verification → `rg '@TAG' -n src/ tests/` (scan code directly)
1290
+ SPEC synchronization:
1291
+ - [SPEC update count] SPECs updated
462
1292
 
463
- ## Next steps
1293
+ Domain-specific sync:
1294
+ - [domain list if applicable]
464
1295
 
465
- **Recommendation**: For better performance and context management, start a new chat session with the `/clear` or `/new` command before proceeding to the next step.
1296
+ 🤖 Generated with Claude Code
466
1297
 
467
- - The entire MoAI-ADK workflow is completed after document synchronization is completed
468
- - All Git operations are dedicated to the git-manager agent to ensure consistency
469
- - Only command-level orchestration is used without direct calls between agents
1298
+ Co-Authored-By: 🦄 Alfred@MoAI
1299
+ ```
1300
+ - Store in variable: `$COMMIT_MESSAGE`
470
1301
 
471
- ## Report results
1302
+ 2. **Invoke git-manager agent for commit**:
1303
+ - **Your task**: Call git-manager to commit document changes
1304
+ - Use Task tool:
1305
+ - `subagent_type`: "git-manager"
1306
+ - `description`: "Commit document synchronization changes"
1307
+ - `prompt`:
1308
+ ```
1309
+ You are the git-manager agent.
472
1310
 
473
- Report synchronization results in a structured format:
1311
+ **Task**: Commit document synchronization changes to Git.
474
1312
 
475
- ### Successful synchronization (summary example)
1313
+ **Commit Scope**:
1314
+ - All changed document files
1315
+ - .moai/reports/ directory
1316
+ - .moai/indexes/ directory (if changed)
1317
+ - README.md (if changed)
1318
+ - docs/ directory (if changed)
476
1319
 
477
- Document synchronization complete — Update N, Create M, TAG Modify K, Verification passed
1320
+ **Commit Message**:
1321
+ $COMMIT_MESSAGE
478
1322
 
479
- ### Partial synchronization (problem detected)
1323
+ **Important**:
1324
+ - Pass commit message in HEREDOC format
1325
+ - Bundle all changes into a single commit
1326
+ - Report success after commit
480
1327
 
481
- ```
482
- ⚠️ Partial sync completed (issue found)
1328
+ **Execution Order**:
1329
+ 1. git add (changed document files)
1330
+ 2. git commit -m (HEREDOC)
1331
+ 3. git log -1 (verify commit)
1332
+ ```
483
1333
 
484
- Problems that need solving:
485
- ├── Broken links: X (specific list)
486
- ├── Duplicate TAG: X
487
- └── Orphan TAG: X
1334
+ 3. **Wait for git-manager response**:
1335
+ - Store response in variable: `$GIT_COMMIT_RESULT`
488
1336
 
489
- 🛠️ Auto-correction recommendations:
490
- 1. Broken link recovery
491
- 2. Merge duplicate TAGs
492
- 3. Orphan TAG cleanup
493
- ```
1337
+ 4. **Verify commit success**:
1338
+ - Execute: `git log -1 --oneline`
1339
+ - Store output in variable: `$LAST_COMMIT`
1340
+ - Print:
1341
+ ```
1342
+ ✅ Document changes committed
494
1343
 
495
- ## Next steps guidance
1344
+ Commit: $LAST_COMMIT
1345
+ ```
496
1346
 
497
- ### Development cycle complete
1347
+ 5. **IF commit failed**:
1348
+ - Print error:
1349
+ ```
1350
+ ❌ Error: Git commit failed
498
1351
 
499
- **Default mode (PR Ready only)**:
500
- ```
501
- 🔄 MoAI-ADK 3-step workflow completion:
502
- ✅ /alfred:1-plan → Create EARS specification (feature/SPEC-{ID} branch)
503
- ✅ /alfred:2-run → TDD implementation
504
- ✅ /alfred:3-sync → Document synchronization + PR Ready
505
-
506
- ⏳ Next steps: PR review and manual merge required
507
- > gh pr view (check PR)
508
- > gh pr merge --squash (merge after review)
509
- ```
1352
+ git-manager reported an issue.
1353
+ Check git status and resolve conflicts if any.
510
1354
 
511
- **Auto Merge Mode (Recommended)**:
512
- ```
513
- 🔄 Fully automated GitFlow workflow:
514
- ✅ /alfred:1-plan → EARS specification creation (from develop)
515
- ✅ /alfred:2-runTDD implementation
516
- ✅ /alfred:3-sync --auto-merge → Document synchronization + PR Merge + branch cleanup
517
-
518
- 🎉 Automatic switch to develop branch done!
519
- 📍 You are here: develop (ready for next work)
520
- > /alfred:1-plan "Describe next feature" # Create new branch in develop
521
- ```
1355
+ You can retry commit manually:
1356
+ git add .moai/reports/ docs/ README.md
1357
+ git commit -m "docs: sync documentation"
1358
+ ```
1359
+ - **STOP HERE** Exit with error code
1360
+
1361
+ **Result**: Document changes committed to Git history.
522
1362
 
523
- ### Integrated project mode
1363
+ **Next step**: Go to STEP 3.2
524
1364
 
525
- **When to use**:
526
- - When the implementation of multiple SPECs has been completed and the entire project documentation needs to be updated
527
- - When periodic synchronization of the entire document in Personal mode is required.
1365
+ ---
528
1366
 
529
- **Differences from Personal/Team mode**:
530
- - **Personal/Team mode**: Synchronize only specific SPEC-related documents
531
- - **Project mode**: Synchronize README, architecture documentation, and entire API documentation
1367
+ ### STEP 3.2: (Optional) PR Ready Transition
532
1368
 
533
- **Output**:
534
- - README.md (updated complete feature list)
535
- - docs/architecture.md (updated system design)
536
- - docs/api/ (unified API documentation)
537
- - .moai/indexes/ (rebuilt full TAG index)
1369
+ **Your task**: Transition PR from Draft to Ready for Review (Team mode only).
538
1370
 
539
- ```
540
- 🏢 Integrated branch sync complete!
1371
+ **Decision point**:
541
1372
 
542
- 📋 Entire project synchronization:
543
- ├── README.md (full feature list)
544
- ├── docs/architecture.md (system design)
545
- ├── docs/api/ (unified API documentation)
546
- └── .moai/indexes/ (full TAG index)
1373
+ 1. **Check if PR transition is needed**:
1374
+ - Read variable: `$PROJECT_MODE`
1375
+ - IF `$PROJECT_MODE != "Team"` → Skip this step:
1376
+ ```
1377
+ ℹ️ PR transition skipped (Personal mode)
1378
+ ```
1379
+ - **Next step**: Go to STEP 3.5 (skip auto-merge)
547
1380
 
548
- 🎯 PR conversion support completed
549
- ```
1381
+ 2. **IF Team mode**:
1382
+ - Continue to PR transition
1383
+
1384
+ 3. **Check if gh CLI is available**:
1385
+ - Execute: `which gh`
1386
+ - IF gh NOT found → Print warning and skip:
1387
+ ```
1388
+ ⚠️ Warning: GitHub CLI (gh) not found
1389
+
1390
+ PR transition skipped.
1391
+ To enable PR features, install gh CLI:
1392
+ https://cli.github.com/
1393
+ ```
1394
+ - **Next step**: Go to STEP 3.5
1395
+
1396
+ 4. **Get current PR number**:
1397
+ - Execute: `gh pr view --json number -q '.number'`
1398
+ - Store result in variable: `$PR_NUMBER`
1399
+ - IF command fails → Print info and skip:
1400
+ ```
1401
+ ℹ️ No PR found for current branch
1402
+
1403
+ Skipping PR transition.
1404
+ You can create a PR manually with: gh pr create
1405
+ ```
1406
+ - **Next step**: Go to STEP 3.5
1407
+
1408
+ 5. **Get current PR status**:
1409
+ - Execute: `gh pr view $PR_NUMBER --json isDraft -q '.isDraft'`
1410
+ - Store result in variable: `$IS_DRAFT`
1411
+
1412
+ 6. **IF PR is already Ready** (`$IS_DRAFT = false`):
1413
+ - Print:
1414
+ ```
1415
+ ℹ️ PR already in Ready state
1416
+
1417
+ PR #$PR_NUMBER: Ready for Review
1418
+ ```
1419
+ - **Next step**: Go to STEP 3.3 (check auto-merge)
1420
+
1421
+ 7. **IF PR is Draft** (`$IS_DRAFT = true`):
1422
+ - Transition PR to Ready:
1423
+ - Execute: `gh pr ready $PR_NUMBER`
1424
+ - Store exit code in variable: `$PR_READY_EXIT`
1425
+
1426
+ 8. **Verify PR transition success**:
1427
+ - IF `$PR_READY_EXIT != 0` → Print error:
1428
+ ```
1429
+ ❌ Error: PR transition failed
1430
+
1431
+ Unable to transition PR #$PR_NUMBER to Ready.
1432
+ Check PR status manually: gh pr view $PR_NUMBER
1433
+ ```
1434
+ - ELSE → Print success:
1435
+ ```
1436
+ ✅ PR transitioned to Ready for Review
1437
+
1438
+ PR #$PR_NUMBER: Ready for Review
1439
+
1440
+ View PR: gh pr view $PR_NUMBER --web
1441
+ ```
1442
+
1443
+ 9. **Assign reviewers** (if configured):
1444
+ - Read `.moai/config.json` → Extract `github.reviewers`
1445
+ - IF reviewers configured:
1446
+ - Execute: `gh pr edit $PR_NUMBER --add-reviewer [reviewer-list]`
1447
+
1448
+ 10. **Add labels** (if configured):
1449
+ - Read `.moai/config.json` → Extract `github.pr_labels`
1450
+ - IF labels configured:
1451
+ - Execute: `gh pr edit $PR_NUMBER --add-label [label-list]`
1452
+
1453
+ **Result**: PR transitioned to Ready for Review (Team mode only).
1454
+
1455
+ **Next step**: Go to STEP 3.3
1456
+
1457
+ ---
1458
+
1459
+ ### STEP 3.3: (Optional) PR Auto-Merge
1460
+
1461
+ **Your task**: Automatically merge PR and clean up branch (if --auto-merge flag is set).
1462
+
1463
+ **Decision point**:
1464
+
1465
+ 1. **Check if auto-merge is requested**:
1466
+ - Read variable: `$AUTO_MERGE`
1467
+ - IF `$AUTO_MERGE = false` → Skip this step:
1468
+ ```
1469
+ ℹ️ Auto-merge not requested
1470
+
1471
+ PR is Ready for manual review and merge.
1472
+ ```
1473
+ - **Next step**: Go to STEP 3.5
1474
+
1475
+ 2. **IF auto-merge requested** (`$AUTO_MERGE = true`):
1476
+ - Print:
1477
+ ```
1478
+ 🤖 Auto-merge activated
1479
+
1480
+ Checking PR status and CI/CD...
1481
+ ```
1482
+
1483
+ 3. **Check CI/CD status**:
1484
+ - Execute: `gh pr checks $PR_NUMBER`
1485
+ - Store exit code in variable: `$CI_STATUS`
1486
+ - IF `$CI_STATUS != 0` → Print error and abort:
1487
+ ```
1488
+ ❌ Error: CI/CD checks not passing
1489
+
1490
+ Cannot auto-merge PR #$PR_NUMBER
1491
+
1492
+ Check CI/CD status: gh pr checks $PR_NUMBER
1493
+
1494
+ Please wait for checks to pass or merge manually.
1495
+ ```
1496
+ - **STOP HERE** → Go to STEP 3.5
1497
+
1498
+ 4. **Check for merge conflicts**:
1499
+ - Execute: `gh pr view $PR_NUMBER --json mergeable -q '.mergeable'`
1500
+ - Store result in variable: `$MERGEABLE`
1501
+ - IF `$MERGEABLE != "MERGEABLE"` → Print error and abort:
1502
+ ```
1503
+ ❌ Error: PR has merge conflicts
1504
+
1505
+ Cannot auto-merge PR #$PR_NUMBER
1506
+
1507
+ Resolve conflicts manually:
1508
+ git fetch origin develop
1509
+ git merge origin/develop
1510
+ ```
1511
+ - **STOP HERE** → Go to STEP 3.5
1512
+
1513
+ 5. **Execute auto-merge**:
1514
+ - Print:
1515
+ ```
1516
+ 🚀 Merging PR #$PR_NUMBER...
1517
+ ```
1518
+ - Execute: `gh pr merge $PR_NUMBER --squash --delete-branch`
1519
+ - Store exit code in variable: `$MERGE_EXIT`
1520
+
1521
+ 6. **Verify merge success**:
1522
+ - IF `$MERGE_EXIT != 0` → Print error:
1523
+ ```
1524
+ ❌ Error: PR merge failed
1525
+
1526
+ Auto-merge encountered an issue.
1527
+ Merge manually: gh pr merge $PR_NUMBER --squash
1528
+ ```
1529
+ - ELSE → Print success:
1530
+ ```
1531
+ ✅ PR merged successfully
1532
+
1533
+ PR #$PR_NUMBER: Merged to develop
1534
+ Remote feature branch: Deleted
1535
+ ```
1536
+
1537
+ **Result**: PR merged and remote branch deleted (if auto-merge succeeded).
1538
+
1539
+ **Next step**: Go to STEP 3.4
1540
+
1541
+ ---
1542
+
1543
+ ### STEP 3.4: (Optional) Branch Cleanup
1544
+
1545
+ **Your task**: Clean up local branches and checkout develop branch (if auto-merge succeeded).
1546
+
1547
+ **Decision point**:
1548
+
1549
+ 1. **Check if branch cleanup is needed**:
1550
+ - Read variable: `$MERGE_EXIT`
1551
+ - IF `$MERGE_EXIT != 0` OR `$AUTO_MERGE = false` → Skip cleanup:
1552
+ ```
1553
+ ℹ️ Branch cleanup skipped
1554
+ ```
1555
+ - **Next step**: Go to STEP 3.5
1556
+
1557
+ 2. **IF merge succeeded**:
1558
+ - Continue to branch cleanup
1559
+
1560
+ 3. **Get current branch name**:
1561
+ - Execute: `git rev-parse --abbrev-ref HEAD`
1562
+ - Store result in variable: `$CURRENT_BRANCH`
1563
+
1564
+ 4. **Checkout develop branch**:
1565
+ - Execute: `git checkout develop`
1566
+ - Store exit code in variable: `$CHECKOUT_EXIT`
1567
+ - IF `$CHECKOUT_EXIT != 0` → Print error:
1568
+ ```
1569
+ ⚠️ Warning: Could not checkout develop
1570
+
1571
+ Staying on current branch: $CURRENT_BRANCH
1572
+ ```
1573
+ - ELSE → Print:
1574
+ ```
1575
+ ✅ Checked out develop branch
1576
+ ```
1577
+
1578
+ 5. **Synchronize with remote**:
1579
+ - Execute: `git pull origin develop`
1580
+ - Print:
1581
+ ```
1582
+ ✅ Develop branch synchronized with remote
1583
+ ```
1584
+
1585
+ 6. **Delete local feature branch**:
1586
+ - Execute: `git branch -d $CURRENT_BRANCH`
1587
+ - Store exit code in variable: `$DELETE_EXIT`
1588
+ - IF `$DELETE_EXIT != 0` → Print warning:
1589
+ ```
1590
+ ⚠️ Warning: Could not delete local branch
1591
+
1592
+ Branch: $CURRENT_BRANCH
1593
+
1594
+ Delete manually if needed: git branch -D $CURRENT_BRANCH
1595
+ ```
1596
+ - ELSE → Print:
1597
+ ```
1598
+ ✅ Local feature branch deleted
1599
+
1600
+ Branch: $CURRENT_BRANCH
1601
+ ```
550
1602
 
551
- ## Constraints and Assumptions
1603
+ 7. **Check for auto-delete-branches config**:
1604
+ - Read `.moai/config.json` → Extract `github.auto_delete_branches`
1605
+ - IF configured as `true`:
1606
+ - Print:
1607
+ ```
1608
+ ℹ️ Remote branch already deleted by auto-merge
1609
+ ```
552
1610
 
553
- **Environment Dependency:**
1611
+ 8. **Print branch cleanup summary**:
1612
+ ```
1613
+ 🧹 Branch Cleanup Complete
554
1614
 
555
- - Git repository required
556
- - gh CLI (required for GitHub integration)
557
- - Python3 (TAG verification script)
1615
+ - Current branch: develop
1616
+ - Deleted local branch: $CURRENT_BRANCH
1617
+ - Remote branch: Deleted
558
1618
 
559
- **Prerequisites:**
1619
+ 🎉 Ready for next feature!
560
1620
 
1621
+ Start next work with: /alfred:1-plan "feature description"
1622
+ ```
1623
+
1624
+ **Result**: Branches cleaned up. Repository ready for next development cycle.
1625
+
1626
+ **Next step**: Go to STEP 3.5
1627
+
1628
+ ---
1629
+
1630
+ ### STEP 3.5: Display Completion Report & Next Steps
1631
+
1632
+ **Your task**: Present final completion report and ask user what to do next.
1633
+
1634
+ **Steps**:
1635
+
1636
+ 1. **Determine workflow completion status**:
1637
+ - Read variables: `$PROJECT_MODE`, `$AUTO_MERGE`, `$MERGE_EXIT`
1638
+ - Determine completion type:
1639
+ - IF `$AUTO_MERGE = true` AND `$MERGE_EXIT = 0` → Status: "Full Auto-Merge Complete"
1640
+ - ELSE IF `$PROJECT_MODE = "Team"` → Status: "PR Ready for Review"
1641
+ - ELSE → Status: "Personal Mode Checkpoint"
1642
+
1643
+ 2. **Print final completion report**:
1644
+
1645
+ **IF Full Auto-Merge Complete**:
1646
+ ```
1647
+ ═══════════════════════════════════════════════════════
1648
+ 🎉 MoAI-ADK Workflow Complete (Full Auto-Merge)
1649
+ ═══════════════════════════════════════════════════════
1650
+
1651
+ ✅ Completed Steps:
1652
+ 1. Document synchronization
1653
+ 2. TAG system verification
1654
+ 3. Git commit
1655
+ 4. PR merge to develop
1656
+ 5. Branch cleanup
1657
+
1658
+ 📍 Current Status:
1659
+ - Branch: develop
1660
+ - PR #$PR_NUMBER: Merged
1661
+ - Local feature branch: Deleted
1662
+ - Remote feature branch: Deleted
1663
+
1664
+ 🚀 Ready for next feature!
1665
+
1666
+ ═══════════════════════════════════════════════════════
1667
+ ```
1668
+
1669
+ **IF PR Ready for Review**:
1670
+ ```
1671
+ ═══════════════════════════════════════════════════════
1672
+ ✅ MoAI-ADK Workflow Complete (PR Ready)
1673
+ ═══════════════════════════════════════════════════════
1674
+
1675
+ ✅ Completed Steps:
1676
+ 1. Document synchronization
1677
+ 2. TAG system verification
1678
+ 3. Git commit
1679
+ 4. PR transition to Ready
1680
+
1681
+ 📍 Current Status:
1682
+ - PR #$PR_NUMBER: Ready for Review
1683
+ - Branch: $CURRENT_BRANCH
1684
+
1685
+ ⏳ Next Steps:
1686
+ - Review PR: gh pr view $PR_NUMBER --web
1687
+ - Merge after approval: gh pr merge $PR_NUMBER --squash
1688
+
1689
+ ═══════════════════════════════════════════════════════
1690
+ ```
1691
+
1692
+ **IF Personal Mode**:
1693
+ ```
1694
+ ═══════════════════════════════════════════════════════
1695
+ ✅ Document Synchronization Complete (Personal Mode)
1696
+ ═══════════════════════════════════════════════════════
1697
+
1698
+ ✅ Completed Steps:
1699
+ 1. Document synchronization
1700
+ 2. TAG system verification
1701
+ 3. Git commit (checkpoint)
1702
+
1703
+ 📍 Current Status:
1704
+ - Branch: $CURRENT_BRANCH
1705
+ - Changes committed locally
1706
+
1707
+ 💡 Personal mode workflow:
1708
+ - Continue development on current branch
1709
+ - OR merge to main manually when ready
1710
+
1711
+ ═══════════════════════════════════════════════════════
1712
+ ```
1713
+
1714
+ 3. **Ask user for next action using AskUserQuestion**:
1715
+ - **Your task**: Use the AskUserQuestion tool to gather user's next step
1716
+ - Tool call:
1717
+ - `questions`: Array with 1 question
1718
+ - Question details:
1719
+ - `question`: "Documentation synchronization complete. What would you like to do next?"
1720
+ - `header`: "Next Steps"
1721
+ - `multiSelect`: false
1722
+ - `options`: Array with 3 choices (context-dependent):
1723
+
1724
+ **IF auto-merge completed**:
1725
+ 1. Label: "📋 Create Next SPEC", Description: "Start new feature planning with /alfred:1-plan"
1726
+ 2. Label: "🔄 Start New Session", Description: "Execute /clear for fresh session (recommended for performance)"
1727
+ 3. Label: "🎯 Project Overview", Description: "Review project status and documentation"
1728
+
1729
+ **IF PR Ready (not auto-merged)**:
1730
+ 1. Label: "📋 Create Next SPEC", Description: "Start new feature planning with /alfred:1-plan"
1731
+ 2. Label: "📤 Review PR", Description: "View PR and prepare for manual merge"
1732
+ 3. Label: "🔄 Start New Session", Description: "Execute /clear for fresh session (recommended for performance)"
1733
+
1734
+ **IF Personal Mode**:
1735
+ 1. Label: "📋 Create Next SPEC", Description: "Start new feature planning with /alfred:1-plan"
1736
+ 2. Label: "🔧 Continue Development", Description: "Keep working on current branch"
1737
+ 3. Label: "🔄 Start New Session", Description: "Execute /clear for fresh session (recommended for performance)"
1738
+
1739
+ 4. **Wait for user response**:
1740
+ - Store response in variable: `$NEXT_ACTION`
1741
+ - Read value from: `$NEXT_ACTION["0"]`
1742
+
1743
+ 5. **Process user response**:
1744
+
1745
+ **IF user chose "📋 Create Next SPEC"**:
1746
+ - Print:
1747
+ ```
1748
+ 🚀 Ready to start next feature
1749
+
1750
+ Use: /alfred:1-plan "feature description"
1751
+
1752
+ This will create a new SPEC and start a new development cycle.
1753
+ ```
1754
+
1755
+ **IF user chose "🔄 Start New Session"**:
1756
+ - Print:
1757
+ ```
1758
+ 🔄 Starting fresh session
1759
+
1760
+ Recommendation: Use /clear or /new command to reset context.
1761
+
1762
+ This improves performance for the next development cycle.
1763
+ ```
1764
+
1765
+ **IF user chose "📤 Review PR"** (Team mode):
1766
+ - Print:
1767
+ ```
1768
+ 📤 Opening PR for review
1769
+
1770
+ PR #$PR_NUMBER: Ready for Review
1771
+
1772
+ View in browser: gh pr view $PR_NUMBER --web
1773
+
1774
+ After approval, merge with: gh pr merge $PR_NUMBER --squash
1775
+ ```
1776
+
1777
+ **IF user chose "🔧 Continue Development"** (Personal mode):
1778
+ - Print:
1779
+ ```
1780
+ 🔧 Continuing development
1781
+
1782
+ Current branch: $CURRENT_BRANCH
1783
+
1784
+ Your changes are committed. Continue implementing features.
1785
+ ```
1786
+
1787
+ **IF user chose "🎯 Project Overview"**:
1788
+ - Print:
1789
+ ```
1790
+ 🎯 Project Overview
1791
+
1792
+ Sync reports: .moai/reports/
1793
+ SPEC documents: .moai/specs/
1794
+ TAG index: .moai/indexes/tags.db
1795
+
1796
+ Quick status check: /alfred:3-sync status
1797
+ ```
1798
+
1799
+ 6. **Print final message**:
1800
+ ```
1801
+ ✨ Thank you for using MoAI-ADK!
1802
+
1803
+ For more information:
1804
+ - Skill("moai-alfred-dev-guide")
1805
+ - CLAUDE.md in project root
1806
+ ```
1807
+
1808
+ **Result**: User informed of completion. Next action suggested.
1809
+
1810
+ **Next step**: Command complete. Exit.
1811
+
1812
+ ---
1813
+
1814
+ ## 🚨 STEP 4: Graceful Exit (User Aborted or Modified)
1815
+
1816
+ **Your task**: Handle user abortion or modification requests gracefully.
1817
+
1818
+ **This step is reached when**:
1819
+ - User chose "❌ Abort" in STEP 1.6
1820
+ - User chose "🔄 Request Modifications" in STEP 1.6
1821
+
1822
+ **Steps**:
1823
+
1824
+ 1. **Read user decision**:
1825
+ - Read variable: `$USER_DECISION["0"]`
1826
+
1827
+ 2. **IF user chose "❌ Abort"**:
1828
+ - Print abort message:
1829
+ ```
1830
+ ═══════════════════════════════════════════════════════
1831
+ ❌ Synchronization Aborted
1832
+ ═══════════════════════════════════════════════════════
1833
+
1834
+ No changes were made to:
1835
+ - Documents
1836
+ - Git history
1837
+ - Branch state
1838
+
1839
+ Your project remains in its current state.
1840
+
1841
+ You can retry synchronization anytime with:
1842
+ /alfred:3-sync [mode]
1843
+
1844
+ ═══════════════════════════════════════════════════════
1845
+ ```
1846
+ - **Exit command** with exit code 0
1847
+
1848
+ 3. **IF user chose "🔄 Request Modifications"**:
1849
+ - Print:
1850
+ ```
1851
+ 🔄 Re-analyzing with modifications...
1852
+ ```
1853
+ - **Go back to STEP 1.5** with `$MODIFICATION_REQUEST` applied
1854
+
1855
+ **Result**: Command exits gracefully or re-runs analysis.
1856
+
1857
+ **Next step**: Exit or STEP 1.5
1858
+
1859
+ ---
1860
+
1861
+ ## 📚 Mode-Specific Execution Summary
1862
+
1863
+ ### Auto Mode (default)
1864
+
1865
+ **Command**: `/alfred:3-sync` or `/alfred:3-sync auto`
1866
+
1867
+ **Behavior**:
1868
+ - Smart selective synchronization based on Git changes
1869
+ - Only changed files and related documents are updated
1870
+ - Quick execution for daily workflow
1871
+ - PR Ready transition in Team mode
1872
+
1873
+ **Best for**: Daily development workflow
1874
+
1875
+ ---
1876
+
1877
+ ### Force Mode
1878
+
1879
+ **Command**: `/alfred:3-sync force`
1880
+
1881
+ **Behavior**:
1882
+ - Full project re-synchronization
1883
+ - All documents regenerated
1884
+ - All TAG chains re-verified
1885
+ - Longer execution time
1886
+
1887
+ **Best for**: Error recovery, major refactoring, periodic full sync
1888
+
1889
+ ---
1890
+
1891
+ ### Status Mode
1892
+
1893
+ **Command**: `/alfred:3-sync status`
1894
+
1895
+ **Behavior**:
1896
+ - Quick status check only
1897
+ - No synchronization performed
1898
+ - Reports TAG system health
1899
+ - Lists changed files since last sync
1900
+
1901
+ **Best for**: Quick health check before starting work
1902
+
1903
+ ---
1904
+
1905
+ ### Project Mode
1906
+
1907
+ **Command**: `/alfred:3-sync project`
1908
+
1909
+ **Behavior**:
1910
+ - Integrated project-wide synchronization
1911
+ - README.md updated with full feature list
1912
+ - docs/architecture.md updated
1913
+ - docs/api/ unified
1914
+ - .moai/indexes/ rebuilt
1915
+
1916
+ **Best for**: Milestone completion, periodic integrated sync
1917
+
1918
+ ---
1919
+
1920
+ ## 🏗️ Agent Collaboration Architecture
1921
+
1922
+ ### Separation of Concerns
1923
+
1924
+ **doc-syncer Agent** (STEP 2):
1925
+ - Living Document synchronization
1926
+ - @TAG system updates
1927
+ - SPEC-Code alignment
1928
+ - Domain-specific routing
1929
+ - Sync report generation
1930
+
1931
+ **git-manager Agent** (STEP 3):
1932
+ - Git commit operations
1933
+ - PR status transitions
1934
+ - PR auto-merge (if requested)
1935
+ - Branch cleanup
1936
+ - GitHub CLI integration
1937
+
1938
+ **Single Responsibility Principle**:
1939
+ - doc-syncer does NOT touch Git
1940
+ - git-manager does NOT touch documents
1941
+ - Clear handoff between STEP 2 and STEP 3
1942
+
1943
+ ---
1944
+
1945
+ ## 🔗 TAG System Verification
1946
+
1947
+ ### Direct Code Scanning
1948
+
1949
+ **Method**: `rg '@TAG' -n src/ tests/`
1950
+
1951
+ **Why**: Direct code scanning ensures accurate TAG counting without relying on index files.
1952
+
1953
+ **Verification points**:
1954
+ - @SPEC TAG locations (.moai/specs/)
1955
+ - @TEST TAG locations (tests/)
1956
+ - @CODE TAG locations (src/)
1957
+ - @DOC TAG locations (docs/)
1958
+
1959
+ **Integrity checks**:
1960
+ - Orphan @CODE TAGs (no matching @SPEC)
1961
+ - Orphan @SPEC TAGs (no matching @CODE)
1962
+ - Broken references
1963
+ - Duplicate TAGs
1964
+
1965
+ ---
1966
+
1967
+ ## 🎯 Integration with MoAI-ADK Workflow
1968
+
1969
+ ### 4-Step Workflow Position
1970
+
1971
+ This command is **STEP 4** (Report & Commit):
1972
+
1973
+ 1. **/alfred:1-plan** → SPEC creation
1974
+ 2. **/alfred:2-run** → TDD implementation
1975
+ 3. **/alfred:3-sync** → **Document sync + PR (this command)**
1976
+ 4. Cycle complete → Start new SPEC
1977
+
1978
+ ### Conditional Report Generation
1979
+
1980
+ **Follows CLAUDE.md guidance**:
1981
+ - Reports generated ONLY when explicitly requested
1982
+ - Sync report is REQUIRED (always generated)
1983
+ - Domain-specific reports OPTIONAL (only if domains detected)
1984
+
1985
+ ---
1986
+
1987
+ ## ⚙️ Environment Dependencies
1988
+
1989
+ **Required**:
1990
+ - Git repository
561
1991
  - MoAI-ADK project structure (.moai/, .claude/)
562
- - TDD implementation completion status
563
- - Compliance with TRUST 5 principles
1992
+ - Python3 (for TAG verification scripts)
564
1993
 
565
- **Limitations:**
1994
+ **Optional**:
1995
+ - gh CLI (for GitHub PR integration)
1996
+ - Domain-specific experts (for domain routing)
566
1997
 
567
- - TAG verification is based on file existence
568
- - PR automatic conversion only works in gh CLI environment
569
- - Coverage figures need to be measured separately
1998
+ **Graceful degradation**:
1999
+ - Works without gh CLI (skips PR features)
2000
+ - Works without Python3 (limited TAG checks)
2001
+ - Works without domain experts (uses generic templates)
570
2002
 
571
2003
  ---
572
2004
 
573
- ## 🧠 Context Management
2005
+ ## 🎓 Best Practices
2006
+
2007
+ ### When to Use Each Mode
2008
+
2009
+ **Use auto mode** (default):
2010
+ - Daily development workflow
2011
+ - Single SPEC implementation complete
2012
+ - Quick sync after code changes
2013
+
2014
+ **Use force mode**:
2015
+ - After major refactoring
2016
+ - Error recovery (TAG system broken)
2017
+ - Periodic full re-sync (weekly/monthly)
2018
+
2019
+ **Use status mode**:
2020
+ - Before starting work (health check)
2021
+ - Quick overview of sync needs
2022
+ - No changes to files
2023
+
2024
+ **Use project mode**:
2025
+ - Milestone completion
2026
+ - Release preparation
2027
+ - Integrated documentation update
2028
+
2029
+ ### Performance Tips
2030
+
2031
+ **Use --auto-merge for fast iteration**:
2032
+ - Automatically merges PR
2033
+ - Cleans up branches
2034
+ - Returns to develop
2035
+ - Ready for next /alfred:1-plan immediately
2036
+
2037
+ **Start new session after sync**:
2038
+ - Use /clear or /new command
2039
+ - Reduces context size
2040
+ - Improves performance for next cycle
2041
+
2042
+ ---
2043
+
2044
+ ## 🔍 Troubleshooting
2045
+
2046
+ ### TAG Verification Issues
2047
+
2048
+ **Problem**: Orphan TAGs detected
2049
+
2050
+ **Solution**:
2051
+ 1. Review sync report: `.moai/reports/sync-report-latest.md`
2052
+ 2. Manually fix orphan TAGs in code
2053
+ 3. Re-run: `/alfred:3-sync force`
2054
+
2055
+ ### PR Transition Failed
2056
+
2057
+ **Problem**: gh CLI error
2058
+
2059
+ **Solution**:
2060
+ 1. Check gh authentication: `gh auth status`
2061
+ 2. Verify PR exists: `gh pr view`
2062
+ 3. Manual transition: `gh pr ready [PR_NUMBER]`
2063
+
2064
+ ### Merge Conflicts
2065
+
2066
+ **Problem**: Cannot auto-merge due to conflicts
2067
+
2068
+ **Solution**:
2069
+ 1. Fetch latest: `git fetch origin develop`
2070
+ 2. Merge develop: `git merge origin/develop`
2071
+ 3. Resolve conflicts
2072
+ 4. Re-run: `/alfred:3-sync`
2073
+
2074
+ ---
574
2075
 
575
- > For more information: `.moai/memory/development-guide.md` - see section "Context Engineering"
2076
+ ## 📖 Related Documentation
576
2077
 
577
- ### Core strategy of this command
2078
+ **Skills**:
2079
+ - `Skill("moai-alfred-tag-scanning")` - TAG system details
2080
+ - `Skill("moai-alfred-git-workflow")` - Git operations
2081
+ - `Skill("moai-alfred-trust-validation")` - Quality gates
2082
+ - `Skill("moai-alfred-ask-user-questions")` - TUI interactions
578
2083
 
579
- **Load first**: `.moai/reports/sync-report-latest.md` (old sync state)
2084
+ **Workflows**:
2085
+ - CLAUDE.md - Alfred 4-step workflow
2086
+ - `.moai/docs/workflows/alfred-3-sync.md` - Detailed workflow
580
2087
 
581
- **Recommendation**: Document synchronization is complete. Now that the entire MoAI-ADK cycle (1-spec → 2-build → 3-sync) has been completed, start a new conversation session with the `/clear` or `/new` command before developing the next feature.
2088
+ **Configuration**:
2089
+ - `.moai/config.json` - Project settings
2090
+ - `.claude/settings.json` - Claude Code settings
582
2091
 
583
2092
  ---
584
2093
 
585
- **Aims to improve code-document consistency and ensure @TAG traceability by linking with the doc-syncer subagent.**
2094
+ **Version**: 3.0.0 (Fully Imperative)
2095
+ **Last Updated**: 2025-01-04
2096
+ **Pattern**: Pure command-driven, zero Python pseudo-code, step-by-step execution flow