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
|
@@ -0,0 +1,713 @@
|
|
|
1
|
+
# Next.js 16 Patterns
|
|
2
|
+
|
|
3
|
+
Comprehensive patterns for Next.js 16 development covering App Router, Server Actions, ISR (Incremental Static Regeneration), and Route Handlers.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## App Router Architecture
|
|
8
|
+
|
|
9
|
+
### File-Based Routing
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
app/
|
|
13
|
+
├── layout.tsx # Root layout
|
|
14
|
+
├── page.tsx # Home page (/)
|
|
15
|
+
├── loading.tsx # Loading UI
|
|
16
|
+
├── error.tsx # Error UI
|
|
17
|
+
├── not-found.tsx # 404 UI
|
|
18
|
+
├── dashboard/
|
|
19
|
+
│ ├── layout.tsx # Dashboard layout
|
|
20
|
+
│ ├── page.tsx # /dashboard
|
|
21
|
+
│ └── settings/
|
|
22
|
+
│ └── page.tsx # /dashboard/settings
|
|
23
|
+
├── blog/
|
|
24
|
+
│ ├── page.tsx # /blog
|
|
25
|
+
│ └── [slug]/
|
|
26
|
+
│ └── page.tsx # /blog/:slug
|
|
27
|
+
└── api/
|
|
28
|
+
└── users/
|
|
29
|
+
└── route.ts # API route
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Layouts and Templates
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
// app/layout.tsx - Root Layout
|
|
36
|
+
import { Inter } from 'next/font/google'
|
|
37
|
+
import { Providers } from './providers'
|
|
38
|
+
import { Header } from '@/components/Header'
|
|
39
|
+
import { Footer } from '@/components/Footer'
|
|
40
|
+
|
|
41
|
+
const inter = Inter({ subsets: ['latin'] })
|
|
42
|
+
|
|
43
|
+
export const metadata = {
|
|
44
|
+
title: {
|
|
45
|
+
default: 'My App',
|
|
46
|
+
template: '%s | My App'
|
|
47
|
+
},
|
|
48
|
+
description: 'Modern web application',
|
|
49
|
+
metadataBase: new URL('https://myapp.com')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default function RootLayout({
|
|
53
|
+
children,
|
|
54
|
+
}: {
|
|
55
|
+
children: React.ReactNode
|
|
56
|
+
}) {
|
|
57
|
+
return (
|
|
58
|
+
<html lang="en" suppressHydrationWarning>
|
|
59
|
+
<body className={inter.className}>
|
|
60
|
+
<Providers>
|
|
61
|
+
<Header />
|
|
62
|
+
<main className="min-h-screen">{children}</main>
|
|
63
|
+
<Footer />
|
|
64
|
+
</Providers>
|
|
65
|
+
</body>
|
|
66
|
+
</html>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// app/dashboard/layout.tsx - Nested Layout
|
|
71
|
+
import { Sidebar } from '@/components/Sidebar'
|
|
72
|
+
import { requireAuth } from '@/lib/auth'
|
|
73
|
+
|
|
74
|
+
export default async function DashboardLayout({
|
|
75
|
+
children,
|
|
76
|
+
}: {
|
|
77
|
+
children: React.ReactNode
|
|
78
|
+
}) {
|
|
79
|
+
await requireAuth()
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<div className="flex">
|
|
83
|
+
<Sidebar />
|
|
84
|
+
<div className="flex-1 p-6">{children}</div>
|
|
85
|
+
</div>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Dynamic Routes
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
// app/blog/[slug]/page.tsx
|
|
94
|
+
import { notFound } from 'next/navigation'
|
|
95
|
+
import { getPost, getAllPosts } from '@/lib/posts'
|
|
96
|
+
|
|
97
|
+
interface PageProps {
|
|
98
|
+
params: Promise<{ slug: string }>
|
|
99
|
+
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export async function generateMetadata({ params }: PageProps) {
|
|
103
|
+
const { slug } = await params
|
|
104
|
+
const post = await getPost(slug)
|
|
105
|
+
|
|
106
|
+
if (!post) {
|
|
107
|
+
return { title: 'Post Not Found' }
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
title: post.title,
|
|
112
|
+
description: post.excerpt,
|
|
113
|
+
openGraph: {
|
|
114
|
+
title: post.title,
|
|
115
|
+
description: post.excerpt,
|
|
116
|
+
images: [post.coverImage]
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export async function generateStaticParams() {
|
|
122
|
+
const posts = await getAllPosts()
|
|
123
|
+
return posts.map((post) => ({
|
|
124
|
+
slug: post.slug
|
|
125
|
+
}))
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export default async function BlogPost({ params }: PageProps) {
|
|
129
|
+
const { slug } = await params
|
|
130
|
+
const post = await getPost(slug)
|
|
131
|
+
|
|
132
|
+
if (!post) {
|
|
133
|
+
notFound()
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<article className="prose prose-lg mx-auto">
|
|
138
|
+
<h1>{post.title}</h1>
|
|
139
|
+
<time dateTime={post.publishedAt}>{post.formattedDate}</time>
|
|
140
|
+
<div dangerouslySetInnerHTML={{ __html: post.content }} />
|
|
141
|
+
</article>
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Server Actions
|
|
149
|
+
|
|
150
|
+
### Form Handling with Server Actions
|
|
151
|
+
|
|
152
|
+
```tsx
|
|
153
|
+
// app/actions/posts.ts
|
|
154
|
+
'use server'
|
|
155
|
+
|
|
156
|
+
import { z } from 'zod'
|
|
157
|
+
import { revalidatePath, revalidateTag } from 'next/cache'
|
|
158
|
+
import { redirect } from 'next/navigation'
|
|
159
|
+
import { auth } from '@/lib/auth'
|
|
160
|
+
import { db } from '@/lib/db'
|
|
161
|
+
|
|
162
|
+
const createPostSchema = z.object({
|
|
163
|
+
title: z.string().min(1, 'Title is required').max(100),
|
|
164
|
+
content: z.string().min(10, 'Content must be at least 10 characters'),
|
|
165
|
+
published: z.boolean().optional().default(false)
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
export interface ActionState {
|
|
169
|
+
success: boolean
|
|
170
|
+
errors?: {
|
|
171
|
+
title?: string
|
|
172
|
+
content?: string
|
|
173
|
+
general?: string
|
|
174
|
+
}
|
|
175
|
+
data?: { id: string }
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export async function createPost(
|
|
179
|
+
prevState: ActionState,
|
|
180
|
+
formData: FormData
|
|
181
|
+
): Promise<ActionState> {
|
|
182
|
+
const session = await auth()
|
|
183
|
+
|
|
184
|
+
if (!session?.user) {
|
|
185
|
+
return {
|
|
186
|
+
success: false,
|
|
187
|
+
errors: { general: 'You must be logged in' }
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const rawData = {
|
|
192
|
+
title: formData.get('title'),
|
|
193
|
+
content: formData.get('content'),
|
|
194
|
+
published: formData.get('published') === 'on'
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const result = createPostSchema.safeParse(rawData)
|
|
198
|
+
|
|
199
|
+
if (!result.success) {
|
|
200
|
+
const fieldErrors = result.error.flatten().fieldErrors
|
|
201
|
+
return {
|
|
202
|
+
success: false,
|
|
203
|
+
errors: {
|
|
204
|
+
title: fieldErrors.title?.[0],
|
|
205
|
+
content: fieldErrors.content?.[0]
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
try {
|
|
211
|
+
const post = await db.post.create({
|
|
212
|
+
data: {
|
|
213
|
+
...result.data,
|
|
214
|
+
authorId: session.user.id
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
revalidatePath('/posts')
|
|
219
|
+
revalidateTag('posts')
|
|
220
|
+
|
|
221
|
+
return {
|
|
222
|
+
success: true,
|
|
223
|
+
data: { id: post.id }
|
|
224
|
+
}
|
|
225
|
+
} catch (error) {
|
|
226
|
+
console.error('Failed to create post:', error)
|
|
227
|
+
return {
|
|
228
|
+
success: false,
|
|
229
|
+
errors: { general: 'Failed to create post. Please try again.' }
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export async function deletePost(postId: string) {
|
|
235
|
+
const session = await auth()
|
|
236
|
+
|
|
237
|
+
if (!session?.user) {
|
|
238
|
+
throw new Error('Unauthorized')
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const post = await db.post.findUnique({
|
|
242
|
+
where: { id: postId }
|
|
243
|
+
})
|
|
244
|
+
|
|
245
|
+
if (!post || post.authorId !== session.user.id) {
|
|
246
|
+
throw new Error('Forbidden')
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
await db.post.delete({ where: { id: postId } })
|
|
250
|
+
|
|
251
|
+
revalidatePath('/posts')
|
|
252
|
+
revalidateTag('posts')
|
|
253
|
+
redirect('/posts')
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export async function togglePublish(postId: string) {
|
|
257
|
+
const post = await db.post.findUnique({
|
|
258
|
+
where: { id: postId }
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
if (!post) {
|
|
262
|
+
throw new Error('Post not found')
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
await db.post.update({
|
|
266
|
+
where: { id: postId },
|
|
267
|
+
data: { published: !post.published }
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
revalidatePath(`/posts/${postId}`)
|
|
271
|
+
revalidatePath('/posts')
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Using Server Actions in Components
|
|
276
|
+
|
|
277
|
+
```tsx
|
|
278
|
+
// app/posts/new/page.tsx
|
|
279
|
+
'use client'
|
|
280
|
+
|
|
281
|
+
import { useActionState } from 'react'
|
|
282
|
+
import { createPost, type ActionState } from '@/app/actions/posts'
|
|
283
|
+
import { useRouter } from 'next/navigation'
|
|
284
|
+
import { useEffect } from 'react'
|
|
285
|
+
|
|
286
|
+
const initialState: ActionState = {
|
|
287
|
+
success: false,
|
|
288
|
+
errors: {}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export default function NewPostPage() {
|
|
292
|
+
const router = useRouter()
|
|
293
|
+
const [state, formAction, isPending] = useActionState(
|
|
294
|
+
createPost,
|
|
295
|
+
initialState
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
useEffect(() => {
|
|
299
|
+
if (state.success && state.data?.id) {
|
|
300
|
+
router.push(`/posts/${state.data.id}`)
|
|
301
|
+
}
|
|
302
|
+
}, [state, router])
|
|
303
|
+
|
|
304
|
+
return (
|
|
305
|
+
<div className="max-w-2xl mx-auto py-8">
|
|
306
|
+
<h1 className="text-2xl font-bold mb-6">Create New Post</h1>
|
|
307
|
+
|
|
308
|
+
<form action={formAction} className="space-y-6">
|
|
309
|
+
{state.errors?.general && (
|
|
310
|
+
<div className="bg-red-50 border border-red-200 rounded p-4">
|
|
311
|
+
{state.errors.general}
|
|
312
|
+
</div>
|
|
313
|
+
)}
|
|
314
|
+
|
|
315
|
+
<div>
|
|
316
|
+
<label htmlFor="title" className="block font-medium mb-2">
|
|
317
|
+
Title
|
|
318
|
+
</label>
|
|
319
|
+
<input
|
|
320
|
+
id="title"
|
|
321
|
+
name="title"
|
|
322
|
+
type="text"
|
|
323
|
+
className="w-full border rounded px-3 py-2"
|
|
324
|
+
aria-describedby={state.errors?.title ? 'title-error' : undefined}
|
|
325
|
+
/>
|
|
326
|
+
{state.errors?.title && (
|
|
327
|
+
<p id="title-error" className="text-red-600 text-sm mt-1">
|
|
328
|
+
{state.errors.title}
|
|
329
|
+
</p>
|
|
330
|
+
)}
|
|
331
|
+
</div>
|
|
332
|
+
|
|
333
|
+
<div>
|
|
334
|
+
<label htmlFor="content" className="block font-medium mb-2">
|
|
335
|
+
Content
|
|
336
|
+
</label>
|
|
337
|
+
<textarea
|
|
338
|
+
id="content"
|
|
339
|
+
name="content"
|
|
340
|
+
rows={8}
|
|
341
|
+
className="w-full border rounded px-3 py-2"
|
|
342
|
+
aria-describedby={state.errors?.content ? 'content-error' : undefined}
|
|
343
|
+
/>
|
|
344
|
+
{state.errors?.content && (
|
|
345
|
+
<p id="content-error" className="text-red-600 text-sm mt-1">
|
|
346
|
+
{state.errors.content}
|
|
347
|
+
</p>
|
|
348
|
+
)}
|
|
349
|
+
</div>
|
|
350
|
+
|
|
351
|
+
<div className="flex items-center gap-2">
|
|
352
|
+
<input id="published" name="published" type="checkbox" />
|
|
353
|
+
<label htmlFor="published">Publish immediately</label>
|
|
354
|
+
</div>
|
|
355
|
+
|
|
356
|
+
<button
|
|
357
|
+
type="submit"
|
|
358
|
+
disabled={isPending}
|
|
359
|
+
className="bg-blue-600 text-white px-4 py-2 rounded disabled:opacity-50"
|
|
360
|
+
>
|
|
361
|
+
{isPending ? 'Creating...' : 'Create Post'}
|
|
362
|
+
</button>
|
|
363
|
+
</form>
|
|
364
|
+
</div>
|
|
365
|
+
)
|
|
366
|
+
}
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## Incremental Static Regeneration (ISR)
|
|
372
|
+
|
|
373
|
+
### Time-Based Revalidation
|
|
374
|
+
|
|
375
|
+
```tsx
|
|
376
|
+
// app/products/page.tsx
|
|
377
|
+
import { getProducts } from '@/lib/products'
|
|
378
|
+
|
|
379
|
+
// Revalidate every 60 seconds
|
|
380
|
+
export const revalidate = 60
|
|
381
|
+
|
|
382
|
+
export default async function ProductsPage() {
|
|
383
|
+
const products = await getProducts()
|
|
384
|
+
|
|
385
|
+
return (
|
|
386
|
+
<div className="grid grid-cols-3 gap-6">
|
|
387
|
+
{products.map(product => (
|
|
388
|
+
<ProductCard key={product.id} product={product} />
|
|
389
|
+
))}
|
|
390
|
+
</div>
|
|
391
|
+
)
|
|
392
|
+
}
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### On-Demand Revalidation
|
|
396
|
+
|
|
397
|
+
```tsx
|
|
398
|
+
// app/api/revalidate/route.ts
|
|
399
|
+
import { revalidatePath, revalidateTag } from 'next/cache'
|
|
400
|
+
import { NextRequest, NextResponse } from 'next/server'
|
|
401
|
+
|
|
402
|
+
export async function POST(request: NextRequest) {
|
|
403
|
+
const secret = request.headers.get('x-revalidate-secret')
|
|
404
|
+
|
|
405
|
+
if (secret !== process.env.REVALIDATE_SECRET) {
|
|
406
|
+
return NextResponse.json({ error: 'Invalid secret' }, { status: 401 })
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const body = await request.json()
|
|
410
|
+
const { path, tag, type } = body
|
|
411
|
+
|
|
412
|
+
try {
|
|
413
|
+
if (type === 'path' && path) {
|
|
414
|
+
revalidatePath(path)
|
|
415
|
+
return NextResponse.json({ revalidated: true, path })
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
if (type === 'tag' && tag) {
|
|
419
|
+
revalidateTag(tag)
|
|
420
|
+
return NextResponse.json({ revalidated: true, tag })
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
return NextResponse.json({ error: 'Invalid request' }, { status: 400 })
|
|
424
|
+
} catch (error) {
|
|
425
|
+
return NextResponse.json({ error: 'Revalidation failed' }, { status: 500 })
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
### Tag-Based Caching
|
|
431
|
+
|
|
432
|
+
```tsx
|
|
433
|
+
// lib/products.ts
|
|
434
|
+
export async function getProducts() {
|
|
435
|
+
const response = await fetch('https://api.example.com/products', {
|
|
436
|
+
next: { tags: ['products'], revalidate: 3600 }
|
|
437
|
+
})
|
|
438
|
+
return response.json()
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
export async function getProduct(id: string) {
|
|
442
|
+
const response = await fetch(`https://api.example.com/products/${id}`, {
|
|
443
|
+
next: { tags: ['products', `product-${id}`] }
|
|
444
|
+
})
|
|
445
|
+
return response.json()
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// In server action or API route
|
|
449
|
+
export async function updateProduct(id: string, data: ProductData) {
|
|
450
|
+
await db.product.update({ where: { id }, data })
|
|
451
|
+
|
|
452
|
+
// Revalidate specific product and product list
|
|
453
|
+
revalidateTag(`product-${id}`)
|
|
454
|
+
revalidateTag('products')
|
|
455
|
+
}
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
460
|
+
## Route Handlers
|
|
461
|
+
|
|
462
|
+
### RESTful API Routes
|
|
463
|
+
|
|
464
|
+
```tsx
|
|
465
|
+
// app/api/users/route.ts
|
|
466
|
+
import { NextRequest, NextResponse } from 'next/server'
|
|
467
|
+
import { z } from 'zod'
|
|
468
|
+
import { auth } from '@/lib/auth'
|
|
469
|
+
import { db } from '@/lib/db'
|
|
470
|
+
|
|
471
|
+
const createUserSchema = z.object({
|
|
472
|
+
name: z.string().min(1),
|
|
473
|
+
email: z.string().email()
|
|
474
|
+
})
|
|
475
|
+
|
|
476
|
+
// GET /api/users
|
|
477
|
+
export async function GET(request: NextRequest) {
|
|
478
|
+
const searchParams = request.nextUrl.searchParams
|
|
479
|
+
const page = parseInt(searchParams.get('page') || '1')
|
|
480
|
+
const limit = parseInt(searchParams.get('limit') || '10')
|
|
481
|
+
const skip = (page - 1) * limit
|
|
482
|
+
|
|
483
|
+
const [users, total] = await Promise.all([
|
|
484
|
+
db.user.findMany({
|
|
485
|
+
skip,
|
|
486
|
+
take: limit,
|
|
487
|
+
orderBy: { createdAt: 'desc' }
|
|
488
|
+
}),
|
|
489
|
+
db.user.count()
|
|
490
|
+
])
|
|
491
|
+
|
|
492
|
+
return NextResponse.json({
|
|
493
|
+
users,
|
|
494
|
+
pagination: {
|
|
495
|
+
page,
|
|
496
|
+
limit,
|
|
497
|
+
total,
|
|
498
|
+
pages: Math.ceil(total / limit)
|
|
499
|
+
}
|
|
500
|
+
})
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// POST /api/users
|
|
504
|
+
export async function POST(request: NextRequest) {
|
|
505
|
+
const session = await auth()
|
|
506
|
+
|
|
507
|
+
if (!session?.user?.isAdmin) {
|
|
508
|
+
return NextResponse.json(
|
|
509
|
+
{ error: 'Unauthorized' },
|
|
510
|
+
{ status: 401 }
|
|
511
|
+
)
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
const body = await request.json()
|
|
515
|
+
const result = createUserSchema.safeParse(body)
|
|
516
|
+
|
|
517
|
+
if (!result.success) {
|
|
518
|
+
return NextResponse.json(
|
|
519
|
+
{ error: 'Validation failed', details: result.error.flatten() },
|
|
520
|
+
{ status: 400 }
|
|
521
|
+
)
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
try {
|
|
525
|
+
const user = await db.user.create({
|
|
526
|
+
data: result.data
|
|
527
|
+
})
|
|
528
|
+
|
|
529
|
+
return NextResponse.json(user, { status: 201 })
|
|
530
|
+
} catch (error) {
|
|
531
|
+
if (error.code === 'P2002') {
|
|
532
|
+
return NextResponse.json(
|
|
533
|
+
{ error: 'Email already exists' },
|
|
534
|
+
{ status: 409 }
|
|
535
|
+
)
|
|
536
|
+
}
|
|
537
|
+
throw error
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// app/api/users/[id]/route.ts
|
|
542
|
+
interface RouteParams {
|
|
543
|
+
params: Promise<{ id: string }>
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
export async function GET(request: NextRequest, { params }: RouteParams) {
|
|
547
|
+
const { id } = await params
|
|
548
|
+
const user = await db.user.findUnique({ where: { id } })
|
|
549
|
+
|
|
550
|
+
if (!user) {
|
|
551
|
+
return NextResponse.json(
|
|
552
|
+
{ error: 'User not found' },
|
|
553
|
+
{ status: 404 }
|
|
554
|
+
)
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
return NextResponse.json(user)
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
export async function PATCH(request: NextRequest, { params }: RouteParams) {
|
|
561
|
+
const { id } = await params
|
|
562
|
+
const body = await request.json()
|
|
563
|
+
|
|
564
|
+
const user = await db.user.update({
|
|
565
|
+
where: { id },
|
|
566
|
+
data: body
|
|
567
|
+
})
|
|
568
|
+
|
|
569
|
+
return NextResponse.json(user)
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
export async function DELETE(request: NextRequest, { params }: RouteParams) {
|
|
573
|
+
const { id } = await params
|
|
574
|
+
|
|
575
|
+
await db.user.delete({ where: { id } })
|
|
576
|
+
|
|
577
|
+
return new NextResponse(null, { status: 204 })
|
|
578
|
+
}
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
---
|
|
582
|
+
|
|
583
|
+
## Parallel and Intercepting Routes
|
|
584
|
+
|
|
585
|
+
### Parallel Routes
|
|
586
|
+
|
|
587
|
+
```tsx
|
|
588
|
+
// app/dashboard/layout.tsx
|
|
589
|
+
export default function DashboardLayout({
|
|
590
|
+
children,
|
|
591
|
+
analytics,
|
|
592
|
+
notifications,
|
|
593
|
+
}: {
|
|
594
|
+
children: React.ReactNode
|
|
595
|
+
analytics: React.ReactNode
|
|
596
|
+
notifications: React.ReactNode
|
|
597
|
+
}) {
|
|
598
|
+
return (
|
|
599
|
+
<div className="dashboard-layout">
|
|
600
|
+
<main className="dashboard-main">{children}</main>
|
|
601
|
+
<aside className="dashboard-sidebar">
|
|
602
|
+
<div className="analytics-panel">{analytics}</div>
|
|
603
|
+
<div className="notifications-panel">{notifications}</div>
|
|
604
|
+
</aside>
|
|
605
|
+
</div>
|
|
606
|
+
)
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// app/dashboard/@analytics/page.tsx
|
|
610
|
+
export default async function AnalyticsPanel() {
|
|
611
|
+
const data = await getAnalytics()
|
|
612
|
+
return <AnalyticsChart data={data} />
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
// app/dashboard/@notifications/page.tsx
|
|
616
|
+
export default async function NotificationsPanel() {
|
|
617
|
+
const notifications = await getNotifications()
|
|
618
|
+
return <NotificationsList items={notifications} />
|
|
619
|
+
}
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
### Intercepting Routes (Modal Pattern)
|
|
623
|
+
|
|
624
|
+
```tsx
|
|
625
|
+
// app/@modal/(.)photos/[id]/page.tsx
|
|
626
|
+
import { Modal } from '@/components/Modal'
|
|
627
|
+
import { getPhoto } from '@/lib/photos'
|
|
628
|
+
|
|
629
|
+
interface PageProps {
|
|
630
|
+
params: Promise<{ id: string }>
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
export default async function PhotoModal({ params }: PageProps) {
|
|
634
|
+
const { id } = await params
|
|
635
|
+
const photo = await getPhoto(id)
|
|
636
|
+
|
|
637
|
+
return (
|
|
638
|
+
<Modal>
|
|
639
|
+
<img src={photo.url} alt={photo.title} className="max-w-full" />
|
|
640
|
+
<h2>{photo.title}</h2>
|
|
641
|
+
<p>{photo.description}</p>
|
|
642
|
+
</Modal>
|
|
643
|
+
)
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// app/layout.tsx
|
|
647
|
+
export default function RootLayout({
|
|
648
|
+
children,
|
|
649
|
+
modal,
|
|
650
|
+
}: {
|
|
651
|
+
children: React.ReactNode
|
|
652
|
+
modal: React.ReactNode
|
|
653
|
+
}) {
|
|
654
|
+
return (
|
|
655
|
+
<html>
|
|
656
|
+
<body>
|
|
657
|
+
{children}
|
|
658
|
+
{modal}
|
|
659
|
+
</body>
|
|
660
|
+
</html>
|
|
661
|
+
)
|
|
662
|
+
}
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
---
|
|
666
|
+
|
|
667
|
+
## Best Practices
|
|
668
|
+
|
|
669
|
+
### Data Fetching Patterns
|
|
670
|
+
|
|
671
|
+
Fetch at the Highest Level:
|
|
672
|
+
- Fetch data in layouts or pages, not deep in component trees
|
|
673
|
+
- Use parallel data fetching with Promise.all()
|
|
674
|
+
- Leverage request deduplication
|
|
675
|
+
|
|
676
|
+
Caching Strategy:
|
|
677
|
+
- Use appropriate revalidation times
|
|
678
|
+
- Tag data for granular cache invalidation
|
|
679
|
+
- Consider static generation for unchanging content
|
|
680
|
+
|
|
681
|
+
### Error Handling
|
|
682
|
+
|
|
683
|
+
```tsx
|
|
684
|
+
// app/dashboard/error.tsx
|
|
685
|
+
'use client'
|
|
686
|
+
|
|
687
|
+
import { useEffect } from 'react'
|
|
688
|
+
|
|
689
|
+
export default function DashboardError({
|
|
690
|
+
error,
|
|
691
|
+
reset,
|
|
692
|
+
}: {
|
|
693
|
+
error: Error & { digest?: string }
|
|
694
|
+
reset: () => void
|
|
695
|
+
}) {
|
|
696
|
+
useEffect(() => {
|
|
697
|
+
console.error(error)
|
|
698
|
+
}, [error])
|
|
699
|
+
|
|
700
|
+
return (
|
|
701
|
+
<div className="error-container">
|
|
702
|
+
<h2>Something went wrong!</h2>
|
|
703
|
+
<p>{error.message}</p>
|
|
704
|
+
<button onClick={() => reset()}>Try again</button>
|
|
705
|
+
</div>
|
|
706
|
+
)
|
|
707
|
+
}
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
---
|
|
711
|
+
|
|
712
|
+
Version: 2.0.0
|
|
713
|
+
Last Updated: 2026-01-06
|