@haaaiawd/anws 2.3.0 → 2.4.1
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.
- package/README.md +1 -1
- package/bin/cli.js +53 -23
- package/lib/diff.js +5 -2
- package/lib/init.js +217 -96
- package/lib/install-state.js +18 -3
- package/lib/manifest.js +364 -79
- package/lib/prompt.js +68 -0
- package/lib/resources/index.js +36 -2
- package/lib/update.js +12 -6
- package/package.json +48 -47
- package/templates/.agents/skills/anws-system/SKILL.md +107 -105
- package/templates/.agents/skills/code-reviewer/SKILL.md +171 -115
- package/templates/.agents/skills/concept-modeler/SKILL.md +230 -179
- package/templates/.agents/skills/craft-authoring/SKILL.md +186 -183
- package/templates/.agents/skills/craft-authoring/references/BUNDLE_POLICY.md +42 -0
- package/templates/.agents/skills/design-reviewer/SKILL.md +265 -190
- package/templates/.agents/skills/e2e-testing-guide/SKILL.md +246 -135
- package/templates/.agents/skills/nexus-mapper/SKILL.md +321 -321
- package/templates/.agents/skills/nexus-mapper/references/probe-protocol.md +1 -1
- package/templates/.agents/skills/nexus-query/SKILL.md +1 -1
- package/templates/.agents/skills/output-contract/SKILL.md +37 -0
- package/templates/.agents/skills/runtime-inspector/SKILL.md +150 -99
- package/templates/.agents/skills/sequential-thinking/SKILL.md +222 -225
- package/templates/.agents/skills/spec-writer/SKILL.md +75 -30
- package/templates/.agents/skills/system-architect/SKILL.md +538 -678
- package/templates/.agents/skills/system-designer/SKILL.md +124 -537
- package/templates/.agents/skills/task-planner/SKILL.md +1 -2
- package/templates/.agents/skills/task-planner/references/TASK_TEMPLATE_05A.md +2 -2
- package/templates/.agents/skills/task-reviewer/SKILL.md +421 -386
- package/templates/.agents/skills/tech-evaluator/SKILL.md +252 -144
- package/templates/.agents/workflows/blueprint.md +156 -68
- package/templates/.agents/workflows/challenge.md +322 -494
- package/templates/.agents/workflows/change.md +182 -339
- package/templates/.agents/workflows/craft.md +159 -197
- package/templates/.agents/workflows/design-system.md +202 -674
- package/templates/.agents/workflows/explore.md +187 -399
- package/templates/.agents/workflows/forge.md +650 -609
- package/templates/.agents/workflows/genesis.md +438 -351
- package/templates/.agents/workflows/probe.md +215 -240
- package/templates/.agents/workflows/quickstart.md +304 -123
- package/templates/.agents/workflows/upgrade.md +145 -182
- package/templates_en/.agents/skills/anws-system/SKILL.md +110 -0
- package/templates_en/.agents/skills/code-reviewer/SKILL.md +171 -0
- package/templates_en/.agents/skills/concept-modeler/SKILL.md +230 -0
- package/templates_en/.agents/skills/craft-authoring/SKILL.md +179 -0
- package/templates_en/.agents/skills/craft-authoring/references/BUNDLE_POLICY.md +42 -0
- package/templates_en/.agents/skills/craft-authoring/references/PROMPT_QUALITY_RUBRIC.md +92 -0
- package/templates_en/.agents/skills/craft-authoring/references/SCORECARD_TEMPLATE.md +52 -0
- package/templates_en/.agents/skills/design-reviewer/SKILL.md +264 -0
- package/templates_en/.agents/skills/e2e-testing-guide/SKILL.md +246 -0
- package/templates_en/.agents/skills/nexus-mapper/SKILL.md +306 -0
- package/templates_en/.agents/skills/nexus-mapper/references/language-customization.md +167 -0
- package/templates_en/.agents/skills/nexus-mapper/references/output-schema.md +311 -0
- package/templates_en/.agents/skills/nexus-mapper/references/probe-protocol.md +246 -0
- package/templates_en/.agents/skills/nexus-mapper/scripts/extract_ast.py +706 -0
- package/templates_en/.agents/skills/nexus-mapper/scripts/git_detective.py +194 -0
- package/templates_en/.agents/skills/nexus-mapper/scripts/languages.json +127 -0
- package/templates_en/.agents/skills/nexus-mapper/scripts/query_graph.py +556 -0
- package/templates_en/.agents/skills/nexus-mapper/scripts/requirements.txt +6 -0
- package/templates_en/.agents/skills/nexus-query/SKILL.md +114 -0
- package/templates_en/.agents/skills/nexus-query/scripts/extract_ast.py +706 -0
- package/templates_en/.agents/skills/nexus-query/scripts/git_detective.py +194 -0
- package/templates_en/.agents/skills/nexus-query/scripts/languages.json +127 -0
- package/templates_en/.agents/skills/nexus-query/scripts/query_graph.py +556 -0
- package/templates_en/.agents/skills/nexus-query/scripts/requirements.txt +6 -0
- package/templates_en/.agents/skills/output-contract/SKILL.md +37 -0
- package/templates_en/.agents/skills/runtime-inspector/SKILL.md +150 -0
- package/templates_en/.agents/skills/sequential-thinking/SKILL.md +214 -0
- package/templates_en/.agents/skills/spec-writer/SKILL.md +153 -0
- package/templates_en/.agents/skills/spec-writer/references/prd_template.md +177 -0
- package/templates_en/.agents/skills/system-architect/SKILL.md +538 -0
- package/templates_en/.agents/skills/system-architect/references/rfc_template.md +59 -0
- package/templates_en/.agents/skills/system-designer/SKILL.md +188 -0
- package/templates_en/.agents/skills/system-designer/references/system-design-detail-template.md +187 -0
- package/templates_en/.agents/skills/system-designer/references/system-design-template.md +605 -0
- package/templates_en/.agents/skills/task-planner/SKILL.md +251 -0
- package/templates_en/.agents/skills/task-planner/references/TASK_TEMPLATE_05A.md +109 -0
- package/templates_en/.agents/skills/task-planner/references/TASK_TEMPLATE_05B.md +176 -0
- package/templates_en/.agents/skills/task-reviewer/SKILL.md +422 -0
- package/templates_en/.agents/skills/tech-evaluator/SKILL.md +252 -0
- package/templates_en/.agents/skills/tech-evaluator/references/ADR_TEMPLATE.md +78 -0
- package/templates_en/.agents/workflows/blueprint.md +200 -0
- package/templates_en/.agents/workflows/challenge.md +326 -0
- package/templates_en/.agents/workflows/change.md +182 -0
- package/templates_en/.agents/workflows/craft.md +159 -0
- package/templates_en/.agents/workflows/design-system.md +202 -0
- package/templates_en/.agents/workflows/explore.md +187 -0
- package/templates_en/.agents/workflows/forge.md +651 -0
- package/templates_en/.agents/workflows/genesis.md +438 -0
- package/templates_en/.agents/workflows/probe.md +215 -0
- package/templates_en/.agents/workflows/quickstart.md +305 -0
- package/templates_en/.agents/workflows/upgrade.md +145 -0
- package/templates_en/AGENTS.md +149 -0
- package/templates/.agents/skills/report-template/SKILL.md +0 -92
- package/templates/.agents/skills/report-template/references/REPORT_TEMPLATE.md +0 -100
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: system-designer
|
|
3
|
+
description: Load when `/design-system <system-id>` needs to produce L0/L1 detailed design documents for one system. Defines boundaries, interface contracts, data models, trade-offs, Mermaid diagrams, testing strategy, and L1 split rules; paired with the same-bundle `/design-system` workflow.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# System Designer (ALPHA)
|
|
7
|
+
|
|
8
|
+
<phase_context>
|
|
9
|
+
You are **SYSTEM DESIGNER**.
|
|
10
|
+
|
|
11
|
+
**Mission**: refine one `system-id` from `02_ARCHITECTURE_OVERVIEW.md` into an implementable, reviewable system design that `/blueprint` can consume.
|
|
12
|
+
**Capabilities**: inherit PRD/ADR/Architecture constraints; consume `/explore` research; use the 6D framework to derive components, interfaces, data models, risks, and testing strategy; persist L0 and conditional L1 documents.
|
|
13
|
+
**Limits**: do not change PRD, ADR, or system-boundary premises; do not put long pseudocode, config dictionaries, or method bodies into L0; do not copy ADR content, only reference ADRs.
|
|
14
|
+
**Output Goal**: `{TARGET_DIR}/04_SYSTEM_DESIGN/{system-id}.md`, plus `{system-id}.detail.md` and `_research/{system-id}-research.md` when triggered.
|
|
15
|
+
</phase_context>
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## CRITICAL Writing And Output Contract
|
|
20
|
+
|
|
21
|
+
> [!IMPORTANT]
|
|
22
|
+
> Persisted-report rules, evidence rules, single-writer rules, and de-duplication rules follow `.agents/skills/output-contract/SKILL.md`. This skill only adds system-design-specific constraints.
|
|
23
|
+
>
|
|
24
|
+
> - **Inherit constraints**: performance, security, interface, tech-stack, and boundary constraints from PRD, ADR, and Architecture Overview may only be tightened, not weakened.
|
|
25
|
+
> - **ADR one-way references**: cross-system decisions reference `03_ADR/*`; do not duplicate ADR rationale. If an ADR is insufficient, route through `/change` or `/genesis`.
|
|
26
|
+
> - **Lightweight L0**: L0 contains architecture, contracts, field declarations, key diagrams, and trade-offs; long algorithms, large config, pseudocode, and implementation edge cases go to L1.
|
|
27
|
+
> - **Traceability**: interfaces, data models, testing strategy, and trade-offs must point to at least one `[REQ-*]`, ADR, or Architecture section.
|
|
28
|
+
> - **No empty placeholders**: unknowns use `[OPEN: concrete question + owner/next step]`; do not use `TBD`, `TODO`, or vague "improve later" text.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Design Framework: 6D
|
|
33
|
+
|
|
34
|
+
### 1. Discover
|
|
35
|
+
|
|
36
|
+
### What
|
|
37
|
+
Read `01_PRD.md`, `02_ARCHITECTURE_OVERVIEW.md`, relevant `03_ADR/*`, and any existing design draft for this system. Extract responsibility, boundaries, dependencies, linked `[REQ-*]`, and non-goals.
|
|
38
|
+
|
|
39
|
+
### Why
|
|
40
|
+
Detailed design is not a second architecture pass; it refines approved boundaries into implementable contracts.
|
|
41
|
+
|
|
42
|
+
### Acceptance
|
|
43
|
+
- One sentence can state this system's responsibility.
|
|
44
|
+
- Inputs, outputs, dependencies, linked requirements, and relevant ADRs are listed.
|
|
45
|
+
|
|
46
|
+
### 2. Deep-Dive
|
|
47
|
+
|
|
48
|
+
### What
|
|
49
|
+
Use the same-bundle `/explore` workflow to produce `_research/{system-id}-research.md`; research only the risks that affect this system.
|
|
50
|
+
|
|
51
|
+
### Why
|
|
52
|
+
Complex design needs external evidence; otherwise trade-offs become preferences.
|
|
53
|
+
|
|
54
|
+
### Acceptance
|
|
55
|
+
- Research supports at least one design decision or risk mitigation.
|
|
56
|
+
- The `_research` path exists, or `/design-system` gives a concrete non-applicability reason.
|
|
57
|
+
|
|
58
|
+
### 3. Decompose
|
|
59
|
+
|
|
60
|
+
### What
|
|
61
|
+
Derive components, modules, data flow, state flow, and external interfaces. Use `sequential-thinking` when the host rules require it.
|
|
62
|
+
|
|
63
|
+
### Why
|
|
64
|
+
Component boundaries determine testability, dependency direction, and downstream task quality.
|
|
65
|
+
|
|
66
|
+
### Acceptance
|
|
67
|
+
- Each core component has responsibility and dependencies.
|
|
68
|
+
- Mermaid architecture or data-flow diagrams match the component inventory.
|
|
69
|
+
|
|
70
|
+
### 4. Design
|
|
71
|
+
|
|
72
|
+
### What
|
|
73
|
+
Define interface contracts, data models, error semantics, configuration boundaries, state transitions, and security/performance strategy. Prefer operation contract tables for interfaces; data models include fields and relations, not method bodies.
|
|
74
|
+
|
|
75
|
+
### Why
|
|
76
|
+
`/blueprint` needs externally observable contracts, not implementation prose.
|
|
77
|
+
|
|
78
|
+
### Acceptance
|
|
79
|
+
- Core operations have contract tables or equivalent interface tables.
|
|
80
|
+
- Data fields, error semantics, and verification responsibility are traceable.
|
|
81
|
+
|
|
82
|
+
### 5. Defend
|
|
83
|
+
|
|
84
|
+
### What
|
|
85
|
+
List key trade-offs, performance bottlenecks, security boundaries, observability, and testing strategy. Public contracts require a Contract Verification Matrix.
|
|
86
|
+
|
|
87
|
+
### Why
|
|
88
|
+
The design document should expose failure modes before `/forge` has to guess them.
|
|
89
|
+
|
|
90
|
+
### Acceptance
|
|
91
|
+
- At least two important decisions explain why option A was chosen over option B.
|
|
92
|
+
- Testing strategy distinguishes unit, API/interface, integration, E2E, smoke, and regression responsibility where applicable.
|
|
93
|
+
|
|
94
|
+
### 6. Document
|
|
95
|
+
|
|
96
|
+
### What
|
|
97
|
+
Read `.agents/skills/system-designer/references/system-design-template.md` and, when needed, `system-design-detail-template.md`; persist L0/L1.
|
|
98
|
+
|
|
99
|
+
### Why
|
|
100
|
+
The template is the long-term maintenance contract used by the host and downstream workflows.
|
|
101
|
+
|
|
102
|
+
### Acceptance
|
|
103
|
+
- L0 required sections 1-11 are present; optional sections 12-14 are kept or marked `N/A` with a reason.
|
|
104
|
+
- If L1 is triggered, L0 links to `.detail.md`.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## L0 / L1 Boundaries
|
|
109
|
+
|
|
110
|
+
| Layer | File | Content | Load Frequency |
|
|
111
|
+
| --- | --- | --- | --- |
|
|
112
|
+
| L0 navigation | `{system-id}.md` | goals, boundaries, diagrams, operation contracts, field declarations, trade-offs, testing strategy | high; always loaded for task planning |
|
|
113
|
+
| L1 implementation | `{system-id}.detail.md` | long pseudocode, config constants, complex algorithms, implementation edge cases, detailed state tables | low; only when task input explicitly references it |
|
|
114
|
+
|
|
115
|
+
### L1 Split Rules R1-R5
|
|
116
|
+
|
|
117
|
+
Create `{system-id}.detail.md` if any rule is triggered:
|
|
118
|
+
|
|
119
|
+
| Rule | Trigger | Action |
|
|
120
|
+
| --- | --- | --- |
|
|
121
|
+
| R1 | one continuous code block > 30 lines | move to L1 |
|
|
122
|
+
| R2 | total code block lines > 200 | move to L1 |
|
|
123
|
+
| R3 | config constant dictionary entries > 5 | move to L1 or a config table |
|
|
124
|
+
| R4 | inline version comments > 5 | consolidate into version history |
|
|
125
|
+
| R5 | L0 total length > 500 lines | split into L1 |
|
|
126
|
+
|
|
127
|
+
### Content Placement
|
|
128
|
+
|
|
129
|
+
| Content Type | L0 | L1 |
|
|
130
|
+
| --- | --- | --- |
|
|
131
|
+
| system goal, boundary, architecture diagrams, trade-offs | yes | no |
|
|
132
|
+
| operation contracts, HTTP/CLI/cross-system protocols | yes | details only |
|
|
133
|
+
| data fields, Protocol/ABC signatures | yes | complex schema examples |
|
|
134
|
+
| function-body pseudocode and complex algorithms | no | yes |
|
|
135
|
+
| config constants and edge-case expansion | summary | yes |
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Template And Sections
|
|
140
|
+
|
|
141
|
+
Use `.agents/skills/system-designer/references/system-design-template.md`.
|
|
142
|
+
|
|
143
|
+
**Required L0 sections 1-11**:
|
|
144
|
+
|
|
145
|
+
1. Overview
|
|
146
|
+
2. Goals & Non-Goals
|
|
147
|
+
3. Background & Context
|
|
148
|
+
4. Architecture
|
|
149
|
+
5. Interface Design
|
|
150
|
+
6. Data Model
|
|
151
|
+
7. Technology Stack
|
|
152
|
+
8. Trade-offs & Alternatives
|
|
153
|
+
9. Security Considerations
|
|
154
|
+
10. Performance Considerations
|
|
155
|
+
11. Testing Strategy
|
|
156
|
+
|
|
157
|
+
**Optional sections 12-14**: Deployment & Operations, Future Considerations, Appendix. Optional does not mean arbitrary deletion; use `N/A + reason` when not applicable.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Design Rules
|
|
162
|
+
|
|
163
|
+
- **Research first**: obtain research evidence before design, or record why research is not applicable.
|
|
164
|
+
- **Mermaid first**: architecture, data flow, state machines, and decision trees prefer Mermaid; long pseudocode goes to L1.
|
|
165
|
+
- **Operation contracts first**: Agent, game-core, messaging, CLI/API, and other public behaviors use operation contract tables.
|
|
166
|
+
- **Do not weaken constraints**: inherit PRD/ADR performance, security, compliance, tech-stack, and error semantics.
|
|
167
|
+
- **Trade-offs are reviewable**: important decisions require alternatives and consequences.
|
|
168
|
+
- **Public contracts are verifiable**: public interfaces, config, error semantics, and persistence structures need testing responsibility.
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Handoff Checklist
|
|
173
|
+
|
|
174
|
+
- [ ] `01`, `02`, relevant `03_ADR/*`, `_research`, and templates have been read.
|
|
175
|
+
- [ ] L0 exists and required sections 1-11 are complete.
|
|
176
|
+
- [ ] L1 trigger rules were evaluated; if triggered, `.detail.md` exists and L0 links to it.
|
|
177
|
+
- [ ] Interface contracts, data model, ADR references, and testing strategy do not contradict each other.
|
|
178
|
+
- [ ] No legacy `.agent/` paths, emoji, or empty `TODO/TBD` placeholders remain.
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
<completion_criteria>
|
|
183
|
+
- `system_id` and `TARGET_DIR` were confirmed by the `/design-system` host.
|
|
184
|
+
- Output follows `.agents/skills/output-contract/SKILL.md` for persistence and collaboration closure.
|
|
185
|
+
- L0/L1 boundaries, R1-R5, required sections 1-11, and optional sections 12-14 are unambiguous.
|
|
186
|
+
- Every public contract has a source anchor and verification responsibility.
|
|
187
|
+
- This skill serves `/design-system` only and does not modify PRD, ADR, Architecture, or 05A/05B.
|
|
188
|
+
</completion_criteria>
|
package/templates_en/.agents/skills/system-designer/references/system-design-detail-template.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# {System Name} — Implementation Details (L1)
|
|
2
|
+
|
|
3
|
+
> **File Type**: L1 implementation layer · **Mapped L0**: [`{system-id}.md`](./{system-id}.md)
|
|
4
|
+
> This file is loaded only when explicitly referenced by a `/forge` task. For daily reading and task planning, prioritize L0.
|
|
5
|
+
> ** Island Check**: Every section in this file must have a corresponding hyperlink entry in L0; isolated content is forbidden.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Version History
|
|
10
|
+
|
|
11
|
+
> All change records are centralized here and should no longer be scattered in code comments.
|
|
12
|
+
|
|
13
|
+
| Version | Date | Changelog |
|
|
14
|
+
| ---- | ------------ | --------- |
|
|
15
|
+
| v1.0 | {YYYY-MM-DD} | Initial version |
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Section Index of This File
|
|
20
|
+
|
|
21
|
+
| § | Section | Mapped L0 Entry |
|
|
22
|
+
| :---: | -------------------------------------------------------------------- | :--------------: |
|
|
23
|
+
| §1 | [Config Constants](#1-config-constants) | L0 §6 Data Model |
|
|
24
|
+
| §2 | [Full Core Data Structures](#2-full-core-data-structures) | L0 §6 Data Model |
|
|
25
|
+
| §3 | [Core Algorithm Pseudocode](#3-core-algorithm-pseudocode-non-trivial-algorithm-pseudocode) | L0 §5 Operation Contracts |
|
|
26
|
+
| §4 | [Detailed Decision Tree Logic](#4-detailed-decision-tree-logic-decision-tree-details) | L0 §4 Architecture Diagram |
|
|
27
|
+
| §5 | [Edge Cases & Gotchas](#5-edge-cases--gotchas-edge-cases--gotchas) | L0 §5 / §9 |
|
|
28
|
+
| §6 | [Test Helpers](#6-test-helpers-test-helpers) *(Optional)* | L0 §11 Testing Strategy |
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## §1 Config Constants
|
|
33
|
+
|
|
34
|
+
> Centralize all hardcoded configs, enum mappings, and lookup tables here.
|
|
35
|
+
> **Mapped L0 Entry**: anchor at end of L0 §6 → *For full config constant dictionaries, see [L1 §1]*
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
# -- Example: unit config table --
|
|
39
|
+
UNIT_CONFIG = {
|
|
40
|
+
# UnitType.WARRIOR: {atk, def, hp, mov, range, cost, tech, behavior, move_type}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
# -- Example: terrain config table --
|
|
44
|
+
TERRAIN_CONFIG = {
|
|
45
|
+
# TerrainType.PLAIN: {move_cost: 1, passable: "land", buildings: [...]}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
# -- Example: building config table --
|
|
49
|
+
BUILDING_CONFIG = {
|
|
50
|
+
# BuildingType.FARM: {cost: 5, tech: "farming", rp_bonus: 1}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## §2 Full Core Data Structures
|
|
57
|
+
|
|
58
|
+
> Contains full class definitions including method bodies. L0 should only include field declarations and method signatures (`def foo(): ...`).
|
|
59
|
+
> **Mapped L0 Entry**: anchor at end of L0 §6.1 → *For full method implementations, see [L1 §2]*
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
@dataclass
|
|
63
|
+
class ExampleEntity:
|
|
64
|
+
id: str
|
|
65
|
+
# ... fields
|
|
66
|
+
|
|
67
|
+
def some_method(self) -> bool:
|
|
68
|
+
"""Method notes"""
|
|
69
|
+
# Full implementation logic
|
|
70
|
+
pass
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## §3 Core Algorithm Pseudocode (Non-Trivial Algorithm Pseudocode)
|
|
76
|
+
|
|
77
|
+
> [!IMPORTANT]
|
|
78
|
+
> **Entry threshold — if none of the following is met, writing this section is forbidden**
|
|
79
|
+
>
|
|
80
|
+
> | Entry Condition | Notes |
|
|
81
|
+
> |---------|------|
|
|
82
|
+
> | Estimated function body **> 15 lines** | Short functions are already understandable from L0 operation contracts |
|
|
83
|
+
> | Includes **non-obvious business rules** | Damage formulas, state machine branches, complex validation |
|
|
84
|
+
> | Includes **multi-step side-effect chains** | A→check→B→update C→trigger D, order must not be changed |
|
|
85
|
+
> | **Teammates cannot infer implementation from signature** | If function name + params already clearly express intent, no need |
|
|
86
|
+
|
|
87
|
+
Each subsection maps to one row in the L0 §5 operation contracts table and provides a full function body.
|
|
88
|
+
|
|
89
|
+
### §3.1 {Operation Name}
|
|
90
|
+
|
|
91
|
+
**Mapped Contract**: L0 §5.1 — `{function_name}()`
|
|
92
|
+
**Entry Reason**: {which entry condition is met}
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
def function_name(param1: Type, param2: Type) -> ReturnType:
|
|
96
|
+
"""
|
|
97
|
+
Function description.
|
|
98
|
+
|
|
99
|
+
Preconditions:
|
|
100
|
+
1. ...
|
|
101
|
+
|
|
102
|
+
Side effects:
|
|
103
|
+
- ...
|
|
104
|
+
"""
|
|
105
|
+
# Full implementation logic
|
|
106
|
+
pass
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
> **Notes**: {critical traps like deep copy / race conditions / order dependencies}
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## §4 Detailed Decision Tree Logic (Decision Tree Details)
|
|
114
|
+
|
|
115
|
+
> Text expansion + complete pseudocode corresponding to the L0 Mermaid decision diagram.
|
|
116
|
+
> **Mapped L0 Entry**: comment under L0 §4 Architecture Diagram → *For full decision logic, see [L1 §4]*
|
|
117
|
+
|
|
118
|
+
### §4.1 {Decision Scenario Name}
|
|
119
|
+
|
|
120
|
+
**Mapped L0 Mermaid**: `{system-id}.md §{section}`
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
def plan_or_decide(...):
|
|
124
|
+
# Step 1: check high-priority conditions
|
|
125
|
+
# Step 2: branching logic
|
|
126
|
+
pass
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## §5 Edge Cases & Gotchas
|
|
132
|
+
|
|
133
|
+
> Non-obvious cases that must be handled during implementation.
|
|
134
|
+
> **Mapped L0 Entry**: anchor in L0 §5 or §9 Security
|
|
135
|
+
|
|
136
|
+
| Scenario | Risk | Handling |
|
|
137
|
+
| -------------- | ---------- | -------------- |
|
|
138
|
+
| {Edge case description} | {Potential bug} | {Correct handling} |
|
|
139
|
+
|
|
140
|
+
### §5.1 {Specific Case}
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
# Incorrect approach
|
|
144
|
+
# cloned_unit.embarked_unit = unit.embarked_unit # shallow copy -> state contamination!
|
|
145
|
+
|
|
146
|
+
# Correct approach
|
|
147
|
+
# cloned_unit.embarked_unit = deepcopy(unit.embarked_unit) if unit.embarked_unit else None
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## §6 Test Helpers
|
|
153
|
+
|
|
154
|
+
> Optional. Factory functions or fixtures reused in unit tests.
|
|
155
|
+
> **Mapped L0 Entry**: anchor in L0 §11 Testing Strategy
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
def make_test_unit(type=UnitType.WARRIOR, hp=10, pos=(0, 0)) -> Unit:
|
|
159
|
+
"""Create a test Unit"""
|
|
160
|
+
pass
|
|
161
|
+
|
|
162
|
+
def make_test_world(size=8) -> World:
|
|
163
|
+
"""Create a test World"""
|
|
164
|
+
pass
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
<!-- AGENT Usage Guide
|
|
170
|
+
|
|
171
|
+
When to create this file: when any L0 split rule R1-R5 is triggered.
|
|
172
|
+
R1 single code block > 30 lines
|
|
173
|
+
R2 total code block lines > 200 lines
|
|
174
|
+
R3 config constant dictionary entries > 5
|
|
175
|
+
R4 version inline comments > 5 occurrences
|
|
176
|
+
R5 total document lines > 500
|
|
177
|
+
|
|
178
|
+
Island check: every new section added here must also add a hyperlink anchor at corresponding position in L0.
|
|
179
|
+
|
|
180
|
+
§ numbering convention:
|
|
181
|
+
§1 config constants — always first section
|
|
182
|
+
§2 data structures — full classes with method bodies
|
|
183
|
+
§3 algorithm pseudocode — numbered by function order (§3.1, §3.2 ...)
|
|
184
|
+
§4 decision tree — expansion of L0 Mermaid diagrams
|
|
185
|
+
§5 edge cases — extracted from "# note" style code comments
|
|
186
|
+
§6 test helpers — optional
|
|
187
|
+
-->
|