moai-adk 0.34.0__py3-none-any.whl → 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- moai_adk/__main__.py +136 -5
- moai_adk/astgrep/__init__.py +37 -0
- moai_adk/astgrep/analyzer.py +522 -0
- moai_adk/astgrep/models.py +124 -0
- moai_adk/astgrep/rules.py +179 -0
- moai_adk/cli/commands/analyze.py +11 -2
- moai_adk/cli/commands/doctor.py +7 -1
- moai_adk/cli/commands/init.py +321 -11
- moai_adk/cli/commands/language.py +7 -1
- moai_adk/cli/commands/rank.py +449 -0
- moai_adk/cli/commands/status.py +7 -1
- moai_adk/cli/commands/switch.py +325 -0
- moai_adk/cli/commands/update.py +296 -23
- moai_adk/cli/prompts/init_prompts.py +362 -66
- moai_adk/cli/prompts/translations/__init__.py +573 -0
- moai_adk/cli/ui/prompts.py +61 -2
- moai_adk/cli/worktree/cli.py +106 -1
- moai_adk/cli/worktree/manager.py +155 -0
- moai_adk/core/config/unified.py +244 -63
- moai_adk/core/credentials.py +264 -0
- moai_adk/core/error_recovery_system.py +22 -4
- moai_adk/core/git/conflict_detector.py +10 -1
- moai_adk/core/git/event_detector.py +16 -5
- moai_adk/core/integration/engine.py +2 -2
- moai_adk/core/integration/integration_tester.py +5 -5
- moai_adk/core/language_config_resolver.py +9 -3
- moai_adk/core/merge/analyzer.py +509 -324
- moai_adk/core/migration/alfred_to_moai_migrator.py +7 -1
- moai_adk/core/migration/backup_manager.py +54 -4
- moai_adk/core/migration/file_migrator.py +174 -2
- moai_adk/core/migration/interactive_checkbox_ui.py +42 -31
- moai_adk/core/migration/version_detector.py +123 -19
- moai_adk/core/migration/version_migrator.py +44 -9
- moai_adk/core/model_allocator.py +241 -0
- moai_adk/core/project/backup_utils.py +12 -2
- moai_adk/core/project/initializer.py +44 -87
- moai_adk/core/project/phase_executor.py +95 -33
- moai_adk/core/project/validator.py +16 -1
- moai_adk/core/quality/trust_checker.py +30 -10
- moai_adk/core/rollback_manager.py +60 -25
- moai_adk/core/template/backup.py +88 -6
- moai_adk/core/template/config.py +33 -9
- moai_adk/core/template/merger.py +34 -8
- moai_adk/core/template/processor.py +334 -11
- moai_adk/core/template_engine.py +10 -1
- moai_adk/core/template_variable_synchronizer.py +16 -2
- moai_adk/core/version_sync.py +54 -6
- moai_adk/foundation/__init__.py +1 -20
- moai_adk/foundation/testing.py +1 -1
- moai_adk/loop/__init__.py +54 -0
- moai_adk/loop/controller.py +305 -0
- moai_adk/loop/feedback.py +230 -0
- moai_adk/loop/state.py +209 -0
- moai_adk/loop/storage.py +220 -0
- moai_adk/lsp/__init__.py +70 -0
- moai_adk/lsp/client.py +320 -0
- moai_adk/lsp/models.py +261 -0
- moai_adk/lsp/protocol.py +404 -0
- moai_adk/lsp/server_manager.py +248 -0
- moai_adk/project/configuration.py +8 -1
- moai_adk/py.typed +0 -0
- moai_adk/ralph/__init__.py +37 -0
- moai_adk/ralph/engine.py +307 -0
- moai_adk/rank/__init__.py +21 -0
- moai_adk/rank/auth.py +425 -0
- moai_adk/rank/client.py +557 -0
- moai_adk/rank/config.py +147 -0
- moai_adk/rank/hook.py +1503 -0
- moai_adk/rank/py.typed +0 -0
- moai_adk/statusline/__init__.py +3 -0
- moai_adk/statusline/enhanced_output_style_detector.py +5 -5
- moai_adk/statusline/main.py +20 -1
- moai_adk/statusline/memory_collector.py +268 -0
- moai_adk/statusline/renderer.py +54 -38
- moai_adk/tag_system/__init__.py +48 -0
- moai_adk/tag_system/atomic_ops.py +117 -0
- moai_adk/tag_system/linkage.py +335 -0
- moai_adk/tag_system/parser.py +176 -0
- moai_adk/tag_system/validator.py +200 -0
- moai_adk/templates/.claude/agents/moai/builder-agent.md +19 -3
- moai_adk/templates/.claude/agents/moai/builder-command.md +62 -16
- moai_adk/templates/.claude/agents/moai/builder-plugin.md +763 -0
- moai_adk/templates/.claude/agents/moai/builder-skill.md +21 -5
- moai_adk/templates/.claude/agents/moai/expert-backend.md +103 -39
- moai_adk/templates/.claude/agents/moai/expert-debug.md +9 -3
- moai_adk/templates/.claude/agents/moai/expert-devops.md +16 -14
- moai_adk/templates/.claude/agents/moai/expert-frontend.md +45 -31
- moai_adk/templates/.claude/agents/moai/expert-performance.md +13 -9
- moai_adk/templates/.claude/agents/moai/expert-refactoring.md +228 -0
- moai_adk/templates/.claude/agents/moai/expert-security.md +19 -3
- moai_adk/templates/.claude/agents/moai/expert-testing.md +13 -9
- moai_adk/templates/.claude/agents/moai/manager-claude-code.md +8 -2
- moai_adk/templates/.claude/agents/moai/manager-docs.md +10 -5
- moai_adk/templates/.claude/agents/moai/manager-git.md +99 -27
- moai_adk/templates/.claude/agents/moai/manager-project.md +87 -7
- moai_adk/templates/.claude/agents/moai/manager-quality.md +22 -5
- moai_adk/templates/.claude/agents/moai/manager-spec.md +8 -2
- moai_adk/templates/.claude/agents/moai/manager-strategy.md +45 -14
- moai_adk/templates/.claude/agents/moai/manager-tdd.md +16 -3
- moai_adk/templates/.claude/commands/moai/0-project.md +239 -1185
- moai_adk/templates/.claude/commands/moai/1-plan.md +383 -363
- moai_adk/templates/.claude/commands/moai/2-run.md +254 -347
- moai_adk/templates/.claude/commands/moai/3-sync.md +174 -100
- moai_adk/templates/.claude/commands/moai/9-feedback.md +49 -33
- moai_adk/templates/.claude/commands/moai/alfred.md +339 -0
- moai_adk/templates/.claude/commands/moai/cancel-loop.md +163 -0
- moai_adk/templates/.claude/commands/moai/fix.md +264 -0
- moai_adk/templates/.claude/commands/moai/loop.md +363 -0
- moai_adk/templates/.claude/hooks/moai/lib/README.md +143 -0
- moai_adk/templates/.claude/hooks/moai/lib/__init__.py +37 -81
- moai_adk/templates/.claude/hooks/moai/lib/alfred_detector.py +105 -0
- moai_adk/templates/.claude/hooks/moai/lib/atomic_write.py +122 -0
- moai_adk/templates/.claude/hooks/moai/lib/checkpoint.py +4 -1
- moai_adk/templates/.claude/hooks/moai/lib/common.py +35 -5
- moai_adk/templates/.claude/hooks/moai/lib/config.py +376 -0
- moai_adk/templates/.claude/hooks/moai/lib/config_manager.py +24 -28
- moai_adk/templates/.claude/hooks/moai/lib/config_validator.py +14 -14
- moai_adk/templates/.claude/hooks/moai/lib/enhanced_output_style_detector.py +372 -0
- moai_adk/templates/.claude/hooks/moai/lib/exceptions.py +171 -0
- moai_adk/templates/.claude/hooks/moai/lib/file_utils.py +95 -0
- moai_adk/templates/.claude/hooks/moai/lib/git_collector.py +190 -0
- moai_adk/templates/.claude/hooks/moai/lib/git_operations_manager.py +15 -13
- moai_adk/templates/.claude/hooks/moai/lib/language_detector.py +298 -0
- moai_adk/templates/.claude/hooks/moai/lib/language_validator.py +125 -25
- moai_adk/templates/.claude/hooks/moai/lib/main.py +341 -0
- moai_adk/templates/.claude/hooks/moai/lib/memory_collector.py +268 -0
- moai_adk/templates/.claude/hooks/moai/lib/metrics_tracker.py +78 -0
- moai_adk/templates/.claude/hooks/moai/lib/models.py +9 -7
- moai_adk/templates/.claude/hooks/moai/lib/path_utils.py +204 -13
- moai_adk/templates/.claude/hooks/moai/lib/project.py +23 -14
- moai_adk/templates/.claude/hooks/moai/lib/renderer.py +359 -0
- moai_adk/templates/.claude/hooks/moai/lib/tag_linkage.py +333 -0
- moai_adk/templates/.claude/hooks/moai/lib/tag_parser.py +176 -0
- moai_adk/templates/.claude/hooks/moai/lib/tag_validator.py +200 -0
- moai_adk/templates/.claude/hooks/moai/lib/timeout.py +5 -5
- moai_adk/templates/.claude/hooks/moai/lib/tool_registry.py +896 -0
- moai_adk/templates/.claude/hooks/moai/lib/unified_timeout_manager.py +30 -18
- moai_adk/templates/.claude/hooks/moai/lib/update_checker.py +129 -0
- moai_adk/templates/.claude/hooks/moai/lib/version_reader.py +741 -0
- moai_adk/templates/.claude/hooks/moai/post_tool__ast_grep_scan.py +276 -0
- moai_adk/templates/.claude/hooks/moai/post_tool__code_formatter.py +255 -0
- moai_adk/templates/.claude/hooks/moai/post_tool__coverage_guard.py +325 -0
- moai_adk/templates/.claude/hooks/moai/post_tool__linter.py +315 -0
- moai_adk/templates/.claude/hooks/moai/post_tool__lsp_diagnostic.py +508 -0
- moai_adk/templates/.claude/hooks/moai/pre_commit__tag_validator.py +287 -0
- moai_adk/templates/.claude/hooks/moai/pre_tool__security_guard.py +268 -0
- moai_adk/templates/.claude/hooks/moai/pre_tool__tdd_enforcer.py +208 -0
- moai_adk/templates/.claude/hooks/moai/session_end__auto_cleanup.py +93 -61
- moai_adk/templates/.claude/hooks/moai/session_end__rank_submit.py +69 -0
- moai_adk/templates/.claude/hooks/moai/session_start__show_project_info.py +165 -70
- moai_adk/templates/.claude/hooks/moai/shared/utils/announcement_translator.py +206 -0
- moai_adk/templates/.claude/hooks/moai/stop__loop_controller.py +621 -0
- moai_adk/templates/.claude/output-styles/moai/alfred.md +758 -0
- moai_adk/templates/.claude/output-styles/moai/r2d2.md +86 -3
- moai_adk/templates/.claude/output-styles/moai/yoda.md +2 -2
- moai_adk/templates/.claude/settings.json +154 -77
- moai_adk/templates/.claude/skills/moai-docs-generation/SKILL.md +252 -198
- moai_adk/templates/.claude/skills/moai-docs-generation/examples.md +169 -323
- moai_adk/templates/.claude/skills/moai-docs-generation/modules/README.md +39 -27
- moai_adk/templates/.claude/skills/moai-docs-generation/modules/api-documentation.md +115 -125
- moai_adk/templates/.claude/skills/moai-docs-generation/modules/code-documentation.md +150 -150
- moai_adk/templates/.claude/skills/moai-docs-generation/modules/multi-format-output.md +182 -175
- moai_adk/templates/.claude/skills/moai-docs-generation/modules/user-guides.md +198 -138
- moai_adk/templates/.claude/skills/moai-docs-generation/reference.md +226 -320
- moai_adk/templates/.claude/skills/moai-domain-backend/SKILL.md +43 -222
- moai_adk/templates/.claude/skills/moai-domain-database/SKILL.md +75 -219
- moai_adk/templates/.claude/skills/moai-domain-frontend/SKILL.md +103 -463
- moai_adk/templates/.claude/skills/moai-domain-frontend/modules/component-architecture.md +723 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/modules/nextjs16-patterns.md +713 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/modules/performance-optimization.md +694 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/modules/react19-patterns.md +591 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/modules/state-management.md +680 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/modules/vue35-patterns.md +802 -0
- moai_adk/templates/.claude/skills/moai-domain-uiux/SKILL.md +118 -339
- moai_adk/templates/.claude/skills/moai-formats-data/SKILL.md +74 -377
- moai_adk/templates/.claude/skills/moai-formats-data/modules/README.md +299 -70
- moai_adk/templates/.claude/skills/moai-foundation-claude/SKILL.md +205 -182
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/advanced-agent-patterns.md +370 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-cli-reference-official.md +420 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-custom-slash-commands-official.md +32 -22
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-devcontainers-official.md +381 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-discover-plugins-official.md +379 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-headless-official.md +378 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-hooks-official.md +110 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-plugin-marketplaces-official.md +308 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-plugins-official.md +640 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-sandboxing-official.md +282 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-skills-official.md +425 -71
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-statusline-official.md +293 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-sub-agents-official.md +325 -143
- moai_adk/templates/.claude/skills/moai-foundation-context/SKILL.md +96 -316
- moai_adk/templates/.claude/skills/moai-foundation-core/SKILL.md +116 -294
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/delegation-advanced.md +279 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/delegation-implementation.md +267 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/delegation-patterns.md +121 -650
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/patterns.md +22 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/spec-ears-format.md +200 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/spec-first-tdd.md +37 -730
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/spec-tdd-implementation.md +275 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/trust-5-framework.md +77 -819
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/trust-5-implementation.md +244 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/trust-5-validation.md +219 -0
- moai_adk/templates/.claude/skills/moai-foundation-philosopher/SKILL.md +14 -18
- moai_adk/templates/.claude/skills/moai-foundation-quality/SKILL.md +86 -270
- moai_adk/templates/.claude/skills/moai-framework-electron/SKILL.md +288 -0
- moai_adk/templates/.claude/skills/moai-framework-electron/examples.md +2082 -0
- moai_adk/templates/.claude/skills/moai-framework-electron/reference.md +1649 -0
- moai_adk/templates/.claude/skills/moai-lang-cpp/SKILL.md +76 -582
- moai_adk/templates/.claude/skills/moai-lang-cpp/examples.md +1239 -0
- moai_adk/templates/.claude/skills/moai-lang-cpp/modules/advanced-patterns.md +401 -0
- moai_adk/templates/.claude/skills/moai-lang-cpp/reference.md +1136 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/SKILL.md +82 -436
- moai_adk/templates/.claude/skills/moai-lang-csharp/examples.md +585 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/modules/aspnet-core.md +627 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/modules/blazor-components.md +767 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/modules/cqrs-validation.md +626 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/modules/csharp12-features.md +580 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/modules/efcore-patterns.md +622 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/reference.md +403 -0
- moai_adk/templates/.claude/skills/moai-lang-elixir/SKILL.md +65 -542
- moai_adk/templates/.claude/skills/moai-lang-elixir/examples.md +1171 -0
- moai_adk/templates/.claude/skills/moai-lang-elixir/modules/advanced-patterns.md +531 -0
- moai_adk/templates/.claude/skills/moai-lang-elixir/reference.md +889 -0
- moai_adk/templates/.claude/skills/moai-lang-flutter/SKILL.md +32 -405
- moai_adk/templates/.claude/skills/moai-lang-go/SKILL.md +114 -293
- moai_adk/templates/.claude/skills/moai-lang-java/SKILL.md +83 -307
- moai_adk/templates/.claude/skills/moai-lang-javascript/SKILL.md +179 -0
- moai_adk/templates/.claude/skills/moai-lang-javascript/examples.md +973 -0
- moai_adk/templates/.claude/skills/moai-lang-javascript/reference.md +1543 -0
- moai_adk/templates/.claude/skills/moai-lang-kotlin/SKILL.md +42 -279
- moai_adk/templates/.claude/skills/moai-lang-php/SKILL.md +94 -556
- moai_adk/templates/.claude/skills/moai-lang-php/examples.md +1608 -0
- moai_adk/templates/.claude/skills/moai-lang-php/modules/advanced-patterns.md +538 -0
- moai_adk/templates/.claude/skills/moai-lang-php/reference.md +1323 -0
- moai_adk/templates/.claude/skills/moai-lang-python/SKILL.md +108 -358
- moai_adk/templates/.claude/skills/moai-lang-r/SKILL.md +84 -482
- moai_adk/templates/.claude/skills/moai-lang-r/examples.md +1154 -0
- moai_adk/templates/.claude/skills/moai-lang-r/modules/advanced-patterns.md +489 -0
- moai_adk/templates/.claude/skills/moai-lang-r/reference.md +1087 -0
- moai_adk/templates/.claude/skills/moai-lang-ruby/SKILL.md +106 -610
- moai_adk/templates/.claude/skills/moai-lang-ruby/examples.md +1106 -0
- moai_adk/templates/.claude/skills/moai-lang-ruby/modules/advanced-patterns.md +309 -0
- moai_adk/templates/.claude/skills/moai-lang-ruby/modules/testing-patterns.md +306 -0
- moai_adk/templates/.claude/skills/moai-lang-ruby/reference.md +1024 -0
- moai_adk/templates/.claude/skills/moai-lang-rust/SKILL.md +51 -265
- moai_adk/templates/.claude/skills/moai-lang-scala/SKILL.md +106 -442
- moai_adk/templates/.claude/skills/moai-lang-scala/modules/akka-actors.md +479 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/modules/cats-effect.md +489 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/modules/functional-programming.md +460 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/modules/spark-data.md +498 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/modules/zio-patterns.md +541 -0
- moai_adk/templates/.claude/skills/moai-lang-swift/SKILL.md +88 -457
- moai_adk/templates/.claude/skills/moai-lang-swift/modules/combine-reactive.md +256 -0
- moai_adk/templates/.claude/skills/moai-lang-swift/modules/concurrency.md +270 -0
- moai_adk/templates/.claude/skills/moai-lang-swift/modules/swift6-features.md +265 -0
- moai_adk/templates/.claude/skills/moai-lang-swift/modules/swiftui-patterns.md +314 -0
- moai_adk/templates/.claude/skills/moai-lang-typescript/SKILL.md +75 -283
- moai_adk/templates/.claude/skills/moai-library-mermaid/SKILL.md +97 -252
- moai_adk/templates/.claude/skills/moai-library-nextra/SKILL.md +64 -240
- moai_adk/templates/.claude/skills/moai-library-nextra/modules/advanced-patterns.md +331 -12
- moai_adk/templates/.claude/skills/moai-library-nextra/modules/configuration.md +330 -37
- moai_adk/templates/.claude/skills/moai-library-shadcn/SKILL.md +90 -287
- moai_adk/templates/.claude/skills/moai-platform-auth0/SKILL.md +200 -206
- moai_adk/templates/.claude/skills/moai-platform-auth0/examples.md +2446 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/adaptive-mfa.md +233 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/akamai-integration.md +214 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/application-credentials.md +280 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/attack-protection-log-events.md +224 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/attack-protection-overview.md +140 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/bot-detection.md +144 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/breached-password-detection.md +187 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/brute-force-protection.md +189 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/certifications.md +282 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/compliance-overview.md +263 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/continuous-session-protection.md +307 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/customize-mfa.md +177 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/dpop-implementation.md +283 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/fapi-implementation.md +259 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/gdpr-compliance.md +313 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/guardian-configuration.md +269 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/highly-regulated-identity.md +272 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/jwt-fundamentals.md +248 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/mdl-verification.md +210 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/mfa-api-management.md +278 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/mfa-factors.md +226 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/mfa-overview.md +174 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/mtls-sender-constraining.md +316 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/ropg-flow-mfa.md +216 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/security-center.md +325 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/security-guidance.md +277 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/state-parameters.md +177 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/step-up-authentication.md +251 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/suspicious-ip-throttling.md +240 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/tenant-access-control.md +179 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/webauthn-fido.md +235 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/reference.md +224 -0
- moai_adk/templates/.claude/skills/moai-platform-clerk/SKILL.md +75 -330
- moai_adk/templates/.claude/skills/moai-platform-clerk/examples.md +1426 -0
- moai_adk/templates/.claude/skills/moai-platform-clerk/modules/advanced-patterns.md +417 -0
- moai_adk/templates/.claude/skills/moai-platform-clerk/reference.md +273 -0
- moai_adk/templates/.claude/skills/moai-platform-convex/SKILL.md +100 -340
- moai_adk/templates/.claude/skills/moai-platform-convex/examples.md +506 -0
- moai_adk/templates/.claude/skills/moai-platform-convex/modules/auth-integration.md +421 -0
- moai_adk/templates/.claude/skills/moai-platform-convex/modules/file-storage.md +474 -0
- moai_adk/templates/.claude/skills/moai-platform-convex/modules/reactive-queries.md +302 -0
- moai_adk/templates/.claude/skills/moai-platform-convex/modules/server-functions.md +452 -0
- moai_adk/templates/.claude/skills/moai-platform-convex/reference.md +385 -0
- moai_adk/templates/.claude/skills/moai-platform-firebase-auth/SKILL.md +113 -326
- moai_adk/templates/.claude/skills/moai-platform-firebase-auth/examples.md +514 -0
- moai_adk/templates/.claude/skills/moai-platform-firebase-auth/modules/custom-claims.md +374 -0
- moai_adk/templates/.claude/skills/moai-platform-firebase-auth/modules/phone-auth.md +372 -0
- moai_adk/templates/.claude/skills/moai-platform-firebase-auth/modules/social-auth.md +339 -0
- moai_adk/templates/.claude/skills/moai-platform-firebase-auth/reference.md +382 -0
- moai_adk/templates/.claude/skills/moai-platform-firestore/SKILL.md +71 -302
- moai_adk/templates/.claude/skills/moai-platform-firestore/examples.md +445 -0
- moai_adk/templates/.claude/skills/moai-platform-firestore/modules/offline-cache.md +392 -0
- moai_adk/templates/.claude/skills/moai-platform-firestore/modules/realtime-listeners.md +441 -0
- moai_adk/templates/.claude/skills/moai-platform-firestore/modules/security-rules.md +352 -0
- moai_adk/templates/.claude/skills/moai-platform-firestore/modules/transactions.md +452 -0
- moai_adk/templates/.claude/skills/moai-platform-firestore/reference.md +322 -0
- moai_adk/templates/.claude/skills/moai-platform-neon/SKILL.md +101 -412
- moai_adk/templates/.claude/skills/moai-platform-neon/examples.md +470 -0
- moai_adk/templates/.claude/skills/moai-platform-neon/modules/auto-scaling.md +349 -0
- moai_adk/templates/.claude/skills/moai-platform-neon/modules/branching-workflows.md +354 -0
- moai_adk/templates/.claude/skills/moai-platform-neon/modules/connection-pooling.md +412 -0
- moai_adk/templates/.claude/skills/moai-platform-neon/modules/pitr-backups.md +458 -0
- moai_adk/templates/.claude/skills/moai-platform-neon/reference.md +272 -0
- moai_adk/templates/.claude/skills/moai-platform-railway/SKILL.md +96 -327
- moai_adk/templates/.claude/skills/moai-platform-railway/examples.md +539 -0
- moai_adk/templates/.claude/skills/moai-platform-railway/modules/docker-deployment.md +261 -0
- moai_adk/templates/.claude/skills/moai-platform-railway/modules/multi-service.md +291 -0
- moai_adk/templates/.claude/skills/moai-platform-railway/modules/networking-domains.md +338 -0
- moai_adk/templates/.claude/skills/moai-platform-railway/modules/volumes-storage.md +353 -0
- moai_adk/templates/.claude/skills/moai-platform-railway/reference.md +374 -0
- moai_adk/templates/.claude/skills/moai-platform-supabase/SKILL.md +103 -428
- moai_adk/templates/.claude/skills/moai-platform-supabase/examples.md +502 -0
- moai_adk/templates/.claude/skills/moai-platform-supabase/modules/auth-integration.md +384 -0
- moai_adk/templates/.claude/skills/moai-platform-supabase/modules/edge-functions.md +371 -0
- moai_adk/templates/.claude/skills/moai-platform-supabase/modules/postgresql-pgvector.md +231 -0
- moai_adk/templates/.claude/skills/moai-platform-supabase/modules/realtime-presence.md +354 -0
- moai_adk/templates/.claude/skills/moai-platform-supabase/modules/row-level-security.md +286 -0
- moai_adk/templates/.claude/skills/moai-platform-supabase/modules/storage-cdn.md +319 -0
- moai_adk/templates/.claude/skills/moai-platform-supabase/modules/typescript-patterns.md +453 -0
- moai_adk/templates/.claude/skills/moai-platform-supabase/reference.md +284 -0
- moai_adk/templates/.claude/skills/moai-platform-vercel/SKILL.md +96 -446
- moai_adk/templates/.claude/skills/moai-platform-vercel/examples.md +502 -0
- moai_adk/templates/.claude/skills/moai-platform-vercel/modules/analytics-speed.md +348 -0
- moai_adk/templates/.claude/skills/moai-platform-vercel/modules/deployment-config.md +344 -0
- moai_adk/templates/.claude/skills/moai-platform-vercel/modules/edge-functions.md +222 -0
- moai_adk/templates/.claude/skills/moai-platform-vercel/modules/isr-caching.md +306 -0
- moai_adk/templates/.claude/skills/moai-platform-vercel/modules/kv-storage.md +399 -0
- moai_adk/templates/.claude/skills/moai-platform-vercel/reference.md +360 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/SKILL.md +193 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/examples.md +1099 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/modules/language-specific.md +307 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/modules/pattern-syntax.md +237 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/modules/refactoring-patterns.md +260 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/modules/security-rules.md +239 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/reference.md +288 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/languages/go.yml +90 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/languages/python.yml +101 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/languages/typescript.yml +83 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/quality/complexity-check.yml +94 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/quality/deprecated-apis.yml +84 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/security/secrets-detection.yml +89 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/security/sql-injection.yml +45 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/security/xss-prevention.yml +50 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/sgconfig.yml +54 -0
- moai_adk/templates/.claude/skills/moai-workflow-jit-docs/SKILL.md +225 -423
- moai_adk/templates/.claude/skills/moai-workflow-loop/SKILL.md +197 -0
- moai_adk/templates/.claude/skills/moai-workflow-loop/examples.md +1063 -0
- moai_adk/templates/.claude/skills/moai-workflow-loop/reference.md +1414 -0
- moai_adk/templates/.claude/skills/moai-workflow-project/SKILL.md +211 -314
- moai_adk/templates/.claude/skills/moai-workflow-project/schemas/tab_schema.json +15 -43
- moai_adk/templates/.claude/skills/moai-workflow-spec/SKILL.md +119 -316
- moai_adk/templates/.claude/skills/moai-workflow-spec/modules/advanced-patterns.md +237 -0
- moai_adk/templates/.claude/skills/moai-workflow-templates/SKILL.md +96 -203
- moai_adk/templates/.claude/skills/moai-workflow-testing/SKILL.md +201 -388
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/README.md +52 -3
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/ai-debugging.md +263 -806
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/context7-integration.md +286 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/review-workflows.md +500 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework/relevance-analysis.md +154 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework/safety-analysis.md +148 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework/scoring-algorithms.md +196 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework/timeliness-analysis.md +168 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework/truthfulness-analysis.md +136 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework/usability-analysis.md +153 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework.md +257 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review.md +191 -1344
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/code-review/analysis-patterns.md +340 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/code-review/core-classes.md +299 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/code-review/tool-integration.md +380 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/debugging/debugging-workflows.md +451 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/debugging/error-analysis.md +442 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance/optimization-patterns.md +473 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance/profiling-techniques.md +481 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance-optimization/ai-optimization.md +241 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance-optimization/bottleneck-detection.md +397 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance-optimization/optimization-plan.md +315 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance-optimization/profiler-core.md +277 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance-optimization/real-time-monitoring.md +187 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance-optimization.md +287 -1194
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/quality-metrics.md +415 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/refactoring/ai-workflows.md +620 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/refactoring/patterns.md +692 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/security-analysis.md +429 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/smart-refactoring.md +262 -1192
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/static-analysis.md +438 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/tdd/core-classes.md +397 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/tdd-context7/advanced-features.md +494 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/tdd-context7/red-green-refactor.md +316 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/tdd-context7/test-generation.md +471 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/tdd-context7/test-patterns.md +371 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/tdd-context7.md +227 -1222
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/trust5-validation.md +428 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/SKILL.md +228 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/integration-patterns.md +149 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/moai-adk-integration.md +245 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/parallel-advanced.md +310 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/parallel-development.md +202 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/parallel-workflows.md +302 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/registry-architecture.md +271 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/resource-optimization.md +300 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/tools-integration.md +280 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/troubleshooting.md +397 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/worktree-commands.md +296 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/worktree-management.md +217 -0
- moai_adk/templates/.git-hooks/pre-push +162 -59
- moai_adk/templates/.github/workflows/ci-universal.yml +934 -133
- moai_adk/templates/.gitignore +65 -107
- moai_adk/templates/.lsp.json +152 -0
- moai_adk/templates/.mcp.json +2 -20
- moai_adk/templates/.moai/announcements/en.json +18 -0
- moai_adk/templates/.moai/announcements/ja.json +18 -0
- moai_adk/templates/.moai/announcements/ko.json +18 -0
- moai_adk/templates/.moai/announcements/zh.json +18 -0
- moai_adk/templates/.moai/config/config.yaml +8 -2
- moai_adk/templates/.moai/config/multilingual-triggers.yaml +213 -0
- moai_adk/templates/.moai/config/sections/language.yaml +2 -2
- moai_adk/templates/.moai/config/sections/llm.yaml +41 -0
- moai_adk/templates/.moai/config/sections/pricing.yaml +30 -0
- moai_adk/templates/.moai/config/sections/project.yaml +2 -2
- moai_adk/templates/.moai/config/sections/quality.yaml +43 -5
- moai_adk/templates/.moai/config/sections/ralph.yaml +55 -0
- moai_adk/templates/.moai/config/sections/system.yaml +46 -1
- moai_adk/templates/.moai/config/sections/user.yaml +1 -1
- moai_adk/templates/.moai/config/statusline-config.yaml +2 -2
- moai_adk/templates/.moai/llm-configs/glm.json +22 -0
- moai_adk/templates/CLAUDE.ja.md +343 -0
- moai_adk/templates/CLAUDE.ko.md +343 -0
- moai_adk/templates/CLAUDE.md +200 -499
- moai_adk/templates/CLAUDE.zh.md +343 -0
- moai_adk/utils/common.py +37 -0
- moai_adk/version.py +1 -1
- moai_adk-1.1.0.dist-info/METADATA +2443 -0
- moai_adk-1.1.0.dist-info/RECORD +701 -0
- {moai_adk-0.34.0.dist-info → moai_adk-1.1.0.dist-info}/entry_points.txt +2 -0
- moai_adk-1.1.0.dist-info/licenses/LICENSE +99 -0
- moai_adk/core/config/auto_spec_config.py +0 -340
- moai_adk/core/hooks/post_tool_auto_spec_completion.py +0 -901
- moai_adk/core/spec/confidence_scoring.py +0 -680
- moai_adk/core/spec/ears_template_engine.py +0 -1247
- moai_adk/core/spec/quality_validator.py +0 -687
- moai_adk/templates/.claude/agents/moai/ai-nano-banana.md +0 -670
- moai_adk/templates/.claude/agents/moai/expert-database.md +0 -777
- moai_adk/templates/.claude/agents/moai/expert-uiux.md +0 -1041
- moai_adk/templates/.claude/agents/moai/mcp-context7.md +0 -458
- moai_adk/templates/.claude/agents/moai/mcp-figma.md +0 -1607
- moai_adk/templates/.claude/agents/moai/mcp-notion.md +0 -789
- moai_adk/templates/.claude/agents/moai/mcp-playwright.md +0 -469
- moai_adk/templates/.claude/agents/moai/mcp-sequential-thinking.md +0 -1032
- moai_adk/templates/.claude/skills/moai-ai-nano-banana/SKILL.md +0 -438
- moai_adk/templates/.claude/skills/moai-ai-nano-banana/examples.md +0 -431
- moai_adk/templates/.claude/skills/moai-domain-uiux/modules/design-system-tokens.md +0 -405
- moai_adk/templates/.claude/skills/moai-library-nextra/advanced-patterns.md +0 -336
- moai_adk/templates/.claude/skills/moai-mcp-figma/SKILL.md +0 -402
- moai_adk/templates/.claude/skills/moai-mcp-figma/advanced-patterns.md +0 -607
- moai_adk/templates/.claude/skills/moai-mcp-notion/SKILL.md +0 -300
- moai_adk/templates/.claude/skills/moai-mcp-notion/advanced-patterns.md +0 -537
- moai_adk/templates/.claude/skills/moai-workflow-project/__init__.py +0 -520
- moai_adk/templates/.claude/skills/moai-workflow-project/complete_workflow_demo_fixed.py +0 -574
- moai_adk/templates/.claude/skills/moai-workflow-project/examples/complete_project_setup.py +0 -317
- moai_adk/templates/.claude/skills/moai-workflow-project/examples/complete_workflow_demo.py +0 -663
- moai_adk/templates/.claude/skills/moai-workflow-project/examples/config-migration-example.json +0 -190
- moai_adk/templates/.claude/skills/moai-workflow-project/examples/question-examples.json +0 -175
- moai_adk/templates/.claude/skills/moai-workflow-project/examples/quick_start.py +0 -196
- moai_adk/templates/.claude/skills/moai-workflow-project/modules/__init__.py +0 -17
- moai_adk/templates/.claude/skills/moai-workflow-project/modules/advanced-patterns.md +0 -158
- moai_adk/templates/.claude/skills/moai-workflow-project/modules/ask_user_integration.py +0 -340
- moai_adk/templates/.claude/skills/moai-workflow-project/modules/batch_questions.py +0 -713
- moai_adk/templates/.claude/skills/moai-workflow-project/modules/config_manager.py +0 -538
- moai_adk/templates/.claude/skills/moai-workflow-project/modules/documentation_manager.py +0 -1336
- moai_adk/templates/.claude/skills/moai-workflow-project/modules/language_initializer.py +0 -730
- moai_adk/templates/.claude/skills/moai-workflow-project/modules/migration_manager.py +0 -608
- moai_adk/templates/.claude/skills/moai-workflow-project/modules/template_optimizer.py +0 -1005
- moai_adk/templates/.claude/skills/moai-workflow-project/test_integration_simple.py +0 -436
- moai_adk/templates/.claude/skills/moai-worktree/SKILL.md +0 -411
- moai_adk/templates/.claude/skills/moai-worktree/modules/integration-patterns.md +0 -982
- moai_adk/templates/.claude/skills/moai-worktree/modules/parallel-development.md +0 -778
- moai_adk/templates/.claude/skills/moai-worktree/modules/worktree-commands.md +0 -646
- moai_adk/templates/.claude/skills/moai-worktree/modules/worktree-management.md +0 -782
- moai_adk/templates/.moai/config/questions/_schema.yaml +0 -151
- moai_adk/templates/.moai/config/questions/tab0-init.yaml +0 -251
- moai_adk/templates/.moai/config/questions/tab1-user.yaml +0 -108
- moai_adk/templates/.moai/config/questions/tab2-project.yaml +0 -81
- moai_adk/templates/.moai/config/questions/tab3-git.yaml +0 -634
- moai_adk/templates/.moai/config/questions/tab4-quality.yaml +0 -170
- moai_adk/templates/.moai/config/questions/tab5-system.yaml +0 -87
- moai_adk/templates/.moai/scripts/setup-glm.py +0 -136
- moai_adk-0.34.0.dist-info/METADATA +0 -2999
- moai_adk-0.34.0.dist-info/RECORD +0 -463
- moai_adk-0.34.0.dist-info/licenses/LICENSE +0 -21
- /moai_adk/foundation/{git.py → git/__init__.py} +0 -0
- /moai_adk/templates/.claude/skills/moai-library-mermaid/{advanced-patterns.md → modules/advanced-patterns.md} +0 -0
- /moai_adk/templates/.claude/skills/moai-library-mermaid/{optimization.md → modules/optimization.md} +0 -0
- /moai_adk/templates/.claude/skills/moai-library-nextra/{optimization.md → modules/optimization.md} +0 -0
- /moai_adk/templates/.claude/skills/moai-workflow-jit-docs/{advanced-patterns.md → modules/advanced-patterns.md} +0 -0
- /moai_adk/templates/.claude/skills/moai-workflow-jit-docs/{optimization.md → modules/optimization.md} +0 -0
- /moai_adk/templates/.claude/skills/moai-workflow-testing/{advanced-patterns.md → modules/advanced-patterns.md} +0 -0
- /moai_adk/templates/.claude/skills/moai-workflow-testing/{optimization.md → modules/optimization.md} +0 -0
- /moai_adk/templates/.claude/skills/{moai-worktree → moai-workflow-worktree}/examples.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-worktree → moai-workflow-worktree}/reference.md +0 -0
- {moai_adk-0.34.0.dist-info → moai_adk-1.1.0.dist-info}/WHEEL +0 -0
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: moai-lang-elixir
|
|
3
|
-
description: Elixir 1.17+ development specialist covering Phoenix 1.7, LiveView, Ecto, and OTP patterns. Use when developing real-time applications, distributed systems, or Phoenix projects.
|
|
4
|
-
version: 1.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
name: "moai-lang-elixir"
|
|
3
|
+
description: "Elixir 1.17+ development specialist covering Phoenix 1.7, LiveView, Ecto, and OTP patterns. Use when developing real-time applications, distributed systems, or Phoenix projects."
|
|
4
|
+
version: 1.1.0
|
|
5
|
+
category: "language"
|
|
6
|
+
modularized: true
|
|
7
|
+
user-invocable: false
|
|
8
|
+
tags: ["language", "elixir", "phoenix", "liveview", "ecto", "otp", "genserver"]
|
|
9
|
+
updated: 2026-01-11
|
|
10
|
+
status: "active"
|
|
11
|
+
allowed-tools:
|
|
12
|
+
- Read
|
|
13
|
+
- Grep
|
|
14
|
+
- Glob
|
|
15
|
+
- Bash
|
|
16
|
+
- mcp__context7__resolve-library-id
|
|
17
|
+
- mcp__context7__get-library-docs
|
|
8
18
|
---
|
|
9
19
|
|
|
10
20
|
## Quick Reference (30 seconds)
|
|
@@ -14,6 +24,7 @@ Elixir 1.17+ Development Specialist - Phoenix 1.7, LiveView, Ecto, OTP patterns,
|
|
|
14
24
|
Auto-Triggers: `.ex`, `.exs` files, `mix.exs`, `config/`, Phoenix/LiveView discussions
|
|
15
25
|
|
|
16
26
|
Core Capabilities:
|
|
27
|
+
|
|
17
28
|
- Elixir 1.17: Pattern matching, pipes, protocols, behaviours, macros
|
|
18
29
|
- Phoenix 1.7: Controllers, LiveView, Channels, PubSub, Verified Routes
|
|
19
30
|
- Ecto: Schemas, Changesets, Queries, Migrations, Multi
|
|
@@ -24,79 +35,13 @@ Core Capabilities:
|
|
|
24
35
|
|
|
25
36
|
### Quick Patterns
|
|
26
37
|
|
|
27
|
-
Phoenix Controller:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def show(conn, %{"id" => id}) do
|
|
35
|
-
user = Accounts.get_user!(id)
|
|
36
|
-
render(conn, :show, user: user)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def create(conn, %{"user" => user_params}) do
|
|
40
|
-
case Accounts.create_user(user_params) do
|
|
41
|
-
{:ok, user} ->
|
|
42
|
-
conn
|
|
43
|
-
|> put_flash(:info, "User created successfully.")
|
|
44
|
-
|> redirect(to: ~p"/users/#{user}")
|
|
45
|
-
|
|
46
|
-
{:error, %Ecto.Changeset{} = changeset} ->
|
|
47
|
-
render(conn, :new, changeset: changeset)
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
Ecto Schema with Changeset:
|
|
54
|
-
```elixir
|
|
55
|
-
defmodule MyApp.Accounts.User do
|
|
56
|
-
use Ecto.Schema
|
|
57
|
-
import Ecto.Changeset
|
|
58
|
-
|
|
59
|
-
schema "users" do
|
|
60
|
-
field :name, :string
|
|
61
|
-
field :email, :string
|
|
62
|
-
field :password_hash, :string
|
|
63
|
-
field :password, :string, virtual: true
|
|
64
|
-
|
|
65
|
-
timestamps()
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def changeset(user, attrs) do
|
|
69
|
-
user
|
|
70
|
-
|> cast(attrs, [:name, :email, :password])
|
|
71
|
-
|> validate_required([:name, :email, :password])
|
|
72
|
-
|> validate_format(:email, ~r/@/)
|
|
73
|
-
|> validate_length(:password, min: 8)
|
|
74
|
-
|> unique_constraint(:email)
|
|
75
|
-
|> put_password_hash()
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
GenServer Pattern:
|
|
81
|
-
```elixir
|
|
82
|
-
defmodule MyApp.Counter do
|
|
83
|
-
use GenServer
|
|
84
|
-
|
|
85
|
-
def start_link(initial_value) do
|
|
86
|
-
GenServer.start_link(__MODULE__, initial_value, name: __MODULE__)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def increment, do: GenServer.call(__MODULE__, :increment)
|
|
90
|
-
def get_count, do: GenServer.call(__MODULE__, :get)
|
|
91
|
-
|
|
92
|
-
@impl true
|
|
93
|
-
def init(initial_value), do: {:ok, initial_value}
|
|
94
|
-
|
|
95
|
-
@impl true
|
|
96
|
-
def handle_call(:increment, _from, count), do: {:reply, count + 1, count + 1}
|
|
97
|
-
def handle_call(:get, _from, count), do: {:reply, count, count}
|
|
98
|
-
end
|
|
99
|
-
```
|
|
38
|
+
Phoenix Controller: Define a module using MyAppWeb with :controller. Create alias for the context module like MyApp.Accounts. Define action functions like show taking conn and params map with destructured id. Fetch data using the context function with bang like get_user! and render the template passing the data as assigns.
|
|
39
|
+
|
|
40
|
+
For create actions, pattern match on the context result tuple. On ok tuple, use pipe operator to put_flash with success message and redirect using ~p sigil for verified routes. On error tuple with Ecto.Changeset, render the form template passing the changeset.
|
|
41
|
+
|
|
42
|
+
Ecto Schema with Changeset: Define a module using Ecto.Schema and importing Ecto.Changeset. Define the schema block with field declarations including types like :string and virtual fields. Create a changeset function taking the struct and attrs, using pipe operator to chain cast with the list of fields to cast, validate_required, validate_format with regex, validate_length with min option, and unique_constraint.
|
|
43
|
+
|
|
44
|
+
GenServer Pattern: Define a module using GenServer. Create start_link taking initial_value and calling GenServer.start_link with __MODULE__, initial_value, and name option. Define client API functions that call GenServer.call with __MODULE__ and the message atom. Implement init callback returning ok tuple with state. Implement handle_call callbacks for each message, returning reply tuple with response and new state.
|
|
100
45
|
|
|
101
46
|
---
|
|
102
47
|
|
|
@@ -104,459 +49,55 @@ end
|
|
|
104
49
|
|
|
105
50
|
### Elixir 1.17 Features
|
|
106
51
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
Pattern Matching Advanced:
|
|
113
|
-
```elixir
|
|
114
|
-
def process_message(%{type: :email, to: to} = message) when is_binary(to) do
|
|
115
|
-
send_email(message)
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def process_message(%{type: :sms, phone: phone}) when byte_size(phone) == 10 do
|
|
119
|
-
send_sms(phone)
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
def process_message(_), do: {:error, :invalid_message}
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
Pipe Operator Best Practices:
|
|
126
|
-
```elixir
|
|
127
|
-
def process_order(order_params) do
|
|
128
|
-
order_params
|
|
129
|
-
|> validate_order()
|
|
130
|
-
|> calculate_total()
|
|
131
|
-
|> apply_discounts()
|
|
132
|
-
|> create_order()
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
# With error handling using with
|
|
136
|
-
def process_order_safe(params) do
|
|
137
|
-
with {:ok, validated} <- validate_order(params),
|
|
138
|
-
{:ok, total} <- calculate_total(validated),
|
|
139
|
-
{:ok, discounted} <- apply_discounts(total),
|
|
140
|
-
{:ok, order} <- create_order(discounted) do
|
|
141
|
-
{:ok, order}
|
|
142
|
-
else
|
|
143
|
-
{:error, reason} -> {:error, reason}
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
Protocols for Polymorphism:
|
|
149
|
-
```elixir
|
|
150
|
-
defprotocol Stringify do
|
|
151
|
-
@doc "Converts a data structure to string"
|
|
152
|
-
def to_string(data)
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
defimpl Stringify, for: Map do
|
|
156
|
-
def to_string(map), do: Jason.encode!(map)
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
defimpl Stringify, for: List do
|
|
160
|
-
def to_string(list), do: Enum.join(list, ", ")
|
|
161
|
-
end
|
|
162
|
-
```
|
|
52
|
+
Pattern Matching Advanced: Define function heads with pattern matching on map keys and types. Use guard clauses with when to add constraints like is_binary or byte_size checks. Add a catch-all clause returning error tuple for invalid inputs.
|
|
53
|
+
|
|
54
|
+
Pipe Operator with Error Handling: Use the with special form for chaining operations that may fail. Pattern match each step with left arrow, and on successful completion of all steps, return the final ok tuple. In the else block, handle error tuples by returning them unchanged.
|
|
55
|
+
|
|
56
|
+
Protocols for Polymorphism: Define a protocol with @doc and function specification using defprotocol. Implement the protocol for specific types using defimpl with for: option. Each implementation provides the specific behavior for that type.
|
|
163
57
|
|
|
164
58
|
### Phoenix 1.7 Patterns
|
|
165
59
|
|
|
166
|
-
LiveView Component:
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
def render(assigns) do
|
|
180
|
-
~H"""
|
|
181
|
-
<div class="counter">
|
|
182
|
-
<h1>Count: <%= @count %></h1>
|
|
183
|
-
<button phx-click="increment">Increment</button>
|
|
184
|
-
</div>
|
|
185
|
-
"""
|
|
186
|
-
end
|
|
187
|
-
end
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
LiveView Form with Changesets:
|
|
191
|
-
```elixir
|
|
192
|
-
defmodule MyAppWeb.UserFormLive do
|
|
193
|
-
use MyAppWeb, :live_view
|
|
194
|
-
|
|
195
|
-
alias MyApp.Accounts
|
|
196
|
-
alias MyApp.Accounts.User
|
|
197
|
-
|
|
198
|
-
def mount(_params, _session, socket) do
|
|
199
|
-
changeset = Accounts.change_user(%User{})
|
|
200
|
-
{:ok, assign(socket, form: to_form(changeset))}
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
def handle_event("validate", %{"user" => user_params}, socket) do
|
|
204
|
-
changeset =
|
|
205
|
-
%User{}
|
|
206
|
-
|> Accounts.change_user(user_params)
|
|
207
|
-
|> Map.put(:action, :validate)
|
|
208
|
-
|
|
209
|
-
{:noreply, assign(socket, form: to_form(changeset))}
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
def handle_event("save", %{"user" => user_params}, socket) do
|
|
213
|
-
case Accounts.create_user(user_params) do
|
|
214
|
-
{:ok, user} ->
|
|
215
|
-
{:noreply,
|
|
216
|
-
socket
|
|
217
|
-
|> put_flash(:info, "User created!")
|
|
218
|
-
|> push_navigate(to: ~p"/users/#{user}")}
|
|
219
|
-
|
|
220
|
-
{:error, %Ecto.Changeset{} = changeset} ->
|
|
221
|
-
{:noreply, assign(socket, form: to_form(changeset))}
|
|
222
|
-
end
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
def render(assigns) do
|
|
226
|
-
~H"""
|
|
227
|
-
<.form for={@form} phx-change="validate" phx-submit="save">
|
|
228
|
-
<.input field={@form[:name]} label="Name" />
|
|
229
|
-
<.input field={@form[:email]} type="email" label="Email" />
|
|
230
|
-
<.button>Save</.button>
|
|
231
|
-
</.form>
|
|
232
|
-
"""
|
|
233
|
-
end
|
|
234
|
-
end
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
Phoenix Channels:
|
|
238
|
-
```elixir
|
|
239
|
-
defmodule MyAppWeb.RoomChannel do
|
|
240
|
-
use MyAppWeb, :channel
|
|
241
|
-
|
|
242
|
-
@impl true
|
|
243
|
-
def join("room:" <> room_id, _params, socket) do
|
|
244
|
-
send(self(), :after_join)
|
|
245
|
-
{:ok, assign(socket, :room_id, room_id)}
|
|
246
|
-
end
|
|
247
|
-
|
|
248
|
-
@impl true
|
|
249
|
-
def handle_info(:after_join, socket) do
|
|
250
|
-
push(socket, "presence_state", MyAppWeb.Presence.list(socket))
|
|
251
|
-
{:ok, _} = MyAppWeb.Presence.track(socket, socket.assigns.user_id, %{
|
|
252
|
-
online_at: System.system_time(:second)
|
|
253
|
-
})
|
|
254
|
-
{:noreply, socket}
|
|
255
|
-
end
|
|
256
|
-
|
|
257
|
-
@impl true
|
|
258
|
-
def handle_in("new_message", %{"body" => body}, socket) do
|
|
259
|
-
broadcast!(socket, "new_message", %{
|
|
260
|
-
user_id: socket.assigns.user_id,
|
|
261
|
-
body: body,
|
|
262
|
-
inserted_at: DateTime.utc_now()
|
|
263
|
-
})
|
|
264
|
-
{:noreply, socket}
|
|
265
|
-
end
|
|
266
|
-
end
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
Verified Routes:
|
|
270
|
-
```elixir
|
|
271
|
-
# In router.ex
|
|
272
|
-
scope "/", MyAppWeb do
|
|
273
|
-
pipe_through :browser
|
|
274
|
-
|
|
275
|
-
live "/users", UserLive.Index, :index
|
|
276
|
-
live "/users/:id", UserLive.Show, :show
|
|
277
|
-
end
|
|
278
|
-
|
|
279
|
-
# Usage with ~p sigil
|
|
280
|
-
~p"/users" # "/users"
|
|
281
|
-
~p"/users/#{user}" # "/users/123"
|
|
282
|
-
~p"/users?page=1" # "/users?page=1"
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
### Ecto Advanced Patterns
|
|
286
|
-
|
|
287
|
-
Multi for Transactions:
|
|
288
|
-
```elixir
|
|
289
|
-
def transfer_funds(from_account, to_account, amount) do
|
|
290
|
-
Ecto.Multi.new()
|
|
291
|
-
|> Ecto.Multi.update(:withdraw, withdraw_changeset(from_account, amount))
|
|
292
|
-
|> Ecto.Multi.update(:deposit, deposit_changeset(to_account, amount))
|
|
293
|
-
|> Ecto.Multi.insert(:transaction, fn %{withdraw: from, deposit: to} ->
|
|
294
|
-
Transaction.changeset(%Transaction{}, %{
|
|
295
|
-
from_account_id: from.id,
|
|
296
|
-
to_account_id: to.id,
|
|
297
|
-
amount: amount
|
|
298
|
-
})
|
|
299
|
-
end)
|
|
300
|
-
|> Repo.transaction()
|
|
301
|
-
end
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
Query Composition:
|
|
305
|
-
```elixir
|
|
306
|
-
defmodule MyApp.Accounts.UserQuery do
|
|
307
|
-
import Ecto.Query
|
|
308
|
-
|
|
309
|
-
def base, do: from(u in User)
|
|
310
|
-
|
|
311
|
-
def active(query \\ base()) do
|
|
312
|
-
from u in query, where: u.active == true
|
|
313
|
-
end
|
|
314
|
-
|
|
315
|
-
def by_email(query \\ base(), email) do
|
|
316
|
-
from u in query, where: u.email == ^email
|
|
317
|
-
end
|
|
318
|
-
|
|
319
|
-
def with_posts(query \\ base()) do
|
|
320
|
-
from u in query, preload: [:posts]
|
|
321
|
-
end
|
|
322
|
-
|
|
323
|
-
def order_by_recent(query \\ base()) do
|
|
324
|
-
from u in query, order_by: [desc: u.inserted_at]
|
|
325
|
-
end
|
|
326
|
-
end
|
|
327
|
-
|
|
328
|
-
# Usage
|
|
329
|
-
User
|
|
330
|
-
|> UserQuery.active()
|
|
331
|
-
|> UserQuery.with_posts()
|
|
332
|
-
|> UserQuery.order_by_recent()
|
|
333
|
-
|> Repo.all()
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
Embedded Schemas:
|
|
337
|
-
```elixir
|
|
338
|
-
defmodule MyApp.Order do
|
|
339
|
-
use Ecto.Schema
|
|
340
|
-
import Ecto.Changeset
|
|
341
|
-
|
|
342
|
-
schema "orders" do
|
|
343
|
-
field :status, :string
|
|
344
|
-
embeds_one :shipping_address, Address, on_replace: :update
|
|
345
|
-
embeds_many :items, Item, on_replace: :delete
|
|
346
|
-
|
|
347
|
-
timestamps()
|
|
348
|
-
end
|
|
349
|
-
|
|
350
|
-
def changeset(order, attrs) do
|
|
351
|
-
order
|
|
352
|
-
|> cast(attrs, [:status])
|
|
353
|
-
|> cast_embed(:shipping_address, required: true)
|
|
354
|
-
|> cast_embed(:items, required: true)
|
|
355
|
-
end
|
|
356
|
-
end
|
|
357
|
-
|
|
358
|
-
defmodule MyApp.Order.Address do
|
|
359
|
-
use Ecto.Schema
|
|
360
|
-
import Ecto.Changeset
|
|
361
|
-
|
|
362
|
-
embedded_schema do
|
|
363
|
-
field :street, :string
|
|
364
|
-
field :city, :string
|
|
365
|
-
field :zip, :string
|
|
366
|
-
end
|
|
367
|
-
|
|
368
|
-
def changeset(address, attrs) do
|
|
369
|
-
address
|
|
370
|
-
|> cast(attrs, [:street, :city, :zip])
|
|
371
|
-
|> validate_required([:street, :city, :zip])
|
|
372
|
-
end
|
|
373
|
-
end
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
### OTP Patterns
|
|
377
|
-
|
|
378
|
-
Supervisor Tree:
|
|
379
|
-
```elixir
|
|
380
|
-
defmodule MyApp.Application do
|
|
381
|
-
use Application
|
|
382
|
-
|
|
383
|
-
@impl true
|
|
384
|
-
def start(_type, _args) do
|
|
385
|
-
children = [
|
|
386
|
-
MyApp.Repo,
|
|
387
|
-
MyAppWeb.Telemetry,
|
|
388
|
-
{Phoenix.PubSub, name: MyApp.PubSub},
|
|
389
|
-
MyAppWeb.Endpoint,
|
|
390
|
-
{MyApp.Cache, []},
|
|
391
|
-
{Task.Supervisor, name: MyApp.TaskSupervisor},
|
|
392
|
-
MyApp.SchedulerSupervisor
|
|
393
|
-
]
|
|
394
|
-
|
|
395
|
-
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
|
|
396
|
-
Supervisor.start_link(children, opts)
|
|
397
|
-
end
|
|
398
|
-
end
|
|
399
|
-
```
|
|
400
|
-
|
|
401
|
-
Dynamic Supervisor:
|
|
402
|
-
```elixir
|
|
403
|
-
defmodule MyApp.WorkerSupervisor do
|
|
404
|
-
use DynamicSupervisor
|
|
405
|
-
|
|
406
|
-
def start_link(init_arg) do
|
|
407
|
-
DynamicSupervisor.start_link(__MODULE__, init_arg, name: __MODULE__)
|
|
408
|
-
end
|
|
409
|
-
|
|
410
|
-
@impl true
|
|
411
|
-
def init(_init_arg) do
|
|
412
|
-
DynamicSupervisor.init(strategy: :one_for_one)
|
|
413
|
-
end
|
|
414
|
-
|
|
415
|
-
def start_worker(args) do
|
|
416
|
-
spec = {MyApp.Worker, args}
|
|
417
|
-
DynamicSupervisor.start_child(__MODULE__, spec)
|
|
418
|
-
end
|
|
419
|
-
|
|
420
|
-
def stop_worker(pid) do
|
|
421
|
-
DynamicSupervisor.terminate_child(__MODULE__, pid)
|
|
422
|
-
end
|
|
423
|
-
end
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
Registry for Named Processes:
|
|
427
|
-
```elixir
|
|
428
|
-
# Start registry in application supervision tree
|
|
429
|
-
{Registry, keys: :unique, name: MyApp.Registry}
|
|
430
|
-
|
|
431
|
-
# GenServer with dynamic name
|
|
432
|
-
defmodule MyApp.Session do
|
|
433
|
-
use GenServer
|
|
434
|
-
|
|
435
|
-
def start_link(user_id) do
|
|
436
|
-
GenServer.start_link(__MODULE__, user_id, name: via_tuple(user_id))
|
|
437
|
-
end
|
|
438
|
-
|
|
439
|
-
defp via_tuple(user_id) do
|
|
440
|
-
{:via, Registry, {MyApp.Registry, {:session, user_id}}}
|
|
441
|
-
end
|
|
442
|
-
|
|
443
|
-
def get_session(user_id) do
|
|
444
|
-
GenServer.call(via_tuple(user_id), :get)
|
|
445
|
-
end
|
|
446
|
-
end
|
|
447
|
-
```
|
|
448
|
-
|
|
449
|
-
### ExUnit Testing
|
|
450
|
-
|
|
451
|
-
Async Tests with Setup:
|
|
452
|
-
```elixir
|
|
453
|
-
defmodule MyApp.AccountsTest do
|
|
454
|
-
use MyApp.DataCase, async: true
|
|
455
|
-
|
|
456
|
-
alias MyApp.Accounts
|
|
457
|
-
|
|
458
|
-
describe "users" do
|
|
459
|
-
setup do
|
|
460
|
-
user = insert(:user)
|
|
461
|
-
{:ok, user: user}
|
|
462
|
-
end
|
|
463
|
-
|
|
464
|
-
test "get_user!/1 returns the user with given id", %{user: user} do
|
|
465
|
-
assert Accounts.get_user!(user.id) == user
|
|
466
|
-
end
|
|
467
|
-
|
|
468
|
-
test "create_user/1 with valid data creates a user" do
|
|
469
|
-
valid_attrs = %{name: "Test", email: "test@example.com", password: "password123"}
|
|
470
|
-
|
|
471
|
-
assert {:ok, %User{} = user} = Accounts.create_user(valid_attrs)
|
|
472
|
-
assert user.name == "Test"
|
|
473
|
-
assert user.email == "test@example.com"
|
|
474
|
-
end
|
|
475
|
-
|
|
476
|
-
test "create_user/1 with invalid data returns error changeset" do
|
|
477
|
-
assert {:error, %Ecto.Changeset{}} = Accounts.create_user(%{})
|
|
478
|
-
end
|
|
479
|
-
end
|
|
480
|
-
end
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
LiveView Testing:
|
|
484
|
-
```elixir
|
|
485
|
-
defmodule MyAppWeb.CounterLiveTest do
|
|
486
|
-
use MyAppWeb.ConnCase
|
|
487
|
-
|
|
488
|
-
import Phoenix.LiveViewTest
|
|
489
|
-
|
|
490
|
-
test "renders counter", %{conn: conn} do
|
|
491
|
-
{:ok, view, html} = live(conn, ~p"/counter")
|
|
492
|
-
|
|
493
|
-
assert html =~ "Count: 0"
|
|
494
|
-
end
|
|
495
|
-
|
|
496
|
-
test "increments counter on click", %{conn: conn} do
|
|
497
|
-
{:ok, view, _html} = live(conn, ~p"/counter")
|
|
498
|
-
|
|
499
|
-
assert view
|
|
500
|
-
|> element("button", "Increment")
|
|
501
|
-
|> render_click() =~ "Count: 1"
|
|
502
|
-
end
|
|
503
|
-
end
|
|
504
|
-
```
|
|
505
|
-
|
|
506
|
-
### Oban Background Jobs
|
|
507
|
-
|
|
508
|
-
Job Worker:
|
|
509
|
-
```elixir
|
|
510
|
-
defmodule MyApp.Workers.EmailWorker do
|
|
511
|
-
use Oban.Worker, queue: :mailers, max_attempts: 3
|
|
512
|
-
|
|
513
|
-
@impl Oban.Worker
|
|
514
|
-
def perform(%Oban.Job{args: %{"email" => email, "template" => template}}) do
|
|
515
|
-
case MyApp.Mailer.send_email(email, template) do
|
|
516
|
-
{:ok, _} -> :ok
|
|
517
|
-
{:error, reason} -> {:error, reason}
|
|
518
|
-
end
|
|
519
|
-
end
|
|
520
|
-
end
|
|
521
|
-
|
|
522
|
-
# Enqueue job
|
|
523
|
-
%{email: "user@example.com", template: "welcome"}
|
|
524
|
-
|> MyApp.Workers.EmailWorker.new()
|
|
525
|
-
|> Oban.insert()
|
|
526
|
-
|
|
527
|
-
# Scheduled job
|
|
528
|
-
%{email: "user@example.com", template: "reminder"}
|
|
529
|
-
|> MyApp.Workers.EmailWorker.new(scheduled_at: DateTime.add(DateTime.utc_now(), 3600))
|
|
530
|
-
|> Oban.insert()
|
|
531
|
-
```
|
|
60
|
+
LiveView Component: Define a module using MyAppWeb with :live_view. Implement mount callback taking params, session, and socket, returning ok tuple with assigned state. Implement handle_event callback for user interactions, returning noreply tuple with updated socket using update helper. Implement render callback with assigns, using ~H sigil for HEEx templates with assigns accessed via @ prefix.
|
|
61
|
+
|
|
62
|
+
LiveView Form with Changesets: In mount, create initial changeset and assign using to_form helper. Implement validate event handler that creates changeset with :validate action and reassigns the form. Implement save event handler that calls context create function, on success using put_flash and push_navigate, on error reassigning the form with error changeset.
|
|
63
|
+
|
|
64
|
+
Phoenix Channels: Define a module using MyAppWeb with :channel. Implement join callback matching on topic pattern with angle brackets for dynamic segments. Use send with self() for after_join messages. Implement handle_info for server-side messages using push. Implement handle_in for client messages using broadcast! to send to all subscribers.
|
|
65
|
+
|
|
66
|
+
Verified Routes: Define routes in router.ex within scope blocks using live macro for LiveView routes. Use ~p sigil for verified routes in templates and controllers, with interpolation syntax for dynamic segments.
|
|
67
|
+
|
|
68
|
+
### Ecto Patterns
|
|
69
|
+
|
|
70
|
+
Multi for Transactions: Use Ecto.Multi.new() and pipe through operations using Ecto.Multi.update with name atoms and changeset functions. Use Ecto.Multi.insert with function callback when needing results from previous steps. Pipe final Multi to Repo.transaction() which returns ok or error tuple with named results.
|
|
71
|
+
|
|
72
|
+
Query Composition: Create a query module with composable query functions. Define a base function returning from expression. Create filter functions with default parameter for query, returning modified from expression with where clause. Chain functions with pipe operator before passing to Repo.all.
|
|
532
73
|
|
|
533
74
|
---
|
|
534
75
|
|
|
535
76
|
## Advanced Implementation (10+ minutes)
|
|
536
77
|
|
|
537
78
|
For comprehensive coverage including:
|
|
79
|
+
|
|
538
80
|
- Production deployment with releases
|
|
539
81
|
- Distributed systems with libcluster
|
|
540
82
|
- Advanced LiveView patterns (streams, components)
|
|
83
|
+
- OTP supervision trees and dynamic supervisors
|
|
541
84
|
- Telemetry and observability
|
|
542
85
|
- Security best practices
|
|
543
86
|
- CI/CD integration patterns
|
|
544
87
|
|
|
545
88
|
See:
|
|
546
|
-
|
|
547
|
-
- [
|
|
89
|
+
|
|
90
|
+
- [Advanced Patterns](modules/advanced-patterns.md) - Complete advanced patterns guide
|
|
548
91
|
|
|
549
92
|
---
|
|
550
93
|
|
|
551
94
|
## Context7 Library Mappings
|
|
552
95
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
/phoenixframework/
|
|
556
|
-
/
|
|
557
|
-
|
|
558
|
-
/sorentwo/oban - Background job processing
|
|
559
|
-
```
|
|
96
|
+
- /elixir-lang/elixir - Elixir language documentation
|
|
97
|
+
- /phoenixframework/phoenix - Phoenix web framework
|
|
98
|
+
- /phoenixframework/phoenix_live_view - LiveView real-time UI
|
|
99
|
+
- /elixir-ecto/ecto - Database wrapper and query language
|
|
100
|
+
- /sorentwo/oban - Background job processing
|
|
560
101
|
|
|
561
102
|
---
|
|
562
103
|
|
|
@@ -564,7 +105,7 @@ See:
|
|
|
564
105
|
|
|
565
106
|
- `moai-domain-backend` - REST API and microservices architecture
|
|
566
107
|
- `moai-domain-database` - SQL patterns and query optimization
|
|
567
|
-
- `moai-
|
|
108
|
+
- `moai-workflow-testing` - TDD and testing strategies
|
|
568
109
|
- `moai-essentials-debug` - AI-powered debugging
|
|
569
110
|
- `moai-platform-deploy` - Deployment and infrastructure
|
|
570
111
|
|
|
@@ -574,39 +115,21 @@ See:
|
|
|
574
115
|
|
|
575
116
|
Common Issues:
|
|
576
117
|
|
|
577
|
-
Elixir Version Check:
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
```bash
|
|
585
|
-
mix deps.get # Fetch dependencies
|
|
586
|
-
mix deps.compile # Compile dependencies
|
|
587
|
-
mix clean # Clean build artifacts
|
|
588
|
-
```
|
|
589
|
-
|
|
590
|
-
Database Migrations:
|
|
591
|
-
```bash
|
|
592
|
-
mix ecto.create # Create database
|
|
593
|
-
mix ecto.migrate # Run migrations
|
|
594
|
-
mix ecto.rollback # Rollback last migration
|
|
595
|
-
```
|
|
596
|
-
|
|
597
|
-
Phoenix Server:
|
|
598
|
-
```bash
|
|
599
|
-
mix phx.server # Start server
|
|
600
|
-
iex -S mix phx.server # Start with IEx
|
|
601
|
-
MIX_ENV=prod mix release # Build release
|
|
602
|
-
```
|
|
118
|
+
Elixir Version Check: Run elixir --version to verify 1.17+ and mix --version for Mix build tool version.
|
|
119
|
+
|
|
120
|
+
Dependency Issues: Run mix deps.get to fetch dependencies, mix deps.compile to compile them, and mix clean to remove build artifacts.
|
|
121
|
+
|
|
122
|
+
Database Migrations: Run mix ecto.create to create database, mix ecto.migrate to run migrations, and mix ecto.rollback to rollback last migration.
|
|
123
|
+
|
|
124
|
+
Phoenix Server: Run mix phx.server to start the server, iex -S mix phx.server to start with IEx shell, and MIX_ENV=prod mix release to build production release.
|
|
603
125
|
|
|
604
126
|
LiveView Not Loading:
|
|
605
|
-
|
|
606
|
-
-
|
|
607
|
-
-
|
|
127
|
+
|
|
128
|
+
- Check websocket connection in browser developer console
|
|
129
|
+
- Verify endpoint configuration includes websocket transport
|
|
130
|
+
- Ensure Phoenix.LiveView is listed in mix.exs dependencies
|
|
608
131
|
|
|
609
132
|
---
|
|
610
133
|
|
|
611
|
-
Last Updated:
|
|
612
|
-
Status: Active (v1.
|
|
134
|
+
Last Updated: 2026-01-11
|
|
135
|
+
Status: Active (v1.1.0)
|