SuperAPI AI Directory

arkweb-code-gen

Coding & development

View repository

Updated 10-16 03:11

About this skill

ArkWeb Requirements Development Team — Full Implementation Workflow Skill

This Skill acts as apure orchestrator(Team Lead), scheduling four Agent Teammates to collaborate and complete the entire process from requirements to code. Team Lead does not participate inspecific analysis, coding, or review — only responsible for process orchestration, gate checks, and user interaction.

Team Members and Communication Model

                 ┌─────────────────────────────────────────┐
                 │   Team Lead: 本 Skill (SKILL.md)        │
                 │   职责: 创建团队、分配任务、汇总结果、    │
                 │         门禁检查、差异对齐、用户交互、    │
                 │         编译编排                         │
                 │   不做: 不分析需求、不写代码、不检视代码  │
                 └──────────────┬──────────────────────────┘
                                │ 创建团队 + 分配初始任务
               ┌────────────────┼────────────────┐
               ▼                ▼                ▼
    ┌──────────────┐  ┌──────────────┐  ┌──────────────┐
    │ Teammate #1  │  │ Teammate #2  │  │ Teammate #3  │
    │ requirements │◄─►│  arkweb-     │◄─►│  arkweb-     │
    │ -analysis    │  │  coder       │  │  reviewer    │
    │ [🔴 opus]    │  │ [🔵 opus]    │  │ [🟢 sonnet]  │
    │              │  │              │  │              │
    │ 需求分析专家 │  │ 代码实现工程师│  │ 代码检视工程师│
    └──────────────┘  └──────────────┘  └──────────────┘
                            ▲
                            │ 编译结果 + 报错报告
                            │
                  ┌──────────────┐
                  │ Teammate #4  │
                  │  arkweb-     │
                  │  builder     │
                  │ [🟠 sonnet]  │
                  │              │
                  │ 编译验证工程师│
                  └──────────────┘

Teammates can communicate directly with each other (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1), without needing to relay through the Team Lead.

Teammate Role Only does Prohibited
requirements-analysis Requirements Analysis Expert Requirements understanding, architecture analysis, code exploration, output step reports, answer teammates' business questions Write business code, modify BUILD.gn
arkweb-coder Code Implementation Engineer Implement code according to the report, fix review issues, consult the requirements expert on business questions Analyze requirements on their own, deviate from the report plan
arkweb-reviewer Code Review Engineer 8-dimension review, generate Fix Step, confirm business context with the requirements expert Directly modify any code file
arkweb-builder Compilation Verification Engineer Execute compilation, analyze errors, generate structured reports Modify code, fix errors, clean/reset

Team Initialization

Teammate #1: requirements-analysis  (model: opus)
Teammate #2: arkweb-coder           (model: opus)
Teammate #3: arkweb-reviewer        (model: sonnet)
Teammate #4: arkweb-builder         (model: sonnet)

Shared context: requirements design document path, analysis report path, review report path, compilation error report path, Teammate identifiers.

Team Lead responsibilities: create Team + pass shared context, execution and orchestration of Phase 2/7/8, global progress tracking, exception handling.

Workflow Overview

Phase Name Executor Output
0 Development Environment Pre-check Team Lead Environment Check Report
1 Requirements Analysis requirements-analysis Analysis Report
2 Design Compliance Gate Team Lead Compliance Check Result
3 Business Alignment arkweb-coder ↔ requirements-analysis Business Alignment Confirmation
4 Code Implementation arkweb-coder Code Changes
5 Code Review arkweb-reviewer Review Report
6 Fix Loop arkweb-coder ↔ arkweb-reviewer Fixed Code
7 Design Difference Alignment Team Lead (interactive) Difference Alignment Result
8 Compile-Fix Loop Team Lead + builder + coder + reviewer Compilation Passed Confirmation

Phase Handover Protocol

Phase 0 → 1:  环境预检全部通过(Agent Teams 可用、Agent 文件齐全、Claude Code 版本满足)
Phase 1 → 2:  分析报告已生成(含"五、实现步骤"且至少 1 个 Step)
Phase 2 → 3:  无未确认的 [偏离-需用户确认] 项
Phase 3 → 4:  arkweb-coder 声明"业务对齐完成" + requirements-analysis 确认
Phase 4 → 5:  arkweb-coder 输出变更文件清单
Phase 5 → 6:  检视报告已生成
Phase 6 → 7:  BLOCKER/CRITICAL 清零,或达到 5 轮上限
Phase 7 → 8:  所有代码变更已最终确定(设计差异已对齐)
Phase 8 → 完成:  编译成功(exit code 0)或达到 10 轮上限

Note: In the .claude/skills directory, design difference alignment has been extracted as an independent skill (arkweb-design-alignment), scheduled and executed by the arkweb-architect full workflow. In the arkweb-sdd directory, Phase 6 logic is embedded in this file (see the full Phase 5 content below), because the arkweb-design-alignment skill does not exist in arkweb-sdd.

Spec-driven: Prioritize code generation based on the structured Spec (spec.md); design documents serve as supplementary context.

Knowledge base-driven rules (offline + DeepWiki)

