Oh Capi Xts Gen 标志

Oh Capi Xts Gen

组织
openharmonyinsight
oh-capi-xts-gen

OpenHarmony CAPI N-API 封装测试用例生成器(方式 2)。自动解析 .h 头文件,生成 C++ N-API 封装和 ETS/ArkTS 测试代码。 **触发此技能的场景**: - 用户提到 CAPI、C 测试、Native 测试、原生测试、.h 文件解析 - 用户需要生成 N-API 封装测试(不是 gtest) - 用户提到覆盖率报告、补充测试、缺失测试 - 用户需要编译或验证 CAPI 测试套 - 用户提到异步编译、后台编译、编译验证 - 用户提到 XTS 测试、OpenHarmony 测试、子系统测试 **核心功能**: 1. 头文件解析 → 提取 API 信息 2. 测试用例生成 → C++ N-API 封装 + ETS 测试代码 3. 编译验证 → 异步编译 + 错误修复 4. 代码验证 → N-API 三重校验 + 格式检查 **支持子系统**:multimedia、bundlemanager、ability、arkui、hilog 等 **当用户提供覆盖率报告时**:自动切换到覆盖率报告驱动模式(高效精准)

概览

发布者openharmonyinsight
代码仓库openharmony-skills
技能名称oh-capi-xts-gen
星标数
36
复刻数
7
附带文件
79
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 79 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 openharmonyinsight 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Oh Capi Xts Gen AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/openharmonyinsight/openharmony-skills/tree/main/skills/oh-capi-xts-gen
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/openharmonyinsight/openharmony-skills.git /tmp/openharmony-skills
mkdir -p .claude/skills
cp -r /tmp/openharmony-skills/skills/oh-capi-xts-gen .claude/skills/oh-capi-xts-gen
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Oh Capi Xts Gen,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Oh Capi Xts Gen。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Oh Capi Xts Gen 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

oh-capi-xts-gen

OpenHarmony CAPI XTS 测试用例生成器 — 方式2(N-API 封装测试)

Architecture Overview

用户输入(.h) → L1_Analysis(解析头文件)→ L2_Generation(生成N-API封装+ETS测试)→ L3_Validation(三重校验+编译)→ 输出
                ↑                              ↑
          references/subsystems/        modules/conventions/(测试框架规范)

Quick File Index

我要做什么看哪个文件
解析 .h 头文件modules/L1_Analysis/parser/unified_api_parser_c.md
读取文档modules/L1_Analysis/parser/doc_reader.md
解析工程配置modules/L1_Analysis/parser/project_parser.md
分析覆盖率modules/L1_Analysis/analyzer/coverage_analyzer.md
生成 C++ N-API 封装modules/L2_Generation/generator/test_generation_c.md
N-API 基础模式modules/L2_Generation/generator/test_patterns_napi_ets.md
N-API 高级模式modules/L2_Generation/generator/test_patterns_napi_ets_advance.md
N-API API 参考modules/L2_Generation/generator/napi_api_reference.md
工程配置模板modules/L2_Generation/generator/project_config_templates.md
测试套结构检查modules/L2_Generation/generator/test_suite_structure_checklist.md
三重校验modules/L2_Generation/generator/verification_common.md
编译测试套modules/L3_Validation/builder/build_workflow_c.md
编译环境配置modules/L3_Validation/builder/linux_compile_env_setup_c.md
Linux 编译流程modules/L3_Validation/builder/linux_compile_workflow_c.md
提取测试套名称modules/L3_Validation/builder/quick_reference_extract_suite_name.md

Prerequisites

读取 OH_ROOT 路径:.opencode/skills/oh-capi-xts-gen/.oh-capi-xts-config.json

CAPI 头文件路径:{OH_ROOT}/interface/sdk_c/

Universal Constraints

  1. 严格按照 .h 头文件声明的接口生成 N-API 封装和测试用例
  2. 每个测试用例必须包含标准 @tc 注释块
  3. hypium 导入语句必须符合规范
  4. 测试用例命名使用小驼峰 camelCase
  5. 禁止修改工程目录中的非测试文件
  6. N-API 三重校验步骤不可跳过

Test Case Naming Format

SUB_[Subsystem]_[Module]_[API]_[Type]_[Sequence]

Types: PARAM / ERROR / RETURN / BOUNDARY / MEMORY

Examples: SUB_HIVIEWDFX_HILOG_OH_LOG_Print_PARAM_001, SUB_BUNDLEMANAGER_BUNDLE_OH_NativeBundle_GetMetadata_RETURN_001

Generation Architecture

C API (.h) → N-API 封装 (C++) → JS 接口 (index.d.ts) → ETS/ArkTS 测试 (.test.ets)

Workflow

Branch Selection

