Entry of ArkTS runtime for AI-Based tools

1. Code map

This repository is the runtime implementation of OpenHarmony's ArkCompiler. There are two basic components in the runtime: the dynamic runtime for ArkTS-Dyn, and the static runtime for ArkTS-Sta (see below).

This AGENTS.md provides guidance to AI coding agents working in this repository. It helps understand main concepts, code structure and how to get further instructions to work with the repo.

Key areas:

  • Directory static_core/: for static runtime
  • Rest of the directory: for dynamic runtime

Key Concepts

  • ArkTS-Dyn: Traditional ArkTS programming model, with dynamic typing at runtime.

  • ArkTS-Sta: Variant of ArkTS with static typing at runtime.

  • Dynamic runtime: Runtime for ArkTS-Dyn. Code and build scripts are located at top-level directory of the repository excluding static_core/.

  • Static runtime: Runtime for ArkTS-Sta. Code and build scripts are located at static_core/.

  • Frontend Compiler: Translates dynamic/static ArkTS source files into IR structures.

    Located in an external repository, which is normally checked out as ets_frontend at parent directory.

  • Assembler: Assembles the IR generated by the frontend compiler into bytecode.

    Located at assembler/ for ArkTS-Dyn and static_core/assembler/ for ArkTS-Sta.

  • JIT/AOT Compiler: Optimizes/compiles bytecode methods/instructions into platform machine code at runtime or offline.

    Located at compiler/ for ArkTS-Dyn and static_core/compiler/ for ArkTS-Sta.

  • Static Builtin: Runtime builtin libraries provided as standard library of ArkTS-Sta.

    Located at static_core/plugins/ets/stdlib/.

File formats

  • ets: ArkTS-Dyn or ArkTS-Sta sources.
  • abc: ArkTS bytecode.
  • an: Posix ELF or Darwin Mach-O file generated from AOT compiler.

2. Knowledge routing

Before planning or editing, classify the task and read the matching documents.

Task-based routing

  • working with dynamic runtime -> read AGENTS_dyn.md
  • working with static runtime -> read static_core/AGENTS.md

Path-based routing

  • assembler/ -> read assembler/AGENTS.md
  • disassembler/ -> read disassembler/AGENTS.md
  • bytecode_optimizer/ -> read bytecode_optimizer/AGENTS.md
  • libpandabase/ -> read libpandabase/AGENTS.md
  • libpandafile/ -> read libpandafile/AGENTS.md
  • abc2program/ -> read abc2program/AGENTS.md
  • libabckit/ -> read libabckit/AGENTS.md
  • verifier/ -> read verifier/AGENTS.md
  • pandastdlib/ -> read pandastdlib/AGENTS.md
  • libziparchive/ -> read libziparchive/AGENTS.md
  • platforms/ -> read platforms/AGENTS.md
  • panda/ -> read panda/AGENTS.md
  • arkplatform/ -> read arkplatform/AGENTS.md
  • ark_guard/ -> read ark_guard/AGENTS.md
  • static_core/ -> read static_core/AGENTS.md
  • static_core/assembler/ -> read static_core/assembler/AGENTS.md
  • static_core/plugins/ets/stdlib/ -> read static_core/plugins/ets/stdlib/AGENTS.md
  • static_core/compiler/ -> read static_core/compiler/AGENTS.md
  • static_core/irtoc/ -> read static_core/irtoc/AGENTS.md
  • static_core/plugins/ets/runtime/ani/ -> read static_core/plugins/ets/runtime/ani/AGENTS.md
  • static_core/plugins/ets/runtime/interop_js/ -> read static_core/plugins/ets/runtime/interop_js/AGENTS.md
  • static_core/libarkbase/ -> read static_core/libarkbase/AGENTS.md
  • static_core/libarkfile/ -> read static_core/libarkfile/AGENTS.md
  • static_core/verification/ -> read static_core/verification/AGENTS.md

Vocabulary-based routing

Term Risk hint Read
pandaasm,es2abc assembler/AGENTS.md
ark_disasm disassembler/AGENTS.md
vm interface,interop,xgc ark_platform/AGENTS.md, static_core/plugins/ets/runtime/interop_js/AGENTS.md
ArkTS-Dyn os,fd,memory,thread,signal,mutex libpandabase/AGENTS.md, platforms/AGENTS.md
ArkTS-Dyn abc file format,loader,reader,writer libpandafile/AGENTS.md, abc2program/AGENTS.md
validate, modify abc files libabckit/AGENTS.md, verifier/AGENTS.md
ArkTS-Dyn ets stdlib pandastdlib/AGENTS.md
zip,hap libziparchive/AGENTS.md
ets2abc static_core/assembler/AGENTS.md
builtin,stdlib static_core/plugins/ets/stdlib/AGENTS.md
ArkTS-Sta aot/jit static_core/compiler/AGENTS.md
irtoc,codegen,interpreter static_core/irtoc/AGENTS.md
ani,native,intrinsic,interop static_core/plugins/ets/runtime/ani/AGENTS.md
ArkTS-Sta memory,file,thread,mutex static_core/libarkbase/AGENTS.md
ArkTS-Sta abc file format,reader,writer static_core/libarkfile/AGENTS.md

In the plan, state:

  • task category
  • documents read
  • constraints found
  • whether a skill/workflow should be used

3. Constraints and boundaries

Architecture/domain invariants

List of runtime invariants that shall not be touched unless explicitly requested and manually confirmed:

  • Layout of ABC file, including data structure, encoding scheme of constants / classes.
  • Opcode of Instructions and their data layout.
  • Memory layout of objects / heap regions.
  • Thread models and atomic operation semantics.

Do not

  • Do not introduce new production dependencies without explicit approval.
  • Do not change public API signatures, error codes, permission behavior, or lifecycle semantics unless the task explicitly requires it.
  • Do not modify generated files directly; update the source spec and regenerate.
  • Do not introduce thread safety issues.
  • Do not break the fidelity of the runtime

Ask before

  • Adding dependencies.
  • Changing public API semantics.
  • Changing permission model or trust boundary.
  • Changing protocol compatibility or persistent data format.
  • Deleting compatibility shims or migration logic.
  • Running commands that may affect connected devices.

4. Verification

Lint & Code formatting

  • Formatting/lint: clang-format <file>

Build & Run Tests

Look into component-level AGENTS.md files for specific build and test commands.

Done definition

A task is done only when:

  • behavior is implemented
  • relevant validation is run or limitation is explained
  • final response includes summary, files changed, validation result, and risks