moai-adk 0.15.0__py3-none-any.whl → 0.25.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of moai-adk might be problematic. Click here for more details.

Files changed (417) hide show
  1. moai_adk/__init__.py +1 -2
  2. moai_adk/__main__.py +85 -2
  3. moai_adk/cli/__init__.py +0 -1
  4. moai_adk/cli/commands/__init__.py +0 -1
  5. moai_adk/cli/commands/analyze.py +127 -0
  6. moai_adk/cli/commands/backup.py +5 -3
  7. moai_adk/cli/commands/doctor.py +35 -11
  8. moai_adk/cli/commands/improve_user_experience.py +348 -0
  9. moai_adk/cli/commands/init.py +150 -23
  10. moai_adk/cli/commands/language.py +269 -0
  11. moai_adk/cli/commands/migrate.py +158 -0
  12. moai_adk/cli/commands/status.py +13 -12
  13. moai_adk/cli/commands/update.py +364 -60
  14. moai_adk/cli/commands/validate_links.py +118 -0
  15. moai_adk/cli/main.py +3 -2
  16. moai_adk/cli/prompts/init_prompts.py +79 -82
  17. moai_adk/core/__init__.py +0 -1
  18. moai_adk/core/analysis/__init__.py +9 -0
  19. moai_adk/core/analysis/session_analyzer.py +439 -0
  20. moai_adk/core/claude_integration.py +421 -0
  21. moai_adk/core/command_helpers.py +270 -0
  22. moai_adk/core/config/__init__.py +6 -0
  23. moai_adk/core/config/auto_spec_config.py +346 -0
  24. moai_adk/core/config/migration.py +133 -12
  25. moai_adk/core/context_manager.py +279 -0
  26. moai_adk/core/diagnostics/slash_commands.py +0 -1
  27. moai_adk/core/error_recovery_system.py +1289 -0
  28. moai_adk/core/git/__init__.py +0 -1
  29. moai_adk/core/git/branch.py +0 -1
  30. moai_adk/core/git/branch_manager.py +4 -4
  31. moai_adk/core/git/checkpoint.py +1 -5
  32. moai_adk/core/git/commit.py +0 -1
  33. moai_adk/core/git/event_detector.py +3 -5
  34. moai_adk/core/git/manager.py +0 -1
  35. moai_adk/core/hooks/post_tool_auto_spec_completion.py +925 -0
  36. moai_adk/core/integration/__init__.py +22 -0
  37. moai_adk/core/integration/engine.py +169 -0
  38. moai_adk/core/integration/integration_tester.py +225 -0
  39. moai_adk/core/integration/models.py +88 -0
  40. moai_adk/core/integration/utils.py +211 -0
  41. moai_adk/core/issue_creator.py +28 -18
  42. moai_adk/core/language_config.py +202 -0
  43. moai_adk/core/language_validator.py +556 -0
  44. moai_adk/core/mcp/setup.py +113 -0
  45. moai_adk/core/migration/__init__.py +18 -0
  46. moai_adk/core/migration/backup_manager.py +208 -0
  47. moai_adk/core/migration/file_migrator.py +218 -0
  48. moai_adk/core/migration/version_detector.py +143 -0
  49. moai_adk/core/migration/version_migrator.py +228 -0
  50. moai_adk/core/performance/__init__.py +6 -0
  51. moai_adk/core/performance/cache_system.py +318 -0
  52. moai_adk/core/performance/parallel_processor.py +116 -0
  53. moai_adk/core/project/__init__.py +0 -1
  54. moai_adk/core/project/backup_utils.py +2 -7
  55. moai_adk/core/project/checker.py +3 -3
  56. moai_adk/core/project/detector.py +20 -40
  57. moai_adk/core/project/initializer.py +42 -17
  58. moai_adk/core/project/phase_executor.py +415 -58
  59. moai_adk/core/project/validator.py +6 -25
  60. moai_adk/core/quality/__init__.py +1 -1
  61. moai_adk/core/quality/trust_checker.py +64 -110
  62. moai_adk/core/quality/validators/__init__.py +1 -1
  63. moai_adk/core/quality/validators/base_validator.py +1 -1
  64. moai_adk/core/rollback_manager.py +993 -0
  65. moai_adk/core/session_manager.py +667 -0
  66. moai_adk/core/spec/confidence_scoring.py +749 -0
  67. moai_adk/core/spec/ears_template_engine.py +1182 -0
  68. moai_adk/core/spec/quality_validator.py +721 -0
  69. moai_adk/core/spec_status_manager.py +488 -0
  70. moai_adk/core/template/__init__.py +0 -1
  71. moai_adk/core/template/backup.py +41 -1
  72. moai_adk/core/template/config.py +11 -12
  73. moai_adk/core/template/languages.py +0 -1
  74. moai_adk/core/template/merger.py +79 -22
  75. moai_adk/core/template/processor.py +614 -40
  76. moai_adk/core/template_engine.py +36 -27
  77. moai_adk/foundation/git/commit_templates.py +565 -0
  78. moai_adk/foundation/trust/trust_principles.py +725 -0
  79. moai_adk/foundation/trust/validation_checklist.py +1678 -0
  80. moai_adk/statusline/__init__.py +38 -0
  81. moai_adk/statusline/alfred_detector.py +107 -0
  82. moai_adk/statusline/config.py +364 -0
  83. moai_adk/statusline/enhanced_output_style_detector.py +364 -0
  84. moai_adk/statusline/git_collector.py +190 -0
  85. moai_adk/statusline/main.py +228 -0
  86. moai_adk/statusline/metrics_tracker.py +78 -0
  87. moai_adk/statusline/renderer.py +327 -0
  88. moai_adk/statusline/update_checker.py +135 -0
  89. moai_adk/statusline/version_reader.py +647 -0
  90. moai_adk/templates/.git-hooks/pre-commit +66 -0
  91. moai_adk/templates/.git-hooks/pre-push +116 -4
  92. moai_adk/templates/.github/workflows/moai-gitflow.yml +1 -7
  93. moai_adk/templates/.github/workflows/spec-issue-sync.yml +0 -1
  94. moai_adk/templates/.gitignore +44 -0
  95. moai_adk/templates/.mcp.json +22 -0
  96. moai_adk/templates/CLAUDE.md +450 -1071
  97. moai_adk/utils/__init__.py +0 -1
  98. moai_adk/utils/banner.py +0 -1
  99. moai_adk/utils/common.py +308 -0
  100. moai_adk/utils/link_validator.py +249 -0
  101. moai_adk/utils/logger.py +4 -9
  102. moai_adk/utils/safe_file_reader.py +210 -0
  103. moai_adk/utils/user_experience.py +531 -0
  104. moai_adk-0.25.4.dist-info/METADATA +2279 -0
  105. moai_adk-0.25.4.dist-info/RECORD +112 -0
  106. moai_adk/core/tags/__init__.py +0 -86
  107. moai_adk/core/tags/ci_validator.py +0 -463
  108. moai_adk/core/tags/cli.py +0 -283
  109. moai_adk/core/tags/generator.py +0 -109
  110. moai_adk/core/tags/inserter.py +0 -99
  111. moai_adk/core/tags/mapper.py +0 -126
  112. moai_adk/core/tags/parser.py +0 -76
  113. moai_adk/core/tags/pre_commit_validator.py +0 -393
  114. moai_adk/core/tags/reporter.py +0 -956
  115. moai_adk/core/tags/tags.py +0 -149
  116. moai_adk/core/tags/validator.py +0 -897
  117. moai_adk/templates/.claude/agents/alfred/backend-expert.md +0 -319
  118. moai_adk/templates/.claude/agents/alfred/cc-manager.md +0 -316
  119. moai_adk/templates/.claude/agents/alfred/debug-helper.md +0 -208
  120. moai_adk/templates/.claude/agents/alfred/devops-expert.md +0 -464
  121. moai_adk/templates/.claude/agents/alfred/doc-syncer.md +0 -214
  122. moai_adk/templates/.claude/agents/alfred/frontend-expert.md +0 -357
  123. moai_adk/templates/.claude/agents/alfred/git-manager.md +0 -406
  124. moai_adk/templates/.claude/agents/alfred/implementation-planner.md +0 -423
  125. moai_adk/templates/.claude/agents/alfred/project-manager.md +0 -312
  126. moai_adk/templates/.claude/agents/alfred/quality-gate.md +0 -343
  127. moai_adk/templates/.claude/agents/alfred/skill-factory.md +0 -865
  128. moai_adk/templates/.claude/agents/alfred/spec-builder.md +0 -392
  129. moai_adk/templates/.claude/agents/alfred/tag-agent.md +0 -361
  130. moai_adk/templates/.claude/agents/alfred/tdd-implementer.md +0 -428
  131. moai_adk/templates/.claude/agents/alfred/trust-checker.md +0 -375
  132. moai_adk/templates/.claude/agents/alfred/ui-ux-expert.md +0 -571
  133. moai_adk/templates/.claude/commands/alfred/0-project.md +0 -1525
  134. moai_adk/templates/.claude/commands/alfred/1-plan.md +0 -802
  135. moai_adk/templates/.claude/commands/alfred/2-run.md +0 -709
  136. moai_adk/templates/.claude/commands/alfred/3-sync.md +0 -1009
  137. moai_adk/templates/.claude/commands/alfred/9-feedback.md +0 -149
  138. moai_adk/templates/.claude/hooks/alfred/core/project.py +0 -748
  139. moai_adk/templates/.claude/hooks/alfred/core/timeout.py +0 -136
  140. moai_adk/templates/.claude/hooks/alfred/core/ttl_cache.py +0 -108
  141. moai_adk/templates/.claude/hooks/alfred/core/version_cache.py +0 -198
  142. moai_adk/templates/.claude/hooks/alfred/handlers/__init__.py +0 -29
  143. moai_adk/templates/.claude/hooks/alfred/post_tool__log_changes.py +0 -94
  144. moai_adk/templates/.claude/hooks/alfred/pre_tool__auto_checkpoint.py +0 -100
  145. moai_adk/templates/.claude/hooks/alfred/session_end__cleanup.py +0 -94
  146. moai_adk/templates/.claude/hooks/alfred/session_start__show_project_info.py +0 -94
  147. moai_adk/templates/.claude/hooks/alfred/shared/core/__init__.py +0 -170
  148. moai_adk/templates/.claude/hooks/alfred/shared/core/checkpoint.py +0 -271
  149. moai_adk/templates/.claude/hooks/alfred/shared/core/context.py +0 -67
  150. moai_adk/templates/.claude/hooks/alfred/shared/core/project.py +0 -749
  151. moai_adk/templates/.claude/hooks/alfred/shared/core/tags.py +0 -230
  152. moai_adk/templates/.claude/hooks/alfred/shared/core/version_cache.py +0 -198
  153. moai_adk/templates/.claude/hooks/alfred/shared/handlers/__init__.py +0 -21
  154. moai_adk/templates/.claude/hooks/alfred/shared/handlers/notification.py +0 -154
  155. moai_adk/templates/.claude/hooks/alfred/shared/handlers/session.py +0 -174
  156. moai_adk/templates/.claude/hooks/alfred/shared/handlers/tool.py +0 -87
  157. moai_adk/templates/.claude/hooks/alfred/shared/handlers/user.py +0 -61
  158. moai_adk/templates/.claude/hooks/alfred/user_prompt__jit_load_docs.py +0 -112
  159. moai_adk/templates/.claude/hooks/alfred/utils/__init__.py +0 -1
  160. moai_adk/templates/.claude/hooks/alfred/utils/timeout.py +0 -161
  161. moai_adk/templates/.claude/settings.json +0 -144
  162. moai_adk/templates/.claude/skills/moai-alfred-agent-guide/SKILL.md +0 -70
  163. moai_adk/templates/.claude/skills/moai-alfred-agent-guide/examples.md +0 -62
  164. moai_adk/templates/.claude/skills/moai-alfred-agent-guide/reference.md +0 -242
  165. moai_adk/templates/.claude/skills/moai-alfred-config-schema/SKILL.md +0 -56
  166. moai_adk/templates/.claude/skills/moai-alfred-config-schema/examples.md +0 -28
  167. moai_adk/templates/.claude/skills/moai-alfred-config-schema/reference.md +0 -444
  168. moai_adk/templates/.claude/skills/moai-alfred-context-budget/SKILL.md +0 -62
  169. moai_adk/templates/.claude/skills/moai-alfred-context-budget/examples.md +0 -28
  170. moai_adk/templates/.claude/skills/moai-alfred-context-budget/reference.md +0 -405
  171. moai_adk/templates/.claude/skills/moai-alfred-dev-guide/SKILL.md +0 -51
  172. moai_adk/templates/.claude/skills/moai-alfred-dev-guide/examples.md +0 -355
  173. moai_adk/templates/.claude/skills/moai-alfred-dev-guide/reference.md +0 -239
  174. moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/SKILL.md +0 -113
  175. moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/examples.md +0 -29
  176. moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/reference.md +0 -28
  177. moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/SKILL.md +0 -323
  178. moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/examples.md +0 -286
  179. moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/reference.md +0 -126
  180. moai_adk/templates/.claude/skills/moai-alfred-git-workflow/SKILL.md +0 -122
  181. moai_adk/templates/.claude/skills/moai-alfred-git-workflow/examples.md +0 -29
  182. moai_adk/templates/.claude/skills/moai-alfred-git-workflow/reference.md +0 -29
  183. moai_adk/templates/.claude/skills/moai-alfred-gitflow-policy/SKILL.md +0 -74
  184. moai_adk/templates/.claude/skills/moai-alfred-gitflow-policy/examples.md +0 -4
  185. moai_adk/templates/.claude/skills/moai-alfred-gitflow-policy/reference.md +0 -269
  186. moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/SKILL.md +0 -237
  187. moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/examples.md +0 -615
  188. moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/reference.md +0 -653
  189. moai_adk/templates/.claude/skills/moai-alfred-issue-labels/SKILL.md +0 -19
  190. moai_adk/templates/.claude/skills/moai-alfred-issue-labels/examples.md +0 -4
  191. moai_adk/templates/.claude/skills/moai-alfred-issue-labels/reference.md +0 -150
  192. moai_adk/templates/.claude/skills/moai-alfred-language-detection/SKILL.md +0 -113
  193. moai_adk/templates/.claude/skills/moai-alfred-language-detection/examples.md +0 -29
  194. moai_adk/templates/.claude/skills/moai-alfred-language-detection/reference.md +0 -28
  195. moai_adk/templates/.claude/skills/moai-alfred-persona-roles/SKILL.md +0 -198
  196. moai_adk/templates/.claude/skills/moai-alfred-persona-roles/examples.md +0 -431
  197. moai_adk/templates/.claude/skills/moai-alfred-persona-roles/reference.md +0 -141
  198. moai_adk/templates/.claude/skills/moai-alfred-practices/SKILL.md +0 -89
  199. moai_adk/templates/.claude/skills/moai-alfred-practices/examples.md +0 -122
  200. moai_adk/templates/.claude/skills/moai-alfred-practices/reference.md +0 -369
  201. moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/SKILL.md +0 -508
  202. moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/examples.md +0 -481
  203. moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/reference.md +0 -100
  204. moai_adk/templates/.claude/skills/moai-alfred-reporting/SKILL.md +0 -273
  205. moai_adk/templates/.claude/skills/moai-alfred-rules/SKILL.md +0 -77
  206. moai_adk/templates/.claude/skills/moai-alfred-rules/examples.md +0 -265
  207. moai_adk/templates/.claude/skills/moai-alfred-rules/reference.md +0 -539
  208. moai_adk/templates/.claude/skills/moai-alfred-session-state/SKILL.md +0 -19
  209. moai_adk/templates/.claude/skills/moai-alfred-session-state/examples.md +0 -4
  210. moai_adk/templates/.claude/skills/moai-alfred-session-state/reference.md +0 -84
  211. moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/README.md +0 -137
  212. moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/SKILL.md +0 -219
  213. moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/examples/validate-spec.sh +0 -161
  214. moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/examples.md +0 -541
  215. moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/reference.md +0 -622
  216. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-extended/SKILL.md +0 -115
  217. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-extended/examples.md +0 -4
  218. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-extended/reference.md +0 -348
  219. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/SKILL.md +0 -113
  220. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/examples.md +0 -29
  221. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/reference.md +0 -28
  222. moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/SKILL.md +0 -113
  223. moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/examples.md +0 -29
  224. moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/reference.md +0 -28
  225. moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/SKILL.md +0 -19
  226. moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/examples.md +0 -4
  227. moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/reference.md +0 -211
  228. moai_adk/templates/.claude/skills/moai-alfred-trust-validation/SKILL.md +0 -113
  229. moai_adk/templates/.claude/skills/moai-alfred-trust-validation/examples.md +0 -29
  230. moai_adk/templates/.claude/skills/moai-alfred-trust-validation/reference.md +0 -28
  231. moai_adk/templates/.claude/skills/moai-alfred-workflow/SKILL.md +0 -288
  232. moai_adk/templates/.claude/skills/moai-cc-agents/SKILL.md +0 -269
  233. moai_adk/templates/.claude/skills/moai-cc-agents/templates/agent-template.md +0 -32
  234. moai_adk/templates/.claude/skills/moai-cc-claude-md/SKILL.md +0 -298
  235. moai_adk/templates/.claude/skills/moai-cc-claude-md/templates/CLAUDE-template.md +0 -26
  236. moai_adk/templates/.claude/skills/moai-cc-commands/SKILL.md +0 -307
  237. moai_adk/templates/.claude/skills/moai-cc-commands/templates/command-template.md +0 -21
  238. moai_adk/templates/.claude/skills/moai-cc-hooks/SKILL.md +0 -252
  239. moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/pre-bash-check.sh +0 -19
  240. moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/preserve-permissions.sh +0 -19
  241. moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/validate-bash-command.py +0 -24
  242. moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/SKILL.md +0 -199
  243. moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/templates/settings-mcp-template.json +0 -39
  244. moai_adk/templates/.claude/skills/moai-cc-memory/SKILL.md +0 -316
  245. moai_adk/templates/.claude/skills/moai-cc-memory/templates/session-summary-template.md +0 -18
  246. moai_adk/templates/.claude/skills/moai-cc-settings/SKILL.md +0 -263
  247. moai_adk/templates/.claude/skills/moai-cc-settings/templates/settings-complete-template.json +0 -30
  248. moai_adk/templates/.claude/skills/moai-cc-skill-descriptions/SKILL.md +0 -19
  249. moai_adk/templates/.claude/skills/moai-cc-skill-descriptions/examples.md +0 -4
  250. moai_adk/templates/.claude/skills/moai-cc-skill-descriptions/reference.md +0 -218
  251. moai_adk/templates/.claude/skills/moai-cc-skill-factory/CHECKLIST.md +0 -482
  252. moai_adk/templates/.claude/skills/moai-cc-skill-factory/EXAMPLES.md +0 -278
  253. moai_adk/templates/.claude/skills/moai-cc-skill-factory/INTERACTIVE-DISCOVERY.md +0 -524
  254. moai_adk/templates/.claude/skills/moai-cc-skill-factory/METADATA.md +0 -477
  255. moai_adk/templates/.claude/skills/moai-cc-skill-factory/PARALLEL-ANALYSIS-REPORT.md +0 -429
  256. moai_adk/templates/.claude/skills/moai-cc-skill-factory/PYTHON-VERSION-MATRIX.md +0 -391
  257. moai_adk/templates/.claude/skills/moai-cc-skill-factory/SKILL-FACTORY-WORKFLOW.md +0 -431
  258. moai_adk/templates/.claude/skills/moai-cc-skill-factory/SKILL-UPDATE-ADVISOR.md +0 -577
  259. moai_adk/templates/.claude/skills/moai-cc-skill-factory/SKILL.md +0 -271
  260. moai_adk/templates/.claude/skills/moai-cc-skill-factory/STEP-BY-STEP-GUIDE.md +0 -466
  261. moai_adk/templates/.claude/skills/moai-cc-skill-factory/STRUCTURE.md +0 -583
  262. moai_adk/templates/.claude/skills/moai-cc-skill-factory/WEB-RESEARCH.md +0 -526
  263. moai_adk/templates/.claude/skills/moai-cc-skill-factory/reference.md +0 -465
  264. moai_adk/templates/.claude/skills/moai-cc-skill-factory/scripts/generate-structure.sh +0 -328
  265. moai_adk/templates/.claude/skills/moai-cc-skill-factory/scripts/validate-skill.sh +0 -312
  266. moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/SKILL_TEMPLATE.md +0 -245
  267. moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/examples-template.md +0 -285
  268. moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/reference-template.md +0 -278
  269. moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/scripts-template.sh +0 -303
  270. moai_adk/templates/.claude/skills/moai-cc-skills/SKILL.md +0 -291
  271. moai_adk/templates/.claude/skills/moai-cc-skills/templates/SKILL-template.md +0 -15
  272. moai_adk/templates/.claude/skills/moai-design-systems/SKILL.md +0 -802
  273. moai_adk/templates/.claude/skills/moai-design-systems/examples.md +0 -1238
  274. moai_adk/templates/.claude/skills/moai-design-systems/reference.md +0 -673
  275. moai_adk/templates/.claude/skills/moai-domain-backend/SKILL.md +0 -290
  276. moai_adk/templates/.claude/skills/moai-domain-backend/examples.md +0 -1633
  277. moai_adk/templates/.claude/skills/moai-domain-backend/reference.md +0 -660
  278. moai_adk/templates/.claude/skills/moai-domain-cli-tool/SKILL.md +0 -123
  279. moai_adk/templates/.claude/skills/moai-domain-cli-tool/examples.md +0 -29
  280. moai_adk/templates/.claude/skills/moai-domain-cli-tool/reference.md +0 -30
  281. moai_adk/templates/.claude/skills/moai-domain-data-science/SKILL.md +0 -123
  282. moai_adk/templates/.claude/skills/moai-domain-data-science/examples.md +0 -29
  283. moai_adk/templates/.claude/skills/moai-domain-data-science/reference.md +0 -30
  284. moai_adk/templates/.claude/skills/moai-domain-database/SKILL.md +0 -123
  285. moai_adk/templates/.claude/skills/moai-domain-database/examples.md +0 -29
  286. moai_adk/templates/.claude/skills/moai-domain-database/reference.md +0 -30
  287. moai_adk/templates/.claude/skills/moai-domain-devops/SKILL.md +0 -124
  288. moai_adk/templates/.claude/skills/moai-domain-devops/examples.md +0 -29
  289. moai_adk/templates/.claude/skills/moai-domain-devops/reference.md +0 -31
  290. moai_adk/templates/.claude/skills/moai-domain-frontend/SKILL.md +0 -128
  291. moai_adk/templates/.claude/skills/moai-domain-frontend/examples.md +0 -29
  292. moai_adk/templates/.claude/skills/moai-domain-frontend/reference.md +0 -31
  293. moai_adk/templates/.claude/skills/moai-domain-ml/SKILL.md +0 -123
  294. moai_adk/templates/.claude/skills/moai-domain-ml/examples.md +0 -29
  295. moai_adk/templates/.claude/skills/moai-domain-ml/reference.md +0 -30
  296. moai_adk/templates/.claude/skills/moai-domain-mobile-app/SKILL.md +0 -123
  297. moai_adk/templates/.claude/skills/moai-domain-mobile-app/examples.md +0 -29
  298. moai_adk/templates/.claude/skills/moai-domain-mobile-app/reference.md +0 -30
  299. moai_adk/templates/.claude/skills/moai-domain-security/SKILL.md +0 -123
  300. moai_adk/templates/.claude/skills/moai-domain-security/examples.md +0 -29
  301. moai_adk/templates/.claude/skills/moai-domain-security/reference.md +0 -30
  302. moai_adk/templates/.claude/skills/moai-domain-web-api/SKILL.md +0 -123
  303. moai_adk/templates/.claude/skills/moai-domain-web-api/examples.md +0 -29
  304. moai_adk/templates/.claude/skills/moai-domain-web-api/reference.md +0 -30
  305. moai_adk/templates/.claude/skills/moai-essentials-debug/SKILL.md +0 -303
  306. moai_adk/templates/.claude/skills/moai-essentials-debug/examples.md +0 -1064
  307. moai_adk/templates/.claude/skills/moai-essentials-debug/reference.md +0 -1047
  308. moai_adk/templates/.claude/skills/moai-essentials-perf/SKILL.md +0 -113
  309. moai_adk/templates/.claude/skills/moai-essentials-perf/examples.md +0 -29
  310. moai_adk/templates/.claude/skills/moai-essentials-perf/reference.md +0 -28
  311. moai_adk/templates/.claude/skills/moai-essentials-refactor/SKILL.md +0 -113
  312. moai_adk/templates/.claude/skills/moai-essentials-refactor/examples.md +0 -29
  313. moai_adk/templates/.claude/skills/moai-essentials-refactor/reference.md +0 -28
  314. moai_adk/templates/.claude/skills/moai-essentials-review/SKILL.md +0 -113
  315. moai_adk/templates/.claude/skills/moai-essentials-review/examples.md +0 -29
  316. moai_adk/templates/.claude/skills/moai-essentials-review/reference.md +0 -28
  317. moai_adk/templates/.claude/skills/moai-foundation-ears/SKILL.md +0 -116
  318. moai_adk/templates/.claude/skills/moai-foundation-ears/examples.md +0 -29
  319. moai_adk/templates/.claude/skills/moai-foundation-ears/reference.md +0 -28
  320. moai_adk/templates/.claude/skills/moai-foundation-git/SKILL.md +0 -122
  321. moai_adk/templates/.claude/skills/moai-foundation-git/examples.md +0 -29
  322. moai_adk/templates/.claude/skills/moai-foundation-git/reference.md +0 -29
  323. moai_adk/templates/.claude/skills/moai-foundation-langs/SKILL.md +0 -113
  324. moai_adk/templates/.claude/skills/moai-foundation-langs/examples.md +0 -29
  325. moai_adk/templates/.claude/skills/moai-foundation-langs/reference.md +0 -28
  326. moai_adk/templates/.claude/skills/moai-foundation-specs/SKILL.md +0 -113
  327. moai_adk/templates/.claude/skills/moai-foundation-specs/examples.md +0 -29
  328. moai_adk/templates/.claude/skills/moai-foundation-specs/reference.md +0 -28
  329. moai_adk/templates/.claude/skills/moai-foundation-tags/SKILL.md +0 -113
  330. moai_adk/templates/.claude/skills/moai-foundation-tags/examples.md +0 -29
  331. moai_adk/templates/.claude/skills/moai-foundation-tags/reference.md +0 -28
  332. moai_adk/templates/.claude/skills/moai-foundation-trust/SKILL.md +0 -307
  333. moai_adk/templates/.claude/skills/moai-foundation-trust/examples.md +0 -0
  334. moai_adk/templates/.claude/skills/moai-foundation-trust/reference.md +0 -1099
  335. moai_adk/templates/.claude/skills/moai-lang-c/SKILL.md +0 -124
  336. moai_adk/templates/.claude/skills/moai-lang-c/examples.md +0 -29
  337. moai_adk/templates/.claude/skills/moai-lang-c/reference.md +0 -31
  338. moai_adk/templates/.claude/skills/moai-lang-cpp/SKILL.md +0 -124
  339. moai_adk/templates/.claude/skills/moai-lang-cpp/examples.md +0 -29
  340. moai_adk/templates/.claude/skills/moai-lang-cpp/reference.md +0 -31
  341. moai_adk/templates/.claude/skills/moai-lang-csharp/SKILL.md +0 -123
  342. moai_adk/templates/.claude/skills/moai-lang-csharp/examples.md +0 -29
  343. moai_adk/templates/.claude/skills/moai-lang-csharp/reference.md +0 -30
  344. moai_adk/templates/.claude/skills/moai-lang-dart/SKILL.md +0 -123
  345. moai_adk/templates/.claude/skills/moai-lang-dart/examples.md +0 -29
  346. moai_adk/templates/.claude/skills/moai-lang-dart/reference.md +0 -30
  347. moai_adk/templates/.claude/skills/moai-lang-go/SKILL.md +0 -127
  348. moai_adk/templates/.claude/skills/moai-lang-go/examples.md +0 -29
  349. moai_adk/templates/.claude/skills/moai-lang-go/reference.md +0 -31
  350. moai_adk/templates/.claude/skills/moai-lang-java/SKILL.md +0 -126
  351. moai_adk/templates/.claude/skills/moai-lang-java/examples.md +0 -29
  352. moai_adk/templates/.claude/skills/moai-lang-java/reference.md +0 -31
  353. moai_adk/templates/.claude/skills/moai-lang-javascript/SKILL.md +0 -125
  354. moai_adk/templates/.claude/skills/moai-lang-javascript/examples.md +0 -29
  355. moai_adk/templates/.claude/skills/moai-lang-javascript/reference.md +0 -32
  356. moai_adk/templates/.claude/skills/moai-lang-kotlin/SKILL.md +0 -124
  357. moai_adk/templates/.claude/skills/moai-lang-kotlin/examples.md +0 -29
  358. moai_adk/templates/.claude/skills/moai-lang-kotlin/reference.md +0 -31
  359. moai_adk/templates/.claude/skills/moai-lang-php/SKILL.md +0 -126
  360. moai_adk/templates/.claude/skills/moai-lang-php/examples.md +0 -29
  361. moai_adk/templates/.claude/skills/moai-lang-php/reference.md +0 -30
  362. moai_adk/templates/.claude/skills/moai-lang-python/SKILL.md +0 -433
  363. moai_adk/templates/.claude/skills/moai-lang-python/examples.md +0 -624
  364. moai_adk/templates/.claude/skills/moai-lang-python/reference.md +0 -316
  365. moai_adk/templates/.claude/skills/moai-lang-r/SKILL.md +0 -123
  366. moai_adk/templates/.claude/skills/moai-lang-r/examples.md +0 -29
  367. moai_adk/templates/.claude/skills/moai-lang-r/reference.md +0 -30
  368. moai_adk/templates/.claude/skills/moai-lang-ruby/SKILL.md +0 -124
  369. moai_adk/templates/.claude/skills/moai-lang-ruby/examples.md +0 -29
  370. moai_adk/templates/.claude/skills/moai-lang-ruby/reference.md +0 -31
  371. moai_adk/templates/.claude/skills/moai-lang-rust/SKILL.md +0 -127
  372. moai_adk/templates/.claude/skills/moai-lang-rust/examples.md +0 -29
  373. moai_adk/templates/.claude/skills/moai-lang-rust/reference.md +0 -31
  374. moai_adk/templates/.claude/skills/moai-lang-scala/SKILL.md +0 -125
  375. moai_adk/templates/.claude/skills/moai-lang-scala/examples.md +0 -29
  376. moai_adk/templates/.claude/skills/moai-lang-scala/reference.md +0 -30
  377. moai_adk/templates/.claude/skills/moai-lang-shell/SKILL.md +0 -123
  378. moai_adk/templates/.claude/skills/moai-lang-shell/examples.md +0 -29
  379. moai_adk/templates/.claude/skills/moai-lang-shell/reference.md +0 -30
  380. moai_adk/templates/.claude/skills/moai-lang-sql/SKILL.md +0 -124
  381. moai_adk/templates/.claude/skills/moai-lang-sql/examples.md +0 -29
  382. moai_adk/templates/.claude/skills/moai-lang-sql/reference.md +0 -31
  383. moai_adk/templates/.claude/skills/moai-lang-swift/SKILL.md +0 -123
  384. moai_adk/templates/.claude/skills/moai-lang-swift/examples.md +0 -29
  385. moai_adk/templates/.claude/skills/moai-lang-swift/reference.md +0 -30
  386. moai_adk/templates/.claude/skills/moai-lang-typescript/SKILL.md +0 -133
  387. moai_adk/templates/.claude/skills/moai-lang-typescript/examples.md +0 -29
  388. moai_adk/templates/.claude/skills/moai-lang-typescript/reference.md +0 -34
  389. moai_adk/templates/.claude/skills/moai-project-documentation.md +0 -622
  390. moai_adk/templates/.github/workflows/c-tag-validation.yml +0 -11
  391. moai_adk/templates/.github/workflows/cpp-tag-validation.yml +0 -11
  392. moai_adk/templates/.github/workflows/csharp-tag-validation.yml +0 -11
  393. moai_adk/templates/.github/workflows/dart-tag-validation.yml +0 -11
  394. moai_adk/templates/.github/workflows/go-tag-validation.yml +0 -130
  395. moai_adk/templates/.github/workflows/java-tag-validation.yml +0 -11
  396. moai_adk/templates/.github/workflows/javascript-tag-validation.yml +0 -135
  397. moai_adk/templates/.github/workflows/kotlin-tag-validation.yml +0 -11
  398. moai_adk/templates/.github/workflows/php-tag-validation.yml +0 -11
  399. moai_adk/templates/.github/workflows/python-tag-validation.yml +0 -118
  400. moai_adk/templates/.github/workflows/release.yml +0 -118
  401. moai_adk/templates/.github/workflows/ruby-tag-validation.yml +0 -11
  402. moai_adk/templates/.github/workflows/rust-tag-validation.yml +0 -11
  403. moai_adk/templates/.github/workflows/shell-tag-validation.yml +0 -11
  404. moai_adk/templates/.github/workflows/swift-tag-validation.yml +0 -11
  405. moai_adk/templates/.github/workflows/tag-report.yml +0 -269
  406. moai_adk/templates/.github/workflows/tag-validation.yml +0 -186
  407. moai_adk/templates/.github/workflows/typescript-tag-validation.yml +0 -154
  408. moai_adk/templates/.moai/config.json +0 -115
  409. moai_adk/templates/workflows/go-tag-validation.yml +0 -30
  410. moai_adk/templates/workflows/javascript-tag-validation.yml +0 -41
  411. moai_adk/templates/workflows/python-tag-validation.yml +0 -42
  412. moai_adk/templates/workflows/typescript-tag-validation.yml +0 -31
  413. moai_adk-0.15.0.dist-info/METADATA +0 -3079
  414. moai_adk-0.15.0.dist-info/RECORD +0 -365
  415. {moai_adk-0.15.0.dist-info → moai_adk-0.25.4.dist-info}/WHEEL +0 -0
  416. {moai_adk-0.15.0.dist-info → moai_adk-0.25.4.dist-info}/entry_points.txt +0 -0
  417. {moai_adk-0.15.0.dist-info → moai_adk-0.25.4.dist-info}/licenses/LICENSE +0 -0
moai_adk/core/tags/cli.py DELETED
@@ -1,283 +0,0 @@
1
- #!/usr/bin/env python3
2
- # @CODE:DOC-TAG-004 | Component 3: CLI utility for TAG validation
3
- """CLI utility for moai-adk validate-tags command
4
-
5
- This module provides a command-line interface to the central TAG validator:
6
- - Validate files or directories
7
- - Generate reports in multiple formats (detailed, summary, JSON)
8
- - Support various validation modes (strict, custom patterns)
9
- - Save reports to files
10
-
11
- Usage:
12
- moai-adk validate-tags .
13
- moai-adk validate-tags --strict src/
14
- moai-adk validate-tags --format json --output report.json
15
- moai-adk validate-tags --no-duplicates --no-orphans
16
- """
17
-
18
- import argparse
19
- import sys
20
- from pathlib import Path
21
- from typing import Optional
22
-
23
- from .validator import (
24
- CentralValidationResult,
25
- CentralValidator,
26
- ValidationConfig,
27
- )
28
-
29
-
30
- def create_parser() -> argparse.ArgumentParser:
31
- """Create argument parser for CLI
32
-
33
- Returns:
34
- ArgumentParser with all CLI options
35
- """
36
- parser = argparse.ArgumentParser(
37
- prog="moai-adk validate-tags",
38
- description="Validate TAG annotations in MoAI-ADK projects",
39
- formatter_class=argparse.RawDescriptionHelpFormatter,
40
- epilog="""
41
- Examples:
42
- moai-adk validate-tags . # Validate entire project
43
- moai-adk validate-tags --strict src/ # Strict validation of src/
44
- moai-adk validate-tags --format json # JSON report output
45
- moai-adk validate-tags --output report.json # Save report to file
46
- moai-adk validate-tags --no-orphans # Disable orphan checking
47
- moai-adk validate-tags --file-types py,js,md # Validate specific file types
48
-
49
- Report Formats:
50
- detailed - Full report with all issues, locations, and suggestions (default)
51
- summary - Concise summary with statistics only
52
- json - Machine-readable JSON format
53
-
54
- Validation Modes:
55
- Normal - Errors block, warnings reported but pass
56
- Strict - Both errors and warnings block (use --strict flag)
57
- """
58
- )
59
-
60
- # Positional argument
61
- parser.add_argument(
62
- "path",
63
- nargs="?",
64
- default=".",
65
- help="Path to file or directory to validate (default: current directory)"
66
- )
67
-
68
- # Validation options
69
- parser.add_argument(
70
- "--strict",
71
- action="store_true",
72
- help="Treat warnings as errors (block on warnings)"
73
- )
74
-
75
- parser.add_argument(
76
- "--no-duplicates",
77
- action="store_true",
78
- help="Disable duplicate TAG checking"
79
- )
80
-
81
- parser.add_argument(
82
- "--no-orphans",
83
- action="store_true",
84
- help="Disable orphan TAG checking"
85
- )
86
-
87
- parser.add_argument(
88
- "--no-chain-check",
89
- action="store_true",
90
- help="Disable TAG chain integrity checking"
91
- )
92
-
93
- # File filtering options
94
- parser.add_argument(
95
- "--file-types",
96
- help="Comma-separated file types to validate (e.g., py,js,ts)"
97
- )
98
-
99
- parser.add_argument(
100
- "--ignore-patterns",
101
- help="Comma-separated glob patterns to ignore (e.g., .git/*,*.pyc)"
102
- )
103
-
104
- # Report options
105
- parser.add_argument(
106
- "--format",
107
- choices=["detailed", "summary", "json"],
108
- default="detailed",
109
- help="Report format (default: detailed)"
110
- )
111
-
112
- parser.add_argument(
113
- "--output",
114
- "-o",
115
- help="Output file path (default: stdout)"
116
- )
117
-
118
- # Quiet mode
119
- parser.add_argument(
120
- "--quiet",
121
- "-q",
122
- action="store_true",
123
- help="Suppress output, only return exit code"
124
- )
125
-
126
- # Version
127
- parser.add_argument(
128
- "--version",
129
- action="version",
130
- version="moai-adk 0.7.0"
131
- )
132
-
133
- return parser
134
-
135
-
136
- def validate_path(path_str: str) -> Optional[Path]:
137
- """Validate that path exists
138
-
139
- Args:
140
- path_str: Path string to validate
141
-
142
- Returns:
143
- Path object if valid, None otherwise
144
- """
145
- path = Path(path_str)
146
- if not path.exists():
147
- print(f"Error: Path does not exist: {path_str}", file=sys.stderr)
148
- return None
149
- return path
150
-
151
-
152
- def create_config_from_args(args: argparse.Namespace) -> ValidationConfig:
153
- """Create ValidationConfig from CLI arguments
154
-
155
- Args:
156
- args: Parsed command-line arguments
157
-
158
- Returns:
159
- ValidationConfig object
160
- """
161
- config = ValidationConfig(
162
- strict_mode=args.strict,
163
- check_duplicates=not args.no_duplicates,
164
- check_orphans=not args.no_orphans,
165
- check_chain_integrity=not args.no_chain_check,
166
- report_format=args.format
167
- )
168
-
169
- # Parse file types if provided
170
- if args.file_types:
171
- config.allowed_file_types = [
172
- ft.strip() for ft in args.file_types.split(",")
173
- ]
174
-
175
- # Parse ignore patterns if provided
176
- if args.ignore_patterns:
177
- config.ignore_patterns = [
178
- pattern.strip() for pattern in args.ignore_patterns.split(",")
179
- ]
180
-
181
- return config
182
-
183
-
184
- def run_validation(path: Path, config: ValidationConfig) -> CentralValidationResult:
185
- """Run validation on path
186
-
187
- Args:
188
- path: Path to validate (file or directory)
189
- config: ValidationConfig object
190
-
191
- Returns:
192
- CentralValidationResult
193
- """
194
- validator = CentralValidator(config=config)
195
-
196
- if path.is_file():
197
- result = validator.validate_files([str(path)])
198
- else:
199
- result = validator.validate_directory(str(path))
200
-
201
- return result
202
-
203
-
204
- def output_report(
205
- result: CentralValidationResult,
206
- validator: CentralValidator,
207
- format: str,
208
- output_file: Optional[str],
209
- quiet: bool
210
- ) -> None:
211
- """Output validation report
212
-
213
- Args:
214
- result: CentralValidationResult
215
- validator: CentralValidator instance
216
- format: Report format (detailed|summary|json)
217
- output_file: Output file path (None for stdout)
218
- quiet: Suppress output if True
219
- """
220
- if quiet:
221
- return
222
-
223
- # Generate report
224
- report = validator.create_report(result, format=format)
225
-
226
- # Output to file or stdout
227
- if output_file:
228
- try:
229
- with open(output_file, 'w') as f:
230
- f.write(report)
231
- print(f"Report saved to: {output_file}", file=sys.stderr)
232
- except Exception as e:
233
- print(f"Error writing report: {e}", file=sys.stderr)
234
- sys.exit(1)
235
- else:
236
- print(report)
237
-
238
-
239
- def main(argv: Optional[list] = None) -> int:
240
- """Main CLI entry point
241
-
242
- Args:
243
- argv: Command-line arguments (default: sys.argv[1:])
244
-
245
- Returns:
246
- Exit code (0 for success, 1 for failure)
247
- """
248
- parser = create_parser()
249
- args = parser.parse_args(argv)
250
-
251
- # Validate path
252
- path = validate_path(args.path)
253
- if path is None:
254
- return 1
255
-
256
- # Create configuration from args
257
- config = create_config_from_args(args)
258
-
259
- # Run validation
260
- try:
261
- result = run_validation(path, config)
262
- except Exception as e:
263
- print(f"Validation error: {e}", file=sys.stderr)
264
- return 1
265
-
266
- # Create validator for report generation
267
- validator = CentralValidator(config=config)
268
-
269
- # Output report
270
- output_report(
271
- result=result,
272
- validator=validator,
273
- format=args.format,
274
- output_file=args.output,
275
- quiet=args.quiet
276
- )
277
-
278
- # Return exit code
279
- return 0 if result.is_valid else 1
280
-
281
-
282
- if __name__ == "__main__":
283
- sys.exit(main())
@@ -1,109 +0,0 @@
1
- # @CODE:GEN-001, @CODE:GEN-002
2
- """TAG ID generation and duplicate detection.
3
-
4
- Generates sequential @DOC:DOMAIN-NNN identifiers and detects duplicates
5
- using ripgrep for performance.
6
-
7
- @SPEC:DOC-TAG-001: @DOC tag automatic generation infrastructure
8
- """
9
-
10
- import re
11
- import subprocess
12
- from typing import List
13
-
14
- # Domain validation: Must start with letter, alphanumeric + hyphens, end with alphanumeric
15
- DOMAIN_PATTERN = re.compile(r"^[A-Z]([A-Z0-9-]*[A-Z0-9])?$")
16
-
17
-
18
- def generate_doc_tag(domain: str, existing_ids: List[str]) -> str:
19
- """Generate next available @DOC tag ID for domain.
20
-
21
- Validates domain format (uppercase alphanumeric, hyphens allowed).
22
- Finds highest current number and increments by 1.
23
-
24
- Args:
25
- domain: Domain name (e.g., "AUTH", "CLI-TOOL")
26
- existing_ids: List of existing TAG IDs for this domain
27
-
28
- Returns:
29
- Next TAG ID (e.g., "@DOC:AUTH-003")
30
-
31
- Raises:
32
- ValueError: Invalid domain format
33
-
34
- Examples:
35
- >>> generate_doc_tag("AUTH", [])
36
- '@DOC:AUTH-001'
37
- >>> generate_doc_tag("AUTH", ["@DOC:AUTH-001", "@DOC:AUTH-002"])
38
- '@DOC:AUTH-003'
39
- """
40
- # Validate domain format: uppercase alphanumeric and hyphens only
41
- if not DOMAIN_PATTERN.match(domain):
42
- raise ValueError(
43
- f"Invalid domain format: {domain}. "
44
- "Domain must be uppercase, start with a letter, "
45
- "and contain only alphanumeric characters and hyphens."
46
- )
47
-
48
- # Find max number from existing IDs for this domain
49
- max_num = 0
50
- pattern = rf"@DOC:{re.escape(domain)}-(\d{{3}})$"
51
-
52
- for tag_id in existing_ids:
53
- match = re.search(pattern, tag_id)
54
- if match:
55
- num = int(match.group(1))
56
- max_num = max(max_num, num)
57
-
58
- # Generate next ID
59
- next_num = max_num + 1
60
- return f"@DOC:{domain}-{next_num:03d}"
61
-
62
-
63
- def detect_duplicates(domain: str, search_path: str = "docs/") -> List[str]:
64
- """Detect existing @DOC tags using ripgrep.
65
-
66
- Performs efficient ripgrep search for all @DOC:DOMAIN-NNN tags.
67
-
68
- Args:
69
- domain: Domain to search for
70
- search_path: Directory to search (default: docs/)
71
-
72
- Returns:
73
- List of existing TAG IDs
74
-
75
- Raises:
76
- RuntimeError: ripgrep not available or execution error
77
-
78
- Examples:
79
- >>> detect_duplicates("AUTH", "docs/")
80
- ['@DOC:AUTH-001', '@DOC:AUTH-002']
81
- """
82
- try:
83
- result = subprocess.run(
84
- ["rg", rf"@DOC:{re.escape(domain)}-\d{{3}}", search_path, "-o", "--no-heading"],
85
- capture_output=True,
86
- text=True,
87
- timeout=5,
88
- )
89
-
90
- if result.returncode == 0:
91
- # Found matches
92
- return [tag.strip() for tag in result.stdout.strip().split("\n") if tag.strip()]
93
- elif result.returncode == 1:
94
- # No matches found (normal case for new domains)
95
- return []
96
- else:
97
- # ripgrep error
98
- raise RuntimeError(f"ripgrep error: {result.stderr}")
99
-
100
- except FileNotFoundError:
101
- raise RuntimeError(
102
- "ripgrep (rg) not found in PATH. Please install it: "
103
- "brew install ripgrep (macOS) or apt install ripgrep (Linux)"
104
- )
105
- except subprocess.TimeoutExpired:
106
- raise RuntimeError(
107
- f"ripgrep timeout after 5 seconds searching {search_path}. "
108
- "Consider narrowing the search path."
109
- )
@@ -1,99 +0,0 @@
1
- # @CODE:INS-001, @CODE:INS-002
2
- """Markdown TAG insertion and file operations.
3
-
4
- Inserts @DOC tags into markdown file headers with chain references
5
- and provides backup/recovery functionality.
6
-
7
- @SPEC:DOC-TAG-001: @DOC tag automatic generation infrastructure
8
- """
9
-
10
- from pathlib import Path
11
- from typing import Optional
12
-
13
-
14
- def format_tag_header(tag_id: str, chain_ref: Optional[str] = None) -> str:
15
- """Format TAG header comment with chain reference.
16
-
17
- Args:
18
- tag_id: TAG ID (e.g., "@DOC:AUTH-001")
19
- chain_ref: Chain reference (e.g., "@SPEC:AUTH-001")
20
-
21
- Returns:
22
- Formatted header comment
23
-
24
- Examples:
25
- >>> format_tag_header("@DOC:AUTH-001", "@SPEC:AUTH-001")
26
- '# @DOC:AUTH-001 | Chain: @SPEC:AUTH-001 -> @DOC:AUTH-001'
27
- """
28
- if chain_ref:
29
- return f"# {tag_id} | Chain: {chain_ref} -> {tag_id}"
30
- return f"# {tag_id}"
31
-
32
-
33
- def insert_tag_to_markdown(
34
- file_path: Path, tag_id: str, chain_ref: Optional[str] = None
35
- ) -> bool:
36
- """Insert TAG comment into markdown file header.
37
-
38
- Inserts TAG as first line before the document title.
39
- Creates backup before modification.
40
-
41
- Args:
42
- file_path: Path to markdown file
43
- tag_id: TAG ID to insert
44
- chain_ref: Optional chain reference
45
-
46
- Returns:
47
- True if successful, False on error
48
-
49
- Examples:
50
- >>> insert_tag_to_markdown(Path("guide.md"), "@DOC:AUTH-001", "@SPEC:AUTH-001")
51
- True
52
- """
53
- try:
54
- # Read original content
55
- content = file_path.read_text(encoding="utf-8")
56
-
57
- # Format TAG header
58
- tag_header = format_tag_header(tag_id, chain_ref)
59
-
60
- # Insert at beginning
61
- new_content = f"{tag_header}\n{content}"
62
-
63
- # Write back
64
- file_path.write_text(new_content, encoding="utf-8")
65
-
66
- return True
67
-
68
- except (FileNotFoundError, PermissionError, OSError) as e:
69
- # Handle file operation errors gracefully
70
- print(f"Error inserting TAG into {file_path}: {e}")
71
- return False
72
-
73
-
74
- def create_backup(file_path: Path, backup_dir: Path = Path(".moai/backups")) -> Optional[Path]:
75
- """Create backup of file before modification.
76
-
77
- Args:
78
- file_path: Path to file to backup
79
- backup_dir: Directory for backups
80
-
81
- Returns:
82
- Path to backup file or None on error
83
-
84
- Examples:
85
- >>> create_backup(Path("guide.md"))
86
- Path('.moai/backups/guide.md.bak')
87
- """
88
- try:
89
- backup_dir.mkdir(parents=True, exist_ok=True)
90
- backup_path = backup_dir / f"{file_path.name}.bak"
91
-
92
- content = file_path.read_text(encoding="utf-8")
93
- backup_path.write_text(content, encoding="utf-8")
94
-
95
- return backup_path
96
-
97
- except (FileNotFoundError, PermissionError, OSError) as e:
98
- print(f"Error creating backup for {file_path}: {e}")
99
- return None
@@ -1,126 +0,0 @@
1
- # @CODE:MAP-001, @CODE:MAP-002
2
- """SPEC-DOC mapping and confidence scoring.
3
-
4
- Maps documentation files to related SPEC IDs based on domain matching
5
- and calculates confidence scores for chain references.
6
-
7
- @SPEC:DOC-TAG-001: @DOC tag automatic generation infrastructure
8
- """
9
-
10
- import re
11
- from pathlib import Path
12
- from typing import Any, Optional
13
-
14
- from moai_adk.core.tags.parser import extract_spec_id, parse_domain
15
-
16
-
17
- def find_related_spec(doc_path: Path, specs_dir: Path = Path(".moai/specs")) -> Optional[str]:
18
- """Find related SPEC ID by matching domain from document path.
19
-
20
- Searches for SPEC directories matching the domain inferred from the
21
- document's file path. Returns the most recent SPEC (highest number)
22
- if multiple matches exist.
23
-
24
- Args:
25
- doc_path: Path to documentation file (e.g., docs/auth/setup.md)
26
- specs_dir: Path to SPEC directory (default: .moai/specs)
27
-
28
- Returns:
29
- SPEC ID (e.g., "AUTH-001") or None if no match found
30
-
31
- Examples:
32
- >>> find_related_spec(Path("docs/auth/guide.md"))
33
- 'AUTH-001'
34
- >>> find_related_spec(Path("docs/api/endpoints.md"))
35
- 'API-001'
36
- """
37
- # Extract potential domain from file path
38
- # E.g., docs/auth/setup.md -> 'auth'
39
- path_parts = doc_path.parts
40
- if len(path_parts) < 2:
41
- return None
42
-
43
- # Get the first directory under 'docs/' as potential domain
44
- potential_domain = path_parts[1] if path_parts[0] == "docs" else path_parts[0]
45
- potential_domain = potential_domain.upper().replace("_", "-")
46
-
47
- # Search for matching SPEC directories
48
- if not specs_dir.exists():
49
- return None
50
-
51
- matching_specs = []
52
- for spec_dir in specs_dir.glob("SPEC-*"):
53
- spec_file = spec_dir / "spec.md"
54
- if not spec_file.exists():
55
- continue
56
-
57
- try:
58
- with open(spec_file, "r", encoding="utf-8") as f:
59
- content = f.read()
60
- spec_id = extract_spec_id(content)
61
- spec_domain = parse_domain(spec_id)
62
-
63
- # Case-insensitive domain match
64
- if spec_domain.upper() == potential_domain:
65
- matching_specs.append(spec_id)
66
- except (ValueError, OSError):
67
- # Skip invalid or unreadable SPEC files
68
- continue
69
-
70
- if not matching_specs:
71
- return None
72
-
73
- # Return most recent SPEC (highest number)
74
- def extract_number(spec: str) -> int:
75
- match: Any = re.search(r"-(\d{3})$", spec)
76
- return int(match.group(1)) if match else 0
77
-
78
- matching_specs.sort(key=extract_number, reverse=True)
79
- return str(matching_specs[0])
80
-
81
-
82
- def calculate_confidence(spec_id: str, doc_path: Path) -> float:
83
- """Calculate confidence score for SPEC-DOC mapping.
84
-
85
- Confidence levels:
86
- - 0.95+: Exact SPEC ID in file path
87
- - 0.80+: Domain match + relevant keywords in filename
88
- - 0.50+: Domain match only
89
- - <0.50: No domain match
90
-
91
- Args:
92
- spec_id: SPEC ID (e.g., "AUTH-001")
93
- doc_path: Path to documentation file
94
-
95
- Returns:
96
- Confidence score (0.0 to 1.0)
97
-
98
- Examples:
99
- >>> calculate_confidence("AUTH-001", Path("docs/auth/AUTH-001-impl.md"))
100
- 0.95
101
- >>> calculate_confidence("AUTH-001", Path("docs/auth/authentication.md"))
102
- 0.85
103
- >>> calculate_confidence("AUTH-001", Path("docs/api/guide.md"))
104
- 0.2
105
- """
106
- doc_str = str(doc_path).lower()
107
- spec_id_lower = spec_id.lower()
108
- domain = parse_domain(spec_id).lower()
109
-
110
- # Exact SPEC ID match in path
111
- if spec_id_lower in doc_str:
112
- return 0.95
113
-
114
- # Domain match + relevant keywords
115
- if domain in doc_str:
116
- # Keywords related to the domain
117
- keywords = [domain, "guide", "setup", "implementation", "tutorial"]
118
- keyword_matches = sum(1 for kw in keywords if kw in doc_str)
119
-
120
- if keyword_matches >= 2:
121
- return 0.80
122
- else:
123
- return 0.50
124
-
125
- # No domain match
126
- return 0.20
@@ -1,76 +0,0 @@
1
- # @CODE:PAR-001 | Chain: @SPEC:DOC-TAG-001 -> @CODE:PAR-001
2
- """SPEC parser utilities for TAG generation system.
3
-
4
- This module extracts SPEC metadata (ID, domain, title) from SPEC documents
5
- for use in TAG generation and SPEC-DOC mapping.
6
-
7
- @SPEC:DOC-TAG-001: @DOC tag automatic generation infrastructure
8
- """
9
-
10
- import re
11
- from typing import Any
12
-
13
- import yaml
14
-
15
-
16
- def extract_spec_id(spec_content: str) -> str:
17
- """Extract SPEC ID from YAML frontmatter.
18
-
19
- Args:
20
- spec_content: Full content of SPEC markdown file
21
-
22
- Returns:
23
- SPEC ID (e.g., "AUTH-001")
24
-
25
- Raises:
26
- ValueError: If YAML frontmatter or ID not found
27
-
28
- Examples:
29
- >>> content = "---\\nid: AUTH-001\\n---\\n# SPEC"
30
- >>> extract_spec_id(content)
31
- 'AUTH-001'
32
- """
33
- # Find YAML frontmatter between --- markers
34
- match = re.search(r"^---\s*\n(.*?)\n---\s*$", spec_content, re.MULTILINE | re.DOTALL)
35
- if not match:
36
- raise ValueError("YAML frontmatter not found in SPEC document")
37
-
38
- # Parse YAML
39
- yaml_content = match.group(1)
40
- try:
41
- metadata: Any = yaml.safe_load(yaml_content)
42
- spec_id: Any = metadata.get("id")
43
- if not spec_id:
44
- raise ValueError("'id' field not found in YAML frontmatter")
45
- return str(spec_id)
46
- except yaml.YAMLError as e:
47
- raise ValueError(f"Invalid YAML frontmatter: {e}")
48
-
49
-
50
- def parse_domain(spec_id: str) -> str:
51
- """Extract domain from SPEC ID.
52
-
53
- The domain is everything before the final -NNN sequence.
54
-
55
- Examples:
56
- >>> parse_domain("AUTH-001")
57
- 'AUTH'
58
- >>> parse_domain("CLI-TOOL-001")
59
- 'CLI-TOOL'
60
- >>> parse_domain("DOC-TAG-001")
61
- 'DOC-TAG'
62
-
63
- Args:
64
- spec_id: Full SPEC ID
65
-
66
- Returns:
67
- Domain part (everything before last "-NNN")
68
-
69
- Raises:
70
- ValueError: Invalid SPEC ID format
71
- """
72
- # Match pattern: any chars followed by hyphen and exactly 3 digits at end
73
- match = re.match(r"^(.*?)-\d{3}$", spec_id)
74
- if not match:
75
- raise ValueError(f"Invalid SPEC ID format: {spec_id}")
76
- return match.group(1)