Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计异常

arkts-syntax-assistantarkts 语法助手

Agent Skill

arkts-syntax-assistant 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

8,288

周安装

356

GitHub Stars

56

下载量

2,905
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:arkts-syntax-assistant(arkts 语法助手)
来源仓库:https://github.com/summerkaze/skill-arkts-syntax-assistant
仓库路径:skills/arkts-syntax-assistant
安装命令:
npx skills add https://github.com/summerkaze/skill-arkts-syntax-assistant --skill arkts-syntax-assistant
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/summerkaze/skill-arkts-syntax-assistant --skill arkts-syntax-assistant

简介

arkts-syntax-assistant 提供 ArkTS 语法规则详解,涵盖静态类型系统与受限操作符行为规范。

  • 适合初学者理解 OpenHarmony 开发语言特性,避免结构性类型误用与非预期运行时行为。
  • 列举常见场景文档链接,包括组件生命周期、异步处理与跨进程通信最佳实践。
  • 使用前应结合官方手册核对版本差异,确保示例代码与当前 SDK 兼容。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

ArkTS Syntax Assistant

中文文档


Overview

ArkTS is the default development language for OpenHarmony applications. It builds upon TypeScript with enhanced static typing to improve program stability and performance.

Core Features

  • Static Typing: All types determined at compile time, reducing runtime checks
  • No Dynamic Object Layout: Object structure fixed at compile time, cannot be modified at runtime
  • Restricted Operators: Some operator behaviors are restricted to encourage clearer code semantics
  • No Structural Typing: Structural typing is currently not supported

Reference Documentation

Workflows

1. Syntax Questions

User Question -> Identify Question Type -> Consult Documentation -> Provide Code Example

Common Syntax Questions:

  • Variable declaration -> Use let/const with explicit type or inference
  • Function definition -> Supports optional parameters, defaults, rest parameters, arrow functions
  • Classes and interfaces -> Must initialize fields, supports inheritance and implementation
  • Generics -> Supports constraints and default values
  • Null safety -> Nullable types ((T | null)), non-null assertion ((!)), optional chaining ((?.))

2. TypeScript Migration

Identify TS Code -> Check Incompatible Features -> Consult Migration Rules -> Provide ArkTS Alternative

Key Migration Rules Quick Reference:

TypeScriptArkTS Alternative
var xlet x
any/unknownSpecific types
{n: 42} object literalDefine class/interface first
[index: T]: U index signatureRecord<T, U>
A & B intersection typeinterface C extends A, B
function(){} function expression() => {} arrow function
<Type>value type assertionvalue as Type
Destructuring [a, b] = arrIndividual access arr[0], arr[1]
for..infor loop or for..of
Constructor parameter propertiesExplicit field declaration

3. Performance Optimization

Analyze Code -> Identify Performance Issues -> Consult Optimization Guide -> Provide Solutions

High-Performance Programming Key Points:

  • Declarations: Use const for invariants; avoid mixing integer and float
  • Loops: Extract loop invariants; avoid numeric overflow
  • Functions: Parameter passing preferred over closures; avoid optional parameters
  • Arrays: Use TypedArray for numeric values; avoid sparse arrays and union type arrays
  • Exceptions: Avoid throwing in loops; use return values instead

4. Compile Error Resolution

Get Error Message -> Search Migration Rules -> Find Related Case -> Provide Fix

Common Questions

Q: How to handle JSON.parse return value?

// Error
let data = JSON.parse(str);

// Correct
let data: Record<string, Object> = JSON.parse(str);

Q: How to define object types?

// TypeScript syntax (not supported in ArkTS)
type Person = { name: string, age: number }

// ArkTS syntax
interface Person {
  name: string;
  age: number;
}

// Using object literal
let p: Person = { name: 'John', age: 25 };

Q: How to replace globalThis?

// Error
globalThis.value = 'xxx';

// Use singleton pattern
export class GlobalContext {
  private constructor() {}
  private static instance: GlobalContext;
  private _objects = new Map<string, Object>();

  public static getContext(): GlobalContext {
    if (!GlobalContext.instance) {
      GlobalContext.instance = new GlobalContext();
    }
    return GlobalContext.instance;
  }

  getObject(key: string): Object | undefined {
    return this._objects.get(key);
  }

  setObject(key: string, value: Object): void {
    this._objects.set(key, value);
  }
}

Q: How to handle error types in catch?

// Error
try {} catch (e: BusinessError) {}

// Correct
try {} catch (error) {
  let e: BusinessError = error as BusinessError;
}

Q: How to use Record type?

// TypeScript index signature
function foo(data: { [key: string]: string }) {}

// ArkTS Record
function foo(data: Record<string, string>) {}

// Usage example
let map: Record<string, number> = {
  'John': 25,
  'Mary': 21,
};

Q: How to replace constructor signatures with factory functions?

// TypeScript constructor signature
type ControllerCtor = {
  new (value: string): Controller;
}

// ArkTS factory function
type ControllerFactory = () => Controller;

class Menu {
  createController: ControllerFactory = () => {
    return new Controller('default');
  }
}

Prohibited Standard Library APIs

The following are prohibited in ArkTS:

  • Global: eval
  • Object: __proto__, defineProperty, freeze, getPrototypeOf, etc.
  • Reflect: apply, construct, defineProperty, etc.
  • Proxy: All handler methods

Build Scripts

The scripts directory provides quick compilation scripts for ArkTS projects (including dependency installation):

PlatformScriptPurpose
macOS/Linuxscripts/run.shExecute ohpm install + hvigorw assembleApp
Windowsscripts/run.ps1Execute ohpm install + hvigorw assembleApp

Usage:

# macOS/Linux
bash scripts/run.sh

# Windows PowerShell
.\scripts\run.ps1

Script execution steps:

  1. Install dependencies (ohpm install --all)
  2. Build project (hvigorw assembleApp)

Mandatory Requirements

CRITICAL: When this skill generates ArkTS code, the following workflow MUST be followed:

  1. Compilation Verification: After generating code, you MUST compile the project using the build scripts:

- macOS/Linux: bash scripts/run.sh - Windows: .\scripts\run.ps1

  1. Retry Strategy: If compilation fails:

- Analyze the error output - Fix the issue and retry compilation - Maximum of 3 compilation attempts

  1. User Intervention: After 3 failed compilation attempts, use AskUserQuestion: Question: Compilation failed after 3 attempts. How would you like to proceed? Options: - Continue retrying (attempt another fix) - Manual intervention (I'll wait for your guidance) - Skip compilation (proceed without verification)
  2. Error Reporting: Always show the full compilation error output when failures occur.

Answer Guidelines

  1. Prioritize code examples: Show correct vs incorrect syntax comparison
  2. Reference official documentation: For detailed explanations, guide users to consult corresponding documents in references/
  3. Explain reasons: Explain why ArkTS has this restriction (performance, stability)
  4. Provide alternatives: For unsupported features, provide feasible alternatives

License

MIT License - see LICENSE.txt

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.82%
按下载量换算1,041

Claude

27.78%
按下载量换算807

Cursor

19.28%
按下载量换算560

Gemini CLI

8.46%
按下载量换算246

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills