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 forArkTS-Dyn. Code and build scripts are located at top-level directory of the repository excludingstatic_core/. -
Static runtime: Runtime forArkTS-Sta. Code and build scripts are located atstatic_core/. -
Frontend Compiler: Translates dynamic/static ArkTS source files into IR structures.Located in an external repository, which is normally checked out as
ets_frontendat parent directory. -
Assembler: Assembles the IR generated by the frontend compiler into bytecode.Located at
assembler/forArkTS-Dynandstatic_core/assembler/forArkTS-Sta. -
JIT/AOT Compiler: Optimizes/compiles bytecode methods/instructions into platform machine code at runtime or offline.Located at
compiler/forArkTS-Dynandstatic_core/compiler/forArkTS-Sta. -
Static Builtin: Runtime builtin libraries provided as standard library ofArkTS-Sta.Located at
static_core/plugins/ets/stdlib/.
File formats
ets:ArkTS-DynorArkTS-Stasources.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/-> readassembler/AGENTS.mddisassembler/-> readdisassembler/AGENTS.mdbytecode_optimizer/-> readbytecode_optimizer/AGENTS.mdlibpandabase/-> readlibpandabase/AGENTS.mdlibpandafile/-> readlibpandafile/AGENTS.mdabc2program/-> readabc2program/AGENTS.mdlibabckit/-> readlibabckit/AGENTS.mdverifier/-> readverifier/AGENTS.mdpandastdlib/-> readpandastdlib/AGENTS.mdlibziparchive/-> readlibziparchive/AGENTS.mdplatforms/-> readplatforms/AGENTS.mdpanda/-> readpanda/AGENTS.mdarkplatform/-> readarkplatform/AGENTS.mdark_guard/-> readark_guard/AGENTS.mdstatic_core/-> readstatic_core/AGENTS.mdstatic_core/assembler/-> readstatic_core/assembler/AGENTS.mdstatic_core/plugins/ets/stdlib/-> readstatic_core/plugins/ets/stdlib/AGENTS.mdstatic_core/compiler/-> readstatic_core/compiler/AGENTS.mdstatic_core/irtoc/-> readstatic_core/irtoc/AGENTS.mdstatic_core/plugins/ets/runtime/ani/-> readstatic_core/plugins/ets/runtime/ani/AGENTS.mdstatic_core/plugins/ets/runtime/interop_js/-> readstatic_core/plugins/ets/runtime/interop_js/AGENTS.mdstatic_core/libarkbase/-> readstatic_core/libarkbase/AGENTS.mdstatic_core/libarkfile/-> readstatic_core/libarkfile/AGENTS.mdstatic_core/verification/-> readstatic_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