Common rules are uniformly referenced:../_shared/KB_RULES.md. The incremental requirements of this skill are as follows:

  • Before code implementation, a candidate subsystem/component/API evidence package must be produced.
  • Before landing external interfaces, it must be checked against the offline apis/*/*.json and local header files to avoid interface specification drift.
  • If the implementation deviates from the evidence package, the reason for the deviation and the risk must be explained in the output.

Input

The user must provide arequirements design document path(required); optionally provide:

  • Spec file path(recommended, preferred over pure document-driven)
  • requirements analysis report output path (default {DOCS_REPO}/tmp/arkweb_requirements_analysis.md)
  • review report output path (default {DOCS_REPO}/tmp/arkweb_review_report.md)
  • compilation error report path (default {DOCS_REPO}/tmp/arkweb_build_error_report.md)

Execution steps

Phase 0: Development environment pre-check

Executor: Team Lead executes directly (does not start an Agent) Knowledge: → Read reference/env-check.md

Before starting any Teammate, perform the environment pre-check. According to reference/env-check.md verify each item in the checklist (Agent Teams environment variables, Agent definition files, Reference files, compilation scripts, Claude Code version). For items that fail, handle them according to the automatic repair process in the reference document.

Output content (mandatory):

  • Candidate subsystems (1~3)
  • Candidate components (3~10)
  • Candidate APIs (5~30)
  • Each piece of evidence includes source, path/URL, reason for match, and confidence.

[Mandatory persistence] Write the evidence package to {DOCS_REPO}/tmp/, see _shared/KB_RULES.md Section 10.

Phase 0 completion criteria:

  • Offline retrieval has been completed in the standard order
  • A candidate evidence package has been formed and written into the subsequent analysis context
  • The evidence package has been persisted to the {DOCS_REPO}/tmp/ directory(completed with the Write tool; the file exists and its content is complete)
  • All environment check items PASS. On FAIL, report the blocking reason and stop the process.

Phase 1: Requirements analysis

Executor:requirements-analysis Agent

Instruction:

请分析以下需求设计文档,按照你的标准流程执行 Phase 0 ~ Phase 3,
生成完整的实现步骤清单。

需求文档路径:{用户提供的文档路径}
分析报告输出路径:{分析报告路径,默认 {DOCS_REPO}/tmp/arkweb_requirements_analysis.md}

【强制要求】必须先 Read 需求设计文档全文,提取其中的架构方案、技术路径、
接口定义、错误码、参数校验规则等强制约束项,然后基于设计文档的方案
(而非代码库中已有的类似模式)来规划实现步骤。

【知识库要求】需求分析报告必须新增"知识库证据包"章节,包含:
1. 候选子系统、部件、API(含分数与命中原因)
2. 每条证据的来源类型(按 `_shared/KB_RULES.md` 的 source_type)与路径
3. 低置信度项标注"推断项"


请先 Read 需求文档,然后按 Phase 1→2→3 顺序执行,
最终将报告 Write 到指定输出路径。

Phase 1 completion criteria:

  • Use Read to check that the analysis report file has been generated
  • The report contains the "V. Implementation Steps" section and has at least 1 Step
  • All items in the "VI. Self-check Checklist" in the report are not empty
  • The report contains a "Knowledge Base Evidence Package" section and has LOCAL_KB as the primary evidence
  • The evidence package has been persisted to the {DOCS_REPO}/tmp/ directory(the Phase 0 evidence package file exists)

If Phase 1 fails(the report is not generated or the content is incomplete):

  • Stop the process
  • Explain to the user the reason for the analysis failure
  • Show the partial analysis results already obtained

Phase 2: Design compliance gate

Executor: Team Lead executes directly (does not start an Agent) Knowledge: → Read reference/design-conformance-check.md

Read the design document and analysis report in parallel, and according to reference/design-conformance-check.md compare item by item across the 5 dimensions, and classify deviations according to the 3-level rules. When [偏离-需用户确认] exists, pause the process and ask the user to decide (A accept / B return / C decide item by item).

Completion criteria: no unconfirmed [偏离-需用户确认] item.


Phase 3: Business Alignment

Executor:arkweb-coder Agent

Instruction:

请先完整阅读需求分析报告,整理出所有不确定的业务疑问。

需求设计文档路径:{用户提供的文档路径}
需求分析报告路径:{分析报告路径}

【Phase 3: 业务对齐 — 编码前必做】
1. Read 需求设计文档全文
2. Read 分析报告全文
3. 整理出所有不确定的业务疑问,逐一向 requirements-analysis 请教
4. 等待所有疑问得到解答后,声明"业务对齐完成"
5. 如果阅读后确认无疑问,直接声明"业务对齐完成,无待确认疑问"

有疑问不猜测,宁可多问不要猜错。
完成后报告业务对齐结果(已提问数量 + 已解答数量)。

Completion criteria: arkweb-coder declares "business alignment complete" and requirements-analysis confirms. On timeout, Team Lead intervenes to summarize unresolved issues and asks the user to answer them all at once.


Phase 4: Code Implementation

Executor:arkweb-coder Agent

Instruction:

业务对齐已完成,请按分析报告中的实现步骤逐 Step 执行代码实现。

需求设计文档路径:{用户提供的文档路径}
需求分析报告路径:{分析报告路径}

【强制要求】
1. 需求设计文档是最高优先级的参考,分析报告是执行指南
2. 设计文档中指定的技术路径不可自行替换
3. 设计文档要求修改的所有层级/仓库都必须实现,包括 deps_code/ 目录

【代码规范】严格遵循你内置的代码生成规范和项目模板执行。

请按你的内部 Phase 1→2→3→4 顺序执行。
完成后输出变更文件清单和验证报告。

Completion criteria: Agent reports all Steps completed (or partially completed). On partial failure, record the failed Steps and continue to Phase 5 to review the completed parts.


Phase 5: Code Review

Executor:arkweb-reviewer Agent

Instruction:

请对所有变更文件进行完整的代码检视。

需求设计文档路径:{用户提供的文档路径}
需求分析报告路径:{分析报告路径}

【检视过程中】如果在 H 维度(设计遵从性)有疑问,直接向 requirements-analysis 确认。
【检视报告要求】每个 Issue 给出代码修改建议 + 测试验证建议。

变更文件来源:分析报告中"四、代码探查结果"列出的文件 + git diff 获取的变更文件。

请按你的内部 Phase 1→2→3→4 顺序执行:
1. 收集变更范围
2. 逐文件检视(A~H 共 8 个维度,含 H-设计遵从性)
3. 交叉验证
4. 生成检视报告到 {检视报告路径,默认 {DOCS_REPO}/tmp/arkweb_review_report.md}

特别注意 H 维度:检查实现是否忠实于设计文档的架构方案、错误码定义、实现范围和参数校验规则。

Completion criteria: Review report has been generated, including a "Issue List" section and a review summary.


Phase 6: Fix Loop

Executor: arkweb-coder ↔ arkweb-reviewer communicate directly (Team Lead does not participate in details)

Loop logic: max_rounds = 5, each round coder fixes → reviewer rechecks → counts BLOCKER/CRITICAL. If cleared, it passes; if the limit is exceeded, report the remaining issues to the user. When disagreements involve business logic, ask requirements-analysis to arbitrate.

Instruction to coder:

请根据代码检视报告中的"附录: 修改指引"章节,逐个 Fix Step 执行修复。
检视报告路径:{检视报告路径}
仅修复报告中列出的问题,不做额外改动。修复完成后直接通知 arkweb-reviewer 复检。
这是第 {current_round}/{max_rounds} 轮修复。

Instruction to reviewer:

arkweb-coder 已完成第 {current_round} 轮修复,请复检。
上轮修复的文件:{修复轮次变更的文件列表}
检视报告输出路径:{检视报告路径}

Phase 7: Design Difference Alignment

Executor: Team Lead leads (interactive) Knowledge: → Read reference/design-diff-alignment.md

Loop logic: max_diff_rounds = 5. According to reference/design-diff-alignment.md compare the 10 dimensions in the design document with the actual implementation, show each difference to the user one by one and request a decision (A accept/B redo/C shelve), and perform write-back or redo operations. After redoing, compare again; if there are no new differences, exit.

Completion criteria: All differences have been handled (passed or reached the maximum number of rounds).


Phase 8: Compile-Fix Loop

Executor: Team Lead orchestrates + arkweb-builder + arkweb-coder + arkweb-reviewer Knowledge: → Read reference/build-verification.md

Loop logic: max_rounds = 10. According to reference/build-verification.md process, builder compiles → if it fails, coder fixes → reviewer reviews (inner loop up to 3 rounds) → recompile. If compilation passes, it is complete.

  1. Read requirements analysis report ({DOCS_REPO}/tmp/arkweb_requirements_analysis.md) → Extract: implementation step list, code exploration results, self-check list

  2. Read review report ({DOCS_REPO}/tmp/arkweb_review_report.md) → Extract: technical decisions, interface changes, architecture adjustments produced during the fix process


**比对维度**:

Design Element Comparison Method Difference Type ───────────────────────────────────────────────────────────────────── Interface/API signature API definition in design doc vs header file in actual code Signature difference Data structure/enum Field definition in design doc vs actual struct/enum Field difference Class/inheritance relationship Class diagram in design doc vs actual class definition Structural difference Method list Method list in design doc vs actual method list Addition/removal difference Parameters/return values Parameter description in design doc vs actual parameter type Type difference Flow/state machine Flowchart in design doc vs actual control flow Logical difference Error code/exception Error definition in design doc vs actual error handling Exception difference Feature Flag Switch plan in design doc vs actual flag definition Configuration difference Multi-language binding scope Binding requirements in design doc vs actual binding coverage Scope difference Module partitioning Module boundaries in design doc vs actual file organization Architectural difference


**执行方式**:对设计文档中描述的每个接口/类/方法,使用 Grep + Read 在实际代码中
查找对应实现,逐项对比。

将所有差异收集为列表,准备进入用户决策环节。

#### Step 5.2: 逐一向用户展示差异并请求决策

对每个差异点,使用 AskUserQuestion 工具向用户展示并请求决策。
**每次仅展示一个差异点**,等待用户明确回复后再处理下一个。

**展示格式**:

Difference {N}/{Total}: {difference title}

Design document description: {original description in the design document, including section reference}

Actual implementation: {actual implementation in the code}

Difference analysis: {briefly explain the cause and impact of the difference}

Please choose a handling method: A) Accept implementation — modify the design document to be consistent with the implementation (write back to the design document) B) Require redo — reimplement the code according to the requirements of the design document (start coder+reviewer) C) Temporarily shelve — record as a pending item, to be handled later


**用户决策选项说明**:

| 选项 | 含义 | 后续操作 |
|------|------|---------|
| A) 接受实现 | 实现合理,设计文档需要更新 | 直接 Edit 设计文档原始章节 |
| B) 要求重做 | 实现偏离设计意图,需修正代码 | 启动 coder → reviewer 循环 |
| C) 暂时搁置 | 无法立即决策,后续处理 | 记录到遗留事项列表 |

#### Step 5.3: 根据用户决策分类处理

收集所有差异点的用户决策,按处理方式分组:

Number of differences for decision A (accept implementation): {a_count} Number of differences for decision B (require redo): {b_count} Number of differences for decision C (temporarily shelve): {c_count}


#### Step 5.4: 执行用户决策

##### 对决策 A(接受实现)的差异:直接回写设计文档

**关键原则:直接修改设计文档的原始章节,而不是在末尾追加说明。**

对每个决策 A 的差异:

1. 使用 Read 定位设计文档中对应的原始章节
2. 使用 Edit **就地修改**原始描述,使其与实际实现一致
3. **不在末尾追加汇总章节**,仅在修改处标注修改来源

**修改原则**:
- 仅修改与实现不一致的段落/章节,不改动文档整体结构
- 保持原文档的写作风格和术语
- 使用 Edit 精确替换,不覆盖整个文档
- 每处修改通过行内注释标注变更来源和原因

**修改示例**:

Original design document (Section 3.1):

Do not append a summary section at the end——All modifications are directly reflected in the original sections.

For differences with decision B (require redo): start the coder+reviewer redo loop

Integrate all decision B differences into redo requirements and pass them to the arkweb-coder Agent:

请根据以下用户决策,重新实现代码以对齐设计文档。

需求设计文档路径:{用户提供的文档路径}
检视报告路径:{检视报告路径}

用户要求重做的差异点:

差异 1: {差异标题}
  设计文档要求:{设计文档的原始描述}
  当前实现:{当前代码的实现}
  需要修改为:{与设计文档一致}

差异 2: ...

请按以下步骤执行:
1. 读取需求设计文档中对应的章节
2. 使用 TodoWrite 创建修复任务列表
3. 逐个修改代码文件以对齐设计文档
4. 修改完成后输出变更文件清单

After the redo is complete, start the arkweb-reviewer Agent to review only the files involved in the redo:

请仅检视以下重做涉及的文件,确认代码已正确对齐设计文档。

需求设计文档路径:{用户提供的文档路径}
重做的文件:{重做变更的文件列表}
检视报告输出路径:{检视报告路径}

重点关注:
1. 用户指出的差异是否已修正
2. 修正是否引入了新问题
3. 代码是否与设计文档一致

If the review still has BLOCKER/CRITICAL issues, continue according to the fix loop logic in Phase 4 (at most 3 rounds).

For differences with decision C (temporarily shelve): record as pending items

Do not modify the design document, do not modify the code. Only list them in the final summary.

Step 5.5: Difference alignment loop check

如果有决策 B 的差异触发了重做:
    → 重新执行 Step 5.1(重新收集信息并比对)
    → 检查重做是否引入了新的差异
    → 如果有新差异 → 回到 Step 5.2(向用户展示新差异)
    → 如果无新差异 → 退出循环

如果无决策 B 的差异:
    → 直接退出循环,所有差异已处理完毕

Loop protection:

max_diff_rounds = 5
如果差异对齐循环超过 5 轮:
    → 向用户报告仍有未对齐的差异
    → 列出剩余差异
    → 建议人工介入

Step 5.6: Difference handling summary

After completing all difference handling, output a summary to the user:

═══════════════════════════════════════════
  Phase 5: 设计差异对齐完成
═══════════════════════════════════════════
需求文档: {原始需求文档路径}

本轮差异统计:
  总差异点: {N}

用户决策分布:
  接受实现(已回写设计文档): {A_count} 处
  要求重做(已重新实现):     {B_count} 处
  暂时搁置(记录为遗留):     {C_count} 处

已直接修改的设计文档章节:
  - {章节1} ({差异标题}): {修改摘要}
  - {章节2} ({差异标题}): {修改摘要}

已重新实现的代码文件:
  - {文件1}: {修改说明}
  - {文件2}: {修改说明}

遗留事项(用户选择搁置):
  - [ ] {差异标题}: {设计要求 vs 实际实现}
═══════════════════════════════════════════

Process status tracking

Use TodoWrite to maintain global progress:

Phase 1:   需求分析          [pending / in_progress / completed]
Phase 2:   设计遵从性门禁    [pending / in_progress / completed / blocked]
Phase 3:   业务对齐          [pending / in_progress / completed]
Phase 4:   代码实现          [pending / in_progress / completed]
Phase 5:   代码检视          [pending / in_progress / completed]
Phase 6:   修复循环 (1~5)    [pending / in_progress / completed]
Phase 7:   设计差异对齐      [pending / in_progress / completed]
  └─ 差异决策轮次 (1~5)      [追踪当前轮次]
Phase 8:   编译-修复循环 (1~10)  [pending / in_progress / completed]
  └─ 内层检视循环 (1~3)         [追踪当前轮次]

Exception handling

Phase 1 failed (requirements cannot be analyzed)

  • Stop the process
  • Show the error message to the user
  • Recommend checking the format and content of the requirements document

Phase 1.5 blocked (design compliance check failed)

  • Stop the process and do not enter Phase 2
  • Output deviation details to the user (design document requirements vs analysis report plan)
  • Provide three options: A) Accept the deviation and continue B) Go back and re-analyze C) Decide item by item
  • Wait for user confirmation before continuing or going back

Phase 1.5 go back (user chooses re-analysis)

  • Pass the deviation details as feedback to the requirements-analysis Agent
  • Re-execute Phase 1, explicitly requiring in the instructions that the deviation items be corrected
  • Re-execute Phase 1.5 verification

Phase 2 partial failure (some Steps cannot be implemented)

  • Record the failed Step
  • Continue executing the subsequent Steps that can be completed
  • Mark the incomplete steps during the Phase 4 review
  • Mark INCOMPLETE when handling design difference alignment (Phase 6)

Phase 4 still has issues after reaching the maximum round

  • Stop the fix loop
  • Report the remaining BLOCKER/CRITICAL issues to the user
  • Recommend manual intervention
  • Phase 5 (design difference alignment) executes normally, mark PASS_WITH_ISSUES

The Phase 5 difference alignment loop exceeds the maximum number of rounds

  • Stop the difference alignment loop
  • Report to the user that there are still unaligned differences
  • List the remaining differences and the recommended handling methods
  • Retain the completed difference handling results

Agent execution times out or does not respond

  • Record the current progress
  • Report to the user the completed phases and the current stuck position
  • Retain the generated intermediate files (analysis report, review report)

Code generation specifications

The following specifications, when Phase 2 schedules arkweb-coder the Agent,must be passed as mandatory instructions。

Naming conventions

类名:     PascalCase       例:WebGPUContext
方法名:   camelCase        例:initializeContext
成员变量: m_ 前缀           例:m_contextId
常量:     k 前缀           例:kMaxTextureSize
文件名:   snake_case       例:webgpu_context.h
命名空间: OHOS::ArkWeb::*  例:OHOS::ArkWeb::WebGPU

Code structure (each C++ file)

// Copyright (c) 2026 Huawei Device Co., Ltd.
// Licensed under the Apache License, Version 2.0

#ifndef {GUARD_NAME}
#define {GUARD_NAME}

#include <memory>
// ... 依赖头文件

namespace OHOS::ArkWeb::{Module} {

class {ClassName} : public {BaseClass} {
public:
    {ClassName}();
    ~{ClassName}() override;

    // 接口方法(来自设计文档)
    int32_t Initialize(const {Config}& config) override;
    void Destroy() override;

private:
    // 成员变量
    std::unique_ptr<{Impl}> impl_;
};

} // namespace OHOS::ArkWeb::{Module}

#endif // {GUARD_NAME}

Key constraints (the coder Agent must comply with)

  1. Copyright header — each source file must contain the Apache 2.0 copyright header — each source file must contain the Apache 2.0 copyright header
  2. namespace — must use the OHOS::ArkWeb::* namespace wrapper
  3. RAII — must follow the Resource Acquisition Is Initialization principle
  4. Raw pointers — passing ownership via raw pointers is prohibited; use — passing ownership via raw pointers is prohibited; use std::unique_ptr / std::shared_ptr
  5. Error codes — use — use int32_t to return error codes (ArkWeb convention, 0 means success)
  6. Logs — use — use WEBGPU_LOGI/LOGE/LOGW or the corresponding module log macros
  7. Design document first — all interfaces, class names, and parameters must be consistent with requirement.md
  8. Minimal modification — if it can be solved by adding new files, do not modify existing files

Unit test specifications

Coverage requirements:

  • Happy Path: at least 2 test cases
  • Boundary conditions: empty input, maximum value, zero value
  • Error paths: invalid parameters, insufficient resources
  • Device differences: behavioral differences across different device types (if applicable)

Test structure:

// Copyright (c) 2026 Huawei Device Co., Ltd.

#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "{header_path}"

using namespace testing;
using namespace OHOS::ArkWeb::{Module};

class {ClassName}Test : public testing::Test {
protected:
    void SetUp() override { /* 初始化 */ }
    void TearDown() override { /* 清理 */ }
};

