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,725 @@
|
|
|
1
|
+
"""
|
|
2
|
+
TRUST 4 Principles Implementation
|
|
3
|
+
|
|
4
|
+
Comprehensive implementation of TRUST principles for MoAI-ADK:
|
|
5
|
+
- Test First: Comprehensive testing strategy
|
|
6
|
+
- Readable: Code clarity and maintainability
|
|
7
|
+
- Unified: Consistent architecture and patterns
|
|
8
|
+
- Secured: Security best practices and validation
|
|
9
|
+
|
|
10
|
+
Features:
|
|
11
|
+
- Automated principle scoring
|
|
12
|
+
- Validation checklists
|
|
13
|
+
- Quality gate enforcement
|
|
14
|
+
- Enterprise-grade security
|
|
15
|
+
- Complete audit trails
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
import re
|
|
19
|
+
from dataclasses import dataclass, field
|
|
20
|
+
from enum import Enum
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
from typing import Any, Dict, List
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class TrustPrinciple(Enum):
|
|
26
|
+
"""TRUST 4 principles enumeration"""
|
|
27
|
+
|
|
28
|
+
TEST_FIRST = "test_first"
|
|
29
|
+
READABLE = "readable"
|
|
30
|
+
UNIFIED = "unified"
|
|
31
|
+
SECURED = "secured"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class ComplianceLevel(Enum):
|
|
35
|
+
"""Compliance level enumeration"""
|
|
36
|
+
|
|
37
|
+
CRITICAL = "critical"
|
|
38
|
+
HIGH = "high"
|
|
39
|
+
MEDIUM = "medium"
|
|
40
|
+
LOW = "low"
|
|
41
|
+
NONE = "none"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@dataclass
|
|
45
|
+
class PrincipleScore:
|
|
46
|
+
"""Individual principle scoring"""
|
|
47
|
+
|
|
48
|
+
principle: TrustPrinciple
|
|
49
|
+
score: float # 0.0 - 100.0
|
|
50
|
+
compliance_level: ComplianceLevel
|
|
51
|
+
issues: List[str] = field(default_factory=list)
|
|
52
|
+
recommendations: List[str] = field(default_factory=list)
|
|
53
|
+
metrics: Dict[str, Any] = field(default_factory=dict)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@dataclass
|
|
57
|
+
class TrustAssessment:
|
|
58
|
+
"""Complete TRUST assessment"""
|
|
59
|
+
|
|
60
|
+
principle_scores: Dict[TrustPrinciple, PrincipleScore]
|
|
61
|
+
overall_score: float
|
|
62
|
+
compliance_level: ComplianceLevel
|
|
63
|
+
passed_checks: int
|
|
64
|
+
total_checks: int
|
|
65
|
+
audit_trail: List[Dict[str, Any]] = field(default_factory=list)
|
|
66
|
+
timestamp: str = field(default_factory=lambda: "2025-11-11")
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class TrustPrinciplesValidator:
|
|
70
|
+
"""TRUST 4 principles validator and analyzer"""
|
|
71
|
+
|
|
72
|
+
def __init__(self):
|
|
73
|
+
self.principle_weights = {
|
|
74
|
+
TrustPrinciple.TEST_FIRST: 0.30,
|
|
75
|
+
TrustPrinciple.READABLE: 0.25,
|
|
76
|
+
TrustPrinciple.UNIFIED: 0.25,
|
|
77
|
+
TrustPrinciple.SECURED: 0.20,
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
# Test First validation patterns
|
|
81
|
+
self.test_patterns = {
|
|
82
|
+
"unit_tests": r"def test_.*\(|class Test.*:",
|
|
83
|
+
"integration_tests": r"@integration_test|test_integration_",
|
|
84
|
+
"coverage_directive": r"# pragma: cover|@pytest\.mark\.cover",
|
|
85
|
+
"assertion_count": r"\bassert\b.*>=|\bshould_\w+\(",
|
|
86
|
+
"test_docstrings": r'def test_\w+.*\n\s*""".*?"""',
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
# Readability validation patterns
|
|
90
|
+
self.readability_patterns = {
|
|
91
|
+
"function_length": r"def \w+\([^)]*\):(.*\n){1,50}",
|
|
92
|
+
"class_length": r"class \w+:",
|
|
93
|
+
"variable_naming": r"\b[a-z_][a-z0-9_]*\b",
|
|
94
|
+
"constant_naming": r"\b[A-Z_][A-Z0-9_]*\b",
|
|
95
|
+
"docstrings": r'def \w+.*\n\s*""".*?"""',
|
|
96
|
+
"type_hints": r": \w+\[?\]?]|: Optional\[|: Dict\[|: List\[",
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
# Unified validation patterns
|
|
100
|
+
self.unified_patterns = {
|
|
101
|
+
"import_structure": r"^(import|from)\s+\w+",
|
|
102
|
+
"naming_convention": r"\b\w+(?:Error|Exception|Manager|Service|Handler|Validator)\b",
|
|
103
|
+
"file_structure": r"^(class|def)\s+",
|
|
104
|
+
"error_handling": r"except\s+\w+:|raise\s+\w+\(",
|
|
105
|
+
"logging_pattern": r"logger\.\w+|logging\.\w+",
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
# Security validation patterns
|
|
109
|
+
self.security_patterns = {
|
|
110
|
+
"sql_injection": r'(cursor\.execute|db\.query)\s*\(\s*["\'][^"\']*%[^"\']*["\']',
|
|
111
|
+
"xss_prevention": r"escape\(|sanitize\(|validate\(",
|
|
112
|
+
"auth_check": r"@login_required|@permission_required|is_authenticated",
|
|
113
|
+
"input_validation": r"re\.match\(|validator\.|form\.is_valid\(\)",
|
|
114
|
+
"secret_management": r"\.env|SECRET_KEY|API_KEY|PASSWORD",
|
|
115
|
+
"https_enforcement": r"https://|SECURE_SSL_REDIRECT|HSTS",
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
# Trackability validation patterns
|
|
119
|
+
self.trackability_patterns = {
|
|
120
|
+
"commit_messages": r"^(feat|fix|docs|style|refactor|test|chop)\(",
|
|
121
|
+
"issue_references": r"#\d+|closes #\d+|fixes #\d+",
|
|
122
|
+
"documentation_links": r"\[.*?\]\(.*?\.md\)",
|
|
123
|
+
"version_tracking": r"v\d+\.\d+\.\d+|\d+\.\d+\.\d+",
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
def validate_test_first(self, project_path: str) -> PrincipleScore:
|
|
127
|
+
"""Validate Test First principle"""
|
|
128
|
+
issues = []
|
|
129
|
+
recommendations = []
|
|
130
|
+
metrics = {}
|
|
131
|
+
|
|
132
|
+
try:
|
|
133
|
+
project_dir = Path(project_path)
|
|
134
|
+
python_files = list(project_dir.rglob("*.py"))
|
|
135
|
+
|
|
136
|
+
test_files = [f for f in python_files if f.name.startswith("test_")]
|
|
137
|
+
source_files = [f for f in python_files if not f.name.startswith("test_")]
|
|
138
|
+
|
|
139
|
+
# Test file ratio
|
|
140
|
+
test_ratio = len(test_files) / max(len(source_files), 1)
|
|
141
|
+
|
|
142
|
+
# Analyze test coverage indicators
|
|
143
|
+
total_test_patterns = 0
|
|
144
|
+
found_test_patterns = 0
|
|
145
|
+
|
|
146
|
+
for file_path in python_files:
|
|
147
|
+
try:
|
|
148
|
+
content = file_path.read_text(encoding="utf-8")
|
|
149
|
+
|
|
150
|
+
for pattern_name, pattern in self.test_patterns.items():
|
|
151
|
+
total_test_patterns += 1
|
|
152
|
+
if re.search(pattern, content, re.MULTILINE | re.DOTALL):
|
|
153
|
+
found_test_patterns += 1
|
|
154
|
+
except Exception as e:
|
|
155
|
+
issues.append(f"Error analyzing {file_path}: {str(e)}")
|
|
156
|
+
|
|
157
|
+
pattern_coverage = found_test_patterns / max(total_test_patterns, 1)
|
|
158
|
+
|
|
159
|
+
# Calculate score
|
|
160
|
+
score = min(100, (test_ratio * 30) + (pattern_coverage * 70))
|
|
161
|
+
|
|
162
|
+
metrics = {
|
|
163
|
+
"test_files": len(test_files),
|
|
164
|
+
"source_files": len(source_files),
|
|
165
|
+
"test_ratio": round(test_ratio, 2),
|
|
166
|
+
"pattern_coverage": round(pattern_coverage, 2),
|
|
167
|
+
"total_patterns": total_test_patterns,
|
|
168
|
+
"found_patterns": found_test_patterns,
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
# Generate recommendations
|
|
172
|
+
if test_ratio < 0.5:
|
|
173
|
+
recommendations.append(
|
|
174
|
+
"Increase test file coverage (aim for 1:1 ratio with source files)"
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
if pattern_coverage < 0.7:
|
|
178
|
+
recommendations.append("Add comprehensive test patterns and assertions")
|
|
179
|
+
|
|
180
|
+
if not any("integration" in str(issue) for issue in issues):
|
|
181
|
+
recommendations.append("Add integration tests for critical workflows")
|
|
182
|
+
|
|
183
|
+
# Determine compliance level
|
|
184
|
+
if score >= 90:
|
|
185
|
+
compliance = ComplianceLevel.CRITICAL
|
|
186
|
+
elif score >= 75:
|
|
187
|
+
compliance = ComplianceLevel.HIGH
|
|
188
|
+
elif score >= 60:
|
|
189
|
+
compliance = ComplianceLevel.MEDIUM
|
|
190
|
+
elif score >= 40:
|
|
191
|
+
compliance = ComplianceLevel.LOW
|
|
192
|
+
else:
|
|
193
|
+
compliance = ComplianceLevel.NONE
|
|
194
|
+
|
|
195
|
+
except Exception as e:
|
|
196
|
+
issues.append(f"Error validating Test First principle: {str(e)}")
|
|
197
|
+
score = 0
|
|
198
|
+
compliance = ComplianceLevel.NONE
|
|
199
|
+
|
|
200
|
+
return PrincipleScore(
|
|
201
|
+
principle=TrustPrinciple.TEST_FIRST,
|
|
202
|
+
score=round(score, 2),
|
|
203
|
+
compliance_level=compliance,
|
|
204
|
+
issues=issues,
|
|
205
|
+
recommendations=recommendations,
|
|
206
|
+
metrics=metrics,
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
def validate_readable(self, project_path: str) -> PrincipleScore:
|
|
210
|
+
"""Validate Readable principle"""
|
|
211
|
+
issues = []
|
|
212
|
+
recommendations = []
|
|
213
|
+
metrics = {}
|
|
214
|
+
|
|
215
|
+
try:
|
|
216
|
+
project_dir = Path(project_path)
|
|
217
|
+
python_files = list(project_dir.rglob("*.py"))
|
|
218
|
+
|
|
219
|
+
total_functions = 0
|
|
220
|
+
long_functions = 0
|
|
221
|
+
functions_with_docstrings = 0
|
|
222
|
+
functions_with_type_hints = 0
|
|
223
|
+
total_classes = 0
|
|
224
|
+
classes_with_docstrings = 0
|
|
225
|
+
|
|
226
|
+
for file_path in python_files:
|
|
227
|
+
try:
|
|
228
|
+
content = file_path.read_text(encoding="utf-8")
|
|
229
|
+
lines = content.split("\n")
|
|
230
|
+
|
|
231
|
+
# Analyze functions
|
|
232
|
+
function_matches = re.finditer(r"def\s+(\w+)\([^)]*\):", content)
|
|
233
|
+
for match in function_matches:
|
|
234
|
+
total_functions += 1
|
|
235
|
+
|
|
236
|
+
# Count lines in function
|
|
237
|
+
func_start = match.start()
|
|
238
|
+
func_lines = 0
|
|
239
|
+
indent_level = None
|
|
240
|
+
|
|
241
|
+
for i, line in enumerate(
|
|
242
|
+
content[func_start:].split("\n")[1:], 1
|
|
243
|
+
):
|
|
244
|
+
if line.strip() == "":
|
|
245
|
+
continue
|
|
246
|
+
|
|
247
|
+
current_indent = len(line) - len(line.lstrip())
|
|
248
|
+
if indent_level is None:
|
|
249
|
+
indent_level = current_indent
|
|
250
|
+
elif current_indent <= indent_level and line.strip():
|
|
251
|
+
break
|
|
252
|
+
func_lines += 1
|
|
253
|
+
|
|
254
|
+
if func_lines > 50:
|
|
255
|
+
long_functions += 1
|
|
256
|
+
issues.append(
|
|
257
|
+
f"Long function in {file_path.name}: {match.group(1)} ({func_lines} lines)"
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
# Check for docstring
|
|
261
|
+
func_content = content[
|
|
262
|
+
func_start : func_start + 1000
|
|
263
|
+
] # Check next 1000 chars
|
|
264
|
+
if '"""' in func_content.split("\n")[1:5]:
|
|
265
|
+
functions_with_docstrings += 1
|
|
266
|
+
|
|
267
|
+
# Check for type hints
|
|
268
|
+
if "->" in match.group(0) or ":" in match.group(0):
|
|
269
|
+
functions_with_type_hints += 1
|
|
270
|
+
|
|
271
|
+
# Analyze classes
|
|
272
|
+
class_matches = re.finditer(r"class\s+(\w+)[\(\:]:", content)
|
|
273
|
+
for match in class_matches:
|
|
274
|
+
total_classes += 1
|
|
275
|
+
|
|
276
|
+
# Check for docstring
|
|
277
|
+
class_start = match.start()
|
|
278
|
+
class_content = content[
|
|
279
|
+
class_start : class_start + 500
|
|
280
|
+
] # Check next 500 chars
|
|
281
|
+
if '"""' in class_content.split("\n")[1:3]:
|
|
282
|
+
classes_with_docstrings += 1
|
|
283
|
+
|
|
284
|
+
except Exception as e:
|
|
285
|
+
issues.append(f"Error analyzing {file_path}: {str(e)}")
|
|
286
|
+
|
|
287
|
+
# Calculate scores
|
|
288
|
+
docstring_ratio = functions_with_docstrings / max(total_functions, 1)
|
|
289
|
+
type_hint_ratio = functions_with_type_hints / max(total_functions, 1)
|
|
290
|
+
long_function_ratio = 1 - (long_functions / max(total_functions, 1))
|
|
291
|
+
class_docstring_ratio = classes_with_docstrings / max(total_classes, 1)
|
|
292
|
+
|
|
293
|
+
score = (
|
|
294
|
+
docstring_ratio * 30
|
|
295
|
+
+ type_hint_ratio * 25
|
|
296
|
+
+ long_function_ratio * 25
|
|
297
|
+
+ class_docstring_ratio * 20
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
metrics = {
|
|
301
|
+
"total_functions": total_functions,
|
|
302
|
+
"functions_with_docstrings": functions_with_docstrings,
|
|
303
|
+
"functions_with_type_hints": functions_with_type_hints,
|
|
304
|
+
"long_functions": long_functions,
|
|
305
|
+
"total_classes": total_classes,
|
|
306
|
+
"classes_with_docstrings": classes_with_docstrings,
|
|
307
|
+
"docstring_ratio": round(docstring_ratio, 2),
|
|
308
|
+
"type_hint_ratio": round(type_hint_ratio, 2),
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
# Generate recommendations
|
|
312
|
+
if docstring_ratio < 0.8:
|
|
313
|
+
recommendations.append("Add docstrings to all functions and methods")
|
|
314
|
+
|
|
315
|
+
if type_hint_ratio < 0.8:
|
|
316
|
+
recommendations.append("Add type hints for better code clarity")
|
|
317
|
+
|
|
318
|
+
if long_function_ratio < 0.9:
|
|
319
|
+
recommendations.append("Refactor long functions (keep under 50 lines)")
|
|
320
|
+
|
|
321
|
+
# Determine compliance level
|
|
322
|
+
if score >= 90:
|
|
323
|
+
compliance = ComplianceLevel.CRITICAL
|
|
324
|
+
elif score >= 80:
|
|
325
|
+
compliance = ComplianceLevel.HIGH
|
|
326
|
+
elif score >= 70:
|
|
327
|
+
compliance = ComplianceLevel.MEDIUM
|
|
328
|
+
elif score >= 60:
|
|
329
|
+
compliance = ComplianceLevel.LOW
|
|
330
|
+
else:
|
|
331
|
+
compliance = ComplianceLevel.NONE
|
|
332
|
+
|
|
333
|
+
except Exception as e:
|
|
334
|
+
issues.append(f"Error validating Readable principle: {str(e)}")
|
|
335
|
+
score = 0
|
|
336
|
+
compliance = ComplianceLevel.NONE
|
|
337
|
+
|
|
338
|
+
return PrincipleScore(
|
|
339
|
+
principle=TrustPrinciple.READABLE,
|
|
340
|
+
score=round(score, 2),
|
|
341
|
+
compliance_level=compliance,
|
|
342
|
+
issues=issues,
|
|
343
|
+
recommendations=recommendations,
|
|
344
|
+
metrics=metrics,
|
|
345
|
+
)
|
|
346
|
+
|
|
347
|
+
def validate_unified(self, project_path: str) -> PrincipleScore:
|
|
348
|
+
"""Validate Unified principle"""
|
|
349
|
+
issues = []
|
|
350
|
+
recommendations = []
|
|
351
|
+
metrics = {}
|
|
352
|
+
|
|
353
|
+
try:
|
|
354
|
+
project_dir = Path(project_path)
|
|
355
|
+
python_files = list(project_dir.rglob("*.py"))
|
|
356
|
+
|
|
357
|
+
unified_patterns_found = 0
|
|
358
|
+
total_patterns = len(self.unified_patterns)
|
|
359
|
+
file_count = len(python_files)
|
|
360
|
+
|
|
361
|
+
naming_violations = 0
|
|
362
|
+
error_handling_count = 0
|
|
363
|
+
logging_count = 0
|
|
364
|
+
|
|
365
|
+
for file_path in python_files:
|
|
366
|
+
try:
|
|
367
|
+
content = file_path.read_text(encoding="utf-8")
|
|
368
|
+
|
|
369
|
+
# Check unified patterns
|
|
370
|
+
for pattern_name, pattern in self.unified_patterns.items():
|
|
371
|
+
if re.search(pattern, content, re.MULTILINE):
|
|
372
|
+
unified_patterns_found += 1
|
|
373
|
+
|
|
374
|
+
# Check naming violations
|
|
375
|
+
if re.search(
|
|
376
|
+
r"class\s+[a-z]", content
|
|
377
|
+
): # Class starting with lowercase
|
|
378
|
+
naming_violations += 1
|
|
379
|
+
|
|
380
|
+
# Count error handling
|
|
381
|
+
error_matches = re.findall(r"except\s+\w+:", content)
|
|
382
|
+
error_handling_count += len(error_matches)
|
|
383
|
+
|
|
384
|
+
# Count logging usage
|
|
385
|
+
logging_matches = re.findall(r"logger\.\w+|logging\.\w+", content)
|
|
386
|
+
logging_count += len(logging_matches)
|
|
387
|
+
|
|
388
|
+
except Exception as e:
|
|
389
|
+
issues.append(f"Error analyzing {file_path}: {str(e)}")
|
|
390
|
+
|
|
391
|
+
# Calculate scores
|
|
392
|
+
pattern_coverage = unified_patterns_found / (total_patterns * file_count)
|
|
393
|
+
error_handling_ratio = error_handling_count / max(file_count, 1)
|
|
394
|
+
logging_ratio = logging_count / max(file_count, 1)
|
|
395
|
+
naming_quality = 1 - (naming_violations / max(file_count, 1))
|
|
396
|
+
|
|
397
|
+
score = (
|
|
398
|
+
pattern_coverage * 40
|
|
399
|
+
+ error_handling_ratio * 25
|
|
400
|
+
+ logging_ratio * 20
|
|
401
|
+
+ naming_quality * 15
|
|
402
|
+
)
|
|
403
|
+
|
|
404
|
+
metrics = {
|
|
405
|
+
"files_analyzed": file_count,
|
|
406
|
+
"unified_patterns_found": unified_patterns_found,
|
|
407
|
+
"pattern_coverage": round(pattern_coverage, 2),
|
|
408
|
+
"error_handling_count": error_handling_count,
|
|
409
|
+
"logging_count": logging_count,
|
|
410
|
+
"naming_violations": naming_violations,
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
# Generate recommendations
|
|
414
|
+
if pattern_coverage < 0.7:
|
|
415
|
+
recommendations.append(
|
|
416
|
+
"Improve code structure consistency across files"
|
|
417
|
+
)
|
|
418
|
+
|
|
419
|
+
if error_handling_count < file_count * 0.5:
|
|
420
|
+
recommendations.append("Add comprehensive error handling")
|
|
421
|
+
|
|
422
|
+
if logging_count < file_count * 0.3:
|
|
423
|
+
recommendations.append("Add proper logging for better debugging")
|
|
424
|
+
|
|
425
|
+
# Determine compliance level
|
|
426
|
+
if score >= 85:
|
|
427
|
+
compliance = ComplianceLevel.CRITICAL
|
|
428
|
+
elif score >= 75:
|
|
429
|
+
compliance = ComplianceLevel.HIGH
|
|
430
|
+
elif score >= 65:
|
|
431
|
+
compliance = ComplianceLevel.MEDIUM
|
|
432
|
+
elif score >= 55:
|
|
433
|
+
compliance = ComplianceLevel.LOW
|
|
434
|
+
else:
|
|
435
|
+
compliance = ComplianceLevel.NONE
|
|
436
|
+
|
|
437
|
+
except Exception as e:
|
|
438
|
+
issues.append(f"Error validating Unified principle: {str(e)}")
|
|
439
|
+
score = 0
|
|
440
|
+
compliance = ComplianceLevel.NONE
|
|
441
|
+
|
|
442
|
+
return PrincipleScore(
|
|
443
|
+
principle=TrustPrinciple.UNIFIED,
|
|
444
|
+
score=round(score, 2),
|
|
445
|
+
compliance_level=compliance,
|
|
446
|
+
issues=issues,
|
|
447
|
+
recommendations=recommendations,
|
|
448
|
+
metrics=metrics,
|
|
449
|
+
)
|
|
450
|
+
|
|
451
|
+
def validate_secured(self, project_path: str) -> PrincipleScore:
|
|
452
|
+
"""Validate Secured principle"""
|
|
453
|
+
issues = []
|
|
454
|
+
recommendations = []
|
|
455
|
+
metrics = {}
|
|
456
|
+
|
|
457
|
+
try:
|
|
458
|
+
project_dir = Path(project_path)
|
|
459
|
+
python_files = list(project_dir.rglob("*.py"))
|
|
460
|
+
|
|
461
|
+
security_issues = []
|
|
462
|
+
security_patterns_found = 0
|
|
463
|
+
high_risk_patterns = 0
|
|
464
|
+
|
|
465
|
+
for file_path in python_files:
|
|
466
|
+
try:
|
|
467
|
+
content = file_path.read_text(encoding="utf-8")
|
|
468
|
+
|
|
469
|
+
# Check for security patterns
|
|
470
|
+
for pattern_name, pattern in self.security_patterns.items():
|
|
471
|
+
matches = re.findall(pattern, content, re.MULTILINE | re.DOTALL)
|
|
472
|
+
if matches:
|
|
473
|
+
security_patterns_found += len(matches)
|
|
474
|
+
|
|
475
|
+
if pattern_name in ["sql_injection", "secret_management"]:
|
|
476
|
+
high_risk_patterns += len(matches)
|
|
477
|
+
for match in matches:
|
|
478
|
+
security_issues.append(
|
|
479
|
+
f"High-risk pattern in {file_path.name}: {pattern_name}"
|
|
480
|
+
)
|
|
481
|
+
|
|
482
|
+
# Check for hardcoded secrets (basic pattern)
|
|
483
|
+
secret_patterns = [
|
|
484
|
+
r'password\s*=\s*["\'][^"\']+["\']',
|
|
485
|
+
r'api_key\s*=\s*["\'][^"\']+["\']',
|
|
486
|
+
r'secret\s*=\s*["\'][^"\']+["\']',
|
|
487
|
+
r'token\s*=\s*["\'][^"\']+["\']',
|
|
488
|
+
]
|
|
489
|
+
|
|
490
|
+
for pattern in secret_patterns:
|
|
491
|
+
if re.search(pattern, content, re.IGNORECASE):
|
|
492
|
+
security_issues.append(
|
|
493
|
+
f"Potential hardcoded secret in {file_path.name}"
|
|
494
|
+
)
|
|
495
|
+
high_risk_patterns += 1
|
|
496
|
+
|
|
497
|
+
except Exception as e:
|
|
498
|
+
issues.append(f"Error analyzing {file_path}: {str(e)}")
|
|
499
|
+
|
|
500
|
+
# Calculate security score
|
|
501
|
+
if high_risk_patterns > 0:
|
|
502
|
+
base_score = max(0, 100 - (high_risk_patterns * 20))
|
|
503
|
+
else:
|
|
504
|
+
base_score = 100
|
|
505
|
+
|
|
506
|
+
# Bonus points for security best practices
|
|
507
|
+
security_bonus = 0
|
|
508
|
+
if security_patterns_found > 0:
|
|
509
|
+
security_bonus = min(20, security_patterns_found * 2)
|
|
510
|
+
|
|
511
|
+
score = min(100, base_score + security_bonus)
|
|
512
|
+
|
|
513
|
+
metrics = {
|
|
514
|
+
"security_patterns_found": security_patterns_found,
|
|
515
|
+
"high_risk_patterns": high_risk_patterns,
|
|
516
|
+
"security_issues": len(security_issues),
|
|
517
|
+
"files_analyzed": len(python_files),
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
# Generate recommendations
|
|
521
|
+
if high_risk_patterns > 0:
|
|
522
|
+
recommendations.append(
|
|
523
|
+
"Address high-risk security patterns immediately"
|
|
524
|
+
)
|
|
525
|
+
issues.extend(security_issues[:5]) # Add first 5 issues
|
|
526
|
+
|
|
527
|
+
if security_patterns_found < 10:
|
|
528
|
+
recommendations.append("Implement more security validation patterns")
|
|
529
|
+
|
|
530
|
+
recommendations.extend(
|
|
531
|
+
[
|
|
532
|
+
"Use environment variables for secrets",
|
|
533
|
+
"Implement input validation and sanitization",
|
|
534
|
+
"Add authentication and authorization checks",
|
|
535
|
+
]
|
|
536
|
+
)
|
|
537
|
+
|
|
538
|
+
# Determine compliance level
|
|
539
|
+
if score >= 95:
|
|
540
|
+
compliance = ComplianceLevel.CRITICAL
|
|
541
|
+
elif score >= 85:
|
|
542
|
+
compliance = ComplianceLevel.HIGH
|
|
543
|
+
elif score >= 75:
|
|
544
|
+
compliance = ComplianceLevel.MEDIUM
|
|
545
|
+
elif score >= 60:
|
|
546
|
+
compliance = ComplianceLevel.LOW
|
|
547
|
+
else:
|
|
548
|
+
compliance = ComplianceLevel.NONE
|
|
549
|
+
|
|
550
|
+
except Exception as e:
|
|
551
|
+
issues.append(f"Error validating Secured principle: {str(e)}")
|
|
552
|
+
score = 0
|
|
553
|
+
compliance = ComplianceLevel.NONE
|
|
554
|
+
|
|
555
|
+
return PrincipleScore(
|
|
556
|
+
principle=TrustPrinciple.SECURED,
|
|
557
|
+
score=round(score, 2),
|
|
558
|
+
compliance_level=compliance,
|
|
559
|
+
issues=issues,
|
|
560
|
+
recommendations=recommendations,
|
|
561
|
+
metrics=metrics,
|
|
562
|
+
)
|
|
563
|
+
|
|
564
|
+
def assess_project(self, project_path: str) -> TrustAssessment:
|
|
565
|
+
"""Perform complete TRUST assessment"""
|
|
566
|
+
principle_scores = {}
|
|
567
|
+
|
|
568
|
+
# Validate each principle
|
|
569
|
+
principle_scores[TrustPrinciple.TEST_FIRST] = self.validate_test_first(
|
|
570
|
+
project_path
|
|
571
|
+
)
|
|
572
|
+
principle_scores[TrustPrinciple.READABLE] = self.validate_readable(project_path)
|
|
573
|
+
principle_scores[TrustPrinciple.UNIFIED] = self.validate_unified(project_path)
|
|
574
|
+
principle_scores[TrustPrinciple.SECURED] = self.validate_secured(project_path)
|
|
575
|
+
|
|
576
|
+
# Calculate overall score
|
|
577
|
+
overall_score = 0
|
|
578
|
+
for principle, score in principle_scores.items():
|
|
579
|
+
weight = self.principle_weights[principle]
|
|
580
|
+
overall_score += score.score * weight
|
|
581
|
+
|
|
582
|
+
# Calculate passed checks
|
|
583
|
+
total_checks = sum(len(score.metrics) for score in principle_scores.values())
|
|
584
|
+
passed_checks = sum(
|
|
585
|
+
sum(
|
|
586
|
+
1
|
|
587
|
+
for metric_value in score.metrics.values()
|
|
588
|
+
if isinstance(metric_value, (int, float)) and metric_value > 0
|
|
589
|
+
)
|
|
590
|
+
for score in principle_scores.values()
|
|
591
|
+
)
|
|
592
|
+
|
|
593
|
+
# Determine overall compliance level
|
|
594
|
+
score_levels = [score.compliance_level for score in principle_scores.values()]
|
|
595
|
+
if all(level == ComplianceLevel.CRITICAL for level in score_levels):
|
|
596
|
+
overall_compliance = ComplianceLevel.CRITICAL
|
|
597
|
+
elif all(
|
|
598
|
+
level in [ComplianceLevel.CRITICAL, ComplianceLevel.HIGH]
|
|
599
|
+
for level in score_levels
|
|
600
|
+
):
|
|
601
|
+
overall_compliance = ComplianceLevel.HIGH
|
|
602
|
+
elif all(
|
|
603
|
+
level
|
|
604
|
+
in [ComplianceLevel.CRITICAL, ComplianceLevel.HIGH, ComplianceLevel.MEDIUM]
|
|
605
|
+
for level in score_levels
|
|
606
|
+
):
|
|
607
|
+
overall_compliance = ComplianceLevel.MEDIUM
|
|
608
|
+
elif all(level != ComplianceLevel.NONE for level in score_levels):
|
|
609
|
+
overall_compliance = ComplianceLevel.LOW
|
|
610
|
+
else:
|
|
611
|
+
overall_compliance = ComplianceLevel.NONE
|
|
612
|
+
|
|
613
|
+
# Create audit trail
|
|
614
|
+
audit_trail = []
|
|
615
|
+
for principle, score in principle_scores.items():
|
|
616
|
+
audit_trail.append(
|
|
617
|
+
{
|
|
618
|
+
"principle": principle.value,
|
|
619
|
+
"score": score.score,
|
|
620
|
+
"compliance_level": score.compliance_level.value,
|
|
621
|
+
"issues_count": len(score.issues),
|
|
622
|
+
"recommendations_count": len(score.recommendations),
|
|
623
|
+
"metrics": score.metrics,
|
|
624
|
+
}
|
|
625
|
+
)
|
|
626
|
+
|
|
627
|
+
return TrustAssessment(
|
|
628
|
+
principle_scores=principle_scores,
|
|
629
|
+
overall_score=round(overall_score, 2),
|
|
630
|
+
compliance_level=overall_compliance,
|
|
631
|
+
passed_checks=passed_checks,
|
|
632
|
+
total_checks=total_checks,
|
|
633
|
+
audit_trail=audit_trail,
|
|
634
|
+
)
|
|
635
|
+
|
|
636
|
+
def generate_report(self, assessment: TrustAssessment) -> str:
|
|
637
|
+
"""Generate comprehensive TRUST assessment report"""
|
|
638
|
+
report = []
|
|
639
|
+
report.append("# TRUST 4 Principles Assessment Report")
|
|
640
|
+
report.append(f"Generated: {assessment.timestamp}")
|
|
641
|
+
report.append(f"Overall Score: {assessment.overall_score}/100")
|
|
642
|
+
report.append(f"Compliance Level: {assessment.compliance_level.value.upper()}")
|
|
643
|
+
report.append(
|
|
644
|
+
f"Passed Checks: {assessment.passed_checks}/{assessment.total_checks}"
|
|
645
|
+
)
|
|
646
|
+
report.append("")
|
|
647
|
+
|
|
648
|
+
# Principle breakdown
|
|
649
|
+
report.append("## Principle Breakdown")
|
|
650
|
+
report.append("")
|
|
651
|
+
|
|
652
|
+
for principle, score in assessment.principle_scores.items():
|
|
653
|
+
report.append(f"### {principle.value.replace('_', ' ').title()}")
|
|
654
|
+
report.append(f"**Score**: {score.score}/100")
|
|
655
|
+
report.append(f"**Compliance**: {score.compliance_level.value.upper()}")
|
|
656
|
+
|
|
657
|
+
if score.issues:
|
|
658
|
+
report.append("**Issues**:")
|
|
659
|
+
for issue in score.issues[:5]: # Show first 5 issues
|
|
660
|
+
report.append(f"- {issue}")
|
|
661
|
+
|
|
662
|
+
if score.recommendations:
|
|
663
|
+
report.append("**Recommendations**:")
|
|
664
|
+
for rec in score.recommendations[:5]: # Show first 5 recommendations
|
|
665
|
+
report.append(f"- {rec}")
|
|
666
|
+
|
|
667
|
+
if score.metrics:
|
|
668
|
+
report.append("**Metrics**:")
|
|
669
|
+
for key, value in score.metrics.items():
|
|
670
|
+
report.append(f"- {key}: {value}")
|
|
671
|
+
|
|
672
|
+
report.append("")
|
|
673
|
+
|
|
674
|
+
# Summary and next steps
|
|
675
|
+
report.append("## Summary")
|
|
676
|
+
report.append("")
|
|
677
|
+
|
|
678
|
+
if assessment.overall_score >= 80:
|
|
679
|
+
report.append(
|
|
680
|
+
"✅ **EXCELLENT**: Project meets TRUST principles at a high level"
|
|
681
|
+
)
|
|
682
|
+
elif assessment.overall_score >= 70:
|
|
683
|
+
report.append(
|
|
684
|
+
"🟡 **GOOD**: Project mostly follows TRUST principles with some areas for improvement"
|
|
685
|
+
)
|
|
686
|
+
elif assessment.overall_score >= 60:
|
|
687
|
+
report.append(
|
|
688
|
+
"🟠 **NEEDS IMPROVEMENT**: Project has significant gaps in TRUST principles"
|
|
689
|
+
)
|
|
690
|
+
else:
|
|
691
|
+
report.append(
|
|
692
|
+
"❌ **CRITICAL**: Project requires immediate attention to TRUST principles"
|
|
693
|
+
)
|
|
694
|
+
|
|
695
|
+
report.append("")
|
|
696
|
+
report.append("## Next Steps")
|
|
697
|
+
report.append("")
|
|
698
|
+
|
|
699
|
+
# Collect all recommendations
|
|
700
|
+
all_recommendations = []
|
|
701
|
+
for score in assessment.principle_scores.values():
|
|
702
|
+
all_recommendations.extend(score.recommendations)
|
|
703
|
+
|
|
704
|
+
if all_recommendations:
|
|
705
|
+
report.append("### Priority Recommendations")
|
|
706
|
+
for i, rec in enumerate(
|
|
707
|
+
set(all_recommendations[:10]), 1
|
|
708
|
+
): # Top 10 unique recommendations
|
|
709
|
+
report.append(f"{i}. {rec}")
|
|
710
|
+
|
|
711
|
+
return "\n".join(report)
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
# Convenience functions for common use cases
|
|
715
|
+
def validate_project_trust(project_path: str = ".") -> TrustAssessment:
|
|
716
|
+
"""Quick TRUST validation for a project"""
|
|
717
|
+
validator = TrustPrinciplesValidator()
|
|
718
|
+
return validator.assess_project(project_path)
|
|
719
|
+
|
|
720
|
+
|
|
721
|
+
def generate_trust_report(project_path: str = ".") -> str:
|
|
722
|
+
"""Generate TRUST assessment report"""
|
|
723
|
+
validator = TrustPrinciplesValidator()
|
|
724
|
+
assessment = validator.assess_project(project_path)
|
|
725
|
+
return validator.generate_report(assessment)
|