Skip to content

feat(tools):Add HarmonyOS project-related tools and skills - #166

Open
hanlinyu1030 wants to merge 19 commits into
mainfrom
hly_branch_ohos_tools
Open

feat(tools):Add HarmonyOS project-related tools and skills#166
hanlinyu1030 wants to merge 19 commits into
mainfrom
hly_branch_ohos_tools

Conversation

@hanlinyu1030

Copy link
Copy Markdown
Collaborator

Summary

Fixes #

Type and Areas

Type:

Areas:

Motivation / Impact

Verification

Reviewer Notes

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

SWangHash and others added 19 commits July 30, 2026 19:29
Add 6 HarmonyOS development skills (130 files, ~574KB) as bundled desktop
resources at src/apps/desktop/resources/skills/:

- arkts-error-fixes (65 files): ArkTS compilation error solutions
- arkts-grammar-standards (5 files): ArkTS syntax specs
- arkts-runtime-fix (20 files): jscrash analysis scripts
- arkui-knowledge (5 files): ArkUI component cookbook
- deveco-cli (1 file): devecocli command skill
- deveco-create-project (34 files): project scaffold templates

Also:
- Update tauri.conf.json bundle.resources to include skills/ directory
- Inline findDevEcoHome/hdcPath in arkts-runtime-fix/scripts/shared/hdc.ts
  to remove cross-project import to deveco-code src/tool/lib/env
Relocate 6 HarmonyOS skills from src/apps/desktop/resources/skills/
to src/crates/assembly/core/builtin_skills/, the only directory embedded
into the binary via include_dir! (builtin.rs:20) and auto-synced to
user_skills_dir()/.system at runtime by ensure_builtin_skills_installed().

Revert the tauri.conf.json bundle.resources entry added previously,
since no Rust code reads skills from the Tauri-packaged resources path.

Skills moved (130 files, 100% rename detected by git):
- arkts-error-fixes, arkts-grammar-standards, arkts-runtime-fix
- arkui-knowledge, deveco-cli, deveco-create-project

Note: catalog.rs registration (BuiltinSkillSpec entries) and policy.rs
mode enablement for a new HarmonyOS group still need to be added in a
follow-up commit, otherwise the runtime_catalog_covers_all_embedded_
builtin_skills test will fail at compile time.
Add HarmonyOS variant to BuiltinSkillGroup enum and register the 6
migrated skills (arkts-error-fixes, arkts-grammar-standards, arkts-
runtime-fix, arkui-knowledge, deveco-cli, deveco-create-project) in
BUILTIN_SKILL_SPECS so the runtime_catalog_covers_all_embedded_
builtin_skills invariant test passes.

Changes:
- agent-runtime/skills/catalog.rs: add HarmonyOS group + 6 specs
- assembly/core/.../skills/catalog.rs: add 6 test assertions
- 6 i18n locale files (en-US/zh-CN/zh-TW x skills/agents): add
  harmonyos group label (HarmonyOS / 鸿蒙 / 鴻蒙)

policy.rs needs no changes: AGENTIC_POLICY (used by coding modes)
already defaults to Enable, so HarmonyOS skills are auto-enabled
where developers need them and disabled in Cowork/ComputerUse/Other.
The core.openharmony ToolProviderGroupPlan entry (containing only the
Calendar tool) was dead code:
- No capability pack referenced core.openharmony (CODE_AGENT_TOOL_GROUPS,
  INTEGRATION_TOOL_GROUPS, CANVAS_TOOL_GROUPS all omit it)
- CalendarTool was not declared in implementations/mod.rs
- Calendar was not in ProductConcreteToolFactory::materialize_tool match
- calendar_tool.rs was orphaned (never compiled)
- Tests already expected core.openharmony absent from the plan

Removing it aligns the constant with the existing test assertions in
product_provider_group_plan_preserves_core_runtime_order and
product_provider_group_plan_preserves_builtin_tool_order.
Both files were dead code — not declared in implementations/mod.rs,
not in materialize_tool match, not in any ToolProviderGroupPlan entry.
Same situation as the previously removed calendar_tool.rs.
… deveco-code

Migrate 3 HarmonyOS development tools from deveco-code (TypeScript/opencode)
to BitFun-OHOS (Rust/Tauri), following the existing JS_THREADSAFE_FUNCTION
callback bridge pattern used by register_arkts_function.rs.

Tools ported:
- check_arkts_files: static ArkTS syntax check on .ets files via
  devecocli MCP (callback key: call_check_arkts_files)
- check_cpp_files: static C/C++ syntax check on native source files
  via devecocli MCP (callback key: call_check_cpp_files)
- switch_cwd: switch session project context directory for HarmonyOS
  project actions (callback key: call_switch_cwd)

Each tool validates input in Rust, then delegates the actual work
(MCP check call, context switch, MCP restart) to the ArkTS frontend
via a registered JS threadsafe function. The frontend is responsible
for registering the callbacks at startup.

Registration:
- implementations/mod.rs: 3 new modules + re-exports
- materialization.rs: 3 match arms in ProductConcreteToolFactory
- tool-provider-groups/lib.rs: 3 tool names added to core.basic group
- test assertions updated to include the 3 new tool names

The tools are in core.basic, so they are included in the CodeAgent
capability pack (available in all coding modes).
…wd in pure Rust

Remove JS_THREADSAFE_FUNCTION callback bridge dependency. All three tools
now implement their logic directly in Rust:

- check_arkts_files: filters .ets files, spawns devecocli serve mcp
  via the new deveco_mcp module, calls MCP tools/call 'check', extracts
  text result
- check_cpp_files: same as above but filters C/C++ extensions (.c/.cc/
  .cpp/.cxx/.h/.hh/.hpp/.hxx)
- switch_cwd: pure path validation + HarmonyOS project detection
  (checks AppScope/app.json5, build-profile.json5, oh-package.json5/
  oh-package.json) — no external process needed

New shared module deveco_mcp.rs implements a minimal MCP stdio client:
- Spawns devecocli serve mcp with project_path as CWD
- JSON-RPC handshake: initialize → notifications/initialized → tools/call
- Newline-delimited JSON over tokio process stdio
- Timeout handling (60s init, 300s call)
- Kills subprocess after each check call

Project path resolution uses ToolUseContext::workspace_root(), falling
back to std::env::current_dir() when no workspace is bound.
…module

Delete deveco_mcp.rs. The check tools now directly use BitFun's
existing MCPServerManager: get_global_mcp_service, get_connection,
call_tool. The deveco-mcp server must be configured in app settings
JSON with command devecocli and args serve mcp.
devecocli_run: extract run_shell_command and add run_hdc reusing the same shell wrapper so SDK paths in shell profiles resolve.

hdc_fallback: list targets, resolve device (sole device when hvd omitted, list when ambiguous), find *.hap preferring build/outputs/<target>/, read bundleName from AppScope/app.json5, then hdc -t <dev> install -r <hap> and hdc -t <dev> shell aa start -a <ability> -b <bundleName>.

start_app: on device-resolution failure, zero devices, or devecocli run failure, drive hdc automatically; only surface the manual ExecCommand hint when hdc also fails.
…ailing 'not connected'

Cause: BitFun never auto-started the devecocli MCP server (deveco-code does this in harmony-mcp.ts), so the check tools errored whenever it was not manually configured. Now they provision/start 'devecocli serve mcp' on demand via a shared deveco_mcp_check helper (shell-wrapped so the npm .cmd shim spawns on Windows).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants