moai-adk 0.34.0__py3-none-any.whl → 1.1.0__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.
Files changed (524) hide show
  1. moai_adk/__main__.py +136 -5
  2. moai_adk/astgrep/__init__.py +37 -0
  3. moai_adk/astgrep/analyzer.py +522 -0
  4. moai_adk/astgrep/models.py +124 -0
  5. moai_adk/astgrep/rules.py +179 -0
  6. moai_adk/cli/commands/analyze.py +11 -2
  7. moai_adk/cli/commands/doctor.py +7 -1
  8. moai_adk/cli/commands/init.py +321 -11
  9. moai_adk/cli/commands/language.py +7 -1
  10. moai_adk/cli/commands/rank.py +449 -0
  11. moai_adk/cli/commands/status.py +7 -1
  12. moai_adk/cli/commands/switch.py +325 -0
  13. moai_adk/cli/commands/update.py +296 -23
  14. moai_adk/cli/prompts/init_prompts.py +362 -66
  15. moai_adk/cli/prompts/translations/__init__.py +573 -0
  16. moai_adk/cli/ui/prompts.py +61 -2
  17. moai_adk/cli/worktree/cli.py +106 -1
  18. moai_adk/cli/worktree/manager.py +155 -0
  19. moai_adk/core/config/unified.py +244 -63
  20. moai_adk/core/credentials.py +264 -0
  21. moai_adk/core/error_recovery_system.py +22 -4
  22. moai_adk/core/git/conflict_detector.py +10 -1
  23. moai_adk/core/git/event_detector.py +16 -5
  24. moai_adk/core/integration/engine.py +2 -2
  25. moai_adk/core/integration/integration_tester.py +5 -5
  26. moai_adk/core/language_config_resolver.py +9 -3
  27. moai_adk/core/merge/analyzer.py +509 -324
  28. moai_adk/core/migration/alfred_to_moai_migrator.py +7 -1
  29. moai_adk/core/migration/backup_manager.py +54 -4
  30. moai_adk/core/migration/file_migrator.py +174 -2
  31. moai_adk/core/migration/interactive_checkbox_ui.py +42 -31
  32. moai_adk/core/migration/version_detector.py +123 -19
  33. moai_adk/core/migration/version_migrator.py +44 -9
  34. moai_adk/core/model_allocator.py +241 -0
  35. moai_adk/core/project/backup_utils.py +12 -2
  36. moai_adk/core/project/initializer.py +44 -87
  37. moai_adk/core/project/phase_executor.py +95 -33
  38. moai_adk/core/project/validator.py +16 -1
  39. moai_adk/core/quality/trust_checker.py +30 -10
  40. moai_adk/core/rollback_manager.py +60 -25
  41. moai_adk/core/template/backup.py +88 -6
  42. moai_adk/core/template/config.py +33 -9
  43. moai_adk/core/template/merger.py +34 -8
  44. moai_adk/core/template/processor.py +334 -11
  45. moai_adk/core/template_engine.py +10 -1
  46. moai_adk/core/template_variable_synchronizer.py +16 -2
  47. moai_adk/core/version_sync.py +54 -6
  48. moai_adk/foundation/__init__.py +1 -20
  49. moai_adk/foundation/testing.py +1 -1
  50. moai_adk/loop/__init__.py +54 -0
  51. moai_adk/loop/controller.py +305 -0
  52. moai_adk/loop/feedback.py +230 -0
  53. moai_adk/loop/state.py +209 -0
  54. moai_adk/loop/storage.py +220 -0
  55. moai_adk/lsp/__init__.py +70 -0
  56. moai_adk/lsp/client.py +320 -0
  57. moai_adk/lsp/models.py +261 -0
  58. moai_adk/lsp/protocol.py +404 -0
  59. moai_adk/lsp/server_manager.py +248 -0
  60. moai_adk/project/configuration.py +8 -1
  61. moai_adk/py.typed +0 -0
  62. moai_adk/ralph/__init__.py +37 -0
  63. moai_adk/ralph/engine.py +307 -0
  64. moai_adk/rank/__init__.py +21 -0
  65. moai_adk/rank/auth.py +425 -0
  66. moai_adk/rank/client.py +557 -0
  67. moai_adk/rank/config.py +147 -0
  68. moai_adk/rank/hook.py +1503 -0
  69. moai_adk/rank/py.typed +0 -0
  70. moai_adk/statusline/__init__.py +3 -0
  71. moai_adk/statusline/enhanced_output_style_detector.py +5 -5
  72. moai_adk/statusline/main.py +20 -1
  73. moai_adk/statusline/memory_collector.py +268 -0
  74. moai_adk/statusline/renderer.py +54 -38
  75. moai_adk/tag_system/__init__.py +48 -0
  76. moai_adk/tag_system/atomic_ops.py +117 -0
  77. moai_adk/tag_system/linkage.py +335 -0
  78. moai_adk/tag_system/parser.py +176 -0
  79. moai_adk/tag_system/validator.py +200 -0
  80. moai_adk/templates/.claude/agents/moai/builder-agent.md +19 -3
  81. moai_adk/templates/.claude/agents/moai/builder-command.md +62 -16
  82. moai_adk/templates/.claude/agents/moai/builder-plugin.md +763 -0
  83. moai_adk/templates/.claude/agents/moai/builder-skill.md +21 -5
  84. moai_adk/templates/.claude/agents/moai/expert-backend.md +103 -39
  85. moai_adk/templates/.claude/agents/moai/expert-debug.md +9 -3
  86. moai_adk/templates/.claude/agents/moai/expert-devops.md +16 -14
  87. moai_adk/templates/.claude/agents/moai/expert-frontend.md +45 -31
  88. moai_adk/templates/.claude/agents/moai/expert-performance.md +13 -9
  89. moai_adk/templates/.claude/agents/moai/expert-refactoring.md +228 -0
  90. moai_adk/templates/.claude/agents/moai/expert-security.md +19 -3
  91. moai_adk/templates/.claude/agents/moai/expert-testing.md +13 -9
  92. moai_adk/templates/.claude/agents/moai/manager-claude-code.md +8 -2
  93. moai_adk/templates/.claude/agents/moai/manager-docs.md +10 -5
  94. moai_adk/templates/.claude/agents/moai/manager-git.md +99 -27
  95. moai_adk/templates/.claude/agents/moai/manager-project.md +87 -7
  96. moai_adk/templates/.claude/agents/moai/manager-quality.md +22 -5
  97. moai_adk/templates/.claude/agents/moai/manager-spec.md +8 -2
  98. moai_adk/templates/.claude/agents/moai/manager-strategy.md +45 -14
  99. moai_adk/templates/.claude/agents/moai/manager-tdd.md +16 -3
  100. moai_adk/templates/.claude/commands/moai/0-project.md +239 -1185
  101. moai_adk/templates/.claude/commands/moai/1-plan.md +383 -363
  102. moai_adk/templates/.claude/commands/moai/2-run.md +254 -347
  103. moai_adk/templates/.claude/commands/moai/3-sync.md +174 -100
  104. moai_adk/templates/.claude/commands/moai/9-feedback.md +49 -33
  105. moai_adk/templates/.claude/commands/moai/alfred.md +339 -0
  106. moai_adk/templates/.claude/commands/moai/cancel-loop.md +163 -0
  107. moai_adk/templates/.claude/commands/moai/fix.md +264 -0
  108. moai_adk/templates/.claude/commands/moai/loop.md +363 -0
  109. moai_adk/templates/.claude/hooks/moai/lib/README.md +143 -0
  110. moai_adk/templates/.claude/hooks/moai/lib/__init__.py +37 -81
  111. moai_adk/templates/.claude/hooks/moai/lib/alfred_detector.py +105 -0
  112. moai_adk/templates/.claude/hooks/moai/lib/atomic_write.py +122 -0
  113. moai_adk/templates/.claude/hooks/moai/lib/checkpoint.py +4 -1
  114. moai_adk/templates/.claude/hooks/moai/lib/common.py +35 -5
  115. moai_adk/templates/.claude/hooks/moai/lib/config.py +376 -0
  116. moai_adk/templates/.claude/hooks/moai/lib/config_manager.py +24 -28
  117. moai_adk/templates/.claude/hooks/moai/lib/config_validator.py +14 -14
  118. moai_adk/templates/.claude/hooks/moai/lib/enhanced_output_style_detector.py +372 -0
  119. moai_adk/templates/.claude/hooks/moai/lib/exceptions.py +171 -0
  120. moai_adk/templates/.claude/hooks/moai/lib/file_utils.py +95 -0
  121. moai_adk/templates/.claude/hooks/moai/lib/git_collector.py +190 -0
  122. moai_adk/templates/.claude/hooks/moai/lib/git_operations_manager.py +15 -13
  123. moai_adk/templates/.claude/hooks/moai/lib/language_detector.py +298 -0
  124. moai_adk/templates/.claude/hooks/moai/lib/language_validator.py +125 -25
  125. moai_adk/templates/.claude/hooks/moai/lib/main.py +341 -0
  126. moai_adk/templates/.claude/hooks/moai/lib/memory_collector.py +268 -0
  127. moai_adk/templates/.claude/hooks/moai/lib/metrics_tracker.py +78 -0
  128. moai_adk/templates/.claude/hooks/moai/lib/models.py +9 -7
  129. moai_adk/templates/.claude/hooks/moai/lib/path_utils.py +204 -13
  130. moai_adk/templates/.claude/hooks/moai/lib/project.py +23 -14
  131. moai_adk/templates/.claude/hooks/moai/lib/renderer.py +359 -0
  132. moai_adk/templates/.claude/hooks/moai/lib/tag_linkage.py +333 -0
  133. moai_adk/templates/.claude/hooks/moai/lib/tag_parser.py +176 -0
  134. moai_adk/templates/.claude/hooks/moai/lib/tag_validator.py +200 -0
  135. moai_adk/templates/.claude/hooks/moai/lib/timeout.py +5 -5
  136. moai_adk/templates/.claude/hooks/moai/lib/tool_registry.py +896 -0
  137. moai_adk/templates/.claude/hooks/moai/lib/unified_timeout_manager.py +30 -18
  138. moai_adk/templates/.claude/hooks/moai/lib/update_checker.py +129 -0
  139. moai_adk/templates/.claude/hooks/moai/lib/version_reader.py +741 -0
  140. moai_adk/templates/.claude/hooks/moai/post_tool__ast_grep_scan.py +276 -0
  141. moai_adk/templates/.claude/hooks/moai/post_tool__code_formatter.py +255 -0
  142. moai_adk/templates/.claude/hooks/moai/post_tool__coverage_guard.py +325 -0
  143. moai_adk/templates/.claude/hooks/moai/post_tool__linter.py +315 -0
  144. moai_adk/templates/.claude/hooks/moai/post_tool__lsp_diagnostic.py +508 -0
  145. moai_adk/templates/.claude/hooks/moai/pre_commit__tag_validator.py +287 -0
  146. moai_adk/templates/.claude/hooks/moai/pre_tool__security_guard.py +268 -0
  147. moai_adk/templates/.claude/hooks/moai/pre_tool__tdd_enforcer.py +208 -0
  148. moai_adk/templates/.claude/hooks/moai/session_end__auto_cleanup.py +93 -61
  149. moai_adk/templates/.claude/hooks/moai/session_end__rank_submit.py +69 -0
  150. moai_adk/templates/.claude/hooks/moai/session_start__show_project_info.py +165 -70
  151. moai_adk/templates/.claude/hooks/moai/shared/utils/announcement_translator.py +206 -0
  152. moai_adk/templates/.claude/hooks/moai/stop__loop_controller.py +621 -0
  153. moai_adk/templates/.claude/output-styles/moai/alfred.md +758 -0
  154. moai_adk/templates/.claude/output-styles/moai/r2d2.md +86 -3
  155. moai_adk/templates/.claude/output-styles/moai/yoda.md +2 -2
  156. moai_adk/templates/.claude/settings.json +154 -77
  157. moai_adk/templates/.claude/skills/moai-docs-generation/SKILL.md +252 -198
  158. moai_adk/templates/.claude/skills/moai-docs-generation/examples.md +169 -323
  159. moai_adk/templates/.claude/skills/moai-docs-generation/modules/README.md +39 -27
  160. moai_adk/templates/.claude/skills/moai-docs-generation/modules/api-documentation.md +115 -125
  161. moai_adk/templates/.claude/skills/moai-docs-generation/modules/code-documentation.md +150 -150
  162. moai_adk/templates/.claude/skills/moai-docs-generation/modules/multi-format-output.md +182 -175
  163. moai_adk/templates/.claude/skills/moai-docs-generation/modules/user-guides.md +198 -138
  164. moai_adk/templates/.claude/skills/moai-docs-generation/reference.md +226 -320
  165. moai_adk/templates/.claude/skills/moai-domain-backend/SKILL.md +43 -222
  166. moai_adk/templates/.claude/skills/moai-domain-database/SKILL.md +75 -219
  167. moai_adk/templates/.claude/skills/moai-domain-frontend/SKILL.md +103 -463
  168. moai_adk/templates/.claude/skills/moai-domain-frontend/modules/component-architecture.md +723 -0
  169. moai_adk/templates/.claude/skills/moai-domain-frontend/modules/nextjs16-patterns.md +713 -0
  170. moai_adk/templates/.claude/skills/moai-domain-frontend/modules/performance-optimization.md +694 -0
  171. moai_adk/templates/.claude/skills/moai-domain-frontend/modules/react19-patterns.md +591 -0
  172. moai_adk/templates/.claude/skills/moai-domain-frontend/modules/state-management.md +680 -0
  173. moai_adk/templates/.claude/skills/moai-domain-frontend/modules/vue35-patterns.md +802 -0
  174. moai_adk/templates/.claude/skills/moai-domain-uiux/SKILL.md +118 -339
  175. moai_adk/templates/.claude/skills/moai-formats-data/SKILL.md +74 -377
  176. moai_adk/templates/.claude/skills/moai-formats-data/modules/README.md +299 -70
  177. moai_adk/templates/.claude/skills/moai-foundation-claude/SKILL.md +205 -182
  178. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/advanced-agent-patterns.md +370 -0
  179. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-cli-reference-official.md +420 -0
  180. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-custom-slash-commands-official.md +32 -22
  181. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-devcontainers-official.md +381 -0
  182. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-discover-plugins-official.md +379 -0
  183. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-headless-official.md +378 -0
  184. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-hooks-official.md +110 -0
  185. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-plugin-marketplaces-official.md +308 -0
  186. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-plugins-official.md +640 -0
  187. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-sandboxing-official.md +282 -0
  188. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-skills-official.md +425 -71
  189. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-statusline-official.md +293 -0
  190. moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-sub-agents-official.md +325 -143
  191. moai_adk/templates/.claude/skills/moai-foundation-context/SKILL.md +96 -316
  192. moai_adk/templates/.claude/skills/moai-foundation-core/SKILL.md +116 -294
  193. moai_adk/templates/.claude/skills/moai-foundation-core/modules/delegation-advanced.md +279 -0
  194. moai_adk/templates/.claude/skills/moai-foundation-core/modules/delegation-implementation.md +267 -0
  195. moai_adk/templates/.claude/skills/moai-foundation-core/modules/delegation-patterns.md +121 -650
  196. moai_adk/templates/.claude/skills/moai-foundation-core/modules/patterns.md +22 -0
  197. moai_adk/templates/.claude/skills/moai-foundation-core/modules/spec-ears-format.md +200 -0
  198. moai_adk/templates/.claude/skills/moai-foundation-core/modules/spec-first-tdd.md +37 -730
  199. moai_adk/templates/.claude/skills/moai-foundation-core/modules/spec-tdd-implementation.md +275 -0
  200. moai_adk/templates/.claude/skills/moai-foundation-core/modules/trust-5-framework.md +77 -819
  201. moai_adk/templates/.claude/skills/moai-foundation-core/modules/trust-5-implementation.md +244 -0
  202. moai_adk/templates/.claude/skills/moai-foundation-core/modules/trust-5-validation.md +219 -0
  203. moai_adk/templates/.claude/skills/moai-foundation-philosopher/SKILL.md +14 -18
  204. moai_adk/templates/.claude/skills/moai-foundation-quality/SKILL.md +86 -270
  205. moai_adk/templates/.claude/skills/moai-framework-electron/SKILL.md +288 -0
  206. moai_adk/templates/.claude/skills/moai-framework-electron/examples.md +2082 -0
  207. moai_adk/templates/.claude/skills/moai-framework-electron/reference.md +1649 -0
  208. moai_adk/templates/.claude/skills/moai-lang-cpp/SKILL.md +76 -582
  209. moai_adk/templates/.claude/skills/moai-lang-cpp/examples.md +1239 -0
  210. moai_adk/templates/.claude/skills/moai-lang-cpp/modules/advanced-patterns.md +401 -0
  211. moai_adk/templates/.claude/skills/moai-lang-cpp/reference.md +1136 -0
  212. moai_adk/templates/.claude/skills/moai-lang-csharp/SKILL.md +82 -436
  213. moai_adk/templates/.claude/skills/moai-lang-csharp/examples.md +585 -0
  214. moai_adk/templates/.claude/skills/moai-lang-csharp/modules/aspnet-core.md +627 -0
  215. moai_adk/templates/.claude/skills/moai-lang-csharp/modules/blazor-components.md +767 -0
  216. moai_adk/templates/.claude/skills/moai-lang-csharp/modules/cqrs-validation.md +626 -0
  217. moai_adk/templates/.claude/skills/moai-lang-csharp/modules/csharp12-features.md +580 -0
  218. moai_adk/templates/.claude/skills/moai-lang-csharp/modules/efcore-patterns.md +622 -0
  219. moai_adk/templates/.claude/skills/moai-lang-csharp/reference.md +403 -0
  220. moai_adk/templates/.claude/skills/moai-lang-elixir/SKILL.md +65 -542
  221. moai_adk/templates/.claude/skills/moai-lang-elixir/examples.md +1171 -0
  222. moai_adk/templates/.claude/skills/moai-lang-elixir/modules/advanced-patterns.md +531 -0
  223. moai_adk/templates/.claude/skills/moai-lang-elixir/reference.md +889 -0
  224. moai_adk/templates/.claude/skills/moai-lang-flutter/SKILL.md +32 -405
  225. moai_adk/templates/.claude/skills/moai-lang-go/SKILL.md +114 -293
  226. moai_adk/templates/.claude/skills/moai-lang-java/SKILL.md +83 -307
  227. moai_adk/templates/.claude/skills/moai-lang-javascript/SKILL.md +179 -0
  228. moai_adk/templates/.claude/skills/moai-lang-javascript/examples.md +973 -0
  229. moai_adk/templates/.claude/skills/moai-lang-javascript/reference.md +1543 -0
  230. moai_adk/templates/.claude/skills/moai-lang-kotlin/SKILL.md +42 -279
  231. moai_adk/templates/.claude/skills/moai-lang-php/SKILL.md +94 -556
  232. moai_adk/templates/.claude/skills/moai-lang-php/examples.md +1608 -0
  233. moai_adk/templates/.claude/skills/moai-lang-php/modules/advanced-patterns.md +538 -0
  234. moai_adk/templates/.claude/skills/moai-lang-php/reference.md +1323 -0
  235. moai_adk/templates/.claude/skills/moai-lang-python/SKILL.md +108 -358
  236. moai_adk/templates/.claude/skills/moai-lang-r/SKILL.md +84 -482
  237. moai_adk/templates/.claude/skills/moai-lang-r/examples.md +1154 -0
  238. moai_adk/templates/.claude/skills/moai-lang-r/modules/advanced-patterns.md +489 -0
  239. moai_adk/templates/.claude/skills/moai-lang-r/reference.md +1087 -0
  240. moai_adk/templates/.claude/skills/moai-lang-ruby/SKILL.md +106 -610
  241. moai_adk/templates/.claude/skills/moai-lang-ruby/examples.md +1106 -0
  242. moai_adk/templates/.claude/skills/moai-lang-ruby/modules/advanced-patterns.md +309 -0
  243. moai_adk/templates/.claude/skills/moai-lang-ruby/modules/testing-patterns.md +306 -0
  244. moai_adk/templates/.claude/skills/moai-lang-ruby/reference.md +1024 -0
  245. moai_adk/templates/.claude/skills/moai-lang-rust/SKILL.md +51 -265
  246. moai_adk/templates/.claude/skills/moai-lang-scala/SKILL.md +106 -442
  247. moai_adk/templates/.claude/skills/moai-lang-scala/modules/akka-actors.md +479 -0
  248. moai_adk/templates/.claude/skills/moai-lang-scala/modules/cats-effect.md +489 -0
  249. moai_adk/templates/.claude/skills/moai-lang-scala/modules/functional-programming.md +460 -0
  250. moai_adk/templates/.claude/skills/moai-lang-scala/modules/spark-data.md +498 -0
  251. moai_adk/templates/.claude/skills/moai-lang-scala/modules/zio-patterns.md +541 -0
  252. moai_adk/templates/.claude/skills/moai-lang-swift/SKILL.md +88 -457
  253. moai_adk/templates/.claude/skills/moai-lang-swift/modules/combine-reactive.md +256 -0
  254. moai_adk/templates/.claude/skills/moai-lang-swift/modules/concurrency.md +270 -0
  255. moai_adk/templates/.claude/skills/moai-lang-swift/modules/swift6-features.md +265 -0
  256. moai_adk/templates/.claude/skills/moai-lang-swift/modules/swiftui-patterns.md +314 -0
  257. moai_adk/templates/.claude/skills/moai-lang-typescript/SKILL.md +75 -283
  258. moai_adk/templates/.claude/skills/moai-library-mermaid/SKILL.md +97 -252
  259. moai_adk/templates/.claude/skills/moai-library-nextra/SKILL.md +64 -240
  260. moai_adk/templates/.claude/skills/moai-library-nextra/modules/advanced-patterns.md +331 -12
  261. moai_adk/templates/.claude/skills/moai-library-nextra/modules/configuration.md +330 -37
  262. moai_adk/templates/.claude/skills/moai-library-shadcn/SKILL.md +90 -287
  263. moai_adk/templates/.claude/skills/moai-platform-auth0/SKILL.md +200 -206
  264. moai_adk/templates/.claude/skills/moai-platform-auth0/examples.md +2446 -0
  265. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/adaptive-mfa.md +233 -0
  266. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/akamai-integration.md +214 -0
  267. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/application-credentials.md +280 -0
  268. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/attack-protection-log-events.md +224 -0
  269. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/attack-protection-overview.md +140 -0
  270. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/bot-detection.md +144 -0
  271. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/breached-password-detection.md +187 -0
  272. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/brute-force-protection.md +189 -0
  273. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/certifications.md +282 -0
  274. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/compliance-overview.md +263 -0
  275. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/continuous-session-protection.md +307 -0
  276. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/customize-mfa.md +177 -0
  277. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/dpop-implementation.md +283 -0
  278. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/fapi-implementation.md +259 -0
  279. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/gdpr-compliance.md +313 -0
  280. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/guardian-configuration.md +269 -0
  281. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/highly-regulated-identity.md +272 -0
  282. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/jwt-fundamentals.md +248 -0
  283. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/mdl-verification.md +210 -0
  284. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/mfa-api-management.md +278 -0
  285. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/mfa-factors.md +226 -0
  286. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/mfa-overview.md +174 -0
  287. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/mtls-sender-constraining.md +316 -0
  288. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/ropg-flow-mfa.md +216 -0
  289. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/security-center.md +325 -0
  290. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/security-guidance.md +277 -0
  291. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/state-parameters.md +177 -0
  292. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/step-up-authentication.md +251 -0
  293. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/suspicious-ip-throttling.md +240 -0
  294. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/tenant-access-control.md +179 -0
  295. moai_adk/templates/.claude/skills/moai-platform-auth0/modules/webauthn-fido.md +235 -0
  296. moai_adk/templates/.claude/skills/moai-platform-auth0/reference.md +224 -0
  297. moai_adk/templates/.claude/skills/moai-platform-clerk/SKILL.md +75 -330
  298. moai_adk/templates/.claude/skills/moai-platform-clerk/examples.md +1426 -0
  299. moai_adk/templates/.claude/skills/moai-platform-clerk/modules/advanced-patterns.md +417 -0
  300. moai_adk/templates/.claude/skills/moai-platform-clerk/reference.md +273 -0
  301. moai_adk/templates/.claude/skills/moai-platform-convex/SKILL.md +100 -340
  302. moai_adk/templates/.claude/skills/moai-platform-convex/examples.md +506 -0
  303. moai_adk/templates/.claude/skills/moai-platform-convex/modules/auth-integration.md +421 -0
  304. moai_adk/templates/.claude/skills/moai-platform-convex/modules/file-storage.md +474 -0
  305. moai_adk/templates/.claude/skills/moai-platform-convex/modules/reactive-queries.md +302 -0
  306. moai_adk/templates/.claude/skills/moai-platform-convex/modules/server-functions.md +452 -0
  307. moai_adk/templates/.claude/skills/moai-platform-convex/reference.md +385 -0
  308. moai_adk/templates/.claude/skills/moai-platform-firebase-auth/SKILL.md +113 -326
  309. moai_adk/templates/.claude/skills/moai-platform-firebase-auth/examples.md +514 -0
  310. moai_adk/templates/.claude/skills/moai-platform-firebase-auth/modules/custom-claims.md +374 -0
  311. moai_adk/templates/.claude/skills/moai-platform-firebase-auth/modules/phone-auth.md +372 -0
  312. moai_adk/templates/.claude/skills/moai-platform-firebase-auth/modules/social-auth.md +339 -0
  313. moai_adk/templates/.claude/skills/moai-platform-firebase-auth/reference.md +382 -0
  314. moai_adk/templates/.claude/skills/moai-platform-firestore/SKILL.md +71 -302
  315. moai_adk/templates/.claude/skills/moai-platform-firestore/examples.md +445 -0
  316. moai_adk/templates/.claude/skills/moai-platform-firestore/modules/offline-cache.md +392 -0
  317. moai_adk/templates/.claude/skills/moai-platform-firestore/modules/realtime-listeners.md +441 -0
  318. moai_adk/templates/.claude/skills/moai-platform-firestore/modules/security-rules.md +352 -0
  319. moai_adk/templates/.claude/skills/moai-platform-firestore/modules/transactions.md +452 -0
  320. moai_adk/templates/.claude/skills/moai-platform-firestore/reference.md +322 -0
  321. moai_adk/templates/.claude/skills/moai-platform-neon/SKILL.md +101 -412
  322. moai_adk/templates/.claude/skills/moai-platform-neon/examples.md +470 -0
  323. moai_adk/templates/.claude/skills/moai-platform-neon/modules/auto-scaling.md +349 -0
  324. moai_adk/templates/.claude/skills/moai-platform-neon/modules/branching-workflows.md +354 -0
  325. moai_adk/templates/.claude/skills/moai-platform-neon/modules/connection-pooling.md +412 -0
  326. moai_adk/templates/.claude/skills/moai-platform-neon/modules/pitr-backups.md +458 -0
  327. moai_adk/templates/.claude/skills/moai-platform-neon/reference.md +272 -0
  328. moai_adk/templates/.claude/skills/moai-platform-railway/SKILL.md +96 -327
  329. moai_adk/templates/.claude/skills/moai-platform-railway/examples.md +539 -0
  330. moai_adk/templates/.claude/skills/moai-platform-railway/modules/docker-deployment.md +261 -0
  331. moai_adk/templates/.claude/skills/moai-platform-railway/modules/multi-service.md +291 -0
  332. moai_adk/templates/.claude/skills/moai-platform-railway/modules/networking-domains.md +338 -0
  333. moai_adk/templates/.claude/skills/moai-platform-railway/modules/volumes-storage.md +353 -0
  334. moai_adk/templates/.claude/skills/moai-platform-railway/reference.md +374 -0
  335. moai_adk/templates/.claude/skills/moai-platform-supabase/SKILL.md +103 -428
  336. moai_adk/templates/.claude/skills/moai-platform-supabase/examples.md +502 -0
  337. moai_adk/templates/.claude/skills/moai-platform-supabase/modules/auth-integration.md +384 -0
  338. moai_adk/templates/.claude/skills/moai-platform-supabase/modules/edge-functions.md +371 -0
  339. moai_adk/templates/.claude/skills/moai-platform-supabase/modules/postgresql-pgvector.md +231 -0
  340. moai_adk/templates/.claude/skills/moai-platform-supabase/modules/realtime-presence.md +354 -0
  341. moai_adk/templates/.claude/skills/moai-platform-supabase/modules/row-level-security.md +286 -0
  342. moai_adk/templates/.claude/skills/moai-platform-supabase/modules/storage-cdn.md +319 -0
  343. moai_adk/templates/.claude/skills/moai-platform-supabase/modules/typescript-patterns.md +453 -0
  344. moai_adk/templates/.claude/skills/moai-platform-supabase/reference.md +284 -0
  345. moai_adk/templates/.claude/skills/moai-platform-vercel/SKILL.md +96 -446
  346. moai_adk/templates/.claude/skills/moai-platform-vercel/examples.md +502 -0
  347. moai_adk/templates/.claude/skills/moai-platform-vercel/modules/analytics-speed.md +348 -0
  348. moai_adk/templates/.claude/skills/moai-platform-vercel/modules/deployment-config.md +344 -0
  349. moai_adk/templates/.claude/skills/moai-platform-vercel/modules/edge-functions.md +222 -0
  350. moai_adk/templates/.claude/skills/moai-platform-vercel/modules/isr-caching.md +306 -0
  351. moai_adk/templates/.claude/skills/moai-platform-vercel/modules/kv-storage.md +399 -0
  352. moai_adk/templates/.claude/skills/moai-platform-vercel/reference.md +360 -0
  353. moai_adk/templates/.claude/skills/moai-tool-ast-grep/SKILL.md +193 -0
  354. moai_adk/templates/.claude/skills/moai-tool-ast-grep/examples.md +1099 -0
  355. moai_adk/templates/.claude/skills/moai-tool-ast-grep/modules/language-specific.md +307 -0
  356. moai_adk/templates/.claude/skills/moai-tool-ast-grep/modules/pattern-syntax.md +237 -0
  357. moai_adk/templates/.claude/skills/moai-tool-ast-grep/modules/refactoring-patterns.md +260 -0
  358. moai_adk/templates/.claude/skills/moai-tool-ast-grep/modules/security-rules.md +239 -0
  359. moai_adk/templates/.claude/skills/moai-tool-ast-grep/reference.md +288 -0
  360. moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/languages/go.yml +90 -0
  361. moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/languages/python.yml +101 -0
  362. moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/languages/typescript.yml +83 -0
  363. moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/quality/complexity-check.yml +94 -0
  364. moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/quality/deprecated-apis.yml +84 -0
  365. moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/security/secrets-detection.yml +89 -0
  366. moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/security/sql-injection.yml +45 -0
  367. moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/security/xss-prevention.yml +50 -0
  368. moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/sgconfig.yml +54 -0
  369. moai_adk/templates/.claude/skills/moai-workflow-jit-docs/SKILL.md +225 -423
  370. moai_adk/templates/.claude/skills/moai-workflow-loop/SKILL.md +197 -0
  371. moai_adk/templates/.claude/skills/moai-workflow-loop/examples.md +1063 -0
  372. moai_adk/templates/.claude/skills/moai-workflow-loop/reference.md +1414 -0
  373. moai_adk/templates/.claude/skills/moai-workflow-project/SKILL.md +211 -314
  374. moai_adk/templates/.claude/skills/moai-workflow-project/schemas/tab_schema.json +15 -43
  375. moai_adk/templates/.claude/skills/moai-workflow-spec/SKILL.md +119 -316
  376. moai_adk/templates/.claude/skills/moai-workflow-spec/modules/advanced-patterns.md +237 -0
  377. moai_adk/templates/.claude/skills/moai-workflow-templates/SKILL.md +96 -203
  378. moai_adk/templates/.claude/skills/moai-workflow-testing/SKILL.md +201 -388
  379. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/README.md +52 -3
  380. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/ai-debugging.md +263 -806
  381. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/context7-integration.md +286 -0
  382. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/review-workflows.md +500 -0
  383. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework/relevance-analysis.md +154 -0
  384. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework/safety-analysis.md +148 -0
  385. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework/scoring-algorithms.md +196 -0
  386. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework/timeliness-analysis.md +168 -0
  387. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework/truthfulness-analysis.md +136 -0
  388. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework/usability-analysis.md +153 -0
  389. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework.md +257 -0
  390. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review.md +191 -1344
  391. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/code-review/analysis-patterns.md +340 -0
  392. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/code-review/core-classes.md +299 -0
  393. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/code-review/tool-integration.md +380 -0
  394. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/debugging/debugging-workflows.md +451 -0
  395. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/debugging/error-analysis.md +442 -0
  396. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance/optimization-patterns.md +473 -0
  397. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance/profiling-techniques.md +481 -0
  398. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance-optimization/ai-optimization.md +241 -0
  399. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance-optimization/bottleneck-detection.md +397 -0
  400. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance-optimization/optimization-plan.md +315 -0
  401. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance-optimization/profiler-core.md +277 -0
  402. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance-optimization/real-time-monitoring.md +187 -0
  403. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance-optimization.md +287 -1194
  404. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/quality-metrics.md +415 -0
  405. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/refactoring/ai-workflows.md +620 -0
  406. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/refactoring/patterns.md +692 -0
  407. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/security-analysis.md +429 -0
  408. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/smart-refactoring.md +262 -1192
  409. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/static-analysis.md +438 -0
  410. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/tdd/core-classes.md +397 -0
  411. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/tdd-context7/advanced-features.md +494 -0
  412. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/tdd-context7/red-green-refactor.md +316 -0
  413. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/tdd-context7/test-generation.md +471 -0
  414. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/tdd-context7/test-patterns.md +371 -0
  415. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/tdd-context7.md +227 -1222
  416. moai_adk/templates/.claude/skills/moai-workflow-testing/modules/trust5-validation.md +428 -0
  417. moai_adk/templates/.claude/skills/moai-workflow-worktree/SKILL.md +228 -0
  418. moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/integration-patterns.md +149 -0
  419. moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/moai-adk-integration.md +245 -0
  420. moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/parallel-advanced.md +310 -0
  421. moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/parallel-development.md +202 -0
  422. moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/parallel-workflows.md +302 -0
  423. moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/registry-architecture.md +271 -0
  424. moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/resource-optimization.md +300 -0
  425. moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/tools-integration.md +280 -0
  426. moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/troubleshooting.md +397 -0
  427. moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/worktree-commands.md +296 -0
  428. moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/worktree-management.md +217 -0
  429. moai_adk/templates/.git-hooks/pre-push +162 -59
  430. moai_adk/templates/.github/workflows/ci-universal.yml +934 -133
  431. moai_adk/templates/.gitignore +65 -107
  432. moai_adk/templates/.lsp.json +152 -0
  433. moai_adk/templates/.mcp.json +2 -20
  434. moai_adk/templates/.moai/announcements/en.json +18 -0
  435. moai_adk/templates/.moai/announcements/ja.json +18 -0
  436. moai_adk/templates/.moai/announcements/ko.json +18 -0
  437. moai_adk/templates/.moai/announcements/zh.json +18 -0
  438. moai_adk/templates/.moai/config/config.yaml +8 -2
  439. moai_adk/templates/.moai/config/multilingual-triggers.yaml +213 -0
  440. moai_adk/templates/.moai/config/sections/language.yaml +2 -2
  441. moai_adk/templates/.moai/config/sections/llm.yaml +41 -0
  442. moai_adk/templates/.moai/config/sections/pricing.yaml +30 -0
  443. moai_adk/templates/.moai/config/sections/project.yaml +2 -2
  444. moai_adk/templates/.moai/config/sections/quality.yaml +43 -5
  445. moai_adk/templates/.moai/config/sections/ralph.yaml +55 -0
  446. moai_adk/templates/.moai/config/sections/system.yaml +46 -1
  447. moai_adk/templates/.moai/config/sections/user.yaml +1 -1
  448. moai_adk/templates/.moai/config/statusline-config.yaml +2 -2
  449. moai_adk/templates/.moai/llm-configs/glm.json +22 -0
  450. moai_adk/templates/CLAUDE.ja.md +343 -0
  451. moai_adk/templates/CLAUDE.ko.md +343 -0
  452. moai_adk/templates/CLAUDE.md +200 -499
  453. moai_adk/templates/CLAUDE.zh.md +343 -0
  454. moai_adk/utils/common.py +37 -0
  455. moai_adk/version.py +1 -1
  456. moai_adk-1.1.0.dist-info/METADATA +2443 -0
  457. moai_adk-1.1.0.dist-info/RECORD +701 -0
  458. {moai_adk-0.34.0.dist-info → moai_adk-1.1.0.dist-info}/entry_points.txt +2 -0
  459. moai_adk-1.1.0.dist-info/licenses/LICENSE +99 -0
  460. moai_adk/core/config/auto_spec_config.py +0 -340
  461. moai_adk/core/hooks/post_tool_auto_spec_completion.py +0 -901
  462. moai_adk/core/spec/confidence_scoring.py +0 -680
  463. moai_adk/core/spec/ears_template_engine.py +0 -1247
  464. moai_adk/core/spec/quality_validator.py +0 -687
  465. moai_adk/templates/.claude/agents/moai/ai-nano-banana.md +0 -670
  466. moai_adk/templates/.claude/agents/moai/expert-database.md +0 -777
  467. moai_adk/templates/.claude/agents/moai/expert-uiux.md +0 -1041
  468. moai_adk/templates/.claude/agents/moai/mcp-context7.md +0 -458
  469. moai_adk/templates/.claude/agents/moai/mcp-figma.md +0 -1607
  470. moai_adk/templates/.claude/agents/moai/mcp-notion.md +0 -789
  471. moai_adk/templates/.claude/agents/moai/mcp-playwright.md +0 -469
  472. moai_adk/templates/.claude/agents/moai/mcp-sequential-thinking.md +0 -1032
  473. moai_adk/templates/.claude/skills/moai-ai-nano-banana/SKILL.md +0 -438
  474. moai_adk/templates/.claude/skills/moai-ai-nano-banana/examples.md +0 -431
  475. moai_adk/templates/.claude/skills/moai-domain-uiux/modules/design-system-tokens.md +0 -405
  476. moai_adk/templates/.claude/skills/moai-library-nextra/advanced-patterns.md +0 -336
  477. moai_adk/templates/.claude/skills/moai-mcp-figma/SKILL.md +0 -402
  478. moai_adk/templates/.claude/skills/moai-mcp-figma/advanced-patterns.md +0 -607
  479. moai_adk/templates/.claude/skills/moai-mcp-notion/SKILL.md +0 -300
  480. moai_adk/templates/.claude/skills/moai-mcp-notion/advanced-patterns.md +0 -537
  481. moai_adk/templates/.claude/skills/moai-workflow-project/__init__.py +0 -520
  482. moai_adk/templates/.claude/skills/moai-workflow-project/complete_workflow_demo_fixed.py +0 -574
  483. moai_adk/templates/.claude/skills/moai-workflow-project/examples/complete_project_setup.py +0 -317
  484. moai_adk/templates/.claude/skills/moai-workflow-project/examples/complete_workflow_demo.py +0 -663
  485. moai_adk/templates/.claude/skills/moai-workflow-project/examples/config-migration-example.json +0 -190
  486. moai_adk/templates/.claude/skills/moai-workflow-project/examples/question-examples.json +0 -175
  487. moai_adk/templates/.claude/skills/moai-workflow-project/examples/quick_start.py +0 -196
  488. moai_adk/templates/.claude/skills/moai-workflow-project/modules/__init__.py +0 -17
  489. moai_adk/templates/.claude/skills/moai-workflow-project/modules/advanced-patterns.md +0 -158
  490. moai_adk/templates/.claude/skills/moai-workflow-project/modules/ask_user_integration.py +0 -340
  491. moai_adk/templates/.claude/skills/moai-workflow-project/modules/batch_questions.py +0 -713
  492. moai_adk/templates/.claude/skills/moai-workflow-project/modules/config_manager.py +0 -538
  493. moai_adk/templates/.claude/skills/moai-workflow-project/modules/documentation_manager.py +0 -1336
  494. moai_adk/templates/.claude/skills/moai-workflow-project/modules/language_initializer.py +0 -730
  495. moai_adk/templates/.claude/skills/moai-workflow-project/modules/migration_manager.py +0 -608
  496. moai_adk/templates/.claude/skills/moai-workflow-project/modules/template_optimizer.py +0 -1005
  497. moai_adk/templates/.claude/skills/moai-workflow-project/test_integration_simple.py +0 -436
  498. moai_adk/templates/.claude/skills/moai-worktree/SKILL.md +0 -411
  499. moai_adk/templates/.claude/skills/moai-worktree/modules/integration-patterns.md +0 -982
  500. moai_adk/templates/.claude/skills/moai-worktree/modules/parallel-development.md +0 -778
  501. moai_adk/templates/.claude/skills/moai-worktree/modules/worktree-commands.md +0 -646
  502. moai_adk/templates/.claude/skills/moai-worktree/modules/worktree-management.md +0 -782
  503. moai_adk/templates/.moai/config/questions/_schema.yaml +0 -151
  504. moai_adk/templates/.moai/config/questions/tab0-init.yaml +0 -251
  505. moai_adk/templates/.moai/config/questions/tab1-user.yaml +0 -108
  506. moai_adk/templates/.moai/config/questions/tab2-project.yaml +0 -81
  507. moai_adk/templates/.moai/config/questions/tab3-git.yaml +0 -634
  508. moai_adk/templates/.moai/config/questions/tab4-quality.yaml +0 -170
  509. moai_adk/templates/.moai/config/questions/tab5-system.yaml +0 -87
  510. moai_adk/templates/.moai/scripts/setup-glm.py +0 -136
  511. moai_adk-0.34.0.dist-info/METADATA +0 -2999
  512. moai_adk-0.34.0.dist-info/RECORD +0 -463
  513. moai_adk-0.34.0.dist-info/licenses/LICENSE +0 -21
  514. /moai_adk/foundation/{git.py → git/__init__.py} +0 -0
  515. /moai_adk/templates/.claude/skills/moai-library-mermaid/{advanced-patterns.md → modules/advanced-patterns.md} +0 -0
  516. /moai_adk/templates/.claude/skills/moai-library-mermaid/{optimization.md → modules/optimization.md} +0 -0
  517. /moai_adk/templates/.claude/skills/moai-library-nextra/{optimization.md → modules/optimization.md} +0 -0
  518. /moai_adk/templates/.claude/skills/moai-workflow-jit-docs/{advanced-patterns.md → modules/advanced-patterns.md} +0 -0
  519. /moai_adk/templates/.claude/skills/moai-workflow-jit-docs/{optimization.md → modules/optimization.md} +0 -0
  520. /moai_adk/templates/.claude/skills/moai-workflow-testing/{advanced-patterns.md → modules/advanced-patterns.md} +0 -0
  521. /moai_adk/templates/.claude/skills/moai-workflow-testing/{optimization.md → modules/optimization.md} +0 -0
  522. /moai_adk/templates/.claude/skills/{moai-worktree → moai-workflow-worktree}/examples.md +0 -0
  523. /moai_adk/templates/.claude/skills/{moai-worktree → moai-workflow-worktree}/reference.md +0 -0
  524. {moai_adk-0.34.0.dist-info → moai_adk-1.1.0.dist-info}/WHEEL +0 -0
