Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b4f6cf6
feat(desktop): migrate HarmonyOS skills from deveco-code
SWangHash Jul 27, 2026
61d93ab
refactor(skills): move HarmonyOS skills to builtin_skills source dir
SWangHash Jul 27, 2026
db7fca7
feat(skills): register HarmonyOS builtin skill group
SWangHash Jul 27, 2026
8063ea4
chore(tools): remove dead Calendar tool and core.openharmony group
SWangHash Jul 27, 2026
6974d9e
chore(tools): remove orphaned harmony_build_tool and harmonyos_project
SWangHash Jul 27, 2026
824345b
feat(tools): port check_arkts_files, check_cpp_files, switch_cwd from…
SWangHash Jul 27, 2026
48d9729
refactor(tools): rewrite check_arkts_files, check_cpp_files, switch_c…
SWangHash Jul 28, 2026
181ec1b
refactor(tools): use existing MCP infra instead of custom deveco_mcp …
SWangHash Jul 28, 2026
bd52c36
feat(tools): add HarmonyOS build_project, start_app, hdc_log, arkts_k…
Jul 28, 2026
85867cc
fix(terminal): apply default shell setting and prefer zsh in auto-det…
Jul 30, 2026
cfe25e2
fix(terminal): source ~/.bashrc for login bash shells in integration …
Jul 30, 2026
f9c4f7b
fix(tools): move check_arkts_files, check_cpp_files, switch_cwd to co…
Jul 30, 2026
8d4c19b
feat(tools): add verify_ui, get_ui_verification_log, save_ui_screensh…
Jul 30, 2026
bb797e8
refactor(tools): remove emulator support from harmony_device and star…
Jul 30, 2026
7692946
docs(skill): add hdc fallback section to deveco-cli skill
Jul 30, 2026
86cdb83
fix(tools): rewrite switch_cwd description to avoid unnecessary calls
Jul 30, 2026
ab3f1ee
fix(tools): implement session CWD store so switch_cwd actually persis…
Jul 30, 2026
556c717
feat(tools): auto-fall back to hdc in start_app when devecocli fails
Jul 31, 2026
eb8c8f0
fix(tools): auto-provision deveco-mcp so check_arkts/cpp_files stop f…
Jul 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/apps/desktop/src/api/terminal_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use bitfun_core::service::remote_ssh::workspace_state::{
get_remote_workspace_manager, init_remote_workspace_manager,
};
use bitfun_core::service::runtime::RuntimeManager;
use bitfun_core::service::config::load_terminal_env_vars;
use bitfun_core::service::config::{load_terminal_default_shell, load_terminal_env_vars};
use bitfun_core::service::terminal::TerminalEvent;
use bitfun_core::service::terminal::{
AcknowledgeRequest as CoreAcknowledgeRequest, CloseSessionRequest as CoreCloseSessionRequest,
Expand Down Expand Up @@ -81,6 +81,13 @@ impl TerminalState {
}
}

// Seed the default shell preference from the user's terminal
// configuration so new terminals and agent sessions honor the
// "Default Terminal" setting. Live updates after this point are
// applied via `SessionManager::update_default_shell` in the
// terminal config provider's `on_config_changed` handler.
config.default_shell = load_terminal_default_shell().await;

let api = TerminalApi::new(config).await;
*api_guard = Some(api);
*initialized = true;
Expand Down
151 changes: 151 additions & 0 deletions src/crates/assembly/core/builtin_skills/arkts-error-fixes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# HarmonyOS ArkTS 错误解决方案Skills

> 专为 AI 辅助开发 HarmonyOS 应用设计的 用于解决ArkTS 编译错误和类型不匹配问题Skills

## 📖 项目背景

在使用 AI 模型(如 Cursor、GitHub Copilot、Claude 等)开发 HarmonyOS 应用时,我们发现了一个普遍存在的问题:

- **AI 模型会重复犯同样的 ArkTS 类型错误**
- **需要开发者反复手动修复相同的错误**,严重影响开发效率

