skills/header-optimization/SKILL.md
This skill should be used when the user asks to "optimize header files", "reduce header dependencies", "优化头文件", "减少头文件依赖", "analyze compilation efficiency", "分析编译效率", or mentions test_header.cpp analysis. This skill optimizes C++ header file compilation efficiency through systematic refactoring.
npx skillsauth add openharmonyinsight/openharmony-skills header-optimizationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Optimize C++ header file compilation efficiency in ace_engine through systematic dependency reduction and implementation restructuring. This skill focuses on reducing compilation time and memory footprint by minimizing header dependencies and moving implementations out of headers.
Invoke this skill when:
Follow these critical constraints during optimization:
Determine the optimization target and mode:
.h): Optimize that header directlytest_header.cpp: Extract the header file from its content and optimize that headerIn analysis-only mode:
Objective: Move all method implementations longer than 3 lines from header to cpp file.
Procedure:
What counts as 3 lines:
// Less than 3 lines - Keep in header
int GetValue() const { return value_; }
// 3 lines or more - Move to cpp
void ProcessData() {
auto result = Calculate();
Validate(result);
cache_.Store(result);
}
Exception: Simple getters/setters that are one-liners typically remain in headers for performance.
Objective: Eliminate unused header dependencies.
Procedure:
#include directives in the header fileExample:
// Before
#include "base/memory/ace_type.h"
#include "core/components/common/layout.h"
#include "core/pipeline/base/element.h" // Not used - REMOVE
// After
#include "base/memory/ace_type.h"
#include "core/components/common/layout.h"
Objective: Replace full header includes with forward declarations wherever possible.
Procedure:
// Before
#include "core/components_ng/base/frame_node.h"
// After
namespace OHOS::Ace::NG {
class FrameNode;
} // namespace OHOS::Ace::NG
Forward Declaration Template:
namespace OHOS::Ace {
namespace NG {
class FrameNode;
class UINode;
} // namespace NG
} // namespace OHOS
IMPORTANT: This section contains advanced forward declaration patterns based on real optimization cases in ace_engine.
When to use forward declaration:
RefPtr<T> or WeakPtr<T>Rule: Smart pointer templates (RefPtr, WeakPtr, std::unique_ptr, std::shared_ptr) do NOT require complete type definition in header files.
Example - Before Optimization:
// click_event.h (BEFORE)
#include "core/components_ng/gestures/recognizers/click_recognizer.h" // ❌ Full include
class ClickEventActuator {
private:
RefPtr<ClickRecognizer> clickRecognizer_; // Only needs forward declaration
const RefPtr<ClickRecognizer>& GetClickRecognizer(); // Also OK with forward decl
};
Example - After Optimization:
// click_event.h (AFTER)
// Removed: #include "click_recognizer.h"
namespace OHOS::Ace::NG {
class ClickRecognizer; // ✅ Forward declaration only
}
class ClickEventActuator {
private:
RefPtr<ClickRecognizer> clickRecognizer_; // Works with forward decl
};
// click_event.cpp
#include "core/components_ng/gestures/recognizers/click_recognizer.h" // Full include here
const RefPtr<ClickRecognizer>& ClickEventActuator::GetClickRecognizer() {
if (!clickRecognizer_) {
clickRecognizer_ = MakeRefPtr<ClickRecognizer>(); // Needs full definition
}
return clickRecognizer_;
}
Key Insights:
RefPtr<T> work with forward declarationconst RefPtr<T>& work with forward declarationMakeRefPtr<T>() requires full definition in .cppVerification: Compile both header and cpp to ensure no undefined type errors.
When to use: When a type from one namespace is needed in another namespace's header file.
Pattern: Add forward declarations in appropriate namespace scope.
Example - gesture_event_hub.h needs ClickInfo:
// click_event.h
#include "base/memory/ace_type.h"
#include "core/components_ng/event/gesture_event_actuator.h"
#include "ui/gestures/gesture_event.h" // Provides GestureEvent, GestureEventFunc
#include "core/components_ng/event/target_component.h" // Provides GestureJudgeFunc
// Cross-namespace forward declaration for gesture_event_hub.h
namespace OHOS::Ace {
class ClickInfo; // Type defined in OHOS::Ace, needed by gesture_event_hub.h
}
namespace OHOS::Ace::NG {
class GestureEventHub; // Forward declaration in target namespace
class ClickRecognizer; // Forward declaration in target namespace
}
class ClickEventActuator : public GestureEventActuator {
// ... implementation
};
Why this works:
Problem: Removing a heavy include (like click_recognizer.h) breaks compilation because other types were indirectly included.
Solution: Identify and directly include only the necessary type definition headers.
Example - Removing click_recognizer.h:
// BEFORE: Heavy indirect dependencies
#include "core/components_ng/gestures/recognizers/click_recognizer.h"
// This indirectly brought in:
// - tap_gesture.h (GestureEventFunc)
// - gesture_recognizer.h
// - multi_fingers_recognizer.h
// - And many more...
// AFTER: Precise includes
#include "ui/gestures/gesture_event.h" // Provides GestureEvent, GestureEventFunc
#include "core/components_ng/event/target_component.h" // Provides GestureJudgeFunc
// Forward declarations
namespace OHOS::Ace::NG {
class ClickRecognizer; // Only name needed for RefPtr<ClickRecognizer>
}
Analysis Process:
GestureEventFunc, GestureJudgeFunc)| Usage Pattern | Can Use Forward Decl? | Requires Full Include? |
|---------------|----------------------|----------------------|
| T* member variable | ✅ Yes | ❌ No |
| T& parameter/return | ✅ Yes | ❌ No |
| RefPtr<T> member | ✅ Yes | ❌ No |
| RefPtr<T>& return | ✅ Yes | ❌ No |
| WeakPtr<T> member | ✅ Yes | ❌ No |
| std::unique_ptr<T> | ✅ Yes | ❌ No |
| std::shared_ptr<T> | ✅ Yes | ❌ No |
| std::vector<T> | ❌ No* | ✅ Yes |
| std::vector<T*> | ✅ Yes | ❌ No |
| Class inheritance | ❌ No | ✅ Yes |
| T member variable | ❌ No | ✅ Yes |
| T value parameter | ❌ No* | ✅ Yes |
| Template instantiation | ❌ No | ✅ Yes |
| Access static members | ❌ No | ✅ Yes |
| Access inline methods | ❌ No | ✅ Yes |
* Exceptions exist with extern templates
Pitfall 1: Removing include breaks dependent headers
Symptom:
error: unknown type name 'ClickInfo' in gesture_event_hub.h
Root Cause: gesture_event_hub.h was indirectly getting ClickInfo from click_recognizer.h
Solution: Add forward declaration in appropriate namespace
namespace OHOS::Ace {
class ClickInfo; // Forward declaration for gesture_event_hub.h
}
Pitfall 2: Missing type definitions after removing include
Symptom:
error: unknown type name 'GestureEventFunc'
error: unknown type name 'GestureJudgeFunc'
Root Cause: These types were indirectly included through click_recognizer.h
Solution: Directly include headers that define these types
#include "ui/gestures/gesture_event.h" // GestureEvent, GestureEventFunc
#include "core/components_ng/event/target_component.h" // GestureJudgeFunc
Pitfall 3: Namespace mismatch in forward declarations
Symptom:
error: no type named 'ClickInfo' in namespace 'OHOS::Ace::NG'
Root Cause: ClickInfo is in OHOS::Ace, not OHOS::Ace::NG
Solution: Use correct namespace for forward declaration
namespace OHOS::Ace { // Correct namespace
class ClickInfo;
}
namespace OHOS::Ace::NG { // Different namespace
class ClickRecognizer;
}
Before Optimization:
// 214 lines, 6 includes
#include <list>
#include "base/memory/ace_type.h"
#include "base/memory/referenced.h" // Redundant
#include "base/utils/noncopyable.h"
#include "core/components_ng/event/gesture_event_actuator.h"
#include "core/components_ng/gestures/recognizers/click_recognizer.h" // Heavy include
namespace OHOS::Ace::NG {
class GestureEventHub; // Only 1 forward declaration
}
// 15 inline method implementations
After Optimization:
// 139 lines (-35%), 5 includes (-16.7%)
#include <list>
#include "base/memory/ace_type.h"
#include "base/utils/noncopyable.h"
#include "core/components_ng/event/gesture_event_actuator.h"
#include "ui/gestures/gesture_event.h" // Precise include
#include "core/components_ng/event/target_component.h" // Precise include
namespace OHOS::Ace {
class ClickInfo; // Cross-namespace forward declaration
}
namespace OHOS::Ace::NG {
class GestureEventHub; // Existing forward declaration
class ClickRecognizer; // ✨ New forward declaration (RefPtr<T> optimization)
}
// 5 inline method implementations (moved 12 to cpp)
Results:
Key Techniques Applied:
#include "click_recognizer.h" with forward declarationGestureEventFunc, GestureJudgeFunc)ClickInfoObjective: Extract frequently-used constants or enums into separate headers to reduce coupling.
When to Apply:
Procedure:
original_types.h, original_constants.h)Example:
// original.h (before)
#pragma once
namespace Constants {
constexpr int MAX_VALUE = 100;
enum class Type { A, B, C };
}
class BigImplementation {
// ... hundreds of lines
};
// original_types.h (after split)
#pragma once
namespace Constants {
constexpr int MAX_VALUE = 100;
enum class Type { A, B, C };
}
// original.h (after split)
#pragma once
#include "original_types.h"
class BigImplementation {
// ... implementation
};
Verification: Only split if it provides clear compilation benefit. Measure before/after with compile-analysis skill.
Objective: Hide implementation details to reduce compilation dependencies.
When to Apply:
Procedure:
PIMPL Template:
// header.h
#pragma once
#include <memory>
namespace OHOS::Ace {
class MyClass {
public:
MyClass();
~MyClass();
// Public interface
void PublicMethod();
private:
class Impl;
std::unique_ptr<Impl> impl_;
};
// cpp.cpp
#include "header.h"
#include "heavy_dependency.h"
class MyClass::Impl {
public:
HeavyDependency dep_;
// Private implementation details
};
MyClass::MyClass() : impl_(std::make_unique<Impl>()) {}
MyClass::~MyClass() = default;
void MyClass::PublicMethod() {
impl_->dep_.DoSomething();
}
Caution: PIMPL adds runtime overhead (extra allocation, indirection). Only use when compilation benefit justifies cost.
Objective: Reduce template compilation overhead through explicit instantiation.
Procedure:
Example:
// header.h (before)
template<typename T>
void Process(T value) {
// Implementation
}
// header.h (after)
template<typename T>
void Process(T value);
extern template void Process<int>(int);
extern template void Process<float>(float);
// cpp.cpp (after)
template<typename T>
void Process(T value) {
// Implementation
}
template void Process<int>(int);
template void Process<float>(float);
Limitation: Only works when template parameter types are known and limited.
Objective: Ensure optimized code compiles correctly.
Procedure:
Error Handling:
Objective: Quantify the impact of optimizations.
Metrics to Collect:
Header dependency count:
Compilation time:
Memory footprint:
Lines of code:
Result Template:
## Optimization Results
### Header: frameworks/path/to/header.h
**Before Optimization:**
- Includes: 15
- Header size: 45.2 KB
- Estimated compile impact: High
**After Optimization:**
- Includes: 6
- Header size: 12.8 KB
- Reduction: 60% includes, 72% size
**Changes Made:**
- Moved 12 method implementations to cpp
- Converted 8 includes to forward declarations
- Removed 3 unused includes
- Split constants into separate header
- Applied PIMPL pattern (if applicable)
**Compilation Status:** ✅ Verified standalone compilation
Objective: Preserve optimized files in git.
Procedure:
git add to stage modified files:
This section provides generalized guidance derived from real optimization cases in ace_engine. Use these strategies to select the right optimization approach for your situation.
┌─────────────────────────────────────────────────────────────┐
│ What type of dependency problem? │
└─────────────────────────────────────────────────────────────┘
│
┌───────────────────┼───────────────────┐
│ │ │
Heavy include Value type Cross-namespace
within same member from include with
namespace heavy include only enum usage
│ │ │
│ │ │
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ RefPtr<T> │ │ unique_ptr<T> │ │ Light Include │
│ Forward Decl │ │ + Forward │ │ Replacement │
│ (Scenario 1) │ │ Declaration │ │ (Scenario 3) │
└───────────────┘ └───────────────┘ └───────────────┘
When to use:
RefPtr<T> or WeakPtr<T>Pattern:
// Header
namespace OHOS::Ace::NG {
class ClickRecognizer; // Forward declaration
}
class ClickEventActuator {
private:
RefPtr<ClickRecognizer> clickRecognizer_; // ✅ Works with forward decl
};
// CPP
#include "core/components_ng/gestures/recognizers/click_recognizer.h"
const RefPtr<ClickRecognizer>& ClickEventActuator::GetClickRecognizer() {
if (!clickRecognizer_) {
clickRecognizer_ = MakeRefPtr<ClickRecognizer>(); // Full definition needed here
}
return clickRecognizer_;
}
⚠️ CRITICAL: RefPtr<T> Members CAN Use Forward Declarations
Common misconception: "RefPtr<T> members require complete type definition"
✅ Correct understanding: RefPtr<T> members work perfectly with forward declarations, provided that:
All inline methods that use the RefPtr<T> member are moved to .cpp
member_->Method() must be in .cppMakeRefPtr<T>() must be in .cppRefPtr<T> parameter or return type should be in .cppOnly declarations remain in header
RefPtr<T> member_; ✅ Works with forward declarationRefPtr<T> GetMember(); ✅ Declaration onlyvoid SetMember(const RefPtr<T>& member); ✅ Declaration onlyNo inline instantiation in header
MakeRefPtr<T>() calls in headermember_->Method() calls in headerExample from gesture_recognizer.h optimization:
// gesture_recognizer.h - BEFORE (inline implementations)
class NGGestureRecognizer {
bool IsSystemGesture() const { // ❌ Inline - needs full GestureInfo definition
if (!gestureInfo_) return false;
return gestureInfo_->IsSystemGesture();
}
RefPtr<GestureInfo> GetGestureInfo() { // ❌ Inline - returns RefPtr<GestureInfo>
return gestureInfo_;
}
private:
RefPtr<GestureInfo> gestureInfo_; // ❌ Requires full definition due to inline methods
};
// gesture_recognizer.h - AFTER (forward declaration + declarations)
namespace OHOS::Ace::NG {
class GestureInfo; // ✅ Forward declaration only
}
class NGGestureRecognizer {
bool IsSystemGesture() const; // ✅ Declaration only
RefPtr<GestureInfo> GetGestureInfo(); // ✅ Declaration only
private:
RefPtr<GestureInfo> gestureInfo_; // ✅ Works with forward declaration!
};
// gesture_recognizer.cpp - Full implementations
#include "core/components_ng/event/gesture_info.h" // ✅ Full include here
bool NGGestureRecognizer::IsSystemGesture() const {
if (!gestureInfo_) return false;
return gestureInfo_->IsSystemGesture(); // ✅ Full definition available
}
RefPtr<GestureInfo> NGGestureRecognizer::GetGestureInfo() {
return gestureInfo_; // ✅ Can return RefPtr with full definition
}
Key principle: RefPtr<T> members do NOT require complete type definition in the header. The requirement comes from inline methods that use the member, not from the member itself.
Benefits:
Real case: case-click_event-forward-declaration.md
Complexity: Easy
When to use:
Pattern:
// Before
#include "core/components_ng/gestures/gesture_info.h" // Heavy include
class DragDropRelatedConfigurations {
private:
DragPreviewOption previewOption_; // ❌ Value type - needs full definition
};
// After
namespace OHOS::Ace::NG {
struct DragPreviewOption; // Forward declaration
}
class DragDropRelatedConfigurations {
public:
~DragDropRelatedConfigurations() override; // ✅ Declaration only
ACE_FORCE_EXPORT const DragPreviewOption& GetOrCreateDragPreviewOption(); // ✅ Return const&
private:
std::unique_ptr<DragPreviewOption> previewOption_; // ✅ Smart pointer
};
// CPP
#include "core/components_ng/gestures/gesture_info.h" // Full include
DragDropRelatedConfigurations::~DragDropRelatedConfigurations() = default;
const DragPreviewOption& DragDropRelatedConfigurations::GetOrCreateDragPreviewOption()
{
if (!previewOption_) {
previewOption_ = std::make_unique<DragPreviewOption>();
}
if (!previewOption_) {
static DragPreviewOption defaultInstance; // ✅ Non-const fallback
return defaultInstance;
}
return *previewOption_; // ✅ Zero-copy return
}
Required Changes:
std::unique_ptr<T>const T& (zero-copy optimization)Benefits:
Costs:
Real case: case-drag-drop-forward-declaration.md
Complexity: Medium
When to use:
Pattern:
// Before - Heavy include
#include "core/gestures/drag_event.h" // ~200 lines, full implementations
class DragEventActuator {
private:
OptionsAfterApplied optionsAfterApplied_; // Value type
};
// After - Light include + forward declarations
#include "core/gestures/drag_constants.h" // ✅ Only enums (~15 lines)
namespace OHOS::Ace {
class DragEvent; // Forward declaration
}
namespace OHOS::Ace::NG {
struct OptionsAfterApplied; // Forward declaration
}
class DragEventActuator {
public:
const OptionsAfterApplied& GetOptionsAfterApplied(); // Declaration only
private:
std::unique_ptr<OptionsAfterApplied> optionsAfterApplied_; // ✅ Smart pointer
};
// Create light header: drag_constants.h
namespace OHOS::Ace {
enum class PreDragStatus : int32_t {
READY = 0,
PROCESSING = 1,
FAILED = 2,
};
}
Required Changes:
Benefits:
Costs:
Real case: case-drag-event-include-reduction.md
Complexity: Medium
| Aspect | Scenario 1: RefPtr<T> | Scenario 2: unique_ptr<T> | Scenario 3: Light Include |
|--------|----------------------|--------------------------|-------------------------|
| Primary use case | Already using smart pointers | Value type members | Cross-namespace heavy includes |
| Creates new files? | No | No | Yes (light headers) |
| Destructor separation | Not needed | Required | Required |
| Return type change | May need RefPtr<T>& | Value → const T& | May or may not need |
| Runtime overhead | Zero | Small (heap alloc) | Small (heap alloc) |
| Dependency reduction | High | High | Very High (90%+) |
| Code complexity | Low | Medium | Medium |
| Best for | RefPtr/WeakPtr members | Value type members | Cross-namespace dependencies |
When: Using forward declarations with smart pointer members
Why: Smart pointer destructor needs complete type definition
Template:
// Header
class MyClass {
public:
~MyClass(); // ✅ Declaration only
private:
std::unique_ptr<ForwardDeclaredType> member_;
};
// CPP
MyClass::~MyClass() = default; // ✅ Implementation here
When: Returning smart pointer managed objects
Why: Avoid unnecessary object copying
Template:
// ❌ Before - Returns by value (creates copy)
DragPreviewOption GetOption() {
return *previewOption_;
}
// ✅ After - Returns const reference (zero copy)
const DragPreviewOption& GetOption() {
if (!previewOption_) {
static DragPreviewOption defaultInstance;
return defaultInstance;
}
return *previewOption_;
}
When: Smart pointer may be null, need safe default
Template:
const OptionsAfterApplied& GetOptionsAfterApplied()
{
if (!optionsAfterApplied_) {
static OptionsAfterApplied defaultInstance; // ✅ Non-const
return defaultInstance;
}
return *optionsAfterApplied_;
}
Why non-const: Const static initialization may fail for complex types with constructors.
When: Passing smart pointer value to function expecting value type
Template:
// When calling: void SetOptionsAfterApplied(const OptionsAfterApplied& options)
// ❌ Wrong - Compile error
frameNode->SetOptionsAfterApplied(optionsAfterApplied_);
// ✅ Correct - Conditional dereference
frameNode->SetOptionsAfterApplied(
optionsAfterApplied_ ? *optionsAfterApplied_ : OptionsAfterApplied()
);
Use this checklist to decide which optimization strategy to apply:
If already using RefPtr/WeakPtr → Scenario 1
If value type member from same namespace → Scenario 2
If cross-namespace include with only enum usage → Scenario 3
If none of the above → Consider PIMPL
references/pimp-guide.md for detailed guidanceSymptom:
error: invalid application of 'sizeof' to an incomplete type
Cause: unique_ptr<T> with forward declaration needs destructor in cpp
Solution: Move destructor implementation to cpp file
Symptom: Unnecessary object copies, potential performance degradation
Cause: Changed member to unique_ptr but still returning by value
Solution: Change return type to const T&
Symptom: Compile error when passing smart pointer to function
Cause: Forgetting to dereference unique_ptr when value type expected
Solution: Use conditional dereference pattern:
function(ptr ? *ptr : Type());
Symptom: Static initialization fails for complex types
Cause: Using static const T with complex constructor
Solution: Use static T (non-const) as fallback
For detailed techniques and examples:
references/patterns.md - Common refactoring patterns for header optimizationreferences/pimp-guide.md - PIMPL pattern detailed guide with ace_engine examplesreferences/forward-declaration.md - Forward declaration best practicesreferences/case-split-enums.md - Real case study: Splitting enums from drag_event.h to drag_constants.h (90%+ dependency reduction)references/case-click_event-forward-declaration.md - Real case study: RefPtr<T> forward declaration optimization for click_event.h (35% size reduction, smart pointer optimization patterns)references/case-drag-drop-forward-declaration.md - ✨ NEW: Real case study: unique_ptr<T> conversion for value type members in drag_drop_related_configuration.hreferences/case-drag-event-include-reduction.md - ✨ NEW: Real case study: Light include replacement strategy for cross-namespace dependencies in drag_event.hWorking examples in examples/:
before-after/ - Side-by-side comparisons of optimizationspimpl-example/ - Complete PIMPL implementation examplesplit-header/ - Header splitting exampleUtility scripts in scripts/:
analyze-includes.sh - Analyze header include dependenciesextract-includes.py - Extract include statistics from headersDO NOT:
ALWAYS:
When user specifies "只分析不进行修改":
This skill integrates with compile-analysis skill for compilation efficiency measurement:
When compilation command extraction is needed, invoke:
Use compile-analysis skill to extract compilation command for [file.cpp]
development
Run local code quality checks covering a subset of OpenHarmony gate CI (copyright, CodeArts C/C++) plus additional local checks (pylint/flake8, shellcheck/bashate, gn format). Use before committing to reduce gate failures. Triggers on: /oh-precommit-codecheck, "门禁检查", "门禁预检", "检查代码", "run codecheck", "check code quality", "lint my code", "代码检查", or after completing code implementation. WHEN to use: before git commit, before creating PR, after modifying C/C++/Python/Shell/GN files, when gate CI fails with codecheck defects, or when you want to preview what gate will flag.
development
OpenHarmony PR full lifecycle workflow. Five modes: - Commit: standardized commit with DCO sign-off and Issue linking - Create PR: commit + push to fork + create Issue + create PR on upstream - Fix Codecheck: fetch gate CI codecheck defects from a PR and auto-fix them - Review PR: fetch a PR's changes to local for code review - Fix Review: fetch unresolved review comments from a PR and auto-fix them Triggers on: /oh-pr-workflow, "提交代码", "创建PR", "提个PR", "commit", "修复告警", "修复门禁", "修复codecheck", "fix codecheck", "review pr", "review这个pr", "看下这个pr", "检视pr", "修复review", "修复检视意见", "fix review", or a GitCode PR URL with fix/review intent.
testing
分析 HM Desktop PRD 文档,提取需求信息、验证完整性、检查章节顺序(需求来源→需求背景→需求价值分析→竞品分析→需求描述)、检查 KEP 定义、检测需求冲突并生成结构化分析报告。适用于用户请求:(1) 分析或审查 PRD 文档, (2) 从需求中提取 KEP 列表, (3) 检查 PRD 完整性或一致性, (4) 将需求映射到模块架构, (5) 验证 PRD 格式合规性, (6) 验证竞品分析章节完整性。关键词:PRD分析, requirement extraction, KEP验证, completeness check, chapter order validation, 竞品分析检查, analyze PRD, 需求提取, 完整性检查, 章节顺序验证
development
基于 PRD 文档自动生成鸿蒙系统设计文档,包括架构设计文档和功能设计文档。生成前会分析 OpenHarmony 存量代码结构,确保与现有架构兼容。架构设计文档第2章必须为竞品方案分析,位于需求背景之后。适用于用户请求:(1) 生成架构设计文档, (2) 生成功能设计文档, (3) 从 PRD 生成设计文档, (4) 创建系统架构设计, (5) 编写功能规格说明, (6) 分析 OH 代码结构。关键词:architecture design, functional design, design doc, 竞品方案分析, OpenHarmony code analysis, 架构设计, 功能设计, 设计文档生成, OH代码分析, analyze codebase, competitor analysis