@@ -5,1412 +5,259 @@
5
5
  > Time: 35+ minutes
6
6
  > Dependencies: Python 3.8+, Context7 MCP, ast, pylint, flake8, bandit, mypy
7
7
 
8
- ## Core Implementation
8
+ ## Quick Reference
9
9
 
10
- ### AutomatedCodeReviewer Class
10
+ ### Core Capabilities
11
11
 
12
- ```python
13
- import ast
14
- import subprocess
15
- import json
16
- import asyncio
17
- from typing import Dict, List, Optional, Any, Union, Callable, Set
18
- from dataclasses import dataclass, field
19
- from enum import Enum
20
- import re
21
- import os
22
- import sys
23
- from pathlib import Path
24
- import tempfile
25
- import difflib
26
-
27
- class TrustCategory(Enum):
28
- """TRUST 5 framework categories."""
29
- TRUTHFULNESS = "truthfulness" # Code correctness and logic accuracy
30
- RELEVANCE = "relevance" # Code meets requirements and purpose
31
- USABILITY = "usability" # Code is maintainable and understandable
32
- SAFETY = "safety" # Code is secure and handles errors properly
33
- TIMELINESS = "timeliness" # Code meets performance and delivery standards
34
-
35
- class Severity(Enum):
36
- """Issue severity levels."""
37
- CRITICAL = "critical"
38
- HIGH = "high"
39
- MEDIUM = "medium"
40
- LOW = "low"
41
- INFO = "info"
42
-
43
- class IssueType(Enum):
44
- """Types of code issues."""
45
- SYNTAX_ERROR = "syntax_error"
46
- LOGIC_ERROR = "logic_error"
47
- SECURITY_VULNERABILITY = "security_vulnerability"
48
- PERFORMANCE_ISSUE = "performance_issue"
49
- CODE_SMELL = "code_smell"
50
- STYLE_VIOLATION = "style_violation"
51
- DOCUMENTATION_ISSUE = "documentation_issue"
52
- TESTING_ISSUE = "testing_issue"
53
- TYPE_ERROR = "type_error"
54
- IMPORT_ISSUE = "import_issue"
55
-
56
- @dataclass
57
- class CodeIssue:
58
- """Individual code issue found during review."""
59
- id: str
60
- category: TrustCategory
61
- severity: Severity
62
- issue_type: IssueType
63
- title: str
64
- description: str
65
- file_path: str
66
- line_number: int
67
- column_number: int
68
- code_snippet: str
69
- suggested_fix: str
70
- confidence: float # 0.0 to 1.0
71
- rule_violated: Optional[str] = None
72
- external_reference: Optional[str] = None
73
- auto_fixable: bool = False
74
- fix_diff: Optional[str] = None
75
-
76
- @dataclass
77
- class FileReviewResult:
78
- """Review results for a single file."""
79
- file_path: str
80
- issues: List[CodeIssue]
81
- metrics: Dict[str, Any]
82
- trust_score: float # 0.0 to 1.0
83
- category_scores: Dict[TrustCategory, float]
84
- lines_of_code: int
85
- complexity_metrics: Dict[str, float]
86
- review_timestamp: float
87
-
88
- @dataclass
89
- class CodeReviewReport:
90
- """Comprehensive code review report."""
91
- project_path: str
92
- files_reviewed: List[FileReviewResult]
93
- overall_trust_score: float
94
- overall_category_scores: Dict[TrustCategory, float]
95
- summary_metrics: Dict[str, Any]
96
- recommendations: List[str]
97
- critical_issues: List[CodeIssue]
98
- review_duration: float
99
- context7_patterns_used: List[str]
100
-
101
- class Context7CodeAnalyzer:
102
- """Integration with Context7 for code analysis patterns."""
103
-
104
- def __init__(self, context7_client=None):
105
- self.context7 = context7_client
106
- self.analysis_patterns = {}
107
- self.security_patterns = {}
108
- self.performance_patterns = {}
109
-
110
- async def load_analysis_patterns(self, language: str = "python") -> Dict[str, Any]:
111
- """Load code analysis patterns from Context7."""
112
-
113
- if not self.context7:
114
- return self._get_default_analysis_patterns()
115
-
116
- try:
117
- # Load security analysis patterns
118
- security_patterns = await self.context7.get_library_docs(
119
- context7_library_id="/security/semgrep",
120
- topic="security vulnerability detection patterns 2025",
121
- tokens=4000
122
- )
123
- self.security_patterns = security_patterns
124
-
125
- # Load performance analysis patterns
126
- performance_patterns = await self.context7.get_library_docs(
127
- context7_library_id="/performance/python-profiling",
128
- topic="performance anti-patterns code analysis 2025",
129
- tokens=3000
130
- )
131
- self.performance_patterns = performance_patterns
132
-
133
- # Load code quality patterns
134
- quality_patterns = await self.context7.get_library_docs(
135
- context7_library_id="/code-quality/sonarqube",
136
- topic="code quality best practices smells detection 2025",
137
- tokens=4000
138
- )
139
-
140
- # Load TRUST 5 validation patterns
141
- trust_patterns = await self.context7.get_library_docs(
142
- context7_library_id="/code-review/trust-framework",
143
- topic="TRUST 5 code validation framework patterns 2025",
144
- tokens=3000
145
- )
146
-
147
- return {
148
- 'security': security_patterns,
149
- 'performance': performance_patterns,
150
- 'quality': quality_patterns,
151
- 'trust': trust_patterns
152
- }
153
-
154
- except Exception as e:
155
- print(f"Failed to load Context7 patterns: {e}")
156
- return self._get_default_analysis_patterns()
157
-
158
- def _get_default_analysis_patterns(self) -> Dict[str, Any]:
159
- """Get default analysis patterns when Context7 is unavailable."""
160
- return {
161
- 'security': {
162
- 'sql_injection': [
163
- r"execute\([^)]*\+[^)]*\)",
164
- r"format\s*\(",
165
- r"%\s*[^,]*s"
166
- ],
167
- 'command_injection': [
168
- r"os\.system\(",
169
- r"subprocess\.call\(",
170
- r"eval\("
171
- ],
172
- 'path_traversal': [
173
- r"open\([^)]*\+[^)]*\)",
174
- r"\.\.\/"
175
- ]
176
- },
177
- 'performance': {
178
- 'inefficient_loops': [
179
- r"for.*in.*range\(len\(",
180
- r"while.*len\("
181
- ],
182
- 'memory_leaks': [
183
- r"global\s+",
184
- r"\.append\(.*\)\s*\.append\("
185
- ]
186
- },
187
- 'quality': {
188
- 'long_functions': {'max_lines': 50},
189
- 'complex_conditionals': {'max_complexity': 10},
190
- 'deep_nesting': {'max_depth': 4}
191
- }
192
- }
193
-
194
- class StaticAnalysisTools:
195
- """Wrapper for various static analysis tools."""
196
-
197
- def __init__(self):
198
- self.tools = {
199
- 'pylint': self._run_pylint,
200
- 'flake8': self._run_flake8,
201
- 'bandit': self._run_bandit,
202
- 'mypy': self._run_mypy
203
- }
204
-
205
- async def run_all_analyses(self, file_path: str) -> Dict[str, Any]:
206
- """Run all available static analysis tools."""
207
-
208
- results = {}
209
-
210
- for tool_name, tool_func in self.tools.items():
211
- try:
212
- result = await tool_func(file_path)
213
- results[tool_name] = result
214
- except Exception as e:
215
- print(f"Error running {tool_name}: {e}")
216
- results[tool_name] = {'error': str(e)}
217
-
218
- return results
219
-
220
- async def _run_pylint(self, file_path: str) -> Dict[str, Any]:
221
- """Run pylint analysis."""
222
- try:
223
- result = subprocess.run(
224
- ['pylint', file_path, '--output-format=json'],
225
- capture_output=True,
226
- text=True
227
- )
228
-
229
- if result.returncode == 0:
230
- return {'issues': []}
231
-
232
- try:
233
- issues = json.loads(result.stdout)
234
- return {'issues': issues, 'summary': self._parse_pylint_summary(result.stderr)}
235
- except json.JSONDecodeError:
236
- return {'raw_output': result.stdout, 'raw_errors': result.stderr}
237
-
238
- except FileNotFoundError:
239
- return {'error': 'pylint not installed'}
240
-
241
- async def _run_flake8(self, file_path: str) -> Dict[str, Any]:
242
- """Run flake8 analysis."""
243
- try:
244
- result = subprocess.run(
245
- ['flake8', file_path, '--format=json'],
246
- capture_output=True,
247
- text=True
248
- )
249
-
250
- if result.returncode == 0:
251
- return {'issues': []}
252
-
253
- # Parse flake8 output
254
- issues = []
255
- for line in result.stdout.split('\n'):
256
- if line.strip():
257
- parts = line.split(':')
258
- if len(parts) >= 4:
259
- issues.append({
260
- 'path': parts[0],
261
- 'line': int(parts[1]),
262
- 'column': int(parts[2]),
263
- 'code': parts[3].strip(),
264
- 'message': ':'.join(parts[4:]).strip()
265
- })
266
-
267
- return {'issues': issues}
268
-
269
- except FileNotFoundError:
270
- return {'error': 'flake8 not installed'}
271
-
272
- async def _run_bandit(self, file_path: str) -> Dict[str, Any]:
273
- """Run bandit security analysis."""
274
- try:
275
- result = subprocess.run(
276
- ['bandit', '-f', 'json', file_path],
277
- capture_output=True,
278
- text=True
279
- )
280
-
281
- try:
282
- bandit_results = json.loads(result.stdout)
283
- return bandit_results
284
- except json.JSONDecodeError:
285
- return {'raw_output': result.stdout}
286
-
287
- except FileNotFoundError:
288
- return {'error': 'bandit not installed'}
289
-
290
- async def _run_mypy(self, file_path: str) -> Dict[str, Any]:
291
- """Run mypy type analysis."""
292
- try:
293
- result = subprocess.run(
294
- ['mypy', file_path, '--show-error-codes'],
295
- capture_output=True,
296
- text=True
297
- )
298
-
299
- # Parse mypy output
300
- issues = []
301
- for line in result.stdout.split('\n'):
302
- if ':' in line and 'error:' in line:
303
- parts = line.split(':', 3)
304
- if len(parts) >= 4:
305
- issues.append({
306
- 'path': parts[0],
307
- 'line': int(parts[1]),
308
- 'message': parts[3].strip()
309
- })
310
-
311
- return {'issues': issues}
312
-
313
- except FileNotFoundError:
314
- return {'error': 'mypy not installed'}
315
-
316
- def _parse_pylint_summary(self, stderr: str) -> Dict[str, Any]:
317
- """Parse pylint summary from stderr."""
318
- summary = {}
319
- for line in stderr.split('\n'):
320
- if 'rated at' in line:
321
- # Extract rating
322
- match = re.search(r'rated at ([\d.]+)/10', line)
323
- if match:
324
- summary['rating'] = float(match.group(1))
325
-
326
- elif any(keyword in line for keyword in ['statements', 'lines', 'functions', 'classes']):
327
- parts = line.split()
328
- if len(parts) >= 2:
329
- summary[parts[0]] = parts[1]
330
-
331
- return summary
332
-
333
- class AutomatedCodeReviewer:
334
- """Main automated code reviewer with TRUST 5 validation."""
335
-
336
- def __init__(self, context7_client=None):
337
- self.context7 = context7_client
338
- self.context7_analyzer = Context7CodeAnalyzer(context7_client)
339
- self.static_analyzer = StaticAnalysisTools()
340
- self.analysis_patterns = {}
341
- self.review_history = []
342
-
343
- async def review_codebase(
344
- self, project_path: str,
345
- include_patterns: List[str] = None,
346
- exclude_patterns: List[str] = None
347
- ) -> CodeReviewReport:
348
- """Perform comprehensive code review of entire codebase."""
349
-
350
- start_time = time.time()
351
-
352
- # Load analysis patterns
353
- self.analysis_patterns = await self.context7_analyzer.load_analysis_patterns()
354
-
355
- # Find files to review
356
- files_to_review = self._find_files_to_review(
357
- project_path, include_patterns, exclude_patterns
358
- )
359
-
360
- print(f"Found {len(files_to_review)} files to review")
361
-
362
- # Review each file
363
- file_results = []
364
- for file_path in files_to_review:
365
- print(f"Reviewing {file_path}...")
366
- file_result = await self.review_single_file(file_path)
367
- file_results.append(file_result)
368
-
369
- # Generate comprehensive report
370
- end_time = time.time()
371
- report = self._generate_comprehensive_report(
372
- project_path, file_results, end_time - start_time
373
- )
374
-
375
- return report
376
-
377
- async def review_single_file(self, file_path: str) -> FileReviewResult:
378
- """Review a single Python file."""
379
-
380
- # Read file content
381
- try:
382
- with open(file_path, 'r', encoding='utf-8') as f:
383
- content = f.read()
384
- except Exception as e:
385
- print(f"Error reading {file_path}: {e}")
386
- return self._create_error_result(file_path, str(e))
387
-
388
- # Parse AST
389
- try:
390
- tree = ast.parse(content)
391
- except SyntaxError as e:
392
- return self._create_syntax_error_result(file_path, content, e)
393
-
394
- # Run static analyses
395
- static_results = await self.static_analyzer.run_all_analyses(file_path)
396
-
397
- # Perform Context7-enhanced analysis
398
- context7_issues = await self._perform_context7_analysis(file_path, content, tree)
399
-
400
- # Perform custom analysis
401
- custom_issues = await self._perform_custom_analysis(file_path, content, tree)
402
-
403
- # Combine all issues
404
- all_issues = []
405
- all_issues.extend(self._convert_static_issues(static_results, file_path))
406
- all_issues.extend(context7_issues)
407
- all_issues.extend(custom_issues)
408
-
409
- # Calculate metrics and scores
410
- metrics = self._calculate_file_metrics(content, tree)
411
- trust_scores = self._calculate_trust_scores(all_issues, metrics)
412
-
413
- return FileReviewResult(
414
- file_path=file_path,
415
- issues=all_issues,
416
- metrics=metrics,
417
- trust_score=trust_scores['overall'],
418
- category_scores=trust_scores['categories'],
419
- lines_of_code=len(content.split('\n')),
420
- complexity_metrics=self._calculate_complexity_metrics(content, tree),
421
- review_timestamp=time.time()
422
- )
423
-
424
- def _find_files_to_review(
425
- self, project_path: str,
426
- include_patterns: List[str] = None,
427
- exclude_patterns: List[str] = None
428
- ) -> List[str]:
429
- """Find Python files to review."""
430
-
431
- if include_patterns is None:
432
- include_patterns = ['/*.py']
433
-
434
- if exclude_patterns is None:
435
- exclude_patterns = [
436
- '/__pycache__/',
437
- '/venv/',
438
- '/env/',
439
- '/node_modules/',
440
- '/.git/',
441
- '/migrations/',
442
- '/tests/'
443
- ]
444
-
445
- import fnmatch
446
- from pathlib import Path
447
-
448
- project_root = Path(project_path)
449
- files = []
450
-
451
- for pattern in include_patterns:
452
- for file_path in project_root.glob(pattern):
453
- if file_path.is_file():
454
- # Check exclude patterns
455
- excluded = False
456
- for exclude_pattern in exclude_patterns:
457
- if fnmatch.fnmatch(str(file_path.relative_to(project_root)), exclude_pattern):
458
- excluded = True
459
- break
460
-
461
- if not excluded:
462
- files.append(str(file_path))
463
-
464
- return sorted(files)
465
-
466
- async def _perform_context7_analysis(
467
- self, file_path: str, content: str, tree: ast.AST
468
- ) -> List[CodeIssue]:
469
- """Perform Context7-enhanced code analysis."""
470
-
471
- issues = []
472
-
473
- # Security analysis
474
- security_issues = await self._analyze_security_patterns(file_path, content)
475
- issues.extend(security_issues)
476
-
477
- # Performance analysis
478
- performance_issues = await self._analyze_performance_patterns(file_path, content)
479
- issues.extend(performance_issues)
480
-
481
- # Code quality analysis
482
- quality_issues = await self._analyze_quality_patterns(file_path, tree)
483
- issues.extend(quality_issues)
484
-
485
- # TRUST 5 analysis
486
- trust_issues = await self._analyze_trust_patterns(file_path, content, tree)
487
- issues.extend(trust_issues)
488
-
489
- return issues
490
-
491
- async def _analyze_security_patterns(self, file_path: str, content: str) -> List[CodeIssue]:
492
- """Analyze security patterns using Context7."""
493
-
494
- issues = []
495
- security_patterns = self.analysis_patterns.get('security', {})
496
- lines = content.split('\n')
497
-
498
- for category, patterns in security_patterns.items():
499
- if isinstance(patterns, list):
500
- for pattern in patterns:
501
- try:
502
- regex = re.compile(pattern, re.IGNORECASE)
503
- for line_num, line in enumerate(lines, 1):
504
- if regex.search(line):
505
- issue = CodeIssue(
506
- id=f"security_{category}_{line_num}_{len(issues)}",
507
- category=TrustCategory.SAFETY,
508
- severity=Severity.HIGH,
509
- issue_type=IssueType.SECURITY_VULNERABILITY,
510
- title=f"Security Issue: {category.replace('_', ' ').title()}",
511
- description=f"Potential {category} vulnerability detected",
512
- file_path=file_path,
513
- line_number=line_num,
514
- column_number=1,
515
- code_snippet=line.strip(),
516
- suggested_fix=self._get_security_fix_suggestion(category, line),
517
- confidence=0.7,
518
- rule_violated=f"SECURITY_{category.upper()}",
519
- external_reference=self._get_security_reference(category)
520
- )
521
- issues.append(issue)
522
- except re.error as e:
523
- print(f"Invalid security pattern {pattern}: {e}")
524
-
525
- return issues
526
-
527
- async def _analyze_performance_patterns(self, file_path: str, content: str) -> List[CodeIssue]:
528
- """Analyze performance patterns using Context7."""
529
-
530
- issues = []
531
- performance_patterns = self.analysis_patterns.get('performance', {})
532
- lines = content.split('\n')
533
-
534
- for category, patterns in performance_patterns.items():
535
- if isinstance(patterns, list):
536
- for pattern in patterns:
537
- try:
538
- regex = re.compile(pattern)
539
- for line_num, line in enumerate(lines, 1):
540
- if regex.search(line):
541
- issue = CodeIssue(
542
- id=f"perf_{category}_{line_num}_{len(issues)}",
543
- category=TrustCategory.TIMELINESS,
544
- severity=Severity.MEDIUM,
545
- issue_type=IssueType.PERFORMANCE_ISSUE,
546
- title=f"Performance Issue: {category.replace('_', ' ').title()}",
547
- description=f"Performance anti-pattern detected: {category}",
548
- file_path=file_path,
549
- line_number=line_num,
550
- column_number=1,
551
- code_snippet=line.strip(),
552
- suggested_fix=self._get_performance_fix_suggestion(category, line),
553
- confidence=0.6,
554
- rule_violated=f"PERF_{category.upper()}"
555
- )
556
- issues.append(issue)
557
- except re.error as e:
558
- print(f"Invalid performance pattern {pattern}: {e}")
559
-
560
- return issues
561
-
562
- async def _analyze_quality_patterns(self, file_path: str, tree: ast.AST) -> List[CodeIssue]:
563
- """Analyze code quality patterns."""
564
-
565
- issues = []
566
- quality_patterns = self.analysis_patterns.get('quality', {})
567
-
568
- # Analyze function length
569
- if 'long_functions' in quality_patterns:
570
- max_lines = quality_patterns['long_functions'].get('max_lines', 50)
571
- function_issues = self._analyze_function_length(file_path, tree, max_lines)
572
- issues.extend(function_issues)
573
-
574
- # Analyze complexity
575
- if 'complex_conditionals' in quality_patterns:
576
- max_complexity = quality_patterns['complex_conditionals'].get('max_complexity', 10)
577
- complexity_issues = self._analyze_complexity(file_path, tree, max_complexity)
578
- issues.extend(complexity_issues)
579
-
580
- # Analyze nesting depth
581
- if 'deep_nesting' in quality_patterns:
582
- max_depth = quality_patterns['deep_nesting'].get('max_depth', 4)
583
- nesting_issues = self._analyze_nesting_depth(file_path, tree, max_depth)
584
- issues.extend(nesting_issues)
585
-
586
- return issues
587
-
588
- async def _analyze_trust_patterns(
589
- self, file_path: str, content: str, tree: ast.AST
590
- ) -> List[CodeIssue]:
591
- """Analyze TRUST 5 patterns."""
592
-
593
- issues = []
594
-
595
- # Truthfulness: Logic correctness
596
- truthfulness_issues = self._analyze_truthfulness(file_path, tree)
597
- issues.extend(truthfulness_issues)
598
-
599
- # Relevance: Requirements fulfillment
600
- relevance_issues = self._analyze_relevance(file_path, content)
601
- issues.extend(relevance_issues)
602
-
603
- # Usability: Maintainability
604
- usability_issues = self._analyze_usability(file_path, content, tree)
605
- issues.extend(usability_issues)
606
-
607
- # Safety: Error handling
608
- safety_issues = self._analyze_safety(file_path, tree)
609
- issues.extend(safety_issues)
610
-
611
- # Timeliness: Performance and standards
612
- timeliness_issues = self._analyze_timeliness(file_path, content)
613
- issues.extend(timeliness_issues)
614
-
615
- return issues
616
-
617
- def _analyze_function_length(
618
- self, file_path: str, tree: ast.AST, max_lines: int
619
- ) -> List[CodeIssue]:
620
- """Analyze function length violations."""
621
-
622
- issues = []
623
- lines = None
624
-
625
- for node in ast.walk(tree):
626
- if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
627
- if lines is None:
628
- with open(file_path, 'r') as f:
629
- lines = f.readlines()
630
-
631
- # Calculate function length (excluding docstring)
632
- start_line = node.lineno - 1
633
- end_line = node.end_lineno - 1 if node.end_lineno else start_line
634
- func_lines = lines[start_line:end_line + 1]
635
-
636
- # Remove docstring and blank lines
637
- code_lines = []
638
- in_docstring = False
639
- for line in func_lines:
640
- stripped = line.strip()
641
- if not in_docstring and ('"""' in line or "'''" in line):
642
- in_docstring = True
643
- continue
644
- if in_docstring and ('"""' in line or "'''" in line):
645
- in_docstring = False
646
- continue
647
- if not in_docstring and stripped and not stripped.startswith('#'):
648
- code_lines.append(line)
649
-
650
- if len(code_lines) > max_lines:
651
- issue = CodeIssue(
652
- id=f"func_length_{node.lineno}",
653
- category=TrustCategory.USABILITY,
654
- severity=Severity.MEDIUM,
655
- issue_type=IssueType.CODE_SMELL,
656
- title="Long Function",
657
- description=f"Function '{node.name}' is {len(code_lines)} lines long (max: {max_lines})",
658
- file_path=file_path,
659
- line_number=node.lineno,
660
- column_number=1,
661
- code_snippet=f"def {node.name}(...): # {len(code_lines)} lines",
662
- suggested_fix=f"Consider breaking '{node.name}' into smaller functions",
663
- confidence=0.8,
664
- rule_violated="FUNC_LENGTH"
665
- )
666
- issues.append(issue)
667
-
668
- return issues
669
-
670
- def _analyze_complexity(
671
- self, file_path: str, tree: ast.AST, max_complexity: int
672
- ) -> List[CodeIssue]:
673
- """Analyze cyclomatic complexity."""
674
-
675
- issues = []
676
-
677
- for node in ast.walk(tree):
678
- if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
679
- complexity = self._calculate_cyclomatic_complexity(node)
680
-
681
- if complexity > max_complexity:
682
- issue = CodeIssue(
683
- id=f"complexity_{node.lineno}",
684
- category=TrustCategory.USABILITY,
685
- severity=Severity.HIGH if complexity > max_complexity * 1.5 else Severity.MEDIUM,
686
- issue_type=IssueType.CODE_SMELL,
687
- title="High Complexity",
688
- description=f"Function '{node.name}' has cyclomatic complexity {complexity} (max: {max_complexity})",
689
- file_path=file_path,
690
- line_number=node.lineno,
691
- column_number=1,
692
- code_snippet=f"def {node.name}(...): # complexity: {complexity}",
693
- suggested_fix=f"Consider refactoring '{node.name}' to reduce complexity",
694
- confidence=0.9,
695
- rule_violated="COMPLEXITY"
696
- )
697
- issues.append(issue)
698
-
699
- return issues
12
+ The automated code review system provides comprehensive code quality analysis across multiple dimensions:
700
13
 
701
- def _calculate_cyclomatic_complexity(self, node: ast.AST) -> int:
702
- """Calculate cyclomatic complexity for an AST node."""
14
+ TRUST 5 Framework:
15
+ - Truthfulness: Code correctness and logic accuracy validation
16
+ - Relevance: Requirements fulfillment and purpose alignment checking
17
+ - Usability: Maintainability and understandability assessment
18
+ - Safety: Security vulnerability and error handling detection
19
+ - Timeliness: Performance standards and modern practices verification
703
20
 
704
- complexity = 1 # Base complexity
21
+ Static Analysis Integration:
22
+ - pylint: Code quality and style checking
23
+ - flake8: Style guide enforcement
24
+ - bandit: Security vulnerability scanning
25
+ - mypy: Type checking and validation
705
26
 
706
- for child in ast.walk(node):
707
- if isinstance(child, (ast.If, ast.While, ast.For, ast.AsyncFor,
708
- ast.ExceptHandler, ast.With, ast.AsyncWith)):
709
- complexity += 1
710
- elif isinstance(child, ast.BoolOp):
711
- complexity += len(child.values) - 1
27
+ Context7-Enhanced Analysis:
28
+ - Up-to-date security patterns from OWASP and Semgrep
29
+ - Performance anti-patterns from profiling best practices
30
+ - Code quality patterns from SonarQube standards
31
+ - TRUST 5 validation framework patterns
712
32
 
713
- return complexity
33
+ ### Key Components
714
34
 
715
- def _analyze_nesting_depth(
716
- self, file_path: str, tree: ast.AST, max_depth: int
717
- ) -> List[CodeIssue]:
718
- """Analyze nesting depth."""
719
-
720
- issues = []
721
-
722
- for node in ast.walk(tree):
723
- if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
724
- max_func_depth = self._calculate_nesting_depth(node)
725
-
726
- if max_func_depth > max_depth:
727
- issue = CodeIssue(
728
- id=f"nesting_{node.lineno}",
729
- category=TrustCategory.USABILITY,
730
- severity=Severity.MEDIUM,
731
- issue_type=IssueType.CODE_SMELL,
732
- title="Deep Nesting",
733
- description=f"Function '{node.name}' has nesting depth {max_func_depth} (max: {max_depth})",
734
- file_path=file_path,
735
- line_number=node.lineno,
736
- column_number=1,
737
- code_snippet=f"def {node.name}(...): # nesting depth: {max_func_depth}",
738
- suggested_fix=f"Consider using early returns or extracting functions in '{node.name}'",
739
- confidence=0.8,
740
- rule_violated="NESTING_DEPTH"
741
- )
742
- issues.append(issue)
743
-
744
- return issues
745
-
746
- def _calculate_nesting_depth(self, node: ast.AST, current_depth: int = 0) -> int:
747
- """Calculate maximum nesting depth for an AST node."""
748
-
749
- max_depth = current_depth
750
-
751
- for child in ast.walk(node):
752
- if isinstance(child, (ast.If, ast.While, ast.For, ast.AsyncFor,
753
- ast.With, ast.AsyncWith, ast.Try)):
754
- if hasattr(child, 'lineno') and hasattr(node, 'lineno') and child.lineno > node.lineno:
755
- child_depth = self._calculate_nesting_depth(child, current_depth + 1)
756
- max_depth = max(max_depth, child_depth)
757
-
758
- return max_depth
759
-
760
- def _analyze_truthfulness(self, file_path: str, tree: ast.AST) -> List[CodeIssue]:
761
- """Analyze code for correctness and logic issues."""
762
-
763
- issues = []
764
-
765
- # Check for unreachable code
766
- for node in ast.walk(tree):
767
- if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
768
- unreachable_issues = self._check_unreachable_code(file_path, node)
769
- issues.extend(unreachable_issues)
770
-
771
- # Check for logic issues
772
- logic_issues = self._check_logic_issues(file_path, tree)
773
- issues.extend(logic_issues)
774
-
775
- return issues
776
-
777
- def _check_unreachable_code(self, file_path: str, func_node: ast.AST) -> List[CodeIssue]:
778
- """Check for unreachable code after return statements."""
779
-
780
- issues = []
781
-
782
- class UnreachableCodeVisitor(ast.NodeVisitor):
783
- def __init__(self):
784
- self.found_return = False
785
- self.issues = []
786
-
787
- def visit_Return(self, node):
788
- self.found_return = True
789
- self.generic_visit(node)
790
-
791
- def generic_visit(self, node):
792
- if self.found_return and hasattr(node, 'lineno'):
793
- if isinstance(node, (ast.Expr, ast.Assign, ast.AugAssign)):
794
- issue = CodeIssue(
795
- id=f"unreachable_{node.lineno}",
796
- category=TrustCategory.TRUTHFULNESS,
797
- severity=Severity.LOW,
798
- issue_type=IssueType.CODE_SMELL,
799
- title="Unreachable Code",
800
- description="Code after return statement is never executed",
801
- file_path=file_path,
802
- line_number=node.lineno,
803
- column_number=1,
804
- code_snippet=f"# Unreachable code at line {node.lineno}",
805
- suggested_fix="Remove unreachable code or move before return statement",
806
- confidence=0.7,
807
- rule_violated="UNREACHABLE_CODE"
808
- )
809
- self.issues.append(issue)
810
-
811
- super().generic_visit(node)
812
-
813
- visitor = UnreachableCodeVisitor()
814
- visitor.visit(func_node)
815
-
816
- return visitor.issues
817
-
818
- def _check_logic_issues(self, file_path: str, tree: ast.AST) -> List[CodeIssue]:
819
- """Check for common logic issues."""
820
-
821
- issues = []
822
-
823
- # Check for comparison issues
824
- for node in ast.walk(tree):
825
- if isinstance(node, ast.Compare):
826
- comparison_issues = self._check_comparison_issues(file_path, node)
827
- issues.extend(comparison_issues)
828
-
829
- return issues
830
-
831
- def _check_comparison_issues(self, file_path: str, compare_node: ast.Compare) -> List[CodeIssue]:
832
- """Check for comparison logic issues."""
833
-
834
- issues = []
835
-
836
- # Check for None comparison
837
- for op in compare_node.ops:
838
- if isinstance(op, ast.Eq) or isinstance(op, ast.NotEq):
839
- for comparator in compare_node.comparators:
840
- if isinstance(comparator, ast.Constant) and comparator.value is None:
841
- issue = CodeIssue(
842
- id=f"none_comparison_{compare_node.lineno}",
843
- category=TrustCategory.TRUTHFULNESS,
844
- severity=Severity.LOW,
845
- issue_type=IssueType.CODE_SMELL,
846
- title="None Comparison",
847
- description="Use 'is' or 'is not' for None comparison",
848
- file_path=file_path,
849
- line_number=compare_node.lineno,
850
- column_number=1,
851
- code_snippet="# Use 'is None' instead of '== None'",
852
- suggested_fix="Replace '== None' with 'is None' and '!= None' with 'is not None'",
853
- confidence=0.8,
854
- rule_violated="NONE_COMPARISON",
855
- auto_fixable=True
856
- )
857
- issues.append(issue)
858
-
859
- return issues
860
-
861
- def _analyze_relevance(self, file_path: str, content: str) -> List[CodeIssue]:
862
- """Analyze code for relevance and requirements fulfillment."""
863
-
864
- issues = []
865
-
866
- # Check for TODO/FIXME comments
867
- lines = content.split('\n')
868
- for line_num, line in enumerate(lines, 1):
869
- if 'TODO:' in line or 'FIXME:' in line:
870
- issue = CodeIssue(
871
- id=f"todo_{line_num}",
872
- category=TrustCategory.RELEVANCE,
873
- severity=Severity.LOW,
874
- issue_type=IssueType.DOCUMENTATION_ISSUE,
875
- title="Unresolved TODO",
876
- description=f"TODO/FIXME comment found: {line.strip()}",
877
- file_path=file_path,
878
- line_number=line_num,
879
- column_number=line.find('TODO') if 'TODO' in line else line.find('FIXME'),
880
- code_snippet=line.strip(),
881
- suggested_fix="Address the TODO/FIXME item or remove the comment",
882
- confidence=0.6,
883
- rule_violated="UNRESOLVED_TODO"
884
- )
885
- issues.append(issue)
886
-
887
- return issues
888
-
889
- def _analyze_usability(self, file_path: str, content: str, tree: ast.AST) -> List[CodeIssue]:
890
- """Analyze code for usability and maintainability."""
891
-
892
- issues = []
893
-
894
- # Check for docstring presence
895
- for node in ast.walk(tree):
896
- if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
897
- if not ast.get_docstring(node):
898
- issue = CodeIssue(
899
- id=f"no_docstring_{node.lineno}",
900
- category=TrustCategory.USABILITY,
901
- severity=Severity.LOW,
902
- issue_type=IssueType.DOCUMENTATION_ISSUE,
903
- title="Missing Docstring",
904
- description=f"Function '{node.name}' is missing a docstring",
905
- file_path=file_path,
906
- line_number=node.lineno,
907
- column_number=1,
908
- code_snippet=f"def {node.name}(...):",
909
- suggested_fix=f"Add a docstring to '{node.name}' explaining its purpose, parameters, and return value",
910
- confidence=0.7,
911
- rule_violated="MISSING_DOCSTRING"
912
- )
913
- issues.append(issue)
914
-
915
- return issues
916
-
917
- def _analyze_safety(self, file_path: str, tree: ast.AST) -> List[CodeIssue]:
918
- """Analyze code for safety and error handling."""
919
-
920
- issues = []
921
-
922
- # Check for bare except clauses
923
- for node in ast.walk(tree):
924
- if isinstance(node, ast.ExceptHandler):
925
- if node.type is None:
926
- issue = CodeIssue(
927
- id=f"bare_except_{node.lineno}",
928
- category=TrustCategory.SAFETY,
929
- severity=Severity.MEDIUM,
930
- issue_type=IssueType.CODE_SMELL,
931
- title="Bare Except Clause",
932
- description="Bare except clause can hide unexpected errors",
933
- file_path=file_path,
934
- line_number=node.lineno,
935
- column_number=1,
936
- code_snippet="except:",
937
- suggested_fix="Specify exception types or use 'except Exception:' with logging",
938
- confidence=0.8,
939
- rule_violated="BARE_EXCEPT"
940
- )
941
- issues.append(issue)
942
-
943
- return issues
944
-
945
- def _analyze_timeliness(self, file_path: str, content: str) -> List[CodeIssue]:
946
- """Analyze code for timeliness and performance."""
947
-
948
- issues = []
949
-
950
- # Check for deprecated imports
951
- deprecated_imports = {
952
- 'StringIO': 'io.StringIO',
953
- 'cStringIO': 'io.StringIO'
954
- }
955
-
956
- lines = content.split('\n')
957
- for line_num, line in enumerate(lines, 1):
958
- for old_import, new_import in deprecated_imports.items():
959
- if f"import {old_import}" in line or f"from {old_import}" in line:
960
- issue = CodeIssue(
961
- id=f"deprecated_import_{line_num}",
962
- category=TrustCategory.TIMELINESS,
963
- severity=Severity.LOW,
964
- issue_type=IssueType.IMPORT_ISSUE,
965
- title="Deprecated Import",
966
- description=f"Using deprecated import '{old_import}', should use '{new_import}'",
967
- file_path=file_path,
968
- line_number=line_num,
969
- column_number=line.find(old_import),
970
- code_snippet=line.strip(),
971
- suggested_fix=f"Replace '{old_import}' with '{new_import}'",
972
- confidence=0.9,
973
- rule_violated="DEPRECATED_IMPORT",
974
- auto_fixable=True
975
- )
976
- issues.append(issue)
977
-
978
- return issues
979
-
980
- def _convert_static_issues(
981
- self, static_results: Dict[str, Any], file_path: str
982
- ) -> List[CodeIssue]:
983
- """Convert static analysis results to CodeIssue objects."""
984
-
985
- issues = []
986
-
987
- for tool_name, results in static_results.items():
988
- if 'error' in results:
989
- continue
990
-
991
- tool_issues = results.get('issues', [])
992
- for issue_data in tool_issues:
993
- # Map tool to TRUST category
994
- category = self._map_tool_to_trust_category(tool_name, issue_data)
995
-
996
- issue = CodeIssue(
997
- id=f"{tool_name}_{len(issues)}",
998
- category=category,
999
- severity=self._map_severity(issue_data.get('severity', 'medium')),
1000
- issue_type=self._map_issue_type(tool_name, issue_data),
1001
- title=f"{tool_name.title()}: {issue_data.get('message', 'Unknown issue')}",
1002
- description=issue_data.get('message', 'Static analysis issue'),
1003
- file_path=file_path,
1004
- line_number=issue_data.get('line', 0),
1005
- column_number=issue_data.get('column', 0),
1006
- code_snippet=issue_data.get('code_snippet', ''),
1007
- suggested_fix=self._get_suggested_fix(tool_name, issue_data),
1008
- confidence=0.8,
1009
- rule_violated=issue_data.get('code', ''),
1010
- external_reference=f"{tool_name} documentation"
1011
- )
1012
- issues.append(issue)
1013
-
1014
- return issues
1015
-
1016
- def _map_tool_to_trust_category(self, tool_name: str, issue_data: Dict) -> TrustCategory:
1017
- """Map static analysis tool to TRUST category."""
1018
-
1019
- if tool_name == 'bandit':
1020
- return TrustCategory.SAFETY
1021
- elif tool_name == 'mypy':
1022
- return TrustCategory.TRUTHFULNESS
1023
- elif tool_name == 'pylint':
1024
- message = issue_data.get('message', '').lower()
1025
- if any(keyword in message for keyword in ['security', 'injection', 'unsafe']):
1026
- return TrustCategory.SAFETY
1027
- elif any(keyword in message for keyword in ['performance', 'inefficient']):
1028
- return TrustCategory.TIMELINESS
1029
- else:
1030
- return TrustCategory.USABILITY
1031
- else:
1032
- return TrustCategory.USABILITY
1033
-
1034
- def _map_severity(self, severity: str) -> Severity:
1035
- """Map severity string to Severity enum."""
1036
-
1037
- severity_map = {
1038
- 'critical': Severity.CRITICAL,
1039
- 'high': Severity.HIGH,
1040
- 'medium': Severity.MEDIUM,
1041
- 'low': Severity.LOW,
1042
- 'info': Severity.INFO
1043
- }
1044
-
1045
- return severity_map.get(severity.lower(), Severity.MEDIUM)
1046
-
1047
- def _map_issue_type(self, tool_name: str, issue_data: Dict) -> IssueType:
1048
- """Map tool issue to IssueType enum."""
1049
-
1050
- if tool_name == 'bandit':
1051
- return IssueType.SECURITY_VULNERABILITY
1052
- elif tool_name == 'mypy':
1053
- return IssueType.TYPE_ERROR
1054
- else:
1055
- message = issue_data.get('message', '').lower()
1056
- if 'security' in message:
1057
- return IssueType.SECURITY_VULNERABILITY
1058
- elif 'performance' in message:
1059
- return IssueType.PERFORMANCE_ISSUE
1060
- elif 'syntax' in message:
1061
- return IssueType.SYNTAX_ERROR
1062
- else:
1063
- return IssueType.CODE_SMELL
1064
-
1065
- def _get_suggested_fix(self, tool_name: str, issue_data: Dict) -> str:
1066
- """Get suggested fix for tool issue."""
1067
-
1068
- message = issue_data.get('message', '')
1069
-
1070
- if 'unused' in message.lower():
1071
- return "Remove unused variable or import"
1072
- elif 'missing docstring' in message.lower():
1073
- return "Add docstring explaining function purpose"
1074
- elif 'too many arguments' in message.lower():
1075
- return "Consider reducing function arguments or using data classes"
1076
- elif else:
1077
- return "Address the linting issue by following best practices"
35
+ ```python
36
+ from moai_workflow_testing.automated_code_review import (
37
+ AutomatedCodeReviewer,
38
+ CodeReviewReport,
39
+ TrustCategory,
40
+ Severity,
41
+ IssueType
42
+ )
1078
43
 