// 正常路径
TEST_F({ClassName}Test, InitializeSuccess) {
    // Arrange
    {ClassName} obj;
    {Config} config = {.width = 1024, .height = 768};
    // Act
    int32_t result = obj.Initialize(config);
    // Assert
    EXPECT_EQ(result, 0);
}

// 边界条件
TEST_F({ClassName}Test, InitializeWithZeroSize) { /* ... */ }

// 错误路径
TEST_F({ClassName}Test, InitializeWithNullConfig) { /* ... */ }

BUILD.gn specifications

When adding new source files, modify BUILD.gn in the following format:

import("//build/ohos.gni")

ohos_shared_library("{module_name}") {
  sources = [
    "{new_source}.cpp",
    # ... 新增文件
  ]

  include_dirs = [
    "//foundation/arkui/ace_engine/interfaces",
    "//base/web/webview/interfaces",
  ]

  deps = [
    "//third_party/googletest:gtest_main",
  ]

  external_deps = [
    "c_utils:utils",
    "hilog:libhilog",
  ]
}

Self-verification checklist (the coder Agent must execute after completing coding)

  1. Naming consistency — class names correspond to file names, method names are consistent with the design document, and namespaces are correct
  2. Interface completeness — All interfaces in the design document have been implemented, and parameter types and return values are consistent with the design document
  3. Test Coverage — At least 1 test per public method, including normal + boundary + error paths
  4. Specification Check — Complete copyright header, namespace wrapping, no raw pointer ownership transfer, correct macros used for logging
  5. Header Includes — All #include correct, no omissions, no redundancy

