Service Widget
Overview
Create or modify HarmonyOS service widgets and card-related project files. Focus on valid widget configuration, generated ArkTS/card code, resources, and safe insertion into the target project.
Workflow
Locate the widget context.
- Inspect module structure, existing card/widget files,
form_config.json, resources, abilities, and build files.
- Determine whether the request is for a new widget, a modification, generated code explanation, or debugging.
Define the widget contract.
- Confirm widget size, name, target page/action, displayed data, refresh behavior, and resources.
- Use a valid service widget name: start with a letter, use letters/digits/underscores, and keep it short enough for project conventions.
- Check for name collisions before adding files.
Implement.
- Follow existing card/module patterns and resource organization.
- Add or modify widget layout code, logic code, static resources, and config together.
- Keep generated code deterministic and easy to merge into the project.
- Avoid hard-coded user-specific absolute paths.
Verify.
- Validate JSON/JSON5 config syntax and file references.
- Check resource paths, widget name consistency, and ability/config linkage.
- Run the project’s available build/check command when practical.
Widget Quality Rules
- Keep the widget glanceable. Prioritize one primary value or action.
- Design for the configured size. Do not assume a full app-page layout inside a widget.
- Ensure text handles truncation and localized length.
- Use existing resources and theme conventions where possible.
- Keep business logic separate from presentation when the project already separates them.
References
Read references/service-widget-checklist.md when adding a widget, changing widget config/resources, or debugging save/preview/build issues.
1---2name: service-widget3description: Service Widget-style HarmonyOS service widget and meta-service card builder. Use when creating, modifying, explaining, or debugging HarmonyOS service widgets/cards, widget layouts, card resources, widget configuration, form_config.json, widget names, card abilities, static resources, logic insertion, preview/save flows, or when the user mentions Service Widget, serviceWidget, ServiceWidget, meta service, 元服务卡片, 服务卡片, 万能卡片, or CodeGenie Service Widget.4---56# Service Widget78## Overview910Create or modify HarmonyOS service widgets and card-related project files. Focus on valid widget configuration, generated ArkTS/card code, resources, and safe insertion into the target project.1112## Workflow13141. Locate the widget context.15 - Inspect module structure, existing card/widget files, `form_config.json`, resources, abilities, and build files.16 - Determine whether the request is for a new widget, a modification, generated code explanation, or debugging.17182. Define the widget contract.19 - Confirm widget size, name, target page/action, displayed data, refresh behavior, and resources.20 - Use a valid service widget name: start with a letter, use letters/digits/underscores, and keep it short enough for project conventions.21 - Check for name collisions before adding files.22233. Implement.24 - Follow existing card/module patterns and resource organization.25 - Add or modify widget layout code, logic code, static resources, and config together.26 - Keep generated code deterministic and easy to merge into the project.27 - Avoid hard-coded user-specific absolute paths.28294. Verify.30 - Validate JSON/JSON5 config syntax and file references.31 - Check resource paths, widget name consistency, and ability/config linkage.32 - Run the project’s available build/check command when practical.3334## Widget Quality Rules3536- Keep the widget glanceable. Prioritize one primary value or action.37- Design for the configured size. Do not assume a full app-page layout inside a widget.38- Ensure text handles truncation and localized length.39- Use existing resources and theme conventions where possible.40- Keep business logic separate from presentation when the project already separates them.4142## References4344Read `references/service-widget-checklist.md` when adding a widget, changing widget config/resources, or debugging save/preview/build issues.