1079
- def _get_security_fix_suggestion(self, category: str, line: str) -> str:
1080
- """Get security fix suggestion."""
44
+ # Initialize automated code reviewer
45
+ reviewer = AutomatedCodeReviewer(context7_client=context7)
1081
46
 
1082
- suggestions = {
1083
- 'sql_injection': "Use parameterized queries or ORM to prevent SQL injection",
1084
- 'command_injection': "Use subprocess.run with proper argument lists or validate input",
1085
- 'path_traversal': "Validate and sanitize file paths, use absolute paths"
1086
- }
47
+ # Review entire codebase
48
+ report = await reviewer.review_codebase(
49
+ project_path="/path/to/project",
50
+ include_patterns=["/*.py"],
51
+ exclude_patterns=["/tests/", "/__pycache__/"]
52
+ )
1087
53
 
1088
- return suggestions.get(category, "Review and fix security vulnerability")
54
+ print(f"Overall TRUST Score: {report.overall_trust_score:.2f}")
55
+ print(f"Files Reviewed: {report.summary_metrics['files_reviewed']}")
56
+ print(f"Total Issues: {report.summary_metrics['total_issues']}")
57
+ print(f"Critical Issues: {report.summary_metrics['critical_issues']}")
58
+ ```
1089
59
 
1090
- def _get_performance_fix_suggestion(self, category: str, line: str) -> str:
1091
- """Get performance fix suggestion."""
60
+ ### TRUST 5 Scores
1092
61
 
1093
- suggestions = {
1094
- 'inefficient_loops': "Use list comprehensions or generator expressions",
1095
- 'memory_leaks': "Review memory usage and ensure proper cleanup"
1096
- }
62
+ The review system calculates scores for each TRUST category:
1097
63
 
1098
- return suggestions.get(category, "Optimize code for better performance")
64
+ ```python
65
+ for category, score in report.overall_category_scores.items():
66
+ print(f"{category.value}: {score:.2f}")
67
+ ```
1099
68
 
1100
- def _get_security_reference(self, category: str) -> str:
1101
- """Get external security reference."""
69
+ Category Score Calculation:
70
+ - Scores range from 0.0 to 1.0
71
+ - Penalties applied based on issue severity and confidence
72
+ - Weighted average for overall score
73
+ - Category weights: Truthfulness (25%), Relevance (20%), Usability (25%), Safety (20%), Timeliness (10%)
1102
74
 
1103
- references = {
1104
- 'sql_injection': "OWASP SQL Injection Prevention Cheat Sheet",
1105
- 'command_injection': "OWASP Command Injection Prevention Cheat Sheet",
1106
- 'path_traversal': "OWASP Path Traversal Prevention Cheat Sheet"
1107
- }
75
+ ### Issue Severity Levels
1108
76
 
1109
- return references.get(category, "OWASP Top 10 Security Risks")
77
+ Critical: Security vulnerabilities, syntax errors, data loss risks
78
+ High: Complex logic issues, major performance problems, significant safety concerns
79
+ Medium: Code smells, maintainability issues, moderate performance problems
80
+ Low: Style violations, minor documentation issues, small optimizations
81
+ Info: Suggestions and best practice recommendations
1110
82
 
1111
- def _calculate_file_metrics(self, content: str, tree: ast.AST) -> Dict[str, Any]:
1112
- """Calculate comprehensive file metrics."""
83
+ ---
1113
84
 
1114
- lines = content.split('\n')
1115
- code_lines = [line for line in lines if line.strip() and not line.strip().startswith('#')]
85
+ ## Implementation Guide
1116
86
 
1117
- functions = [node for node in ast.walk(tree) if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef))]
1118
- classes = [node for node in ast.walk(tree) if isinstance(node, ast.ClassDef)]
87
+ ### Basic Code Review Workflow
1119
88
 
1120
- return {
1121
- 'total_lines': len(lines),
1122
- 'code_lines': len(code_lines),
1123
- 'comment_lines': len(lines) - len(code_lines),
1124
- 'functions': len(functions),
1125
- 'classes': len(classes),
1126
- 'imports': len([node for node in ast.walk(tree) if isinstance(node, (ast.Import, ast.ImportFrom))])
1127
- }
89
+ Step 1: Initialize the automated code reviewer with optional Context7 client for enhanced pattern detection
1128
90
 
1129
- def _calculate_trust_scores(
1130
- self, issues: List[CodeIssue], metrics: Dict[str, Any]
1131
- ) -> Dict[str, Any]:
1132
- """Calculate TRUST 5 scores."""
91
+ Step 2: Review the codebase by specifying:
92
+ - Project path to analyze
93
+ - Include patterns for files to review (default: ["/*.py"])
94
+ - Exclude patterns for directories to skip (default: ["/__pycache__/", "/venv/", "/tests/"])
1133
95
 
1134
- category_scores = {}
1135
- category_weights = {
1136
- TrustCategory.TRUTHFULNESS: 0.25,
1137
- TrustCategory.RELEVANCE: 0.20,
1138
- TrustCategory.USABILITY: 0.25,
1139
- TrustCategory.SAFETY: 0.20,
1140
- TrustCategory.TIMELINESS: 0.10
1141
- }
96
+ Step 3: Analyze the generated report which includes:
97
+ - Overall TRUST score across all categories
98
+ - Per-file review results with individual issues
99
+ - Summary metrics with issue counts by severity and category
100
+ - Critical issues requiring immediate attention
101
+ - Actionable recommendations prioritized by impact
1142
102
 
1143
- # Group issues by category
1144
- issues_by_category = {category: [] for category in TrustCategory}
1145
- for issue in issues:
1146
- issues_by_category[issue.category].append(issue)
103
+ ### Single File Review
1147
104
 
1148
- # Calculate scores for each category
1149
- for category in TrustCategory:
1150
- category_issues = issues_by_category[category]
105
+ For reviewing individual files:
1151
106
 
1152
- # Calculate penalty based on severity and number of issues
1153
- penalty = 0.0
1154
- for issue in category_issues:
1155
- severity_penalty = {
1156
- Severity.CRITICAL: 0.5,
1157
- Severity.HIGH: 0.3,
1158
- Severity.MEDIUM: 0.1,
1159
- Severity.LOW: 0.05,
1160
- Severity.INFO: 0.01
1161
- }
1162
- penalty += severity_penalty.get(issue.severity, 0.1) * issue.confidence
107
+ ```python
108
+ file_result = await reviewer.review_single_file("/path/to/file.py")
109
+ print(f"File Trust Score: {file_result.trust_score:.2f}")
110
+ print(f"Issues found: {len(file_result.issues)}")
111
+ print(f"Lines of code: {file_result.lines_of_code}")
112
+ ```
1163
113
 
1164
- # Apply penalties (max penalty of 1.0)
1165
- score = max(0.0, 1.0 - min(penalty, 1.0))
1166
- category_scores[category] = score
114
+ ### Understanding Code Issues
1167
115
 
1168
- # Calculate overall score
1169
- overall_score = sum(
1170
- category_scores[cat] * category_weights[cat]
1171
- for cat in TrustCategory
1172
- )
116
+ Each issue detected includes:
1173
117
 
1174
- return {
1175
- 'overall': overall_score,
1176
- 'categories': category_scores
1177
- }
118
+ ```python
119
+ for issue in file_result.issues:
120
+ print(f"Category: {issue.category.value}")
121
+ print(f"Severity: {issue.severity.value}")
122
+ print(f"Type: {issue.issue_type.value}")
123
+ print(f"Title: {issue.title}")
124
+ print(f"Description: {issue.description}")
125
+ print(f"Location: {issue.file_path}:{issue.line_number}")
126
+ print(f"Code snippet: {issue.code_snippet}")
127
+ print(f"Suggested fix: {issue.suggested_fix}")
128
+ print(f"Confidence: {issue.confidence:.2f}")
129
+ if issue.rule_violated:
130
+ print(f"Rule violated: {issue.rule_violated}")
131
+ if issue.external_reference:
132
+ print(f"Reference: {issue.external_reference}")
133
+ ```
1178
134
 
1179
- def _calculate_complexity_metrics(self, content: str, tree: ast.AST) -> Dict[str, float]:
1180
- """Calculate complexity metrics."""
135
+ ### Customizing Analysis Patterns
1181
136
 
1182
- total_complexity = 0
1183
- max_function_complexity = 0
1184
- function_count = 0
137
+ Configure analysis patterns to match project standards:
1185
138
 
1186
- for node in ast.walk(tree):
1187
- if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
1188
- complexity = self._calculate_cyclomatic_complexity(node)
1189
- total_complexity += complexity
1190
- max_function_complexity = max(max_function_complexity, complexity)
1191
- function_count += 1
139
+ ```python
140
+ # Access analysis patterns
141
+ patterns = await reviewer.context7_analyzer.load_analysis_patterns()
1192
142
 
