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

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

Potentially problematic release.


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

Files changed (417) hide show
  1. moai_adk/__init__.py +1 -2
  2. moai_adk/__main__.py +85 -2
  3. moai_adk/cli/__init__.py +0 -1
  4. moai_adk/cli/commands/__init__.py +0 -1
  5. moai_adk/cli/commands/analyze.py +127 -0
  6. moai_adk/cli/commands/backup.py +5 -3
  7. moai_adk/cli/commands/doctor.py +35 -11
  8. moai_adk/cli/commands/improve_user_experience.py +348 -0
  9. moai_adk/cli/commands/init.py +150 -23
  10. moai_adk/cli/commands/language.py +269 -0
  11. moai_adk/cli/commands/migrate.py +158 -0
  12. moai_adk/cli/commands/status.py +13 -12
  13. moai_adk/cli/commands/update.py +364 -60
  14. moai_adk/cli/commands/validate_links.py +118 -0
  15. moai_adk/cli/main.py +3 -2
  16. moai_adk/cli/prompts/init_prompts.py +79 -82
  17. moai_adk/core/__init__.py +0 -1
  18. moai_adk/core/analysis/__init__.py +9 -0
  19. moai_adk/core/analysis/session_analyzer.py +439 -0
  20. moai_adk/core/claude_integration.py +421 -0
  21. moai_adk/core/command_helpers.py +270 -0
  22. moai_adk/core/config/__init__.py +6 -0
  23. moai_adk/core/config/auto_spec_config.py +346 -0
  24. moai_adk/core/config/migration.py +133 -12
  25. moai_adk/core/context_manager.py +279 -0
  26. moai_adk/core/diagnostics/slash_commands.py +0 -1
  27. moai_adk/core/error_recovery_system.py +1289 -0
  28. moai_adk/core/git/__init__.py +0 -1
  29. moai_adk/core/git/branch.py +0 -1
  30. moai_adk/core/git/branch_manager.py +4 -4
  31. moai_adk/core/git/checkpoint.py +1 -5
  32. moai_adk/core/git/commit.py +0 -1
  33. moai_adk/core/git/event_detector.py +3 -5
  34. moai_adk/core/git/manager.py +0 -1
  35. moai_adk/core/hooks/post_tool_auto_spec_completion.py +925 -0
  36. moai_adk/core/integration/__init__.py +22 -0
  37. moai_adk/core/integration/engine.py +169 -0
  38. moai_adk/core/integration/integration_tester.py +225 -0
  39. moai_adk/core/integration/models.py +88 -0
  40. moai_adk/core/integration/utils.py +211 -0
  41. moai_adk/core/issue_creator.py +28 -18
  42. moai_adk/core/language_config.py +202 -0
  43. moai_adk/core/language_validator.py +556 -0
  44. moai_adk/core/mcp/setup.py +113 -0
  45. moai_adk/core/migration/__init__.py +18 -0
  46. moai_adk/core/migration/backup_manager.py +208 -0
  47. moai_adk/core/migration/file_migrator.py +218 -0
  48. moai_adk/core/migration/version_detector.py +143 -0
  49. moai_adk/core/migration/version_migrator.py +228 -0
  50. moai_adk/core/performance/__init__.py +6 -0
  51. moai_adk/core/performance/cache_system.py +318 -0
  52. moai_adk/core/performance/parallel_processor.py +116 -0
  53. moai_adk/core/project/__init__.py +0 -1
  54. moai_adk/core/project/backup_utils.py +2 -7
  55. moai_adk/core/project/checker.py +3 -3
  56. moai_adk/core/project/detector.py +20 -40
  57. moai_adk/core/project/initializer.py +42 -17
  58. moai_adk/core/project/phase_executor.py +415 -58
  59. moai_adk/core/project/validator.py +6 -25
  60. moai_adk/core/quality/__init__.py +1 -1
  61. moai_adk/core/quality/trust_checker.py +64 -110
  62. moai_adk/core/quality/validators/__init__.py +1 -1
  63. moai_adk/core/quality/validators/base_validator.py +1 -1
  64. moai_adk/core/rollback_manager.py +993 -0
  65. moai_adk/core/session_manager.py +667 -0
  66. moai_adk/core/spec/confidence_scoring.py +749 -0
  67. moai_adk/core/spec/ears_template_engine.py +1182 -0
  68. moai_adk/core/spec/quality_validator.py +721 -0
  69. moai_adk/core/spec_status_manager.py +488 -0
  70. moai_adk/core/template/__init__.py +0 -1
  71. moai_adk/core/template/backup.py +41 -1
  72. moai_adk/core/template/config.py +11 -12
  73. moai_adk/core/template/languages.py +0 -1
  74. moai_adk/core/template/merger.py +79 -22
  75. moai_adk/core/template/processor.py +614 -40
  76. moai_adk/core/template_engine.py +36 -27
  77. moai_adk/foundation/git/commit_templates.py +565 -0
  78. moai_adk/foundation/trust/trust_principles.py +725 -0
  79. moai_adk/foundation/trust/validation_checklist.py +1678 -0
  80. moai_adk/statusline/__init__.py +38 -0
  81. moai_adk/statusline/alfred_detector.py +107 -0
  82. moai_adk/statusline/config.py +364 -0
  83. moai_adk/statusline/enhanced_output_style_detector.py +364 -0
  84. moai_adk/statusline/git_collector.py +190 -0
  85. moai_adk/statusline/main.py +228 -0
  86. moai_adk/statusline/metrics_tracker.py +78 -0
  87. moai_adk/statusline/renderer.py +327 -0
  88. moai_adk/statusline/update_checker.py +135 -0
  89. moai_adk/statusline/version_reader.py +647 -0
  90. moai_adk/templates/.git-hooks/pre-commit +66 -0
  91. moai_adk/templates/.git-hooks/pre-push +116 -4
  92. moai_adk/templates/.github/workflows/moai-gitflow.yml +1 -7
  93. moai_adk/templates/.github/workflows/spec-issue-sync.yml +0 -1
  94. moai_adk/templates/.gitignore +44 -0
  95. moai_adk/templates/.mcp.json +22 -0
  96. moai_adk/templates/CLAUDE.md +450 -1071
  97. moai_adk/utils/__init__.py +0 -1
  98. moai_adk/utils/banner.py +0 -1
  99. moai_adk/utils/common.py +308 -0
  100. moai_adk/utils/link_validator.py +249 -0
  101. moai_adk/utils/logger.py +4 -9
  102. moai_adk/utils/safe_file_reader.py +210 -0
  103. moai_adk/utils/user_experience.py +531 -0
  104. moai_adk-0.25.4.dist-info/METADATA +2279 -0
  105. moai_adk-0.25.4.dist-info/RECORD +112 -0
  106. moai_adk/core/tags/__init__.py +0 -86
  107. moai_adk/core/tags/ci_validator.py +0 -463
  108. moai_adk/core/tags/cli.py +0 -283
  109. moai_adk/core/tags/generator.py +0 -109
  110. moai_adk/core/tags/inserter.py +0 -99
  111. moai_adk/core/tags/mapper.py +0 -126
  112. moai_adk/core/tags/parser.py +0 -76
  113. moai_adk/core/tags/pre_commit_validator.py +0 -393
  114. moai_adk/core/tags/reporter.py +0 -956
  115. moai_adk/core/tags/tags.py +0 -149
  116. moai_adk/core/tags/validator.py +0 -897
  117. moai_adk/templates/.claude/agents/alfred/backend-expert.md +0 -319
  118. moai_adk/templates/.claude/agents/alfred/cc-manager.md +0 -316
  119. moai_adk/templates/.claude/agents/alfred/debug-helper.md +0 -208
  120. moai_adk/templates/.claude/agents/alfred/devops-expert.md +0 -464
  121. moai_adk/templates/.claude/agents/alfred/doc-syncer.md +0 -214
  122. moai_adk/templates/.claude/agents/alfred/frontend-expert.md +0 -357
  123. moai_adk/templates/.claude/agents/alfred/git-manager.md +0 -406
  124. moai_adk/templates/.claude/agents/alfred/implementation-planner.md +0 -423
  125. moai_adk/templates/.claude/agents/alfred/project-manager.md +0 -312
  126. moai_adk/templates/.claude/agents/alfred/quality-gate.md +0 -343
  127. moai_adk/templates/.claude/agents/alfred/skill-factory.md +0 -865
  128. moai_adk/templates/.claude/agents/alfred/spec-builder.md +0 -426
  129. moai_adk/templates/.claude/agents/alfred/tag-agent.md +0 -361
  130. moai_adk/templates/.claude/agents/alfred/tdd-implementer.md +0 -428
  131. moai_adk/templates/.claude/agents/alfred/trust-checker.md +0 -375
  132. moai_adk/templates/.claude/agents/alfred/ui-ux-expert.md +0 -571
  133. moai_adk/templates/.claude/commands/alfred/0-project.md +0 -1854
  134. moai_adk/templates/.claude/commands/alfred/1-plan.md +0 -880
  135. moai_adk/templates/.claude/commands/alfred/2-run.md +0 -793
  136. moai_adk/templates/.claude/commands/alfred/3-sync.md +0 -1084
  137. moai_adk/templates/.claude/commands/alfred/9-feedback.md +0 -149
  138. moai_adk/templates/.claude/hooks/alfred/core/project.py +0 -748
  139. moai_adk/templates/.claude/hooks/alfred/core/timeout.py +0 -136
  140. moai_adk/templates/.claude/hooks/alfred/core/ttl_cache.py +0 -108
  141. moai_adk/templates/.claude/hooks/alfred/core/version_cache.py +0 -198
  142. moai_adk/templates/.claude/hooks/alfred/handlers/__init__.py +0 -29
  143. moai_adk/templates/.claude/hooks/alfred/post_tool__log_changes.py +0 -94
  144. moai_adk/templates/.claude/hooks/alfred/pre_tool__auto_checkpoint.py +0 -100
  145. moai_adk/templates/.claude/hooks/alfred/session_end__cleanup.py +0 -94
  146. moai_adk/templates/.claude/hooks/alfred/session_start__show_project_info.py +0 -94
  147. moai_adk/templates/.claude/hooks/alfred/shared/core/__init__.py +0 -170
  148. moai_adk/templates/.claude/hooks/alfred/shared/core/checkpoint.py +0 -271
  149. moai_adk/templates/.claude/hooks/alfred/shared/core/context.py +0 -67
  150. moai_adk/templates/.claude/hooks/alfred/shared/core/project.py +0 -749
  151. moai_adk/templates/.claude/hooks/alfred/shared/core/tags.py +0 -230
  152. moai_adk/templates/.claude/hooks/alfred/shared/core/version_cache.py +0 -198
  153. moai_adk/templates/.claude/hooks/alfred/shared/handlers/__init__.py +0 -21
  154. moai_adk/templates/.claude/hooks/alfred/shared/handlers/notification.py +0 -154
  155. moai_adk/templates/.claude/hooks/alfred/shared/handlers/session.py +0 -174
  156. moai_adk/templates/.claude/hooks/alfred/shared/handlers/tool.py +0 -87
  157. moai_adk/templates/.claude/hooks/alfred/shared/handlers/user.py +0 -61
  158. moai_adk/templates/.claude/hooks/alfred/user_prompt__jit_load_docs.py +0 -112
  159. moai_adk/templates/.claude/hooks/alfred/utils/__init__.py +0 -1
  160. moai_adk/templates/.claude/hooks/alfred/utils/timeout.py +0 -161
  161. moai_adk/templates/.claude/settings.json +0 -144
  162. moai_adk/templates/.claude/skills/moai-alfred-agent-guide/SKILL.md +0 -70
  163. moai_adk/templates/.claude/skills/moai-alfred-agent-guide/examples.md +0 -62
  164. moai_adk/templates/.claude/skills/moai-alfred-agent-guide/reference.md +0 -242
  165. moai_adk/templates/.claude/skills/moai-alfred-config-schema/SKILL.md +0 -56
  166. moai_adk/templates/.claude/skills/moai-alfred-config-schema/examples.md +0 -28
  167. moai_adk/templates/.claude/skills/moai-alfred-config-schema/reference.md +0 -444
  168. moai_adk/templates/.claude/skills/moai-alfred-context-budget/SKILL.md +0 -62
  169. moai_adk/templates/.claude/skills/moai-alfred-context-budget/examples.md +0 -28
  170. moai_adk/templates/.claude/skills/moai-alfred-context-budget/reference.md +0 -405
  171. moai_adk/templates/.claude/skills/moai-alfred-dev-guide/SKILL.md +0 -51
  172. moai_adk/templates/.claude/skills/moai-alfred-dev-guide/examples.md +0 -355
  173. moai_adk/templates/.claude/skills/moai-alfred-dev-guide/reference.md +0 -239
  174. moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/SKILL.md +0 -113
  175. moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/examples.md +0 -29
  176. moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/reference.md +0 -28
  177. moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/SKILL.md +0 -323
  178. moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/examples.md +0 -286
  179. moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/reference.md +0 -126
  180. moai_adk/templates/.claude/skills/moai-alfred-git-workflow/SKILL.md +0 -122
  181. moai_adk/templates/.claude/skills/moai-alfred-git-workflow/examples.md +0 -29
  182. moai_adk/templates/.claude/skills/moai-alfred-git-workflow/reference.md +0 -29
  183. moai_adk/templates/.claude/skills/moai-alfred-gitflow-policy/SKILL.md +0 -74
  184. moai_adk/templates/.claude/skills/moai-alfred-gitflow-policy/examples.md +0 -4
  185. moai_adk/templates/.claude/skills/moai-alfred-gitflow-policy/reference.md +0 -269
  186. moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/SKILL.md +0 -237
  187. moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/examples.md +0 -615
  188. moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/reference.md +0 -653
  189. moai_adk/templates/.claude/skills/moai-alfred-issue-labels/SKILL.md +0 -19
  190. moai_adk/templates/.claude/skills/moai-alfred-issue-labels/examples.md +0 -4
  191. moai_adk/templates/.claude/skills/moai-alfred-issue-labels/reference.md +0 -150
  192. moai_adk/templates/.claude/skills/moai-alfred-language-detection/SKILL.md +0 -113
  193. moai_adk/templates/.claude/skills/moai-alfred-language-detection/examples.md +0 -29
  194. moai_adk/templates/.claude/skills/moai-alfred-language-detection/reference.md +0 -28
  195. moai_adk/templates/.claude/skills/moai-alfred-persona-roles/SKILL.md +0 -198
  196. moai_adk/templates/.claude/skills/moai-alfred-persona-roles/examples.md +0 -431
  197. moai_adk/templates/.claude/skills/moai-alfred-persona-roles/reference.md +0 -141
  198. moai_adk/templates/.claude/skills/moai-alfred-practices/SKILL.md +0 -89
  199. moai_adk/templates/.claude/skills/moai-alfred-practices/examples.md +0 -122
  200. moai_adk/templates/.claude/skills/moai-alfred-practices/reference.md +0 -369
  201. moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/SKILL.md +0 -508
  202. moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/examples.md +0 -481
  203. moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/reference.md +0 -100
  204. moai_adk/templates/.claude/skills/moai-alfred-reporting/SKILL.md +0 -273
  205. moai_adk/templates/.claude/skills/moai-alfred-rules/SKILL.md +0 -77
  206. moai_adk/templates/.claude/skills/moai-alfred-rules/examples.md +0 -265
  207. moai_adk/templates/.claude/skills/moai-alfred-rules/reference.md +0 -539
  208. moai_adk/templates/.claude/skills/moai-alfred-session-state/SKILL.md +0 -19
  209. moai_adk/templates/.claude/skills/moai-alfred-session-state/examples.md +0 -4
  210. moai_adk/templates/.claude/skills/moai-alfred-session-state/reference.md +0 -84
  211. moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/README.md +0 -137
  212. moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/SKILL.md +0 -219
  213. moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/examples/validate-spec.sh +0 -161
  214. moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/examples.md +0 -541
  215. moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/reference.md +0 -622
  216. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-extended/SKILL.md +0 -115
  217. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-extended/examples.md +0 -4
  218. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-extended/reference.md +0 -348
  219. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/SKILL.md +0 -113
  220. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/examples.md +0 -29
  221. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/reference.md +0 -28
  222. moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/SKILL.md +0 -113
  223. moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/examples.md +0 -29
  224. moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/reference.md +0 -28
  225. moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/SKILL.md +0 -19
  226. moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/examples.md +0 -4
  227. moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/reference.md +0 -211
  228. moai_adk/templates/.claude/skills/moai-alfred-trust-validation/SKILL.md +0 -113
  229. moai_adk/templates/.claude/skills/moai-alfred-trust-validation/examples.md +0 -29
  230. moai_adk/templates/.claude/skills/moai-alfred-trust-validation/reference.md +0 -28
  231. moai_adk/templates/.claude/skills/moai-alfred-workflow/SKILL.md +0 -288
  232. moai_adk/templates/.claude/skills/moai-cc-agents/SKILL.md +0 -269
  233. moai_adk/templates/.claude/skills/moai-cc-agents/templates/agent-template.md +0 -32
  234. moai_adk/templates/.claude/skills/moai-cc-claude-md/SKILL.md +0 -298
  235. moai_adk/templates/.claude/skills/moai-cc-claude-md/templates/CLAUDE-template.md +0 -26
  236. moai_adk/templates/.claude/skills/moai-cc-commands/SKILL.md +0 -307
  237. moai_adk/templates/.claude/skills/moai-cc-commands/templates/command-template.md +0 -21
  238. moai_adk/templates/.claude/skills/moai-cc-hooks/SKILL.md +0 -252
  239. moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/pre-bash-check.sh +0 -19
  240. moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/preserve-permissions.sh +0 -19
  241. moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/validate-bash-command.py +0 -24
  242. moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/SKILL.md +0 -199
  243. moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/templates/settings-mcp-template.json +0 -39
  244. moai_adk/templates/.claude/skills/moai-cc-memory/SKILL.md +0 -316
  245. moai_adk/templates/.claude/skills/moai-cc-memory/templates/session-summary-template.md +0 -18
  246. moai_adk/templates/.claude/skills/moai-cc-settings/SKILL.md +0 -263
  247. moai_adk/templates/.claude/skills/moai-cc-settings/templates/settings-complete-template.json +0 -30
  248. moai_adk/templates/.claude/skills/moai-cc-skill-descriptions/SKILL.md +0 -19
  249. moai_adk/templates/.claude/skills/moai-cc-skill-descriptions/examples.md +0 -4
  250. moai_adk/templates/.claude/skills/moai-cc-skill-descriptions/reference.md +0 -218
  251. moai_adk/templates/.claude/skills/moai-cc-skill-factory/CHECKLIST.md +0 -482
  252. moai_adk/templates/.claude/skills/moai-cc-skill-factory/EXAMPLES.md +0 -278
  253. moai_adk/templates/.claude/skills/moai-cc-skill-factory/INTERACTIVE-DISCOVERY.md +0 -524
  254. moai_adk/templates/.claude/skills/moai-cc-skill-factory/METADATA.md +0 -477
  255. moai_adk/templates/.claude/skills/moai-cc-skill-factory/PARALLEL-ANALYSIS-REPORT.md +0 -429
  256. moai_adk/templates/.claude/skills/moai-cc-skill-factory/PYTHON-VERSION-MATRIX.md +0 -391
  257. moai_adk/templates/.claude/skills/moai-cc-skill-factory/SKILL-FACTORY-WORKFLOW.md +0 -431
  258. moai_adk/templates/.claude/skills/moai-cc-skill-factory/SKILL-UPDATE-ADVISOR.md +0 -577
  259. moai_adk/templates/.claude/skills/moai-cc-skill-factory/SKILL.md +0 -271
  260. moai_adk/templates/.claude/skills/moai-cc-skill-factory/STEP-BY-STEP-GUIDE.md +0 -466
  261. moai_adk/templates/.claude/skills/moai-cc-skill-factory/STRUCTURE.md +0 -583
  262. moai_adk/templates/.claude/skills/moai-cc-skill-factory/WEB-RESEARCH.md +0 -526
  263. moai_adk/templates/.claude/skills/moai-cc-skill-factory/reference.md +0 -465
  264. moai_adk/templates/.claude/skills/moai-cc-skill-factory/scripts/generate-structure.sh +0 -328
  265. moai_adk/templates/.claude/skills/moai-cc-skill-factory/scripts/validate-skill.sh +0 -312
  266. moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/SKILL_TEMPLATE.md +0 -245
  267. moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/examples-template.md +0 -285
  268. moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/reference-template.md +0 -278
  269. moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/scripts-template.sh +0 -303
  270. moai_adk/templates/.claude/skills/moai-cc-skills/SKILL.md +0 -291
  271. moai_adk/templates/.claude/skills/moai-cc-skills/templates/SKILL-template.md +0 -15
  272. moai_adk/templates/.claude/skills/moai-design-systems/SKILL.md +0 -802
  273. moai_adk/templates/.claude/skills/moai-design-systems/examples.md +0 -1238
  274. moai_adk/templates/.claude/skills/moai-design-systems/reference.md +0 -673
  275. moai_adk/templates/.claude/skills/moai-domain-backend/SKILL.md +0 -290
  276. moai_adk/templates/.claude/skills/moai-domain-backend/examples.md +0 -1633
  277. moai_adk/templates/.claude/skills/moai-domain-backend/reference.md +0 -660
  278. moai_adk/templates/.claude/skills/moai-domain-cli-tool/SKILL.md +0 -123
  279. moai_adk/templates/.claude/skills/moai-domain-cli-tool/examples.md +0 -29
  280. moai_adk/templates/.claude/skills/moai-domain-cli-tool/reference.md +0 -30
  281. moai_adk/templates/.claude/skills/moai-domain-data-science/SKILL.md +0 -123
  282. moai_adk/templates/.claude/skills/moai-domain-data-science/examples.md +0 -29
  283. moai_adk/templates/.claude/skills/moai-domain-data-science/reference.md +0 -30
  284. moai_adk/templates/.claude/skills/moai-domain-database/SKILL.md +0 -123
  285. moai_adk/templates/.claude/skills/moai-domain-database/examples.md +0 -29
  286. moai_adk/templates/.claude/skills/moai-domain-database/reference.md +0 -30
  287. moai_adk/templates/.claude/skills/moai-domain-devops/SKILL.md +0 -124
  288. moai_adk/templates/.claude/skills/moai-domain-devops/examples.md +0 -29
  289. moai_adk/templates/.claude/skills/moai-domain-devops/reference.md +0 -31
  290. moai_adk/templates/.claude/skills/moai-domain-frontend/SKILL.md +0 -128
  291. moai_adk/templates/.claude/skills/moai-domain-frontend/examples.md +0 -29
  292. moai_adk/templates/.claude/skills/moai-domain-frontend/reference.md +0 -31
  293. moai_adk/templates/.claude/skills/moai-domain-ml/SKILL.md +0 -123
  294. moai_adk/templates/.claude/skills/moai-domain-ml/examples.md +0 -29
  295. moai_adk/templates/.claude/skills/moai-domain-ml/reference.md +0 -30
  296. moai_adk/templates/.claude/skills/moai-domain-mobile-app/SKILL.md +0 -123
  297. moai_adk/templates/.claude/skills/moai-domain-mobile-app/examples.md +0 -29
  298. moai_adk/templates/.claude/skills/moai-domain-mobile-app/reference.md +0 -30
  299. moai_adk/templates/.claude/skills/moai-domain-security/SKILL.md +0 -123
  300. moai_adk/templates/.claude/skills/moai-domain-security/examples.md +0 -29
  301. moai_adk/templates/.claude/skills/moai-domain-security/reference.md +0 -30
  302. moai_adk/templates/.claude/skills/moai-domain-web-api/SKILL.md +0 -123
  303. moai_adk/templates/.claude/skills/moai-domain-web-api/examples.md +0 -29
  304. moai_adk/templates/.claude/skills/moai-domain-web-api/reference.md +0 -30
  305. moai_adk/templates/.claude/skills/moai-essentials-debug/SKILL.md +0 -303
  306. moai_adk/templates/.claude/skills/moai-essentials-debug/examples.md +0 -1064
  307. moai_adk/templates/.claude/skills/moai-essentials-debug/reference.md +0 -1047
  308. moai_adk/templates/.claude/skills/moai-essentials-perf/SKILL.md +0 -113
  309. moai_adk/templates/.claude/skills/moai-essentials-perf/examples.md +0 -29
  310. moai_adk/templates/.claude/skills/moai-essentials-perf/reference.md +0 -28
  311. moai_adk/templates/.claude/skills/moai-essentials-refactor/SKILL.md +0 -113
  312. moai_adk/templates/.claude/skills/moai-essentials-refactor/examples.md +0 -29
  313. moai_adk/templates/.claude/skills/moai-essentials-refactor/reference.md +0 -28
  314. moai_adk/templates/.claude/skills/moai-essentials-review/SKILL.md +0 -113
  315. moai_adk/templates/.claude/skills/moai-essentials-review/examples.md +0 -29
  316. moai_adk/templates/.claude/skills/moai-essentials-review/reference.md +0 -28
  317. moai_adk/templates/.claude/skills/moai-foundation-ears/SKILL.md +0 -116
  318. moai_adk/templates/.claude/skills/moai-foundation-ears/examples.md +0 -29
  319. moai_adk/templates/.claude/skills/moai-foundation-ears/reference.md +0 -28
  320. moai_adk/templates/.claude/skills/moai-foundation-git/SKILL.md +0 -122
  321. moai_adk/templates/.claude/skills/moai-foundation-git/examples.md +0 -29
  322. moai_adk/templates/.claude/skills/moai-foundation-git/reference.md +0 -29
  323. moai_adk/templates/.claude/skills/moai-foundation-langs/SKILL.md +0 -113
  324. moai_adk/templates/.claude/skills/moai-foundation-langs/examples.md +0 -29
  325. moai_adk/templates/.claude/skills/moai-foundation-langs/reference.md +0 -28
  326. moai_adk/templates/.claude/skills/moai-foundation-specs/SKILL.md +0 -113
  327. moai_adk/templates/.claude/skills/moai-foundation-specs/examples.md +0 -29
  328. moai_adk/templates/.claude/skills/moai-foundation-specs/reference.md +0 -28
  329. moai_adk/templates/.claude/skills/moai-foundation-tags/SKILL.md +0 -113
  330. moai_adk/templates/.claude/skills/moai-foundation-tags/examples.md +0 -29
  331. moai_adk/templates/.claude/skills/moai-foundation-tags/reference.md +0 -28
  332. moai_adk/templates/.claude/skills/moai-foundation-trust/SKILL.md +0 -307
  333. moai_adk/templates/.claude/skills/moai-foundation-trust/examples.md +0 -0
  334. moai_adk/templates/.claude/skills/moai-foundation-trust/reference.md +0 -1099
  335. moai_adk/templates/.claude/skills/moai-lang-c/SKILL.md +0 -124
  336. moai_adk/templates/.claude/skills/moai-lang-c/examples.md +0 -29
  337. moai_adk/templates/.claude/skills/moai-lang-c/reference.md +0 -31
  338. moai_adk/templates/.claude/skills/moai-lang-cpp/SKILL.md +0 -124
  339. moai_adk/templates/.claude/skills/moai-lang-cpp/examples.md +0 -29
  340. moai_adk/templates/.claude/skills/moai-lang-cpp/reference.md +0 -31
  341. moai_adk/templates/.claude/skills/moai-lang-csharp/SKILL.md +0 -123
  342. moai_adk/templates/.claude/skills/moai-lang-csharp/examples.md +0 -29
  343. moai_adk/templates/.claude/skills/moai-lang-csharp/reference.md +0 -30
  344. moai_adk/templates/.claude/skills/moai-lang-dart/SKILL.md +0 -123
  345. moai_adk/templates/.claude/skills/moai-lang-dart/examples.md +0 -29
  346. moai_adk/templates/.claude/skills/moai-lang-dart/reference.md +0 -30
  347. moai_adk/templates/.claude/skills/moai-lang-go/SKILL.md +0 -127
  348. moai_adk/templates/.claude/skills/moai-lang-go/examples.md +0 -29
  349. moai_adk/templates/.claude/skills/moai-lang-go/reference.md +0 -31
  350. moai_adk/templates/.claude/skills/moai-lang-java/SKILL.md +0 -126
  351. moai_adk/templates/.claude/skills/moai-lang-java/examples.md +0 -29
  352. moai_adk/templates/.claude/skills/moai-lang-java/reference.md +0 -31
  353. moai_adk/templates/.claude/skills/moai-lang-javascript/SKILL.md +0 -125
  354. moai_adk/templates/.claude/skills/moai-lang-javascript/examples.md +0 -29
  355. moai_adk/templates/.claude/skills/moai-lang-javascript/reference.md +0 -32
  356. moai_adk/templates/.claude/skills/moai-lang-kotlin/SKILL.md +0 -124
  357. moai_adk/templates/.claude/skills/moai-lang-kotlin/examples.md +0 -29
  358. moai_adk/templates/.claude/skills/moai-lang-kotlin/reference.md +0 -31
  359. moai_adk/templates/.claude/skills/moai-lang-php/SKILL.md +0 -126
  360. moai_adk/templates/.claude/skills/moai-lang-php/examples.md +0 -29
  361. moai_adk/templates/.claude/skills/moai-lang-php/reference.md +0 -30
  362. moai_adk/templates/.claude/skills/moai-lang-python/SKILL.md +0 -433
  363. moai_adk/templates/.claude/skills/moai-lang-python/examples.md +0 -624
  364. moai_adk/templates/.claude/skills/moai-lang-python/reference.md +0 -316
  365. moai_adk/templates/.claude/skills/moai-lang-r/SKILL.md +0 -123
  366. moai_adk/templates/.claude/skills/moai-lang-r/examples.md +0 -29
  367. moai_adk/templates/.claude/skills/moai-lang-r/reference.md +0 -30
  368. moai_adk/templates/.claude/skills/moai-lang-ruby/SKILL.md +0 -124
  369. moai_adk/templates/.claude/skills/moai-lang-ruby/examples.md +0 -29
  370. moai_adk/templates/.claude/skills/moai-lang-ruby/reference.md +0 -31
  371. moai_adk/templates/.claude/skills/moai-lang-rust/SKILL.md +0 -127
  372. moai_adk/templates/.claude/skills/moai-lang-rust/examples.md +0 -29
  373. moai_adk/templates/.claude/skills/moai-lang-rust/reference.md +0 -31
  374. moai_adk/templates/.claude/skills/moai-lang-scala/SKILL.md +0 -125
  375. moai_adk/templates/.claude/skills/moai-lang-scala/examples.md +0 -29
  376. moai_adk/templates/.claude/skills/moai-lang-scala/reference.md +0 -30
  377. moai_adk/templates/.claude/skills/moai-lang-shell/SKILL.md +0 -123
  378. moai_adk/templates/.claude/skills/moai-lang-shell/examples.md +0 -29
  379. moai_adk/templates/.claude/skills/moai-lang-shell/reference.md +0 -30
  380. moai_adk/templates/.claude/skills/moai-lang-sql/SKILL.md +0 -124
  381. moai_adk/templates/.claude/skills/moai-lang-sql/examples.md +0 -29
  382. moai_adk/templates/.claude/skills/moai-lang-sql/reference.md +0 -31
  383. moai_adk/templates/.claude/skills/moai-lang-swift/SKILL.md +0 -123
  384. moai_adk/templates/.claude/skills/moai-lang-swift/examples.md +0 -29
  385. moai_adk/templates/.claude/skills/moai-lang-swift/reference.md +0 -30
  386. moai_adk/templates/.claude/skills/moai-lang-typescript/SKILL.md +0 -133
  387. moai_adk/templates/.claude/skills/moai-lang-typescript/examples.md +0 -29
  388. moai_adk/templates/.claude/skills/moai-lang-typescript/reference.md +0 -34
  389. moai_adk/templates/.claude/skills/moai-project-documentation.md +0 -622
  390. moai_adk/templates/.github/workflows/c-tag-validation.yml +0 -11
  391. moai_adk/templates/.github/workflows/cpp-tag-validation.yml +0 -11
  392. moai_adk/templates/.github/workflows/csharp-tag-validation.yml +0 -11
  393. moai_adk/templates/.github/workflows/dart-tag-validation.yml +0 -11
  394. moai_adk/templates/.github/workflows/go-tag-validation.yml +0 -130
  395. moai_adk/templates/.github/workflows/java-tag-validation.yml +0 -11
  396. moai_adk/templates/.github/workflows/javascript-tag-validation.yml +0 -135
  397. moai_adk/templates/.github/workflows/kotlin-tag-validation.yml +0 -11
  398. moai_adk/templates/.github/workflows/php-tag-validation.yml +0 -11
  399. moai_adk/templates/.github/workflows/python-tag-validation.yml +0 -118
  400. moai_adk/templates/.github/workflows/release.yml +0 -118
  401. moai_adk/templates/.github/workflows/ruby-tag-validation.yml +0 -11
  402. moai_adk/templates/.github/workflows/rust-tag-validation.yml +0 -11
  403. moai_adk/templates/.github/workflows/shell-tag-validation.yml +0 -11
  404. moai_adk/templates/.github/workflows/swift-tag-validation.yml +0 -11
  405. moai_adk/templates/.github/workflows/tag-report.yml +0 -269
  406. moai_adk/templates/.github/workflows/tag-validation.yml +0 -186
  407. moai_adk/templates/.github/workflows/typescript-tag-validation.yml +0 -154
  408. moai_adk/templates/.moai/config.json +0 -115
  409. moai_adk/templates/workflows/go-tag-validation.yml +0 -30
  410. moai_adk/templates/workflows/javascript-tag-validation.yml +0 -41
  411. moai_adk/templates/workflows/python-tag-validation.yml +0 -42
  412. moai_adk/templates/workflows/typescript-tag-validation.yml +0 -31
  413. moai_adk-0.15.1.dist-info/METADATA +0 -3094
  414. moai_adk-0.15.1.dist-info/RECORD +0 -365
  415. {moai_adk-0.15.1.dist-info → moai_adk-0.25.4.dist-info}/WHEEL +0 -0
  416. {moai_adk-0.15.1.dist-info → moai_adk-0.25.4.dist-info}/entry_points.txt +0 -0
  417. {moai_adk-0.15.1.dist-info → moai_adk-0.25.4.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,1182 @@
1
+ """EARS Template Engine for Auto-Generated SPECs."""
2
+
3
+ import logging
4
+ import re
5
+ import time
6
+ from pathlib import Path
7
+ from typing import Any, Dict
8
+
9
+ from moai_adk.core.spec.confidence_scoring import ConfidenceScoringSystem
10
+
11
+ # Configure logging
12
+ logger = logging.getLogger(__name__)
13
+
14
+
15
+ class EARSTemplateEngine:
16
+ """
17
+ EARS Template Engine for generating complete SPEC documents.
18
+
19
+ This engine generates SPEC documents in EARS (Environment, Assumptions,
20
+ Requirements, Specifications) format based on code analysis.
21
+ """
22
+
23
+ def __init__(self):
24
+ self.confidence_scorer = ConfidenceScoringSystem()
25
+ self.template_cache = {}
26
+
27
+ # Domain-specific templates
28
+ self.domain_templates = {
29
+ 'auth': {
30
+ 'description': 'User authentication and security system',
31
+ 'common_features': ['Login', 'Registration', 'Password Reset', 'Session Management'],
32
+ 'security_requirements': ['Encryption', 'Password Hashing', 'Rate Limiting'],
33
+ 'environment': 'Web Application with User Management'
34
+ },
35
+ 'api': {
36
+ 'description': 'RESTful API service',
37
+ 'common_features': ['Endpoints', 'Authentication', 'Rate Limiting', 'Caching'],
38
+ 'technical_requirements': ['RESTful Design', 'JSON Format', 'HTTP Status Codes'],
39
+ 'environment': 'Microservice Architecture'
40
+ },
41
+ 'data': {
42
+ 'description': 'Data processing and storage system',
43
+ 'common_features': ['Data Validation', 'Persistence', 'Backup', 'Migration'],
44
+ 'technical_requirements': ['Data Integrity', 'Performance', 'Scalability'],
45
+ 'environment': 'Database System with Analytics'
46
+ },
47
+ 'ui': {
48
+ 'description': 'User interface and experience system',
49
+ 'common_features': ['Components', 'Navigation', 'Forms', 'Validation'],
50
+ 'experience_requirements': ['Responsive Design', 'Accessibility', 'Performance'],
51
+ 'environment': 'Web Frontend with React/Angular/Vue'
52
+ },
53
+ 'business': {
54
+ 'description': 'Business logic and workflow system',
55
+ 'common_features': ['Process Management', 'Rules Engine', 'Notifications'],
56
+ 'business_requirements': ['Compliance', 'Audit Trail', 'Reporting'],
57
+ 'environment': 'Enterprise Application'
58
+ }
59
+ }
60
+
61
+ # EARS section templates
62
+ self.ears_templates = {
63
+ 'environment': {
64
+ 'template': '''### Environment
65
+
66
+ - **Project**: {project_name}
67
+ - **Language**: {language}
68
+ - **Framework**: {framework}
69
+ - **Paradigm**: {paradigm}
70
+ - **Platform**: {platform}
71
+ - **Deployment**: {deployment}
72
+ - **Status**: {status}
73
+ - **Generation Method**: Auto-analysis based''',
74
+ 'required_fields': ['project_name', 'language', 'framework', 'paradigm']
75
+ },
76
+ 'assumptions': {
77
+ 'template': '''### Assumptions
78
+
79
+ 1. System follows standard development practices
80
+ 2. Users have basic domain knowledge
81
+ 3. System is designed with stable and scalable architecture
82
+ 4. External dependencies operate normally
83
+ 5. Security requirements comply with industry standards
84
+ 6. Data integrity is maintained
85
+ 7. User interface is intuitively designed
86
+ 8. Performance requirements are met''',
87
+ 'required_fields': []
88
+ },
89
+ 'requirements': {
90
+ 'template': '''### Requirements
91
+
92
+ #### Ubiquitous Requirements
93
+
94
+ - **REQ-001**: System SHALL perform {primary_function} functionality
95
+ - **REQ-002**: Generated features SHALL be stable
96
+ - **REQ-003**: Code SHALL be maintainable
97
+ - **REQ-004**: Tests SHALL meet functional requirements
98
+ - **REQ-005**: Code SHALL comply with project coding standards
99
+ - **REQ-006**: System SHALL handle exceptional situations appropriately
100
+ - **REQ-007**: User experience SHALL be optimized
101
+
102
+ #### State-driven Requirements
103
+
104
+ {state_requirements}
105
+
106
+ #### Event-driven Requirements
107
+
108
+ {event_requirements}
109
+
110
+ #### Optional Requirements
111
+
112
+ - **REQ-008**: System SHALL include performance monitoring features
113
+ - **REQ-009**: Automatic backup and restore features MAY be required
114
+ - **REQ-010**: User activity logging MAY be required
115
+ - **REQ-011**: Multi-language support MAY be required
116
+ - **REQ-012**: Mobile compatibility MAY be required''',
117
+ 'required_fields': ['primary_function']
118
+ },
119
+ 'specifications': {
120
+ 'template': '''### Specifications
121
+
122
+ {technical_specs}
123
+
124
+ #### Technical Specifications
125
+
126
+ {technical_details}
127
+
128
+ #### Data Models
129
+
130
+ {data_models}
131
+
132
+ #### API Specifications
133
+
134
+ {api_specs}
135
+
136
+ #### Interface Specifications
137
+
138
+ {interface_specs}
139
+
140
+ #### Security Specifications
141
+
142
+ {security_specs}
143
+
144
+ #### Performance Specifications
145
+
146
+ {performance_specs}
147
+
148
+ #### Scalability Specifications
149
+
150
+ {scalability_specs}''',
151
+ 'required_fields': []
152
+ }
153
+ }
154
+
155
+ def generate_complete_spec(self, code_analysis: Dict[str, Any],
156
+ file_path: str,
157
+ custom_config: Dict[str, Any] = None) -> Dict[str, str]:
158
+ """
159
+ Generate complete SPEC document in EARS format.
160
+
161
+ Args:
162
+ code_analysis: Code analysis result
163
+ file_path: Path to the analyzed file
164
+ custom_config: Custom configuration overrides
165
+
166
+ Returns:
167
+ Dictionary with spec.md, plan.md, and acceptance.md
168
+ """
169
+ start_time = time.time()
170
+
171
+ # Extract information from code analysis
172
+ extraction_result = self._extract_information_from_analysis(code_analysis, file_path)
173
+
174
+ # Determine domain
175
+ domain = self._determine_domain(extraction_result)
176
+
177
+ # Generate SPEC ID
178
+ spec_id = self._generate_spec_id(extraction_result, domain)
179
+
180
+ # Generate content for each section
181
+ spec_md_content = self._generate_spec_content(extraction_result, domain, spec_id, custom_config)
182
+ plan_md_content = self._generate_plan_content(extraction_result, domain, spec_id, custom_config)
183
+ acceptance_md_content = self._generate_acceptance_content(extraction_result, domain, spec_id, custom_config)
184
+
185
+ # Validate content
186
+ validation_result = self._validate_ears_compliance({
187
+ 'spec_md': spec_md_content,
188
+ 'plan_md': plan_md_content,
189
+ 'acceptance_md': acceptance_md_content
190
+ })
191
+
192
+ # Create result
193
+ result = {
194
+ 'spec_id': spec_id,
195
+ 'domain': domain,
196
+ 'spec_md': spec_md_content,
197
+ 'plan_md': plan_md_content,
198
+ 'acceptance_md': acceptance_md_content,
199
+ 'validation': validation_result,
200
+ 'generation_time': time.time() - start_time,
201
+ 'extraction': extraction_result
202
+ }
203
+
204
+ return result
205
+
206
+ def _extract_information_from_analysis(self, code_analysis: Dict[str, Any], file_path: str) -> Dict[str, Any]:
207
+ """Extract information from code analysis."""
208
+ extraction = {
209
+ 'file_path': file_path,
210
+ 'file_name': Path(file_path).stem,
211
+ 'file_extension': Path(file_path).suffix,
212
+ 'language': self._detect_language(file_path),
213
+ 'classes': [],
214
+ 'functions': [],
215
+ 'imports': [],
216
+ 'domain_keywords': [],
217
+ 'technical_indicators': [],
218
+ 'complexity': 'low',
219
+ 'architecture': 'simple'
220
+ }
221
+
222
+ # Extract from code_analysis
223
+ if 'structure_info' in code_analysis:
224
+ structure = code_analysis['structure_info']
225
+ extraction['classes'] = structure.get('classes', [])
226
+ extraction['functions'] = structure.get('functions', [])
227
+ extraction['imports'] = structure.get('imports', [])
228
+
229
+ if 'domain_keywords' in code_analysis:
230
+ extraction['domain_keywords'] = code_analysis['domain_keywords']
231
+
232
+ # Extract from AST analysis if available
233
+ if hasattr(code_analysis, 'ast_info'):
234
+ ast_info = code_analysis.ast_info
235
+ # Additional extraction logic here
236
+
237
+ # Determine complexity and architecture
238
+ extraction['complexity'] = self._analyze_complexity(extraction)
239
+ extraction['architecture'] = self._analyze_architecture(extraction)
240
+
241
+ return extraction
242
+
243
+ def _detect_language(self, file_path: str) -> str:
244
+ """Detect programming language from file path."""
245
+ extension = Path(file_path).suffix.lower()
246
+
247
+ language_map = {
248
+ '.py': 'Python',
249
+ '.js': 'JavaScript',
250
+ '.jsx': 'JavaScript',
251
+ '.ts': 'TypeScript',
252
+ '.tsx': 'TypeScript',
253
+ '.go': 'Go',
254
+ '.java': 'Java',
255
+ '.cpp': 'C++',
256
+ '.c': 'C',
257
+ '.cs': 'C#',
258
+ '.rb': 'Ruby',
259
+ '.php': 'PHP',
260
+ '.swift': 'Swift',
261
+ '.kt': 'Kotlin'
262
+ }
263
+
264
+ return language_map.get(extension, 'Unknown')
265
+
266
+ def _analyze_complexity(self, extraction: Dict[str, Any]) -> str:
267
+ """Analyze code complexity."""
268
+ class_count = len(extraction['classes'])
269
+ function_count = len(extraction['functions'])
270
+
271
+ if class_count > 5 or function_count > 20:
272
+ return 'high'
273
+ elif class_count > 2 or function_count > 10:
274
+ return 'medium'
275
+ else:
276
+ return 'low'
277
+
278
+ def _analyze_architecture(self, extraction: Dict[str, Any]) -> str:
279
+ """Analyze system architecture."""
280
+ imports = extraction['imports']
281
+
282
+ # Check for architectural patterns
283
+ if any('django' in imp.lower() for imp in imports):
284
+ return 'mvc'
285
+ elif any('react' in imp.lower() or 'vue' in imp.lower() for imp in imports):
286
+ return 'frontend'
287
+ elif any('fastapi' in imp.lower() or 'flask' in imp.lower() for imp in imports):
288
+ return 'api'
289
+ elif any('sqlalchemy' in imp.lower() or 'django' in imp.lower() for imp in imports):
290
+ return 'data'
291
+ else:
292
+ return 'simple'
293
+
294
+ def _determine_domain(self, extraction: Dict[str, Any]) -> str:
295
+ """Determine the domain based on code analysis."""
296
+ domain_keywords = extraction['domain_keywords']
297
+ imports = extraction['imports']
298
+
299
+ # Check for domain indicators
300
+ domain_indicators = {
301
+ 'auth': ['auth', 'login', 'password', 'security', 'bcrypt', 'token'],
302
+ 'api': ['api', 'endpoint', 'route', 'controller', 'service'],
303
+ 'data': ['model', 'entity', 'schema', 'database', 'persistence'],
304
+ 'ui': ['ui', 'interface', 'component', 'view', 'template'],
305
+ 'business': ['business', 'logic', 'process', 'workflow', 'rule']
306
+ }
307
+
308
+ domain_scores = {}
309
+ for domain, keywords in domain_indicators.items():
310
+ score = sum(1 for keyword in keywords if any(keyword in kw for kw in domain_keywords))
311
+ domain_scores[domain] = score
312
+
313
+ # Return domain with highest score
314
+ if domain_scores:
315
+ return max(domain_scores, key=domain_scores.get)
316
+ else:
317
+ return 'general'
318
+
319
+ def _generate_spec_id(self, extraction: Dict[str, Any], domain: str) -> str:
320
+ """Generate unique SPEC ID."""
321
+ file_name = extraction['file_name']
322
+ domain_upper = domain.upper()
323
+
324
+ # Clean file name
325
+ clean_name = re.sub(r'[^a-zA-Z0-9]', '', file_name)
326
+
327
+ # Generate hash for uniqueness
328
+ import hashlib
329
+ file_hash = hashlib.md5(f"{file_name}{domain}{time.time()}".encode()).hexdigest()[:4]
330
+
331
+ return f"{domain_upper}-{clean_name[:8]}-{file_hash}"
332
+
333
+ def _generate_spec_content(self, extraction: Dict[str, Any], domain: str,
334
+ spec_id: str, custom_config: Dict[str, Any] = None) -> str:
335
+ """Generate main spec.md content."""
336
+ config = custom_config or {}
337
+
338
+ # Get domain template
339
+ domain_info = self.domain_templates.get(domain, {
340
+ 'description': 'General system',
341
+ 'common_features': ['Standard Features'],
342
+ 'environment': 'General Purpose'
343
+ })
344
+
345
+ # Extract information
346
+ primary_function = self._extract_primary_function(extraction, domain)
347
+ state_requirements = self._generate_state_requirements(extraction, domain)
348
+ event_requirements = self._generate_event_requirements(extraction, domain)
349
+ technical_specs = self._generate_technical_specs(extraction, domain)
350
+
351
+ # Generate template content
352
+ spec_content = self._render_template(
353
+ self.ears_templates['environment'],
354
+ {
355
+ 'project_name': config.get('project_name', f'{domain.capitalize()} System'),
356
+ 'language': extraction['language'],
357
+ 'framework': config.get('framework', self._detect_framework(extraction)),
358
+ 'paradigm': config.get('paradigm', 'Object-Oriented'),
359
+ 'platform': config.get('platform', 'Web/Server'),
360
+ 'deployment': config.get('deployment', 'Cloud-based'),
361
+ 'status': config.get('status', 'Development'),
362
+ **extraction
363
+ }
364
+ )
365
+
366
+ # Add assumptions
367
+ spec_content += "\n\n" + self._render_template(
368
+ self.ears_templates['assumptions'],
369
+ extraction
370
+ )
371
+
372
+ # Add requirements
373
+ spec_content += "\n\n" + self._render_template(
374
+ self.ears_templates['requirements'],
375
+ {
376
+ 'primary_function': primary_function,
377
+ 'state_requirements': state_requirements,
378
+ 'event_requirements': event_requirements,
379
+ **extraction
380
+ }
381
+ )
382
+
383
+ # Add specifications
384
+ spec_content += "\n\n" + self._render_template(
385
+ self.ears_templates['specifications'],
386
+ {
387
+ 'technical_specs': technical_specs,
388
+ **self._generate_technical_details(extraction, domain),
389
+ **extraction
390
+ }
391
+ )
392
+
393
+ # Add traceability
394
+ spec_content += self._generate_traceability(spec_id)
395
+
396
+ # Add edit guide
397
+ spec_content += self._generate_edit_guide(extraction, domain)
398
+
399
+ # Add meta information
400
+ spec_md = f"""---
401
+ "id": "SPEC-{spec_id}",
402
+ "title": "Auto-generated SPEC for {extraction['file_name']}",
403
+ "title_en": "Auto-generated SPEC for {extraction['file_name']}",
404
+ "version": "1.0.0",
405
+ "status": "pending",
406
+ "created": "{time.strftime('%Y-%m-%d')}",
407
+ "author": "@alfred-auto",
408
+ "reviewer": "",
409
+ "category": "FEATURE",
410
+ "priority": "MEDIUM",
411
+ "tags": ["auto-generated", "{spec_id}", "{domain}"],
412
+ "language": "en",
413
+ "estimated_complexity": "{extraction['complexity']}",
414
+ "domain": "{domain}"
415
+ }}
416
+ ---
417
+
418
+ ## Auto-generated SPEC for {extraction['file_name']}
419
+
420
+ ### Overview
421
+
422
+ {domain_info['description']}
423
+
424
+ {spec_content}
425
+ """
426
+
427
+ return spec_md
428
+
429
+ def _render_template(self, template: Dict[str, str], context: Dict[str, Any]) -> str:
430
+ """Render template with context."""
431
+ template_text = template['template']
432
+
433
+ # Replace placeholders
434
+ for key, value in context.items():
435
+ placeholder = f"{{{key}}}"
436
+ template_text = template_text.replace(placeholder, str(value))
437
+
438
+ return template_text
439
+
440
+ def _extract_primary_function(self, extraction: Dict[str, Any], domain: str) -> str:
441
+ """Extract primary function from code analysis."""
442
+ classes = extraction['classes']
443
+ functions = extraction['functions']
444
+
445
+ if classes:
446
+ return f"Manage {classes[0]} class and related operations"
447
+ elif functions:
448
+ return f"Execute {functions[0]} function and related operations"
449
+ else:
450
+ return f"Process data and perform {domain} operations"
451
+
452
+ def _generate_state_requirements(self, extraction: Dict[str, Any], domain: str) -> str:
453
+ """Generate state-based requirements."""
454
+ base_requirements = [
455
+ "- **REQ-006**: System SHALL transition from initial state to target state",
456
+ "- **REQ-007**: State changes SHALL occur only under valid conditions",
457
+ "- **REQ-008**: System SHALL maintain integrity of each state",
458
+ "- **REQ-009**: State changes SHALL be logged and traceable",
459
+ "- **REQ-010**: System SHALL provide recovery mechanism from error state"
460
+ ]
461
+
462
+ domain_specific = {
463
+ 'auth': [
464
+ "- **AUTH-001**: User SHALL be able to transition from unauthenticated to authenticated state",
465
+ "- **AUTH-002**: System SHALL be accessible in authenticated state",
466
+ "- **AUTH-003**: System SHALL automatically transition to unauthenticated state on session expiry"
467
+ ],
468
+ 'api': [
469
+ "- **API-001**: API SHALL have ready, executing, and error states",
470
+ "- **API-002**: System SHALL return appropriate error response in error state",
471
+ "- **API-003**: State changes SHALL be notified as events"
472
+ ],
473
+ 'data': [
474
+ "- **DATA-001**: Data SHALL have create, update, and delete states",
475
+ "- **DATA-002**: Data integrity SHALL be maintained at all times",
476
+ "- **DATA-003**: Data backup state SHALL be monitored"
477
+ ]
478
+ }
479
+
480
+ result = "\n".join(base_requirements)
481
+ if domain in domain_specific:
482
+ result += "\n\n" + "\n".join(domain_specific[domain])
483
+
484
+ return result
485
+
486
+ def _generate_event_requirements(self, extraction: Dict[str, Any], domain: str) -> str:
487
+ """Generate event-based requirements."""
488
+ base_events = [
489
+ "- **EVT-001**: System SHALL respond to user input events",
490
+ "- **EVT-002**: System SHALL handle internal system events",
491
+ "- **EVT-003**: System SHALL receive external service events",
492
+ "- **EVT-004**: Event processing errors SHALL be handled appropriately",
493
+ "- **EVT-005**: Event logs SHALL be maintained"
494
+ ]
495
+
496
+ domain_specific = {
497
+ 'auth': [
498
+ "- **AUTH-EVT-001**: System SHALL handle login events",
499
+ "- **AUTH-EVT-002**: System SHALL handle logout events",
500
+ "- **AUTH-EVT-003**: System SHALL handle password change events"
501
+ ],
502
+ 'api': [
503
+ "- **API-EVT-001**: System SHALL handle API request events",
504
+ "- **API-EVT-002**: System SHALL handle authentication events",
505
+ "- **API-EVT-003**: System SHALL handle rate limit events"
506
+ ],
507
+ 'data': [
508
+ "- **DATA-EVT-001**: System SHALL handle data save events",
509
+ "- **DATA-EVT-002**: System SHALL handle data retrieval events",
510
+ "- **DATA-EVT-003**: System SHALL handle data deletion events"
511
+ ]
512
+ }
513
+
514
+ result = "\n".join(base_events)
515
+ if domain in domain_specific:
516
+ result += "\n\n" + "\n".join(domain_specific[domain])
517
+
518
+ return result
519
+
520
+ def _generate_technical_specs(self, extraction: Dict[str, Any], domain: str) -> str:
521
+ """Generate technical specifications."""
522
+ technical_specs = [
523
+ "#### Core Implementation",
524
+
525
+ f"- **SPEC-001**: {extraction['classes'][0] if extraction['classes'] else 'Main'} class SHALL be implemented",
526
+ f"- **SPEC-002**: {extraction['functions'][0] if extraction['functions'] else 'Core'} function SHALL be implemented",
527
+ "- **SPEC-003**: Input validation SHALL be implemented",
528
+ "- **SPEC-004**: Error handling mechanism SHALL be implemented",
529
+ "- **SPEC-005**: Logging system SHALL be implemented",
530
+
531
+ "#### Extensibility",
532
+ "- **SPEC-006**: Plugin architecture support",
533
+ "- **SPEC-007**: Configuration-based feature enable/disable",
534
+ "- **SPEC-008**: Testable design",
535
+
536
+ "#### Maintainability",
537
+ "- **SPEC-009**: Code documentation",
538
+ "- **SPEC-010**: Unit test coverage",
539
+ "- **SPEC-011**: Code quality validation"
540
+ ]
541
+
542
+ return "\n".join(technical_specs)
543
+
544
+ def _generate_technical_details(self, extraction: Dict[str, Any], domain: str) -> Dict[str, str]:
545
+ """Generate technical details for specifications."""
546
+ return {
547
+ 'technical_details': f"""#### Technical Details
548
+
549
+ - **Architecture**: {extraction['architecture'].title()} Architecture
550
+ - **Complexity**: {extraction['complexity'].title()}
551
+ - **Language**: {extraction['language']}
552
+ - **Module Count**: {len(extraction['classes'])} classes, {len(extraction['functions'])} functions
553
+ - **Dependencies**: {len(extraction['imports'])} external dependencies
554
+
555
+ #### Data Models
556
+
557
+ {self._generate_data_models(extraction, domain)}
558
+
559
+ #### API Specification
560
+
561
+ {self._generate_api_specs(extraction, domain)}
562
+
563
+ #### Interface Specification
564
+
565
+ {self._generate_interface_specs(extraction, domain)}
566
+
567
+ #### Security Specification
568
+
569
+ {self._generate_security_specs(extraction, domain)}
570
+
571
+ #### Performance Specification
572
+
573
+ {self._generate_performance_specs(extraction, domain)}
574
+
575
+ #### Scalability Specification
576
+
577
+ {self._generate_scalability_specs(extraction, domain)}""",
578
+ 'data_models': self._generate_data_models(extraction, domain),
579
+ 'api_specs': self._generate_api_specs(extraction, domain),
580
+ 'interface_specs': self._generate_interface_specs(extraction, domain),
581
+ 'security_specs': self._generate_security_specs(extraction, domain),
582
+ 'performance_specs': self._generate_performance_specs(extraction, domain),
583
+ 'scalability_specs': self._generate_scalability_specs(extraction, domain)
584
+ }
585
+
586
+ def _generate_data_models(self, extraction: Dict[str, Any], domain: str) -> str:
587
+ """Generate data models section."""
588
+ if extraction['classes']:
589
+ models = []
590
+ for class_name in extraction['classes'][:3]: # Limit to 3 models
591
+ models.append(f"""
592
+ **{class_name}**:
593
+ - Attributes: ID, created_at, status
594
+ - Methods: create, update, delete, retrieve
595
+ - Relations: Relationships with other models""")
596
+ return "\n".join(models)
597
+ else:
598
+ return "Data models are not explicitly defined."
599
+
600
+ def _generate_api_specs(self, extraction: Dict[str, Any], domain: str) -> str:
601
+ """Generate API specifications."""
602
+ if domain in ['api', 'auth']:
603
+ return """
604
+ **RESTful API Endpoints**:
605
+ - `GET /api/{resource}`: Retrieve resource list
606
+ - `POST /api/{resource}`: Create resource
607
+ - `PUT /api/{resource}/{id}`: Update resource
608
+ - `DELETE /api/{resource}/{id}`: Delete resource
609
+ - `GET /api/{resource}/{id}`: Retrieve specific resource
610
+
611
+ **Response Format**:
612
+ - Success: `200 OK` + JSON data
613
+ - Failure: `400 Bad Request`, `404 Not Found`, `500 Internal Server Error`"""
614
+ else:
615
+ return "API specification not applicable to this domain."
616
+
617
+ def _generate_interface_specs(self, extraction: Dict[str, Any], domain: str) -> str:
618
+ """Generate interface specifications."""
619
+ if domain in ['ui', 'api']:
620
+ return """
621
+ **User Interface**:
622
+ - Web Interface: Responsive design
623
+ - Mobile Interface: Cross-platform compatible
624
+ - API Interface: RESTful API
625
+
626
+ **Interaction Patterns**:
627
+ - User input handling
628
+ - Real-time updates
629
+ - Error state handling"""
630
+ else:
631
+ return "Interface specification not applicable to this domain."
632
+
633
+ def _generate_security_specs(self, extraction: Dict[str, Any], domain: str) -> str:
634
+ """Generate security specifications."""
635
+ if domain in ['auth', 'api']:
636
+ return """
637
+ **Security Requirements**:
638
+ - Authentication and authorization
639
+ - Data encryption
640
+ - Input validation
641
+ - Access control
642
+ - Logging and monitoring
643
+
644
+ **Security Measures**:
645
+ - Password hashing
646
+ - Session management
647
+ - CSRF prevention
648
+ - XSS prevention
649
+ - SQL injection prevention"""
650
+ else:
651
+ return "Security specifications apply by default."
652
+
653
+ def _generate_performance_specs(self, extraction: Dict[str, Any], domain: str) -> str:
654
+ """Generate performance specifications."""
655
+ return """
656
+ **Performance Requirements**:
657
+ - Response time: Within 1 second
658
+ - Concurrent processing: Maximum 1000 requests/second
659
+ - Memory usage: Maximum 512MB
660
+ - Throughput: 99.9% availability
661
+
662
+ **Performance Monitoring**:
663
+ - Response time monitoring
664
+ - Resource usage monitoring
665
+ - Error rate monitoring"""
666
+
667
+ def _generate_scalability_specs(self, extraction: Dict[str, Any], domain: str) -> str:
668
+ """Generate scalability specifications."""
669
+ return """
670
+ **Scalability Requirements**:
671
+ - Horizontal scaling support
672
+ - Load balancing
673
+ - Caching strategy
674
+ - Database sharding
675
+
676
+ **Scalability Plan**:
677
+ - Microservice architecture
678
+ - Containerization
679
+ - Orchestration
680
+ - CDN integration"""
681
+
682
+ def _generate_traceability(self, spec_id: str) -> str:
683
+ """Generate traceability section."""
684
+ return """
685
+
686
+ ### Traceability
687
+
688
+ **Requirements Traceability Matrix:**
689
+ - Functional requirements → Design specifications → Test cases
690
+ - Non-functional requirements → Architecture decisions → Validation tests
691
+ - Business requirements → User stories → Acceptance criteria
692
+
693
+ **Implementation Traceability:**
694
+ - Design specifications → Code modules → Unit tests
695
+ - API specifications → Endpoints → Integration tests
696
+ - Database design → Schemas → Data validation tests
697
+
698
+ **Change Management:**
699
+ - All changes tracked with timestamps
700
+ - Impact analysis documented
701
+ - Stakeholder approvals recorded"""
702
+
703
+
704
+ def _generate_edit_guide(self, extraction: Dict[str, Any], domain: str) -> str:
705
+ """Generate edit guide section."""
706
+ return f"""
707
+
708
+ ### Edit Guide
709
+
710
+ **User Review Checklist:**
711
+ 1. [OK] Verify technical clarity
712
+ 2. [OK] Specify requirements in detail
713
+ 3. [OK] Review domain terminology
714
+ 4. [OK] Define state and event requirements
715
+ 5. [OK] Detail specifications
716
+
717
+ **Quality Improvement Suggestions:**
718
+ - Add domain-specific terminology
719
+ - Specify user cases in detail
720
+ - Define performance requirements
721
+ - Add security requirements
722
+
723
+ **Domain-Specific Review:**
724
+ - **{domain.upper()}**: {self._get_domain_specific_review(domain)}"""
725
+
726
+ def _get_domain_specific_review(self, domain: str) -> str:
727
+ """Get domain-specific review guidance."""
728
+ domain_reviews = {
729
+ 'auth': 'Review security requirements, verify authentication flow, review session management',
730
+ 'api': 'Review API design, review error handling, review performance',
731
+ 'data': 'Review data integrity, review backup and restore',
732
+ 'ui': 'Review user experience, review accessibility, review performance',
733
+ 'business': 'Review business rules, review compliance'
734
+ }
735
+ return domain_reviews.get(domain, 'Review general requirements')
736
+
737
+ def _generate_plan_content(self, extraction: Dict[str, Any], domain: str,
738
+ spec_id: str, custom_config: Dict[str, Any] = None) -> str:
739
+ """Generate plan.md content."""
740
+ config = custom_config or {}
741
+
742
+ # Generate implementation plan based on complexity and domain
743
+ plan_content = f"""---
744
+ id: "PLAN-{spec_id}"
745
+ spec_id: "SPEC-{spec_id}"
746
+ title: "Auto-generated Implementation Plan for {extraction['file_name']}"
747
+ version: "1.0.0"
748
+ status: "pending"
749
+ created: "{time.strftime('%Y-%m-%d')}"
750
+ author: "@alfred-auto"
751
+ domain: "{domain}"
752
+ ---
753
+ ## Auto-generated Implementation Plan for {extraction['file_name']}
754
+
755
+ ### Implementation Phases
756
+
757
+ #### Phase 1: Requirements Analysis (Priority: High)
758
+
759
+ - [ ] Detail functional requirements
760
+ - [ ] Define non-functional requirements
761
+ - [ ] Set performance requirements
762
+ - [ ] Define security requirements
763
+ - [ ] Write user stories
764
+
765
+ #### Phase 2: Design (Priority: High)
766
+
767
+ - [ ] Complete architecture design
768
+ - [ ] Design data models
769
+ - [ ] Complete API design
770
+ - [ ] Design interfaces
771
+ - [ ] Design database schema
772
+
773
+ #### Phase 3: Development (Priority: Medium)
774
+
775
+ - [ ] Develop core modules
776
+ - [ ] Complete API development
777
+ - [ ] Develop interfaces
778
+ - [ ] Integrate database
779
+ - [ ] Implement security features
780
+
781
+ #### Phase 4: Testing (Priority: High)
782
+
783
+ - [ ] Implement unit tests
784
+ - [ ] Implement integration tests
785
+ - [ ] Implement system tests
786
+ - [ ] Performance testing
787
+ - [ ] Security testing
788
+
789
+ #### Phase 5: Deployment (Priority: Medium)
790
+
791
+ - [ ] Deploy to staging environment
792
+ - [ ] Implement deployment automation
793
+ - [ ] Configure monitoring
794
+ - [ ] Complete documentation
795
+ - [ ] Write operational guide
796
+
797
+ ### Technical Approach
798
+
799
+ #### Architecture Design
800
+
801
+ ```
802
+ {self._generate_architecture_diagram(extraction, domain)}
803
+ ```
804
+
805
+ #### Core Components
806
+
807
+ 1. **{self._get_main_component(extraction, domain)}**: Main business logic processing
808
+ 2. **{self._get_service_component(extraction, domain)}**: External service integration
809
+ 3. **{self._get_data_component(extraction, domain)}**: Data processing and storage
810
+ 4. **{self._get_component_4(extraction, domain)}**: Validation and processing layer
811
+
812
+ #### Dependency Management
813
+
814
+ **Utilize Existing Modules:**
815
+ - Utilize standard libraries
816
+ - Utilize existing infrastructure
817
+
818
+ **Add New Modules:**
819
+ - {self._get_new_modules(extraction, domain)}
820
+
821
+ ### Success Criteria
822
+
823
+ #### Functional Criteria
824
+
825
+ - ✅ All requirements implemented
826
+ - ✅ Test coverage above 85%
827
+ - ✅ Performance goals met
828
+ - ✅ User requirements satisfied
829
+
830
+ #### Performance Criteria
831
+
832
+ - ✅ Response time within 1 second
833
+ - ✅ Memory usage optimized
834
+ - ✅ Parallel processing supported
835
+ - ✅ Scalability verified
836
+
837
+ #### Quality Criteria
838
+
839
+ - ✅ Code quality validation passed
840
+ - ✅ Security scanning passed
841
+ - ✅ Documentation completeness verified
842
+ - ✅ Maintainability verified
843
+
844
+ ### Next Steps
845
+
846
+ 1. **Immediate**: Requirements analysis (1-2 days)
847
+ 2. **Weekly Goal**: Complete design (3-5 days)
848
+ 3. **2-Week Goal**: Complete development (7-14 days)
849
+ 4. **Deployment Prep**: Testing and verification (14-16 days)
850
+ """
851
+
852
+ return plan_content
853
+
854
+ def _generate_architecture_diagram(self, extraction: Dict[str, Any], domain: str) -> str:
855
+ """Generate architecture diagram."""
856
+ if domain == 'auth':
857
+ return """
858
+ Client → [API Gateway] → [Auth Service] → [Database]
859
+ ↑ ↓ ↓
860
+ [UI Layer] [Log Service] [Cache]
861
+ """
862
+ elif domain == 'api':
863
+ return """
864
+ Client → [Load Balancer] → [API Gateway] → [Service 1]
865
+
866
+ [Service 2]
867
+
868
+ [Database]
869
+ """
870
+ elif domain == 'data':
871
+ return """
872
+ [Application] → [Data Service] → [Database]
873
+ ↑ ↓
874
+ [Cache Layer] [Analytics]
875
+ """
876
+ else:
877
+ return """
878
+ [Client] → [Service] → [Database]
879
+ ↑ ↓
880
+ [UI] [Cache]
881
+ """
882
+
883
+ def _get_main_component(self, extraction: Dict[str, Any], domain: str) -> str:
884
+ """Get main component name."""
885
+ components = {
886
+ 'auth': 'AuthService',
887
+ 'api': 'APIController',
888
+ 'data': 'DataService',
889
+ 'ui': 'UIController',
890
+ 'business': 'BusinessLogic'
891
+ }
892
+ return components.get(domain, 'MainComponent')
893
+
894
+ def _get_service_component(self, extraction: Dict[str, Any], domain: str) -> str:
895
+ """Get service component name."""
896
+ components = {
897
+ 'auth': 'UserService',
898
+ 'api': 'ExternalService',
899
+ 'data': 'PersistenceService',
900
+ 'ui': 'ClientService',
901
+ 'business': 'WorkflowService'
902
+ }
903
+ return components.get(domain, 'ServiceComponent')
904
+
905
+ def _get_data_component(self, extraction: Dict[str, Any], domain: str) -> str:
906
+ """Get data component name."""
907
+ components = {
908
+ 'auth': 'UserRepository',
909
+ 'api': 'DataRepository',
910
+ 'data': 'DataAccessLayer',
911
+ 'ui': 'StateManagement',
912
+ 'business': 'DataProcessor'
913
+ }
914
+ return components.get(domain, 'DataComponent')
915
+
916
+ def _get_component_4(self, extraction: Dict[str, Any], domain: str) -> str:
917
+ """Get fourth component name."""
918
+ components = {
919
+ 'auth': 'SecurityManager',
920
+ 'api': 'RateLimiter',
921
+ 'data': 'DataValidator',
922
+ 'ui': 'FormValidator',
923
+ 'business': 'RuleEngine'
924
+ }
925
+ return components.get(domain, 'ValidationComponent')
926
+
927
+ def _get_new_modules(self, extraction: Dict[str, Any], domain: str) -> str:
928
+ """Get new modules to be added."""
929
+ modules = {
930
+ 'auth': 'Authentication module, Security module, Session management module',
931
+ 'api': 'Routing module, Middleware module, Authentication module',
932
+ 'data': 'Database module, Cache module, Backup module',
933
+ 'ui': 'Component library, State management module',
934
+ 'business': 'Business rules module, Workflow module'
935
+ }
936
+ return modules.get(domain, 'Standard modules')
937
+
938
+ def _generate_acceptance_content(self, extraction: Dict[str, Any], domain: str,
939
+ spec_id: str, custom_config: Dict[str, Any] = None) -> str:
940
+ """Generate acceptance.md content."""
941
+ config = custom_config or {}
942
+
943
+ acceptance_content = f"""---
944
+ "id": "ACCEPT-{spec_id}",
945
+ "spec_id": "SPEC-{spec_id}",
946
+ "title": "Auto-generated Acceptance Criteria for {extraction['file_name']}",
947
+ "version": "1.0.0",
948
+ "status": "pending",
949
+ "created": "{time.strftime('%Y-%m-%d')}",
950
+ "author": "@alfred-auto",
951
+ "domain": "{domain}"
952
+ }}
953
+ ---
954
+
955
+ ## Auto-generated Acceptance Criteria for {extraction['file_name']}
956
+
957
+ ### Acceptance Criteria
958
+
959
+ #### Basic Functionality
960
+
961
+ **Must-have:**
962
+ - [ ] System SHALL operate normally
963
+ - [ ] User interface SHALL display correctly
964
+ - [ ] Data processing logic SHALL operate correctly
965
+ - [ ] Error situations SHALL be handled appropriately
966
+ - [ ] Logging SHALL operate correctly
967
+
968
+ **Should-have:**
969
+ - [ ] User experience SHALL be smooth
970
+ - [ ] Performance goals SHALL be met
971
+ - [ ] Security requirements SHALL be met
972
+ - [ ] Accessibility standards SHALL be complied with
973
+
974
+ #### {domain.upper()} Domain Specific
975
+
976
+ {self._generate_domain_specific_acceptance(domain)}
977
+
978
+ #### Performance Testing
979
+
980
+ **Performance Requirements:**
981
+ - [ ] Response time: Within 1 second
982
+ - [ ] Concurrent users: Support 100+ users
983
+ - [ ] Memory usage: Under 100MB
984
+ - [ ] CPU usage: Under 50%
985
+
986
+ **Load Testing:**
987
+ - [ ] Pass functional load tests
988
+ - [ ] Pass long-term stability tests
989
+ - [ ] Pass recovery tests
990
+
991
+ #### Security Testing
992
+
993
+ **Security Requirements:**
994
+ - [ ] Pass authentication and authorization validation
995
+ - [ ] Pass input validation
996
+ - [ ] Pass SQL injection defense
997
+ - [ ] Pass CSRF defense
998
+ - [ ] Pass XSS defense
999
+
1000
+ **Vulnerability Testing:**
1001
+ - [ ] Pass OWASP Top 10 checks
1002
+ - [ ] Pass security scanning
1003
+ - [ ] Pass permission configuration validation
1004
+
1005
+ ### Validation Process
1006
+
1007
+ #### Phase 1: Unit Tests
1008
+
1009
+ - [ ] Complete developer testing
1010
+ - [ ] Pass code review
1011
+ - [ ] Pass automated testing
1012
+ - [ ] Code coverage above 85%
1013
+
1014
+ #### Phase 2: Integration Tests
1015
+
1016
+ - [ ] Inter-module integration testing
1017
+ - [ ] API integration testing
1018
+ - [ ] Database integration testing
1019
+ - [ ] External service integration testing
1020
+
1021
+ #### Phase 3: System Tests
1022
+
1023
+ - [ ] Full system functionality testing
1024
+ - [ ] Performance testing
1025
+ - [ ] Security testing
1026
+ - [ ] Stability testing
1027
+
1028
+ #### Phase 4: User Tests
1029
+
1030
+ - [ ] Internal user testing
1031
+ - [ ] Actual user testing
1032
+ - [ ] Feedback collection and incorporation
1033
+ - [ ] Final validation approval
1034
+
1035
+ ### Validation Templates
1036
+
1037
+ #### Functional Validation Template
1038
+
1039
+ | Function ID | Function Name | Expected Result | Actual Result | Status | Notes |
1040
+ |-------------|---------------|-----------------|---------------|--------|-------|
1041
+ | FUNC-001 | Feature 1 | Success | Testing | In Progress | Description |
1042
+ | FUNC-002 | Feature 2 | Success | Success | Passed | Description |
1043
+ | FUNC-003 | Feature 3 | Success | Failed | Failed | Description |
1044
+
1045
+ #### Performance Validation Template
1046
+
1047
+ | Test Item | Target | Measured | Status | Notes |
1048
+ |-----------|--------|----------|--------|-------|
1049
+ | Response Time | 1 sec | 0.8 sec | Passed | Description |
1050
+ | Memory Usage | 100MB | 85MB | Passed | Description |
1051
+ | CPU Usage | 50% | 45% | Passed | Description |
1052
+
1053
+ ### Completion Criteria
1054
+
1055
+ #### Pass Criteria
1056
+
1057
+ - ✅ All essential functionality validation passed
1058
+ - ✅ Performance requirements met
1059
+ - ✅ Security testing passed
1060
+ - ✅ User validation passed
1061
+ - ✅ Documentation validation completed
1062
+
1063
+ #### Reporting
1064
+
1065
+ - [ ] Write validation report
1066
+ - [ ] Organize discovered issues list
1067
+ - [ ] Define improvements
1068
+ - [ ] Write validation approval document
1069
+
1070
+ **Validation Team:**
1071
+ - Developer: @developer
1072
+ - QA: @qa_engineer
1073
+ - Product Owner: @product_owner
1074
+ - Final Validator: @stakeholder
1075
+ """
1076
+
1077
+ return acceptance_content
1078
+
1079
+ def _generate_domain_specific_acceptance(self, domain: str) -> str:
1080
+ """Generate domain-specific acceptance criteria."""
1081
+ domain_criteria = {
1082
+ 'auth': """
1083
+ - **AUTH-001**: User login functionality validation
1084
+ - SHALL allow login with user ID and password
1085
+ - SHALL issue session token on success
1086
+ - SHALL display appropriate error message on failure
1087
+ - **AUTH-002**: User registration functionality validation
1088
+ - SHALL allow new user registration
1089
+ - SHALL check for duplicate IDs correctly
1090
+ - MAY require email verification
1091
+ - **AUTH-003**: Password change functionality validation
1092
+ - SHALL allow password change after verification
1093
+ - SHALL validate password complexity
1094
+ - SHALL send notification on change""",
1095
+ 'api': """
1096
+ - **API-001**: REST API functionality validation
1097
+ - SHALL operate CRUD operations correctly
1098
+ - SHALL return correct HTTP status codes
1099
+ - SHALL manage API versioning
1100
+ - **API-002**: Authentication functionality validation
1101
+ - SHALL operate API key-based authentication
1102
+ - SHALL process JWT tokens correctly
1103
+ - SHALL implement permission-level access control
1104
+ - **API-003**: Rate limiting functionality validation
1105
+ - SHALL operate request limits correctly
1106
+ - SHALL return appropriate errors when limit exceeded""",
1107
+ 'data': """
1108
+ - **DATA-001**: Data storage functionality validation
1109
+ - SHALL store data correctly
1110
+ - SHALL maintain data integrity
1111
+ - SHALL provide backup and restore functionality
1112
+ - **DATA-002**: Data retrieval functionality validation
1113
+ - SHALL retrieve data accurately
1114
+ - SHALL meet query performance goals
1115
+ - SHALL operate indexing correctly
1116
+ - **DATA-003**: Data management functionality validation
1117
+ - SHALL allow data modification
1118
+ - SHALL handle data deletion safely
1119
+ - MAY require data migration functionality"""
1120
+ }
1121
+ return domain_criteria.get(domain, "")
1122
+
1123
+ def _validate_ears_compliance(self, spec_content: Dict[str, str]) -> Dict[str, Any]:
1124
+ """Validate EARS format compliance."""
1125
+ spec_md = spec_content.get('spec_md', '')
1126
+
1127
+ # Check for required sections
1128
+ required_sections = [
1129
+ 'Overview',
1130
+ 'Environment',
1131
+ 'Assumptions',
1132
+ 'Requirements',
1133
+ 'Specifications',
1134
+ 'Traceability'
1135
+ ]
1136
+
1137
+ section_scores = {}
1138
+ for section in required_sections:
1139
+ if section in spec_md:
1140
+ section_scores[section] = 1.0
1141
+ else:
1142
+ section_scores[section] = 0.0
1143
+
1144
+ # Calculate overall compliance
1145
+ overall_compliance = sum(section_scores.values()) / len(required_sections)
1146
+
1147
+ # Generate suggestions
1148
+ suggestions = []
1149
+ for section, score in section_scores.items():
1150
+ if score < 1.0:
1151
+ suggestions.append(f"Required: {section} section must be included")
1152
+
1153
+ return {
1154
+ 'ears_compliance': round(overall_compliance, 2),
1155
+ 'section_scores': section_scores,
1156
+ 'suggestions': suggestions[:5], # Top 5 suggestions
1157
+ 'total_sections': len(required_sections),
1158
+ 'present_sections': sum(1 for score in section_scores.values() if score > 0)
1159
+ }
1160
+
1161
+ def _detect_framework(self, extraction: Dict[str, Any]) -> str:
1162
+ """Detect framework from imports."""
1163
+ imports = extraction['imports']
1164
+
1165
+ framework_indicators = {
1166
+ 'Django': ['django'],
1167
+ 'Flask': ['flask'],
1168
+ 'FastAPI': ['fastapi'],
1169
+ 'Spring': ['spring'],
1170
+ 'Express': ['express'],
1171
+ 'React': ['react'],
1172
+ 'Angular': ['angular'],
1173
+ 'Vue': ['vue'],
1174
+ 'Next.js': ['next']
1175
+ }
1176
+
1177
+ for framework, indicators in framework_indicators.items():
1178
+ for imp in imports:
1179
+ if any(indicator in imp.lower() for indicator in indicators):
1180
+ return framework
1181
+
1182
+ return 'Custom'