例如,AI 经常生成:
- 使用全局 `animateTo` 而不是 `this.getUIContext().animateTo()`
- 使用 `window.Rect` 而不是 `window.TitleButtonRect`
- 访问 `TitleButtonRect` 不存在的 `left` 和 `top` 属性
- 在 catch 子句中使用类型注解
- 等等...

为了解决这个问题,我们开发了这个 **ArkTS 错误解决方案库**,旨在:

✅ **提高 AI 开发效率** - 让 AI 模型能够自动识别和修复常见错误
✅ **减少重复工作** - 避免反复修复相同的类型错误
✅ **提供最佳实践** - 每个错误都配有详细的解决方案和代码示例

## 🎯 项目目标

本仓库收集并整理了 **32+ 种常见的 ArkTS 编译错误和类型不匹配问题**,每个错误都包含:

- 📝 详细的错误描述和原因分析
- ✅ 正确的解决方案
- 💡 最佳实践建议
- 📚 完整的代码示例

## 📦 内容概览

### 错误分类

| 错误类型 | 数量 | 说明 |
|---------|------|------|
| **API 类型错误** | 5+ | Notification、Window、AppStorage 等 API 类型不匹配 |
| **对象类型错误** | 6+ | 对象展开、对象字面量、接口方法签名等 |
| **函数类型错误** | 4+ | 函数返回类型、箭头函数转换等 |
| **装饰器错误** | 2+ | @StorageLink 默认值、未使用变量警告等 |
| **其他类型错误** | 15+ | Catch 子句、ESObject、资源转换等 |

### 主要错误类型

- ✅ **Notification API 类型错误** - ContentType 类型不兼容
- ✅ **Window API 类型错误** - `window.getLastWindow` 类型推断问题
- ✅ **AppStorage 类型错误** - `AppStorage.get()` 类型推断错误
- ✅ **对象展开类型错误** - 对象展开时的类型推断问题
- ✅ **@StorageLink 默认值错误** - 缺少默认值
- ✅ **对象字面量接口错误** - 对象字面量缺少显式接口
- ✅ **函数返回类型错误** - 返回类型推断受限
- ✅ **箭头函数转换错误** - 使用函数表达式而非箭头函数
- ✅ **TitleButtonRect 类型错误** - 返回类型错误和访问不存在属性
- ✅ **Catch 子句类型错误** - catch 子句中的类型注解
- ✅ **ESObject 类型错误** - ESObject 类型使用受限
- ✅ **资源转换错误** - Resource 到 string/number 转换错误
- ✅ 以及更多...

## 🚀 使用方法

### 作为 AI Skill 使用

本仓库设计为 AI 开发工具的 Skill,可以直接被 AI 模型调用:

1. **配置 Skill**:将本仓库添加到你的 AI 开发工具(如 Cursor)的 Skills 目录
2. **自动识别**:AI 模型在生成代码时会自动参考这些解决方案
3. **减少错误**:AI 生成的代码将更符合 HarmonyOS API 11+ 规范

### 手动查阅

你也可以直接查阅文档和代码示例:

- 📚 **参考文档**:查看 `reference/` 目录下的详细错误说明
- 💻 **代码示例**:查看 `assets/` 目录下的完整代码示例

## 📁 目录结构

```
arkts-error-solution-skill/
├── README.md # 本文件
├── SKILL.md # Skill 配置文件
├── assets/ # 代码示例目录
│ ├── NotificationError.ets
│ ├── WindowTypeError.ets
│ ├── AppStorageError.ets
│ └── ... (27+ 个示例文件)
└── reference/ # 参考文档目录
├── notification_errors.md
├── window_type_errors.md
├── appstorage_errors.md
└── ... (27+ 个文档文件)
```

## 💡 使用示例

### 问题场景

AI 生成代码时经常出现这样的错误:

```typescript
// ❌ AI 经常生成的错误代码
async function getTitleButtonRect(context: UIAbilityContext): Promise<window.Rect> {
const win = await window.getLastWindow(context);
const rect = win.getTitleButtonRect();
return rect; // 类型错误!
}
```

### 解决方案

参考本仓库的解决方案,AI 可以生成正确的代码:

```typescript
// ✅ 正确的代码
async function getTitleButtonRect(context: UIAbilityContext): Promise<window.TitleButtonRect> {
return new Promise((resolve, reject) => {
window.getLastWindow(context, (err, win) => {
if (err.code !== 0) {
reject(new Error(err.message));
return;
}
const titleButtonRect = win.getTitleButtonRect();
resolve(titleButtonRect); // 正确!
});
});
}
```

## 🤝 贡献

欢迎提交 Issue 和 Pull Request!

如果你发现了新的常见错误类型,或者有更好的解决方案,欢迎贡献:

1. Fork 本仓库
2. 创建你的特性分支 (`git checkout -b feature/AmazingError`)
3. 提交你的更改 (`git commit -m 'Add some AmazingError'`)
4. 推送到分支 (`git push origin feature/AmazingError`)
5. 开启一个 Pull Request

## 📄 许可证

本项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情

---

**让 AI 开发 HarmonyOS 应用更高效!** 🚀

150 changes: 150 additions & 0 deletions src/crates/assembly/core/builtin_skills/arkts-error-fixes/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
---
name: arkts-error-fixes
description: Solutions for ArkTS compilation errors and type mismatches. Load this skill when compilation fails or when fixing ArkTS type errors.
---

# Harmony Error Fixes

This skill provides solutions for common ArkTS compilation errors and type mismatches encountered during HarmonyOS development.

## Error Categories

| Category | Description |
|-----------|-------------|
| Notification API Type Errors | ContentType type incompatibility |
| Window API Type Errors | Type inference issues with `window.getLastWindow` |
| AppStorage Type Errors | Type inference errors with `AppStorage.get()` |
| Object Spread Type Errors | Type inference issues with object spread |
| @StorageLink Default Value Errors | Missing default values for `@StorageLink` properties |
| Object Literal Interface Errors | Object literals without explicit interfaces |
| Object Literal Type Errors | Using object literal types in return type annotations |
| Function Return Type Errors | Limited return type inference |
| Arrow Function Conversion Errors | Using function expressions instead of arrow functions |
| Color Property Errors | Non-existent `Color` properties |
| Interface Method Signature Errors | Method signature mismatches in object literals |
| AvoidArea Type Errors | Missing `visible` property in `AvoidArea` type |
| Standalone Function `this` Errors | Using `this` in standalone functions |
| TitleButtonRect Type Errors | Incorrect return type for `getTitleButtonRect`; accessing non-existent properties (left, top) |
| Catch Clause Type Errors | Type annotations in catch clauses |
| ESObject Type Errors | Restricted usage of ESObject type |
| Resource Conversion Errors | Resource to string/number conversion errors |
| Unused Variable Warnings | Declared but never used variables |
| IDataSource Type Errors | LazyForEach requires IDataSource implementation |
| Duplicate Entry Errors | Multiple @Entry decorators in same file |
| Possibly Null Errors | Object possibly null when accessing properties |

## Quick Reference

| Error Type | Solution |
|------------|-----------|
| Notification type error | Cast to `number` type |
| Window type error | Use callback pattern for `getLastWindow` |
| AppStorage type error | Use `@StorageLink` with `LocalStorage` or `AppStorage.setAndLink` (avoid `setOrCreate`) |
| Object spread error | Explicitly type objects |
| @StorageLink default value error | Add `= undefined` or specific default value |
| Object literal interface error | Define interface before using object literal |
| Object literal type error | Define interface and use it as return type |
| Function return type error | Add explicit return type annotation |
| Arrow function conversion error | Convert `function` to arrow function `=>` |
| Color property error | Use hex color values instead of non-existent Color properties |
| Interface method signature error | Use property syntax `method: () => {}` instead of method syntax |
| AvoidArea type error | Add `visible: false` property to AvoidArea object |
| Standalone function `this` error | Pass context as parameter: `function foo(context: Context)` |
| TitleButtonRect type error | Use `window.TitleButtonRect` instead of `window.Rect`; only `width` and `height` properties available |
| Catch clause type error | Remove type annotation or use `any`/`unknown` |
| ESObject type error | Use `ESModule` or specific types instead of `ESObject` |
| Resource conversion error | Use Resource directly in UI components or use ResourceManager |
| Unused variable warning | Use console.info/hilog or delete unused variable |
| IDataSource type error | Implement IDataSource interface for LazyForEach |
| Duplicate Entry error | Remove extra @Entry, use @Component for child components |
| Possibly Null error | Use !== null check or optional chaining |

## Detailed Error Solutions

### Notification API Type Errors
- [Notification Type Error](./reference/notification_errors.md)
- [Code Example](./assets/NotificationError.ets)

### Window API Type Errors
- [Window Type Inference Error](./reference/window_type_errors.md)
- [Code Example](./assets/WindowTypeError.ets)

### AppStorage Type Errors
- [AppStorage Type Error](./reference/appstorage_errors.md)
- [Code Example](./assets/AppStorageError.ets)

### Object Spread Type Errors
- [Object Spread Type Error](./reference/object_spread_errors.md)
- [Code Example](./assets/ObjectSpreadError.ets)

### @StorageLink Default Value Errors
- [@StorageLink Default Value Error](./reference/storage_link_default_errors.md)
- [Code Example](./assets/StorageLinkDefaultError.ets)

### Object Literal Interface Errors
- [Object Literal Interface Error](./reference/object_literal_interface_errors.md)
- [Code Example](./assets/ObjectLiteralInterfaceError.ets)

### Object Literal Type Errors
- [Object Literal Type Error](./reference/object_literal_type_errors.md)
- [Code Example](./assets/ObjectLiteralTypeError.ets)

### Function Return Type Errors
- [Function Return Type Error](./reference/function_return_type_errors.md)
- [Code Example](./assets/FunctionReturnTypeError.ets)

### Arrow Function Conversion Errors
- [Arrow Function Conversion Error](./reference/arrow_function_conversion_errors.md)
- [Code Example](./assets/ArrowFunctionConversionError.ets)

### Color Property Errors
- [Color Property Error](./reference/color_property_errors.md)
- [Code Example](./assets/ColorPropertyError.ets)

### Interface Method Signature Errors
- [Interface Method Signature Error](./reference/interface_method_signature_errors.md)
- [Code Example](./assets/InterfaceMethodSignatureError.ets)

### AvoidArea Type Errors
- [AvoidArea Type Error](./reference/avoid_area_type_errors.md)
- [Code Example](./assets/AvoidAreaTypeError.ets)

### Standalone Function `this` Errors
- [Standalone Function `this` Error](./reference/standalone_function_errors.md)
- [Code Example](./assets/StandaloneFunctionError.ets)

### TitleButtonRect Type Errors
- [TitleButtonRect Type Error](./reference/title_button_rect_type_errors.md)
- [Code Example](./assets/TitleButtonRectTypeError.ets)

### Catch Clause Type Errors
- [Catch Clause Type Error](./reference/catch_clause_type_errors.md)
- [Code Example](./assets/CatchClauseTypeError.ets)

### ESObject Type Errors
- [ESObject Type Error](./reference/esobject_type_errors.md)
- [Code Example](./assets/ESObjectTypeError.ets)

### Resource Conversion Errors
- [Resource Conversion Error](./reference/resource_conversion_errors.md)
- [Code Example](./assets/ResourceConversionError.ets)

### Unused Variable Warnings
- [Unused Variable Warning](./reference/unused_variable_warnings.md)
- [Code Example](./assets/UnusedVariableWarning.ets)

### IDataSource Type Errors
- [IDataSource Type Error](./reference/idata_source_errors.md)
- [Code Example](./assets/IDataSourceError.ets)

### Duplicate Entry Errors
- [Duplicate Entry Error](./reference/duplicate_entry_errors.md)
- [Code Example](./assets/DuplicateEntryError.ets)

### Possibly Null Errors
- [Possibly Null Error](./reference/possibly_null_errors.md)
- [Code Example](./assets/PossiblyNullError.ets)

### Window Rect/Size Type Errors
- [Window Rect/Size Type Error](./reference/window_rect_size_errors.md)
- [Code Example](./assets/WindowRectSizeError.ets)
Loading
Loading