1193
- avg_complexity = total_complexity / max(function_count, 1)
143
+ # Customize quality thresholds
144
+ patterns['quality']['long_functions']['max_lines'] = 100
145
+ patterns['quality']['complex_conditionals']['max_complexity'] = 15
146
+ patterns['quality']['deep_nesting']['max_depth'] = 5
1194
147
 
1195
- return {
1196
- 'total_complexity': total_complexity,
1197
- 'max_function_complexity': max_function_complexity,
1198
- 'average_complexity': avg_complexity,
1199
- 'function_count': function_count
1200
- }
148
+ # Run review with custom patterns
149
+ reviewer.analysis_patterns = patterns
150
+ report = await reviewer.review_codebase(project_path)
151
+ ```
1201
152
 
1202
- def _generate_comprehensive_report(
1203
- self, project_path: str, file_results: List[FileReviewResult], duration: float
1204
- ) -> CodeReviewReport:
1205
- """Generate comprehensive code review report."""
153
+ ---
1206
154
 
1207
- # Collect all issues
1208
- all_issues = []
1209
- for result in file_results:
1210
- all_issues.extend(result.issues)
155
+ ## Advanced Modules
1211
156
 
1212
- # Calculate overall scores
1213
- overall_category_scores = {}
1214
- for category in TrustCategory:
1215
- scores = [result.category_scores.get(category, 0.0) for result in file_results]
1216
- overall_category_scores[category] = sum(scores) / len(scores) if scores else 0.0
157
+ For detailed implementation and advanced features, see the specialized modules:
1217
158
 
1218
- overall_trust_score = sum(overall_category_scores.values()) / len(overall_category_scores)
159
+ ### TRUST 5 Validation Framework
1219
160
 
1220
- # Get critical issues
1221
- critical_issues = [issue for issue in all_issues if issue.severity == Severity.CRITICAL]
161
+ See [trust5-validation.md](./trust5-validation.md) for:
162
+ - Complete TRUST 5 category implementations
163
+ - Custom validation rules and patterns
164
+ - Category-specific analysis methods
165
+ - Score calculation algorithms
166
+ - Penalty and weight customization
1222
167
 
1223
- # Generate recommendations
1224
- recommendations = self._generate_recommendations(overall_category_scores, all_issues)
168
+ ### Static Analysis Integration
1225
169
 
1226
- # Calculate summary metrics
1227
- summary_metrics = {
1228
- 'files_reviewed': len(file_results),
1229
- 'total_issues': len(all_issues),
1230
- 'critical_issues': len(critical_issues),
1231
- 'issues_by_severity': {
1232
- severity.value: len([i for i in all_issues if i.severity == severity])
1233
- for severity in Severity
1234
- },
1235
- 'issues_by_category': {
1236
- category.value: len([i for i in all_issues if i.category == category])
1237
- for category in TrustCategory
1238
- },
1239
- 'total_lines_of_code': sum(result.lines_of_code for result in file_results),
1240
- 'average_trust_score': overall_trust_score,
1241
- 'context7_patterns_used': list(self.analysis_patterns.keys())
1242
- }
170
+ See [static-analysis.md](./static-analysis.md) for:
171
+ - pylint, flake8, bandit, mypy integration details
172
+ - Tool configuration and customization
173
+ - Result parsing and normalization
174
+ - Tool-to-TRUST category mapping
175
+ - Error handling and fallback strategies
1243
176
 
1244
- return CodeReviewReport(
1245
- project_path=project_path,
1246
- files_reviewed=file_results,
1247
- overall_trust_score=overall_trust_score,
1248
- overall_category_scores=overall_category_scores,
1249
- summary_metrics=summary_metrics,
1250
- recommendations=recommendations,
1251
- critical_issues=critical_issues,
1252
- review_duration=duration,
1253
- context7_patterns_used=list(self.analysis_patterns.keys())
1254
- )
177
+ ### Security Analysis
1255
178
 
1256
- def _generate_recommendations(
1257
- self, category_scores: Dict[TrustCategory, float], issues: List[CodeIssue]
1258
- ) -> List[str]:
1259
- """Generate actionable recommendations."""
179
+ See [security-analysis.md](./security-analysis.md) for:
180
+ - Context7-enhanced security pattern detection
181
+ - OWASP Top 10 vulnerability scanning
182
+ - SQL injection, command injection, path traversal detection
183
+ - Security fix suggestions with references
184
+ - Business logic vulnerability analysis
1260
185
 
1261
- recommendations = []
186
+ ### Quality Metrics
1262
187
 
1263
- # Category-specific recommendations
1264
- for category, score in category_scores.items():
1265
- if score < 0.7:
1266
- if category == TrustCategory.SAFETY:
1267
- recommendations.append("Address security vulnerabilities immediately - critical safety issues detected")
1268
- elif category == TrustCategory.TRUTHFULNESS:
1269
- recommendations.append("Review code logic and fix correctness issues")
1270
- elif category == TrustCategory.USABILITY:
1271
- recommendations.append("Improve code maintainability by refactoring complex functions")
1272
- elif category == TrustCategory.RELEVANCE:
1273
- recommendations.append("Remove TODO items and improve documentation")
1274
- elif category == TrustCategory.TIMELINESS:
1275
- recommendations.append("Optimize performance issues and update deprecated code")
188
+ See [quality-metrics.md](./quality-metrics.md) for:
189
+ - Function length and complexity analysis
190
+ - Nesting depth detection
191
+ - Cyclomatic complexity calculation
192
+ - Code metrics and statistics
193
+ - Maintainability indices
1276
194
 
1277
- # General recommendations
1278
- high_severity_count = len([i for i in issues if i.severity in [Severity.CRITICAL, Severity.HIGH]])
1279
- if high_severity_count > 0:
1280
- recommendations.append(f"Address {high_severity_count} high-priority issues before release")
195
+ ### Advanced TRUST 5 Framework
1281
196
 
1282
- auto_fixable_count = len([i for i in issues if i.auto_fixable])
1283
- if auto_fixable_count > 0:
1284
- recommendations.append(f"Use automated fixes for {auto_fixable_count} auto-fixable issues")
197
+ See [automated-code-review/trust5-framework.md](./automated-code-review/trust5-framework.md) for:
198
+ - Deep dive into TRUST 5 methodology
199
+ - Category-specific analysis patterns
200
+ - Advanced scoring algorithms
201
+ - Custom rule creation
202
+ - Integration with external validation tools
1285
203
 
1286
- return recommendations
204
+ ### Context7 Integration
1287
205
 
1288
- def _create_error_result(self, file_path: str, error_message: str) -> FileReviewResult:
1289
- """Create error result for file that couldn't be processed."""
206
+ See [automated-code-review/context7-integration.md](./automated-code-review/context7-integration.md) for:
207
+ - Context7 MCP integration patterns
208
+ - Real-time pattern loading
209
+ - Security vulnerability databases
210
+ - Performance optimization libraries
211
+ - Code quality standards integration
1290
212
 
1291
- return FileReviewResult(
1292
- file_path=file_path,
1293
- issues=[],
1294
- metrics={'error': error_message},
1295
- trust_score=0.0,
1296
- category_scores={cat: 0.0 for cat in TrustCategory},
1297
- lines_of_code=0,
1298
- complexity_metrics={},
1299
- review_timestamp=time.time()
1300
- )
213
+ ### Review Workflows
1301
214
 
1302
- def _create_syntax_error_result(
1303
- self, file_path: str, content: str, syntax_error: SyntaxError
1304
- ) -> FileReviewResult:
1305
- """Create result for file with syntax errors."""
215
+ See [automated-code-review/review-workflows.md](./automated-code-review/review-workflows.md) for:
216
+ - CI/CD pipeline integration
217
+ - Automated review workflows
218
+ - Report generation and formatting
219
+ - Team collaboration patterns
220
+ - Continuous quality monitoring
1306
221
 
1307
- issue = CodeIssue(
1308
- id=f"syntax_error_{syntax_error.lineno}",
1309
- category=TrustCategory.TRUTHFULNESS,
1310
- severity=Severity.CRITICAL,
1311
- issue_type=IssueType.SYNTAX_ERROR,
1312
- title="Syntax Error",
1313
- description=f"Syntax error: {syntax_error.msg}",
1314
- file_path=file_path,
1315
- line_number=syntax_error.lineno,
1316
- column_number=syntax_error.offset or 0,
1317
- code_snippet=content.split('\n')[syntax_error.lineno - 1] if syntax_error.lineno <= len(content.split('\n')) else "",
1318
- suggested_fix="Fix the syntax error",
1319
- confidence=1.0
1320
- )
222
+ ---
1321
223
 
1322
- return FileReviewResult(
1323
- file_path=file_path,
1324
- issues=[issue],
1325
- metrics={'syntax_error': True},
1326
- trust_score=0.0,
1327
- category_scores={cat: 0.0 for cat in TrustCategory},
1328
- lines_of_code=len(content.split('\n')),
1329
- complexity_metrics={},
1330
- review_timestamp=time.time()
1331
- )
224
+ ## Best Practices
1332
225
 
1333
- # Usage Examples
1334
- """
1335
- # Initialize automated code reviewer
1336
- reviewer = AutomatedCodeReviewer(context7_client=context7)
226
+ 1. Comprehensive Coverage: Analyze code across all TRUST 5 dimensions for complete quality assessment
227
+ 2. Context Integration: Leverage Context7 for up-to-date security and quality patterns
228
+ 3. Actionable Feedback: Provide specific, implementable suggestions with code examples
229
+ 4. Severity Prioritization: Focus on critical and high-severity issues first for maximum impact
230
+ 5. Continuous Integration: Integrate into CI/CD pipeline for automated reviews on every commit
231
+ 6. Custom Thresholds: Adjust analysis thresholds to match project standards and team preferences
232
+ 7. Regular Updates: Keep Context7 patterns current for latest vulnerability detection
233
+ 8. Team Consistency: Use consistent review rules across entire codebase for uniform quality
1337
234
 
1338
- # Review entire codebase
1339
- report = await reviewer.review_codebase(
1340
- project_path="/path/to/project",
1341
- include_patterns=["/*.py"],
1342
- exclude_patterns=["/tests/", "/__pycache__/"]
1343
- )
235
+ ---
1344
236
 
1345
- print(f"Code Review Results:")
1346
- print(f" Overall TRUST Score: {report.overall_trust_score:.2f}")
1347
- print(f" Files Reviewed: {report.summary_metrics['files_reviewed']}")
1348
- print(f" Total Issues: {report.summary_metrics['total_issues']}")
1349
- print(f" Critical Issues: {report.summary_metrics['critical_issues']}")
237
+ ## Related Modules
1350
238
 
1351
- print(f"\nTRUST 5 Category Scores:")
1352
- for category, score in report.overall_category_scores.items():
1353
- print(f" {category.value}: {score:.2f}")
239
+ - [Smart Refactoring](./smart-refactoring.md): Automated refactoring with code quality improvements
240
+ - [Performance Optimization](./performance-optimization.md): Performance profiling and bottleneck detection
241
+ - [AI Debugging](./ai-debugging.md): AI-powered debugging and error resolution
1354
242
 
1355
- print(f"\nTop Recommendations:")
1356
- for i, rec in enumerate(report.recommendations[:5], 1):
1357
- print(f" {i}. {rec}")
243
+ ---
1358
244
 
1359
- print(f"\nCritical Issues:")
1360
- for issue in report.critical_issues[:3]:
1361
- print(f" - {issue.title} in {issue.file_path}:{issue.line_number}")
1362
- print(f" {issue.description}")
245
+ ## Module Structure
1363
246
 
1364
- # Review single file
1365
- file_result = await reviewer.review_single_file("/path/to/file.py")
1366
- print(f"\nFile Trust Score: {file_result.trust_score:.2f}")
1367
- print(f"Issues found: {len(file_result.issues)}")
1368
- """
1369
247
  ```
