ArkTS_Agent_Kit_3270:基于 ArkTS 技术的代码开发与优化工具包项目

Set of skills, tools, and guides for AI agents to generate canonical ArkTS code. Or modernize the existing one.

Branch7Tags0

ArkTS Agent Kit

ArkTS Agent Kit is a curated enablement layer for humans and AI agents that need to implement, migrate, modernize, optimize, review, diagnose, and repair ArkTS code against the real ArkTS toolkit.

It does not fork the toolkit itself. It packages the current ArkTS docs, compiler-facing signals, repair guidance, and install flows into a portable repo that agents can actually use during execution.

Repository Identity

  • Purpose: turn arkcompiler_* language, linter, LSP, and runtime knowledge into skill-time guidance, normalized artifacts, stable wrappers, and portable/public ArkTS workflows
  • Primary stack: Markdown, JSON, Python, shell
  • Python packaging: pyproject.toml, editable install into repo-local .venv
  • Installable product skill bundle: arkts-skills/
  • Repo-local maintainer skill bundle: .agents/skills/

Upstream Grounding

This repo is grounded in these local upstream trees, tracked in .agents/sources/manifest.yaml:

  • arkcompiler_runtime_core/static_core/plugins/ets/doc
  • arkcompiler_ets_frontend/ets2panda
  • arkcompiler_runtime_core/static_core/plugins/ets
  • interface_sdk-js (api/, arkts/, kits/, and API diff/parser tooling)
  • developtools_ace_ets2bundle (ArkUI compiler metadata, component definitions, UI syntax validation, and sample apps)
  • applications_app_samples (maintainer-only HarmonyOS sample app corpus for local reference and future extraction work)

Repository Layout

  • AGENTS.md: root behavior contract
  • INSTALL.md: setup and verification
  • .agents/sources/manifest.yaml: upstream paths, SHAs, and scopes
  • .agents/curation: maintainer-owned curated-knowledge policy and authoring guides
  • knowledge/raw: deterministic extracted evidence
  • knowledge/derived: generated retrieval and routing contracts
  • knowledge/migration-rules: source-language migration rule sets
  • docs/cards: short skill-time guide cards
  • docs/curated: broader curated markdown summaries for source-heavy domains
  • docs/diagnostics: error and fix documentation
  • docs: higher-level human-facing reference docs
  • arkts-skills: public product skills shipped by bootstrap
  • .agents/skills: repo-local refresh, validation, curation, and release workflows
  • src/arkts_agent_kit: packaged Python control plane and console entrypoints
  • pyproject.toml: package metadata, pytest/coverage, mypy, and ruff configuration
  • scripts: operational control plane
  • tools: thin user-facing wrappers
  • install: bootstrap entrypoints and runtime templates
  • install/adapters: runtime-specific install docs
  • examples: illustrative ArkTS and migration demos, not the grounding source of truth

Build, Test, And Run

Portable product setup:

./install/bootstrap.sh --adapter codex
tools/arkts-compile examples/minimal/hello.ets --json
tools/arkts-lint examples/minimal --json

Bootstrap creates <workspace>/.venv, installs the package in editable mode, and makes the repo wrappers in tools/ delegate to the venv console scripts.

Primary product-mode developer loop:

  1. ./install/bootstrap.sh --adapter <runtime>
  2. tools/arkts-compile examples/minimal/hello.ets --json
  3. tools/arkts-lint examples/minimal --json
  4. ask the agent to use implement-arkts, fix-arkts-errors, or review-arkts
  5. use tools/arkts-check, tools/arkts-compile, or tools/arkts-lint only when the skill needs narrower tool feedback

Maintainer setup with local upstream sources:

./install/bootstrap.sh \
  --adapter codex \
  --profile maintainer \
  --with-refresh-sources \
  --runtime-core /path/to/arkcompiler_runtime_core/static_core \
  --ets-frontend /path/to/arkcompiler_ets_frontend/ets2panda \
  --interface-sdk-js /path/to/interface_sdk-js \
  --ace-ets2bundle /path/to/developtools_ace_ets2bundle \
  --app-samples /path/to/applications_app_samples \
  --ohos-sdk /path/to/ohos/sdk \
  --command-line-tools /path/to/ohos/sdk/command-line-tools
tools/arkts-compile examples/minimal/hello.ets --json
tools/arkts-lint examples/minimal --json
python3 scripts/arkts_agent_kit.py refresh

Core commands:

  • python3 scripts/arkts_agent_kit.py refresh
  • python3 scripts/arkts_agent_kit.py curation-audit
  • python3 scripts/arkts_agent_kit.py curation-plan
  • tools/arkts-capabilities
  • tools/arkts-compile <file.ets> --json
  • tools/arkts-lint <path> --json
  • tools/arkts-lint <path> --fix --json
  • tools/arkts-check <file-or-dir> --json
  • tools/arkts-migrate --from typescript <path> --json

UI note:

  • plain .ets files compile through es2panda
  • ArkUI @Entry and @Component files compile through the upstream driver/build-system path
  • if that UI path is missing native bindings such as public.node, the wrapper reports a blocked capability with the missing path instead of raw compiler diagnostics

Repository developer setup

Create venv environment and install pre-commit hooks in this repository:

python3 -m venv .venv
source .venv/bin/activate
pip3 install .[dev]
pre-commit install

After setup is done, all pre-commit checks can be run with the following command:

pre-commit run --all-files

Architecture And Workflows

  • scripts/arkts_agent_kit.py is the stable repo entrypoint. The packaged implementation now lives under src/arkts_agent_kit/, which reads the source manifest and local install state, discovers tool capabilities, refreshes extracted knowledge, and normalizes compile/lint/check output.
  • src/arkts_agent_kit/ is the packaged implementation surface. scripts/arkts_agent_kit.py and install/bootstrap.py are thin repo shims over the package entrypoints.
  • python3 scripts/arkts_agent_kit.py refresh regenerates:
    • knowledge/raw/sections.jsonl and knowledge/raw/snippets.jsonl from plugins/ets/doc/*
    • knowledge/raw/sdk-declarations.jsonl from interface_sdk-js declaration trees
    • knowledge/raw/stdlib-symbols.jsonl from plugins/ets/stdlib/*.ets
    • knowledge/raw/ace-ui-components.jsonl and knowledge/raw/ace-ui-samples.jsonl from developtools_ace_ets2bundle
    • knowledge/derived/*.json indexes, routing, diagnostics maps, and source status
  • python3 scripts/arkts_agent_kit.py curation-audit reads committed raw and derived artifacts plus the current authored cards and summaries, writes .generated/curation/report.json, initializes .generated/curation/draft-manifest.json when needed, and reports curated coverage, inventory, normalized coverage zones, worklist summary, missing expected domains, and draft-staging issues
  • python3 scripts/arkts_agent_kit.py curation-plan builds the exhaustive curation worklist and writes .generated/curation/worklist.json plus .generated/curation/worklist.md
  • applications_app_samples is tracked in the source manifest and installer state for maintainer workflows, but it is not extracted into product artifacts by default
  • tools/arkts-* stay intentionally thin and delegate to the Python control plane.
  • public skills do not all map to dedicated shell wrappers; workflows such as modernize-arkts, optimize-arkts, and review-arkts orchestrate tools/arkts-check, tools/arkts-compile, and tools/arkts-lint
  • knowledge/raw/* is deterministic extraction output from upstream docs.
  • knowledge/derived/* is generated retrieval state for skills and guides. The key runtime contracts are knowledge/derived/guide-index.json and knowledge/derived/skill-context.json.
  • .generated/* is local maintainer/runtime state and must not be treated as the committed product contract.
  • docs/cards/* is the first-read guide layer for skill execution. docs/curated/* is the second-layer summary surface for SDK, stdlib, ArkUI, runtime, interop, and concurrency context. Long docs in docs/language, docs/migration, docs/cookbook, and docs/style are secondary reference material.
  • .agents/curation/* is the maintainer-owned contract for expanding or refreshing the authored card and summary layers without changing the public runtime contract.
  • Product installs consume committed repo artifacts only. Maintainer installs additionally enable live-source refresh and validation.
  • The canonical runtime binaries live in <workspace>/.venv/bin/.
  • Supported adapters additionally publish managed skill copies into their native homes:
    • Codex: $CODEX_HOME/skills or ~/.codex/skills
    • Claude Code: ~/.claude/skills
    • OpenCode global: $XDG_CONFIG_HOME/opencode/skills or ~/.config/opencode/skills
    • OpenCode project-local: .opencode/skills via ./install/bootstrap.sh --adapter opencode --skill-scope project

User-Facing Script Rule

All user-facing workflows should go through local repo assets only:

  • local markdown guidance in docs/
  • local derived contracts in knowledge/derived/
  • local examples
  • repo wrappers in tools/

Public users should not need to read live arkcompiler_* source trees. Only maintainer refresh and validation workflows may do that. That includes ArkUI framework data from developtools_ace_ets2bundle: product skills should use committed knowledge/derived/ace-ui-index.json, not the live repo.

Current Scripts And How To Use Them

Public commands:

  • ./install/bootstrap.sh --adapter <runtime>
  • python3 install/bootstrap.py --adapter <runtime> --workspace .
  • .venv/bin/arkts-bootstrap --adapter <runtime>
  • .venv/bin/arkts-agent-kit <command>
  • arkts-agent-kit skills install --adapter <runtime> --workspace .
  • arkts-agent-kit skills status --adapter <runtime> --workspace .
  • arkts-agent-kit skills uninstall --adapter <runtime> --workspace .
  • tools/arkts-compile <file.ets> --json
  • tools/arkts-lint <path> --json
  • tools/arkts-lint <path> --fix --json
  • tools/arkts-check <path> --json
  • tools/arkts-migrate --from typescript <path> --json
  • tools/arkts-build-library <package-dir> <output-file>
  • tools/arkts-build-app <app-dir>
  • tools/arkts-run-app <app-dir>
  • tools/arkts-migrate --from javascript <path> --json

For the normal developer loop, prefer:

  1. tools/arkts-check <path> --json for the combined compile-and-lint pass
  2. tools/arkts-compile <file.ets> --json when a plain static .ets file fails before lint is useful
  3. tools/arkts-lint <path> --json when compile is already green and only lint/policy feedback is needed
  4. tools/arkts-lint <path> --fix --json only after the failure family is understood

Manifest-driven runtime flow:

  • copied runtime wrappers expect arktsconfig.json in <package>/ or <package>/src/
  • app wrappers expect <app>/app.json with output, library_abc, library_path, and main
  • tool resolution comes from bootstrap install state or ARKTS_BUILD_ROOT

Advanced direct CLI:

Public skills should keep using tools/. The direct CLI entries below are for maintainer or low-level debugging work, not the normal skill contract.

  • tools/arkts-capabilities
  • python3 scripts/arkts_agent_kit.py check <path> --json

Foreign-repo note:

  • full bootstrap is only for this kit checkout or another checkout with the same package/templates layout
  • use arkts-agent-kit skills install --adapter <runtime> --workspace . --skills-dir <path> when you only want to copy/manage the public skills in another repo

Maintainer-only:

  • ./install/bootstrap.sh --adapter <runtime> --profile maintainer --with-refresh-sources ...
  • ./install/bootstrap.sh --adapter <runtime> --profile maintainer --with-refresh-sources --interface-sdk-js /path/to/interface_sdk-js ...
  • ./install/bootstrap.sh --adapter <runtime> --profile maintainer --with-refresh-sources --ace-ets2bundle /path/to/developtools_ace_ets2bundle ...
  • ./install/bootstrap.sh --adapter <runtime> --profile maintainer --with-refresh-sources --app-samples /path/to/applications_app_samples ...
  • python3 scripts/arkts_agent_kit.py refresh --json
  • python3 scripts/arkts_agent_kit.py curation-audit --json
  • python3 scripts/arkts_agent_kit.py curation-plan --json
  • python3 scripts/arkts_agent_kit.py drift-check --json
  • python3 scripts/arkts_agent_kit.py validate-maintainer --json

Maintainer report model:

  • refresh --json does preflight, extraction, guide validation, and raw-to-derived maintenance analysis in one structured report
  • curation-audit --json audits the current curated layer, stages .generated/curation/* runtime files, and reports inventory, normalized coverage zones, worklist status, and draft follow-up
  • curation-plan --json writes .generated/curation/worklist.json and .generated/curation/worklist.md for the exhaustive backlog
  • drift-check --json checks committed contracts for guide, migration-rule, maintainer-skill, and wrapper drift without mutating repo state
  • validate-maintainer --json groups maintainer readiness into install, refresh, guide validation, curation audit, wrapper smoke checks, and drift

Conventions And Pitfalls

  • Prefer committed repo artifacts over scanning upstream trees during normal product skill execution.
  • If docs and implementation disagree, prefer implementation and treat the mismatch as drift.
  • AI-authored guides must stay citation-backed through the extracted corpus.
  • Generated local runtime state belongs in .generated/ and is not part of the authored repo contract.
  • The repo uses arkts-skills/ for the installable product bundle and .agents/skills/ for repo-local maintainer workflows.
  • tools/arkts-check is the default non-UI developer loop; a green verification expects both compile and lint to work for examples/minimal/hello.ets
  • missing optional capabilities still produce structured wrapper output, but they are reduced modes rather than a fully verified developer loop:
    • without node, tools/arkts-lint and combined check are blocked, while plain compile can still work
    • without an ArkTS build, tools/arkts-compile and combined check are blocked, while docs and review skills still work
    • without ArkUI build-system bindings, plain .ets work can still proceed, but ArkUI UI compile is blocked

Skill Bundles

Installable product skills:

  • arkts-skills/arkts-skill/SKILL.md
  • arkts-skills/design-arkts-ui-app/SKILL.md
  • arkts-skills/implement-arkts/SKILL.md
  • arkts-skills/migrate-to-arkts/SKILL.md
  • arkts-skills/fix-arkts-errors/SKILL.md
  • arkts-skills/explain-arkts-diagnostic/SKILL.md
  • arkts-skills/modernize-arkts/SKILL.md
  • arkts-skills/optimize-arkts/SKILL.md
  • arkts-skills/review-arkts/SKILL.md
  • arkts-skills/verify-arkts-ui/SKILL.md
  • arkts-skills/verify-arkts-device/SKILL.md
  • arkts-skills/verify-arkts-previewer/SKILL.md

Repo-local maintainer skills:

  • .agents/skills/install-arkts-skills/SKILL.md
  • .agents/skills/refresh-arkts-kit/SKILL.md
  • .agents/skills/rebuild-guide-data/SKILL.md
  • .agents/skills/update-curated-knowledge/SKILL.md
  • .agents/skills/validate-arkts-kit/SKILL.md
  • .agents/skills/publish-agent-kit/SKILL.md

Guide routing is documented in docs/guide-usage.md. Skill taxonomy is documented in docs/cookbook/skill-taxonomy.md. Script usage is documented in docs/cookbook/scripts-and-wrappers.md. ArkTS personal-first design-system packs live under arkts-design-systems/ and are validated by scripts/arkts_design_system_check.py. Each pack follows an Open Design-inspired shape: manifest.json for discovery and quality gates, USAGE.md for agent generation rules, DESIGN.md for visual direction, and ArkTS-native tokens.ets / components.ets for implementation patterns. ArkTS UI app verification workflows are documented in arkts-skills/verify-arkts-device/SKILL.md and arkts-skills/verify-arkts-previewer/SKILL.md; shared UI quality gates live in arkts-skills/verify-arkts-ui/. Generated UI apps should keep the selected design-system manifest quality gates in their evidence report. modernize-arkts usage is documented in docs/cookbook/using-modernize-arkts.md.

Introduction

Set of skills, tools, and guides for AI agents to generate canonical ArkTS code. Or modernize the existing one.

Customize your domain