moai-adk 0.3.13__py3-none-any.whl → 0.4.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of moai-adk might be problematic. Click here for more details.
- moai_adk/__init__.py +1 -1
- moai_adk/__main__.py +1 -1
- moai_adk/cli/commands/__init__.py +1 -1
- moai_adk/cli/commands/doctor.py +2 -2
- moai_adk/cli/commands/init.py +10 -5
- moai_adk/cli/commands/status.py +1 -1
- moai_adk/cli/commands/update.py +210 -8
- moai_adk/cli/prompts/init_prompts.py +15 -19
- moai_adk/core/__init__.py +1 -1
- moai_adk/core/diagnostics/slash_commands.py +1 -1
- moai_adk/core/git/branch.py +1 -1
- moai_adk/core/git/manager.py +1 -1
- moai_adk/core/project/backup_utils.py +1 -0
- moai_adk/core/project/phase_executor.py +3 -1
- moai_adk/core/project/validator.py +3 -2
- moai_adk/core/quality/__init__.py +1 -1
- moai_adk/core/quality/trust_checker.py +1 -1
- moai_adk/core/quality/validators/__init__.py +1 -1
- moai_adk/core/quality/validators/base_validator.py +1 -1
- moai_adk/core/template/__init__.py +1 -1
- moai_adk/core/template/backup.py +12 -3
- moai_adk/core/template/config.py +24 -0
- moai_adk/core/template/languages.py +1 -1
- moai_adk/core/template/merger.py +74 -4
- moai_adk/core/template/processor.py +62 -14
- moai_adk/templates/.claude/agents/alfred/cc-manager.md +765 -191
- moai_adk/templates/.claude/agents/alfred/debug-helper.md +116 -103
- moai_adk/templates/.claude/agents/alfred/doc-syncer.md +130 -116
- moai_adk/templates/.claude/agents/alfred/git-manager.md +186 -174
- moai_adk/templates/.claude/agents/alfred/implementation-planner.md +227 -213
- moai_adk/templates/.claude/agents/alfred/project-manager.md +205 -125
- moai_adk/templates/.claude/agents/alfred/quality-gate.md +224 -209
- moai_adk/templates/.claude/agents/alfred/spec-builder.md +174 -160
- moai_adk/templates/.claude/agents/alfred/tag-agent.md +151 -139
- moai_adk/templates/.claude/agents/alfred/tdd-implementer.md +209 -196
- moai_adk/templates/.claude/agents/alfred/trust-checker.md +247 -233
- moai_adk/templates/.claude/commands/alfred/0-project.md +856 -355
- moai_adk/templates/.claude/commands/alfred/1-plan.md +572 -0
- moai_adk/templates/.claude/commands/alfred/2-run.md +470 -0
- moai_adk/templates/.claude/commands/alfred/3-sync.md +366 -356
- moai_adk/templates/.claude/hooks/alfred/README.md +52 -52
- moai_adk/templates/.claude/hooks/alfred/alfred_hooks.py +44 -48
- moai_adk/templates/.claude/hooks/alfred/core/__init__.py +17 -17
- moai_adk/templates/.claude/hooks/alfred/core/checkpoint.py +59 -59
- moai_adk/templates/.claude/hooks/alfred/core/context.py +19 -19
- moai_adk/templates/.claude/hooks/alfred/core/project.py +52 -52
- moai_adk/templates/.claude/hooks/alfred/handlers/__init__.py +1 -1
- moai_adk/templates/.claude/hooks/alfred/handlers/notification.py +4 -4
- moai_adk/templates/.claude/hooks/alfred/handlers/session.py +30 -51
- moai_adk/templates/.claude/hooks/alfred/handlers/tool.py +16 -17
- moai_adk/templates/.claude/hooks/alfred/handlers/user.py +11 -11
- moai_adk/templates/.claude/output-styles/alfred/agentic-coding.md +308 -307
- moai_adk/templates/.claude/output-styles/alfred/moai-adk-learning.md +297 -296
- moai_adk/templates/.claude/output-styles/alfred/study-with-alfred.md +191 -190
- moai_adk/templates/.claude/skills/moai-alfred-code-reviewer/SKILL.md +112 -0
- moai_adk/templates/.claude/skills/moai-alfred-debugger-pro/SKILL.md +103 -0
- moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/SKILL.md +103 -0
- moai_adk/templates/.claude/skills/moai-alfred-git-workflow/SKILL.md +95 -0
- moai_adk/templates/.claude/skills/moai-alfred-language-detection/SKILL.md +99 -0
- moai_adk/templates/.claude/skills/moai-alfred-performance-optimizer/SKILL.md +105 -0
- moai_adk/templates/.claude/skills/moai-alfred-refactoring-coach/SKILL.md +97 -0
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/SKILL.md +97 -0
- moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/SKILL.md +90 -0
- moai_adk/templates/.claude/skills/moai-alfred-trust-validation/SKILL.md +99 -0
- moai_adk/templates/.claude/skills/moai-alfred-tui-survey/SKILL.md +87 -0
- moai_adk/templates/.claude/skills/moai-alfred-tui-survey/examples.md +62 -0
- moai_adk/templates/.claude/skills/moai-claude-code/SKILL.md +94 -0
- moai_adk/templates/.claude/skills/moai-claude-code/examples.md +513 -0
- moai_adk/templates/.claude/skills/moai-claude-code/reference.md +433 -0
- moai_adk/templates/.claude/skills/moai-claude-code/templates/agent-full.md +332 -0
- moai_adk/templates/.claude/skills/moai-claude-code/templates/command-full.md +384 -0
- moai_adk/templates/.claude/skills/moai-claude-code/templates/plugin-full.json +363 -0
- moai_adk/templates/.claude/skills/moai-claude-code/templates/settings-full.json +595 -0
- moai_adk/templates/.claude/skills/moai-claude-code/templates/skill-full.md +496 -0
- moai_adk/templates/.claude/skills/moai-domain-backend/SKILL.md +99 -0
- moai_adk/templates/.claude/skills/moai-domain-cli-tool/SKILL.md +95 -0
- moai_adk/templates/.claude/skills/moai-domain-data-science/SKILL.md +98 -0
- moai_adk/templates/.claude/skills/moai-domain-database/SKILL.md +100 -0
- moai_adk/templates/.claude/skills/moai-domain-devops/SKILL.md +100 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/SKILL.md +99 -0
- moai_adk/templates/.claude/skills/moai-domain-ml/SKILL.md +99 -0
- moai_adk/templates/.claude/skills/moai-domain-mobile-app/SKILL.md +93 -0
- moai_adk/templates/.claude/skills/moai-domain-security/SKILL.md +105 -0
- moai_adk/templates/.claude/skills/moai-domain-web-api/SKILL.md +97 -0
- moai_adk/templates/.claude/skills/moai-essentials-debug/SKILL.md +102 -0
- moai_adk/templates/.claude/skills/moai-essentials-perf/SKILL.md +104 -0
- moai_adk/templates/.claude/skills/moai-essentials-refactor/SKILL.md +96 -0
- moai_adk/templates/.claude/skills/moai-essentials-review/SKILL.md +112 -0
- moai_adk/templates/.claude/skills/moai-foundation-ears/SKILL.md +98 -0
- moai_adk/templates/.claude/skills/moai-foundation-git/SKILL.md +90 -0
- moai_adk/templates/.claude/skills/moai-foundation-langs/SKILL.md +94 -0
- moai_adk/templates/.claude/skills/moai-foundation-specs/SKILL.md +93 -0
- moai_adk/templates/.claude/skills/moai-foundation-tags/SKILL.md +86 -0
- moai_adk/templates/.claude/skills/moai-foundation-trust/SKILL.md +86 -0
- moai_adk/templates/.claude/skills/moai-lang-c/SKILL.md +100 -0
- moai_adk/templates/.claude/skills/moai-lang-clojure/SKILL.md +100 -0
- moai_adk/templates/.claude/skills/moai-lang-cpp/SKILL.md +102 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/SKILL.md +100 -0
- moai_adk/templates/.claude/skills/moai-lang-dart/SKILL.md +98 -0
- moai_adk/templates/.claude/skills/moai-lang-elixir/SKILL.md +99 -0
- moai_adk/templates/.claude/skills/moai-lang-go/SKILL.md +100 -0
- moai_adk/templates/.claude/skills/moai-lang-haskell/SKILL.md +100 -0
- moai_adk/templates/.claude/skills/moai-lang-java/SKILL.md +98 -0
- moai_adk/templates/.claude/skills/moai-lang-javascript/SKILL.md +96 -0
- moai_adk/templates/.claude/skills/moai-lang-julia/SKILL.md +98 -0
- moai_adk/templates/.claude/skills/moai-lang-kotlin/SKILL.md +99 -0
- moai_adk/templates/.claude/skills/moai-lang-lua/SKILL.md +98 -0
- moai_adk/templates/.claude/skills/moai-lang-php/SKILL.md +98 -0
- moai_adk/templates/.claude/skills/moai-lang-python/SKILL.md +96 -0
- moai_adk/templates/.claude/skills/moai-lang-r/SKILL.md +99 -0
- moai_adk/templates/.claude/skills/moai-lang-ruby/SKILL.md +99 -0
- moai_adk/templates/.claude/skills/moai-lang-rust/SKILL.md +100 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/SKILL.md +100 -0
- moai_adk/templates/.claude/skills/moai-lang-shell/SKILL.md +100 -0
- moai_adk/templates/.claude/skills/moai-lang-sql/SKILL.md +100 -0
- moai_adk/templates/.claude/skills/moai-lang-swift/SKILL.md +99 -0
- moai_adk/templates/.claude/skills/moai-lang-typescript/SKILL.md +96 -0
- moai_adk/templates/.github/PULL_REQUEST_TEMPLATE.md +44 -43
- moai_adk/templates/.github/workflows/moai-gitflow.yml +36 -35
- moai_adk/templates/.moai/config.json +9 -6
- moai_adk/templates/.moai/memory/development-guide.md +220 -221
- moai_adk/templates/.moai/memory/gitflow-protection-policy.md +85 -85
- moai_adk/templates/.moai/memory/spec-metadata.md +149 -150
- moai_adk/templates/.moai/project/product.md +90 -90
- moai_adk/templates/.moai/project/structure.md +85 -85
- moai_adk/templates/.moai/project/tech.md +117 -117
- moai_adk/templates/CLAUDE.md +354 -573
- moai_adk/templates/__init__.py +1 -1
- moai_adk/utils/__init__.py +1 -1
- moai_adk/utils/banner.py +7 -7
- moai_adk/utils/logger.py +1 -1
- moai_adk-0.4.1.dist-info/METADATA +303 -0
- moai_adk-0.4.1.dist-info/RECORD +152 -0
- moai_adk/templates/.claude/commands/alfred/1-spec.md +0 -532
- moai_adk/templates/.claude/commands/alfred/2-build.md +0 -432
- moai_adk/templates/.moai/hooks/pre-push.sample +0 -88
- moai_adk-0.3.13.dist-info/METADATA +0 -1586
- moai_adk-0.3.13.dist-info/RECORD +0 -90
- {moai_adk-0.3.13.dist-info → moai_adk-0.4.1.dist-info}/WHEEL +0 -0
- {moai_adk-0.3.13.dist-info → moai_adk-0.4.1.dist-info}/entry_points.txt +0 -0
- {moai_adk-0.3.13.dist-info → moai_adk-0.4.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,201 +1,201 @@
|
|
|
1
|
-
# {{PROJECT_NAME}}
|
|
1
|
+
# {{PROJECT_NAME}} Development Guide
|
|
2
2
|
|
|
3
|
-
> "
|
|
3
|
+
> "No spec, no code. No tests, no implementation."
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This unified guardrail applies to every agent and developer who uses the MoAI-ADK universal development toolkit. The Python-based toolkit supports all major programming languages and enforces a SPEC-first TDD methodology with @TAG traceability. English is the default working language.
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
## SPEC
|
|
9
|
+
## SPEC-First TDD Workflow
|
|
10
10
|
|
|
11
|
-
###
|
|
11
|
+
### Core Development Loop (3 Steps)
|
|
12
12
|
|
|
13
|
-
1. **SPEC
|
|
14
|
-
2. **TDD
|
|
15
|
-
3.
|
|
13
|
+
1. **Write the SPEC** (`/alfred:1-plan`) → no code without a spec
|
|
14
|
+
2. **Implement with TDD** (`/alfred:2-run`) → no implementation without tests
|
|
15
|
+
3. **Sync Documentation** (`/alfred:3-sync`) → no completion without traceability
|
|
16
16
|
|
|
17
|
-
###
|
|
17
|
+
### On-Demand Support
|
|
18
18
|
|
|
19
|
-
-
|
|
20
|
-
- **CLI
|
|
21
|
-
-
|
|
19
|
+
- **Debugging**: summon `@agent-debug-helper` when failures occur
|
|
20
|
+
- **CLI Commands**: init, doctor, status, update, restore, help, version
|
|
21
|
+
- **System Diagnostics**: auto-detect language tooling and verify prerequisites
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Every change must comply with the @TAG system, SPEC-derived requirements, and language-specific TDD practices.
|
|
24
24
|
|
|
25
|
-
### EARS
|
|
25
|
+
### EARS Requirement Authoring
|
|
26
26
|
|
|
27
|
-
**EARS (Easy Approach to Requirements Syntax)
|
|
27
|
+
**EARS (Easy Approach to Requirements Syntax)** provides a disciplined method for writing requirements.
|
|
28
28
|
|
|
29
|
-
#### EARS
|
|
30
|
-
1.
|
|
31
|
-
2.
|
|
32
|
-
3.
|
|
33
|
-
4.
|
|
34
|
-
5.
|
|
29
|
+
#### Five EARS Patterns
|
|
30
|
+
1. **Ubiquitous Requirements**: The system shall provide [capability].
|
|
31
|
+
2. **Event-driven Requirements**: WHEN [condition], the system shall [behaviour].
|
|
32
|
+
3. **State-driven Requirements**: WHILE [state], the system shall [behaviour].
|
|
33
|
+
4. **Optional Features**: WHERE [condition], the system may [behaviour].
|
|
34
|
+
5. **Constraints**: IF [condition], the system shall enforce [constraint].
|
|
35
35
|
|
|
36
|
-
####
|
|
36
|
+
#### Practical Example
|
|
37
37
|
```markdown
|
|
38
|
-
### Ubiquitous Requirements (
|
|
39
|
-
-
|
|
38
|
+
### Ubiquitous Requirements (Baseline)
|
|
39
|
+
- The system shall provide user authentication.
|
|
40
40
|
|
|
41
|
-
### Event-driven Requirements
|
|
42
|
-
- WHEN
|
|
43
|
-
- WHEN
|
|
41
|
+
### Event-driven Requirements
|
|
42
|
+
- WHEN a user logs in with valid credentials, the system shall issue a JWT token.
|
|
43
|
+
- WHEN a token expires, the system shall return a 401 error.
|
|
44
44
|
|
|
45
|
-
### State-driven Requirements
|
|
46
|
-
- WHILE
|
|
45
|
+
### State-driven Requirements
|
|
46
|
+
- WHILE the user remains authenticated, the system shall allow access to protected resources.
|
|
47
47
|
|
|
48
|
-
### Optional Features
|
|
49
|
-
- WHERE
|
|
48
|
+
### Optional Features
|
|
49
|
+
- WHERE a refresh token is present, the system may issue a new access token.
|
|
50
50
|
|
|
51
|
-
### Constraints
|
|
52
|
-
- IF
|
|
53
|
-
-
|
|
51
|
+
### Constraints
|
|
52
|
+
- IF an invalid token is supplied, the system shall deny access.
|
|
53
|
+
- Access tokens shall not exceed a 15-minute lifetime.
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
---
|
|
57
57
|
|
|
58
|
-
## Context Engineering
|
|
58
|
+
## Context Engineering
|
|
59
59
|
|
|
60
|
-
MoAI-ADK
|
|
60
|
+
MoAI-ADK follows Anthropic's principles from “Effective Context Engineering for AI Agents” to keep context lean and relevant.
|
|
61
61
|
|
|
62
62
|
### 1. JIT (Just-in-Time) Retrieval
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
**Principle**: Load documents only when needed to minimize initial context load.
|
|
65
65
|
|
|
66
|
-
**Alfred
|
|
66
|
+
**Alfred’s JIT Strategy**:
|
|
67
67
|
|
|
68
|
-
|
|
|
69
|
-
|
|
70
|
-
| `/alfred:1-
|
|
71
|
-
| `/alfred:2-
|
|
72
|
-
| `/alfred:3-sync` | sync-report.md
|
|
68
|
+
| Command | Required Load | Optional Load | Timing |
|
|
69
|
+
| ---------------- | ---------------- | -------------------------------- | ---------------------------------- |
|
|
70
|
+
| `/alfred:1-plan` | product.md | structure.md, tech.md | While discovering SPEC candidates |
|
|
71
|
+
| `/alfred:2-run` | SPEC-XXX/spec.md | development-guide.md | At the start of TDD implementation |
|
|
72
|
+
| `/alfred:3-sync` | sync-report.md | TAG chain validation (`rg` scan) | During documentation sync |
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
- Alfred
|
|
76
|
-
-
|
|
77
|
-
- CLAUDE.md
|
|
74
|
+
**Implementation Notes**:
|
|
75
|
+
- Alfred uses the `Read` tool to load only the necessary documents at command time.
|
|
76
|
+
- Agents request only the documents relevant to their current task.
|
|
77
|
+
- The five documents listed in CLAUDE.md “Memory Strategy” are always loaded.
|
|
78
78
|
|
|
79
|
-
### Context Engineering
|
|
79
|
+
### Context Engineering Checklist
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
- [ ] JIT:
|
|
83
|
-
- [ ]
|
|
81
|
+
**When designing commands**:
|
|
82
|
+
- [ ] JIT: Do we load only the required documents?
|
|
83
|
+
- [ ] Optional Load: Do we load documents conditionally?
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
- [ ]
|
|
87
|
-
- [ ]
|
|
85
|
+
**When designing agents**:
|
|
86
|
+
- [ ] Minimum tools: Does the YAML frontmatter declare only the needed tools?
|
|
87
|
+
- [ ] Clear roles: Does each agent maintain a single responsibility?
|
|
88
88
|
|
|
89
89
|
---
|
|
90
90
|
|
|
91
|
-
## TRUST 5
|
|
91
|
+
## TRUST Principles (5 Pillars)
|
|
92
92
|
|
|
93
|
-
### T -
|
|
93
|
+
### T – Test-Driven Development (SPEC-Aligned)
|
|
94
94
|
|
|
95
|
-
**SPEC → Test → Code
|
|
95
|
+
**SPEC → Test → Code Cycle**:
|
|
96
96
|
|
|
97
|
-
- **SPEC**: `@SPEC:ID`
|
|
98
|
-
- **RED**: `@TEST:ID`
|
|
99
|
-
- **GREEN**: `@CODE:ID`
|
|
100
|
-
- **REFACTOR**: `@CODE:ID`
|
|
97
|
+
- **SPEC**: Author detailed specifications first with `@SPEC:ID` tags (EARS format).
|
|
98
|
+
- **RED**: `@TEST:ID` – write failing tests tied to SPEC requirements and confirm failure.
|
|
99
|
+
- **GREEN**: `@CODE:ID` – implement the minimal code that passes the tests and satisfies the SPEC.
|
|
100
|
+
- **REFACTOR**: `@CODE:ID` – improve the code while preserving SPEC compliance, then document with `@DOC:ID`.
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
**Language-Specific TDD Tooling**:
|
|
103
103
|
|
|
104
|
-
- **Python**: pytest + SPEC
|
|
105
|
-
- **TypeScript**: Vitest + SPEC
|
|
106
|
-
- **Java**: JUnit + SPEC
|
|
107
|
-
- **Go**: go test + SPEC
|
|
108
|
-
- **Rust**: cargo test + SPEC
|
|
109
|
-
- **Ruby**: RSpec + SPEC
|
|
104
|
+
- **Python**: pytest + SPEC-based test cases (with mypy type hints)
|
|
105
|
+
- **TypeScript**: Vitest + SPEC-driven suites (strict typing)
|
|
106
|
+
- **Java**: JUnit + SPEC annotations (behaviour-driven tests)
|
|
107
|
+
- **Go**: go test + SPEC table-driven tests (interface adherence)
|
|
108
|
+
- **Rust**: cargo test + SPEC doc tests (trait validation)
|
|
109
|
+
- **Ruby**: RSpec + SPEC-based BDD scenarios
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
Each test links SPEC requirements to implementations via `@TEST:ID → @CODE:ID`.
|
|
112
112
|
|
|
113
|
-
### R -
|
|
113
|
+
### R – Requirement-Driven Readability
|
|
114
114
|
|
|
115
|
-
**SPEC
|
|
115
|
+
**SPEC-Aligned Clean Code**:
|
|
116
116
|
|
|
117
|
-
-
|
|
118
|
-
-
|
|
119
|
-
-
|
|
120
|
-
-
|
|
117
|
+
- Functions implement SPEC requirements directly (≤ 50 LOC per function).
|
|
118
|
+
- Names mirror SPEC terminology and domain language.
|
|
119
|
+
- Code structure reflects SPEC design decisions.
|
|
120
|
+
- Comments are limited to SPEC clarifications and @TAG references.
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
**Language-Specific SPEC Implementation**:
|
|
123
123
|
|
|
124
|
-
- **Python**:
|
|
125
|
-
- **TypeScript**:
|
|
126
|
-
- **Java**:
|
|
127
|
-
- **Go**:
|
|
128
|
-
- **Rust**:
|
|
129
|
-
- **Ruby**:
|
|
124
|
+
- **Python**: Type hints mirroring SPEC interfaces + mypy validation
|
|
125
|
+
- **TypeScript**: Strict interfaces that match SPEC contracts
|
|
126
|
+
- **Java**: Classes implementing SPEC components with strong typing
|
|
127
|
+
- **Go**: Interfaces that satisfy SPEC requirements + gofmt
|
|
128
|
+
- **Rust**: Types enforcing SPEC safety requirements + rustfmt
|
|
129
|
+
- **Ruby**: Behaviour reflecting SPEC narratives + RuboCop validation
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
Every code element must remain traceable back to the SPEC via @TAG comments.
|
|
132
132
|
|
|
133
|
-
### U
|
|
133
|
+
### U – Unified SPEC Architecture
|
|
134
134
|
|
|
135
|
-
- **SPEC
|
|
136
|
-
- **SPEC
|
|
137
|
-
-
|
|
138
|
-
- **SPEC
|
|
135
|
+
- **SPEC-Driven Complexity**: Each SPEC defines its complexity threshold. Exceeding it requires a new SPEC or a documented exception.
|
|
136
|
+
- **SPEC vs. Implementation**: Keep authoring and implementation separate; never edit the SPEC mid-TDD cycle.
|
|
137
|
+
- **Language Boundaries**: SPECs define boundaries across languages (Python modules, TypeScript interfaces, Java packages, Go packages, Rust crates, etc.).
|
|
138
|
+
- **SPEC-Guided Architecture**: Domain boundaries follow the SPEC, not language conventions, with the @TAG system ensuring cross-language traceability.
|
|
139
139
|
|
|
140
|
-
### S
|
|
140
|
+
### S – SPEC-Compliant Security
|
|
141
141
|
|
|
142
|
-
- **
|
|
143
|
-
-
|
|
144
|
-
-
|
|
145
|
-
-
|
|
146
|
-
-
|
|
147
|
-
-
|
|
148
|
-
-
|
|
142
|
+
- **Security Requirements**: Every SPEC explicitly defines security needs, data sensitivity, and access control.
|
|
143
|
+
- **Security by Design**: Implement security controls during the TDD cycle, not after completion.
|
|
144
|
+
- **Language-Agnostic Security Patterns**:
|
|
145
|
+
- Input validation based on SPEC interface definitions
|
|
146
|
+
- Audit logging for SPEC-defined critical operations
|
|
147
|
+
- Access controls aligned with the SPEC permission model
|
|
148
|
+
- Secret management tailored to SPEC environment requirements
|
|
149
149
|
|
|
150
|
-
### T
|
|
150
|
+
### T – SPEC Traceability
|
|
151
151
|
|
|
152
|
-
- **
|
|
153
|
-
- **
|
|
154
|
-
- `/alfred:1-
|
|
155
|
-
- `/alfred:2-
|
|
156
|
-
- `/alfred:3-sync`: `@DOC:ID` (docs/)
|
|
157
|
-
-
|
|
152
|
+
- **Spec-to-Code Traceability**: Every code change references SPEC IDs and requirements through the @TAG system.
|
|
153
|
+
- **Three-Stage Workflow Trace**:
|
|
154
|
+
- `/alfred:1-plan`: Write SPECs with `@SPEC:ID` tags (`.moai/specs/`)
|
|
155
|
+
- `/alfred:2-run`: Implement via TDD with `@TEST:ID` (tests/) → `@CODE:ID` (src/)
|
|
156
|
+
- `/alfred:3-sync`: Sync documentation using `@DOC:ID` (docs/) and validate TAG coverage
|
|
157
|
+
- **Code Scan Verification**: Guarantee TAG traceability by scanning the codebase directly with `rg '@(SPEC|TEST|CODE|DOC):' -n`, without intermediate caches.
|
|
158
158
|
|
|
159
159
|
---
|
|
160
160
|
|
|
161
|
-
## SPEC
|
|
161
|
+
## SPEC-First Mindset
|
|
162
162
|
|
|
163
|
-
1. **SPEC
|
|
164
|
-
2. **SPEC
|
|
165
|
-
3. **SPEC
|
|
163
|
+
1. **SPEC-Led Decisions**: Reference an existing SPEC or author a new one before making any technical decision. Never implement without clear requirements.
|
|
164
|
+
2. **SPEC Context Review**: Read the relevant SPEC documents before changing code, understand the @TAG relationships, and confirm compliance.
|
|
165
|
+
3. **SPEC Communication**: Default to English for collaboration. SPEC documents should use precise technical terminology and plain, unambiguous explanations.
|
|
166
166
|
|
|
167
|
-
## SPEC-TDD
|
|
167
|
+
## SPEC-TDD Workflow
|
|
168
168
|
|
|
169
|
-
1. **SPEC
|
|
170
|
-
2. **TDD
|
|
171
|
-
3.
|
|
169
|
+
1. **Start with the SPEC**: Author or reference a SPEC before writing code. Use `/alfred:1-plan` to clarify requirements, design, and tasks.
|
|
170
|
+
2. **Implement with TDD**: Follow the Red–Green–Refactor loop rigorously using `/alfred:2-run` with language-appropriate testing frameworks.
|
|
171
|
+
3. **Maintain Traceability**: Run `/alfred:3-sync` to update documentation and preserve @TAG relationships between SPECs and code.
|
|
172
172
|
|
|
173
|
-
## @TAG
|
|
173
|
+
## @TAG System
|
|
174
174
|
|
|
175
|
-
###
|
|
175
|
+
### Core Chain
|
|
176
176
|
|
|
177
177
|
```text
|
|
178
178
|
@SPEC:ID → @TEST:ID → @CODE:ID → @DOC:ID
|
|
179
179
|
```
|
|
180
180
|
|
|
181
|
-
**TDD
|
|
182
|
-
- `@SPEC:ID` (
|
|
183
|
-
- `@TEST:ID` (RED)
|
|
184
|
-
- `@CODE:ID` (GREEN + REFACTOR)
|
|
185
|
-
- `@DOC:ID` (
|
|
181
|
+
**Perfect TDD Alignment**:
|
|
182
|
+
- `@SPEC:ID` (Preparation) – requirements authored with the EARS pattern
|
|
183
|
+
- `@TEST:ID` (RED) – failing tests derived from the SPEC
|
|
184
|
+
- `@CODE:ID` (GREEN + REFACTOR) – implementation and refactoring
|
|
185
|
+
- `@DOC:ID` (Documentation) – live documents that capture the outcome
|
|
186
186
|
|
|
187
|
-
### TAG
|
|
187
|
+
### TAG Block Template
|
|
188
188
|
|
|
189
|
-
> **📋 SPEC
|
|
189
|
+
> **📋 SPEC Metadata Standard (SSOT)**: see `spec-metadata.md`
|
|
190
190
|
|
|
191
|
-
|
|
192
|
-
-
|
|
193
|
-
-
|
|
194
|
-
- **HISTORY
|
|
191
|
+
**Every SPEC document must include YAML front matter and a HISTORY section**:
|
|
192
|
+
- **Required Fields (7)**: id, version, status, created, updated, author, priority
|
|
193
|
+
- **Optional Fields (9)**: category, labels, depends_on, blocks, related_specs, related_issue, scope
|
|
194
|
+
- **HISTORY Section**: log every version change (mandatory)
|
|
195
195
|
|
|
196
|
-
|
|
196
|
+
Find the complete template, field descriptions, and validation commands in `spec-metadata.md`.
|
|
197
197
|
|
|
198
|
-
|
|
198
|
+
**Quick Reference Example**:
|
|
199
199
|
```yaml
|
|
200
200
|
---
|
|
201
201
|
id: AUTH-001
|
|
@@ -207,139 +207,138 @@ author: @Goos
|
|
|
207
207
|
priority: high
|
|
208
208
|
---
|
|
209
209
|
|
|
210
|
-
# @SPEC:AUTH-001: JWT
|
|
210
|
+
# @SPEC:AUTH-001: JWT Authentication System
|
|
211
211
|
|
|
212
212
|
## HISTORY
|
|
213
213
|
### v0.0.1 (2025-09-15)
|
|
214
|
-
- **INITIAL**:
|
|
214
|
+
- **INITIAL**: Authored the JWT authentication system SPEC
|
|
215
215
|
...
|
|
216
216
|
```
|
|
217
217
|
|
|
218
|
-
|
|
218
|
+
**Source Code (`src/`)**:
|
|
219
219
|
```text
|
|
220
220
|
# @CODE:AUTH-001 | SPEC: SPEC-AUTH-001.md | TEST: tests/auth/service.test.ts
|
|
221
221
|
```
|
|
222
222
|
|
|
223
|
-
|
|
223
|
+
**Test Code (`tests/`)**:
|
|
224
224
|
```text
|
|
225
225
|
# @TEST:AUTH-001 | SPEC: SPEC-AUTH-001.md
|
|
226
226
|
```
|
|
227
227
|
|
|
228
|
-
### @CODE
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
- `@CODE:ID:API`
|
|
232
|
-
- `@CODE:ID:UI`
|
|
233
|
-
- `@CODE:ID:DATA`
|
|
234
|
-
- `@CODE:ID:DOMAIN`
|
|
235
|
-
- `@CODE:ID:INFRA`
|
|
236
|
-
|
|
237
|
-
### TAG
|
|
238
|
-
|
|
239
|
-
- **TAG ID**:
|
|
240
|
-
-
|
|
241
|
-
- ✅
|
|
242
|
-
- ❌
|
|
243
|
-
-
|
|
244
|
-
-
|
|
245
|
-
- **TAG
|
|
246
|
-
-
|
|
247
|
-
-
|
|
248
|
-
-
|
|
249
|
-
- **TAG
|
|
250
|
-
- **
|
|
251
|
-
- **
|
|
252
|
-
|
|
253
|
-
### HISTORY
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
- `INITIAL`:
|
|
257
|
-
- `ADDED`:
|
|
258
|
-
- `CHANGED`:
|
|
259
|
-
- `FIXED`:
|
|
260
|
-
- `REMOVED`:
|
|
261
|
-
- `BREAKING`:
|
|
262
|
-
- `DEPRECATED`:
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
- `AUTHOR`:
|
|
266
|
-
- `REVIEW`:
|
|
267
|
-
- `REASON`:
|
|
268
|
-
- `RELATED`:
|
|
269
|
-
|
|
270
|
-
**HISTORY
|
|
228
|
+
### @CODE Subcategories (Comment Level)
|
|
229
|
+
|
|
230
|
+
Document implementation details inside `@CODE:ID` blocks:
|
|
231
|
+
- `@CODE:ID:API` – REST APIs, GraphQL endpoints
|
|
232
|
+
- `@CODE:ID:UI` – UI components, views, screens
|
|
233
|
+
- `@CODE:ID:DATA` – data models, schemas, types
|
|
234
|
+
- `@CODE:ID:DOMAIN` – business logic, domain rules
|
|
235
|
+
- `@CODE:ID:INFRA` – infrastructure, databases, integrations
|
|
236
|
+
|
|
237
|
+
### TAG Usage Rules
|
|
238
|
+
|
|
239
|
+
- **TAG ID Format**: `<DOMAIN>-<3 digits>` (e.g., `AUTH-003`) – immutable once created.
|
|
240
|
+
- **Directory Naming**: `.moai/specs/SPEC-{ID}/` (required)
|
|
241
|
+
- ✅ Valid: `SPEC-AUTH-001/`, `SPEC-REFACTOR-001/`, `SPEC-UPDATE-REFACTOR-001/`
|
|
242
|
+
- ❌ Invalid: `AUTH-001/`, `SPEC-001-auth/`, `SPEC-AUTH-001-jwt/`
|
|
243
|
+
- **Composite Domains**: hyphenated combinations allowed (e.g., `UPDATE-REFACTOR-001`)
|
|
244
|
+
- **Guideline**: Prefer fewer than three hyphen segments for clarity
|
|
245
|
+
- **TAG Contents**: May evolve freely; always record the rationale in HISTORY.
|
|
246
|
+
- **Versioning**: Semantic Versioning (v0.0.1 → v0.1.0 → v1.0.0)
|
|
247
|
+
- See `spec-metadata.md#versioning` for details.
|
|
248
|
+
- **Duplicate Check**: Run `rg "@SPEC:{ID}" -n .moai/specs/` before creating a new TAG.
|
|
249
|
+
- **TAG Validation**: `rg '@(SPEC|TEST|CODE|DOC):' -n .moai/specs/ tests/ src/ docs/`
|
|
250
|
+
- **Version Alignment**: `rg "SPEC-{ID}.md v" -n`
|
|
251
|
+
- **Code-First Principle**: The source of truth for TAGs lives in the codebase.
|
|
252
|
+
|
|
253
|
+
### HISTORY Authoring Guide
|
|
254
|
+
|
|
255
|
+
**Change Type Tags**:
|
|
256
|
+
- `INITIAL`: First release (v1.0.0)
|
|
257
|
+
- `ADDED`: New requirement or capability → increment MINOR
|
|
258
|
+
- `CHANGED`: Adjusted behaviour → increment PATCH
|
|
259
|
+
- `FIXED`: Bug or defect fix → increment PATCH
|
|
260
|
+
- `REMOVED`: Removed capability → increment MAJOR
|
|
261
|
+
- `BREAKING`: Backward-incompatible change → increment MAJOR
|
|
262
|
+
- `DEPRECATED`: Marked for future removal
|
|
263
|
+
|
|
264
|
+
**Required Metadata**:
|
|
265
|
+
- `AUTHOR`: Contributor (GitHub ID)
|
|
266
|
+
- `REVIEW`: Reviewer and approval status
|
|
267
|
+
- `REASON`: Why the change was made (optional but recommended for significant updates)
|
|
268
|
+
- `RELATED`: Linked issues/PRs (optional)
|
|
269
|
+
|
|
270
|
+
**HISTORY Search Examples**:
|
|
271
271
|
```bash
|
|
272
|
-
#
|
|
272
|
+
# View the full change log for a TAG
|
|
273
273
|
rg -A 20 "# @SPEC:AUTH-001" .moai/specs/SPEC-AUTH-001.md
|
|
274
274
|
|
|
275
|
-
# HISTORY
|
|
275
|
+
# Extract only the HISTORY section
|
|
276
276
|
rg -A 50 "## HISTORY" .moai/specs/SPEC-AUTH-001.md
|
|
277
277
|
|
|
278
|
-
#
|
|
278
|
+
# Check the latest entries
|
|
279
279
|
rg "### v[0-9]" .moai/specs/SPEC-AUTH-001.md | head -3
|
|
280
280
|
```
|
|
281
281
|
|
|
282
|
-
|
|
283
282
|
---
|
|
284
283
|
|
|
285
|
-
##
|
|
284
|
+
## Development Principles
|
|
286
285
|
|
|
287
|
-
###
|
|
286
|
+
### Code Constraints
|
|
288
287
|
|
|
289
|
-
-
|
|
290
|
-
-
|
|
291
|
-
-
|
|
292
|
-
-
|
|
288
|
+
- ≤ 300 LOC per file
|
|
289
|
+
- ≤ 50 LOC per function
|
|
290
|
+
- ≤ 5 parameters per function
|
|
291
|
+
- Cyclomatic complexity ≤ 10
|
|
293
292
|
|
|
294
|
-
###
|
|
293
|
+
### Quality Benchmarks
|
|
295
294
|
|
|
296
|
-
-
|
|
297
|
-
-
|
|
298
|
-
-
|
|
299
|
-
-
|
|
295
|
+
- ≥ 85% test coverage
|
|
296
|
+
- Use intention-revealing names
|
|
297
|
+
- Prefer guard clauses
|
|
298
|
+
- Leverage language-standard tooling
|
|
300
299
|
|
|
301
|
-
###
|
|
300
|
+
### Refactoring Rules
|
|
302
301
|
|
|
303
|
-
- **
|
|
304
|
-
-
|
|
305
|
-
-
|
|
302
|
+
- **Rule of Three**: Plan refactoring when the same pattern appears a third time.
|
|
303
|
+
- **Preparatory Refactoring**: Shape the code for easy change before applying the change.
|
|
304
|
+
- **Tidy as You Go**: Fix small issues immediately; when scope expands, split into a dedicated effort.
|
|
306
305
|
|
|
307
|
-
##
|
|
306
|
+
## Exception Handling
|
|
308
307
|
|
|
309
|
-
|
|
308
|
+
When deviating from recommendations, document a waiver and attach it to the relevant PR, issue, or ADR.
|
|
310
309
|
|
|
311
|
-
**Waiver
|
|
310
|
+
**Waiver Checklist**:
|
|
312
311
|
|
|
313
|
-
-
|
|
314
|
-
-
|
|
315
|
-
-
|
|
316
|
-
-
|
|
312
|
+
- Justification and evaluated alternatives
|
|
313
|
+
- Risks and mitigation plan
|
|
314
|
+
- Temporary vs. permanent status
|
|
315
|
+
- Expiry conditions and approver
|
|
317
316
|
|
|
318
|
-
##
|
|
317
|
+
## Language Tooling Map
|
|
319
318
|
|
|
320
|
-
- **Python**: pytest (
|
|
321
|
-
- **TypeScript**: Vitest (
|
|
322
|
-
- **Java**: JUnit (
|
|
323
|
-
- **Go**: go test (
|
|
324
|
-
- **Rust**: cargo test (
|
|
325
|
-
- **Ruby**: RSpec (
|
|
319
|
+
- **Python**: pytest (tests), mypy (type checks), black (formatting)
|
|
320
|
+
- **TypeScript**: Vitest (tests), Biome (lint + format)
|
|
321
|
+
- **Java**: JUnit (tests), Maven/Gradle (build)
|
|
322
|
+
- **Go**: go test (tests), gofmt (format)
|
|
323
|
+
- **Rust**: cargo test (tests), rustfmt (format)
|
|
324
|
+
- **Ruby**: RSpec (tests), RuboCop (lint + format), Bundler (packages)
|
|
326
325
|
|
|
327
|
-
##
|
|
326
|
+
## Variable Role Reference
|
|
328
327
|
|
|
329
|
-
| Role | Description
|
|
330
|
-
| ------------------ |
|
|
331
|
-
| Fixed Value | Constant after initialization
|
|
332
|
-
| Stepper | Changes sequentially
|
|
333
|
-
| Flag | Boolean state indicator
|
|
334
|
-
| Walker | Traverses a data structure
|
|
335
|
-
| Most Recent Holder | Holds the most recent value
|
|
336
|
-
| Most Wanted Holder | Holds optimal/maximum value
|
|
337
|
-
| Gatherer | Accumulator
|
|
338
|
-
| Container | Stores multiple values
|
|
339
|
-
| Follower | Previous value of another variable
|
|
340
|
-
| Organizer | Reorganizes data
|
|
341
|
-
| Temporary | Temporary storage
|
|
328
|
+
| Role | Description | Example |
|
|
329
|
+
| ------------------ | ---------------------------------- | ------------------------------------ |
|
|
330
|
+
| Fixed Value | Constant after initialization | `const MAX_SIZE = 100` |
|
|
331
|
+
| Stepper | Changes sequentially | `for (let i = 0; i < n; i++)` |
|
|
332
|
+
| Flag | Boolean state indicator | `let isValid = true` |
|
|
333
|
+
| Walker | Traverses a data structure | `while (node) { node = node.next; }` |
|
|
334
|
+
| Most Recent Holder | Holds the most recent value | `let lastError` |
|
|
335
|
+
| Most Wanted Holder | Holds optimal/maximum value | `let bestScore = -Infinity` |
|
|
336
|
+
| Gatherer | Accumulator | `sum += value` |
|
|
337
|
+
| Container | Stores multiple values | `const list = []` |
|
|
338
|
+
| Follower | Previous value of another variable | `prev = curr; curr = next;` |
|
|
339
|
+
| Organizer | Reorganizes data | `const sorted = array.sort()` |
|
|
340
|
+
| Temporary | Temporary storage | `const temp = a; a = b; b = temp;` |
|
|
342
341
|
|
|
343
342
|
---
|
|
344
343
|
|
|
345
|
-
|
|
344
|
+
This guide defines the standards for executing the three-stage MoAI-ADK pipeline.
|