1370
-
1371
- ## Advanced Features
1372
-
1373
- ### Context7-Enhanced Security Analysis
1374
-
1375
- Advanced Security Pattern Detection:
1376
- ```python
1377
- class EnhancedSecurityAnalyzer:
1378
- """Enhanced security analyzer with Context7 integration."""
1379
-
1380
- async def analyze_advanced_security_patterns(
1381
- self, file_path: str, content: str
1382
- ) -> List[CodeIssue]:
1383
- """Analyze advanced security patterns using Context7."""
1384
-
1385
- issues = []
1386
-
1387
- # Get latest security patterns from Context7
1388
- security_patterns = await self.context7.get_library_docs(
1389
- context7_library_id="/security/owasp",
1390
- topic="advanced security vulnerability patterns 2025",
1391
- tokens=5000
1392
- )
1393
-
1394
- # Analyze for OWASP Top 10 vulnerabilities
1395
- owasp_issues = await self._analyze_owasp_patterns(file_path, content, security_patterns)
1396
- issues.extend(owasp_issues)
1397
-
1398
- # Analyze for business logic vulnerabilities
1399
- logic_issues = await self._analyze_business_logic_security(file_path, content)
1400
- issues.extend(logic_issues)
1401
-
1402
- return issues
248
+ automated-code-review.md (this file)
249
+ ├── trust5-validation.md (TRUST 5 framework implementation)
250
+ ├── static-analysis.md (pylint, flake8, bandit, mypy integration)
251
+ ├── security-analysis.md (security vulnerability detection)
252
+ ├── quality-metrics.md (code quality, complexity, metrics)
253
+ └── automated-code-review/
254
+ ├── trust5-framework.md (deep dive into TRUST 5 categories)
255
+ ├── context7-integration.md (Context7 MCP integration)
256
+ └── review-workflows.md (CI/CD and team workflows)
1403
257
  ```
1404
258
 
1405
- ## Best Practices
1406
-
1407
- 1. Comprehensive Coverage: Analyze code across all TRUST 5 dimensions
1408
- 2. Context Integration: Leverage Context7 for up-to-date security and quality patterns
1409
- 3. Actionable Feedback: Provide specific, implementable suggestions
1410
- 4. Severity Prioritization: Focus on critical and high-severity issues first
1411
- 5. Continuous Integration: Integrate into CI/CD pipeline for automated reviews
1412
-
1413
259
  ---
1414
260
 
261
+ Version: 2.0.0 (Modular Structure)
262
+ Last Updated: 2026-01-06
1415
263
  Module: `modules/automated-code-review.md`
1416
- Related: [Smart Refactoring](./smart-refactoring.md) | [Performance Optimization](./performance-optimization.md)