Code Generation Principles

  1. The design document is the sole source of truth — All interfaces, class names, and parameters must be consistent with requirement.md
  2. Minimal Modification — Prefer additions over modifications, prefer small changes over large ones
  3. Plan Before Coding — First list the file inventory, then generate them one by one
  4. Test First — Every public interface must have tests
  5. Self-Verification Loop — Self-check must be performed after generation, and failures must be automatically fixed
  6. Follow Existing Specifications — Read the naming and structure specifications in analysis.md, do not start from scratch

Usage Examples

Example 1: Complete Workflow (including discrepancy interaction)

用户: 实现需求 /path/to/requirement_design.md

助手: 好的,我将启动需求实现全流程。
      需求文档: /path/to/requirement_design.md
      分析报告: {DOCS_REPO}/tmp/arkweb_requirements_analysis.md
      检视报告: {DOCS_REPO}/tmp/arkweb_review_report.md

      Phase 1: 启动需求分析...
      → [requirements-analysis Agent 执行]
      → 分析完成:8 个功能点,12 个实现步骤

      Phase 2: 设计遵从性门禁...
      → 比对设计文档与分析报告
      → 3 项一致,0 项偏离 → 检查通过

      Phase 2: 启动代码实现...
      → [arkweb-coder Agent 执行]
      → 实现完成:12/12 Step 已完成,变更 18 个文件

      Phase 3: 启动代码检视...
      → [arkweb-reviewer Agent 执行]
      → 检视完成:2 CRITICAL,5 MAJOR,3 MINOR

      Phase 4: 修复循环 (Round 1/5)...
      → [arkweb-coder 执行修复]
      → [arkweb-reviewer 再次检视]
      → Round 1 完成:0 BLOCKER,0 CRITICAL → 检视通过

      Phase 5: 设计差异对齐(交互式)...

      → 比对设计文档与实际实现,发现 3 处差异

      差异 1/3: 接口方法签名扩展