BranchTriggerPhase 3Generation Target
Flow AUser provides coverage report (trigger: 覆盖率报告、补充测试、缺失测试)Style scan only — extract code style from existing tests, do NOT re-analyze coverage补充已有工程 — generate only missing tests per coverage report, never create new project
Flow BNo coverage report (default)Full coverage analysis — scan all existing tests, analyze method/param/error-code coverage, generate gap report优先补充已有工程 > 创建新工程(must copy from template_project/capi_test_template/)

Flow A: Coverage-Report-Driven

Phase 1 (Config) → Phase 2 (Header Parse) → Phase 3 (Style Scan Only) → Phase 4 (Generate) → Phase 5 (Verify) → Phase 6 (Build) → Phase 7 (Output)
  1. Parse coverage report to extract missing test items
  2. Scan existing test files for code style only (naming patterns, comment style, test structure)
  3. Generate tests directly per report's missing items (do NOT re-analyze existing coverage)
  4. Supplement tests in existing project, never create new project

Flow B: Standard Process (Default)

Phase 1 (Config) → Phase 2 (Header Parse) → Phase 3 (Full Coverage) → Phase 4 (Generate) → Phase 5 (Verify) → Phase 6 (Build) → Phase 7 (Output)

Flow B performs full coverage analysis in Phase 3 (scans all existing test files, generates gap report). Flow A only performs style scan when coverage report already exists.

Phase Details

PhaseNameKey ModuleMandatory
1Determine Subsystem Configreferences/subsystems/_common.md + subsystem configYes
2Header File Parsingmodules/L1_Analysis/parser/unified_api_parser_c.mdYes
3Coverage Analysis / Style Scanmodules/L1_Analysis/analyzer/coverage_analyzer.mdYes
4Generate Test Casesmodules/L2_Generation/generator/test_generation_c.md + test_patterns_napi_ets.mdYes
5N-API Triple Verificationmodules/L2_Generation/generator/verification_common.mdMANDATORY — NEVER SKIP
6Build Verificationmodules/L3_Validation/builder/build_workflow_c.mdRecommended
7Output Results—Yes

Phase 1 config loading order: Core → Subsystem → Module (priority: User Custom > Module Config > Subsystem Config > Core Config)

Phase 2 info source priority: .h header (highest) → subsystem config → reference examples

Phase 4 generated artifacts:

ArtifactPath
C++ N-API wrapperentry/src/main/cpp/NapiTest.cpp
TypeScript declarationentry/src/main/cpp/types/libentry/index.d.ts
ETS test casesentry/src/ohosTest/ets/test/*.test.ets
Build configBUILD.gn, Test.json, etc.

Module Loading (Reference Injection Map)

Load modules based on the triggered usage pattern. Only load what's needed for the current phase.

PhaseAlways LoadConditionally Load
1references/subsystems/_common.mdreferences/subsystems/{Subsystem}/_common.md, {Module}.md
2modules/L1_Analysis/parser/unified_api_parser_c.mdmodules/L1_Analysis/parser/doc_reader.md, modules/L1_Analysis/parser/project_parser.md
3modules/L1_Analysis/analyzer/coverage_analyzer.md—
4modules/L2_Generation/generator/test_generation_c.md, modules/L2_Generation/generator/test_patterns_napi_ets.mdmodules/L2_Generation/generator/test_patterns_napi_ets_advance.md(回调/异步/句柄类 API), modules/L2_Generation/generator/project_config_templates.md(新建工程), modules/L2_Generation/generator/napi_api_reference.md(不常用 napi 函数)
5modules/L2_Generation/generator/verification_common.mdmodules/L2_Generation/generator/test_suite_structure_checklist.md
6modules/L3_Validation/builder/build_workflow_c.mdmodules/L3_Validation/builder/linux_compile_env_setup_c.md(环境配置), modules/L3_Validation/builder/linux_compile_workflow_c.md(Linux 详细流程), modules/L3_Validation/builder/quick_reference_extract_suite_name.md(提取测试套名称)
7——
Error handlingreferences/error_handling.mdAll phases

Configuration Architecture

Priority: User Custom > Module Config > Subsystem Config > Core Config

Core:      references/subsystems/_common.md          (shared mandatory + default rules)
Subsystem: references/subsystems/{Subsystem}/_common.md  (differential rules)
Module:    references/subsystems/{Subsystem}/{Module}.md  (module-specific rules)

Key Constraints

  1. Verification is mandatory — Phase 5 (N-API 三重校验) can never be skipped
  2. Strict API adherence — Only use interfaces declared in .h header files
  3. Module name must be entry — nm_modname = "entry", ETS imports from libentry.so
  4. No project config modification — Only create test files in designated directories
  5. Template copy required — Creating new test suite must copy from template_project/capi_test_template/
  6. @tc annotation required — Every test case must have standard @tc block
  7. Error handling uses napi_throw_error — Do not return error objects from N-API functions

Mandatory Phase 5: N-API Triple Verification

This phase is the core quality gate. Skipping it will cause runtime crashes, missing function registrations, and type mismatches between C++, TypeScript, and ETS.

Self-Verification Method (perform after generating all files)

After generating NapiTest.cpp, index.d.ts, and .test.ets files, you MUST perform the following cross-checks before considering generation complete. For each check, list the extracted items and confirm they match.

Check 1: C++ Registration Completeness

Extract all static napi_value function definitions from NapiTest.cpp, then verify each one appears in the napi_property_descriptor desc[] array in Init. Report any missing registrations.

Check 2: TypeScript ↔ C++ Consistency

Extract all JS function names (the first string parameter) from napi_property_descriptor desc[], then verify each one has a matching export const in index.d.ts. Report any missing declarations.

Check 3: ETS ↔ TypeScript Consistency

Extract all testNapi.xxx calls from .test.ets files, then verify each xxx has a matching export const in index.d.ts. Report any undefined references.

Output Format

After completing all checks, output a summary:

=== N-API Triple Verification ===
C++ functions defined: N
C++ functions registered: N (missing: none)
TypeScript declarations: N (missing: none)
ETS testNapi calls: N (undefined: none)
Result: PASS

If any check fails, fix the generated files immediately before proceeding.

Automated Verification Scripts (run if target path exists)

bash
bash scripts/verify_napi_triple.sh ${TARGET_PATH}
bash scripts/check_test_suite_structure.sh ${TARGET_PATH}

Generation Strategy

优先级:补充已有工程 > 创建新工程

  1. 用户指定目标测试套 → 直接在该工程中补充用例
  2. 分析后发现可添加到已有工程 → 在已有工程中补充用例
  3. 用户未指定且无合适已有工程 → 创建新工程(必须先复制模板)

Supported Subsystems

SubsystemConfig PathKey Notes
multimediareferences/subsystems/multimedia/Camera include 用 <ohcamera/xxx.h>
bundlemanagerreferences/subsystems/bundlemanager/
abilityreferences/subsystems/ability/
hilogreferences/subsystems/hilog/

Test Suite Structure

{测试套名称}/
├── AppScope/app.json5
├── BUILD.gn
├── Test.json
├── build-profile.json5
├── oh-package.json5
├── signature/openharmony.p7b
├── entry/
│   └── src/
│       ├── main/
│       │   ├── cpp/
│       │   │   ├── NapiTest.cpp
│       │   │   ├── CMakeLists.txt
│       │   │   └── types/libentry/index.d.ts
│       │   ├── ets/entryability/EntryAbility.ts
│       │   ├── module.json5
│       │   └── syscap.json
│       └── ohosTest/
│           └── ets/test/*.test.ets

版本: 2.2.0 | 更新日期: 2026-04-08 | 兼容性: OpenHarmony API 10+

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

还有 19 个文件。

常见问题

Oh Capi Xts Gen AI 技能有什么作用?

OpenHarmony CAPI N-API 封装测试用例生成器(方式 2)。自动解析 .h 头文件,生成 C++ N-API 封装和 ETS/ArkTS 测试代码。 **触发此技能的场景**: - 用户提到 CAPI、C 测试、Native 测试、原生测试、.h 文件解析 - 用户需要生成 N-API 封装测试(不是 gtest) - 用户提到覆盖率报告、补充测试、缺失测试 - 用户需要编译或验证 CAPI 测试套 - 用户提到异步编译、后台编译、编译验证 - 用户提到 XTS 测试、OpenHarmony 测试、子系统测试 **核心功能**: 1. 头文件解析 → 提取 API 信息 2. 测试用例生成 → C++ N-API 封装 + ETS 测试代码 3. 编译验证 → 异步编译 + 错误修复 4. 代码验证 → N-API 三重校验 + 格式检查 **支持子系统**:multimedia、bundlemanager、ability、arkui、hilog 等 **当用户提供覆盖率报告时**:自动切换到覆盖率报告驱动模式(高效精准)

为什么在 TypingMind 中使用 Oh Capi Xts Gen?

因为您只需安装一次,就能搭配任何模型使用。Oh Capi Xts Gen 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Oh Capi Xts Gen?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/openharmonyinsight/openharmony-skills/tree/main/skills/oh-capi-xts-gen。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Oh Capi Xts Gen?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Oh Capi Xts Gen 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Oh Capi Xts Gen 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Oh Capi Xts Gen AI 技能免费吗?

openharmonyinsight 已在 GitHub 上发布了该技能。请查看代码仓库了解许可条款。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