moai-adk 0.4.5__py3-none-any.whl → 0.20.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of moai-adk might be problematic. Click here for more details.
- moai_adk/__init__.py +1 -1
- moai_adk/__main__.py +74 -1
- moai_adk/cli/commands/__init__.py +1 -1
- moai_adk/cli/commands/analyze.py +119 -0
- moai_adk/cli/commands/backup.py +25 -1
- moai_adk/cli/commands/doctor.py +31 -5
- moai_adk/cli/commands/improve_user_experience.py +307 -0
- moai_adk/cli/commands/init.py +111 -10
- moai_adk/cli/commands/status.py +33 -3
- moai_adk/cli/commands/update.py +921 -130
- moai_adk/cli/commands/validate_links.py +120 -0
- moai_adk/cli/prompts/init_prompts.py +22 -87
- moai_adk/core/analysis/__init__.py +9 -0
- moai_adk/core/analysis/session_analyzer.py +388 -0
- moai_adk/core/analysis/tag_chain_analyzer.py +344 -0
- moai_adk/core/analysis/tag_chain_repair.py +879 -0
- moai_adk/core/config/__init__.py +19 -0
- moai_adk/core/config/migration.py +235 -0
- moai_adk/core/git/__init__.py +1 -1
- moai_adk/core/git/branch.py +1 -1
- moai_adk/core/git/commit.py +1 -1
- moai_adk/core/git/manager.py +1 -1
- moai_adk/core/issue_creator.py +313 -0
- moai_adk/core/mcp/setup.py +56 -0
- moai_adk/core/mcp/setup_old.py +296 -0
- moai_adk/core/project/backup_utils.py +1 -1
- moai_adk/core/project/checker.py +2 -2
- moai_adk/core/project/detector.py +211 -12
- moai_adk/core/project/initializer.py +85 -15
- moai_adk/core/project/phase_executor.py +76 -13
- moai_adk/core/project/validator.py +13 -13
- moai_adk/core/quality/__init__.py +1 -1
- moai_adk/core/quality/trust_checker.py +1 -1
- moai_adk/core/quality/validators/__init__.py +1 -1
- moai_adk/core/quality/validators/base_validator.py +1 -1
- moai_adk/core/tags/__init__.py +86 -0
- moai_adk/core/tags/auto_corrector.py +693 -0
- moai_adk/core/tags/ci_validator.py +463 -0
- moai_adk/core/tags/cli.py +283 -0
- moai_adk/core/tags/generator.py +109 -0
- moai_adk/core/tags/inserter.py +99 -0
- moai_adk/core/tags/mapper.py +126 -0
- moai_adk/core/tags/parser.py +76 -0
- moai_adk/core/tags/policy_validator.py +580 -0
- moai_adk/core/tags/pre_commit_validator.py +421 -0
- moai_adk/core/tags/reporter.py +956 -0
- moai_adk/core/tags/rollback_manager.py +525 -0
- moai_adk/core/tags/tags.py +149 -0
- moai_adk/core/tags/validator.py +897 -0
- moai_adk/core/template/__init__.py +1 -1
- moai_adk/core/template/backup.py +1 -1
- moai_adk/core/template/merger.py +50 -1
- moai_adk/core/template/processor.py +119 -13
- moai_adk/core/template_engine.py +268 -0
- moai_adk/templates/.claude/agents/alfred/backend-expert.md +348 -0
- moai_adk/templates/.claude/agents/alfred/cc-manager.md +209 -944
- moai_adk/templates/.claude/agents/alfred/database-expert.md +352 -0
- moai_adk/templates/.claude/agents/alfred/debug-helper.md +34 -5
- moai_adk/templates/.claude/agents/alfred/devops-expert.md +464 -0
- moai_adk/templates/.claude/agents/alfred/doc-syncer.md +38 -8
- moai_adk/templates/.claude/agents/alfred/format-expert.md +469 -0
- moai_adk/templates/.claude/agents/alfred/frontend-expert.md +357 -0
- moai_adk/templates/.claude/agents/alfred/git-manager.md +128 -9
- moai_adk/templates/.claude/agents/alfred/implementation-planner.md +104 -6
- moai_adk/templates/.claude/agents/alfred/project-manager.md +88 -16
- moai_adk/templates/.claude/agents/alfred/quality-gate.md +36 -9
- moai_adk/templates/.claude/agents/alfred/security-expert.md +270 -0
- moai_adk/templates/.claude/agents/alfred/skill-factory.md +865 -0
- moai_adk/templates/.claude/agents/alfred/spec-builder.md +214 -43
- moai_adk/templates/.claude/agents/alfred/tag-agent.md +111 -9
- moai_adk/templates/.claude/agents/alfred/tdd-implementer.md +309 -160
- moai_adk/templates/.claude/agents/alfred/trust-checker.md +36 -7
- moai_adk/templates/.claude/agents/alfred/ui-ux-expert.md +605 -0
- moai_adk/templates/.claude/commands/alfred/0-project.md +393 -966
- moai_adk/templates/.claude/commands/alfred/1-plan.md +651 -367
- moai_adk/templates/.claude/commands/alfred/2-run.md +388 -241
- moai_adk/templates/.claude/commands/alfred/3-sync.md +1921 -410
- moai_adk/templates/.claude/commands/alfred/9-feedback.md +153 -0
- moai_adk/templates/.claude/commands/alfred/release-new.md +3604 -0
- moai_adk/templates/.claude/hooks/alfred/core/project.py +484 -20
- moai_adk/templates/.claude/hooks/alfred/core/timeout.py +136 -0
- moai_adk/templates/.claude/hooks/alfred/core/ttl_cache.py +108 -0
- moai_adk/templates/.claude/hooks/alfred/core/version_cache.py +198 -0
- moai_adk/templates/.claude/hooks/alfred/handlers/__init__.py +14 -6
- moai_adk/templates/.claude/hooks/alfred/post_tool__enable_streaming_ui.py +50 -0
- moai_adk/templates/.claude/hooks/alfred/post_tool__log_changes.py +93 -0
- moai_adk/templates/.claude/hooks/alfred/post_tool__tag_auto_corrector.py +407 -0
- moai_adk/templates/.claude/hooks/alfred/pre_tool__auto_checkpoint.py +99 -0
- moai_adk/templates/.claude/hooks/alfred/pre_tool__realtime_tag_monitor.py +335 -0
- moai_adk/templates/.claude/hooks/alfred/pre_tool__tag_policy_validator.py +325 -0
- moai_adk/templates/.claude/hooks/alfred/session_end__cleanup.py +93 -0
- moai_adk/templates/.claude/hooks/alfred/session_start__auto_cleanup.py +580 -0
- moai_adk/templates/.claude/hooks/alfred/session_start__show_project_info.py +298 -0
- moai_adk/templates/.claude/hooks/alfred/shared/core/__init__.py +170 -0
- moai_adk/templates/.claude/hooks/alfred/{core → shared/core}/checkpoint.py +3 -3
- moai_adk/templates/.claude/hooks/alfred/{core → shared/core}/context.py +5 -5
- moai_adk/templates/.claude/hooks/alfred/shared/core/project.py +749 -0
- moai_adk/templates/.claude/hooks/alfred/shared/core/tags.py +230 -0
- moai_adk/templates/.claude/hooks/alfred/shared/core/version_cache.py +198 -0
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/__init__.py +21 -0
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/daily_analysis.py +351 -0
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/notification.py +154 -0
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/session.py +174 -0
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/tool.py +87 -0
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/user.py +61 -0
- moai_adk/templates/.claude/hooks/alfred/user_prompt__jit_load_docs.py +111 -0
- moai_adk/templates/.claude/hooks/alfred/utils/__init__.py +1 -0
- moai_adk/templates/.claude/hooks/alfred/utils/hook_config.py +94 -0
- moai_adk/templates/.claude/hooks/alfred/utils/timeout.py +161 -0
- moai_adk/templates/.claude/output-styles/alfred/alfred-moai-adk-beginner.md +267 -0
- moai_adk/templates/.claude/output-styles/alfred/keating-personal-tutor.md +440 -0
- moai_adk/templates/.claude/output-styles/alfred/r2d2-agentic-coding.md +583 -0
- moai_adk/templates/.claude/settings.json +96 -14
- moai_adk/templates/.claude/skills/moai-alfred-agent-guide/SKILL.md +70 -0
- moai_adk/templates/.claude/skills/moai-alfred-agent-guide/examples.md +62 -0
- moai_adk/templates/.claude/skills/moai-alfred-agent-guide/reference.md +242 -0
- moai_adk/templates/.claude/skills/moai-alfred-ask-user-questions/SKILL.md +237 -0
- moai_adk/templates/.claude/skills/moai-alfred-ask-user-questions/examples.md +871 -0
- moai_adk/templates/.claude/skills/moai-alfred-ask-user-questions/reference.md +653 -0
- moai_adk/templates/.claude/skills/moai-alfred-clone-pattern/README.md +162 -0
- moai_adk/templates/.claude/skills/moai-alfred-clone-pattern/SKILL.md +227 -0
- moai_adk/templates/.claude/skills/moai-alfred-clone-pattern/examples.md +354 -0
- moai_adk/templates/.claude/skills/moai-alfred-clone-pattern/reference.md +158 -0
- moai_adk/templates/.claude/skills/moai-alfred-code-reviewer/SKILL.md +179 -79
- moai_adk/templates/.claude/skills/moai-alfred-code-reviewer/examples.md +117 -0
- moai_adk/templates/.claude/skills/moai-alfred-code-reviewer/scripts/pre-review-check.sh +62 -0
- moai_adk/templates/.claude/skills/moai-alfred-config-schema/SKILL.md +132 -0
- moai_adk/templates/.claude/skills/moai-alfred-config-schema/examples.md +28 -0
- moai_adk/templates/.claude/skills/moai-alfred-config-schema/reference.md +444 -0
- moai_adk/templates/.claude/skills/moai-alfred-context-budget/SKILL.md +62 -0
- moai_adk/templates/.claude/skills/moai-alfred-context-budget/examples.md +28 -0
- moai_adk/templates/.claude/skills/moai-alfred-context-budget/reference.md +405 -0
- moai_adk/templates/.claude/skills/moai-alfred-dev-guide/SKILL.md +51 -0
- moai_adk/templates/.claude/skills/moai-alfred-dev-guide/examples.md +355 -0
- moai_adk/templates/.claude/skills/moai-alfred-dev-guide/reference.md +239 -0
- moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/SKILL.md +323 -0
- moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/examples.md +286 -0
- moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/reference.md +126 -0
- moai_adk/templates/.claude/skills/moai-alfred-issue-labels/SKILL.md +229 -0
- moai_adk/templates/.claude/skills/moai-alfred-issue-labels/examples.md +4 -0
- moai_adk/templates/.claude/skills/moai-alfred-issue-labels/reference.md +150 -0
- moai_adk/templates/.claude/skills/moai-alfred-language-detection/SKILL.md +87 -73
- moai_adk/templates/.claude/skills/moai-alfred-language-detection/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-alfred-language-detection/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-alfred-personas/README.md +42 -0
- moai_adk/templates/.claude/skills/moai-alfred-personas/SKILL.md +429 -0
- moai_adk/templates/.claude/skills/moai-alfred-personas/examples.md +520 -0
- moai_adk/templates/.claude/skills/moai-alfred-personas/reference.md +405 -0
- moai_adk/templates/.claude/skills/moai-alfred-practices/SKILL.md +89 -0
- moai_adk/templates/.claude/skills/moai-alfred-practices/examples.md +122 -0
- moai_adk/templates/.claude/skills/moai-alfred-practices/reference.md +369 -0
- moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/SKILL.md +508 -0
- moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/examples.md +481 -0
- moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/reference.md +100 -0
- moai_adk/templates/.claude/skills/moai-alfred-rules/SKILL.md +77 -0
- moai_adk/templates/.claude/skills/moai-alfred-rules/examples.md +265 -0
- moai_adk/templates/.claude/skills/moai-alfred-rules/reference.md +539 -0
- moai_adk/templates/.claude/skills/moai-alfred-session-state/SKILL.md +320 -0
- moai_adk/templates/.claude/skills/moai-alfred-session-state/examples.md +4 -0
- moai_adk/templates/.claude/skills/moai-alfred-session-state/reference.md +84 -0
- moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/README.md +137 -0
- moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/SKILL.md +219 -0
- moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/examples/validate-spec.sh +161 -0
- moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/examples.md +541 -0
- moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/reference.md +622 -0
- moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/SKILL.md +19 -0
- moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/examples.md +4 -0
- moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/reference.md +211 -0
- moai_adk/templates/.claude/skills/moai-alfred-workflow/SKILL.md +288 -0
- moai_adk/templates/.claude/skills/moai-cc-agents/SKILL.md +269 -0
- moai_adk/templates/.claude/skills/moai-cc-agents/templates/agent-template.md +32 -0
- moai_adk/templates/.claude/skills/moai-cc-claude-md/SKILL.md +298 -0
- moai_adk/templates/.claude/skills/moai-cc-claude-md/templates/CLAUDE-template.md +26 -0
- moai_adk/templates/.claude/skills/moai-cc-commands/SKILL.md +307 -0
- moai_adk/templates/.claude/skills/moai-cc-commands/templates/command-template.md +21 -0
- moai_adk/templates/.claude/skills/moai-cc-hooks/SKILL.md +252 -0
- moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/pre-bash-check.sh +19 -0
- moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/preserve-permissions.sh +19 -0
- moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/validate-bash-command.py +24 -0
- moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/SKILL.md +199 -0
- moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/templates/settings-mcp-template.json +39 -0
- moai_adk/templates/.claude/skills/moai-cc-memory/SKILL.md +316 -0
- moai_adk/templates/.claude/skills/moai-cc-memory/templates/session-summary-template.md +18 -0
- moai_adk/templates/.claude/skills/moai-cc-settings/SKILL.md +263 -0
- moai_adk/templates/.claude/skills/moai-cc-settings/templates/settings-complete-template.json +30 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/CHECKLIST.md +482 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/EXAMPLES.md +303 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/INTERACTIVE-DISCOVERY.md +524 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/METADATA.md +477 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/PARALLEL-ANALYSIS-REPORT.md +429 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/PYTHON-VERSION-MATRIX.md +391 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/SKILL-FACTORY-WORKFLOW.md +431 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/SKILL-UPDATE-ADVISOR.md +577 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/SKILL.md +273 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/STEP-BY-STEP-GUIDE.md +466 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/STRUCTURE.md +583 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/WEB-RESEARCH.md +526 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/reference.md +608 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/scripts/generate-structure.sh +328 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/scripts/validate-skill.sh +312 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/SKILL_TEMPLATE.md +245 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/examples-template.md +285 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/reference-template.md +278 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/scripts-template.sh +303 -0
- moai_adk/templates/.claude/skills/moai-cc-skills/SKILL.md +291 -0
- moai_adk/templates/.claude/skills/moai-cc-skills/templates/SKILL-template.md +15 -0
- moai_adk/templates/.claude/skills/moai-change-logger/SKILL.md +563 -0
- moai_adk/templates/.claude/skills/moai-design-systems/SKILL.md +802 -0
- moai_adk/templates/.claude/skills/moai-design-systems/examples.md +1238 -0
- moai_adk/templates/.claude/skills/moai-design-systems/reference.md +673 -0
- moai_adk/templates/.claude/skills/moai-domain-backend/SKILL.md +234 -43
- moai_adk/templates/.claude/skills/moai-domain-backend/examples.md +1633 -0
- moai_adk/templates/.claude/skills/moai-domain-backend/reference.md +660 -0
- moai_adk/templates/.claude/skills/moai-domain-cli-tool/SKILL.md +97 -69
- moai_adk/templates/.claude/skills/moai-domain-cli-tool/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-cli-tool/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-domain-data-science/SKILL.md +97 -72
- moai_adk/templates/.claude/skills/moai-domain-data-science/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-data-science/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-domain-database/SKILL.md +97 -74
- moai_adk/templates/.claude/skills/moai-domain-database/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-database/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-domain-devops/SKILL.md +98 -74
- moai_adk/templates/.claude/skills/moai-domain-devops/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-devops/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/SKILL.md +102 -73
- moai_adk/templates/.claude/skills/moai-domain-frontend/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-domain-ml/SKILL.md +97 -73
- moai_adk/templates/.claude/skills/moai-domain-ml/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-ml/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-domain-mobile-app/SKILL.md +97 -67
- moai_adk/templates/.claude/skills/moai-domain-mobile-app/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-mobile-app/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-domain-security/SKILL.md +97 -79
- moai_adk/templates/.claude/skills/moai-domain-security/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-security/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-domain-web-api/SKILL.md +97 -71
- moai_adk/templates/.claude/skills/moai-domain-web-api/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-web-api/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-essentials-debug/SKILL.md +265 -64
- moai_adk/templates/.claude/skills/moai-essentials-debug/examples.md +1064 -0
- moai_adk/templates/.claude/skills/moai-essentials-debug/reference.md +1047 -0
- moai_adk/templates/.claude/skills/moai-essentials-perf/SKILL.md +87 -78
- moai_adk/templates/.claude/skills/moai-essentials-perf/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-essentials-perf/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-essentials-refactor/SKILL.md +87 -70
- moai_adk/templates/.claude/skills/moai-essentials-refactor/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-essentials-refactor/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-essentials-review/SKILL.md +87 -86
- moai_adk/templates/.claude/skills/moai-essentials-review/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-essentials-review/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-foundation-ears/SKILL.md +80 -62
- moai_adk/templates/.claude/skills/moai-foundation-ears/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-foundation-ears/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-foundation-git/SKILL.md +207 -50
- moai_adk/templates/.claude/skills/moai-foundation-git/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-foundation-git/reference.md +29 -0
- moai_adk/templates/.claude/skills/moai-foundation-langs/SKILL.md +90 -71
- moai_adk/templates/.claude/skills/moai-foundation-langs/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-foundation-langs/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-foundation-specs/SKILL.md +78 -58
- moai_adk/templates/.claude/skills/moai-foundation-specs/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-foundation-specs/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-foundation-tags/SKILL.md +78 -51
- moai_adk/templates/.claude/skills/moai-foundation-tags/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-foundation-tags/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-foundation-trust/.!11330!examples.md +0 -0
- moai_adk/templates/.claude/skills/moai-foundation-trust/SKILL.md +253 -32
- moai_adk/templates/.claude/skills/moai-foundation-trust/examples.md +0 -0
- moai_adk/templates/.claude/skills/moai-foundation-trust/reference.md +1099 -0
- moai_adk/templates/.claude/skills/moai-jit-docs-enhanced/SKILL.md +460 -0
- moai_adk/templates/.claude/skills/moai-lang-c/SKILL.md +98 -74
- moai_adk/templates/.claude/skills/moai-lang-c/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-c/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-cpp/SKILL.md +98 -76
- moai_adk/templates/.claude/skills/moai-lang-cpp/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-cpp/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/SKILL.md +2358 -70
- moai_adk/templates/.claude/skills/moai-lang-csharp/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-dart/SKILL.md +2962 -68
- moai_adk/templates/.claude/skills/moai-lang-dart/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-dart/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-go/SKILL.md +1898 -70
- moai_adk/templates/.claude/skills/moai-lang-go/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-go/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-java/SKILL.md +1465 -68
- moai_adk/templates/.claude/skills/moai-lang-java/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-java/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-javascript/SKILL.md +2364 -66
- moai_adk/templates/.claude/skills/moai-lang-javascript/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-javascript/reference.md +32 -0
- moai_adk/templates/.claude/skills/moai-lang-kotlin/SKILL.md +1630 -69
- moai_adk/templates/.claude/skills/moai-lang-kotlin/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-kotlin/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-php/SKILL.md +89 -61
- moai_adk/templates/.claude/skills/moai-lang-php/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-php/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-python/SKILL.md +735 -66
- moai_adk/templates/.claude/skills/moai-lang-python/examples.md +624 -0
- moai_adk/templates/.claude/skills/moai-lang-python/reference.md +316 -0
- moai_adk/templates/.claude/skills/moai-lang-r/SKILL.md +97 -73
- moai_adk/templates/.claude/skills/moai-lang-r/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-r/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-ruby/SKILL.md +98 -73
- moai_adk/templates/.claude/skills/moai-lang-ruby/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-ruby/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-rust/SKILL.md +1834 -70
- moai_adk/templates/.claude/skills/moai-lang-rust/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-rust/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/SKILL.md +99 -74
- moai_adk/templates/.claude/skills/moai-lang-scala/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-shell/SKILL.md +97 -74
- moai_adk/templates/.claude/skills/moai-lang-shell/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-shell/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-sql/SKILL.md +98 -74
- moai_adk/templates/.claude/skills/moai-lang-sql/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-sql/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-swift/SKILL.md +1959 -69
- moai_adk/templates/.claude/skills/moai-lang-swift/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-swift/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-template/SKILL.md +348 -0
- moai_adk/templates/.claude/skills/moai-lang-template/VARIABLES.md +98 -0
- moai_adk/templates/.claude/skills/moai-lang-typescript/SKILL.md +1230 -66
- moai_adk/templates/.claude/skills/moai-lang-typescript/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-typescript/reference.md +34 -0
- moai_adk/templates/.claude/skills/moai-learning-optimizer/SKILL.md +575 -0
- moai_adk/templates/.claude/skills/moai-project-batch-questions/README.md +50 -0
- moai_adk/templates/.claude/skills/moai-project-batch-questions/SKILL.md +304 -0
- moai_adk/templates/.claude/skills/moai-project-batch-questions/examples.md +417 -0
- moai_adk/templates/.claude/skills/moai-project-batch-questions/reference.md +704 -0
- moai_adk/templates/.claude/skills/moai-project-config-manager/README.md +87 -0
- moai_adk/templates/.claude/skills/moai-project-config-manager/SKILL.md +552 -0
- moai_adk/templates/.claude/skills/moai-project-config-manager/examples.md +1109 -0
- moai_adk/templates/.claude/skills/moai-project-config-manager/reference.md +514 -0
- moai_adk/templates/.claude/skills/moai-project-config-manager/validate.py +106 -0
- moai_adk/templates/.claude/skills/moai-project-documentation/README.md +11 -0
- moai_adk/templates/.claude/skills/moai-project-documentation/SKILL.md +622 -0
- moai_adk/templates/.claude/skills/moai-project-documentation/examples.md +20 -0
- moai_adk/templates/.claude/skills/moai-project-documentation/reference.md +12 -0
- moai_adk/templates/.claude/skills/moai-project-language-initializer/README.md +152 -0
- moai_adk/templates/.claude/skills/moai-project-language-initializer/SKILL.md +285 -0
- moai_adk/templates/.claude/skills/moai-project-language-initializer/examples.md +333 -0
- moai_adk/templates/.claude/skills/moai-project-language-initializer/reference.md +386 -0
- moai_adk/templates/.claude/skills/moai-project-template-optimizer/README.md +49 -0
- moai_adk/templates/.claude/skills/moai-project-template-optimizer/SKILL.md +319 -0
- moai_adk/templates/.claude/skills/moai-project-template-optimizer/examples.md +58 -0
- moai_adk/templates/.claude/skills/moai-project-template-optimizer/reference.md +123 -0
- moai_adk/templates/.claude/skills/moai-session-info/SKILL.md +314 -0
- moai_adk/templates/.claude/skills/moai-streaming-ui/SKILL.md +552 -0
- moai_adk/templates/.claude/skills/moai-tag-policy-validator/SKILL.md +570 -0
- moai_adk/templates/.git-hooks/pre-commit +66 -0
- moai_adk/templates/.git-hooks/pre-push +255 -0
- moai_adk/templates/.github/workflows/c-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/cpp-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/csharp-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/dart-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/go-tag-validation.yml +130 -0
- moai_adk/templates/.github/workflows/java-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/javascript-tag-validation.yml +135 -0
- moai_adk/templates/.github/workflows/kotlin-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/moai-gitflow.yml +166 -3
- moai_adk/templates/.github/workflows/moai-release-create.yml +100 -0
- moai_adk/templates/.github/workflows/moai-release-pipeline.yml +188 -0
- moai_adk/templates/.github/workflows/php-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/python-tag-validation.yml +118 -0
- moai_adk/templates/.github/workflows/release.yml +118 -0
- moai_adk/templates/.github/workflows/ruby-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/rust-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/shell-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/spec-issue-sync.yml +338 -0
- moai_adk/templates/.github/workflows/swift-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/tag-report.yml +269 -0
- moai_adk/templates/.github/workflows/tag-validation.yml +186 -0
- moai_adk/templates/.github/workflows/typescript-tag-validation.yml +154 -0
- moai_adk/templates/.mcp.json +31 -0
- moai_adk/templates/.moai/config.json +80 -7
- moai_adk/templates/CLAUDE.md +562 -546
- moai_adk/utils/banner.py +5 -5
- moai_adk/utils/common.py +294 -0
- moai_adk/utils/link_validator.py +235 -0
- moai_adk/utils/logger.py +8 -8
- moai_adk/utils/user_experience.py +451 -0
- moai_adk-0.20.1.dist-info/METADATA +233 -0
- moai_adk-0.20.1.dist-info/RECORD +404 -0
- moai_adk/templates/.claude/hooks/alfred/README.md +0 -230
- moai_adk/templates/.claude/hooks/alfred/alfred_hooks.py +0 -156
- moai_adk/templates/.claude/hooks/alfred/core/__init__.py +0 -85
- moai_adk/templates/.claude/hooks/alfred/handlers/notification.py +0 -25
- moai_adk/templates/.claude/hooks/alfred/handlers/session.py +0 -92
- moai_adk/templates/.claude/hooks/alfred/handlers/tool.py +0 -70
- moai_adk/templates/.claude/hooks/alfred/handlers/user.py +0 -41
- moai_adk/templates/.claude/output-styles/alfred/agentic-coding.md +0 -636
- moai_adk/templates/.claude/output-styles/alfred/moai-adk-learning.md +0 -692
- moai_adk/templates/.claude/output-styles/alfred/study-with-alfred.md +0 -470
- moai_adk/templates/.claude/skills/moai-alfred-debugger-pro/SKILL.md +0 -103
- moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/SKILL.md +0 -103
- moai_adk/templates/.claude/skills/moai-alfred-git-workflow/SKILL.md +0 -95
- moai_adk/templates/.claude/skills/moai-alfred-performance-optimizer/SKILL.md +0 -105
- moai_adk/templates/.claude/skills/moai-alfred-refactoring-coach/SKILL.md +0 -97
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/SKILL.md +0 -97
- moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/SKILL.md +0 -90
- moai_adk/templates/.claude/skills/moai-alfred-trust-validation/SKILL.md +0 -99
- moai_adk/templates/.claude/skills/moai-alfred-tui-survey/SKILL.md +0 -87
- moai_adk/templates/.claude/skills/moai-alfred-tui-survey/examples.md +0 -62
- moai_adk/templates/.claude/skills/moai-claude-code/SKILL.md +0 -94
- moai_adk/templates/.claude/skills/moai-claude-code/examples.md +0 -513
- moai_adk/templates/.claude/skills/moai-claude-code/reference.md +0 -433
- moai_adk/templates/.claude/skills/moai-claude-code/templates/agent-full.md +0 -332
- moai_adk/templates/.claude/skills/moai-claude-code/templates/command-full.md +0 -384
- moai_adk/templates/.claude/skills/moai-claude-code/templates/plugin-full.json +0 -363
- moai_adk/templates/.claude/skills/moai-claude-code/templates/settings-full.json +0 -595
- moai_adk/templates/.claude/skills/moai-claude-code/templates/skill-full.md +0 -496
- moai_adk/templates/.claude/skills/moai-lang-clojure/SKILL.md +0 -100
- moai_adk/templates/.claude/skills/moai-lang-elixir/SKILL.md +0 -99
- moai_adk/templates/.claude/skills/moai-lang-haskell/SKILL.md +0 -100
- moai_adk/templates/.claude/skills/moai-lang-julia/SKILL.md +0 -98
- moai_adk/templates/.claude/skills/moai-lang-lua/SKILL.md +0 -98
- moai_adk/templates/.github/PULL_REQUEST_TEMPLATE.md +0 -69
- moai_adk/templates/.moai/memory/development-guide.md +0 -344
- moai_adk/templates/.moai/memory/gitflow-protection-policy.md +0 -220
- moai_adk/templates/.moai/memory/spec-metadata.md +0 -356
- moai_adk/templates/.moai/project/product.md +0 -161
- moai_adk/templates/.moai/project/structure.md +0 -156
- moai_adk/templates/.moai/project/tech.md +0 -227
- moai_adk/templates/__init__.py +0 -2
- moai_adk-0.4.5.dist-info/METADATA +0 -369
- moai_adk-0.4.5.dist-info/RECORD +0 -152
- {moai_adk-0.4.5.dist-info → moai_adk-0.20.1.dist-info}/WHEEL +0 -0
- {moai_adk-0.4.5.dist-info → moai_adk-0.20.1.dist-info}/entry_points.txt +0 -0
- {moai_adk-0.4.5.dist-info → moai_adk-0.20.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,693 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# @CODE:TAG-AUTO-CORRECTOR-001 | @SPEC:TAG-AUTO-001
|
|
3
|
+
"""TAG 오류 자동 수정 시스템
|
|
4
|
+
|
|
5
|
+
TAG 정책 위반을 자동으로 수정하고 스마트한 TAG를 생성하는 시스템.
|
|
6
|
+
Post-Tool-Use 훅과 통합하여 실시간으로 TAG 오류를 교정.
|
|
7
|
+
|
|
8
|
+
주요 기능:
|
|
9
|
+
- 누락된 TAG 자동 생성
|
|
10
|
+
- 중복 TAG 자동 제거
|
|
11
|
+
- TAG 체인 연결 자동 복구
|
|
12
|
+
- 스마트 TAG 제안 시스템
|
|
13
|
+
|
|
14
|
+
@SPEC:TAG-AUTO-001
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
import re
|
|
18
|
+
from dataclasses import dataclass
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
from typing import Dict, List, Optional, Set, Tuple
|
|
21
|
+
|
|
22
|
+
from .policy_validator import PolicyViolation, PolicyViolationType
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass
|
|
26
|
+
class AutoCorrection:
|
|
27
|
+
"""자동 수정 정보
|
|
28
|
+
|
|
29
|
+
Attributes:
|
|
30
|
+
file_path: 수정할 파일 경로
|
|
31
|
+
original_content: 원본 내용
|
|
32
|
+
corrected_content: 수정된 내용
|
|
33
|
+
description: 수정 설명
|
|
34
|
+
confidence: 수정 신뢰도 (0.0-1.0)
|
|
35
|
+
requires_review: 수동 검토 필요 여부
|
|
36
|
+
"""
|
|
37
|
+
file_path: str
|
|
38
|
+
original_content: str
|
|
39
|
+
corrected_content: str
|
|
40
|
+
description: str
|
|
41
|
+
confidence: float
|
|
42
|
+
requires_review: bool = False
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@dataclass
|
|
46
|
+
class AutoCorrectionConfig:
|
|
47
|
+
"""자동 수정 설정
|
|
48
|
+
|
|
49
|
+
Attributes:
|
|
50
|
+
enable_auto_fix: 자동 수정 활성화
|
|
51
|
+
confidence_threshold: 자동 적용할 최소 신뢰도
|
|
52
|
+
create_missing_specs: 누락된 SPEC 자동 생성
|
|
53
|
+
create_missing_tests: 누락된 TEST 자동 생성
|
|
54
|
+
remove_duplicates: 중복 TAG 자동 제거
|
|
55
|
+
backup_before_fix: 수정 전 백업 생성
|
|
56
|
+
"""
|
|
57
|
+
enable_auto_fix: bool = False
|
|
58
|
+
confidence_threshold: float = 0.8
|
|
59
|
+
create_missing_specs: bool = False
|
|
60
|
+
create_missing_tests: bool = False
|
|
61
|
+
remove_duplicates: bool = True
|
|
62
|
+
backup_before_fix: bool = True
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class TagAutoCorrector:
|
|
66
|
+
"""TAG 오류 자동 수정기
|
|
67
|
+
|
|
68
|
+
Post-Tool-Use 훅에서 호출되어 TAG 정책 위반을 자동으로 수정.
|
|
69
|
+
스마트한 알고리즘으로 최적의 TAG를 생성하고 제안.
|
|
70
|
+
|
|
71
|
+
Usage:
|
|
72
|
+
config = AutoCorrectionConfig(enable_auto_fix=True)
|
|
73
|
+
corrector = TagAutoCorrector(config=config)
|
|
74
|
+
|
|
75
|
+
violations = [...]
|
|
76
|
+
corrections = corrector.generate_corrections(violations)
|
|
77
|
+
|
|
78
|
+
if corrections:
|
|
79
|
+
corrector.apply_corrections(corrections)
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
# TAG 정규식 패턴
|
|
83
|
+
TAG_PATTERN = re.compile(r"@(SPEC|CODE|TEST|DOC):([A-Z0-9-]+-\d{3})")
|
|
84
|
+
SHEBANG_PATTERN = re.compile(r"^#!.*\n")
|
|
85
|
+
|
|
86
|
+
def __init__(self, config: Optional[AutoCorrectionConfig] = None):
|
|
87
|
+
"""초기화
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
config: 자동 수정 설정 (기본: AutoCorrectionConfig())
|
|
91
|
+
"""
|
|
92
|
+
self.config = config or AutoCorrectionConfig()
|
|
93
|
+
|
|
94
|
+
def generate_corrections(self, violations: List[PolicyViolation]) -> List[AutoCorrection]:
|
|
95
|
+
"""정책 위반에 대한 자동 수정 생성
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
violations: 정책 위반 목록
|
|
99
|
+
|
|
100
|
+
Returns:
|
|
101
|
+
AutoCorrection 목록
|
|
102
|
+
"""
|
|
103
|
+
corrections = []
|
|
104
|
+
|
|
105
|
+
# 파일별로 위반 그룹화
|
|
106
|
+
violations_by_file = self._group_violations_by_file(violations)
|
|
107
|
+
|
|
108
|
+
for file_path, file_violations in violations_by_file.items():
|
|
109
|
+
try:
|
|
110
|
+
# 파일 내용 읽기
|
|
111
|
+
path = Path(file_path)
|
|
112
|
+
if not path.exists():
|
|
113
|
+
continue
|
|
114
|
+
|
|
115
|
+
original_content = path.read_text(encoding="utf-8", errors="ignore")
|
|
116
|
+
corrected_content = original_content
|
|
117
|
+
|
|
118
|
+
# 각 위반에 대해 수정 적용
|
|
119
|
+
for violation in file_violations:
|
|
120
|
+
correction = self._generate_single_correction(
|
|
121
|
+
file_path, corrected_content, violation
|
|
122
|
+
)
|
|
123
|
+
if correction:
|
|
124
|
+
corrected_content = correction.corrected_content
|
|
125
|
+
corrections.append(correction)
|
|
126
|
+
|
|
127
|
+
except Exception:
|
|
128
|
+
# 파일 읽기 실패 시 건너뛰기
|
|
129
|
+
continue
|
|
130
|
+
|
|
131
|
+
return corrections
|
|
132
|
+
|
|
133
|
+
def apply_corrections(self, corrections: List[AutoCorrection]) -> bool:
|
|
134
|
+
"""자동 수정 적용
|
|
135
|
+
|
|
136
|
+
Args:
|
|
137
|
+
corrections: 적용할 수정 목록
|
|
138
|
+
|
|
139
|
+
Returns:
|
|
140
|
+
성공 여부
|
|
141
|
+
"""
|
|
142
|
+
if not self.config.enable_auto_fix:
|
|
143
|
+
return False
|
|
144
|
+
|
|
145
|
+
success_count = 0
|
|
146
|
+
for correction in corrections:
|
|
147
|
+
if correction.confidence >= self.config.confidence_threshold:
|
|
148
|
+
try:
|
|
149
|
+
# 백업 생성
|
|
150
|
+
if self.config.backup_before_fix:
|
|
151
|
+
self._create_backup(correction.file_path, correction.original_content)
|
|
152
|
+
|
|
153
|
+
# 수정 적용
|
|
154
|
+
path = Path(correction.file_path)
|
|
155
|
+
path.write_text(correction.corrected_content, encoding="utf-8")
|
|
156
|
+
success_count += 1
|
|
157
|
+
|
|
158
|
+
except Exception:
|
|
159
|
+
# 수정 실패 시 건너뛰기
|
|
160
|
+
continue
|
|
161
|
+
|
|
162
|
+
return success_count == len(corrections)
|
|
163
|
+
|
|
164
|
+
def suggest_tag_for_code_file(self, file_path: str) -> Optional[Tuple[str, float]]:
|
|
165
|
+
"""코드 파일에 대한 TAG 제안
|
|
166
|
+
|
|
167
|
+
Args:
|
|
168
|
+
file_path: 코드 파일 경로
|
|
169
|
+
|
|
170
|
+
Returns:
|
|
171
|
+
(TAG, 신뢰도) 튜플 또는 None
|
|
172
|
+
"""
|
|
173
|
+
path = Path(file_path)
|
|
174
|
+
|
|
175
|
+
# 파일 경로에서 도메인 추출
|
|
176
|
+
domain = self._extract_domain_from_path(path)
|
|
177
|
+
if not domain:
|
|
178
|
+
return None
|
|
179
|
+
|
|
180
|
+
# 기존 TAG 확인
|
|
181
|
+
existing_tags = self._find_existing_tags_in_project(domain)
|
|
182
|
+
|
|
183
|
+
# 다음 번호 계산
|
|
184
|
+
next_number = self._calculate_next_number(existing_tags, domain)
|
|
185
|
+
|
|
186
|
+
tag = f"@CODE:{domain}-{next_number:03d}"
|
|
187
|
+
confidence = self._calculate_tag_confidence(domain, file_path)
|
|
188
|
+
|
|
189
|
+
return tag, confidence
|
|
190
|
+
|
|
191
|
+
def _group_violations_by_file(self, violations: List[PolicyViolation]) -> Dict[str, List[PolicyViolation]]:
|
|
192
|
+
"""파일별로 정책 위반 그룹화
|
|
193
|
+
|
|
194
|
+
Args:
|
|
195
|
+
violations: 정책 위반 목록
|
|
196
|
+
|
|
197
|
+
Returns:
|
|
198
|
+
{file_path: [violations]} 딕셔너리
|
|
199
|
+
"""
|
|
200
|
+
grouped = {}
|
|
201
|
+
for violation in violations:
|
|
202
|
+
if violation.file_path:
|
|
203
|
+
if violation.file_path not in grouped:
|
|
204
|
+
grouped[violation.file_path] = []
|
|
205
|
+
grouped[violation.file_path].append(violation)
|
|
206
|
+
return grouped
|
|
207
|
+
|
|
208
|
+
def _generate_single_correction(self, file_path: str, content: str,
|
|
209
|
+
violation: PolicyViolation) -> Optional[AutoCorrection]:
|
|
210
|
+
"""단일 정책 위반에 대한 수정 생성
|
|
211
|
+
|
|
212
|
+
Args:
|
|
213
|
+
file_path: 파일 경로
|
|
214
|
+
content: 현재 파일 내용
|
|
215
|
+
violation: 정책 위반
|
|
216
|
+
|
|
217
|
+
Returns:
|
|
218
|
+
AutoCorrection 또는 None
|
|
219
|
+
"""
|
|
220
|
+
if violation.type == PolicyViolationType.MISSING_TAGS:
|
|
221
|
+
return self._fix_missing_tags(file_path, content, violation)
|
|
222
|
+
elif violation.type == PolicyViolationType.DUPLICATE_TAGS:
|
|
223
|
+
return self._fix_duplicate_tags(file_path, content, violation)
|
|
224
|
+
elif violation.type == PolicyViolationType.NO_SPEC_REFERENCE:
|
|
225
|
+
return self._fix_missing_spec_reference(file_path, content, violation)
|
|
226
|
+
elif violation.type == PolicyViolationType.CHAIN_BREAK:
|
|
227
|
+
return self._fix_chain_break(file_path, content, violation)
|
|
228
|
+
|
|
229
|
+
return None
|
|
230
|
+
|
|
231
|
+
def _fix_missing_tags(self, file_path: str, content: str,
|
|
232
|
+
violation: PolicyViolation) -> Optional[AutoCorrection]:
|
|
233
|
+
"""누락된 TAG 수정
|
|
234
|
+
|
|
235
|
+
Args:
|
|
236
|
+
file_path: 파일 경로
|
|
237
|
+
content: 파일 내용
|
|
238
|
+
violation: 정책 위반
|
|
239
|
+
|
|
240
|
+
Returns:
|
|
241
|
+
AutoCorrection 또는 None
|
|
242
|
+
"""
|
|
243
|
+
# 코드 파일에 대한 TAG 제안
|
|
244
|
+
tag_suggestion = self.suggest_tag_for_code_file(file_path)
|
|
245
|
+
if not tag_suggestion:
|
|
246
|
+
return None
|
|
247
|
+
|
|
248
|
+
tag, confidence = tag_suggestion
|
|
249
|
+
|
|
250
|
+
# TAG 삽입 위치 찾기
|
|
251
|
+
insert_position = self._find_tag_insert_position(content)
|
|
252
|
+
|
|
253
|
+
# TAG 주석 생성
|
|
254
|
+
tag_comment = f"# {tag}\n"
|
|
255
|
+
|
|
256
|
+
# 내용에 TAG 삽입
|
|
257
|
+
lines = content.splitlines()
|
|
258
|
+
if insert_position is not None:
|
|
259
|
+
lines.insert(insert_position, tag_comment.strip())
|
|
260
|
+
else:
|
|
261
|
+
# 파일 시작에 삽입 (shebang 다음)
|
|
262
|
+
if self.SHEBANG_PATTERN.match(content):
|
|
263
|
+
shebang_line = lines[0]
|
|
264
|
+
lines = [shebang_line, "", tag_comment.strip()] + lines[1:]
|
|
265
|
+
else:
|
|
266
|
+
lines = [tag_comment.strip()] + lines
|
|
267
|
+
|
|
268
|
+
corrected_content = "\n".join(lines) + "\n"
|
|
269
|
+
|
|
270
|
+
return AutoCorrection(
|
|
271
|
+
file_path=file_path,
|
|
272
|
+
original_content=content,
|
|
273
|
+
corrected_content=corrected_content,
|
|
274
|
+
description=f"@TAG 자동 추가: {tag}",
|
|
275
|
+
confidence=confidence,
|
|
276
|
+
requires_review=confidence < 0.9
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
def _fix_duplicate_tags(self, file_path: str, content: str,
|
|
280
|
+
violation: PolicyViolation) -> Optional[AutoCorrection]:
|
|
281
|
+
"""중복 TAG 수정
|
|
282
|
+
|
|
283
|
+
Args:
|
|
284
|
+
file_path: 파일 경로
|
|
285
|
+
content: 파일 내용
|
|
286
|
+
violation: 정책 위반
|
|
287
|
+
|
|
288
|
+
Returns:
|
|
289
|
+
AutoCorrection 또는 None
|
|
290
|
+
"""
|
|
291
|
+
if not violation.tag:
|
|
292
|
+
return None
|
|
293
|
+
|
|
294
|
+
# 중복 TAG 제거 (첫 번째만 유지)
|
|
295
|
+
tag = violation.tag
|
|
296
|
+
corrected_content = content
|
|
297
|
+
found_first = False
|
|
298
|
+
|
|
299
|
+
# 정규식으로 모든 TAG 찾기
|
|
300
|
+
pattern = re.compile(re.escape(tag))
|
|
301
|
+
matches = list(pattern.finditer(content))
|
|
302
|
+
|
|
303
|
+
if len(matches) <= 1:
|
|
304
|
+
return None
|
|
305
|
+
|
|
306
|
+
# 첫 번째를 제외한 모든 TAG 제거
|
|
307
|
+
# 역순으로 처리하여 인덱스 변화 문제 방지
|
|
308
|
+
for match in reversed(matches[1:]):
|
|
309
|
+
start, end = match.span()
|
|
310
|
+
line_start = content.rfind('\n', 0, start) + 1
|
|
311
|
+
line_end = content.find('\n', end)
|
|
312
|
+
if line_end == -1:
|
|
313
|
+
line_end = len(content)
|
|
314
|
+
|
|
315
|
+
line = content[line_start:line_end]
|
|
316
|
+
if line.strip() == f"#{tag}":
|
|
317
|
+
# TAG만 있는 라인 제거
|
|
318
|
+
corrected_content = corrected_content[:line_start] + corrected_content[line_end:]
|
|
319
|
+
else:
|
|
320
|
+
# 라인의 일부로 있는 TAG 제거
|
|
321
|
+
corrected_content = (corrected_content[:start] +
|
|
322
|
+
corrected_content[end:])
|
|
323
|
+
|
|
324
|
+
return AutoCorrection(
|
|
325
|
+
file_path=file_path,
|
|
326
|
+
original_content=content,
|
|
327
|
+
corrected_content=corrected_content,
|
|
328
|
+
description=f"중복 TAG 제거: {tag}",
|
|
329
|
+
confidence=0.95,
|
|
330
|
+
requires_review=False
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
def _fix_missing_spec_reference(self, file_path: str, content: str,
|
|
334
|
+
violation: PolicyViolation) -> Optional[AutoCorrection]:
|
|
335
|
+
"""누락된 SPEC 참조 수정
|
|
336
|
+
|
|
337
|
+
Args:
|
|
338
|
+
file_path: 파일 경로
|
|
339
|
+
content: 파일 내용
|
|
340
|
+
violation: 정책 위반
|
|
341
|
+
|
|
342
|
+
Returns:
|
|
343
|
+
AutoCorrection 또는 None
|
|
344
|
+
"""
|
|
345
|
+
if not violation.tag or not self.config.create_missing_specs:
|
|
346
|
+
return None
|
|
347
|
+
|
|
348
|
+
# CODE TAG에서 도메인 추출
|
|
349
|
+
match = self.TAG_PATTERN.search(violation.tag)
|
|
350
|
+
if not match:
|
|
351
|
+
return None
|
|
352
|
+
|
|
353
|
+
domain = match.group(2)
|
|
354
|
+
|
|
355
|
+
# SPEC 파일 자동 생성
|
|
356
|
+
spec_created = self._create_spec_file(domain)
|
|
357
|
+
if not spec_created:
|
|
358
|
+
return None
|
|
359
|
+
|
|
360
|
+
# 기존 내용에 SPEC 참조 추가
|
|
361
|
+
corrected_content = self._add_spec_reference_to_content(content, domain)
|
|
362
|
+
|
|
363
|
+
return AutoCorrection(
|
|
364
|
+
file_path=file_path,
|
|
365
|
+
original_content=content,
|
|
366
|
+
corrected_content=corrected_content,
|
|
367
|
+
description=f"SPEC 참조 추가: {domain}",
|
|
368
|
+
confidence=0.8,
|
|
369
|
+
requires_review=True
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
def _fix_chain_break(self, file_path: str, content: str,
|
|
373
|
+
violation: PolicyViolation) -> Optional[AutoCorrection]:
|
|
374
|
+
"""체인 끊김 수정
|
|
375
|
+
|
|
376
|
+
Args:
|
|
377
|
+
file_path: 파일 경로
|
|
378
|
+
content: 파일 내용
|
|
379
|
+
violation: 정책 위반
|
|
380
|
+
|
|
381
|
+
Returns:
|
|
382
|
+
AutoCorrection 또는 None
|
|
383
|
+
"""
|
|
384
|
+
if violation.type == PolicyViolationType.CHAIN_BREAK and violation.tag:
|
|
385
|
+
# CODE에 대한 TEST 생성
|
|
386
|
+
if "@CODE:" in violation.tag and self.config.create_missing_tests:
|
|
387
|
+
return self._create_missing_test_file(violation.tag)
|
|
388
|
+
|
|
389
|
+
return None
|
|
390
|
+
|
|
391
|
+
def _find_tag_insert_position(self, content: str) -> Optional[int]:
|
|
392
|
+
"""TAG 삽입 위치 찾기
|
|
393
|
+
|
|
394
|
+
Args:
|
|
395
|
+
content: 파일 내용
|
|
396
|
+
|
|
397
|
+
Returns:
|
|
398
|
+
라인 번호 (0-based) 또는 None
|
|
399
|
+
"""
|
|
400
|
+
lines = content.splitlines()
|
|
401
|
+
|
|
402
|
+
# shebang 다음 위치 찾기
|
|
403
|
+
for i, line in enumerate(lines):
|
|
404
|
+
if line.startswith('#!'):
|
|
405
|
+
return i + 1
|
|
406
|
+
|
|
407
|
+
# docstring 다음 위치 찾기 (Python)
|
|
408
|
+
for i, line in enumerate(lines):
|
|
409
|
+
if line.strip().startswith('"""') or line.strip().startswith("'''"):
|
|
410
|
+
# docstring 끝 찾기
|
|
411
|
+
quote_char = '"""' if line.strip().startswith('"""') else "'''"
|
|
412
|
+
if quote_char in line[line.find(quote_char)+3:]:
|
|
413
|
+
return i + 1
|
|
414
|
+
else:
|
|
415
|
+
# 여러 줄 docstring
|
|
416
|
+
for j in range(i + 1, len(lines)):
|
|
417
|
+
if quote_char in lines[j]:
|
|
418
|
+
return j + 1
|
|
419
|
+
|
|
420
|
+
# 첫 번째 빈 라인 또는 주석 다음
|
|
421
|
+
for i, line in enumerate(lines):
|
|
422
|
+
if not line.strip() or line.strip().startswith('#'):
|
|
423
|
+
return i
|
|
424
|
+
|
|
425
|
+
return 0
|
|
426
|
+
|
|
427
|
+
def _extract_domain_from_path(self, path: Path) -> Optional[str]:
|
|
428
|
+
"""파일 경로에서 도메인 추출
|
|
429
|
+
|
|
430
|
+
Args:
|
|
431
|
+
path: 파일 경로
|
|
432
|
+
|
|
433
|
+
Returns:
|
|
434
|
+
도메인 문자열 또는 None
|
|
435
|
+
"""
|
|
436
|
+
parts = path.parts
|
|
437
|
+
|
|
438
|
+
# src/ 밑의 첫 번째 디렉토리를 도메인으로 사용
|
|
439
|
+
if "src" in parts:
|
|
440
|
+
src_index = parts.index("src")
|
|
441
|
+
if src_index + 1 < len(parts):
|
|
442
|
+
domain_part = parts[src_index + 1]
|
|
443
|
+
return domain_part.upper().replace("_", "-")
|
|
444
|
+
|
|
445
|
+
# 파일 이름에서 도메인 추출
|
|
446
|
+
stem = path.stem.upper()
|
|
447
|
+
# 일반적인 패턴 변환
|
|
448
|
+
replacements = {
|
|
449
|
+
"_": "-",
|
|
450
|
+
"AUTH": "AUTH",
|
|
451
|
+
"USER": "USER",
|
|
452
|
+
"LOGIN": "LOGIN",
|
|
453
|
+
"API": "API",
|
|
454
|
+
"CLI": "CLI",
|
|
455
|
+
"UTIL": "UTILS",
|
|
456
|
+
"HELPER": "HELPERS"
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
for old, new in replacements.items():
|
|
460
|
+
stem = stem.replace(old, new)
|
|
461
|
+
|
|
462
|
+
# 유효한 도메인 형식 확인
|
|
463
|
+
if re.match(r'^[A-Z-]+$', stem):
|
|
464
|
+
return stem
|
|
465
|
+
|
|
466
|
+
return None
|
|
467
|
+
|
|
468
|
+
def _find_existing_tags_in_project(self, domain: str) -> Set[str]:
|
|
469
|
+
"""프로젝트에서 기존 TAG 찾기
|
|
470
|
+
|
|
471
|
+
Args:
|
|
472
|
+
domain: 도메인
|
|
473
|
+
|
|
474
|
+
Returns:
|
|
475
|
+
기존 TAG 번호 집합
|
|
476
|
+
"""
|
|
477
|
+
existing_numbers = set()
|
|
478
|
+
|
|
479
|
+
# 프로젝트 루트에서 TAG 검색
|
|
480
|
+
for pattern in ["**/*.py", "**/*.js", "**/*.ts", "**/*.md"]:
|
|
481
|
+
for path in Path(".").glob(pattern):
|
|
482
|
+
if path.is_file():
|
|
483
|
+
try:
|
|
484
|
+
content = path.read_text(encoding="utf-8", errors="ignore")
|
|
485
|
+
matches = self.TAG_PATTERN.findall(content)
|
|
486
|
+
for tag_type, tag_domain in matches:
|
|
487
|
+
if tag_domain.startswith(domain):
|
|
488
|
+
# 도메인-번호 형식에서 번호 추출
|
|
489
|
+
if f"{domain}-" in tag_domain:
|
|
490
|
+
number_part = tag_domain.replace(f"{domain}-", "")
|
|
491
|
+
if number_part.isdigit():
|
|
492
|
+
existing_numbers.add(int(number_part))
|
|
493
|
+
except Exception:
|
|
494
|
+
continue
|
|
495
|
+
|
|
496
|
+
return existing_numbers
|
|
497
|
+
|
|
498
|
+
def _calculate_next_number(self, existing_numbers: Set[int], domain: str) -> int:
|
|
499
|
+
"""다음 TAG 번호 계산
|
|
500
|
+
|
|
501
|
+
Args:
|
|
502
|
+
existing_numbers: 기존 TAG 번호 집합
|
|
503
|
+
domain: 도메인
|
|
504
|
+
|
|
505
|
+
Returns:
|
|
506
|
+
다음 번호
|
|
507
|
+
"""
|
|
508
|
+
if not existing_numbers:
|
|
509
|
+
return 1
|
|
510
|
+
|
|
511
|
+
# 1부터 999까지 중 비어있는 가장 작은 번호 찾기
|
|
512
|
+
for i in range(1, 1000):
|
|
513
|
+
if i not in existing_numbers:
|
|
514
|
+
return i
|
|
515
|
+
|
|
516
|
+
# 모두 사용된 경우 마지막 번호 + 1
|
|
517
|
+
return max(existing_numbers) + 1
|
|
518
|
+
|
|
519
|
+
def _calculate_tag_confidence(self, domain: str, file_path: str) -> float:
|
|
520
|
+
"""TAG 신뢰도 계산
|
|
521
|
+
|
|
522
|
+
Args:
|
|
523
|
+
domain: 도메인
|
|
524
|
+
file_path: 파일 경로
|
|
525
|
+
|
|
526
|
+
Returns:
|
|
527
|
+
신뢰도 (0.0-1.0)
|
|
528
|
+
"""
|
|
529
|
+
confidence = 0.5 # 기본 신뢰도
|
|
530
|
+
|
|
531
|
+
path = Path(file_path)
|
|
532
|
+
|
|
533
|
+
# 경로 기반 신뢰도 증가
|
|
534
|
+
if "src" in str(path):
|
|
535
|
+
confidence += 0.2
|
|
536
|
+
|
|
537
|
+
# 도메인 일치 여부
|
|
538
|
+
if domain.lower() in path.stem.lower():
|
|
539
|
+
confidence += 0.2
|
|
540
|
+
|
|
541
|
+
# 파일 구조 정확성
|
|
542
|
+
if path.suffix in ['.py', '.js', '.ts']:
|
|
543
|
+
confidence += 0.1
|
|
544
|
+
|
|
545
|
+
return min(confidence, 1.0)
|
|
546
|
+
|
|
547
|
+
def _create_backup(self, file_path: str, content: str) -> None:
|
|
548
|
+
"""백업 파일 생성
|
|
549
|
+
|
|
550
|
+
Args:
|
|
551
|
+
file_path: 원본 파일 경로
|
|
552
|
+
content: 원본 내용
|
|
553
|
+
"""
|
|
554
|
+
try:
|
|
555
|
+
backup_path = Path(f"{file_path}.backup")
|
|
556
|
+
backup_path.write_text(content, encoding="utf-8")
|
|
557
|
+
except Exception:
|
|
558
|
+
pass
|
|
559
|
+
|
|
560
|
+
def _create_spec_file(self, domain: str) -> bool:
|
|
561
|
+
"""SPEC 파일 자동 생성
|
|
562
|
+
|
|
563
|
+
Args:
|
|
564
|
+
domain: 도메인
|
|
565
|
+
|
|
566
|
+
Returns:
|
|
567
|
+
성공 여부
|
|
568
|
+
"""
|
|
569
|
+
try:
|
|
570
|
+
spec_dir = Path(f".moai/specs/SPEC-{domain}")
|
|
571
|
+
spec_dir.mkdir(parents=True, exist_ok=True)
|
|
572
|
+
|
|
573
|
+
spec_file = spec_dir / "spec.md"
|
|
574
|
+
if not spec_file.exists():
|
|
575
|
+
spec_content = f"""# SPEC: {domain}
|
|
576
|
+
|
|
577
|
+
## 요구사항
|
|
578
|
+
|
|
579
|
+
- [요구사항 상세 내용]
|
|
580
|
+
|
|
581
|
+
## 구현 가이드
|
|
582
|
+
|
|
583
|
+
### TAG 연결
|
|
584
|
+
- @SPEC:{domain} (현재 문서)
|
|
585
|
+
- @CODE:{domain} (구현 파일)
|
|
586
|
+
- @TEST:{domain} (테스트 파일)
|
|
587
|
+
|
|
588
|
+
### 인수 조건
|
|
589
|
+
- [ ] 기능 구현 완료
|
|
590
|
+
- [ ] 테스트 통과
|
|
591
|
+
- [ ] 문서화 완료
|
|
592
|
+
|
|
593
|
+
## 기록
|
|
594
|
+
|
|
595
|
+
- 생성일: {Path('.').absolute().name}
|
|
596
|
+
- 상태: 작성 중
|
|
597
|
+
"""
|
|
598
|
+
spec_file.write_text(spec_content, encoding="utf-8")
|
|
599
|
+
return True
|
|
600
|
+
|
|
601
|
+
except Exception:
|
|
602
|
+
pass
|
|
603
|
+
|
|
604
|
+
return False
|
|
605
|
+
|
|
606
|
+
def _add_spec_reference_to_content(self, content: str, domain: str) -> str:
|
|
607
|
+
"""내용에 SPEC 참조 추가
|
|
608
|
+
|
|
609
|
+
Args:
|
|
610
|
+
content: 원본 내용
|
|
611
|
+
domain: 도메인
|
|
612
|
+
|
|
613
|
+
Returns:
|
|
614
|
+
수정된 내용
|
|
615
|
+
"""
|
|
616
|
+
lines = content.splitlines()
|
|
617
|
+
|
|
618
|
+
# 기존 CODE TAG 찾기
|
|
619
|
+
for i, line in enumerate(lines):
|
|
620
|
+
if f"@CODE:{domain}" in line:
|
|
621
|
+
# SPEC 참조 추가
|
|
622
|
+
spec_ref = f" | SPEC: .moai/specs/SPEC-{domain}/spec.md"
|
|
623
|
+
if spec_ref not in line:
|
|
624
|
+
lines[i] = line + spec_ref
|
|
625
|
+
break
|
|
626
|
+
|
|
627
|
+
return "\n".join(lines) + "\n"
|
|
628
|
+
|
|
629
|
+
def _create_missing_test_file(self, code_tag: str) -> Optional[AutoCorrection]:
|
|
630
|
+
"""누락된 테스트 파일 생성
|
|
631
|
+
|
|
632
|
+
Args:
|
|
633
|
+
code_tag: CODE TAG
|
|
634
|
+
|
|
635
|
+
Returns:
|
|
636
|
+
AutoCorrection 또는 None
|
|
637
|
+
"""
|
|
638
|
+
match = self.TAG_PATTERN.search(code_tag)
|
|
639
|
+
if not match:
|
|
640
|
+
return None
|
|
641
|
+
|
|
642
|
+
domain = match.group(2)
|
|
643
|
+
|
|
644
|
+
try:
|
|
645
|
+
test_dir = Path("tests")
|
|
646
|
+
test_dir.mkdir(exist_ok=True)
|
|
647
|
+
|
|
648
|
+
test_file = test_dir / f"test_{domain.lower()}.py"
|
|
649
|
+
|
|
650
|
+
if not test_file.exists():
|
|
651
|
+
test_content = f'''#!/usr/bin/env python3
|
|
652
|
+
# @TEST:{domain} | SPEC: .moai/specs/SPEC-{domain}/spec.md | CODE: @CODE:{domain}
|
|
653
|
+
"""Test cases for {domain} functionality.
|
|
654
|
+
|
|
655
|
+
This module tests the implementation defined in @CODE:{domain}.
|
|
656
|
+
"""
|
|
657
|
+
|
|
658
|
+
import pytest
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
class Test{domain.replace('-', '')}:
|
|
662
|
+
"""Test class for {domain} functionality."""
|
|
663
|
+
|
|
664
|
+
def test_basic_functionality(self):
|
|
665
|
+
"""Test basic functionality."""
|
|
666
|
+
# TODO: Implement test cases
|
|
667
|
+
assert True
|
|
668
|
+
|
|
669
|
+
def test_edge_cases(self):
|
|
670
|
+
"""Test edge cases."""
|
|
671
|
+
# TODO: Implement edge case tests
|
|
672
|
+
assert True
|
|
673
|
+
|
|
674
|
+
def test_error_conditions(self):
|
|
675
|
+
"""Test error conditions."""
|
|
676
|
+
# TODO: Implement error condition tests
|
|
677
|
+
assert True
|
|
678
|
+
'''
|
|
679
|
+
test_file.write_text(test_content, encoding="utf-8")
|
|
680
|
+
|
|
681
|
+
return AutoCorrection(
|
|
682
|
+
file_path=str(test_file),
|
|
683
|
+
original_content="",
|
|
684
|
+
corrected_content=test_content,
|
|
685
|
+
description=f"테스트 파일 생성: {domain}",
|
|
686
|
+
confidence=0.8,
|
|
687
|
+
requires_review=True
|
|
688
|
+
)
|
|
689
|
+
|
|
690
|
+
except Exception:
|
|
691
|
+
pass
|
|
692
|
+
|
|
693
|
+
return None
|