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.
- moai_adk/__init__.py +1 -2
- moai_adk/__main__.py +85 -2
- moai_adk/cli/__init__.py +0 -1
- moai_adk/cli/commands/__init__.py +0 -1
- moai_adk/cli/commands/analyze.py +127 -0
- moai_adk/cli/commands/backup.py +5 -3
- moai_adk/cli/commands/doctor.py +35 -11
- moai_adk/cli/commands/improve_user_experience.py +348 -0
- moai_adk/cli/commands/init.py +150 -23
- moai_adk/cli/commands/language.py +269 -0
- moai_adk/cli/commands/migrate.py +158 -0
- moai_adk/cli/commands/status.py +13 -12
- moai_adk/cli/commands/update.py +364 -60
- moai_adk/cli/commands/validate_links.py +118 -0
- moai_adk/cli/main.py +3 -2
- moai_adk/cli/prompts/init_prompts.py +79 -82
- moai_adk/core/__init__.py +0 -1
- moai_adk/core/analysis/__init__.py +9 -0
- moai_adk/core/analysis/session_analyzer.py +439 -0
- moai_adk/core/claude_integration.py +421 -0
- moai_adk/core/command_helpers.py +270 -0
- moai_adk/core/config/__init__.py +6 -0
- moai_adk/core/config/auto_spec_config.py +346 -0
- moai_adk/core/config/migration.py +133 -12
- moai_adk/core/context_manager.py +279 -0
- moai_adk/core/diagnostics/slash_commands.py +0 -1
- moai_adk/core/error_recovery_system.py +1289 -0
- moai_adk/core/git/__init__.py +0 -1
- moai_adk/core/git/branch.py +0 -1
- moai_adk/core/git/branch_manager.py +4 -4
- moai_adk/core/git/checkpoint.py +1 -5
- moai_adk/core/git/commit.py +0 -1
- moai_adk/core/git/event_detector.py +3 -5
- moai_adk/core/git/manager.py +0 -1
- moai_adk/core/hooks/post_tool_auto_spec_completion.py +925 -0
- moai_adk/core/integration/__init__.py +22 -0
- moai_adk/core/integration/engine.py +169 -0
- moai_adk/core/integration/integration_tester.py +225 -0
- moai_adk/core/integration/models.py +88 -0
- moai_adk/core/integration/utils.py +211 -0
- moai_adk/core/issue_creator.py +28 -18
- moai_adk/core/language_config.py +202 -0
- moai_adk/core/language_validator.py +556 -0
- moai_adk/core/mcp/setup.py +113 -0
- moai_adk/core/migration/__init__.py +18 -0
- moai_adk/core/migration/backup_manager.py +208 -0
- moai_adk/core/migration/file_migrator.py +218 -0
- moai_adk/core/migration/version_detector.py +143 -0
- moai_adk/core/migration/version_migrator.py +228 -0
- moai_adk/core/performance/__init__.py +6 -0
- moai_adk/core/performance/cache_system.py +318 -0
- moai_adk/core/performance/parallel_processor.py +116 -0
- moai_adk/core/project/__init__.py +0 -1
- moai_adk/core/project/backup_utils.py +2 -7
- moai_adk/core/project/checker.py +3 -3
- moai_adk/core/project/detector.py +20 -40
- moai_adk/core/project/initializer.py +42 -17
- moai_adk/core/project/phase_executor.py +415 -58
- moai_adk/core/project/validator.py +6 -25
- moai_adk/core/quality/__init__.py +1 -1
- moai_adk/core/quality/trust_checker.py +64 -110
- moai_adk/core/quality/validators/__init__.py +1 -1
- moai_adk/core/quality/validators/base_validator.py +1 -1
- moai_adk/core/rollback_manager.py +993 -0
- moai_adk/core/session_manager.py +667 -0
- moai_adk/core/spec/confidence_scoring.py +749 -0
- moai_adk/core/spec/ears_template_engine.py +1182 -0
- moai_adk/core/spec/quality_validator.py +721 -0
- moai_adk/core/spec_status_manager.py +488 -0
- moai_adk/core/template/__init__.py +0 -1
- moai_adk/core/template/backup.py +41 -1
- moai_adk/core/template/config.py +11 -12
- moai_adk/core/template/languages.py +0 -1
- moai_adk/core/template/merger.py +79 -22
- moai_adk/core/template/processor.py +614 -40
- moai_adk/core/template_engine.py +36 -27
- moai_adk/foundation/git/commit_templates.py +565 -0
- moai_adk/foundation/trust/trust_principles.py +725 -0
- moai_adk/foundation/trust/validation_checklist.py +1678 -0
- moai_adk/statusline/__init__.py +38 -0
- moai_adk/statusline/alfred_detector.py +107 -0
- moai_adk/statusline/config.py +364 -0
- moai_adk/statusline/enhanced_output_style_detector.py +364 -0
- moai_adk/statusline/git_collector.py +190 -0
- moai_adk/statusline/main.py +228 -0
- moai_adk/statusline/metrics_tracker.py +78 -0
- moai_adk/statusline/renderer.py +327 -0
- moai_adk/statusline/update_checker.py +135 -0
- moai_adk/statusline/version_reader.py +647 -0
- moai_adk/templates/.git-hooks/pre-commit +66 -0
- moai_adk/templates/.git-hooks/pre-push +116 -4
- moai_adk/templates/.github/workflows/moai-gitflow.yml +1 -7
- moai_adk/templates/.github/workflows/spec-issue-sync.yml +0 -1
- moai_adk/templates/.gitignore +44 -0
- moai_adk/templates/.mcp.json +22 -0
- moai_adk/templates/CLAUDE.md +450 -1071
- moai_adk/utils/__init__.py +0 -1
- moai_adk/utils/banner.py +0 -1
- moai_adk/utils/common.py +308 -0
- moai_adk/utils/link_validator.py +249 -0
- moai_adk/utils/logger.py +4 -9
- moai_adk/utils/safe_file_reader.py +210 -0
- moai_adk/utils/user_experience.py +531 -0
- moai_adk-0.25.4.dist-info/METADATA +2279 -0
- moai_adk-0.25.4.dist-info/RECORD +112 -0
- moai_adk/core/tags/__init__.py +0 -86
- moai_adk/core/tags/ci_validator.py +0 -463
- moai_adk/core/tags/cli.py +0 -283
- moai_adk/core/tags/generator.py +0 -109
- moai_adk/core/tags/inserter.py +0 -99
- moai_adk/core/tags/mapper.py +0 -126
- moai_adk/core/tags/parser.py +0 -76
- moai_adk/core/tags/pre_commit_validator.py +0 -393
- moai_adk/core/tags/reporter.py +0 -956
- moai_adk/core/tags/tags.py +0 -149
- moai_adk/core/tags/validator.py +0 -897
- moai_adk/templates/.claude/agents/alfred/backend-expert.md +0 -319
- moai_adk/templates/.claude/agents/alfred/cc-manager.md +0 -316
- moai_adk/templates/.claude/agents/alfred/debug-helper.md +0 -208
- moai_adk/templates/.claude/agents/alfred/devops-expert.md +0 -464
- moai_adk/templates/.claude/agents/alfred/doc-syncer.md +0 -214
- moai_adk/templates/.claude/agents/alfred/frontend-expert.md +0 -357
- moai_adk/templates/.claude/agents/alfred/git-manager.md +0 -406
- moai_adk/templates/.claude/agents/alfred/implementation-planner.md +0 -423
- moai_adk/templates/.claude/agents/alfred/project-manager.md +0 -312
- moai_adk/templates/.claude/agents/alfred/quality-gate.md +0 -343
- moai_adk/templates/.claude/agents/alfred/skill-factory.md +0 -865
- moai_adk/templates/.claude/agents/alfred/spec-builder.md +0 -426
- moai_adk/templates/.claude/agents/alfred/tag-agent.md +0 -361
- moai_adk/templates/.claude/agents/alfred/tdd-implementer.md +0 -428
- moai_adk/templates/.claude/agents/alfred/trust-checker.md +0 -375
- moai_adk/templates/.claude/agents/alfred/ui-ux-expert.md +0 -571
- moai_adk/templates/.claude/commands/alfred/0-project.md +0 -1854
- moai_adk/templates/.claude/commands/alfred/1-plan.md +0 -880
- moai_adk/templates/.claude/commands/alfred/2-run.md +0 -793
- moai_adk/templates/.claude/commands/alfred/3-sync.md +0 -1084
- moai_adk/templates/.claude/commands/alfred/9-feedback.md +0 -149
- moai_adk/templates/.claude/hooks/alfred/core/project.py +0 -748
- moai_adk/templates/.claude/hooks/alfred/core/timeout.py +0 -136
- moai_adk/templates/.claude/hooks/alfred/core/ttl_cache.py +0 -108
- moai_adk/templates/.claude/hooks/alfred/core/version_cache.py +0 -198
- moai_adk/templates/.claude/hooks/alfred/handlers/__init__.py +0 -29
- moai_adk/templates/.claude/hooks/alfred/post_tool__log_changes.py +0 -94
- moai_adk/templates/.claude/hooks/alfred/pre_tool__auto_checkpoint.py +0 -100
- moai_adk/templates/.claude/hooks/alfred/session_end__cleanup.py +0 -94
- moai_adk/templates/.claude/hooks/alfred/session_start__show_project_info.py +0 -94
- moai_adk/templates/.claude/hooks/alfred/shared/core/__init__.py +0 -170
- moai_adk/templates/.claude/hooks/alfred/shared/core/checkpoint.py +0 -271
- moai_adk/templates/.claude/hooks/alfred/shared/core/context.py +0 -67
- moai_adk/templates/.claude/hooks/alfred/shared/core/project.py +0 -749
- moai_adk/templates/.claude/hooks/alfred/shared/core/tags.py +0 -230
- moai_adk/templates/.claude/hooks/alfred/shared/core/version_cache.py +0 -198
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/__init__.py +0 -21
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/notification.py +0 -154
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/session.py +0 -174
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/tool.py +0 -87
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/user.py +0 -61
- moai_adk/templates/.claude/hooks/alfred/user_prompt__jit_load_docs.py +0 -112
- moai_adk/templates/.claude/hooks/alfred/utils/__init__.py +0 -1
- moai_adk/templates/.claude/hooks/alfred/utils/timeout.py +0 -161
- moai_adk/templates/.claude/settings.json +0 -144
- moai_adk/templates/.claude/skills/moai-alfred-agent-guide/SKILL.md +0 -70
- moai_adk/templates/.claude/skills/moai-alfred-agent-guide/examples.md +0 -62
- moai_adk/templates/.claude/skills/moai-alfred-agent-guide/reference.md +0 -242
- moai_adk/templates/.claude/skills/moai-alfred-config-schema/SKILL.md +0 -56
- moai_adk/templates/.claude/skills/moai-alfred-config-schema/examples.md +0 -28
- moai_adk/templates/.claude/skills/moai-alfred-config-schema/reference.md +0 -444
- moai_adk/templates/.claude/skills/moai-alfred-context-budget/SKILL.md +0 -62
- moai_adk/templates/.claude/skills/moai-alfred-context-budget/examples.md +0 -28
- moai_adk/templates/.claude/skills/moai-alfred-context-budget/reference.md +0 -405
- moai_adk/templates/.claude/skills/moai-alfred-dev-guide/SKILL.md +0 -51
- moai_adk/templates/.claude/skills/moai-alfred-dev-guide/examples.md +0 -355
- moai_adk/templates/.claude/skills/moai-alfred-dev-guide/reference.md +0 -239
- moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/SKILL.md +0 -323
- moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/examples.md +0 -286
- moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/reference.md +0 -126
- moai_adk/templates/.claude/skills/moai-alfred-git-workflow/SKILL.md +0 -122
- moai_adk/templates/.claude/skills/moai-alfred-git-workflow/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-alfred-git-workflow/reference.md +0 -29
- moai_adk/templates/.claude/skills/moai-alfred-gitflow-policy/SKILL.md +0 -74
- moai_adk/templates/.claude/skills/moai-alfred-gitflow-policy/examples.md +0 -4
- moai_adk/templates/.claude/skills/moai-alfred-gitflow-policy/reference.md +0 -269
- moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/SKILL.md +0 -237
- moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/examples.md +0 -615
- moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/reference.md +0 -653
- moai_adk/templates/.claude/skills/moai-alfred-issue-labels/SKILL.md +0 -19
- moai_adk/templates/.claude/skills/moai-alfred-issue-labels/examples.md +0 -4
- moai_adk/templates/.claude/skills/moai-alfred-issue-labels/reference.md +0 -150
- moai_adk/templates/.claude/skills/moai-alfred-language-detection/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-alfred-language-detection/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-alfred-language-detection/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-alfred-persona-roles/SKILL.md +0 -198
- moai_adk/templates/.claude/skills/moai-alfred-persona-roles/examples.md +0 -431
- moai_adk/templates/.claude/skills/moai-alfred-persona-roles/reference.md +0 -141
- moai_adk/templates/.claude/skills/moai-alfred-practices/SKILL.md +0 -89
- moai_adk/templates/.claude/skills/moai-alfred-practices/examples.md +0 -122
- moai_adk/templates/.claude/skills/moai-alfred-practices/reference.md +0 -369
- moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/SKILL.md +0 -508
- moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/examples.md +0 -481
- moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/reference.md +0 -100
- moai_adk/templates/.claude/skills/moai-alfred-reporting/SKILL.md +0 -273
- moai_adk/templates/.claude/skills/moai-alfred-rules/SKILL.md +0 -77
- moai_adk/templates/.claude/skills/moai-alfred-rules/examples.md +0 -265
- moai_adk/templates/.claude/skills/moai-alfred-rules/reference.md +0 -539
- moai_adk/templates/.claude/skills/moai-alfred-session-state/SKILL.md +0 -19
- moai_adk/templates/.claude/skills/moai-alfred-session-state/examples.md +0 -4
- moai_adk/templates/.claude/skills/moai-alfred-session-state/reference.md +0 -84
- moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/README.md +0 -137
- moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/SKILL.md +0 -219
- moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/examples/validate-spec.sh +0 -161
- moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/examples.md +0 -541
- moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/reference.md +0 -622
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-extended/SKILL.md +0 -115
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-extended/examples.md +0 -4
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-extended/reference.md +0 -348
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/SKILL.md +0 -19
- moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/examples.md +0 -4
- moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/reference.md +0 -211
- moai_adk/templates/.claude/skills/moai-alfred-trust-validation/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-alfred-trust-validation/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-alfred-trust-validation/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-alfred-workflow/SKILL.md +0 -288
- moai_adk/templates/.claude/skills/moai-cc-agents/SKILL.md +0 -269
- moai_adk/templates/.claude/skills/moai-cc-agents/templates/agent-template.md +0 -32
- moai_adk/templates/.claude/skills/moai-cc-claude-md/SKILL.md +0 -298
- moai_adk/templates/.claude/skills/moai-cc-claude-md/templates/CLAUDE-template.md +0 -26
- moai_adk/templates/.claude/skills/moai-cc-commands/SKILL.md +0 -307
- moai_adk/templates/.claude/skills/moai-cc-commands/templates/command-template.md +0 -21
- moai_adk/templates/.claude/skills/moai-cc-hooks/SKILL.md +0 -252
- moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/pre-bash-check.sh +0 -19
- moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/preserve-permissions.sh +0 -19
- moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/validate-bash-command.py +0 -24
- moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/SKILL.md +0 -199
- moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/templates/settings-mcp-template.json +0 -39
- moai_adk/templates/.claude/skills/moai-cc-memory/SKILL.md +0 -316
- moai_adk/templates/.claude/skills/moai-cc-memory/templates/session-summary-template.md +0 -18
- moai_adk/templates/.claude/skills/moai-cc-settings/SKILL.md +0 -263
- moai_adk/templates/.claude/skills/moai-cc-settings/templates/settings-complete-template.json +0 -30
- moai_adk/templates/.claude/skills/moai-cc-skill-descriptions/SKILL.md +0 -19
- moai_adk/templates/.claude/skills/moai-cc-skill-descriptions/examples.md +0 -4
- moai_adk/templates/.claude/skills/moai-cc-skill-descriptions/reference.md +0 -218
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/CHECKLIST.md +0 -482
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/EXAMPLES.md +0 -278
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/INTERACTIVE-DISCOVERY.md +0 -524
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/METADATA.md +0 -477
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/PARALLEL-ANALYSIS-REPORT.md +0 -429
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/PYTHON-VERSION-MATRIX.md +0 -391
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/SKILL-FACTORY-WORKFLOW.md +0 -431
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/SKILL-UPDATE-ADVISOR.md +0 -577
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/SKILL.md +0 -271
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/STEP-BY-STEP-GUIDE.md +0 -466
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/STRUCTURE.md +0 -583
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/WEB-RESEARCH.md +0 -526
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/reference.md +0 -465
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/scripts/generate-structure.sh +0 -328
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/scripts/validate-skill.sh +0 -312
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/SKILL_TEMPLATE.md +0 -245
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/examples-template.md +0 -285
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/reference-template.md +0 -278
- moai_adk/templates/.claude/skills/moai-cc-skill-factory/templates/scripts-template.sh +0 -303
- moai_adk/templates/.claude/skills/moai-cc-skills/SKILL.md +0 -291
- moai_adk/templates/.claude/skills/moai-cc-skills/templates/SKILL-template.md +0 -15
- moai_adk/templates/.claude/skills/moai-design-systems/SKILL.md +0 -802
- moai_adk/templates/.claude/skills/moai-design-systems/examples.md +0 -1238
- moai_adk/templates/.claude/skills/moai-design-systems/reference.md +0 -673
- moai_adk/templates/.claude/skills/moai-domain-backend/SKILL.md +0 -290
- moai_adk/templates/.claude/skills/moai-domain-backend/examples.md +0 -1633
- moai_adk/templates/.claude/skills/moai-domain-backend/reference.md +0 -660
- moai_adk/templates/.claude/skills/moai-domain-cli-tool/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-domain-cli-tool/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-domain-cli-tool/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-domain-data-science/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-domain-data-science/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-domain-data-science/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-domain-database/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-domain-database/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-domain-database/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-domain-devops/SKILL.md +0 -124
- moai_adk/templates/.claude/skills/moai-domain-devops/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-domain-devops/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-domain-frontend/SKILL.md +0 -128
- moai_adk/templates/.claude/skills/moai-domain-frontend/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-domain-frontend/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-domain-ml/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-domain-ml/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-domain-ml/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-domain-mobile-app/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-domain-mobile-app/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-domain-mobile-app/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-domain-security/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-domain-security/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-domain-security/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-domain-web-api/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-domain-web-api/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-domain-web-api/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-essentials-debug/SKILL.md +0 -303
- moai_adk/templates/.claude/skills/moai-essentials-debug/examples.md +0 -1064
- moai_adk/templates/.claude/skills/moai-essentials-debug/reference.md +0 -1047
- moai_adk/templates/.claude/skills/moai-essentials-perf/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-essentials-perf/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-essentials-perf/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-essentials-refactor/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-essentials-refactor/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-essentials-refactor/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-essentials-review/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-essentials-review/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-essentials-review/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-foundation-ears/SKILL.md +0 -116
- moai_adk/templates/.claude/skills/moai-foundation-ears/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-foundation-ears/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-foundation-git/SKILL.md +0 -122
- moai_adk/templates/.claude/skills/moai-foundation-git/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-foundation-git/reference.md +0 -29
- moai_adk/templates/.claude/skills/moai-foundation-langs/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-foundation-langs/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-foundation-langs/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-foundation-specs/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-foundation-specs/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-foundation-specs/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-foundation-tags/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-foundation-tags/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-foundation-tags/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-foundation-trust/SKILL.md +0 -307
- moai_adk/templates/.claude/skills/moai-foundation-trust/examples.md +0 -0
- moai_adk/templates/.claude/skills/moai-foundation-trust/reference.md +0 -1099
- moai_adk/templates/.claude/skills/moai-lang-c/SKILL.md +0 -124
- moai_adk/templates/.claude/skills/moai-lang-c/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-c/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-lang-cpp/SKILL.md +0 -124
- moai_adk/templates/.claude/skills/moai-lang-cpp/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-cpp/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-lang-csharp/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-lang-csharp/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-csharp/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-lang-dart/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-lang-dart/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-dart/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-lang-go/SKILL.md +0 -127
- moai_adk/templates/.claude/skills/moai-lang-go/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-go/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-lang-java/SKILL.md +0 -126
- moai_adk/templates/.claude/skills/moai-lang-java/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-java/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-lang-javascript/SKILL.md +0 -125
- moai_adk/templates/.claude/skills/moai-lang-javascript/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-javascript/reference.md +0 -32
- moai_adk/templates/.claude/skills/moai-lang-kotlin/SKILL.md +0 -124
- moai_adk/templates/.claude/skills/moai-lang-kotlin/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-kotlin/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-lang-php/SKILL.md +0 -126
- moai_adk/templates/.claude/skills/moai-lang-php/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-php/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-lang-python/SKILL.md +0 -433
- moai_adk/templates/.claude/skills/moai-lang-python/examples.md +0 -624
- moai_adk/templates/.claude/skills/moai-lang-python/reference.md +0 -316
- moai_adk/templates/.claude/skills/moai-lang-r/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-lang-r/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-r/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-lang-ruby/SKILL.md +0 -124
- moai_adk/templates/.claude/skills/moai-lang-ruby/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-ruby/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-lang-rust/SKILL.md +0 -127
- moai_adk/templates/.claude/skills/moai-lang-rust/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-rust/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-lang-scala/SKILL.md +0 -125
- moai_adk/templates/.claude/skills/moai-lang-scala/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-scala/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-lang-shell/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-lang-shell/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-shell/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-lang-sql/SKILL.md +0 -124
- moai_adk/templates/.claude/skills/moai-lang-sql/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-sql/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-lang-swift/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-lang-swift/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-swift/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-lang-typescript/SKILL.md +0 -133
- moai_adk/templates/.claude/skills/moai-lang-typescript/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-typescript/reference.md +0 -34
- moai_adk/templates/.claude/skills/moai-project-documentation.md +0 -622
- moai_adk/templates/.github/workflows/c-tag-validation.yml +0 -11
- moai_adk/templates/.github/workflows/cpp-tag-validation.yml +0 -11
- moai_adk/templates/.github/workflows/csharp-tag-validation.yml +0 -11
- moai_adk/templates/.github/workflows/dart-tag-validation.yml +0 -11
- moai_adk/templates/.github/workflows/go-tag-validation.yml +0 -130
- moai_adk/templates/.github/workflows/java-tag-validation.yml +0 -11
- moai_adk/templates/.github/workflows/javascript-tag-validation.yml +0 -135
- moai_adk/templates/.github/workflows/kotlin-tag-validation.yml +0 -11
- moai_adk/templates/.github/workflows/php-tag-validation.yml +0 -11
- moai_adk/templates/.github/workflows/python-tag-validation.yml +0 -118
- moai_adk/templates/.github/workflows/release.yml +0 -118
- moai_adk/templates/.github/workflows/ruby-tag-validation.yml +0 -11
- moai_adk/templates/.github/workflows/rust-tag-validation.yml +0 -11
- moai_adk/templates/.github/workflows/shell-tag-validation.yml +0 -11
- moai_adk/templates/.github/workflows/swift-tag-validation.yml +0 -11
- moai_adk/templates/.github/workflows/tag-report.yml +0 -269
- moai_adk/templates/.github/workflows/tag-validation.yml +0 -186
- moai_adk/templates/.github/workflows/typescript-tag-validation.yml +0 -154
- moai_adk/templates/.moai/config.json +0 -115
- moai_adk/templates/workflows/go-tag-validation.yml +0 -30
- moai_adk/templates/workflows/javascript-tag-validation.yml +0 -41
- moai_adk/templates/workflows/python-tag-validation.yml +0 -42
- moai_adk/templates/workflows/typescript-tag-validation.yml +0 -31
- moai_adk-0.15.1.dist-info/METADATA +0 -3094
- moai_adk-0.15.1.dist-info/RECORD +0 -365
- {moai_adk-0.15.1.dist-info → moai_adk-0.25.4.dist-info}/WHEEL +0 -0
- {moai_adk-0.15.1.dist-info → moai_adk-0.25.4.dist-info}/entry_points.txt +0 -0
- {moai_adk-0.15.1.dist-info → moai_adk-0.25.4.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Backup management module for MoAI-ADK migrations
|
|
3
|
+
|
|
4
|
+
Creates and manages backups during migration processes
|
|
5
|
+
to ensure data safety and enable rollback.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
import logging
|
|
10
|
+
import shutil
|
|
11
|
+
from datetime import datetime
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from typing import Dict, List, Optional
|
|
14
|
+
|
|
15
|
+
logger = logging.getLogger(__name__)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class BackupManager:
|
|
19
|
+
"""Manages backup creation and restoration for migrations"""
|
|
20
|
+
|
|
21
|
+
def __init__(self, project_root: Path):
|
|
22
|
+
"""
|
|
23
|
+
Initialize backup manager
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
project_root: Root directory of the project
|
|
27
|
+
"""
|
|
28
|
+
self.project_root = Path(project_root)
|
|
29
|
+
self.backup_base_dir = self.project_root / ".moai" / "backups"
|
|
30
|
+
self.backup_base_dir.mkdir(parents=True, exist_ok=True)
|
|
31
|
+
|
|
32
|
+
def create_backup(self, description: str = "migration") -> Path:
|
|
33
|
+
"""
|
|
34
|
+
Create a full backup of configuration files
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
description: Description of this backup
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
Path to the backup directory
|
|
41
|
+
"""
|
|
42
|
+
# Create timestamped backup directory
|
|
43
|
+
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
44
|
+
backup_dir = self.backup_base_dir / f"{description}_{timestamp}"
|
|
45
|
+
backup_dir.mkdir(parents=True, exist_ok=True)
|
|
46
|
+
|
|
47
|
+
logger.info(f"Creating backup at {backup_dir}")
|
|
48
|
+
|
|
49
|
+
# Files to backup
|
|
50
|
+
backup_targets = [
|
|
51
|
+
self.project_root / ".moai" / "config.json",
|
|
52
|
+
self.project_root / ".moai" / "config" / "config.json",
|
|
53
|
+
self.project_root / ".claude" / "statusline-config.yaml",
|
|
54
|
+
self.project_root / ".moai" / "config" / "statusline-config.yaml",
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
backed_up_files = []
|
|
58
|
+
|
|
59
|
+
for target in backup_targets:
|
|
60
|
+
if target.exists():
|
|
61
|
+
# Preserve relative path structure in backup
|
|
62
|
+
rel_path = target.relative_to(self.project_root)
|
|
63
|
+
backup_path = backup_dir / rel_path
|
|
64
|
+
|
|
65
|
+
# Create parent directories
|
|
66
|
+
backup_path.parent.mkdir(parents=True, exist_ok=True)
|
|
67
|
+
|
|
68
|
+
# Copy file
|
|
69
|
+
shutil.copy2(target, backup_path)
|
|
70
|
+
backed_up_files.append(str(rel_path))
|
|
71
|
+
logger.debug(f"Backed up: {rel_path}")
|
|
72
|
+
|
|
73
|
+
# Save backup metadata
|
|
74
|
+
metadata = {
|
|
75
|
+
"timestamp": timestamp,
|
|
76
|
+
"description": description,
|
|
77
|
+
"backed_up_files": backed_up_files,
|
|
78
|
+
"project_root": str(self.project_root),
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
metadata_path = backup_dir / "backup_metadata.json"
|
|
82
|
+
with open(metadata_path, "w") as f:
|
|
83
|
+
json.dump(metadata, f, indent=2)
|
|
84
|
+
|
|
85
|
+
logger.info(f"✅ Backup created successfully: {backup_dir}")
|
|
86
|
+
return backup_dir
|
|
87
|
+
|
|
88
|
+
def list_backups(self) -> List[Dict[str, str]]:
|
|
89
|
+
"""
|
|
90
|
+
List all available backups
|
|
91
|
+
|
|
92
|
+
Returns:
|
|
93
|
+
List of backup information dictionaries
|
|
94
|
+
"""
|
|
95
|
+
backups = []
|
|
96
|
+
|
|
97
|
+
if not self.backup_base_dir.exists():
|
|
98
|
+
return backups
|
|
99
|
+
|
|
100
|
+
for backup_dir in sorted(self.backup_base_dir.iterdir(), reverse=True):
|
|
101
|
+
if backup_dir.is_dir():
|
|
102
|
+
metadata_path = backup_dir / "backup_metadata.json"
|
|
103
|
+
if metadata_path.exists():
|
|
104
|
+
try:
|
|
105
|
+
with open(metadata_path, "r") as f:
|
|
106
|
+
metadata = json.load(f)
|
|
107
|
+
backups.append(
|
|
108
|
+
{
|
|
109
|
+
"path": str(backup_dir),
|
|
110
|
+
"timestamp": metadata.get("timestamp", "unknown"),
|
|
111
|
+
"description": metadata.get(
|
|
112
|
+
"description", "unknown"
|
|
113
|
+
),
|
|
114
|
+
"files": len(metadata.get("backed_up_files", [])),
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
except Exception as e:
|
|
118
|
+
logger.warning(f"Failed to read backup metadata: {e}")
|
|
119
|
+
|
|
120
|
+
return backups
|
|
121
|
+
|
|
122
|
+
def restore_backup(self, backup_path: Path) -> bool:
|
|
123
|
+
"""
|
|
124
|
+
Restore files from a backup
|
|
125
|
+
|
|
126
|
+
Args:
|
|
127
|
+
backup_path: Path to the backup directory
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
True if restore was successful, False otherwise
|
|
131
|
+
"""
|
|
132
|
+
backup_path = Path(backup_path)
|
|
133
|
+
|
|
134
|
+
if not backup_path.exists():
|
|
135
|
+
logger.error(f"Backup directory not found: {backup_path}")
|
|
136
|
+
return False
|
|
137
|
+
|
|
138
|
+
metadata_path = backup_path / "backup_metadata.json"
|
|
139
|
+
if not metadata_path.exists():
|
|
140
|
+
logger.error(f"Backup metadata not found: {metadata_path}")
|
|
141
|
+
return False
|
|
142
|
+
|
|
143
|
+
try:
|
|
144
|
+
# Read metadata
|
|
145
|
+
with open(metadata_path, "r") as f:
|
|
146
|
+
metadata = json.load(f)
|
|
147
|
+
|
|
148
|
+
logger.info(f"Restoring backup from {backup_path}")
|
|
149
|
+
|
|
150
|
+
# Restore each file
|
|
151
|
+
for rel_path in metadata.get("backed_up_files", []):
|
|
152
|
+
backup_file = backup_path / rel_path
|
|
153
|
+
target_file = self.project_root / rel_path
|
|
154
|
+
|
|
155
|
+
if backup_file.exists():
|
|
156
|
+
# Create parent directories
|
|
157
|
+
target_file.parent.mkdir(parents=True, exist_ok=True)
|
|
158
|
+
|
|
159
|
+
# Restore file
|
|
160
|
+
shutil.copy2(backup_file, target_file)
|
|
161
|
+
logger.debug(f"Restored: {rel_path}")
|
|
162
|
+
|
|
163
|
+
logger.info("✅ Backup restored successfully")
|
|
164
|
+
return True
|
|
165
|
+
|
|
166
|
+
except Exception as e:
|
|
167
|
+
logger.error(f"Failed to restore backup: {e}")
|
|
168
|
+
return False
|
|
169
|
+
|
|
170
|
+
def cleanup_old_backups(self, keep_count: int = 5) -> int:
|
|
171
|
+
"""
|
|
172
|
+
Clean up old backups, keeping only the most recent ones
|
|
173
|
+
|
|
174
|
+
Args:
|
|
175
|
+
keep_count: Number of recent backups to keep
|
|
176
|
+
|
|
177
|
+
Returns:
|
|
178
|
+
Number of backups deleted
|
|
179
|
+
"""
|
|
180
|
+
backups = self.list_backups()
|
|
181
|
+
|
|
182
|
+
if len(backups) <= keep_count:
|
|
183
|
+
return 0
|
|
184
|
+
|
|
185
|
+
deleted_count = 0
|
|
186
|
+
for backup_info in backups[keep_count:]:
|
|
187
|
+
backup_path = Path(backup_info["path"])
|
|
188
|
+
try:
|
|
189
|
+
shutil.rmtree(backup_path)
|
|
190
|
+
deleted_count += 1
|
|
191
|
+
logger.debug(f"Deleted old backup: {backup_path}")
|
|
192
|
+
except Exception as e:
|
|
193
|
+
logger.warning(f"Failed to delete backup {backup_path}: {e}")
|
|
194
|
+
|
|
195
|
+
logger.info(f"Cleaned up {deleted_count} old backups")
|
|
196
|
+
return deleted_count
|
|
197
|
+
|
|
198
|
+
def get_latest_backup(self) -> Optional[Path]:
|
|
199
|
+
"""
|
|
200
|
+
Get the most recent backup
|
|
201
|
+
|
|
202
|
+
Returns:
|
|
203
|
+
Path to the latest backup directory, or None if no backups exist
|
|
204
|
+
"""
|
|
205
|
+
backups = self.list_backups()
|
|
206
|
+
if backups:
|
|
207
|
+
return Path(backups[0]["path"])
|
|
208
|
+
return None
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"""
|
|
2
|
+
File migration module for MoAI-ADK version upgrades
|
|
3
|
+
|
|
4
|
+
Handles the actual file movement and directory creation
|
|
5
|
+
during migration processes.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import logging
|
|
9
|
+
import shutil
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Dict, List
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger(__name__)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class FileMigrator:
|
|
17
|
+
"""Handles file operations during migrations"""
|
|
18
|
+
|
|
19
|
+
def __init__(self, project_root: Path):
|
|
20
|
+
"""
|
|
21
|
+
Initialize file migrator
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
project_root: Root directory of the project
|
|
25
|
+
"""
|
|
26
|
+
self.project_root = Path(project_root)
|
|
27
|
+
self.moved_files: List[Dict[str, str]] = []
|
|
28
|
+
self.created_dirs: List[str] = []
|
|
29
|
+
|
|
30
|
+
def create_directory(self, directory: Path) -> bool:
|
|
31
|
+
"""
|
|
32
|
+
Create a directory if it doesn't exist
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
directory: Directory path to create
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
True if directory was created or already exists
|
|
39
|
+
"""
|
|
40
|
+
try:
|
|
41
|
+
directory = Path(directory)
|
|
42
|
+
directory.mkdir(parents=True, exist_ok=True)
|
|
43
|
+
self.created_dirs.append(str(directory))
|
|
44
|
+
logger.debug(f"Created directory: {directory}")
|
|
45
|
+
return True
|
|
46
|
+
except Exception as e:
|
|
47
|
+
logger.error(f"Failed to create directory {directory}: {e}")
|
|
48
|
+
return False
|
|
49
|
+
|
|
50
|
+
def move_file(
|
|
51
|
+
self, source: Path, destination: Path, copy_instead: bool = True
|
|
52
|
+
) -> bool:
|
|
53
|
+
"""
|
|
54
|
+
Move a file from source to destination
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
source: Source file path
|
|
58
|
+
destination: Destination file path
|
|
59
|
+
copy_instead: If True, copy instead of move (safer)
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
True if operation was successful
|
|
63
|
+
"""
|
|
64
|
+
source = Path(source)
|
|
65
|
+
destination = Path(destination)
|
|
66
|
+
|
|
67
|
+
if not source.exists():
|
|
68
|
+
logger.warning(f"Source file not found: {source}")
|
|
69
|
+
return False
|
|
70
|
+
|
|
71
|
+
if destination.exists():
|
|
72
|
+
logger.info(f"Destination already exists, skipping: {destination}")
|
|
73
|
+
return True
|
|
74
|
+
|
|
75
|
+
try:
|
|
76
|
+
# Ensure destination directory exists
|
|
77
|
+
destination.parent.mkdir(parents=True, exist_ok=True)
|
|
78
|
+
|
|
79
|
+
# Copy or move file
|
|
80
|
+
if copy_instead:
|
|
81
|
+
shutil.copy2(source, destination)
|
|
82
|
+
logger.debug(f"Copied: {source} → {destination}")
|
|
83
|
+
else:
|
|
84
|
+
shutil.move(str(source), str(destination))
|
|
85
|
+
logger.debug(f"Moved: {source} → {destination}")
|
|
86
|
+
|
|
87
|
+
# Record operation
|
|
88
|
+
self.moved_files.append({"from": str(source), "to": str(destination)})
|
|
89
|
+
|
|
90
|
+
return True
|
|
91
|
+
|
|
92
|
+
except Exception as e:
|
|
93
|
+
logger.error(f"Failed to move file {source} to {destination}: {e}")
|
|
94
|
+
return False
|
|
95
|
+
|
|
96
|
+
def delete_file(self, file_path: Path, safe: bool = True) -> bool:
|
|
97
|
+
"""
|
|
98
|
+
Delete a file
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
file_path: Path to the file to delete
|
|
102
|
+
safe: If True, only delete if it's a known safe file
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
True if deletion was successful
|
|
106
|
+
"""
|
|
107
|
+
file_path = Path(file_path)
|
|
108
|
+
|
|
109
|
+
if not file_path.exists():
|
|
110
|
+
logger.debug(f"File already deleted: {file_path}")
|
|
111
|
+
return True
|
|
112
|
+
|
|
113
|
+
# Safety check for safe mode
|
|
114
|
+
if safe:
|
|
115
|
+
safe_patterns = [
|
|
116
|
+
".moai/config.json",
|
|
117
|
+
".claude/statusline-config.yaml",
|
|
118
|
+
]
|
|
119
|
+
is_safe = any(
|
|
120
|
+
str(file_path.relative_to(self.project_root)).endswith(pattern)
|
|
121
|
+
for pattern in safe_patterns
|
|
122
|
+
)
|
|
123
|
+
if not is_safe:
|
|
124
|
+
logger.warning(f"Refusing to delete non-safe file: {file_path}")
|
|
125
|
+
return False
|
|
126
|
+
|
|
127
|
+
try:
|
|
128
|
+
file_path.unlink()
|
|
129
|
+
logger.debug(f"Deleted: {file_path}")
|
|
130
|
+
return True
|
|
131
|
+
except Exception as e:
|
|
132
|
+
logger.error(f"Failed to delete file {file_path}: {e}")
|
|
133
|
+
return False
|
|
134
|
+
|
|
135
|
+
def execute_migration_plan(self, plan: Dict[str, List]) -> Dict[str, any]:
|
|
136
|
+
"""
|
|
137
|
+
Execute a migration plan
|
|
138
|
+
|
|
139
|
+
Args:
|
|
140
|
+
plan: Migration plan dictionary with 'create', 'move', 'cleanup' keys
|
|
141
|
+
|
|
142
|
+
Returns:
|
|
143
|
+
Dictionary with execution results
|
|
144
|
+
"""
|
|
145
|
+
results = {
|
|
146
|
+
"success": True,
|
|
147
|
+
"created_dirs": 0,
|
|
148
|
+
"moved_files": 0,
|
|
149
|
+
"cleaned_files": 0,
|
|
150
|
+
"errors": [],
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
# Create directories
|
|
154
|
+
for directory in plan.get("create", []):
|
|
155
|
+
dir_path = self.project_root / directory
|
|
156
|
+
if self.create_directory(dir_path):
|
|
157
|
+
results["created_dirs"] += 1
|
|
158
|
+
else:
|
|
159
|
+
results["errors"].append(f"Failed to create directory: {directory}")
|
|
160
|
+
results["success"] = False
|
|
161
|
+
|
|
162
|
+
# Move files
|
|
163
|
+
for move_op in plan.get("move", []):
|
|
164
|
+
source = self.project_root / move_op["from"]
|
|
165
|
+
dest = self.project_root / move_op["to"]
|
|
166
|
+
|
|
167
|
+
if self.move_file(source, dest, copy_instead=True):
|
|
168
|
+
results["moved_files"] += 1
|
|
169
|
+
logger.info(
|
|
170
|
+
f"✅ {move_op['description']}: {move_op['from']} → {move_op['to']}"
|
|
171
|
+
)
|
|
172
|
+
else:
|
|
173
|
+
results["errors"].append(
|
|
174
|
+
f"Failed to move: {move_op['from']} → {move_op['to']}"
|
|
175
|
+
)
|
|
176
|
+
results["success"] = False
|
|
177
|
+
|
|
178
|
+
return results
|
|
179
|
+
|
|
180
|
+
def cleanup_old_files(self, cleanup_list: List[str], dry_run: bool = False) -> int:
|
|
181
|
+
"""
|
|
182
|
+
Clean up old files after successful migration
|
|
183
|
+
|
|
184
|
+
Args:
|
|
185
|
+
cleanup_list: List of file paths to clean up
|
|
186
|
+
dry_run: If True, only show what would be deleted
|
|
187
|
+
|
|
188
|
+
Returns:
|
|
189
|
+
Number of files cleaned up
|
|
190
|
+
"""
|
|
191
|
+
cleaned = 0
|
|
192
|
+
|
|
193
|
+
for file_path in cleanup_list:
|
|
194
|
+
full_path = self.project_root / file_path
|
|
195
|
+
|
|
196
|
+
if dry_run:
|
|
197
|
+
if full_path.exists():
|
|
198
|
+
logger.info(f"Would delete: {file_path}")
|
|
199
|
+
cleaned += 1
|
|
200
|
+
else:
|
|
201
|
+
if self.delete_file(full_path, safe=True):
|
|
202
|
+
logger.info(f"🗑️ Cleaned up: {file_path}")
|
|
203
|
+
cleaned += 1
|
|
204
|
+
|
|
205
|
+
return cleaned
|
|
206
|
+
|
|
207
|
+
def get_migration_summary(self) -> Dict[str, any]:
|
|
208
|
+
"""
|
|
209
|
+
Get summary of migration operations performed
|
|
210
|
+
|
|
211
|
+
Returns:
|
|
212
|
+
Dictionary with migration summary
|
|
213
|
+
"""
|
|
214
|
+
return {
|
|
215
|
+
"moved_files": len(self.moved_files),
|
|
216
|
+
"created_directories": len(self.created_dirs),
|
|
217
|
+
"operations": self.moved_files,
|
|
218
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Version detection module for MoAI-ADK projects
|
|
3
|
+
|
|
4
|
+
Detects the current version of a project and determines
|
|
5
|
+
which migrations are needed.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
import logging
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Dict, List, Optional
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger(__name__)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class VersionDetector:
|
|
17
|
+
"""Detects project version and migration requirements"""
|
|
18
|
+
|
|
19
|
+
def __init__(self, project_root: Path):
|
|
20
|
+
"""
|
|
21
|
+
Initialize version detector
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
project_root: Root directory of the project
|
|
25
|
+
"""
|
|
26
|
+
self.project_root = Path(project_root)
|
|
27
|
+
self.old_config = self.project_root / ".moai" / "config.json"
|
|
28
|
+
self.new_config = self.project_root / ".moai" / "config" / "config.json"
|
|
29
|
+
self.old_statusline = self.project_root / ".claude" / "statusline-config.yaml"
|
|
30
|
+
self.new_statusline = (
|
|
31
|
+
self.project_root / ".moai" / "config" / "statusline-config.yaml"
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
def detect_version(self) -> str:
|
|
35
|
+
"""
|
|
36
|
+
Detect current project version based on file structure
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
Version string (e.g., "0.23.0", "0.24.0+", "unknown")
|
|
40
|
+
"""
|
|
41
|
+
# Check if already migrated to v0.24.0+
|
|
42
|
+
if self.new_config.exists():
|
|
43
|
+
return "0.24.0+"
|
|
44
|
+
|
|
45
|
+
# Check if v0.23.0 or earlier
|
|
46
|
+
if self.old_config.exists():
|
|
47
|
+
try:
|
|
48
|
+
with open(self.old_config, "r") as f:
|
|
49
|
+
config_data = json.load(f)
|
|
50
|
+
# Try to get version from config
|
|
51
|
+
if "moai_version" in config_data:
|
|
52
|
+
return config_data["moai_version"]
|
|
53
|
+
return "0.23.0"
|
|
54
|
+
except Exception as e:
|
|
55
|
+
logger.warning(f"Failed to read old config: {e}")
|
|
56
|
+
return "0.23.0"
|
|
57
|
+
|
|
58
|
+
return "unknown"
|
|
59
|
+
|
|
60
|
+
def needs_migration(self) -> bool:
|
|
61
|
+
"""
|
|
62
|
+
Check if project needs migration
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
True if migration is needed, False otherwise
|
|
66
|
+
"""
|
|
67
|
+
version = self.detect_version()
|
|
68
|
+
if version == "unknown":
|
|
69
|
+
logger.info("Unknown version, assuming no migration needed")
|
|
70
|
+
return False
|
|
71
|
+
|
|
72
|
+
if version == "0.24.0+":
|
|
73
|
+
logger.info("Project already on v0.24.0+")
|
|
74
|
+
return False
|
|
75
|
+
|
|
76
|
+
# Version 0.23.0 or earlier needs migration
|
|
77
|
+
return True
|
|
78
|
+
|
|
79
|
+
def get_migration_plan(self) -> Dict[str, List[Dict[str, str]]]:
|
|
80
|
+
"""
|
|
81
|
+
Get detailed migration plan
|
|
82
|
+
|
|
83
|
+
Returns:
|
|
84
|
+
Dictionary with migration actions:
|
|
85
|
+
{
|
|
86
|
+
"move": [{"from": "...", "to": "..."}],
|
|
87
|
+
"create": ["directory1", "directory2"],
|
|
88
|
+
"cleanup": ["old_file1", "old_file2"]
|
|
89
|
+
}
|
|
90
|
+
"""
|
|
91
|
+
plan = {"move": [], "create": [], "cleanup": []}
|
|
92
|
+
|
|
93
|
+
if not self.needs_migration():
|
|
94
|
+
return plan
|
|
95
|
+
|
|
96
|
+
# Create config directory
|
|
97
|
+
plan["create"].append(str(self.project_root / ".moai" / "config"))
|
|
98
|
+
|
|
99
|
+
# Move config.json
|
|
100
|
+
if self.old_config.exists() and not self.new_config.exists():
|
|
101
|
+
plan["move"].append(
|
|
102
|
+
{
|
|
103
|
+
"from": str(self.old_config.relative_to(self.project_root)),
|
|
104
|
+
"to": str(self.new_config.relative_to(self.project_root)),
|
|
105
|
+
"description": "Main configuration file",
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
# Move statusline-config.yaml
|
|
110
|
+
if self.old_statusline.exists() and not self.new_statusline.exists():
|
|
111
|
+
plan["move"].append(
|
|
112
|
+
{
|
|
113
|
+
"from": str(self.old_statusline.relative_to(self.project_root)),
|
|
114
|
+
"to": str(self.new_statusline.relative_to(self.project_root)),
|
|
115
|
+
"description": "Statusline configuration",
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
# Cleanup old files (after successful migration)
|
|
120
|
+
if self.old_config.exists():
|
|
121
|
+
plan["cleanup"].append(str(self.old_config.relative_to(self.project_root)))
|
|
122
|
+
if self.old_statusline.exists():
|
|
123
|
+
plan["cleanup"].append(
|
|
124
|
+
str(self.old_statusline.relative_to(self.project_root))
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
return plan
|
|
128
|
+
|
|
129
|
+
def get_version_info(self) -> Dict[str, Optional[str]]:
|
|
130
|
+
"""
|
|
131
|
+
Get detailed version information
|
|
132
|
+
|
|
133
|
+
Returns:
|
|
134
|
+
Dictionary with version details
|
|
135
|
+
"""
|
|
136
|
+
return {
|
|
137
|
+
"detected_version": self.detect_version(),
|
|
138
|
+
"needs_migration": self.needs_migration(),
|
|
139
|
+
"has_old_config": self.old_config.exists(),
|
|
140
|
+
"has_new_config": self.new_config.exists(),
|
|
141
|
+
"has_old_statusline": self.old_statusline.exists(),
|
|
142
|
+
"has_new_statusline": self.new_statusline.exists(),
|
|
143
|
+
}
|