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
@@ -1,897 +0,0 @@
1
- #!/usr/bin/env python3
2
- # @CODE:DOC-TAG-004 | Component 3: Central validation system
3
- """Central TAG validation system for MoAI-ADK
4
-
5
- This module provides a unified, extensible validation engine that:
6
- - Validates TAG format, duplicates, orphans, and chain integrity
7
- - Supports multiple validator types with priority ordering
8
- - Generates reports in multiple formats (detailed, summary, JSON)
9
- - Provides CLI integration via moai-adk validate-tags
10
-
11
- Architecture:
12
- CentralValidator (orchestrator)
13
- ├── DuplicateValidator (priority: 90)
14
- ├── OrphanValidator (priority: 50)
15
- ├── ChainValidator (priority: 30)
16
- └── FormatValidator (priority: 100)
17
-
18
- Usage:
19
- config = ValidationConfig(strict_mode=True)
20
- validator = CentralValidator(config=config)
21
- result = validator.validate_directory("/path/to/project")
22
- report = validator.create_report(result, format="json")
23
- """
24
-
25
- import json
26
- import re
27
- import time
28
- from abc import ABC, abstractmethod
29
- from dataclasses import dataclass, field
30
- from datetime import datetime
31
- from pathlib import Path
32
- from typing import Any, Dict, List, Optional, Set, Tuple
33
-
34
-
35
- @dataclass
36
- class ValidationConfig:
37
- """Configuration for validation behavior
38
-
39
- Attributes:
40
- strict_mode: Treat warnings as errors (block on warnings)
41
- check_duplicates: Enable duplicate TAG detection
42
- check_orphans: Enable orphan TAG detection (CODE without TEST)
43
- check_chain_integrity: Enable SPEC→CODE→TEST→DOC chain validation
44
- allowed_file_types: List of file extensions to validate (e.g., ["py", "js"])
45
- ignore_patterns: List of glob patterns to ignore (e.g., [".git/*", "*.pyc"])
46
- report_format: Default report format (detailed|summary|json)
47
- """
48
- strict_mode: bool = False
49
- check_duplicates: bool = True
50
- check_orphans: bool = True
51
- check_chain_integrity: bool = True
52
- allowed_file_types: List[str] = field(default_factory=lambda: [
53
- "py", "js", "ts", "jsx", "tsx", "md", "txt", "yml", "yaml", "json"
54
- ])
55
- ignore_patterns: List[str] = field(default_factory=lambda: [
56
- ".git/*", "node_modules/*", "__pycache__/*", "*.pyc", ".venv/*", "venv/*"
57
- ])
58
- report_format: str = "detailed"
59
-
60
-
61
- @dataclass
62
- class ValidationIssue:
63
- """Validation issue with severity, type, and location
64
-
65
- Attributes:
66
- severity: Issue severity (error|warning|info)
67
- type: Issue type (duplicate|orphan|chain|format)
68
- tag: TAG string (e.g., "@CODE:TEST-001")
69
- message: Human-readable issue description
70
- locations: List of (file, line) tuples where issue occurs
71
- suggestion: How to fix the issue
72
- """
73
- severity: str # error|warning|info
74
- type: str # duplicate|orphan|chain|format
75
- tag: str
76
- message: str
77
- locations: List[Tuple[str, int]] = field(default_factory=list)
78
- suggestion: str = ""
79
-
80
- def to_dict(self) -> Dict[str, Any]:
81
- """Convert to dictionary for JSON serialization"""
82
- return {
83
- "severity": self.severity,
84
- "type": self.type,
85
- "tag": self.tag,
86
- "message": self.message,
87
- "locations": [
88
- {"file": f, "line": line} for f, line in self.locations
89
- ],
90
- "suggestion": self.suggestion
91
- }
92
-
93
-
94
- @dataclass
95
- class ValidationStatistics:
96
- """Validation statistics
97
-
98
- Attributes:
99
- total_files_scanned: Number of files scanned
100
- total_tags_found: Total TAG count across all files
101
- total_issues: Total issues found (errors + warnings)
102
- error_count: Number of errors
103
- warning_count: Number of warnings
104
- coverage_percentage: Percentage of SPEC tags with CODE implementation
105
- """
106
- total_files_scanned: int
107
- total_tags_found: int
108
- total_issues: int
109
- error_count: int
110
- warning_count: int
111
- coverage_percentage: float
112
-
113
- def to_dict(self) -> Dict[str, Any]:
114
- """Convert to dictionary for JSON serialization"""
115
- return {
116
- "total_files_scanned": self.total_files_scanned,
117
- "total_tags_found": self.total_tags_found,
118
- "total_issues": self.total_issues,
119
- "error_count": self.error_count,
120
- "warning_count": self.warning_count,
121
- "coverage_percentage": self.coverage_percentage
122
- }
123
-
124
-
125
- @dataclass
126
- class CentralValidationResult:
127
- """Complete validation result from CentralValidator
128
-
129
- Attributes:
130
- is_valid: Overall validation status (False if errors, or warnings in strict mode)
131
- issues: All issues (errors + warnings combined)
132
- errors: Error-level issues only
133
- warnings: Warning-level issues only
134
- statistics: Validation statistics
135
- timestamp: When validation was performed
136
- execution_time_ms: Validation execution time in milliseconds
137
- """
138
- is_valid: bool
139
- issues: List[ValidationIssue]
140
- errors: List[ValidationIssue]
141
- warnings: List[ValidationIssue]
142
- statistics: ValidationStatistics
143
- timestamp: datetime
144
- execution_time_ms: float
145
-
146
- def to_dict(self) -> Dict[str, Any]:
147
- """Convert to dictionary for JSON serialization"""
148
- return {
149
- "is_valid": self.is_valid,
150
- "issues": [issue.to_dict() for issue in self.issues],
151
- "errors": [error.to_dict() for error in self.errors],
152
- "warnings": [warning.to_dict() for warning in self.warnings],
153
- "statistics": self.statistics.to_dict(),
154
- "timestamp": self.timestamp.isoformat(),
155
- "execution_time_ms": self.execution_time_ms
156
- }
157
-
158
-
159
- class TagValidator(ABC):
160
- """Abstract base class for all validators
161
-
162
- All validators must extend this class and implement:
163
- - validate(): Perform validation and return issues
164
- - get_name(): Return validator name
165
- - get_priority(): Return priority (higher = runs first)
166
- """
167
-
168
- # Default TAG pattern: @(SPEC|CODE|TEST|DOC):DOMAIN-TYPE-NNN
169
- TAG_PATTERN = re.compile(r"@(SPEC|CODE|TEST|DOC):([A-Z]+(?:-[A-Z]+)*-\d{3})")
170
-
171
- @abstractmethod
172
- def validate(self, files: List[str]) -> List[ValidationIssue]:
173
- """Validate files and return list of issues
174
-
175
- Args:
176
- files: List of file paths to validate
177
-
178
- Returns:
179
- List of ValidationIssue objects
180
- """
181
- pass
182
-
183
- @abstractmethod
184
- def get_name(self) -> str:
185
- """Return validator name"""
186
- pass
187
-
188
- @abstractmethod
189
- def get_priority(self) -> int:
190
- """Return validator priority (higher = runs first)
191
-
192
- Priority guidelines:
193
- - 100: Format validation (must pass before other checks)
194
- - 90: Duplicate detection (errors that block)
195
- - 50: Orphan detection (warnings)
196
- - 30: Chain integrity (warnings)
197
- """
198
- pass
199
-
200
- def extract_tags_from_file(self, filepath: str) -> List[Tuple[str, str, int]]:
201
- """Extract TAGs from a file
202
-
203
- Args:
204
- filepath: Path to file to scan
205
-
206
- Returns:
207
- List of (tag_type, domain, line_number) tuples
208
- Example: [("CODE", "USER-REG-001", 10), ("TEST", "USER-REG-001", 25)]
209
- """
210
- try:
211
- path = Path(filepath)
212
- if not path.exists() or not path.is_file():
213
- return []
214
-
215
- content = path.read_text(encoding="utf-8", errors="ignore")
216
- lines = content.splitlines()
217
-
218
- tags = []
219
- for line_num, line in enumerate(lines, start=1):
220
- matches = self.TAG_PATTERN.findall(line)
221
- for tag_type, domain in matches:
222
- tags.append((tag_type, domain, line_num))
223
-
224
- return tags
225
-
226
- except Exception:
227
- return []
228
-
229
-
230
- class DuplicateValidator(TagValidator):
231
- """Validator for duplicate TAG detection
232
-
233
- Detects duplicate TAGs within same file or across multiple files.
234
- Returns error-level issues for all duplicates found.
235
-
236
- Priority: 90 (high - errors that must be fixed)
237
- """
238
-
239
- def validate(self, files: List[str]) -> List[ValidationIssue]:
240
- """Detect duplicate TAGs across all files
241
-
242
- Args:
243
- files: List of file paths to validate
244
-
245
- Returns:
246
- List of ValidationIssue objects for duplicates
247
- """
248
- issues: List[ValidationIssue] = []
249
- tag_locations: Dict[str, List[Tuple[str, int]]] = {}
250
-
251
- # Collect all TAGs and their locations
252
- for filepath in files:
253
- tags = self.extract_tags_from_file(filepath)
254
- for tag_type, domain, line_num in tags:
255
- full_tag = f"@{tag_type}:{domain}"
256
- if full_tag not in tag_locations:
257
- tag_locations[full_tag] = []
258
- tag_locations[full_tag].append((filepath, line_num))
259
-
260
- # Find duplicates (tags with more than one location)
261
- for tag, locations in tag_locations.items():
262
- if len(locations) > 1:
263
- issues.append(ValidationIssue(
264
- severity="error",
265
- type="duplicate",
266
- tag=tag,
267
- message=f"Duplicate TAG found in {len(locations)} locations",
268
- locations=locations,
269
- suggestion="Remove duplicate TAG declarations. Each TAG must be unique across the codebase."
270
- ))
271
-
272
- return issues
273
-
274
- def get_name(self) -> str:
275
- """Return validator name"""
276
- return "DuplicateValidator"
277
-
278
- def get_priority(self) -> int:
279
- """Return high priority (errors block early)"""
280
- return 90
281
-
282
-
283
- class OrphanValidator(TagValidator):
284
- """Validator for orphan TAG detection
285
-
286
- Detects orphan TAGs:
287
- - @CODE without corresponding @TEST
288
- - @TEST without corresponding @CODE
289
- - @SPEC without implementation (@CODE)
290
-
291
- Returns warning-level issues for all orphans found.
292
-
293
- Priority: 50 (medium - warnings that should be addressed)
294
- """
295
-
296
- def validate(self, files: List[str]) -> List[ValidationIssue]:
297
- """Detect orphan TAGs across all files
298
-
299
- Args:
300
- files: List of file paths to validate
301
-
302
- Returns:
303
- List of ValidationIssue objects for orphans
304
- """
305
- issues: List[ValidationIssue] = []
306
-
307
- # Collect all TAGs by type and domain
308
- tags_by_type: Dict[str, Dict[str, List[Tuple[str, int]]]] = {
309
- "SPEC": {},
310
- "CODE": {},
311
- "TEST": {},
312
- "DOC": {}
313
- }
314
-
315
- for filepath in files:
316
- tags = self.extract_tags_from_file(filepath)
317
- for tag_type, domain, line_num in tags:
318
- if domain not in tags_by_type[tag_type]:
319
- tags_by_type[tag_type][domain] = []
320
- tags_by_type[tag_type][domain].append((filepath, line_num))
321
-
322
- # Check for orphans: CODE without TEST
323
- for domain, locations in tags_by_type["CODE"].items():
324
- if domain not in tags_by_type["TEST"]:
325
- for filepath, line_num in locations:
326
- issues.append(ValidationIssue(
327
- severity="warning",
328
- type="orphan",
329
- tag=f"@CODE:{domain}",
330
- message="CODE TAG without corresponding TEST",
331
- locations=[(filepath, line_num)],
332
- suggestion=f"Add @TEST:{domain} to test this code implementation"
333
- ))
334
-
335
- # Check for orphans: TEST without CODE
336
- for domain, locations in tags_by_type["TEST"].items():
337
- if domain not in tags_by_type["CODE"]:
338
- for filepath, line_num in locations:
339
- issues.append(ValidationIssue(
340
- severity="warning",
341
- type="orphan",
342
- tag=f"@TEST:{domain}",
343
- message="TEST TAG without corresponding CODE",
344
- locations=[(filepath, line_num)],
345
- suggestion=f"Add @CODE:{domain} for the implementation being tested"
346
- ))
347
-
348
- return issues
349
-
350
- def get_name(self) -> str:
351
- """Return validator name"""
352
- return "OrphanValidator"
353
-
354
- def get_priority(self) -> int:
355
- """Return medium priority"""
356
- return 50
357
-
358
-
359
- class ChainValidator(TagValidator):
360
- """Validator for TAG chain integrity (NEW in Component 3)
361
-
362
- Validates complete SPEC→CODE→TEST→DOC chain:
363
- - @SPEC should have corresponding @CODE (implementation)
364
- - @CODE should have corresponding @TEST (test coverage)
365
- - Complete chain optionally includes @DOC (documentation)
366
-
367
- Returns warning-level issues for incomplete chains.
368
-
369
- Priority: 30 (low - runs after duplicates and orphans)
370
- """
371
-
372
- def validate(self, files: List[str]) -> List[ValidationIssue]:
373
- """Validate TAG chain integrity
374
-
375
- Args:
376
- files: List of file paths to validate
377
-
378
- Returns:
379
- List of ValidationIssue objects for chain problems
380
- """
381
- issues: List[ValidationIssue] = []
382
-
383
- # Collect all TAGs by type
384
- tags_by_type: Dict[str, Set[str]] = {
385
- "SPEC": set(),
386
- "CODE": set(),
387
- "TEST": set(),
388
- "DOC": set()
389
- }
390
-
391
- for filepath in files:
392
- tags = self.extract_tags_from_file(filepath)
393
- for tag_type, domain, _ in tags:
394
- tags_by_type[tag_type].add(domain)
395
-
396
- # Check SPEC→CODE chain
397
- for spec_domain in tags_by_type["SPEC"]:
398
- if spec_domain not in tags_by_type["CODE"]:
399
- issues.append(ValidationIssue(
400
- severity="warning",
401
- type="chain",
402
- tag=f"@SPEC:{spec_domain}",
403
- message="SPEC without CODE implementation",
404
- locations=[],
405
- suggestion=f"Implement @CODE:{spec_domain} for this specification"
406
- ))
407
-
408
- # Check CODE→SPEC chain (reverse: CODE should have SPEC)
409
- for code_domain in tags_by_type["CODE"]:
410
- if code_domain not in tags_by_type["SPEC"]:
411
- issues.append(ValidationIssue(
412
- severity="warning",
413
- type="chain",
414
- tag=f"@CODE:{code_domain}",
415
- message="CODE implementation without SPEC",
416
- locations=[],
417
- suggestion=f"Add @SPEC:{code_domain} to document the specification"
418
- ))
419
-
420
- # Check TEST→SPEC chain (reverse: TEST should have SPEC)
421
- for test_domain in tags_by_type["TEST"]:
422
- if test_domain not in tags_by_type["SPEC"]:
423
- issues.append(ValidationIssue(
424
- severity="warning",
425
- type="chain",
426
- tag=f"@TEST:{test_domain}",
427
- message="TEST without SPEC",
428
- locations=[],
429
- suggestion=f"Add @SPEC:{test_domain} to document what is being tested"
430
- ))
431
-
432
- # Check SPEC+CODE without TEST chain
433
- spec_with_code = tags_by_type["SPEC"] & tags_by_type["CODE"]
434
- for domain in spec_with_code:
435
- if domain not in tags_by_type["TEST"]:
436
- issues.append(ValidationIssue(
437
- severity="warning",
438
- type="chain",
439
- tag=f"@CODE:{domain}",
440
- message="CODE implementation without TEST",
441
- locations=[],
442
- suggestion=f"Add @TEST:{domain} to test this implementation"
443
- ))
444
-
445
- # Check for documentation (info level - optional)
446
- complete_implementations = tags_by_type["SPEC"] & tags_by_type["CODE"] & tags_by_type["TEST"]
447
- for domain in complete_implementations:
448
- if domain not in tags_by_type["DOC"]:
449
- issues.append(ValidationIssue(
450
- severity="info",
451
- type="chain",
452
- tag=f"@SPEC:{domain}",
453
- message="Complete implementation without documentation",
454
- locations=[],
455
- suggestion=f"Consider adding @DOC:{domain} to document this feature"
456
- ))
457
-
458
- return issues
459
-
460
- def get_name(self) -> str:
461
- """Return validator name"""
462
- return "ChainValidator"
463
-
464
- def get_priority(self) -> int:
465
- """Return low priority (runs after other checks)"""
466
- return 30
467
-
468
-
469
- class FormatValidator(TagValidator):
470
- """Validator for TAG format validation
471
-
472
- Validates TAG format: @PREFIX:DOMAIN-TYPE-NNN
473
- Returns error-level issues for invalid formats.
474
-
475
- Priority: 100 (highest - format must be valid before other checks)
476
- """
477
-
478
- def validate(self, files: List[str]) -> List[ValidationIssue]:
479
- """Validate TAG format in all files
480
-
481
- Args:
482
- files: List of file paths to validate
483
-
484
- Returns:
485
- List of ValidationIssue objects for format problems
486
- """
487
- # Format validation is implicitly done by TAG_PATTERN regex
488
- # Invalid formats won't be extracted, so no issues to report here
489
- # This validator is a placeholder for future format-specific checks
490
- return []
491
-
492
- def get_name(self) -> str:
493
- """Return validator name"""
494
- return "FormatValidator"
495
-
496
- def get_priority(self) -> int:
497
- """Return highest priority"""
498
- return 100
499
-
500
-
501
- class CentralValidator:
502
- """Central validation orchestrator
503
-
504
- Coordinates multiple validators to provide unified validation:
505
- 1. Registers default validators (Duplicate, Orphan, Chain, Format)
506
- 2. Runs validators in priority order (high to low)
507
- 3. Collects all issues and generates statistics
508
- 4. Creates formatted reports in multiple formats
509
-
510
- Usage:
511
- config = ValidationConfig(strict_mode=True)
512
- validator = CentralValidator(config=config)
513
- result = validator.validate_directory("/path/to/project")
514
- print(validator.create_report(result, format="summary"))
515
-
516
- Args:
517
- config: ValidationConfig object (default: ValidationConfig())
518
- """
519
-
520
- def __init__(self, config: Optional[ValidationConfig] = None):
521
- """Initialize CentralValidator with configuration
522
-
523
- Args:
524
- config: ValidationConfig object (default: ValidationConfig())
525
- """
526
- self.config = config or ValidationConfig()
527
- self.validators: List[TagValidator] = []
528
-
529
- # Register default validators based on configuration
530
- if self.config.check_duplicates:
531
- self.register_validator(DuplicateValidator())
532
-
533
- if self.config.check_orphans:
534
- self.register_validator(OrphanValidator())
535
-
536
- if self.config.check_chain_integrity:
537
- self.register_validator(ChainValidator())
538
-
539
- # Always register format validator
540
- self.register_validator(FormatValidator())
541
-
542
- # Sort validators by priority (high to low)
543
- self.validators.sort(key=lambda v: v.get_priority(), reverse=True)
544
-
545
- def register_validator(self, validator: TagValidator) -> None:
546
- """Register a custom validator
547
-
548
- Args:
549
- validator: TagValidator instance to register
550
- """
551
- self.validators.append(validator)
552
- # Re-sort by priority
553
- self.validators.sort(key=lambda v: v.get_priority(), reverse=True)
554
-
555
- def get_validators(self) -> List[TagValidator]:
556
- """Get list of registered validators
557
-
558
- Returns:
559
- List of TagValidator instances sorted by priority
560
- """
561
- return self.validators.copy()
562
-
563
- def _should_scan_file(self, filepath: str) -> bool:
564
- """Check if file should be scanned based on configuration
565
-
566
- Args:
567
- filepath: Path to file
568
-
569
- Returns:
570
- True if file should be scanned
571
- """
572
- path = Path(filepath)
573
-
574
- # Check file extension
575
- if self.config.allowed_file_types:
576
- suffix = path.suffix.lstrip(".")
577
- if suffix and suffix not in self.config.allowed_file_types:
578
- return False
579
-
580
- # Check ignore patterns
581
- for pattern in self.config.ignore_patterns:
582
- # Simple pattern matching (can be enhanced with fnmatch)
583
- pattern_clean = pattern.replace("/*", "").replace("*", "")
584
- if pattern_clean in str(path):
585
- return False
586
-
587
- return True
588
-
589
- def _collect_files_from_directory(self, directory: str) -> List[str]:
590
- """Collect all files from directory recursively
591
-
592
- Args:
593
- directory: Directory path to scan
594
-
595
- Returns:
596
- List of file paths that should be scanned
597
- """
598
- dir_path = Path(directory)
599
- if not dir_path.exists() or not dir_path.is_dir():
600
- return []
601
-
602
- files = []
603
- for path in dir_path.rglob("*"):
604
- if path.is_file() and self._should_scan_file(str(path)):
605
- files.append(str(path))
606
-
607
- return files
608
-
609
- def validate_files(self, files: List[str]) -> CentralValidationResult:
610
- """Validate list of files
611
-
612
- Main validation method that:
613
- 1. Runs all registered validators in priority order
614
- 2. Collects all issues (errors + warnings)
615
- 3. Generates statistics
616
- 4. Returns CentralValidationResult
617
-
618
- Args:
619
- files: List of file paths to validate
620
-
621
- Returns:
622
- CentralValidationResult with all issues and statistics
623
- """
624
- start_time = time.time()
625
-
626
- # Filter files based on configuration
627
- files_to_scan = [f for f in files if self._should_scan_file(f)]
628
-
629
- # Run all validators
630
- all_issues: List[ValidationIssue] = []
631
- for validator in self.validators:
632
- issues = validator.validate(files_to_scan)
633
- all_issues.extend(issues)
634
-
635
- # Separate errors and warnings
636
- errors = [issue for issue in all_issues if issue.severity == "error"]
637
- warnings = [issue for issue in all_issues if issue.severity == "warning"]
638
-
639
- # Calculate statistics
640
- total_tags = 0
641
- spec_tags = set()
642
- code_tags = set()
643
-
644
- for filepath in files_to_scan:
645
- try:
646
- path = Path(filepath)
647
- if not path.exists():
648
- continue
649
- content = path.read_text(encoding="utf-8", errors="ignore")
650
- matches = TagValidator.TAG_PATTERN.findall(content)
651
- total_tags += len(matches)
652
-
653
- for tag_type, domain in matches:
654
- if tag_type == "SPEC":
655
- spec_tags.add(domain)
656
- elif tag_type == "CODE":
657
- code_tags.add(domain)
658
- except Exception:
659
- continue
660
-
661
- # Calculate coverage percentage (SPEC tags with CODE implementation)
662
- if spec_tags:
663
- implemented_specs = spec_tags & code_tags
664
- coverage_percentage = (len(implemented_specs) / len(spec_tags)) * 100
665
- else:
666
- coverage_percentage = 0.0 if code_tags else 100.0
667
-
668
- statistics = ValidationStatistics(
669
- total_files_scanned=len(files_to_scan),
670
- total_tags_found=total_tags,
671
- total_issues=len(all_issues),
672
- error_count=len(errors),
673
- warning_count=len(warnings),
674
- coverage_percentage=round(coverage_percentage, 2)
675
- )
676
-
677
- # Determine if validation passed
678
- if self.config.strict_mode:
679
- is_valid = len(errors) == 0 and len(warnings) == 0
680
- else:
681
- is_valid = len(errors) == 0
682
-
683
- execution_time_ms = (time.time() - start_time) * 1000
684
-
685
- return CentralValidationResult(
686
- is_valid=is_valid,
687
- issues=all_issues,
688
- errors=errors,
689
- warnings=warnings,
690
- statistics=statistics,
691
- timestamp=datetime.now(),
692
- execution_time_ms=round(execution_time_ms, 2)
693
- )
694
-
695
- def validate_directory(self, directory: str, config: Optional[ValidationConfig] = None) -> CentralValidationResult:
696
- """Validate all files in a directory recursively
697
-
698
- Args:
699
- directory: Directory path to scan
700
- config: Optional custom configuration (overrides instance config)
701
-
702
- Returns:
703
- CentralValidationResult
704
- """
705
- # Temporarily override config if provided
706
- original_config = self.config
707
- if config:
708
- self.config = config
709
-
710
- # Collect files from directory
711
- files = self._collect_files_from_directory(directory)
712
-
713
- # Validate files
714
- result = self.validate_files(files)
715
-
716
- # Restore original config
717
- self.config = original_config
718
-
719
- return result
720
-
721
- def create_report(self, result: CentralValidationResult, format: str = "detailed") -> str:
722
- """Create formatted validation report
723
-
724
- Args:
725
- result: CentralValidationResult from validation
726
- format: Report format (detailed|summary|json)
727
-
728
- Returns:
729
- Formatted report string
730
- """
731
- if format == "json":
732
- return json.dumps(result.to_dict(), indent=2)
733
- elif format == "summary":
734
- return self._create_summary_report(result)
735
- else: # detailed
736
- return self._create_detailed_report(result)
737
-
738
- def _create_summary_report(self, result: CentralValidationResult) -> str:
739
- """Create summary report
740
-
741
- Args:
742
- result: CentralValidationResult
743
-
744
- Returns:
745
- Summary report string
746
- """
747
- lines = []
748
- lines.append("=" * 60)
749
- lines.append("TAG Validation Summary")
750
- lines.append("=" * 60)
751
- lines.append("")
752
-
753
- # Status
754
- if result.is_valid:
755
- lines.append("✅ Validation PASSED")
756
- else:
757
- lines.append("❌ Validation FAILED")
758
- lines.append("")
759
-
760
- # Statistics
761
- stats = result.statistics
762
- lines.append(f"Files Scanned: {stats.total_files_scanned}")
763
- lines.append(f"Tags Found: {stats.total_tags_found}")
764
- lines.append(f"Total Issues: {stats.total_issues}")
765
- lines.append(f" - Errors: {stats.error_count}")
766
- lines.append(f" - Warnings: {stats.warning_count}")
767
- lines.append(f"Coverage: {stats.coverage_percentage:.1f}%")
768
- lines.append("")
769
-
770
- # Execution time
771
- lines.append(f"Execution Time: {result.execution_time_ms:.2f} ms")
772
- lines.append("")
773
-
774
- return "\n".join(lines)
775
-
776
- def _create_detailed_report(self, result: CentralValidationResult) -> str:
777
- """Create detailed report with all issues
778
-
779
- Args:
780
- result: CentralValidationResult
781
-
782
- Returns:
783
- Detailed report string
784
- """
785
- lines = []
786
- lines.append("=" * 60)
787
- lines.append("TAG Validation Report")
788
- lines.append("=" * 60)
789
- lines.append("")
790
-
791
- # Status
792
- if result.is_valid:
793
- lines.append("✅ Validation PASSED")
794
- else:
795
- lines.append("❌ Validation FAILED")
796
- lines.append("")
797
-
798
- # Errors
799
- if result.errors:
800
- lines.append("ERRORS:")
801
- lines.append("-" * 60)
802
- for error in result.errors:
803
- lines.append(f" {error.tag}")
804
- lines.append(f" Type: {error.type}")
805
- lines.append(f" Message: {error.message}")
806
- if error.locations:
807
- lines.append(" Locations:")
808
- for filepath, line_num in error.locations:
809
- lines.append(f" - {filepath}:{line_num}")
810
- if error.suggestion:
811
- lines.append(f" Suggestion: {error.suggestion}")
812
- lines.append("")
813
-
814
- # Warnings
815
- if result.warnings:
816
- lines.append("WARNINGS:")
817
- lines.append("-" * 60)
818
- for warning in result.warnings:
819
- lines.append(f" {warning.tag}")
820
- lines.append(f" Type: {warning.type}")
821
- lines.append(f" Message: {warning.message}")
822
- if warning.locations:
823
- lines.append(" Locations:")
824
- for filepath, line_num in warning.locations:
825
- lines.append(f" - {filepath}:{line_num}")
826
- if warning.suggestion:
827
- lines.append(f" Suggestion: {warning.suggestion}")
828
- lines.append("")
829
-
830
- # Statistics
831
- lines.append("STATISTICS:")
832
- lines.append("-" * 60)
833
- stats = result.statistics
834
- lines.append(f"Files Scanned: {stats.total_files_scanned}")
835
- lines.append(f"Tags Found: {stats.total_tags_found}")
836
- lines.append(f"Total Issues: {stats.total_issues}")
837
- lines.append(f" - Errors: {stats.error_count}")
838
- lines.append(f" - Warnings: {stats.warning_count}")
839
- lines.append(f"Spec→Code Coverage: {stats.coverage_percentage:.1f}%")
840
- lines.append(f"Execution Time: {result.execution_time_ms:.2f} ms")
841
- lines.append("")
842
-
843
- return "\n".join(lines)
844
-
845
- def export_for_reporting(self, result: CentralValidationResult) -> Dict[str, Any]:
846
- """Export validation result in format compatible with ReportGenerator
847
-
848
- This method bridges Component 3 (Validation) with Component 4 (Reporting).
849
- Exports validation results as structured data for integration with
850
- automated reporting workflows.
851
-
852
- Args:
853
- result: CentralValidationResult from validation
854
-
855
- Returns:
856
- Dictionary with validation data formatted for reporting:
857
- {
858
- "timestamp": ISO timestamp,
859
- "is_valid": bool,
860
- "statistics": {
861
- "total_files_scanned": int,
862
- "total_tags_found": int,
863
- "total_issues": int,
864
- "error_count": int,
865
- "warning_count": int,
866
- "coverage_percentage": float
867
- },
868
- "issues_by_type": {
869
- "duplicate": [...],
870
- "orphan": [...],
871
- "chain": [...],
872
- "format": [...]
873
- },
874
- "execution_time_ms": float
875
- }
876
- """
877
- # Group issues by type
878
- issues_by_type: Dict[str, List[Dict[str, Any]]] = {
879
- "duplicate": [],
880
- "orphan": [],
881
- "chain": [],
882
- "format": []
883
- }
884
-
885
- for issue in result.issues:
886
- issues_by_type[issue.type].append(issue.to_dict())
887
-
888
- # Build export data
889
- export_data = {
890
- "timestamp": result.timestamp.isoformat(),
891
- "is_valid": result.is_valid,
892
- "statistics": result.statistics.to_dict(),
893
- "issues_by_type": issues_by_type,
894
- "execution_time_ms": result.execution_time_ms
895
- }
896
-
897
- return export_data