Loading...
Loading...
Compare original and translation side by side
Systematic software development through Specification, Pseudocode, Architecture, Refinement (TDD), and Completion phases.
通过Specification、Pseudocode、Architecture、Refinement(TDD)和Completion五个阶段实现系统化软件开发。
undefinedundefinedundefinedundefined.agent-os/.agent-os/┌─────────────────────────────────────────────────────────────────┐
│ S → P → A → R → C │
│ │
│ Specification → Pseudocode → Architecture → Refinement → Done │
└─────────────────────────────────────────────────────────────────┘┌─────────────────────────────────────────────────────────────────┐
│ S → P → A → R → C │
│ │
│ Specification → Pseudocode → Architecture → Refinement → Done │
└─────────────────────────────────────────────────────────────────┘| Phase | Focus | Output |
|---|---|---|
| Specification | What to build | Requirements document |
| Pseudocode | How it works | Algorithm design |
| Architecture | How it fits | System design |
| Refinement | Make it work | Tested implementation |
| Completion | Make it right | Production-ready code |
| 阶段 | 核心关注点 | 输出成果 |
|---|---|---|
| Specification(需求规格) | 明确要开发的内容 | 需求文档 |
| Pseudocode(伪代码) | 梳理实现逻辑 | 算法设计方案 |
| Architecture(架构设计) | 明确系统适配方式 | 系统设计方案 |
| Refinement(迭代优化) | 实现功能并验证 | 经过测试的实现代码 |
| Completion(完成交付) | 优化至生产可用 | 生产就绪代码 |
undefinedundefinedundefinedundefinedFUNCTION process_data(input_data):
// Validate input
IF input_data is empty:
RAISE ValidationError("Input cannot be empty")
// Initialize result
result = EMPTY_LIST
// Process each item
FOR EACH item IN input_data:
// Check conditions
IF item.meets_criteria():
processed_item = transform(item)
APPEND processed_item TO result
RETURN result
FUNCTION transform(item):
// Apply transformation logic
new_value = item.value * MULTIPLIER
RETURN Item(new_value, item.metadata)FUNCTION process_data(input_data):
// 验证输入
IF input_data is empty:
RAISE ValidationError("Input cannot be empty")
// 初始化结果
result = EMPTY_LIST
// 处理每个条目
FOR EACH item IN input_data:
// 检查条件
IF item.meets_criteria():
processed_item = transform(item)
APPEND processed_item TO result
RETURN result
FUNCTION transform(item):
// 应用转换逻辑
new_value = item.value * MULTIPLIER
RETURN Item(new_value, item.metadata)undefinedundefined| Case | Input | Expected Output |
|---|---|---|
| Empty | [] | [] |
| Single | [1] | [processed_1] |
| Maximum | [1..10000] | [processed_all] |
| 场景 | 输入 | 预期输出 |
|---|---|---|
| 空输入 | [] | [] |
| 单个条目 | [1] | [processed_1] |
| 最大规模 | [1..10000] | [processed_all] |
undefinedundefinedundefinedundefineddef validate(self, data: InputData) -> bool:
"""Validate input data."""
...def validate(self, data: InputData) -> bool:
"""验证输入数据。"""
...undefinedundefined┌──────────────┐
│ 1. RED │ Write failing test
└──────┬───────┘
│
▼
┌──────────────┐
│ 2. GREEN │ Write minimal code to pass
└──────┬───────┘
│
▼
┌──────────────┐
│ 3. REFACTOR │ Improve code quality
└──────┬───────┘
│
└──────────► Repeat┌──────────────┐
│ 1. RED │ 编写失败的测试用例
└──────┬───────┘
│
▼
┌──────────────┐
│ 2. GREEN │ 编写最少代码使测试通过
└──────┬───────┘
│
▼
┌──────────────┐
│ 3. REFACTOR │ 提升代码质量
└──────┬───────┘
│
└──────────► 重复循环def test_process_valid_input():
"""Test processing with valid input."""
processor = Processor()
result = processor.process([1, 2, 3])
assert result == [2, 4, 6]pytest tests/test_processor.py -v
# Expected: FAILEDclass Processor:
def process(self, data):
return [x * 2 for x in data]pytest tests/test_processor.py -v
# Expected: PASSEDclass Processor:
def __init__(self, multiplier: int = 2):
self.multiplier = multiplier
def process(self, data: List[int]) -> List[int]:
return [x * self.multiplier for x in data]def test_process_valid_input():
"""测试处理有效输入的场景。"""
processor = Processor()
result = processor.process([1, 2, 3])
assert result == [2, 4, 6]pytest tests/test_processor.py -v
# 预期结果: FAILEDclass Processor:
def process(self, data):
return [x * 2 for x in data]pytest tests/test_processor.py -v
# 预期结果: PASSEDclass Processor:
def __init__(self, multiplier: int = 2):
self.multiplier = multiplier
def process(self, data: List[int]) -> List[int]:
return [x * self.multiplier for x in data]undefinedundefineddef test_process_empty_input(self):
"""Test with empty input."""
...
def test_process_invalid_input(self):
"""Test with invalid input raises error."""
...def test_process_empty_input(self):
"""测试空输入场景。"""
...
def test_process_invalid_input(self):
"""测试无效输入是否抛出错误。"""
...undefinedundefinedundefinedundefinedundefinedundefinedundefinedundefined| Mode | Focus |
|---|---|
| Full development cycle |
| API development |
| UI development |
| Testing focus |
| Code improvement |
| 模式 | 核心关注点 |
|---|---|
| 完整开发周期 |
| API开发 |
| UI开发 |
| 聚焦测试 |
| 代码优化 |
undefinedundefined.agent-os/
├── specs/
│ └── feature-name/
│ ├── spec.md # Specification
│ ├── tasks.md # Task breakdown
│ └── sub-specs/
│ ├── pseudocode.md # Pseudocode
│ ├── architecture.md # Architecture
│ ├── tests.md # Test spec
│ └── api-spec.md # API spec (if applicable)
└── product/
└── decisions.md # Decision log.agent-os/
├── specs/
│ └── feature-name/
│ ├── spec.md # 需求规格
│ ├── tasks.md # 任务拆解
│ └── sub-specs/
│ ├── pseudocode.md # 伪代码
│ ├── architecture.md # 架构设计
│ ├── tests.md # 测试规格
│ └── api-spec.md # API规格(如适用)
└── product/
└── decisions.md # 决策日志undefinedundefinedundefinedundefinedundefinedundefinedundefinedundefined// Start SPARC mode
mode: "dev",
task_description: "Implement user authentication"
})
// Orchestrate tasks
task: "Complete SPARC refinement phase",
strategy: "sequential",
priority: "high"
})// 启动SPARC模式
mode: "dev",
task_description: "Implement user authentication"
})
// 编排任务
task: "Complete SPARC refinement phase",
strategy: "sequential",
priority: "high"
})