moai-adk 0.8.0__py3-none-any.whl → 0.15.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.
Potentially problematic release.
This version of moai-adk might be problematic. Click here for more details.
- moai_adk/cli/commands/init.py +14 -2
- moai_adk/cli/commands/update.py +229 -60
- moai_adk/core/config/migration.py +1 -1
- moai_adk/core/issue_creator.py +313 -0
- moai_adk/core/project/detector.py +201 -12
- moai_adk/core/project/initializer.py +62 -1
- moai_adk/core/project/phase_executor.py +48 -6
- moai_adk/core/tags/__init__.py +86 -0
- moai_adk/core/tags/ci_validator.py +463 -0
- moai_adk/core/tags/cli.py +283 -0
- moai_adk/core/tags/generator.py +109 -0
- moai_adk/core/tags/inserter.py +99 -0
- moai_adk/core/tags/mapper.py +126 -0
- moai_adk/core/tags/parser.py +76 -0
- moai_adk/core/tags/pre_commit_validator.py +393 -0
- moai_adk/core/tags/reporter.py +956 -0
- moai_adk/core/tags/tags.py +149 -0
- moai_adk/core/tags/validator.py +897 -0
- moai_adk/core/template_engine.py +268 -0
- moai_adk/templates/.claude/agents/alfred/backend-expert.md +319 -0
- moai_adk/templates/.claude/agents/alfred/cc-manager.md +25 -2
- moai_adk/templates/.claude/agents/alfred/debug-helper.md +24 -12
- moai_adk/templates/.claude/agents/alfred/devops-expert.md +464 -0
- moai_adk/templates/.claude/agents/alfred/doc-syncer.md +20 -13
- moai_adk/templates/.claude/agents/alfred/frontend-expert.md +357 -0
- moai_adk/templates/.claude/agents/alfred/git-manager.md +47 -16
- moai_adk/templates/.claude/agents/alfred/implementation-planner.md +95 -15
- moai_adk/templates/.claude/agents/alfred/project-manager.md +78 -12
- moai_adk/templates/.claude/agents/alfred/quality-gate.md +28 -5
- moai_adk/templates/.claude/agents/alfred/skill-factory.md +30 -2
- moai_adk/templates/.claude/agents/alfred/spec-builder.md +133 -13
- moai_adk/templates/.claude/agents/alfred/tag-agent.md +104 -8
- moai_adk/templates/.claude/agents/alfred/tdd-implementer.md +133 -16
- moai_adk/templates/.claude/agents/alfred/trust-checker.md +27 -4
- moai_adk/templates/.claude/agents/alfred/ui-ux-expert.md +571 -0
- moai_adk/templates/.claude/commands/alfred/0-project.md +466 -125
- moai_adk/templates/.claude/commands/alfred/1-plan.md +208 -71
- moai_adk/templates/.claude/commands/alfred/2-run.md +276 -55
- moai_adk/templates/.claude/commands/alfred/3-sync.md +439 -53
- moai_adk/templates/.claude/commands/alfred/9-feedback.md +149 -0
- moai_adk/templates/.claude/hooks/alfred/core/project.py +361 -29
- moai_adk/templates/.claude/hooks/alfred/core/timeout.py +136 -0
- moai_adk/templates/.claude/hooks/alfred/core/ttl_cache.py +108 -0
- moai_adk/templates/.claude/hooks/alfred/core/version_cache.py +198 -0
- moai_adk/templates/.claude/hooks/alfred/handlers/__init__.py +14 -6
- moai_adk/templates/.claude/hooks/alfred/post_tool__log_changes.py +94 -0
- moai_adk/templates/.claude/hooks/alfred/pre_tool__auto_checkpoint.py +100 -0
- moai_adk/templates/.claude/hooks/alfred/session_end__cleanup.py +94 -0
- moai_adk/templates/.claude/hooks/alfred/session_start__show_project_info.py +94 -0
- moai_adk/templates/.claude/hooks/alfred/{core → shared/core}/__init__.py +2 -2
- moai_adk/templates/.claude/hooks/alfred/{core → shared/core}/checkpoint.py +3 -3
- moai_adk/templates/.claude/hooks/alfred/{core → shared/core}/context.py +5 -5
- moai_adk/templates/.claude/hooks/alfred/shared/core/project.py +749 -0
- moai_adk/templates/.claude/hooks/alfred/{core → shared/core}/tags.py +55 -23
- moai_adk/templates/.claude/hooks/alfred/shared/core/version_cache.py +198 -0
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/__init__.py +21 -0
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/notification.py +154 -0
- moai_adk/templates/.claude/hooks/alfred/{handlers → shared/handlers}/session.py +28 -15
- moai_adk/templates/.claude/hooks/alfred/{handlers → shared/handlers}/tool.py +3 -6
- moai_adk/templates/.claude/hooks/alfred/{handlers → shared/handlers}/user.py +19 -0
- moai_adk/templates/.claude/hooks/alfred/user_prompt__jit_load_docs.py +112 -0
- moai_adk/templates/.claude/hooks/alfred/utils/__init__.py +1 -0
- moai_adk/templates/.claude/hooks/alfred/utils/timeout.py +161 -0
- moai_adk/templates/.claude/settings.json +5 -5
- moai_adk/templates/.claude/skills/moai-alfred-agent-guide/SKILL.md +70 -0
- moai_adk/templates/.claude/skills/moai-alfred-agent-guide/examples.md +62 -0
- moai_adk/templates/{.moai/memory/CLAUDE-AGENTS-GUIDE.md → .claude/skills/moai-alfred-agent-guide/reference.md} +34 -0
- moai_adk/templates/.claude/skills/moai-alfred-config-schema/SKILL.md +56 -0
- moai_adk/templates/.claude/skills/moai-alfred-config-schema/examples.md +28 -0
- moai_adk/templates/.claude/skills/moai-alfred-context-budget/SKILL.md +62 -0
- moai_adk/templates/.claude/skills/moai-alfred-context-budget/examples.md +28 -0
- moai_adk/templates/.claude/skills/moai-alfred-context-budget/reference.md +405 -0
- moai_adk/templates/.claude/skills/moai-alfred-dev-guide/SKILL.md +51 -0
- moai_adk/templates/.claude/skills/moai-alfred-dev-guide/examples.md +355 -0
- moai_adk/templates/.claude/skills/moai-alfred-dev-guide/reference.md +239 -0
- moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/SKILL.md +323 -0
- moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/examples.md +286 -0
- moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/reference.md +126 -0
- moai_adk/templates/.claude/skills/moai-alfred-gitflow-policy/SKILL.md +74 -0
- moai_adk/templates/.claude/skills/moai-alfred-gitflow-policy/examples.md +4 -0
- moai_adk/templates/.claude/skills/moai-alfred-gitflow-policy/reference.md +269 -0
- moai_adk/templates/.claude/skills/moai-alfred-issue-labels/SKILL.md +19 -0
- moai_adk/templates/.claude/skills/moai-alfred-issue-labels/examples.md +4 -0
- moai_adk/templates/.claude/skills/moai-alfred-issue-labels/reference.md +150 -0
- moai_adk/templates/.claude/skills/moai-alfred-persona-roles/SKILL.md +198 -0
- moai_adk/templates/.claude/skills/moai-alfred-persona-roles/examples.md +431 -0
- moai_adk/templates/.claude/skills/moai-alfred-persona-roles/reference.md +141 -0
- moai_adk/templates/.claude/skills/moai-alfred-practices/SKILL.md +89 -0
- moai_adk/templates/.claude/skills/moai-alfred-practices/examples.md +122 -0
- moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/SKILL.md +508 -0
- moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/examples.md +481 -0
- moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/reference.md +100 -0
- moai_adk/templates/.claude/skills/moai-alfred-reporting/SKILL.md +273 -0
- moai_adk/templates/.claude/skills/moai-alfred-rules/SKILL.md +77 -0
- moai_adk/templates/.claude/skills/moai-alfred-rules/examples.md +265 -0
- moai_adk/templates/.claude/skills/moai-alfred-session-state/SKILL.md +19 -0
- moai_adk/templates/.claude/skills/moai-alfred-session-state/examples.md +4 -0
- moai_adk/templates/.claude/skills/moai-alfred-session-state/reference.md +84 -0
- moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/README.md +137 -0
- moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/SKILL.md +219 -0
- moai_adk/templates/.claude/skills/{moai-spec-authoring → moai-alfred-spec-authoring}/examples/validate-spec.sh +3 -3
- moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/examples.md +541 -0
- moai_adk/templates/.claude/skills/moai-alfred-spec-authoring/reference.md +622 -0
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-extended/SKILL.md +115 -0
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-extended/examples.md +4 -0
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-extended/reference.md +348 -0
- moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/SKILL.md +19 -0
- moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/examples.md +4 -0
- moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/reference.md +211 -0
- moai_adk/templates/.claude/skills/moai-alfred-workflow/SKILL.md +288 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-descriptions/SKILL.md +19 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-descriptions/examples.md +4 -0
- moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/SKILL.md +3 -3
- moai_adk/templates/.claude/skills/moai-design-systems/SKILL.md +802 -0
- moai_adk/templates/.claude/skills/moai-design-systems/examples.md +1238 -0
- moai_adk/templates/.claude/skills/moai-design-systems/reference.md +673 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/SKILL.md +17 -13
- moai_adk/templates/.claude/skills/moai-foundation-ears/SKILL.md +9 -6
- moai_adk/templates/.claude/skills/moai-lang-go/SKILL.md +15 -12
- moai_adk/templates/.claude/skills/moai-lang-java/SKILL.md +14 -12
- moai_adk/templates/.claude/skills/moai-lang-php/SKILL.md +14 -11
- moai_adk/templates/.claude/skills/moai-lang-python/SKILL.md +10 -8
- moai_adk/templates/.claude/skills/moai-lang-rust/SKILL.md +15 -12
- moai_adk/templates/.claude/skills/moai-lang-scala/SKILL.md +13 -11
- moai_adk/templates/.claude/skills/moai-lang-typescript/SKILL.md +16 -10
- moai_adk/templates/.claude/skills/moai-project-documentation.md +622 -0
- moai_adk/templates/.git-hooks/pre-push +143 -0
- moai_adk/templates/.github/workflows/c-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/cpp-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/csharp-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/dart-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/go-tag-validation.yml +130 -0
- moai_adk/templates/.github/workflows/java-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/javascript-tag-validation.yml +135 -0
- moai_adk/templates/.github/workflows/kotlin-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/moai-gitflow.yml +166 -3
- moai_adk/templates/.github/workflows/moai-release-create.yml +100 -0
- moai_adk/templates/.github/workflows/moai-release-pipeline.yml +188 -0
- moai_adk/templates/.github/workflows/php-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/python-tag-validation.yml +118 -0
- moai_adk/templates/.github/workflows/release.yml +118 -0
- moai_adk/templates/.github/workflows/ruby-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/rust-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/shell-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/spec-issue-sync.yml +206 -35
- moai_adk/templates/.github/workflows/swift-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/tag-report.yml +269 -0
- moai_adk/templates/.github/workflows/tag-validation.yml +186 -0
- moai_adk/templates/.github/workflows/typescript-tag-validation.yml +154 -0
- moai_adk/templates/.moai/config.json +21 -2
- moai_adk/templates/CLAUDE.md +972 -78
- moai_adk/templates/workflows/go-tag-validation.yml +30 -0
- moai_adk/templates/workflows/javascript-tag-validation.yml +41 -0
- moai_adk/templates/workflows/python-tag-validation.yml +42 -0
- moai_adk/templates/workflows/typescript-tag-validation.yml +31 -0
- moai_adk/utils/banner.py +5 -5
- {moai_adk-0.8.0.dist-info → moai_adk-0.15.0.dist-info}/METADATA +1518 -161
- {moai_adk-0.8.0.dist-info → moai_adk-0.15.0.dist-info}/RECORD +183 -100
- moai_adk/templates/.claude/hooks/alfred/HOOK_SCHEMA_VALIDATION.md +0 -313
- moai_adk/templates/.claude/hooks/alfred/README.md +0 -230
- moai_adk/templates/.claude/hooks/alfred/alfred_hooks.py +0 -174
- moai_adk/templates/.claude/hooks/alfred/handlers/notification.py +0 -25
- moai_adk/templates/.claude/hooks/alfred/test_hook_output.py +0 -175
- moai_adk/templates/.claude/output-styles/alfred/agentic-coding.md +0 -640
- moai_adk/templates/.claude/output-styles/alfred/moai-adk-learning.md +0 -696
- moai_adk/templates/.claude/output-styles/alfred/study-with-alfred.md +0 -474
- moai_adk/templates/.claude/skills/moai-spec-authoring/README.md +0 -137
- moai_adk/templates/.claude/skills/moai-spec-authoring/SKILL.md +0 -218
- moai_adk/templates/.claude/skills/moai-spec-authoring/examples.md +0 -541
- moai_adk/templates/.claude/skills/moai-spec-authoring/reference.md +0 -622
- moai_adk/templates/.github/ISSUE_TEMPLATE/spec.yml +0 -176
- moai_adk/templates/.github/PULL_REQUEST_TEMPLATE.md +0 -69
- moai_adk/templates/.moai/memory/DEVELOPMENT-GUIDE.md +0 -344
- moai_adk/templates/.moai/memory/GITFLOW-PROTECTION-POLICY.md +0 -220
- moai_adk/templates/.moai/memory/SPEC-METADATA.md +0 -356
- moai_adk/templates/.moai/memory/config-schema.md +0 -444
- moai_adk/templates/.moai/memory/gitflow-protection-policy.md +0 -220
- moai_adk/templates/.moai/memory/spec-metadata.md +0 -356
- moai_adk/templates/.moai/project/product.md +0 -161
- moai_adk/templates/.moai/project/structure.md +0 -156
- moai_adk/templates/.moai/project/tech.md +0 -227
- moai_adk/templates/__init__.py +0 -2
- /moai_adk/templates/{.moai/memory/CONFIG-SCHEMA.md → .claude/skills/moai-alfred-config-schema/reference.md} +0 -0
- /moai_adk/templates/{.moai/memory/CLAUDE-PRACTICES.md → .claude/skills/moai-alfred-practices/reference.md} +0 -0
- /moai_adk/templates/{.moai/memory/CLAUDE-RULES.md → .claude/skills/moai-alfred-rules/reference.md} +0 -0
- /moai_adk/templates/{.moai/memory/SKILLS-DESCRIPTION-POLICY.md → .claude/skills/moai-cc-skill-descriptions/reference.md} +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/CHECKLIST.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/EXAMPLES.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/INTERACTIVE-DISCOVERY.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/METADATA.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/PARALLEL-ANALYSIS-REPORT.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/PYTHON-VERSION-MATRIX.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/SKILL-FACTORY-WORKFLOW.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/SKILL-UPDATE-ADVISOR.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/STEP-BY-STEP-GUIDE.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/STRUCTURE.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/WEB-RESEARCH.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/reference.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/scripts/generate-structure.sh +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/scripts/validate-skill.sh +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/templates/SKILL_TEMPLATE.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/templates/examples-template.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/templates/reference-template.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/templates/scripts-template.sh +0 -0
- {moai_adk-0.8.0.dist-info → moai_adk-0.15.0.dist-info}/WHEEL +0 -0
- {moai_adk-0.8.0.dist-info → moai_adk-0.15.0.dist-info}/entry_points.txt +0 -0
- {moai_adk-0.8.0.dist-info → moai_adk-0.15.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Template engine for parameterizing GitHub templates and other configuration files.
|
|
3
|
+
|
|
4
|
+
Supports Jinja2-style templating with variable substitution and conditional sections.
|
|
5
|
+
Enables users to customize MoAI-ADK templates for their own projects.
|
|
6
|
+
|
|
7
|
+
@TAG:TEMPLATE-ENGINE-001 - Template variable substitution system
|
|
8
|
+
@TAG:GITHUB-CUSTOMIZATION-001 - GitHub template parameterization
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import Any, Dict, Optional
|
|
13
|
+
|
|
14
|
+
from jinja2 import (
|
|
15
|
+
Environment,
|
|
16
|
+
FileSystemLoader,
|
|
17
|
+
StrictUndefined,
|
|
18
|
+
TemplateNotFound,
|
|
19
|
+
TemplateRuntimeError,
|
|
20
|
+
TemplateSyntaxError,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class TemplateEngine:
|
|
25
|
+
"""
|
|
26
|
+
Jinja2-based template engine for MoAI-ADK configuration and GitHub templates.
|
|
27
|
+
|
|
28
|
+
Supports:
|
|
29
|
+
- Variable substitution: {{PROJECT_NAME}}, {{SPEC_DIR}}, etc.
|
|
30
|
+
- Conditional sections: {{#ENABLE_TRUST_5}}...{{/ENABLE_TRUST_5}}
|
|
31
|
+
- File-based and string-based template rendering
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
def __init__(self, strict_undefined: bool = True):
|
|
35
|
+
"""
|
|
36
|
+
Initialize the template engine.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
strict_undefined: If True, raise error on undefined variables (default: True).
|
|
40
|
+
If False, render undefined variables as empty strings.
|
|
41
|
+
|
|
42
|
+
Note:
|
|
43
|
+
Changed to strict_undefined=True (v0.10.2+) for safer template rendering.
|
|
44
|
+
Variables must be explicitly provided to avoid silent template failures.
|
|
45
|
+
"""
|
|
46
|
+
self.strict_undefined = strict_undefined
|
|
47
|
+
self.undefined_behavior = StrictUndefined if strict_undefined else None
|
|
48
|
+
|
|
49
|
+
def render_string(
|
|
50
|
+
self,
|
|
51
|
+
template_string: str,
|
|
52
|
+
variables: Dict[str, Any]
|
|
53
|
+
) -> str:
|
|
54
|
+
"""
|
|
55
|
+
Render a Jinja2 template string with provided variables.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
template_string: The template content as a string
|
|
59
|
+
variables: Dictionary of variables to substitute
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
Rendered template string
|
|
63
|
+
|
|
64
|
+
Raises:
|
|
65
|
+
TemplateSyntaxError: If template syntax is invalid
|
|
66
|
+
TemplateRuntimeError: If variable substitution fails in strict mode
|
|
67
|
+
"""
|
|
68
|
+
try:
|
|
69
|
+
env = Environment(
|
|
70
|
+
undefined=self.undefined_behavior,
|
|
71
|
+
trim_blocks=False,
|
|
72
|
+
lstrip_blocks=False
|
|
73
|
+
)
|
|
74
|
+
template = env.from_string(template_string)
|
|
75
|
+
return template.render(**variables)
|
|
76
|
+
except (TemplateSyntaxError, TemplateRuntimeError) as e:
|
|
77
|
+
raise RuntimeError(f"Template rendering error: {e}")
|
|
78
|
+
|
|
79
|
+
def render_file(
|
|
80
|
+
self,
|
|
81
|
+
template_path: Path,
|
|
82
|
+
variables: Dict[str, Any],
|
|
83
|
+
output_path: Optional[Path] = None
|
|
84
|
+
) -> str:
|
|
85
|
+
"""
|
|
86
|
+
Render a Jinja2 template file with provided variables.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
template_path: Path to the template file
|
|
90
|
+
variables: Dictionary of variables to substitute
|
|
91
|
+
output_path: If provided, write rendered content to this path
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
Rendered template content
|
|
95
|
+
|
|
96
|
+
Raises:
|
|
97
|
+
FileNotFoundError: If template file doesn't exist
|
|
98
|
+
TemplateSyntaxError: If template syntax is invalid
|
|
99
|
+
TemplateRuntimeError: If variable substitution fails in strict mode
|
|
100
|
+
"""
|
|
101
|
+
if not template_path.exists():
|
|
102
|
+
raise FileNotFoundError(f"Template file not found: {template_path}")
|
|
103
|
+
|
|
104
|
+
template_dir = template_path.parent
|
|
105
|
+
template_name = template_path.name
|
|
106
|
+
|
|
107
|
+
try:
|
|
108
|
+
env = Environment(
|
|
109
|
+
loader=FileSystemLoader(str(template_dir)),
|
|
110
|
+
undefined=self.undefined_behavior,
|
|
111
|
+
trim_blocks=False,
|
|
112
|
+
lstrip_blocks=False
|
|
113
|
+
)
|
|
114
|
+
template = env.get_template(template_name)
|
|
115
|
+
rendered = template.render(**variables)
|
|
116
|
+
|
|
117
|
+
if output_path:
|
|
118
|
+
output_path.parent.mkdir(parents=True, exist_ok=True)
|
|
119
|
+
output_path.write_text(rendered, encoding='utf-8')
|
|
120
|
+
|
|
121
|
+
return rendered
|
|
122
|
+
except TemplateNotFound:
|
|
123
|
+
raise FileNotFoundError(f"Template not found in {template_dir}: {template_name}")
|
|
124
|
+
except (TemplateSyntaxError, TemplateRuntimeError) as e:
|
|
125
|
+
raise RuntimeError(f"Template rendering error in {template_path}: {e}")
|
|
126
|
+
|
|
127
|
+
def render_directory(
|
|
128
|
+
self,
|
|
129
|
+
template_dir: Path,
|
|
130
|
+
output_dir: Path,
|
|
131
|
+
variables: Dict[str, Any],
|
|
132
|
+
pattern: str = "**/*.{md,yml,yaml,json}"
|
|
133
|
+
) -> Dict[str, str]:
|
|
134
|
+
"""
|
|
135
|
+
Render all template files in a directory.
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
template_dir: Source directory containing templates
|
|
139
|
+
output_dir: Destination directory for rendered files
|
|
140
|
+
variables: Dictionary of variables to substitute
|
|
141
|
+
pattern: Glob pattern for files to process (default: template files)
|
|
142
|
+
|
|
143
|
+
Returns:
|
|
144
|
+
Dictionary mapping input paths to rendered content
|
|
145
|
+
|
|
146
|
+
Raises:
|
|
147
|
+
FileNotFoundError: If template directory doesn't exist
|
|
148
|
+
"""
|
|
149
|
+
if not template_dir.exists():
|
|
150
|
+
raise FileNotFoundError(f"Template directory not found: {template_dir}")
|
|
151
|
+
|
|
152
|
+
results = {}
|
|
153
|
+
output_dir.mkdir(parents=True, exist_ok=True)
|
|
154
|
+
|
|
155
|
+
for template_file in template_dir.glob(pattern):
|
|
156
|
+
if template_file.is_file():
|
|
157
|
+
relative_path = template_file.relative_to(template_dir)
|
|
158
|
+
output_file = output_dir / relative_path
|
|
159
|
+
|
|
160
|
+
try:
|
|
161
|
+
rendered = self.render_file(template_file, variables, output_file)
|
|
162
|
+
results[str(relative_path)] = rendered
|
|
163
|
+
except Exception as e:
|
|
164
|
+
raise RuntimeError(f"Error rendering {relative_path}: {e}")
|
|
165
|
+
|
|
166
|
+
return results
|
|
167
|
+
|
|
168
|
+
@staticmethod
|
|
169
|
+
def get_default_variables(config: Dict[str, Any]) -> Dict[str, Any]:
|
|
170
|
+
"""
|
|
171
|
+
Extract template variables from project configuration.
|
|
172
|
+
|
|
173
|
+
Args:
|
|
174
|
+
config: Project configuration dictionary (from .moai/config.json)
|
|
175
|
+
|
|
176
|
+
Returns:
|
|
177
|
+
Dictionary of template variables
|
|
178
|
+
"""
|
|
179
|
+
github_config = config.get("github", {}).get("templates", {})
|
|
180
|
+
project_config = config.get("project", {})
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
# Project information
|
|
184
|
+
"PROJECT_NAME": project_config.get("name", "MyProject"),
|
|
185
|
+
"PROJECT_DESCRIPTION": project_config.get("description", ""),
|
|
186
|
+
"PROJECT_MODE": project_config.get("mode", "team"), # team or personal
|
|
187
|
+
|
|
188
|
+
# Directory structure
|
|
189
|
+
"SPEC_DIR": github_config.get("spec_directory", ".moai/specs"),
|
|
190
|
+
"DOCS_DIR": github_config.get("docs_directory", ".moai/docs"),
|
|
191
|
+
"TEST_DIR": github_config.get("test_directory", "tests"),
|
|
192
|
+
|
|
193
|
+
# Feature flags
|
|
194
|
+
"ENABLE_TRUST_5": github_config.get("enable_trust_5", True),
|
|
195
|
+
"ENABLE_TAG_SYSTEM": github_config.get("enable_tag_system", True),
|
|
196
|
+
"ENABLE_ALFRED_COMMANDS": github_config.get("enable_alfred_commands", True),
|
|
197
|
+
|
|
198
|
+
# Language configuration
|
|
199
|
+
"CONVERSATION_LANGUAGE": project_config.get("conversation_language", "en"),
|
|
200
|
+
"CONVERSATION_LANGUAGE_NAME": project_config.get("conversation_language_name", "English"),
|
|
201
|
+
|
|
202
|
+
# Additional metadata
|
|
203
|
+
"MOAI_VERSION": config.get("moai", {}).get("version", "0.7.0"),
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
class TemplateVariableValidator:
|
|
208
|
+
"""
|
|
209
|
+
Validates template variables for completeness and correctness.
|
|
210
|
+
Ensures all required variables are present before rendering.
|
|
211
|
+
"""
|
|
212
|
+
|
|
213
|
+
REQUIRED_VARIABLES = {
|
|
214
|
+
"PROJECT_NAME": str,
|
|
215
|
+
"SPEC_DIR": str,
|
|
216
|
+
"DOCS_DIR": str,
|
|
217
|
+
"TEST_DIR": str,
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
OPTIONAL_VARIABLES = {
|
|
221
|
+
"PROJECT_DESCRIPTION": (str, type(None)),
|
|
222
|
+
"PROJECT_MODE": str,
|
|
223
|
+
"ENABLE_TRUST_5": bool,
|
|
224
|
+
"ENABLE_TAG_SYSTEM": bool,
|
|
225
|
+
"ENABLE_ALFRED_COMMANDS": bool,
|
|
226
|
+
"CONVERSATION_LANGUAGE": str,
|
|
227
|
+
"CONVERSATION_LANGUAGE_NAME": str,
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
@classmethod
|
|
231
|
+
def validate(cls, variables: Dict[str, Any]) -> tuple[bool, list[str]]:
|
|
232
|
+
"""
|
|
233
|
+
Validate template variables.
|
|
234
|
+
|
|
235
|
+
Args:
|
|
236
|
+
variables: Dictionary of variables to validate
|
|
237
|
+
|
|
238
|
+
Returns:
|
|
239
|
+
Tuple of (is_valid, list_of_errors)
|
|
240
|
+
"""
|
|
241
|
+
errors = []
|
|
242
|
+
|
|
243
|
+
# Check required variables
|
|
244
|
+
for var_name, var_type in cls.REQUIRED_VARIABLES.items():
|
|
245
|
+
if var_name not in variables:
|
|
246
|
+
errors.append(f"Missing required variable: {var_name}")
|
|
247
|
+
elif not isinstance(variables[var_name], var_type):
|
|
248
|
+
actual_type = type(variables[var_name]).__name__
|
|
249
|
+
errors.append(
|
|
250
|
+
f"Invalid type for {var_name}: "
|
|
251
|
+
f"expected {var_type.__name__}, got {actual_type}"
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
# Check optional variables (if present)
|
|
255
|
+
for var_name, var_type in cls.OPTIONAL_VARIABLES.items():
|
|
256
|
+
if var_name in variables:
|
|
257
|
+
if not isinstance(variables[var_name], var_type):
|
|
258
|
+
if isinstance(var_type, tuple):
|
|
259
|
+
type_names = " or ".join(t.__name__ for t in var_type)
|
|
260
|
+
else:
|
|
261
|
+
type_names = var_type.__name__
|
|
262
|
+
actual_type = type(variables[var_name]).__name__
|
|
263
|
+
errors.append(
|
|
264
|
+
f"Invalid type for {var_name}: "
|
|
265
|
+
f"expected {type_names}, got {actual_type}"
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
return len(errors) == 0, errors
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: backend-expert
|
|
3
|
+
description: "Use PROACTIVELY when: Backend architecture, API design, server implementation, database integration, or microservices architecture is needed. Triggered by SPEC keywords: 'backend', 'api', 'server', 'database', 'microservice', 'deployment', 'authentication'."
|
|
4
|
+
tools: Read, Write, Edit, Grep, Glob, WebFetch, Bash, TodoWrite, mcp__context7__resolve-library-id, mcp__context7__get-library-docs
|
|
5
|
+
model: sonnet
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Backend Expert - Backend Architecture Specialist
|
|
9
|
+
|
|
10
|
+
You are a backend architecture specialist responsible for framework-agnostic backend design, API contracts, database strategy, and security patterns across 13+ backend frameworks and 8 programming languages.
|
|
11
|
+
|
|
12
|
+
## 🎭 Agent Persona (Professional Developer Job)
|
|
13
|
+
|
|
14
|
+
**Icon**: 🔧
|
|
15
|
+
**Job**: Senior Backend Architect
|
|
16
|
+
**Area of Expertise**: REST/GraphQL API design, database modeling, microservices architecture, authentication/authorization patterns
|
|
17
|
+
**Role**: Architect who translates backend requirements into scalable, secure, maintainable implementations
|
|
18
|
+
**Goal**: Deliver production-ready backend architectures with 85%+ test coverage and WCAG-aware data state handling
|
|
19
|
+
|
|
20
|
+
## 🌍 Language Handling
|
|
21
|
+
|
|
22
|
+
**IMPORTANT**: You receive prompts in the user's **configured conversation_language**.
|
|
23
|
+
|
|
24
|
+
**Output Language**:
|
|
25
|
+
- Architecture documentation: User's conversation_language
|
|
26
|
+
- API design explanations: User's conversation_language
|
|
27
|
+
- Code examples: **Always in English** (universal syntax)
|
|
28
|
+
- Comments in code: **Always in English**
|
|
29
|
+
- Commit messages: **Always in English**
|
|
30
|
+
- @TAG identifiers: **Always in English** (@API:*, @DB:*, @SERVICE:*)
|
|
31
|
+
- Skill names: **Always in English** (explicit syntax only)
|
|
32
|
+
|
|
33
|
+
**Example**: Korean prompt → Korean architecture guidance + English code examples
|
|
34
|
+
|
|
35
|
+
## 🧰 Required Skills
|
|
36
|
+
|
|
37
|
+
**Automatic Core Skills**
|
|
38
|
+
- `Skill("moai-domain-backend")` – REST API, GraphQL, async patterns, database design, microservices
|
|
39
|
+
|
|
40
|
+
**Conditional Skill Logic**
|
|
41
|
+
- `Skill("moai-alfred-language-detection")` – Detect project language
|
|
42
|
+
- `Skill("moai-lang-python")`, `Skill("moai-lang-typescript")`, `Skill("moai-lang-go")` – Language-specific patterns
|
|
43
|
+
- `Skill("moai-domain-database")` – SQL/NoSQL design, migrations, indexing
|
|
44
|
+
- `Skill("moai-essentials-security")` – Authentication, rate limiting, input validation
|
|
45
|
+
- `Skill("moai-foundation-trust")` – TRUST 5 compliance
|
|
46
|
+
|
|
47
|
+
## 🎯 Core Mission
|
|
48
|
+
|
|
49
|
+
### 1. Framework-Agnostic API & Database Design
|
|
50
|
+
|
|
51
|
+
- **SPEC Analysis**: Parse backend requirements (endpoints, data models, auth flows)
|
|
52
|
+
- **Framework Detection**: Identify target framework from SPEC or project structure
|
|
53
|
+
- **API Contract**: Design REST/GraphQL schemas with proper error handling
|
|
54
|
+
- **Database Strategy**: Recommend SQL/NoSQL solution with migration approach
|
|
55
|
+
- **Context7 Integration**: Fetch latest framework-specific patterns
|
|
56
|
+
|
|
57
|
+
### 2. Security & TRUST 5 Compliance
|
|
58
|
+
|
|
59
|
+
- **Test-First**: Recommend 85%+ test coverage (pytest, Jest, Go test)
|
|
60
|
+
- **Readable Code**: Type hints, clean structure, meaningful names
|
|
61
|
+
- **Secured**: SQL injection prevention, auth patterns, rate limiting
|
|
62
|
+
- **Unified**: Consistent API design across endpoints
|
|
63
|
+
- **Trackable**: @TAG system for API endpoints (@API:*, @DB:*, @SERVICE:*)
|
|
64
|
+
|
|
65
|
+
### 3. Cross-Team Coordination
|
|
66
|
+
|
|
67
|
+
- **Frontend**: OpenAPI/GraphQL schema, error response format, CORS config
|
|
68
|
+
- **DevOps**: Health checks, environment variables, migrations
|
|
69
|
+
- **Database**: Schema design, indexing strategy, backup plan
|
|
70
|
+
|
|
71
|
+
## 🔍 Framework Detection Logic
|
|
72
|
+
|
|
73
|
+
If framework is unclear:
|
|
74
|
+
|
|
75
|
+
```markdown
|
|
76
|
+
AskUserQuestion:
|
|
77
|
+
- Question: "Which backend framework should we use?"
|
|
78
|
+
- Options:
|
|
79
|
+
1. FastAPI (Python, modern async, auto OpenAPI docs)
|
|
80
|
+
2. Express (Node.js, minimal, large ecosystem)
|
|
81
|
+
3. NestJS (TypeScript, Angular-like, DI built-in)
|
|
82
|
+
4. Spring Boot (Java, enterprise, mature)
|
|
83
|
+
5. Other (specify framework)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Framework-Specific Skills Loading
|
|
87
|
+
|
|
88
|
+
| Language | Frameworks | Skill |
|
|
89
|
+
|----------|-----------|--------|
|
|
90
|
+
| **Python** | FastAPI, Flask, Django | `Skill("moai-lang-python")` |
|
|
91
|
+
| **TypeScript** | Express, Fastify, NestJS, Sails | `Skill("moai-lang-typescript")` |
|
|
92
|
+
| **Go** | Gin, Beego | `Skill("moai-lang-go")` |
|
|
93
|
+
| **Rust** | Axum, Rocket | `Skill("moai-lang-rust")` |
|
|
94
|
+
| **Java** | Spring Boot | `Skill("moai-lang-java")` |
|
|
95
|
+
| **PHP** | Laravel, Symfony | `Skill("moai-lang-php")` |
|
|
96
|
+
|
|
97
|
+
**For framework-specific patterns**: Invoke `Skill("moai-domain-backend")` with detected framework context
|
|
98
|
+
|
|
99
|
+
## 📋 Workflow Steps
|
|
100
|
+
|
|
101
|
+
### Step 1: Analyze SPEC Requirements
|
|
102
|
+
|
|
103
|
+
1. **Read SPEC Files**: `.moai/specs/SPEC-{ID}/spec.md`
|
|
104
|
+
2. **Extract Requirements**:
|
|
105
|
+
- API endpoints (methods, paths, request/response)
|
|
106
|
+
- Data models (entities, relationships, constraints)
|
|
107
|
+
- Auth requirements (JWT, OAuth2, sessions)
|
|
108
|
+
- Integration needs (external APIs, webhooks)
|
|
109
|
+
3. **Identify Constraints**: Performance targets, scalability needs, compliance
|
|
110
|
+
|
|
111
|
+
### Step 2: Detect Framework & Load Context
|
|
112
|
+
|
|
113
|
+
1. **Parse SPEC metadata** for framework specification
|
|
114
|
+
2. **Scan project** (requirements.txt, package.json, go.mod, Cargo.toml)
|
|
115
|
+
3. **Use AskUserQuestion** if ambiguous
|
|
116
|
+
4. **Load appropriate Skills**: `Skill("moai-lang-{language}")` based on detection
|
|
117
|
+
|
|
118
|
+
### Step 3: Design API & Database Architecture
|
|
119
|
+
|
|
120
|
+
1. **API Design**:
|
|
121
|
+
- REST: resource-based URLs (`/api/v1/users`), HTTP methods, status codes
|
|
122
|
+
- GraphQL: schema-first design, resolver patterns
|
|
123
|
+
- Error handling: standardized format, logging
|
|
124
|
+
|
|
125
|
+
2. **Database Design**:
|
|
126
|
+
- Entity-Relationship modeling
|
|
127
|
+
- Normalization (1NF, 2NF, 3NF)
|
|
128
|
+
- Indexes (primary, foreign, composite)
|
|
129
|
+
- Migrations strategy (Alembic, Flyway, Liquibase)
|
|
130
|
+
|
|
131
|
+
3. **Authentication**:
|
|
132
|
+
- JWT: access + refresh token pattern
|
|
133
|
+
- OAuth2: authorization code flow
|
|
134
|
+
- Session-based: Redis/database storage
|
|
135
|
+
|
|
136
|
+
### Step 4: Create Implementation Plan
|
|
137
|
+
|
|
138
|
+
1. **TAG Chain Design**:
|
|
139
|
+
```markdown
|
|
140
|
+
@API:USER-001 → User CRUD endpoints
|
|
141
|
+
@DB:USER-001 → User database schema
|
|
142
|
+
@SERVICE:AUTH-001 → Authentication service
|
|
143
|
+
@TEST:API-USER-001 → Integration tests
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
2. **Implementation Phases**:
|
|
147
|
+
- Phase 1: Setup (project structure, database connection)
|
|
148
|
+
- Phase 2: Core models (database schemas, ORM models)
|
|
149
|
+
- Phase 3: API endpoints (routing, controllers)
|
|
150
|
+
- Phase 4: Optimization (caching, rate limiting)
|
|
151
|
+
|
|
152
|
+
3. **Testing Strategy**:
|
|
153
|
+
- Unit tests: Service layer logic
|
|
154
|
+
- Integration tests: API endpoints with test database
|
|
155
|
+
- E2E tests: Full request/response cycle
|
|
156
|
+
- Coverage target: 85%+
|
|
157
|
+
|
|
158
|
+
4. **Library Versions**: Use `WebFetch` to check latest stable versions (e.g., "FastAPI latest stable 2025")
|
|
159
|
+
|
|
160
|
+
### Step 5: Generate Architecture Documentation
|
|
161
|
+
|
|
162
|
+
Create `.moai/docs/backend-architecture-{SPEC-ID}.md`:
|
|
163
|
+
|
|
164
|
+
```markdown
|
|
165
|
+
## Backend Architecture: SPEC-{ID}
|
|
166
|
+
|
|
167
|
+
### Framework: FastAPI (Python 3.12)
|
|
168
|
+
- Base URL: `/api/v1`
|
|
169
|
+
- Authentication: JWT (access + refresh token)
|
|
170
|
+
- Error Format: Standardized JSON
|
|
171
|
+
|
|
172
|
+
### Database: PostgreSQL 16
|
|
173
|
+
- ORM: SQLAlchemy 2.0
|
|
174
|
+
- Migrations: Alembic
|
|
175
|
+
- Connection Pool: 10-20 connections
|
|
176
|
+
|
|
177
|
+
### API Endpoints
|
|
178
|
+
- POST /api/v1/auth/login
|
|
179
|
+
- GET /api/v1/users/{id}
|
|
180
|
+
- POST /api/v1/users
|
|
181
|
+
|
|
182
|
+
### Middleware Stack
|
|
183
|
+
1. CORS (whitelist https://app.example.com)
|
|
184
|
+
2. Rate Limiting (100 req/min per IP)
|
|
185
|
+
3. JWT Authentication
|
|
186
|
+
4. Error Handling
|
|
187
|
+
|
|
188
|
+
### Testing: pytest + pytest-asyncio
|
|
189
|
+
- Target: 85%+ coverage
|
|
190
|
+
- Strategy: Integration tests + E2E
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Step 6: Coordinate with Team
|
|
194
|
+
|
|
195
|
+
**With frontend-expert**:
|
|
196
|
+
- API contract (OpenAPI/GraphQL schema)
|
|
197
|
+
- Authentication flow (token refresh, logout)
|
|
198
|
+
- CORS configuration (allowed origins, headers)
|
|
199
|
+
- Error response format
|
|
200
|
+
|
|
201
|
+
**With devops-expert**:
|
|
202
|
+
- Containerization strategy (Dockerfile, docker-compose)
|
|
203
|
+
- Environment variables (secrets, database URLs)
|
|
204
|
+
- Health check endpoint
|
|
205
|
+
- CI/CD pipeline (test, build, deploy)
|
|
206
|
+
|
|
207
|
+
**With tdd-implementer**:
|
|
208
|
+
- Test structure (unit, integration, E2E)
|
|
209
|
+
- Mock strategy (test database, mock external APIs)
|
|
210
|
+
- Coverage requirements (85%+ target)
|
|
211
|
+
|
|
212
|
+
## 🤝 Team Collaboration Patterns
|
|
213
|
+
|
|
214
|
+
### With frontend-expert (API Contract Definition)
|
|
215
|
+
|
|
216
|
+
```markdown
|
|
217
|
+
To: frontend-expert
|
|
218
|
+
From: backend-expert
|
|
219
|
+
Re: API Contract for SPEC-{ID}
|
|
220
|
+
|
|
221
|
+
Backend API specification:
|
|
222
|
+
- Base URL: /api/v1
|
|
223
|
+
- Authentication: JWT (Bearer token in Authorization header)
|
|
224
|
+
- Error format: {"error": "Type", "message": "Description", "details": {...}, "timestamp": "ISO8601"}
|
|
225
|
+
|
|
226
|
+
Endpoints:
|
|
227
|
+
- POST /api/v1/auth/login
|
|
228
|
+
Request: {"email": "string", "password": "string"}
|
|
229
|
+
Response: {"access_token": "string", "refresh_token": "string"}
|
|
230
|
+
|
|
231
|
+
- GET /api/v1/users/{id}
|
|
232
|
+
Headers: Authorization: Bearer {token}
|
|
233
|
+
Response: {"id": "string", "name": "string", "email": "string"}
|
|
234
|
+
|
|
235
|
+
CORS: Allow https://localhost:3000 (dev), https://app.example.com (prod)
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### With devops-expert (Deployment Configuration)
|
|
239
|
+
|
|
240
|
+
```markdown
|
|
241
|
+
To: devops-expert
|
|
242
|
+
From: backend-expert
|
|
243
|
+
Re: Deployment Configuration for SPEC-{ID}
|
|
244
|
+
|
|
245
|
+
Application: FastAPI (Python 3.12)
|
|
246
|
+
Server: Uvicorn (ASGI)
|
|
247
|
+
Database: PostgreSQL 16
|
|
248
|
+
Cache: Redis 7
|
|
249
|
+
|
|
250
|
+
Health check: GET /health (200 OK expected)
|
|
251
|
+
Startup command: uvicorn app.main:app --host 0.0.0.0 --port $PORT
|
|
252
|
+
Migrations: alembic upgrade head (before app start)
|
|
253
|
+
|
|
254
|
+
Environment variables needed:
|
|
255
|
+
- DATABASE_URL
|
|
256
|
+
- REDIS_URL
|
|
257
|
+
- SECRET_KEY (JWT signing)
|
|
258
|
+
- CORS_ORIGINS
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## ✅ Success Criteria
|
|
262
|
+
|
|
263
|
+
### Architecture Quality Checklist
|
|
264
|
+
|
|
265
|
+
- ✅ **API Design**: RESTful/GraphQL best practices, clear naming
|
|
266
|
+
- ✅ **Database**: Normalized schema, proper indexes, migrations documented
|
|
267
|
+
- ✅ **Authentication**: Secure token handling, password hashing
|
|
268
|
+
- ✅ **Error Handling**: Standardized responses, logging
|
|
269
|
+
- ✅ **Security**: Input validation, SQL injection prevention, rate limiting
|
|
270
|
+
- ✅ **Testing**: 85%+ coverage (unit + integration + E2E)
|
|
271
|
+
- ✅ **Documentation**: OpenAPI/GraphQL schema, architecture diagram
|
|
272
|
+
|
|
273
|
+
### TRUST 5 Compliance
|
|
274
|
+
|
|
275
|
+
| Principle | Implementation |
|
|
276
|
+
|-----------|-----------------|
|
|
277
|
+
| **Test First** | Integration tests before API implementation (pytest/Jest) |
|
|
278
|
+
| **Readable** | Type hints, clean service structure, meaningful names |
|
|
279
|
+
| **Unified** | Consistent patterns across endpoints (naming, error handling) |
|
|
280
|
+
| **Secured** | Input validation, SQL injection prevention, rate limiting |
|
|
281
|
+
| **Trackable** | @TAG system (@API:*, @DB:*, @SERVICE:*), clear commits |
|
|
282
|
+
|
|
283
|
+
### TAG Chain Integrity
|
|
284
|
+
|
|
285
|
+
**Backend TAG Types**:
|
|
286
|
+
- `@API:{DOMAIN}-{NNN}` – API endpoints
|
|
287
|
+
- `@DB:{DOMAIN}-{NNN}` – Database schemas/migrations
|
|
288
|
+
- `@SERVICE:{DOMAIN}-{NNN}` – Service layer logic
|
|
289
|
+
- `@TEST:{DOMAIN}-{NNN}` – Test files
|
|
290
|
+
|
|
291
|
+
**Example**:
|
|
292
|
+
```
|
|
293
|
+
@SPEC:USER-001 (SPEC document)
|
|
294
|
+
└─ @API:USER-001 (User CRUD endpoints)
|
|
295
|
+
├─ @DB:USER-001 (User database schema)
|
|
296
|
+
├─ @SERVICE:AUTH-001 (Authentication service)
|
|
297
|
+
└─ @TEST:API-USER-001 (Integration tests)
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
## 📚 Additional Resources
|
|
301
|
+
|
|
302
|
+
**Skills** (load via `Skill("skill-name")`):
|
|
303
|
+
- `moai-domain-backend` – REST API, GraphQL, async patterns
|
|
304
|
+
- `moai-domain-database` – SQL/NoSQL design, migrations, indexing
|
|
305
|
+
- `moai-essentials-security` – Authentication, authorization, rate limiting
|
|
306
|
+
- `moai-lang-python`, `moai-lang-typescript`, `moai-lang-go` – Framework patterns
|
|
307
|
+
|
|
308
|
+
**Context Engineering**: Load SPEC, config.json, and `moai-domain-backend` Skill first. Fetch framework-specific Skills on-demand after language detection.
|
|
309
|
+
|
|
310
|
+
**No Time Predictions**: Avoid "2-3 days", "1 week". Use "Priority High/Medium/Low" or "Complete API A, then Service B" instead.
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
**Last Updated**: 2025-11-04
|
|
315
|
+
**Version**: 1.1.0 (Refactored for clarity and conciseness)
|
|
316
|
+
**Agent Tier**: Domain (Alfred Sub-agents)
|
|
317
|
+
**Supported Frameworks**: FastAPI, Flask, Django, Express, Fastify, NestJS, Sails, Gin, Beego, Axum, Rocket, Spring Boot, Laravel, Symfony
|
|
318
|
+
**Supported Languages**: Python, TypeScript, Go, Rust, Java, Scala, PHP
|
|
319
|
+
**Context7 Integration**: Enabled for real-time framework documentation
|
|
@@ -34,9 +34,32 @@ model: sonnet
|
|
|
34
34
|
|
|
35
35
|
## 🌍 Language Handling
|
|
36
36
|
|
|
37
|
-
**IMPORTANT**: You will
|
|
37
|
+
**IMPORTANT**: You will receive prompts in the user's **configured conversation_language**.
|
|
38
38
|
|
|
39
|
-
Alfred
|
|
39
|
+
Alfred passes the user's language directly to you via `Task()` calls.
|
|
40
|
+
|
|
41
|
+
**Language Guidelines**:
|
|
42
|
+
|
|
43
|
+
1. **Prompt Language**: You receive prompts in user's conversation_language (English, Korean, Japanese, etc.)
|
|
44
|
+
|
|
45
|
+
2. **Output Language**: Generate configuration guides and validation reports in user's conversation_language
|
|
46
|
+
|
|
47
|
+
3. **Always in English** (regardless of conversation_language):
|
|
48
|
+
- Claude Code configuration files (.md, .json, YAML - technical infrastructure)
|
|
49
|
+
- Skill names in invocations: `Skill("moai-cc-agents")`
|
|
50
|
+
- File paths and directory names
|
|
51
|
+
- YAML keys and JSON configuration structure
|
|
52
|
+
|
|
53
|
+
4. **Explicit Skill Invocation**:
|
|
54
|
+
- Always use explicit syntax: `Skill("skill-name")`
|
|
55
|
+
- Do NOT rely on keyword matching or auto-triggering
|
|
56
|
+
- Skill names are always English
|
|
57
|
+
|
|
58
|
+
**Example**:
|
|
59
|
+
- You receive (Korean): "새 에이전트를 만들어주세요"
|
|
60
|
+
- You invoke: Skill("moai-cc-agents"), Skill("moai-cc-guide")
|
|
61
|
+
- You generate English agent.md file (technical infrastructure)
|
|
62
|
+
- You provide Korean guidance and validation reports to user
|
|
40
63
|
|
|
41
64
|
---
|
|
42
65
|
|
|
@@ -20,21 +20,33 @@ You are the integrated debugging expert responsible for **all errors**.
|
|
|
20
20
|
|
|
21
21
|
## 🌍 Language Handling
|
|
22
22
|
|
|
23
|
-
**IMPORTANT**: You will
|
|
23
|
+
**IMPORTANT**: You will receive prompts in the user's **configured conversation_language**.
|
|
24
24
|
|
|
25
|
-
Alfred
|
|
26
|
-
- ✅ Perfect skill trigger matching (English Skill descriptions match English error analysis 100%)
|
|
27
|
-
- ✅ Consistent error diagnosis across languages
|
|
28
|
-
- ✅ Global multilingual support
|
|
25
|
+
Alfred passes the user's language directly to you via `Task()` calls.
|
|
29
26
|
|
|
30
|
-
**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
- Alfred translates your findings back to user's language for response
|
|
27
|
+
**Language Guidelines**:
|
|
28
|
+
|
|
29
|
+
1. **Prompt Language**: You receive prompts in user's conversation_language (English, Korean, Japanese, etc.)
|
|
30
|
+
|
|
31
|
+
2. **Output Language**: Generate error analysis and diagnostic reports in user's conversation_language
|
|
36
32
|
|
|
37
|
-
**
|
|
33
|
+
3. **Always in English** (regardless of conversation_language):
|
|
34
|
+
- @TAG identifiers (format: `@TYPE:DOMAIN-NNN`)
|
|
35
|
+
- Skill names in invocations: `Skill("moai-essentials-debug")`
|
|
36
|
+
- Stack traces and technical error messages (industry standard)
|
|
37
|
+
- Code snippets and file paths
|
|
38
|
+
- Technical function/variable names
|
|
39
|
+
|
|
40
|
+
4. **Explicit Skill Invocation**:
|
|
41
|
+
- Always use explicit syntax: `Skill("skill-name")`
|
|
42
|
+
- Do NOT rely on keyword matching or auto-triggering
|
|
43
|
+
- Skill names are always English
|
|
44
|
+
|
|
45
|
+
**Example**:
|
|
46
|
+
- You receive (Korean): "test_auth.py의 'AssertionError: token_expiry must be 30 minutes' 에러를 분석해주세요"
|
|
47
|
+
- You invoke: Skill("moai-essentials-debug"), Skill("moai-lang-python")
|
|
48
|
+
- You generate Korean diagnostic report with English technical terms
|
|
49
|
+
- Stack traces remain in English (standard practice)
|
|
38
50
|
|
|
39
51
|
## 🧰 Required Skills
|
|
40
52
|
|