moai-adk 0.32.8__py3-none-any.whl → 0.41.2__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/cli/commands/init.py +4 -1
- moai_adk/cli/commands/update.py +31 -26
- moai_adk/cli/worktree/cli.py +54 -43
- moai_adk/cli/worktree/manager.py +17 -14
- moai_adk/cli/worktree/registry.py +313 -19
- moai_adk/core/config/unified.py +237 -63
- 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/language_config_resolver.py +96 -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/project/backup_utils.py +9 -1
- moai_adk/core/project/initializer.py +33 -96
- moai_adk/core/project/phase_executor.py +79 -33
- moai_adk/core/quality/trust_checker.py +30 -10
- moai_adk/core/realtime_monitoring_dashboard.py +3 -3
- moai_adk/core/rollback_manager.py +46 -19
- moai_adk/core/template/backup.py +4 -3
- moai_adk/core/template/config.py +33 -9
- moai_adk/core/template/merger.py +34 -8
- moai_adk/core/template/processor.py +144 -9
- 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/project/configuration.py +1 -1
- moai_adk/statusline/config.py +5 -2
- moai_adk/statusline/main.py +58 -0
- moai_adk/statusline/renderer.py +56 -84
- moai_adk/templates/.claude/agents/moai/ai-nano-banana.md +218 -51
- moai_adk/templates/.claude/agents/moai/builder-agent.md +46 -11
- moai_adk/templates/.claude/agents/moai/builder-command.md +88 -26
- moai_adk/templates/.claude/agents/moai/builder-plugin.md +753 -0
- moai_adk/templates/.claude/agents/moai/builder-skill.md +79 -8
- moai_adk/templates/.claude/agents/moai/expert-backend.md +100 -28
- moai_adk/templates/.claude/agents/moai/expert-database.md +20 -12
- moai_adk/templates/.claude/agents/moai/expert-debug.md +19 -8
- moai_adk/templates/.claude/agents/moai/expert-devops.md +36 -25
- moai_adk/templates/.claude/agents/moai/expert-frontend.md +99 -38
- moai_adk/templates/.claude/agents/moai/expert-performance.md +661 -0
- moai_adk/templates/.claude/agents/moai/expert-refactoring.md +218 -0
- moai_adk/templates/.claude/agents/moai/expert-security.md +55 -4
- moai_adk/templates/.claude/agents/moai/expert-testing.md +737 -0
- moai_adk/templates/.claude/agents/moai/expert-uiux.md +20 -11
- moai_adk/templates/.claude/agents/moai/manager-claude-code.md +13 -4
- moai_adk/templates/.claude/agents/moai/manager-docs.md +15 -7
- moai_adk/templates/.claude/agents/moai/manager-git.md +192 -37
- moai_adk/templates/.claude/agents/moai/manager-project.md +13 -7
- moai_adk/templates/.claude/agents/moai/manager-quality.md +48 -6
- moai_adk/templates/.claude/agents/moai/manager-spec.md +110 -8
- moai_adk/templates/.claude/agents/moai/manager-strategy.md +203 -17
- moai_adk/templates/.claude/agents/moai/manager-tdd.md +217 -23
- moai_adk/templates/.claude/agents/moai/mcp-context7.md +102 -7
- moai_adk/templates/.claude/agents/moai/mcp-figma.md +107 -86
- moai_adk/templates/.claude/agents/moai/mcp-notion.md +50 -4
- moai_adk/templates/.claude/agents/moai/mcp-playwright.md +52 -4
- moai_adk/templates/.claude/agents/moai/mcp-sequential-thinking.md +49 -5
- moai_adk/templates/.claude/commands/moai/0-project.md +503 -307
- moai_adk/templates/.claude/commands/moai/1-plan.md +255 -323
- moai_adk/templates/.claude/commands/moai/2-run.md +257 -315
- moai_adk/templates/.claude/commands/moai/3-sync.md +421 -56
- moai_adk/templates/.claude/commands/moai/9-feedback.md +40 -34
- moai_adk/templates/.claude/hooks/moai/__init__.py +0 -0
- moai_adk/templates/.claude/hooks/moai/lib/README.md +143 -0
- moai_adk/templates/.claude/hooks/moai/lib/__init__.py +19 -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_manager.py +12 -14
- moai_adk/templates/.claude/hooks/moai/lib/exceptions.py +171 -0
- moai_adk/templates/.claude/hooks/moai/lib/git_operations_manager.py +1 -1
- moai_adk/templates/.claude/hooks/moai/lib/language_validator.py +104 -14
- 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/tool_registry.py +804 -0
- moai_adk/templates/.claude/hooks/moai/lib/unified_timeout_manager.py +14 -2
- moai_adk/templates/.claude/hooks/moai/post_tool__ast_grep_scan.py +256 -0
- moai_adk/templates/.claude/hooks/moai/post_tool__code_formatter.py +253 -0
- moai_adk/templates/.claude/hooks/moai/post_tool__linter.py +307 -0
- moai_adk/templates/.claude/hooks/moai/pre_tool__security_guard.py +231 -0
- moai_adk/templates/.claude/hooks/moai/session_end__auto_cleanup.py +40 -24
- moai_adk/templates/.claude/hooks/moai/session_start__show_project_info.py +248 -32
- moai_adk/templates/.claude/output-styles/moai/r2d2.md +265 -2
- moai_adk/templates/.claude/output-styles/moai/yoda.md +23 -2
- moai_adk/templates/.claude/settings.json +44 -6
- moai_adk/templates/.claude/skills/moai-ai-nano-banana/SKILL.md +303 -0
- moai_adk/templates/.claude/skills/moai-ai-nano-banana/examples.md +431 -0
- moai_adk/templates/.claude/skills/moai-ai-nano-banana/reference.md +139 -0
- moai_adk/templates/.claude/skills/moai-ai-nano-banana/scripts/batch_generate.py +560 -0
- moai_adk/templates/.claude/skills/moai-ai-nano-banana/scripts/generate_image.py +362 -0
- moai_adk/templates/.claude/skills/moai-docs-generation/SKILL.md +252 -196
- moai_adk/templates/.claude/skills/moai-docs-generation/examples.md +252 -0
- 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 +234 -0
- moai_adk/templates/.claude/skills/moai-domain-backend/SKILL.md +19 -13
- moai_adk/templates/.claude/skills/moai-domain-backend/examples.md +718 -0
- moai_adk/templates/.claude/skills/moai-domain-backend/reference.md +464 -0
- moai_adk/templates/.claude/skills/moai-domain-database/SKILL.md +21 -14
- moai_adk/templates/.claude/skills/moai-domain-database/examples.md +830 -0
- moai_adk/templates/.claude/skills/moai-domain-database/reference.md +545 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/SKILL.md +124 -425
- moai_adk/templates/.claude/skills/moai-domain-frontend/examples.md +968 -0
- 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-frontend/reference.md +664 -0
- moai_adk/templates/.claude/skills/moai-domain-uiux/SKILL.md +17 -15
- moai_adk/templates/.claude/skills/moai-formats-data/SKILL.md +105 -315
- moai_adk/templates/.claude/skills/moai-formats-data/examples.md +804 -0
- moai_adk/templates/.claude/skills/moai-formats-data/modules/README.md +299 -70
- moai_adk/templates/.claude/skills/moai-formats-data/modules/toon-encoding.md +6 -6
- moai_adk/templates/.claude/skills/moai-formats-data/reference.md +585 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/SKILL.md +197 -154
- moai_adk/templates/.claude/skills/moai-foundation-claude/examples.md +732 -0
- 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-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-memory-official.md +2 -2
- 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 +432 -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-claude/reference.md +209 -0
- moai_adk/templates/.claude/skills/moai-foundation-context/SKILL.md +12 -1
- moai_adk/templates/.claude/skills/moai-foundation-context/examples.md +1048 -0
- moai_adk/templates/.claude/skills/moai-foundation-context/reference.md +246 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/SKILL.md +33 -134
- moai_adk/templates/.claude/skills/moai-foundation-core/examples.md +358 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/agents-reference.md +31 -18
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/commands-reference.md +30 -30
- 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-core/reference.md +478 -0
- moai_adk/templates/.claude/skills/moai-foundation-philosopher/SKILL.md +311 -0
- moai_adk/templates/.claude/skills/moai-foundation-philosopher/examples.md +228 -0
- moai_adk/templates/.claude/skills/moai-foundation-philosopher/modules/assumption-matrix.md +80 -0
- moai_adk/templates/.claude/skills/moai-foundation-philosopher/modules/cognitive-bias.md +199 -0
- moai_adk/templates/.claude/skills/moai-foundation-philosopher/modules/first-principles.md +140 -0
- moai_adk/templates/.claude/skills/moai-foundation-philosopher/modules/trade-off-analysis.md +154 -0
- moai_adk/templates/.claude/skills/moai-foundation-philosopher/reference.md +157 -0
- moai_adk/templates/.claude/skills/moai-foundation-quality/SKILL.md +17 -16
- moai_adk/templates/.claude/skills/moai-lang-cpp/SKILL.md +431 -0
- moai_adk/templates/.claude/skills/moai-lang-cpp/examples.md +17 -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 +17 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/SKILL.md +194 -0
- 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 +395 -0
- moai_adk/templates/.claude/skills/moai-lang-elixir/examples.md +17 -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 +17 -0
- moai_adk/templates/.claude/skills/moai-lang-flutter/SKILL.md +473 -0
- moai_adk/templates/.claude/skills/moai-lang-flutter/examples.md +1090 -0
- moai_adk/templates/.claude/skills/moai-lang-flutter/reference.md +686 -0
- moai_adk/templates/.claude/skills/moai-lang-go/SKILL.md +378 -0
- moai_adk/templates/.claude/skills/moai-lang-go/examples.md +919 -0
- moai_adk/templates/.claude/skills/moai-lang-go/reference.md +737 -0
- moai_adk/templates/.claude/skills/moai-lang-java/SKILL.md +387 -0
- moai_adk/templates/.claude/skills/moai-lang-java/examples.md +864 -0
- moai_adk/templates/.claude/skills/moai-lang-java/reference.md +291 -0
- moai_adk/templates/.claude/skills/moai-lang-javascript/SKILL.md +419 -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 +384 -0
- moai_adk/templates/.claude/skills/moai-lang-kotlin/examples.md +1006 -0
- moai_adk/templates/.claude/skills/moai-lang-kotlin/reference.md +562 -0
- moai_adk/templates/.claude/skills/moai-lang-php/SKILL.md +505 -0
- moai_adk/templates/.claude/skills/moai-lang-php/examples.md +17 -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 +17 -0
- moai_adk/templates/.claude/skills/moai-lang-python/SKILL.md +490 -0
- moai_adk/templates/.claude/skills/moai-lang-python/examples.md +977 -0
- moai_adk/templates/.claude/skills/moai-lang-python/reference.md +804 -0
- moai_adk/templates/.claude/skills/moai-lang-r/SKILL.md +390 -0
- moai_adk/templates/.claude/skills/moai-lang-r/examples.md +17 -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 +17 -0
- moai_adk/templates/.claude/skills/moai-lang-ruby/SKILL.md +433 -0
- moai_adk/templates/.claude/skills/moai-lang-ruby/examples.md +17 -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 +17 -0
- moai_adk/templates/.claude/skills/moai-lang-rust/SKILL.md +378 -0
- moai_adk/templates/.claude/skills/moai-lang-rust/examples.md +659 -0
- moai_adk/templates/.claude/skills/moai-lang-rust/reference.md +504 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/SKILL.md +212 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/examples.md +633 -0
- 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-scala/reference.md +423 -0
- moai_adk/templates/.claude/skills/moai-lang-swift/SKILL.md +192 -0
- moai_adk/templates/.claude/skills/moai-lang-swift/examples.md +918 -0
- 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-swift/reference.md +672 -0
- moai_adk/templates/.claude/skills/moai-lang-typescript/SKILL.md +365 -0
- moai_adk/templates/.claude/skills/moai-lang-typescript/examples.md +1089 -0
- moai_adk/templates/.claude/skills/moai-lang-typescript/reference.md +731 -0
- moai_adk/templates/.claude/skills/moai-library-mermaid/SKILL.md +94 -227
- moai_adk/templates/.claude/skills/moai-library-nextra/SKILL.md +26 -6
- moai_adk/templates/.claude/skills/moai-library-nextra/examples.md +592 -0
- 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-nextra/reference.md +379 -0
- moai_adk/templates/.claude/skills/moai-library-shadcn/SKILL.md +17 -13
- moai_adk/templates/.claude/skills/moai-library-shadcn/modules/shadcn-theming.md +1 -1
- moai_adk/templates/.claude/skills/moai-platform-auth0/SKILL.md +284 -0
- 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 +426 -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 +229 -0
- 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 +250 -0
- 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 +231 -0
- 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 +206 -0
- 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 +224 -0
- 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 +207 -0
- 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 +210 -0
- 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-plugin-builder/SKILL.md +474 -0
- moai_adk/templates/.claude/skills/moai-plugin-builder/examples.md +621 -0
- moai_adk/templates/.claude/skills/moai-plugin-builder/modules/migration.md +341 -0
- moai_adk/templates/.claude/skills/moai-plugin-builder/modules/validation.md +373 -0
- moai_adk/templates/.claude/skills/moai-plugin-builder/reference.md +464 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/SKILL.md +307 -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-tool-opencode/SKILL.md +215 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/examples.md +697 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/index.md +96 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/acp.md +115 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/agents.md +241 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/commands.md +197 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/custom-tools.md +197 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/formatters.md +164 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/keybinds.md +150 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/lsp-servers.md +156 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/mcp-servers.md +214 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/models.md +197 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/permissions.md +162 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/rules.md +129 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/skills.md +192 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/themes.md +200 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/tools.md +169 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/core/config.md +211 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/core/enterprise.md +68 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/core/intro.md +127 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/core/migration-1.0.md +82 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/core/network.md +72 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/core/providers.md +310 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/core/troubleshooting.md +124 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/develop/ecosystem.md +75 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/develop/plugins.md +218 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/develop/sdk.md +266 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/develop/server.md +207 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/usage/cli.md +159 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/usage/github.md +181 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/usage/gitlab.md +122 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/usage/ide.md +74 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/usage/share.md +106 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/usage/tui.md +129 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/usage/zen.md +118 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/reference.md +790 -0
- moai_adk/templates/.claude/skills/moai-workflow-jit-docs/SKILL.md +190 -424
- moai_adk/templates/.claude/skills/moai-workflow-jit-docs/examples.md +544 -0
- moai_adk/templates/.claude/skills/moai-workflow-jit-docs/reference.md +307 -0
- moai_adk/templates/.claude/skills/moai-workflow-project/SKILL.md +188 -314
- moai_adk/templates/.claude/skills/moai-workflow-project/examples.md +547 -0
- moai_adk/templates/.claude/skills/moai-workflow-project/reference.md +275 -0
- moai_adk/templates/.claude/skills/moai-workflow-project/schemas/tab_schema.json +284 -212
- moai_adk/templates/.claude/skills/moai-workflow-project/templates/doc-templates/product-template.md +2 -2
- moai_adk/templates/.claude/skills/moai-workflow-project/templates/doc-templates/structure-template.md +1 -1
- moai_adk/templates/.claude/skills/moai-workflow-project/templates/doc-templates/tech-template.md +22 -1
- moai_adk/templates/.claude/skills/moai-workflow-spec/SKILL.md +337 -0
- moai_adk/templates/.claude/skills/moai-workflow-spec/examples.md +900 -0
- moai_adk/templates/.claude/skills/moai-workflow-spec/modules/advanced-patterns.md +237 -0
- moai_adk/templates/.claude/skills/moai-workflow-spec/reference.md +704 -0
- moai_adk/templates/.claude/skills/moai-workflow-templates/SKILL.md +13 -0
- moai_adk/templates/.claude/skills/moai-workflow-templates/examples.md +552 -0
- moai_adk/templates/.claude/skills/moai-workflow-templates/reference.md +346 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/SKILL.md +222 -367
- moai_adk/templates/.claude/skills/moai-workflow-testing/examples.md +672 -0
- 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-testing/reference.md +440 -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 +168 -50
- moai_adk/templates/.gitignore +0 -3
- moai_adk/templates/.lsp.json +152 -0
- moai_adk/templates/.mcp.json +5 -12
- moai_adk/templates/.moai/config/config.yaml +20 -306
- moai_adk/templates/.moai/config/multilingual-triggers.yaml +213 -0
- moai_adk/templates/.moai/config/questions/_schema.yaml +105 -10
- moai_adk/templates/.moai/config/questions/tab0-init.yaml +259 -0
- moai_adk/templates/.moai/config/questions/tab1-user.yaml +4 -5
- moai_adk/templates/.moai/config/questions/tab2-project.yaml +12 -55
- moai_adk/templates/.moai/config/questions/tab3-git.yaml +111 -21
- moai_adk/templates/.moai/config/questions/tab4-quality.yaml +34 -18
- moai_adk/templates/.moai/config/questions/tab5-system.yaml +19 -75
- moai_adk/templates/.moai/config/sections/git-strategy.yaml +83 -7
- moai_adk/templates/.moai/config/sections/language.yaml +7 -7
- moai_adk/templates/.moai/config/sections/project.yaml +1 -1
- moai_adk/templates/.moai/config/sections/quality.yaml +7 -4
- moai_adk/templates/.moai/config/sections/system.yaml +11 -1
- moai_adk/templates/.moai/config/statusline-config.yaml +19 -13
- moai_adk/templates/.moai/scripts/setup-glm.py +4 -4
- moai_adk/templates/CLAUDE.md +578 -154
- moai_adk/utils/common.py +33 -0
- moai_adk/version.py +1 -1
- {moai_adk-0.32.8.dist-info → moai_adk-0.41.2.dist-info}/METADATA +905 -109
- moai_adk-0.41.2.dist-info/RECORD +683 -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/skills/moai-domain-uiux/modules/design-system-tokens.md +0 -405
- moai_adk/templates/.claude/skills/moai-integration-mcp/SKILL.md +0 -352
- moai_adk/templates/.claude/skills/moai-integration-mcp/modules/README.md +0 -52
- moai_adk/templates/.claude/skills/moai-integration-mcp/modules/error-handling.md +0 -334
- moai_adk/templates/.claude/skills/moai-integration-mcp/modules/integration-patterns.md +0 -310
- moai_adk/templates/.claude/skills/moai-integration-mcp/modules/security-authentication.md +0 -256
- moai_adk/templates/.claude/skills/moai-integration-mcp/modules/server-architecture.md +0 -253
- moai_adk/templates/.claude/skills/moai-lang-unified/README.md +0 -133
- moai_adk/templates/.claude/skills/moai-lang-unified/SKILL.md +0 -296
- moai_adk/templates/.claude/skills/moai-lang-unified/examples.md +0 -1269
- moai_adk/templates/.claude/skills/moai-lang-unified/reference.md +0 -331
- moai_adk/templates/.claude/skills/moai-library-nextra/advanced-patterns.md +0 -336
- moai_adk/templates/.claude/skills/moai-platform-baas/README.md +0 -186
- moai_adk/templates/.claude/skills/moai-platform-baas/SKILL.md +0 -290
- moai_adk/templates/.claude/skills/moai-platform-baas/examples.md +0 -1225
- moai_adk/templates/.claude/skills/moai-platform-baas/reference.md +0 -567
- moai_adk/templates/.claude/skills/moai-platform-baas/scripts/provider-selector.py +0 -323
- moai_adk/templates/.claude/skills/moai-platform-baas/templates/stack-config.yaml +0 -204
- 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 -135
- 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 -410
- 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/cache/personalization.json +0 -10
- moai_adk/templates/.moai/config/presets/manual.yaml +0 -28
- moai_adk/templates/.moai/config/presets/personal.yaml +0 -30
- moai_adk/templates/.moai/config/presets/team.yaml +0 -33
- moai_adk-0.32.8.dist-info/RECORD +0 -396
- /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.32.8.dist-info → moai_adk-0.41.2.dist-info}/WHEEL +0 -0
- {moai_adk-0.32.8.dist-info → moai_adk-0.41.2.dist-info}/entry_points.txt +0 -0
- {moai_adk-0.32.8.dist-info → moai_adk-0.41.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,1269 +0,0 @@
|
|
|
1
|
-
# Multi-Language Code Examples
|
|
2
|
-
|
|
3
|
-
## Quick Start Examples
|
|
4
|
-
|
|
5
|
-
### REST API Implementation by Language
|
|
6
|
-
|
|
7
|
-
#### Python (FastAPI)
|
|
8
|
-
```python
|
|
9
|
-
# main.py
|
|
10
|
-
from fastapi import FastAPI, HTTPException, Depends
|
|
11
|
-
from pydantic import BaseModel
|
|
12
|
-
from typing import List, Optional
|
|
13
|
-
import asyncpg
|
|
14
|
-
|
|
15
|
-
app = FastAPI(title="User API", version="1.0.0")
|
|
16
|
-
|
|
17
|
-
# Models
|
|
18
|
-
class User(BaseModel):
|
|
19
|
-
id: int
|
|
20
|
-
name: str
|
|
21
|
-
email: str
|
|
22
|
-
created_at: Optional[str] = None
|
|
23
|
-
|
|
24
|
-
class CreateUserRequest(BaseModel):
|
|
25
|
-
name: str
|
|
26
|
-
email: str
|
|
27
|
-
|
|
28
|
-
# Database
|
|
29
|
-
DATABASE_URL = "postgresql+asyncpg://user:pass@localhost/db"
|
|
30
|
-
|
|
31
|
-
async def get_db():
|
|
32
|
-
return await asyncpg.connect(DATABASE_URL)
|
|
33
|
-
|
|
34
|
-
# Routes
|
|
35
|
-
@app.get("/users", response_model=List[User])
|
|
36
|
-
async def list_users():
|
|
37
|
-
conn = await get_db()
|
|
38
|
-
rows = await conn.fetch("SELECT id, name, email, created_at FROM users")
|
|
39
|
-
await conn.close()
|
|
40
|
-
return [User(dict(row)) for row in rows]
|
|
41
|
-
|
|
42
|
-
@app.get("/users/{user_id}", response_model=User)
|
|
43
|
-
async def get_user(user_id: int):
|
|
44
|
-
conn = await get_db()
|
|
45
|
-
row = await conn.fetchrow("SELECT id, name, email, created_at FROM users WHERE id = $1", user_id)
|
|
46
|
-
await conn.close()
|
|
47
|
-
if not row:
|
|
48
|
-
raise HTTPException(status_code=404, detail="User not found")
|
|
49
|
-
return User(dict(row))
|
|
50
|
-
|
|
51
|
-
@app.post("/users", response_model=User, status_code=201)
|
|
52
|
-
async def create_user(user: CreateUserRequest):
|
|
53
|
-
conn = await get_db()
|
|
54
|
-
row = await conn.fetchrow(
|
|
55
|
-
"INSERT INTO users (name, email) VALUES ($1, $2) RETURNING id, name, email, created_at",
|
|
56
|
-
user.name, user.email
|
|
57
|
-
)
|
|
58
|
-
await conn.close()
|
|
59
|
-
return User(dict(row))
|
|
60
|
-
|
|
61
|
-
# Run: uvicorn main:app --reload --host 0.0.0.0 --port 8000
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
#### TypeScript (Express.js)
|
|
65
|
-
```typescript
|
|
66
|
-
// src/app.ts
|
|
67
|
-
import express, { Request, Response } from 'express';
|
|
68
|
-
import { Pool } from 'pg';
|
|
69
|
-
import { z } from 'zod';
|
|
70
|
-
|
|
71
|
-
const app = express();
|
|
72
|
-
app.use(express.json());
|
|
73
|
-
|
|
74
|
-
// Database
|
|
75
|
-
const pool = new Pool({
|
|
76
|
-
connectionString: 'postgresql://user:pass@localhost/db'
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
// Schemas
|
|
80
|
-
const CreateUserSchema = z.object({
|
|
81
|
-
name: z.string().min(2),
|
|
82
|
-
email: z.string().email()
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
const UserSchema = z.object({
|
|
86
|
-
id: z.number(),
|
|
87
|
-
name: z.string(),
|
|
88
|
-
email: z.string(),
|
|
89
|
-
created_at: z.string().nullable()
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
type User = z.infer<typeof UserSchema>;
|
|
93
|
-
type CreateUserRequest = z.infer<typeof CreateUserSchema>;
|
|
94
|
-
|
|
95
|
-
// Routes
|
|
96
|
-
app.get('/users', async (req: Request, res: Response) => {
|
|
97
|
-
const result = await pool.query('SELECT id, name, email, created_at FROM users');
|
|
98
|
-
const users = result.rows.map(row => UserSchema.parse(row));
|
|
99
|
-
res.json(users);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
app.get('/users/:id', async (req: Request, res: Response) => {
|
|
103
|
-
const { id } = req.params;
|
|
104
|
-
const result = await pool.query(
|
|
105
|
-
'SELECT id, name, email, created_at FROM users WHERE id = $1',
|
|
106
|
-
[parseInt(id)]
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
if (result.rows.length === 0) {
|
|
110
|
-
return res.status(404).json({ error: 'User not found' });
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const user = UserSchema.parse(result.rows[0]);
|
|
114
|
-
res.json(user);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
app.post('/users', async (req: Request, res: Response) => {
|
|
118
|
-
try {
|
|
119
|
-
const createUser = CreateUserSchema.parse(req.body);
|
|
120
|
-
const result = await pool.query(
|
|
121
|
-
'INSERT INTO users (name, email) VALUES ($1, $2) RETURNING id, name, email, created_at',
|
|
122
|
-
[createUser.name, createUser.email]
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
const user = UserSchema.parse(result.rows[0]);
|
|
126
|
-
res.status(201).json(user);
|
|
127
|
-
} catch (error) {
|
|
128
|
-
if (error instanceof z.ZodError) {
|
|
129
|
-
res.status(400).json({ error: error.errors });
|
|
130
|
-
} else {
|
|
131
|
-
res.status(500).json({ error: 'Internal server error' });
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
const PORT = 3000;
|
|
137
|
-
app.listen(PORT, () => {
|
|
138
|
-
console.log(`Server running on port ${PORT}`);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
// Run: npm install express pg zod && npm run dev
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
#### Go (Fiber)
|
|
145
|
-
```go
|
|
146
|
-
// main.go
|
|
147
|
-
package main
|
|
148
|
-
|
|
149
|
-
import (
|
|
150
|
-
"context"
|
|
151
|
-
"database/sql"
|
|
152
|
-
"encoding/json"
|
|
153
|
-
"fmt"
|
|
154
|
-
"log"
|
|
155
|
-
"net/http"
|
|
156
|
-
"time"
|
|
157
|
-
|
|
158
|
-
"github.com/gofiber/fiber/v3"
|
|
159
|
-
"github.com/jackc/pgx/v5/pgxpool"
|
|
160
|
-
)
|
|
161
|
-
|
|
162
|
-
type User struct {
|
|
163
|
-
ID int `json:"id"`
|
|
164
|
-
Name string `json:"name"`
|
|
165
|
-
Email string `json:"email"`
|
|
166
|
-
CreatedAt time.Time `json:"created_at,omitempty"`
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
type CreateUserRequest struct {
|
|
170
|
-
Name string `json:"name"`
|
|
171
|
-
Email string `json:"email"`
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
var pool *pgxpool.Pool
|
|
175
|
-
|
|
176
|
-
func main() {
|
|
177
|
-
// Database
|
|
178
|
-
var err error
|
|
179
|
-
pool, err = pgxpool.New(context.Background(), "postgres://user:pass@localhost/db")
|
|
180
|
-
if err != nil {
|
|
181
|
-
log.Fatal(err)
|
|
182
|
-
}
|
|
183
|
-
defer pool.Close()
|
|
184
|
-
|
|
185
|
-
// Fiber app
|
|
186
|
-
app := fiber.New()
|
|
187
|
-
|
|
188
|
-
// Routes
|
|
189
|
-
app.Get("/users", listUsers)
|
|
190
|
-
app.Get("/users/:id", getUser)
|
|
191
|
-
app.Post("/users", createUser)
|
|
192
|
-
|
|
193
|
-
log.Fatal(app.Listen(":3000"))
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
func listUsers(c fiber.Ctx) error {
|
|
197
|
-
rows, err := pool.Query(context.Background(), "SELECT id, name, email, created_at FROM users")
|
|
198
|
-
if err != nil {
|
|
199
|
-
return c.Status(500).JSON(fiber.Map{"error": err.Error()})
|
|
200
|
-
}
|
|
201
|
-
defer rows.Close()
|
|
202
|
-
|
|
203
|
-
var users []User
|
|
204
|
-
for rows.Next() {
|
|
205
|
-
var user User
|
|
206
|
-
err := rows.Scan(&user.ID, &user.Name, &user.Email, &user.CreatedAt)
|
|
207
|
-
if err != nil {
|
|
208
|
-
return c.Status(500).JSON(fiber.Map{"error": err.Error()})
|
|
209
|
-
}
|
|
210
|
-
users = append(users, user)
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return c.JSON(users)
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
func getUser(c fiber.Ctx) error {
|
|
217
|
-
id, err := c.ParamsInt("id")
|
|
218
|
-
if err != nil {
|
|
219
|
-
return c.Status(400).JSON(fiber.Map{"error": "Invalid user ID"})
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
var user User
|
|
223
|
-
err = pool.QueryRow(context.Background(),
|
|
224
|
-
"SELECT id, name, email, created_at FROM users WHERE id = $1", id).
|
|
225
|
-
Scan(&user.ID, &user.Name, &user.Email, &user.CreatedAt)
|
|
226
|
-
|
|
227
|
-
if err == sql.ErrNoRows {
|
|
228
|
-
return c.Status(404).JSON(fiber.Map{"error": "User not found"})
|
|
229
|
-
}
|
|
230
|
-
if err != nil {
|
|
231
|
-
return c.Status(500).JSON(fiber.Map{"error": err.Error()})
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return c.JSON(user)
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
func createUser(c fiber.Ctx) error {
|
|
238
|
-
var req CreateUserRequest
|
|
239
|
-
if err := c.BodyParser(&req); err != nil {
|
|
240
|
-
return c.Status(400).JSON(fiber.Map{"error": err.Error()})
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
var user User
|
|
244
|
-
err := pool.QueryRow(context.Background(),
|
|
245
|
-
"INSERT INTO users (name, email) VALUES ($1, $2) RETURNING id, name, email, created_at",
|
|
246
|
-
req.Name, req.Email).
|
|
247
|
-
Scan(&user.ID, &user.Name, &user.Email, &user.CreatedAt)
|
|
248
|
-
|
|
249
|
-
if err != nil {
|
|
250
|
-
return c.Status(500).JSON(fiber.Map{"error": err.Error()})
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
return c.Status(201).JSON(user)
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// Run: go mod init user-api && go get github.com/gofiber/fiber/v3 github.com/jackc/pgx/v5 && go run main.go
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
#### Rust (Axum)
|
|
260
|
-
```rust
|
|
261
|
-
// src/main.rs
|
|
262
|
-
use axum::{
|
|
263
|
-
extract::{Path, State},
|
|
264
|
-
http::StatusCode,
|
|
265
|
-
response::Json,
|
|
266
|
-
routing::get,
|
|
267
|
-
Router,
|
|
268
|
-
};
|
|
269
|
-
use serde::{Deserialize, Serialize};
|
|
270
|
-
use sqlx::{postgres::PgPoolOptions, PgPool};
|
|
271
|
-
use std::net::SocketAddr;
|
|
272
|
-
|
|
273
|
-
#[derive(Debug, Serialize, Deserialize)]
|
|
274
|
-
struct User {
|
|
275
|
-
id: i32,
|
|
276
|
-
name: String,
|
|
277
|
-
email: String,
|
|
278
|
-
created_at: Option<String>,
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
#[derive(Debug, Deserialize)]
|
|
282
|
-
struct CreateUserRequest {
|
|
283
|
-
name: String,
|
|
284
|
-
email: String,
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
#[derive(Clone)]
|
|
288
|
-
struct AppState {
|
|
289
|
-
db: PgPool,
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
#[tokio::main]
|
|
293
|
-
async fn main() {
|
|
294
|
-
// Database
|
|
295
|
-
let pool = PgPoolOptions::new()
|
|
296
|
-
.max_connections(5)
|
|
297
|
-
.connect("postgres://user:pass@localhost/db")
|
|
298
|
-
.await
|
|
299
|
-
.expect("Failed to connect to database");
|
|
300
|
-
|
|
301
|
-
let state = AppState { db: pool };
|
|
302
|
-
|
|
303
|
-
// Routes
|
|
304
|
-
let app = Router::new()
|
|
305
|
-
.route("/users", get(list_users).post(create_user))
|
|
306
|
-
.route("/users/:id", get(get_user))
|
|
307
|
-
.with_state(state);
|
|
308
|
-
|
|
309
|
-
// Server
|
|
310
|
-
let addr = SocketAddr::from(([0, 0, 0, 0], 3000));
|
|
311
|
-
println!("Server listening on {}", addr);
|
|
312
|
-
|
|
313
|
-
axum::Server::bind(&addr)
|
|
314
|
-
.serve(app.into_make_service())
|
|
315
|
-
.await
|
|
316
|
-
.unwrap();
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
async fn list_users(State(state): State<AppState>) -> Json<Vec<User>> {
|
|
320
|
-
let users = sqlx::query_as!(
|
|
321
|
-
User,
|
|
322
|
-
"SELECT id, name, email, TO_CHAR(created_at, 'YYYY-MM-DD HH24:MI:SS') as created_at FROM users"
|
|
323
|
-
)
|
|
324
|
-
.fetch_all(&state.db)
|
|
325
|
-
.await
|
|
326
|
-
.expect("Failed to fetch users");
|
|
327
|
-
|
|
328
|
-
Json(users)
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
async fn get_user(
|
|
332
|
-
State(state): State<AppState>,
|
|
333
|
-
Path(user_id): Path<i32>,
|
|
334
|
-
) -> Result<Json<User>, StatusCode> {
|
|
335
|
-
let user = sqlx::query_as!(
|
|
336
|
-
User,
|
|
337
|
-
"SELECT id, name, email, TO_CHAR(created_at, 'YYYY-MM-DD HH24:MI:SS') as created_at FROM users WHERE id = $1",
|
|
338
|
-
user_id
|
|
339
|
-
)
|
|
340
|
-
.fetch_optional(&state.db)
|
|
341
|
-
.await
|
|
342
|
-
.expect("Failed to fetch user");
|
|
343
|
-
|
|
344
|
-
match user {
|
|
345
|
-
Some(user) => Ok(Json(user)),
|
|
346
|
-
None => Err(StatusCode::NOT_FOUND),
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
async fn create_user(
|
|
351
|
-
State(state): State<AppState>,
|
|
352
|
-
Json(payload): Json<CreateUserRequest>,
|
|
353
|
-
) -> Result<Json<User>, StatusCode> {
|
|
354
|
-
let user = sqlx::query_as!(
|
|
355
|
-
User,
|
|
356
|
-
r#"
|
|
357
|
-
INSERT INTO users (name, email)
|
|
358
|
-
VALUES ($1, $2)
|
|
359
|
-
RETURNING id, name, email, TO_CHAR(created_at, 'YYYY-MM-DD HH24:MI:SS') as created_at
|
|
360
|
-
"#,
|
|
361
|
-
payload.name,
|
|
362
|
-
payload.email
|
|
363
|
-
)
|
|
364
|
-
.fetch_one(&state.db)
|
|
365
|
-
.await
|
|
366
|
-
.expect("Failed to create user");
|
|
367
|
-
|
|
368
|
-
Ok(Json(user))
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
// Cargo.toml dependencies:
|
|
372
|
-
// axum = "0.8"
|
|
373
|
-
// sqlx = { version = "0.8", features = ["runtime-tokio-rustls", "postgres", "chrono"] }
|
|
374
|
-
// serde = { version = "1.0", features = ["derive"] }
|
|
375
|
-
// tokio = { version = "1.0", features = ["full"] }
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
## Cross-Language Communication
|
|
379
|
-
|
|
380
|
-
### gRPC Service Implementation
|
|
381
|
-
|
|
382
|
-
#### Go Server
|
|
383
|
-
```go
|
|
384
|
-
// server.go
|
|
385
|
-
package main
|
|
386
|
-
|
|
387
|
-
import (
|
|
388
|
-
"context"
|
|
389
|
-
"log"
|
|
390
|
-
"net"
|
|
391
|
-
|
|
392
|
-
pb "github.com/yourorg/user-service/proto"
|
|
393
|
-
"google.golang.org/grpc"
|
|
394
|
-
)
|
|
395
|
-
|
|
396
|
-
type server struct {
|
|
397
|
-
pb.UnimplementedUserServiceServer
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
func (s *server) GetUser(ctx context.Context, req *pb.GetUserRequest) (*pb.UserResponse, error) {
|
|
401
|
-
// Business logic
|
|
402
|
-
return &pb.UserResponse{
|
|
403
|
-
Id: req.Id,
|
|
404
|
-
Name: "John Doe",
|
|
405
|
-
Email: "john@example.com",
|
|
406
|
-
}, nil
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
func main() {
|
|
410
|
-
lis, err := net.Listen("tcp", ":50051")
|
|
411
|
-
if err != nil {
|
|
412
|
-
log.Fatal(err)
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
s := grpc.NewServer()
|
|
416
|
-
pb.RegisterUserServiceServer(s, &server{})
|
|
417
|
-
|
|
418
|
-
log.Println("gRPC server listening on :50051")
|
|
419
|
-
if err := s.Serve(lis); err != nil {
|
|
420
|
-
log.Fatal(err)
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
```
|
|
424
|
-
|
|
425
|
-
#### Python Client
|
|
426
|
-
```python
|
|
427
|
-
# client.py
|
|
428
|
-
import grpc
|
|
429
|
-
from generated import user_pb2, user_pb2_grpc
|
|
430
|
-
|
|
431
|
-
def get_user(user_id: int):
|
|
432
|
-
with grpc.insecure_channel('localhost:50051') as channel:
|
|
433
|
-
stub = user_pb2_grpc.UserServiceStub(channel)
|
|
434
|
-
request = user_pb2.GetUserRequest(id=user_id)
|
|
435
|
-
response = stub.GetUser(request)
|
|
436
|
-
return response
|
|
437
|
-
|
|
438
|
-
# Usage
|
|
439
|
-
user = get_user(123)
|
|
440
|
-
print(f"User: {user.name}, Email: {user.email}")
|
|
441
|
-
```
|
|
442
|
-
|
|
443
|
-
#### Rust Client
|
|
444
|
-
```rust
|
|
445
|
-
// client.rs
|
|
446
|
-
use tonic::transport::Channel;
|
|
447
|
-
use proto::user_service_client::UserServiceClient;
|
|
448
|
-
use proto::GetUserRequest;
|
|
449
|
-
|
|
450
|
-
#[tokio::main]
|
|
451
|
-
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
452
|
-
let mut client = UserServiceClient::connect("http://[::1]:50051").await?;
|
|
453
|
-
|
|
454
|
-
let request = tonic::Request::new(GetUserRequest {
|
|
455
|
-
id: 123,
|
|
456
|
-
});
|
|
457
|
-
|
|
458
|
-
let response = client.get_user(request).await?;
|
|
459
|
-
println!("Response: {:?}", response.get_ref());
|
|
460
|
-
|
|
461
|
-
Ok(())
|
|
462
|
-
}
|
|
463
|
-
```
|
|
464
|
-
|
|
465
|
-
## Data Processing Examples
|
|
466
|
-
|
|
467
|
-
### JSON Processing
|
|
468
|
-
|
|
469
|
-
#### Python (FastAPI)
|
|
470
|
-
```python
|
|
471
|
-
import json
|
|
472
|
-
from typing import List, Dict, Any
|
|
473
|
-
from pathlib import Path
|
|
474
|
-
|
|
475
|
-
def process_json_data(file_path: str) -> List[Dict[str, Any]]:
|
|
476
|
-
"""Process JSON file and return structured data"""
|
|
477
|
-
with open(file_path, 'r') as f:
|
|
478
|
-
data = json.load(f)
|
|
479
|
-
|
|
480
|
-
# Transform data
|
|
481
|
-
processed = []
|
|
482
|
-
for item in data:
|
|
483
|
-
processed.append({
|
|
484
|
-
'id': item['id'],
|
|
485
|
-
'name': item['name'].upper(),
|
|
486
|
-
'email': item['email'].lower(),
|
|
487
|
-
'processed_at': datetime.now().isoformat()
|
|
488
|
-
})
|
|
489
|
-
|
|
490
|
-
return processed
|
|
491
|
-
|
|
492
|
-
# Async batch processing
|
|
493
|
-
async def process_large_json_async(file_path: str) -> List[Dict]:
|
|
494
|
-
with open(file_path, 'r') as f:
|
|
495
|
-
data = json.load(f)
|
|
496
|
-
|
|
497
|
-
# Process in batches
|
|
498
|
-
batch_size = 1000
|
|
499
|
-
results = []
|
|
500
|
-
|
|
501
|
-
for i in range(0, len(data), batch_size):
|
|
502
|
-
batch = data[i:i + batch_size]
|
|
503
|
-
batch_results = await process_batch(batch)
|
|
504
|
-
results.extend(batch_results)
|
|
505
|
-
|
|
506
|
-
return results
|
|
507
|
-
```
|
|
508
|
-
|
|
509
|
-
#### JavaScript (Node.js)
|
|
510
|
-
```javascript
|
|
511
|
-
// jsonProcessor.js
|
|
512
|
-
const fs = require('fs').promises;
|
|
513
|
-
const { pipeline } = require('stream/promises');
|
|
514
|
-
const { createReadStream, createWriteStream } = require('fs');
|
|
515
|
-
|
|
516
|
-
async function processJsonFile(inputPath, outputPath) {
|
|
517
|
-
const readStream = createReadStream(inputPath, { encoding: 'utf8' });
|
|
518
|
-
const writeStream = createWriteStream(outputPath, { encoding: 'utf8' });
|
|
519
|
-
|
|
520
|
-
let buffer = '';
|
|
521
|
-
let isFirstLine = true;
|
|
522
|
-
|
|
523
|
-
// Process line by line for memory efficiency
|
|
524
|
-
for await (const chunk of readStream) {
|
|
525
|
-
buffer += chunk;
|
|
526
|
-
let lineEnd = buffer.indexOf('\n');
|
|
527
|
-
|
|
528
|
-
while (lineEnd >= 0) {
|
|
529
|
-
const line = buffer.slice(0, lineEnd);
|
|
530
|
-
buffer = buffer.slice(lineEnd + 1);
|
|
531
|
-
lineEnd = buffer.indexOf('\n');
|
|
532
|
-
|
|
533
|
-
try {
|
|
534
|
-
const data = JSON.parse(line);
|
|
535
|
-
const processed = {
|
|
536
|
-
id: data.id,
|
|
537
|
-
name: data.name.toUpperCase(),
|
|
538
|
-
email: data.email.toLowerCase(),
|
|
539
|
-
processedAt: new Date().toISOString()
|
|
540
|
-
};
|
|
541
|
-
|
|
542
|
-
if (!isFirstLine) {
|
|
543
|
-
writeStream.write(',\n');
|
|
544
|
-
}
|
|
545
|
-
isFirstLine = false;
|
|
546
|
-
writeStream.write(JSON.stringify(processed));
|
|
547
|
-
} catch (error) {
|
|
548
|
-
console.error('Error processing line:', error.message);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
writeStream.end();
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
// Usage
|
|
557
|
-
processJsonFile('input.json', 'output.json')
|
|
558
|
-
.then(() => console.log('Processing complete'))
|
|
559
|
-
.catch(console.error);
|
|
560
|
-
```
|
|
561
|
-
|
|
562
|
-
#### Go
|
|
563
|
-
```go
|
|
564
|
-
// jsonProcessor.go
|
|
565
|
-
package main
|
|
566
|
-
|
|
567
|
-
import (
|
|
568
|
-
"encoding/json"
|
|
569
|
-
"fmt"
|
|
570
|
-
"io"
|
|
571
|
-
"os"
|
|
572
|
-
"strings"
|
|
573
|
-
)
|
|
574
|
-
|
|
575
|
-
type InputData struct {
|
|
576
|
-
ID int `json:"id"`
|
|
577
|
-
Name string `json:"name"`
|
|
578
|
-
Email string `json:"email"`
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
type ProcessedData struct {
|
|
582
|
-
ID int `json:"id"`
|
|
583
|
-
Name string `json:"name"`
|
|
584
|
-
Email string `json:"email"`
|
|
585
|
-
ProcessedAt string `json:"processed_at"`
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
func processJSONFile(inputPath, outputPath string) error {
|
|
589
|
-
file, err := os.Open(inputPath)
|
|
590
|
-
if err != nil {
|
|
591
|
-
return err
|
|
592
|
-
}
|
|
593
|
-
defer file.Close()
|
|
594
|
-
|
|
595
|
-
outputFile, err := os.Create(outputPath)
|
|
596
|
-
if err != nil {
|
|
597
|
-
return err
|
|
598
|
-
}
|
|
599
|
-
defer outputFile.Close()
|
|
600
|
-
|
|
601
|
-
decoder := json.NewDecoder(file)
|
|
602
|
-
|
|
603
|
-
outputFile.WriteString("[\n")
|
|
604
|
-
isFirst := true
|
|
605
|
-
|
|
606
|
-
for decoder.More() {
|
|
607
|
-
var data InputData
|
|
608
|
-
if err := decoder.Decode(&data); err != nil {
|
|
609
|
-
return err
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
processed := ProcessedData{
|
|
613
|
-
ID: data.ID,
|
|
614
|
-
Name: strings.ToUpper(data.Name),
|
|
615
|
-
Email: strings.ToLower(data.Email),
|
|
616
|
-
ProcessedAt: time.Now().Format(time.RFC3339),
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
if !isFirst {
|
|
620
|
-
outputFile.WriteString(",\n")
|
|
621
|
-
}
|
|
622
|
-
isFirst = false
|
|
623
|
-
|
|
624
|
-
jsonData, err := json.MarshalIndent(processed, "", " ")
|
|
625
|
-
if err != nil {
|
|
626
|
-
return err
|
|
627
|
-
}
|
|
628
|
-
outputFile.Write(jsonData)
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
outputFile.WriteString("\n]")
|
|
632
|
-
return nil
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
func main() {
|
|
636
|
-
err := processJSONFile("input.json", "output.json")
|
|
637
|
-
if err != nil {
|
|
638
|
-
fmt.Printf("Error: %v\n", err)
|
|
639
|
-
os.Exit(1)
|
|
640
|
-
}
|
|
641
|
-
fmt.Println("Processing complete")
|
|
642
|
-
}
|
|
643
|
-
```
|
|
644
|
-
|
|
645
|
-
## Testing Examples
|
|
646
|
-
|
|
647
|
-
### Unit Testing
|
|
648
|
-
|
|
649
|
-
#### Python (pytest)
|
|
650
|
-
```python
|
|
651
|
-
# test_user_service.py
|
|
652
|
-
import pytest
|
|
653
|
-
from unittest.mock import Mock, patch
|
|
654
|
-
from user_service import UserService, UserNotFoundError
|
|
655
|
-
|
|
656
|
-
@pytest.fixture
|
|
657
|
-
def user_service():
|
|
658
|
-
return UserService()
|
|
659
|
-
|
|
660
|
-
@pytest.fixture
|
|
661
|
-
def mock_db():
|
|
662
|
-
return Mock()
|
|
663
|
-
|
|
664
|
-
def test_create_user_success(user_service, mock_db):
|
|
665
|
-
# Setup
|
|
666
|
-
user_data = {"name": "John Doe", "email": "john@example.com"}
|
|
667
|
-
mock_db.insert.return_value = {"id": 1, user_data}
|
|
668
|
-
|
|
669
|
-
# Test
|
|
670
|
-
with patch.object(user_service, 'db', mock_db):
|
|
671
|
-
result = user_service.create_user(user_data)
|
|
672
|
-
|
|
673
|
-
# Assert
|
|
674
|
-
assert result["id"] == 1
|
|
675
|
-
assert result["name"] == "John Doe"
|
|
676
|
-
mock_db.insert.assert_called_once_with(user_data)
|
|
677
|
-
|
|
678
|
-
def test_get_user_not_found(user_service, mock_db):
|
|
679
|
-
# Setup
|
|
680
|
-
user_id = 999
|
|
681
|
-
mock_db.get.return_value = None
|
|
682
|
-
|
|
683
|
-
# Test
|
|
684
|
-
with patch.object(user_service, 'db', mock_db):
|
|
685
|
-
with pytest.raises(UserNotFoundError):
|
|
686
|
-
user_service.get_user(user_id)
|
|
687
|
-
|
|
688
|
-
# Assert
|
|
689
|
-
mock_db.get.assert_called_once_with(user_id)
|
|
690
|
-
|
|
691
|
-
@pytest.mark.asyncio
|
|
692
|
-
async def test_async_user_operations(user_service, mock_db):
|
|
693
|
-
# Setup
|
|
694
|
-
user_data = {"name": "Jane Doe", "email": "jane@example.com"}
|
|
695
|
-
mock_db.async_insert.return_value = {"id": 2, user_data}
|
|
696
|
-
|
|
697
|
-
# Test
|
|
698
|
-
with patch.object(user_service, 'db', mock_db):
|
|
699
|
-
result = await user_service.create_user_async(user_data)
|
|
700
|
-
|
|
701
|
-
# Assert
|
|
702
|
-
assert result["id"] == 2
|
|
703
|
-
assert result["name"] == "Jane Doe"
|
|
704
|
-
```
|
|
705
|
-
|
|
706
|
-
#### JavaScript (Vitest)
|
|
707
|
-
```javascript
|
|
708
|
-
// userService.test.js
|
|
709
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
710
|
-
import { UserService, UserNotFoundError } from './userService.js';
|
|
711
|
-
|
|
712
|
-
describe('UserService', () => {
|
|
713
|
-
let userService;
|
|
714
|
-
let mockDb;
|
|
715
|
-
|
|
716
|
-
beforeEach(() => {
|
|
717
|
-
mockDb = {
|
|
718
|
-
insert: vi.fn(),
|
|
719
|
-
get: vi.fn(),
|
|
720
|
-
update: vi.fn(),
|
|
721
|
-
delete: vi.fn()
|
|
722
|
-
};
|
|
723
|
-
userService = new UserService(mockDb);
|
|
724
|
-
});
|
|
725
|
-
|
|
726
|
-
it('should create user successfully', async () => {
|
|
727
|
-
// Setup
|
|
728
|
-
const userData = { name: 'John Doe', email: 'john@example.com' };
|
|
729
|
-
const expectedUser = { id: 1, ...userData };
|
|
730
|
-
mockDb.insert.mockResolvedValue(expectedUser);
|
|
731
|
-
|
|
732
|
-
// Test
|
|
733
|
-
const result = await userService.createUser(userData);
|
|
734
|
-
|
|
735
|
-
// Assert
|
|
736
|
-
expect(result).toEqual(expectedUser);
|
|
737
|
-
expect(mockDb.insert).toHaveBeenCalledWith(userData);
|
|
738
|
-
expect(mockDb.insert).toHaveBeenCalledTimes(1);
|
|
739
|
-
});
|
|
740
|
-
|
|
741
|
-
it('should throw UserNotFoundError when user not found', async () => {
|
|
742
|
-
// Setup
|
|
743
|
-
const userId = 999;
|
|
744
|
-
mockDb.get.mockResolvedValue(null);
|
|
745
|
-
|
|
746
|
-
// Test & Assert
|
|
747
|
-
await expect(userService.getUser(userId))
|
|
748
|
-
.rejects
|
|
749
|
-
.toThrow(UserNotFoundError);
|
|
750
|
-
|
|
751
|
-
expect(mockDb.get).toHaveBeenCalledWith(userId);
|
|
752
|
-
});
|
|
753
|
-
|
|
754
|
-
it('should handle database errors gracefully', async () => {
|
|
755
|
-
// Setup
|
|
756
|
-
const userData = { name: 'Jane Doe', email: 'jane@example.com' };
|
|
757
|
-
mockDb.insert.mockRejectedValue(new Error('Database connection failed'));
|
|
758
|
-
|
|
759
|
-
// Test & Assert
|
|
760
|
-
await expect(userService.createUser(userData))
|
|
761
|
-
.rejects
|
|
762
|
-
.toThrow('Database connection failed');
|
|
763
|
-
});
|
|
764
|
-
});
|
|
765
|
-
```
|
|
766
|
-
|
|
767
|
-
#### Go
|
|
768
|
-
```go
|
|
769
|
-
// user_service_test.go
|
|
770
|
-
package main
|
|
771
|
-
|
|
772
|
-
import (
|
|
773
|
-
"errors"
|
|
774
|
-
"testing"
|
|
775
|
-
"github.com/stretchr/testify/assert"
|
|
776
|
-
"github.com/stretchr/testify/mock"
|
|
777
|
-
)
|
|
778
|
-
|
|
779
|
-
type MockDB struct {
|
|
780
|
-
mock.Mock
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
func (m *MockDB) Insert(user map[string]interface{}) (map[string]interface{}, error) {
|
|
784
|
-
args := m.Called(user)
|
|
785
|
-
return args.Get(0).(map[string]interface{}), args.Error(1)
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
func (m *MockDB) Get(id int) (map[string]interface{}, error) {
|
|
789
|
-
args := m.Called(id)
|
|
790
|
-
return args.Get(0).(map[string]interface{}), args.Error(1)
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
func TestCreateUser_Success(t *testing.T) {
|
|
794
|
-
// Setup
|
|
795
|
-
mockDB := new(MockDB)
|
|
796
|
-
userService := NewUserService(mockDB)
|
|
797
|
-
|
|
798
|
-
userData := map[string]interface{}{
|
|
799
|
-
"name": "John Doe",
|
|
800
|
-
"email": "john@example.com",
|
|
801
|
-
}
|
|
802
|
-
expectedUser := map[string]interface{}{
|
|
803
|
-
"id": 1,
|
|
804
|
-
"name": "John Doe",
|
|
805
|
-
"email": "john@example.com",
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
mockDB.On("Insert", userData).Return(expectedUser, nil)
|
|
809
|
-
|
|
810
|
-
// Test
|
|
811
|
-
result, err := userService.CreateUser(userData)
|
|
812
|
-
|
|
813
|
-
// Assert
|
|
814
|
-
assert.NoError(t, err)
|
|
815
|
-
assert.Equal(t, expectedUser, result)
|
|
816
|
-
mockDB.AssertExpectations(t)
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
func TestGetUser_NotFound(t *testing.T) {
|
|
820
|
-
// Setup
|
|
821
|
-
mockDB := new(MockDB)
|
|
822
|
-
userService := NewUserService(mockDB)
|
|
823
|
-
userID := 999
|
|
824
|
-
|
|
825
|
-
mockDB.On("Get", userID).Return(nil, errors.New("user not found"))
|
|
826
|
-
|
|
827
|
-
// Test
|
|
828
|
-
_, err := userService.GetUser(userID)
|
|
829
|
-
|
|
830
|
-
// Assert
|
|
831
|
-
assert.Error(t, err)
|
|
832
|
-
assert.Contains(t, err.Error(), "user not found")
|
|
833
|
-
mockDB.AssertExpectations(t)
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
func BenchmarkCreateUser(b *testing.B) {
|
|
837
|
-
// Setup
|
|
838
|
-
mockDB := new(MockDB)
|
|
839
|
-
userService := NewUserService(mockDB)
|
|
840
|
-
userData := map[string]interface{}{
|
|
841
|
-
"name": "Benchmark User",
|
|
842
|
-
"email": "benchmark@example.com",
|
|
843
|
-
}
|
|
844
|
-
expectedUser := map[string]interface{}{
|
|
845
|
-
"id": 1,
|
|
846
|
-
"name": "Benchmark User",
|
|
847
|
-
"email": "benchmark@example.com",
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
mockDB.On("Insert", userData).Return(expectedUser, nil)
|
|
851
|
-
|
|
852
|
-
// Benchmark
|
|
853
|
-
b.ResetTimer()
|
|
854
|
-
for i := 0; i < b.N; i++ {
|
|
855
|
-
_, _ = userService.CreateUser(userData)
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
```
|
|
859
|
-
|
|
860
|
-
#### Rust
|
|
861
|
-
```rust
|
|
862
|
-
// src/user_service_test.rs
|
|
863
|
-
#[cfg(test)]
|
|
864
|
-
mod tests {
|
|
865
|
-
use super::*;
|
|
866
|
-
use tokio_test;
|
|
867
|
-
|
|
868
|
-
#[derive(Debug)]
|
|
869
|
-
struct MockDB {
|
|
870
|
-
users: std::cell::RefCell<HashMap<i32, User>>,
|
|
871
|
-
next_id: std::cell::Cell<i32>,
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
impl MockDB {
|
|
875
|
-
fn new() -> Self {
|
|
876
|
-
Self {
|
|
877
|
-
users: std::cell::RefCell::new(HashMap::new()),
|
|
878
|
-
next_id: std::cell::Cell::new(1),
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
async fn create_user(&self, user: CreateUserRequest) -> User {
|
|
883
|
-
let id = self.next_id.get();
|
|
884
|
-
self.next_id.set(id + 1);
|
|
885
|
-
|
|
886
|
-
let user = User {
|
|
887
|
-
id,
|
|
888
|
-
name: user.name,
|
|
889
|
-
email: user.email,
|
|
890
|
-
created_at: Some(chrono::Utc::now().to_string()),
|
|
891
|
-
};
|
|
892
|
-
|
|
893
|
-
self.users.borrow_mut().insert(id, user.clone());
|
|
894
|
-
user
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
async fn get_user(&self, id: i32) -> Option<User> {
|
|
898
|
-
self.users.borrow().get(&id).cloned()
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
#[tokio::test]
|
|
903
|
-
async fn test_create_user_success() {
|
|
904
|
-
// Setup
|
|
905
|
-
let mock_db = MockDB::new();
|
|
906
|
-
let user_request = CreateUserRequest {
|
|
907
|
-
name: "John Doe".to_string(),
|
|
908
|
-
email: "john@example.com".to_string(),
|
|
909
|
-
};
|
|
910
|
-
|
|
911
|
-
// Test
|
|
912
|
-
let result = mock_db.create_user(user_request.clone()).await;
|
|
913
|
-
|
|
914
|
-
// Assert
|
|
915
|
-
assert_eq!(result.name, "John Doe");
|
|
916
|
-
assert_eq!(result.email, "john@example.com");
|
|
917
|
-
assert_eq!(result.id, 1);
|
|
918
|
-
assert!(result.created_at.is_some());
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
#[tokio::test]
|
|
922
|
-
async fn test_get_user_not_found() {
|
|
923
|
-
// Setup
|
|
924
|
-
let mock_db = MockDB::new();
|
|
925
|
-
let non_existent_id = 999;
|
|
926
|
-
|
|
927
|
-
// Test
|
|
928
|
-
let result = mock_db.get_user(non_existent_id).await;
|
|
929
|
-
|
|
930
|
-
// Assert
|
|
931
|
-
assert!(result.is_none());
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
#[tokio::test]
|
|
935
|
-
async fn test_get_user_success() {
|
|
936
|
-
// Setup
|
|
937
|
-
let mock_db = MockDB::new();
|
|
938
|
-
let user_request = CreateUserRequest {
|
|
939
|
-
name: "Jane Doe".to_string(),
|
|
940
|
-
email: "jane@example.com".to_string(),
|
|
941
|
-
};
|
|
942
|
-
|
|
943
|
-
let created_user = mock_db.create_user(user_request.clone()).await;
|
|
944
|
-
|
|
945
|
-
// Test
|
|
946
|
-
let result = mock_db.get_user(created_user.id).await;
|
|
947
|
-
|
|
948
|
-
// Assert
|
|
949
|
-
assert!(result.is_some());
|
|
950
|
-
let user = result.unwrap();
|
|
951
|
-
assert_eq!(user.name, "Jane Doe");
|
|
952
|
-
assert_eq!(user.email, "jane@example.com");
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
```
|
|
956
|
-
|
|
957
|
-
## Deployment Examples
|
|
958
|
-
|
|
959
|
-
### Docker Multi-Stage Builds
|
|
960
|
-
|
|
961
|
-
#### Python Dockerfile
|
|
962
|
-
```dockerfile
|
|
963
|
-
# Dockerfile.python
|
|
964
|
-
FROM python:3.13-slim as builder
|
|
965
|
-
|
|
966
|
-
WORKDIR /app
|
|
967
|
-
COPY requirements.txt .
|
|
968
|
-
RUN pip install --no-cache-dir --user -r requirements.txt
|
|
969
|
-
|
|
970
|
-
FROM python:3.13-slim as runtime
|
|
971
|
-
|
|
972
|
-
WORKDIR /app
|
|
973
|
-
COPY --from=builder /root/.local /root/.local
|
|
974
|
-
COPY . .
|
|
975
|
-
|
|
976
|
-
ENV PATH=/root/.local/bin:$PATH
|
|
977
|
-
|
|
978
|
-
EXPOSE 8000
|
|
979
|
-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
980
|
-
```
|
|
981
|
-
|
|
982
|
-
#### Go Dockerfile
|
|
983
|
-
```dockerfile
|
|
984
|
-
# Dockerfile.go
|
|
985
|
-
FROM golang:1.23-alpine AS builder
|
|
986
|
-
|
|
987
|
-
WORKDIR /app
|
|
988
|
-
COPY go.mod go.sum ./
|
|
989
|
-
RUN go mod download
|
|
990
|
-
COPY . .
|
|
991
|
-
RUN CGO_ENABLED=0 GOOS=linux go build -o main .
|
|
992
|
-
|
|
993
|
-
FROM alpine:latest
|
|
994
|
-
RUN apk --no-cache add ca-certificates tzdata
|
|
995
|
-
WORKDIR /root/
|
|
996
|
-
COPY --from=builder /app/main .
|
|
997
|
-
EXPOSE 3000
|
|
998
|
-
CMD ["./main"]
|
|
999
|
-
```
|
|
1000
|
-
|
|
1001
|
-
#### Rust Dockerfile
|
|
1002
|
-
```dockerfile
|
|
1003
|
-
# Dockerfile.rust
|
|
1004
|
-
FROM rust:1.91-alpine AS builder
|
|
1005
|
-
|
|
1006
|
-
WORKDIR /app
|
|
1007
|
-
COPY Cargo.toml Cargo.lock ./
|
|
1008
|
-
RUN mkdir src && echo "fn main() {}" > src/main.rs
|
|
1009
|
-
RUN cargo build --release
|
|
1010
|
-
RUN rm -rf src
|
|
1011
|
-
|
|
1012
|
-
COPY . .
|
|
1013
|
-
RUN touch src/main.rs && cargo build --release
|
|
1014
|
-
|
|
1015
|
-
FROM alpine:latest
|
|
1016
|
-
RUN apk --no-cache add ca-certificates tzdata
|
|
1017
|
-
WORKDIR /app
|
|
1018
|
-
COPY --from=builder /app/target/release/service .
|
|
1019
|
-
EXPOSE 3000
|
|
1020
|
-
CMD ["./service"]
|
|
1021
|
-
```
|
|
1022
|
-
|
|
1023
|
-
### Kubernetes Deployment
|
|
1024
|
-
|
|
1025
|
-
#### Python Deployment
|
|
1026
|
-
```yaml
|
|
1027
|
-
# k8s-python.yaml
|
|
1028
|
-
apiVersion: apps/v1
|
|
1029
|
-
kind: Deployment
|
|
1030
|
-
metadata:
|
|
1031
|
-
name: python-api
|
|
1032
|
-
spec:
|
|
1033
|
-
replicas: 3
|
|
1034
|
-
selector:
|
|
1035
|
-
matchLabels:
|
|
1036
|
-
app: python-api
|
|
1037
|
-
template:
|
|
1038
|
-
metadata:
|
|
1039
|
-
labels:
|
|
1040
|
-
app: python-api
|
|
1041
|
-
spec:
|
|
1042
|
-
containers:
|
|
1043
|
-
- name: python-api
|
|
1044
|
-
image: your-registry/python-api:latest
|
|
1045
|
-
ports:
|
|
1046
|
-
- containerPort: 8000
|
|
1047
|
-
env:
|
|
1048
|
-
- name: DATABASE_URL
|
|
1049
|
-
valueFrom:
|
|
1050
|
-
secretKeyRef:
|
|
1051
|
-
name: db-secret
|
|
1052
|
-
key: url
|
|
1053
|
-
resources:
|
|
1054
|
-
requests:
|
|
1055
|
-
memory: "256Mi"
|
|
1056
|
-
cpu: "250m"
|
|
1057
|
-
limits:
|
|
1058
|
-
memory: "512Mi"
|
|
1059
|
-
cpu: "500m"
|
|
1060
|
-
---
|
|
1061
|
-
apiVersion: v1
|
|
1062
|
-
kind: Service
|
|
1063
|
-
metadata:
|
|
1064
|
-
name: python-api-service
|
|
1065
|
-
spec:
|
|
1066
|
-
selector:
|
|
1067
|
-
app: python-api
|
|
1068
|
-
ports:
|
|
1069
|
-
- port: 80
|
|
1070
|
-
targetPort: 8000
|
|
1071
|
-
type: LoadBalancer
|
|
1072
|
-
```
|
|
1073
|
-
|
|
1074
|
-
#### Go Deployment
|
|
1075
|
-
```yaml
|
|
1076
|
-
# k8s-go.yaml
|
|
1077
|
-
apiVersion: apps/v1
|
|
1078
|
-
kind: Deployment
|
|
1079
|
-
metadata:
|
|
1080
|
-
name: go-api
|
|
1081
|
-
spec:
|
|
1082
|
-
replicas: 2
|
|
1083
|
-
selector:
|
|
1084
|
-
matchLabels:
|
|
1085
|
-
app: go-api
|
|
1086
|
-
template:
|
|
1087
|
-
metadata:
|
|
1088
|
-
labels:
|
|
1089
|
-
app: go-api
|
|
1090
|
-
spec:
|
|
1091
|
-
containers:
|
|
1092
|
-
- name: go-api
|
|
1093
|
-
image: your-registry/go-api:latest
|
|
1094
|
-
ports:
|
|
1095
|
-
- containerPort: 3000
|
|
1096
|
-
env:
|
|
1097
|
-
- name: DB_HOST
|
|
1098
|
-
value: postgres-service
|
|
1099
|
-
- name: DB_PORT
|
|
1100
|
-
value: "5432"
|
|
1101
|
-
resources:
|
|
1102
|
-
requests:
|
|
1103
|
-
memory: "64Mi"
|
|
1104
|
-
cpu: "100m"
|
|
1105
|
-
limits:
|
|
1106
|
-
memory: "128Mi"
|
|
1107
|
-
cpu: "200m"
|
|
1108
|
-
livenessProbe:
|
|
1109
|
-
httpGet:
|
|
1110
|
-
path: /health
|
|
1111
|
-
port: 3000
|
|
1112
|
-
initialDelaySeconds: 10
|
|
1113
|
-
periodSeconds: 30
|
|
1114
|
-
---
|
|
1115
|
-
apiVersion: v1
|
|
1116
|
-
kind: Service
|
|
1117
|
-
metadata:
|
|
1118
|
-
name: go-api-service
|
|
1119
|
-
spec:
|
|
1120
|
-
selector:
|
|
1121
|
-
app: go-api
|
|
1122
|
-
ports:
|
|
1123
|
-
- port: 80
|
|
1124
|
-
targetPort: 3000
|
|
1125
|
-
type: LoadBalancer
|
|
1126
|
-
```
|
|
1127
|
-
|
|
1128
|
-
## Microservices Communication
|
|
1129
|
-
|
|
1130
|
-
### Message Queue Patterns
|
|
1131
|
-
|
|
1132
|
-
#### RabbitMQ Producer (Python)
|
|
1133
|
-
```python
|
|
1134
|
-
# producer.py
|
|
1135
|
-
import pika
|
|
1136
|
-
import json
|
|
1137
|
-
import asyncio
|
|
1138
|
-
|
|
1139
|
-
class MessageProducer:
|
|
1140
|
-
def __init__(self, connection_params):
|
|
1141
|
-
self.connection = pika.BlockingConnection(connection_params)
|
|
1142
|
-
self.channel = self.connection.channel()
|
|
1143
|
-
|
|
1144
|
-
# Declare queue
|
|
1145
|
-
self.channel.queue_declare(queue='user_events', durable=True)
|
|
1146
|
-
|
|
1147
|
-
def publish_user_event(self, event_type, user_data):
|
|
1148
|
-
message = {
|
|
1149
|
-
'event_type': event_type,
|
|
1150
|
-
'user': user_data,
|
|
1151
|
-
'timestamp': datetime.now().isoformat()
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
self.channel.basic_publish(
|
|
1155
|
-
exchange='',
|
|
1156
|
-
routing_key='user_events',
|
|
1157
|
-
body=json.dumps(message),
|
|
1158
|
-
properties=pika.BasicProperties(
|
|
1159
|
-
delivery_mode=2, # make message persistent
|
|
1160
|
-
))
|
|
1161
|
-
|
|
1162
|
-
print(f" [x] Sent {event_type} event")
|
|
1163
|
-
|
|
1164
|
-
def close(self):
|
|
1165
|
-
self.connection.close()
|
|
1166
|
-
|
|
1167
|
-
# Usage
|
|
1168
|
-
producer = MessageProducer(pika.ConnectionParameters('localhost'))
|
|
1169
|
-
producer.publish_user_event('user_created', {'id': 123, 'name': 'John Doe'})
|
|
1170
|
-
producer.close()
|
|
1171
|
-
```
|
|
1172
|
-
|
|
1173
|
-
#### RabbitMQ Consumer (Go)
|
|
1174
|
-
```go
|
|
1175
|
-
// consumer.go
|
|
1176
|
-
package main
|
|
1177
|
-
|
|
1178
|
-
import (
|
|
1179
|
-
"encoding/json"
|
|
1180
|
-
"log"
|
|
1181
|
-
"github.com/streadway/amqp"
|
|
1182
|
-
)
|
|
1183
|
-
|
|
1184
|
-
type UserEvent struct {
|
|
1185
|
-
EventType string `json:"event_type"`
|
|
1186
|
-
User interface{} `json:"user"`
|
|
1187
|
-
Timestamp string `json:"timestamp"`
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
|
-
func main() {
|
|
1191
|
-
conn, err := amqp.Dial("amqp://guest:guest@localhost:5672/")
|
|
1192
|
-
if err != nil {
|
|
1193
|
-
log.Fatal(err)
|
|
1194
|
-
}
|
|
1195
|
-
defer conn.Close()
|
|
1196
|
-
|
|
1197
|
-
ch, err := conn.Channel()
|
|
1198
|
-
if err != nil {
|
|
1199
|
-
log.Fatal(err)
|
|
1200
|
-
}
|
|
1201
|
-
defer ch.Close()
|
|
1202
|
-
|
|
1203
|
-
q, err := ch.QueueDeclare(
|
|
1204
|
-
"user_events", // name
|
|
1205
|
-
true, // durable
|
|
1206
|
-
false, // delete when unused
|
|
1207
|
-
false, // exclusive
|
|
1208
|
-
false, // no-wait
|
|
1209
|
-
nil, // arguments
|
|
1210
|
-
)
|
|
1211
|
-
if err != nil {
|
|
1212
|
-
log.Fatal(err)
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
msgs, err := ch.Consume(
|
|
1216
|
-
q.Name, // queue
|
|
1217
|
-
"", // consumer
|
|
1218
|
-
true, // auto-ack
|
|
1219
|
-
false, // exclusive
|
|
1220
|
-
false, // no-local
|
|
1221
|
-
false, // no-wait
|
|
1222
|
-
nil, // args
|
|
1223
|
-
)
|
|
1224
|
-
if err != nil {
|
|
1225
|
-
log.Fatal(err)
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
log.Println("Waiting for messages. To exit press CTRL+C")
|
|
1229
|
-
|
|
1230
|
-
forever := make(chan bool)
|
|
1231
|
-
|
|
1232
|
-
go func() {
|
|
1233
|
-
for d := range msgs {
|
|
1234
|
-
log.Printf("Received a message: %s", d.Body)
|
|
1235
|
-
|
|
1236
|
-
var event UserEvent
|
|
1237
|
-
if err := json.Unmarshal(d.Body, &event); err != nil {
|
|
1238
|
-
log.Printf("Error parsing message: %v", err)
|
|
1239
|
-
continue
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
|
-
log.Printf("Event type: %s, User: %v", event.EventType, event.User)
|
|
1243
|
-
|
|
1244
|
-
// Process the event
|
|
1245
|
-
handleUserEvent(event)
|
|
1246
|
-
}
|
|
1247
|
-
}()
|
|
1248
|
-
|
|
1249
|
-
<-forever
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
func handleUserEvent(event UserEvent) {
|
|
1253
|
-
switch event.EventType {
|
|
1254
|
-
case "user_created":
|
|
1255
|
-
log.Println("Handling user creation event")
|
|
1256
|
-
case "user_updated":
|
|
1257
|
-
log.Println("Handling user update event")
|
|
1258
|
-
case "user_deleted":
|
|
1259
|
-
log.Println("Handling user deletion event")
|
|
1260
|
-
default:
|
|
1261
|
-
log.Printf("Unknown event type: %s", event.EventType)
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
```
|
|
1265
|
-
|
|
1266
|
-
---
|
|
1267
|
-
|
|
1268
|
-
Last Updated: 2025-11-25
|
|
1269
|
-
Version: 1.0.0
|