### 示例 1.5: 设计遵从性门禁拦截

Assistant: Phase 2: Design Compliance Gate... → Compare design document with analysis report

  ⚠ Phase 1.5: 设计遵从性检查未通过

  偏离 1: 技术路径偏离
  设计文档要求:使用 C++ DOM API (SetValueForUser)
  分析报告方案:使用 JS 注入 (ExecuteJavaScript)

  偏离 2: 实现范围缺失
  设计文档要求:修改 arkui_ace_engine 入口层参数校验
  分析报告方案:未涉及 ACE Engine 层修改

  偏离 3: 错误码体系未对齐
  设计文档要求:定义 -1 至 -10 的专项错误码
  分析报告方案:复用已有错误码 102/131/132/133

  请确认:
  A) 接受偏离,按分析报告方案继续
  B) 拒绝偏离,退回 Phase 1 重新分析
  C) 逐项决定(告知每项选择)

User: B

Assistant: Return to Phase 1 to re-analyze, using the discrepancy details as feedback... → Re-execute Phase 1 (corrections for 3 discrepancies have been instructed) → Re-check Phase 1.5 → Check passed → Continue Phase 2...


### 示例 2: 指定文档和自定义输出路径

User: Implement the functionality according to the design document docs/snapshot_api_design.md, output the analysis report to {DOCS_REPO}/tmp/snapshot_analysis.md

Assistant: OK, starting the full requirements implementation workflow. Requirements document: docs/snapshot_api_design.md Analysis report: {DOCS_REPO}/tmp/snapshot_analysis.md ... (same workflow as above)


### 示例 3: 达到最大修复轮次

Assistant: Phase 4: Fix Loop (Round 5/5)... → [arkweb-coder performs fixes] → [arkweb-reviewer reviews again] → Round 5 complete: there is still 1 CRITICAL issue

  ⚠️ 已达到最大修复轮次(5轮),以下问题尚未解决:
  - Issue 3: [CRITICAL] nweb_snapshot_impl.cc:87 异步回调中
    使用 shared_ptr 可能导致循环引用

  建议人工介入处理此问题。
  Phase 5 将正常执行,状态标注为 PASS_WITH_ISSUES。

### Phase 8 超限(编译验证达到最大轮次)
- 报告最后一轮编译错误摘要
- 建议人工介入
- 保留已生成的所有中间文件

### Phase 8 内层超限(coder 修复轮次耗尽)
- 直接进入下一轮编译
- 让编译器验证当前代码状态