@haaaiawd/anws 1.2.0 → 1.2.2
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 +217 -48
- package/lib/init.js +1 -1
- package/package.json +13 -7
- package/templates/.agent/skills/git-forensics/scripts/__pycache__/git_forensics.cpython-313.pyc +0 -0
- package/templates/.agent/skills/system-designer/references/system-design-detail-template.md +66 -77
- package/templates/.agent/skills/system-designer/references/system-design-template.md +65 -45
- package/templates/.agent/workflows/craft.md +104 -63
- package/templates/.agent/workflows/design-system.md +1 -0
- package/templates/.agent/workflows/quickstart.md +47 -212
package/README.md
CHANGED
|
@@ -1,96 +1,265 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<img src="assets/logo.png" width="200" alt="Antigravity Workflow System">
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://github.com/google-deepmind/antigravity)
|
|
7
|
+
[](https://github.com/karpathy/vibe-coding)
|
|
8
|
+
|
|
9
|
+
[English](./README.md) | [中文](./README_CN.md)
|
|
10
|
+
|
|
11
|
+
</div>
|
|
9
12
|
|
|
10
13
|
---
|
|
11
14
|
|
|
12
|
-
##
|
|
15
|
+
## ⚡ What is this?
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
npm install -g @haaaiawd/anws
|
|
16
|
-
```
|
|
17
|
+
A **structured workflow framework** for Agentic AI assistants, designed to solve the core pain points of the Vibe Coding era.
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
> 💡 **TL;DR**: Stop letting AI write spaghetti code. Force it to think like an architect first.
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
### 🎯 Problems We Solve
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
| Pain Point | The Problem | Our Solution |
|
|
24
|
+
| ---------------------- | ----------------------------------------------------------- | -------------------------------------------------------------- |
|
|
25
|
+
| **Architecture Drift** | AI generates inconsistent patterns across the same codebase | `/genesis` forces PRD & architecture design first |
|
|
26
|
+
| **Spaghetti Code** | AI lacks project context, writes code that doesn't fit | Tasks include constraints & acceptance criteria |
|
|
27
|
+
| **Context Amnesia** | New session = AI forgets all previous decisions | `.agent/rules/agents.md` + versioned docs as persistent memory |
|
|
28
|
+
| **Lack of Planning** | Vibe Coding skips design, creates tech debt | Mandatory design-first workflow |
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 🚀 Quick Start
|
|
25
33
|
|
|
26
|
-
|
|
34
|
+
### Option A — npm CLI (Recommended)
|
|
27
35
|
|
|
28
36
|
```bash
|
|
29
|
-
|
|
37
|
+
npm install -g @haaaiawd/anws
|
|
38
|
+
cd your-project
|
|
30
39
|
anws init
|
|
31
40
|
```
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
- **检测到冲突**:显示已存在的托管文件数量,询问是否覆盖(默认 **N**)。
|
|
35
|
-
确认后只会覆盖 `anws` 管理的文件,你的自定义文件不受影响。
|
|
36
|
-
- **非 TTY 环境(如 CI)**:检测到冲突时自动跳过,不挂起进程。
|
|
42
|
+
> Requires Node.js ≥ 18.
|
|
37
43
|
|
|
38
|
-
###
|
|
44
|
+
### Option B — GitHub Release
|
|
39
45
|
|
|
40
|
-
|
|
46
|
+
Download the latest `.zip` from [Releases](https://github.com/Haaaiawd/Antigravity-Workflow-System/releases), then copy `.agent/` to your project root.
|
|
47
|
+
|
|
48
|
+
### 📦 Update Existing Installation
|
|
41
49
|
|
|
42
50
|
```bash
|
|
51
|
+
cd your-project
|
|
43
52
|
anws update
|
|
44
53
|
```
|
|
45
54
|
|
|
46
|
-
|
|
47
|
-
|
|
55
|
+
> `anws update` overwrites all managed workflow/skill files to the latest version while **preserving** your `agents.md`.
|
|
56
|
+
> If the `agents.md` template has new content, an `agents.md.new` file will be generated for you to merge manually.
|
|
48
57
|
|
|
49
|
-
###
|
|
58
|
+
### Your First Project 🐣
|
|
50
59
|
|
|
51
|
-
|
|
52
|
-
|------|------|
|
|
53
|
-
| `-v`, `--version` | 打印版本号 |
|
|
54
|
-
| `-h`, `--help` | 显示帮助信息 |
|
|
60
|
+
> **The easiest way to start**: Just run the `/quickstart` command! The AI will automatically analyze your project state and guide you step-by-step through the entire lifecycle (from `/genesis` to `/forge`).
|
|
55
61
|
|
|
56
|
-
|
|
62
|
+
**Looking for inspiration? Alternative prompt**: "I want to build a web-based macOS simulator, including Dock, top bar, and several system apps. Please start this new project from scratch according to the development process."
|
|
57
63
|
|
|
58
|
-
|
|
64
|
+
### 🔁 Built with Itself (Dogfooding)
|
|
59
65
|
|
|
60
|
-
|
|
66
|
+
Fun fact: **This very CLI tool (`anws`) was built using its own workflows!**
|
|
67
|
+
We used the `/genesis` workflow to design the CLI's architecture, and the `/forge` workflow to implement the code. This project serves as a live demonstration of what Antigravity Workflow System can achieve.
|
|
61
68
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
**Deep Thinking & Architecture Design**: The AI will automatically execute the `/genesis` workflow, thinking deeply about project requirements and producing the PRD and architecture design.
|
|
70
|
+
<img src="assets/genesis工作流演示.jpg" width="800" alt="Genesis Workflow">
|
|
71
|
+
|
|
72
|
+
**Interactive Requirement Alignment**: The AI will ask follow-up questions for ambiguous requirements to ensure the design matches your intuition.
|
|
73
|
+
<img src="assets/与人类交互确认细节.jpg" width="800" alt="Human Interaction">
|
|
74
|
+
|
|
75
|
+
**Autonomous Task Breakdown & Execution**: The AI will autonomously call necessary Skills (e.g., `spec-writer`, `task-planner`, etc.) to complete documentation and task decomposition.
|
|
76
|
+
<img src="assets/自主调用skills.jpg" width="800" alt="Skills Execution">
|
|
77
|
+
|
|
78
|
+
---
|
|
65
79
|
|
|
66
|
-
|
|
67
|
-
|
|
80
|
+
## 🗺️ Decision Flowchart
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
┌─────────────────┐
|
|
84
|
+
│ Where are you? │
|
|
85
|
+
└────────┬────────┘
|
|
86
|
+
┌─────────────────┼─────────────────┐
|
|
87
|
+
▼ ▼ ▼
|
|
88
|
+
┌──────────┐ ┌──────────┐ ┌──────────┐
|
|
89
|
+
│ New │ │ Legacy │ │ Existing │
|
|
90
|
+
│ Project │ │ Takeover │ │ Change │
|
|
91
|
+
└────┬─────┘ └────┬─────┘ └────┬─────┘
|
|
92
|
+
│ │ │
|
|
93
|
+
▼ ▼ ▼
|
|
94
|
+
/genesis /scout Tweak existing task?
|
|
95
|
+
│ │ / \
|
|
96
|
+
│ │ / \
|
|
97
|
+
└────────┬────────┘ /change /genesis
|
|
98
|
+
│ (modify only) (new tasks)
|
|
99
|
+
▼ │ │
|
|
100
|
+
/design-system <--------+------------+
|
|
101
|
+
(optional, recommended)
|
|
102
|
+
|
|
|
103
|
+
v
|
|
104
|
+
/challenge
|
|
105
|
+
(design review)
|
|
106
|
+
|
|
|
107
|
+
v
|
|
108
|
+
/blueprint
|
|
109
|
+
|
|
|
110
|
+
v
|
|
111
|
+
/challenge
|
|
112
|
+
(task review)
|
|
113
|
+
|
|
|
114
|
+
v
|
|
115
|
+
/forge
|
|
116
|
+
(code delivery)
|
|
68
117
|
```
|
|
69
118
|
|
|
70
119
|
---
|
|
71
120
|
|
|
72
|
-
##
|
|
121
|
+
## 🔑 Core Principles
|
|
122
|
+
|
|
123
|
+
### 1. Versioned Architecture
|
|
124
|
+
> Don't "fix" architecture docs. **Evolve** them.
|
|
125
|
+
|
|
126
|
+
- `genesis/v1` → `genesis/v2` on major changes
|
|
127
|
+
- Full traceability of decisions
|
|
128
|
+
- No "it was always like this" mystery
|
|
129
|
+
|
|
130
|
+
### 2. Deep Thinking First
|
|
131
|
+
> AI must think before it writes.
|
|
132
|
+
|
|
133
|
+
- Workflows force multi-step reasoning via `sequentialthinking`
|
|
134
|
+
- `[!IMPORTANT]` blocks as guardrails
|
|
135
|
+
- No shallow, scan-and-output responses
|
|
136
|
+
|
|
137
|
+
### 3. Filesystem as Memory
|
|
138
|
+
> Chat is ephemeral. Files are eternal.
|
|
139
|
+
|
|
140
|
+
- `AGENTS.md` = AI's anchor
|
|
141
|
+
- Architecture docs = persistent decisions
|
|
142
|
+
- New session recovery in 30 seconds
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 📋 Workflows
|
|
147
|
+
|
|
148
|
+
| Command | Purpose | Input | Output |
|
|
149
|
+
| ----------------- | ------------------------------------------------------- | ----------------- | ------------------------------------------ |
|
|
150
|
+
| **`/quickstart`** | **One-command entry: orchestrates the whole lifecycle** | Auto-detected | Full pipeline orchestration |
|
|
151
|
+
| `/genesis` | Start from zero, create PRD & architecture | Vague idea | PRD, Architecture, ADRs |
|
|
152
|
+
| `/scout` | Analyze legacy codebase risks | Existing code | Risk report, Gap analysis |
|
|
153
|
+
| `/design-system` | Detailed design for a system | Architecture | System Design doc |
|
|
154
|
+
| `/challenge` | Review Design & Tasks (intelligent detection) | Full Docs / TASKS | Challenge Report (Graded) |
|
|
155
|
+
| `/blueprint` | Break architecture into tasks | PRD + Arch | TASKS.md (WBS) |
|
|
156
|
+
| `/forge` | Execute tasks — architecture to code | TASKS.md | Working code, verified |
|
|
157
|
+
| `/change` | Tweak existing tasks (no new tasks) | Minor tweak | Updated TASKS + Design files (modify only) |
|
|
158
|
+
| `/explore` | Deep research & brainstorm | Topic/Question | Exploration report |
|
|
159
|
+
| `/craft` | Create workflows/skills/prompts | Creation request | Workflow / Skill / Prompt docs |
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## 🛠️ Compatibility & Prerequisites
|
|
164
|
+
|
|
165
|
+
> ⚠️ **Important**: This framework requires **Antigravity** environment with `.agent/workflows/` support.
|
|
166
|
+
|
|
167
|
+
| Environment | Status | Notes |
|
|
168
|
+
| --------------- | :--------------------------: | ------------------------------ |
|
|
169
|
+
| **Antigravity** | ✅ Supported | Full workflow + skills support |
|
|
170
|
+
| Claude Code | ❌ No native workflow support | |
|
|
171
|
+
| Cursor | ❌ No workflow support | |
|
|
172
|
+
| GitHub Copilot | ❌ No workflow support | |
|
|
173
|
+
|
|
174
|
+
**What is Antigravity?**
|
|
175
|
+
|
|
176
|
+
Antigravity is an Agentic AI coding environment that natively recognizes `.agent/workflows/` directory and can execute slash commands like `/genesis`, `/blueprint`, etc.
|
|
177
|
+
|
|
178
|
+
### 🔌 Required: Sequential Thinking MCP Server
|
|
179
|
+
|
|
180
|
+
This framework uses `sequentialthinking` for deep reasoning. Install it via MCP Store:
|
|
181
|
+
|
|
182
|
+
1. Open **Antigravity Editor**
|
|
183
|
+
2. Click **"..."** (three dots) in the sidebar → **Additional Options**
|
|
184
|
+
3. Select **MCP Servers**
|
|
185
|
+
4. Open **MCP Store** and search for `sequential-thinking`
|
|
186
|
+
5. Click **Add** to install
|
|
187
|
+
|
|
188
|
+
> 💡 Without this, workflows still work, but deep thinking features will be limited.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## ⚡ Invoke Workflows
|
|
193
|
+
|
|
194
|
+
Antigravity will automatically recognize the intent and trigger the appropriate workflow. You can use it in two ways:
|
|
73
195
|
|
|
74
|
-
|
|
75
|
-
|
|
196
|
+
#### ⚡ Method A: Slash Protocol (Explicit)
|
|
197
|
+
Directly type the command in the chat or editor to trigger the workflow.
|
|
198
|
+
- `/genesis` - Start project creation
|
|
199
|
+
- `/scout` - Analyze existing codebase
|
|
200
|
+
- `/blueprint` - Break down architecture into tasks
|
|
201
|
+
|
|
202
|
+
#### 🧠 Method B: Intent Protocol (Implicit)
|
|
203
|
+
Just speak naturally. Antigravity will automatically select and run the right workflow.
|
|
204
|
+
- *"I want to start a new project for a todo app"* → Triggers `/genesis`
|
|
205
|
+
- *"Help me understand this legacy code and its risks"* → Triggers `/scout`
|
|
206
|
+
- *"I think there are gaps in this design, challenge it"* → Triggers `/challenge`
|
|
207
|
+
- *"The architecture is ready, let's plan the tasks"* → Triggers `/blueprint`
|
|
208
|
+
- *"Change the error message on the login page"* → Triggers `/change` (tweak existing task)
|
|
209
|
+
- *"I need to add a back-to-top button"* → Triggers `/genesis` (requires new task)
|
|
76
210
|
|
|
77
211
|
---
|
|
78
212
|
|
|
79
|
-
##
|
|
213
|
+
## 📁 Project Structure
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
your-project/
|
|
217
|
+
├── .agent/
|
|
218
|
+
│ ├── rules/
|
|
219
|
+
│ │ └── agents.md # 🧠 AI's anchor point
|
|
220
|
+
│ ├── workflows/ # Workflow definitions
|
|
221
|
+
│ │ ├── genesis.md
|
|
222
|
+
│ │ ├── scout.md
|
|
223
|
+
│ │ ├── design-system.md
|
|
224
|
+
│ │ ├── challenge.md
|
|
225
|
+
│ │ ├── blueprint.md
|
|
226
|
+
│ │ ├── forge.md
|
|
227
|
+
│ │ ├── change.md
|
|
228
|
+
│ │ ├── explore.md
|
|
229
|
+
│ │ └── craft.md
|
|
230
|
+
│ │
|
|
231
|
+
│ └── skills/ # Reusable skills
|
|
232
|
+
│ ├── concept-modeler/
|
|
233
|
+
│ ├── spec-writer/
|
|
234
|
+
│ ├── task-planner/
|
|
235
|
+
│ └── ...
|
|
236
|
+
│
|
|
237
|
+
└── genesis/ # Versioned architecture docs
|
|
238
|
+
├── v1/
|
|
239
|
+
│ ├── 01_PRD.md
|
|
240
|
+
│ ├── 02_ARCHITECTURE.md
|
|
241
|
+
│ ├── 03_ADR/
|
|
242
|
+
│ ├── 05_TASKS.md
|
|
243
|
+
│ └── 07_CHALLENGE_REPORT.md
|
|
244
|
+
└── v2/ # New version on major changes
|
|
245
|
+
```
|
|
80
246
|
|
|
81
|
-
|
|
247
|
+
## 🙌 Contributing
|
|
82
248
|
|
|
83
|
-
|
|
249
|
+
Contributions are welcome! Please read our contributing guidelines before submitting PRs.
|
|
84
250
|
|
|
85
251
|
---
|
|
86
252
|
|
|
87
|
-
##
|
|
253
|
+
## 📜 License
|
|
88
254
|
|
|
89
|
-
|
|
90
|
-
- 无运行时依赖
|
|
255
|
+
[MIT](LICENSE) © 2026
|
|
91
256
|
|
|
92
257
|
---
|
|
93
258
|
|
|
94
|
-
|
|
259
|
+
<div align="center">
|
|
260
|
+
|
|
261
|
+
**Made for architects who code, and AIs who think.**
|
|
262
|
+
|
|
263
|
+
🧠 *"Good architecture isn't written. It's designed."*
|
|
95
264
|
|
|
96
|
-
|
|
265
|
+
</div>
|
package/lib/init.js
CHANGED
|
@@ -161,7 +161,7 @@ function printNextSteps() {
|
|
|
161
161
|
blank();
|
|
162
162
|
info('Next steps:');
|
|
163
163
|
info(' 1. Read .agent/rules/agents.md to understand the system');
|
|
164
|
-
info(' 2. Run /
|
|
164
|
+
info(' 2. Run /quickstart in your AI assistant to analyze and start the workflow');
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
/**
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haaaiawd/anws",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.2.2",
|
|
4
|
+
"description": "A spec-driven workflow framework for AI-assisted development. Empowers prompt engineers to build production-ready software through structured PRD → Architecture → Task decomposition. Designed for Antigravity to enforce design-first principles and prevent architectural drift in vibe coding.",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
6
|
+
"antigravity",
|
|
7
|
+
"agentic-ai",
|
|
8
|
+
"workflow-orchestration",
|
|
9
|
+
"spec-driven",
|
|
10
|
+
"system-architecture",
|
|
11
|
+
"vibe-coding",
|
|
12
|
+
"prompt-engineering",
|
|
13
|
+
"devops-for-ai",
|
|
14
|
+
"skills-framework"
|
|
11
15
|
],
|
|
12
16
|
"homepage": "https://github.com/Haaaiawd/Antigravity-Workflow-System",
|
|
13
17
|
"repository": {
|
|
@@ -30,6 +34,8 @@
|
|
|
30
34
|
],
|
|
31
35
|
"main": "./lib/index.js",
|
|
32
36
|
"scripts": {
|
|
37
|
+
"sync": "node scripts/sync-assets.js",
|
|
38
|
+
"prepublishOnly": "npm run sync",
|
|
33
39
|
"test": "node --test test/**/*.test.js"
|
|
34
40
|
},
|
|
35
41
|
"dependencies": {}
|
package/templates/.agent/skills/git-forensics/scripts/__pycache__/git_forensics.cpython-313.pyc
ADDED
|
Binary file
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
# {System Name} — 实现细节 (
|
|
1
|
+
# {System Name} — 实现细节 (L1)
|
|
2
2
|
|
|
3
|
-
> **文件性质**: L1 实现层
|
|
4
|
-
>
|
|
5
|
-
>
|
|
6
|
-
> 日常阅读、系统概览、任务规划请优先阅读 L0 层文件。
|
|
3
|
+
> **文件性质**: L1 实现层 · **对应 L0**: [`{system-id}.md`](./{system-id}.md)
|
|
4
|
+
> 本文件仅在 `/forge` 任务明确引用时加载。日常阅读和任务规划请优先看 L0。
|
|
5
|
+
> **⚠️ 孤岛检查**: 本文件各节均须在 L0 有对应超链接入口,禁止孤岛内容。
|
|
7
6
|
|
|
8
7
|
---
|
|
9
8
|
|
|
10
9
|
## 版本历史
|
|
11
10
|
|
|
12
|
-
>
|
|
11
|
+
> 所有变更记录集中于此,不再散落在代码注释里。
|
|
13
12
|
|
|
14
13
|
| 版本 | 日期 | Changelog |
|
|
15
14
|
| ---- | ------------ | --------- |
|
|
@@ -17,28 +16,38 @@
|
|
|
17
16
|
|
|
18
17
|
---
|
|
19
18
|
|
|
19
|
+
## 本文件章节索引
|
|
20
|
+
|
|
21
|
+
| § | 章节 | 对应 L0 入口 |
|
|
22
|
+
| :---: | -------------------------------------------------------------------- | :--------------: |
|
|
23
|
+
| §1 | [配置常量](#1-配置常量-config-constants) | L0 §6 数据模型 |
|
|
24
|
+
| §2 | [完整数据结构](#2-核心数据结构完整定义-full-data-structures) | L0 §6 数据模型 |
|
|
25
|
+
| §3 | [核心算法伪代码](#3-核心算法伪代码-non-trivial-algorithm-pseudocode) | L0 §5 操作契约表 |
|
|
26
|
+
| §4 | [决策树详细逻辑](#4-决策树详细逻辑-decision-tree-details) | L0 §4 架构图 |
|
|
27
|
+
| §5 | [边缘情况与注意事项](#5-边缘情况与注意事项-edge-cases--gotchas) | L0 §5 / §9 |
|
|
28
|
+
| §6 | [测试辅助](#6-测试辅助-test-helpers) *(可选)* | L0 §11 测试策略 |
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
20
32
|
## §1 配置常量 (Config Constants)
|
|
21
33
|
|
|
22
34
|
> 所有硬编码配置、枚举映射、查找表集中放在此处。
|
|
35
|
+
> **L0 对应入口**: L0 §6 末尾锚点 → *配置常量字典详见 [L1 §1]*
|
|
23
36
|
|
|
24
37
|
```python
|
|
25
38
|
# ── 示例: 单位配置表 ──
|
|
26
|
-
# 每行格式: UnitType: {atk, def, hp, mov, range, cost, tech, behavior, move_type}
|
|
27
39
|
UNIT_CONFIG = {
|
|
28
|
-
# UnitType.WARRIOR: {
|
|
29
|
-
# ...
|
|
40
|
+
# UnitType.WARRIOR: {atk, def, hp, mov, range, cost, tech, behavior, move_type}
|
|
30
41
|
}
|
|
31
42
|
|
|
32
43
|
# ── 示例: 地形配置表 ──
|
|
33
44
|
TERRAIN_CONFIG = {
|
|
34
45
|
# TerrainType.PLAIN: {move_cost: 1, passable: "land", buildings: [...]}
|
|
35
|
-
# ...
|
|
36
46
|
}
|
|
37
47
|
|
|
38
48
|
# ── 示例: 建筑配置表 ──
|
|
39
49
|
BUILDING_CONFIG = {
|
|
40
50
|
# BuildingType.FARM: {cost: 5, tech: "farming", rp_bonus: 1}
|
|
41
|
-
# ...
|
|
42
51
|
}
|
|
43
52
|
```
|
|
44
53
|
|
|
@@ -46,11 +55,10 @@ BUILDING_CONFIG = {
|
|
|
46
55
|
|
|
47
56
|
## §2 核心数据结构完整定义 (Full Data Structures)
|
|
48
57
|
|
|
49
|
-
>
|
|
58
|
+
> 含方法体的完整类定义。L0 层只放属性声明和方法签名(`def foo(): ...`)。
|
|
59
|
+
> **L0 对应入口**: L0 §6.1 末尾锚点 → *完整方法实现详见 [L1 §2]*
|
|
50
60
|
|
|
51
61
|
```python
|
|
52
|
-
# ── 示例: 完整类定义(含方法) ──
|
|
53
|
-
|
|
54
62
|
@dataclass
|
|
55
63
|
class ExampleEntity:
|
|
56
64
|
id: str
|
|
@@ -58,7 +66,7 @@ class ExampleEntity:
|
|
|
58
66
|
|
|
59
67
|
def some_method(self) -> bool:
|
|
60
68
|
"""方法说明"""
|
|
61
|
-
#
|
|
69
|
+
# 完整实现逻辑
|
|
62
70
|
pass
|
|
63
71
|
```
|
|
64
72
|
|
|
@@ -67,42 +75,30 @@ class ExampleEntity:
|
|
|
67
75
|
## §3 核心算法伪代码 (Non-Trivial Algorithm Pseudocode)
|
|
68
76
|
|
|
69
77
|
> [!IMPORTANT]
|
|
70
|
-
>
|
|
78
|
+
> **准入门槛 — 不满足任意一条,禁止写入本节**
|
|
71
79
|
>
|
|
72
80
|
> | 准入条件 | 说明 |
|
|
73
81
|
> |---------|------|
|
|
74
|
-
> | 函数体估计 **> 15 行** |
|
|
75
|
-
> | 含**不明显的业务规则** |
|
|
76
|
-
> | 含**多步骤副作用链** |
|
|
77
|
-
> | **同事看签名猜不出实现** |
|
|
78
|
-
>
|
|
79
|
-
> **反例(禁止写入 §3)**:
|
|
80
|
-
> ```python
|
|
81
|
-
> # ❌ 太简单,不需要伪代码
|
|
82
|
-
> def get_nation_stars(nation: Nation) -> int:
|
|
83
|
-
> return nation.stars
|
|
84
|
-
>
|
|
85
|
-
> # ❌ 5行setter,从签名已可理解
|
|
86
|
-
> def set_military_target(self, target: str) -> None:
|
|
87
|
-
> self.military_target = target
|
|
88
|
-
> self.last_updated_turn = world.turn
|
|
89
|
-
> ```
|
|
82
|
+
> | 函数体估计 **> 15 行** | 短函数从 L0 操作契约表已可理解 |
|
|
83
|
+
> | 含**不明显的业务规则** | 伤害公式、状态机分支、复杂校验 |
|
|
84
|
+
> | 含**多步骤副作用链** | A→检查→B→更新C→触发D,顺序不可颠倒 |
|
|
85
|
+
> | **同事看签名猜不出实现** | 函数名+参数已能清楚表达意图则不需要 |
|
|
90
86
|
|
|
91
|
-
每个小节对应 L0
|
|
87
|
+
每个小节对应 L0 §5 操作契约表的一行,提供完整函数体。
|
|
92
88
|
|
|
93
89
|
### §3.1 {操作名称}
|
|
94
90
|
|
|
95
|
-
**对应契约**: L0 §
|
|
96
|
-
**准入理由**: {
|
|
91
|
+
**对应契约**: L0 §5.1 — `{function_name}()`
|
|
92
|
+
**准入理由**: {满足了哪条准入条件}
|
|
97
93
|
|
|
98
94
|
```python
|
|
99
|
-
def function_name(param1: Type, param2: Type
|
|
95
|
+
def function_name(param1: Type, param2: Type) -> ReturnType:
|
|
100
96
|
"""
|
|
101
97
|
函数说明。
|
|
102
|
-
|
|
98
|
+
|
|
103
99
|
前置条件:
|
|
104
100
|
1. ...
|
|
105
|
-
|
|
101
|
+
|
|
106
102
|
副作用:
|
|
107
103
|
- ...
|
|
108
104
|
"""
|
|
@@ -110,37 +106,23 @@ def function_name(param1: Type, param2: Type, ...) -> ReturnType:
|
|
|
110
106
|
pass
|
|
111
107
|
```
|
|
112
108
|
|
|
113
|
-
|
|
114
|
-
- 注意点1 (如: 深拷贝、竞争条件、顺序依赖等)
|
|
115
|
-
|
|
116
|
-
---
|
|
117
|
-
|
|
118
|
-
### §3.2 {操作名称}
|
|
119
|
-
|
|
120
|
-
```python
|
|
121
|
-
# ...
|
|
122
|
-
```
|
|
109
|
+
> **注意事项**: {深拷贝 / 竞争条件 / 顺序依赖等关键陷阱}
|
|
123
110
|
|
|
124
111
|
---
|
|
125
112
|
|
|
126
113
|
## §4 决策树详细逻辑 (Decision Tree Details)
|
|
127
114
|
|
|
128
|
-
> 对应 L0
|
|
115
|
+
> 对应 L0 Mermaid 决策图的文字展开 + 完整伪代码。
|
|
116
|
+
> **L0 对应入口**: L0 §4 架构图注释 → *完整决策逻辑见 [L1 §4]*
|
|
129
117
|
|
|
130
118
|
### §4.1 {决策场景名称}
|
|
131
119
|
|
|
132
|
-
**对应 L0 Mermaid**: `{system}.md §{章节}`
|
|
120
|
+
**对应 L0 Mermaid**: `{system-id}.md §{章节}`
|
|
133
121
|
|
|
134
122
|
```python
|
|
135
123
|
def plan_or_decide(...):
|
|
136
|
-
"""
|
|
137
|
-
决策逻辑完整实现。
|
|
138
|
-
"""
|
|
139
124
|
# Step 1: 检查高优先级条件
|
|
140
|
-
# ...
|
|
141
|
-
|
|
142
125
|
# Step 2: 分支逻辑
|
|
143
|
-
# ...
|
|
144
126
|
pass
|
|
145
127
|
```
|
|
146
128
|
|
|
@@ -148,17 +130,18 @@ def plan_or_decide(...):
|
|
|
148
130
|
|
|
149
131
|
## §5 边缘情况与注意事项 (Edge Cases & Gotchas)
|
|
150
132
|
|
|
151
|
-
>
|
|
133
|
+
> 实现时必须处理的非显而易见情况。
|
|
134
|
+
> **L0 对应入口**: L0 §5 或 §9 安全性章节的锚点
|
|
152
135
|
|
|
153
136
|
| 场景 | 风险 | 处理方式 |
|
|
154
137
|
| -------------- | ---------- | -------------- |
|
|
155
138
|
| {边缘情况描述} | {潜在 Bug} | {正确处理方式} |
|
|
156
139
|
|
|
157
|
-
### §5.1 {
|
|
140
|
+
### §5.1 {具体情况}
|
|
158
141
|
|
|
159
142
|
```python
|
|
160
|
-
# ❌ 错误做法
|
|
161
|
-
# cloned_unit.embarked_unit = unit.embarked_unit #
|
|
143
|
+
# ❌ 错误做法
|
|
144
|
+
# cloned_unit.embarked_unit = unit.embarked_unit # 浅拷贝 → 状态污染!
|
|
162
145
|
|
|
163
146
|
# ✅ 正确做法
|
|
164
147
|
# cloned_unit.embarked_unit = deepcopy(unit.embarked_unit) if unit.embarked_unit else None
|
|
@@ -168,31 +151,37 @@ def plan_or_decide(...):
|
|
|
168
151
|
|
|
169
152
|
## §6 测试辅助 (Test Helpers)
|
|
170
153
|
|
|
171
|
-
>
|
|
154
|
+
> 可选。单元测试中复用的工厂函数或 fixtures。
|
|
155
|
+
> **L0 对应入口**: L0 §11 测试策略锚点
|
|
172
156
|
|
|
173
157
|
```python
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
"""创建测试用 Unit 对象"""
|
|
158
|
+
def make_test_unit(type=UnitType.WARRIOR, hp=10, pos=(0, 0)) -> Unit:
|
|
159
|
+
"""创建测试用 Unit"""
|
|
177
160
|
pass
|
|
178
161
|
|
|
179
162
|
def make_test_world(size=8) -> World:
|
|
180
|
-
"""创建测试用 World
|
|
163
|
+
"""创建测试用 World"""
|
|
181
164
|
pass
|
|
182
165
|
```
|
|
183
166
|
|
|
184
167
|
---
|
|
185
168
|
|
|
186
|
-
<!-- ⚠️ 使用指南
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
169
|
+
<!-- ⚠️ AGENT 使用指南
|
|
170
|
+
|
|
171
|
+
何时创建本文件: 触发 L0 拆分规则 R1-R5 任意一条时。
|
|
172
|
+
R1 单个代码块 > 30 行
|
|
173
|
+
R2 代码块总行数 > 200 行
|
|
174
|
+
R3 配置常量字典条目 > 5 个
|
|
175
|
+
R4 版本内联注释 > 5 处
|
|
176
|
+
R5 文档总行数 > 500 行
|
|
177
|
+
|
|
178
|
+
孤岛检查: 本文件每新增一节,必须同步在 L0 对应位置添加超链接锚点。
|
|
179
|
+
|
|
180
|
+
§ 编号约定:
|
|
181
|
+
§1 配置常量 — 始终第一节
|
|
182
|
+
§2 数据结构 — 含方法体的完整类
|
|
183
|
+
§3 算法伪代码 — 按函数顺序编号 (§3.1, §3.2 ...)
|
|
184
|
+
§4 决策树 — 对应 L0 Mermaid 图的展开
|
|
185
|
+
§5 边缘情况 — 从代码注释中提取的 "# ⚠️ 注意" 类内容
|
|
186
|
+
§6 测试辅助 — 可选
|
|
198
187
|
-->
|