miniapp-dev
Develops and maintains the BitFun MiniApp system (Zero-Dialect Runtime). Use when working on miniapp modules, Mini Apps gallery, bridge scripts, agent tool (InitMiniApp), permission policy, or any code under src/crates/core/src/miniapp/ or src/web-ui/src/app/scenes/miniapps/. Also use when the user mentions MiniApp, miniapps, bridge, or zero-dialect.
Best use case
miniapp-dev is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Develops and maintains the BitFun MiniApp system (Zero-Dialect Runtime). Use when working on miniapp modules, Mini Apps gallery, bridge scripts, agent tool (InitMiniApp), permission policy, or any code under src/crates/core/src/miniapp/ or src/web-ui/src/app/scenes/miniapps/. Also use when the user mentions MiniApp, miniapps, bridge, or zero-dialect.
Teams using miniapp-dev should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/miniapp-dev/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How miniapp-dev Compares
| Feature / Agent | miniapp-dev | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Develops and maintains the BitFun MiniApp system (Zero-Dialect Runtime). Use when working on miniapp modules, Mini Apps gallery, bridge scripts, agent tool (InitMiniApp), permission policy, or any code under src/crates/core/src/miniapp/ or src/web-ui/src/app/scenes/miniapps/. Also use when the user mentions MiniApp, miniapps, bridge, or zero-dialect.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Cursor vs Codex for AI Workflows
Compare Cursor and Codex for AI coding workflows, repository assistance, debugging, refactoring, and reusable developer skills.
SKILL.md Source
# BitFun MiniApp V2 开发指南
## 核心哲学:Zero-Dialect Runtime
MiniApp 使用 **标准 Web API + window.app**:UI 侧为 ESM 模块(`ui.js`),后端逻辑在独立 JS Worker 进程(Bun 优先 / Node 回退)中执行。Rust 负责进程管理、权限策略和 Tauri 独占 API;Bridge 从旧的 `require()` shim + `__BITFUN__` 替换为统一的 **window.app** Runtime Adapter。
## 代码架构
### Rust 后端
```
src/crates/core/src/miniapp/
├── types.rs # MiniAppSource (ui_js/worker_js/esm_dependencies/npm_dependencies), NodePermissions
├── manager.rs # CRUD + recompile() + resolve_policy_for_app()
├── storage.rs # ui.js, worker.js, package.json, esm_dependencies.json
├── compiler.rs # Import Map + Runtime Adapter 注入 + ESM
├── bridge_builder.rs # window.app 生成 + build_import_map()
├── permission_policy.rs # resolve_policy() → JSON 策略供 Worker 启动
├── runtime_detect.rs # detect_runtime() Bun/Node
├── js_worker.rs # 单进程 stdin/stderr JSON-RPC
├── js_worker_pool.rs # 池管理 + install_deps
├── exporter.rs # 导出骨架
└── mod.rs
```
### Tauri Commands
```
src/apps/desktop/src/api/miniapp_api.rs
```
- 应用管理: `list_miniapps`, `get_miniapp`, `create_miniapp`, `update_miniapp`, `delete_miniapp`
- 存储/授权: `get/set_miniapp_storage`, `grant_miniapp_workspace`, `grant_miniapp_path`
- 版本: `get_miniapp_versions`, `rollback_miniapp`
- Worker/Runtime: `miniapp_runtime_status`, `miniapp_worker_call`, `miniapp_worker_stop`, `miniapp_install_deps`, `miniapp_recompile`
- 对话框由前端 Bridge 用 Tauri dialog 插件处理,无单独后端命令
### Agent 工具
```
src/crates/core/src/agentic/tools/implementations/
└── miniapp_init_tool.rs # InitMiniApp — 唯一工具,创建骨架目录供 AI 用通用文件工具编辑
```
注册在 `registry.rs` 的 `register_all_tools()` 中。AI 后续用 Read/Edit/Write 等通用文件工具编辑 MiniApp 文件。
### 前端
```
src/web-ui/src/app/scenes/miniapps/
├── MiniAppGalleryScene.tsx / .scss
├── MiniAppScene.tsx / .scss
├── miniAppStore.ts
├── views/ MiniAppGalleryView
├── components/ MiniAppCard, MiniAppRunner (iframe 带 data-app-id)
├── hooks/
│ ├── useMiniAppBridge.ts # worker.call → workerCall() + dialog.open/save/message
│ └── useMiniAppCatalogSync.ts # 列表与运行态同步
└── utils/ miniAppIcons.tsx, buildMiniAppThemeVars.ts
src/web-ui/src/infrastructure/api/service-api/MiniAppAPI.ts # runtimeStatus, workerCall, workerStop, installDeps, recompile
src/web-ui/src/flow_chat/tool-cards/MiniAppToolDisplay.tsx # InitMiniAppDisplay
```
### Worker 宿主
```
src/apps/desktop/resources/worker_host.js
```
Node/Bun 标准脚本:从 argv 读策略 JSON,stdin 收 RPC、stderr 回响应,内置 fs/shell/net/os/storage dispatch + 加载用户 `source/worker.js` 自定义方法。
## MiniApp 数据模型 (V2)
```rust
// types.rs
MiniAppSource {
html, css,
ui_js, // 浏览器侧 ESM
esm_dependencies,
worker_js, // Worker 侧逻辑
npm_dependencies,
}
MiniAppPermissions { fs?, shell?, net?, node? } // node 替代 env/compute
```
## 权限模型
- **permission_policy.rs**:`resolve_policy(perms, app_id, app_data_dir, workspace_dir, granted_paths)` 生成 JSON 策略,传给 Worker 启动参数;Worker 内部按策略拦截越权。
- 路径变量同前:`{appdata}`, `{workspace}`, `{user-selected}`, `{home}` 等。
## Bridge 通信流程 (V2)
```
iframe 内 window.app.call(method, params)
→ postMessage({ method: 'worker.call', params: { method, params } })
→ useMiniAppBridge 监听
→ miniAppAPI.workerCall(appId, method, params)
→ Tauri invoke('miniapp_worker_call')
→ JsWorkerPool → Worker 进程 stdin → stderr 响应
→ 结果回 iframe
dialog.open / dialog.save / dialog.message
→ postMessage → useMiniAppBridge 直接调 @tauri-apps/plugin-dialog
```
## window.app 运行时 API
MiniApp UI 内通过 **window.app** 访问:
| API | 说明 |
|-----|------|
| `app.call(method, params)` | 调用 Worker 方法(含 fs/shell/net/os/storage 及用户 worker.js 导出) |
| `app.fs.*` | 封装为 worker.call('fs.*', …) |
| `app.shell.*` | 同上 |
| `app.net.*` | 同上 |
| `app.os.*` | 同上 |
| `app.storage.*` | 同上 |
| `app.dialog.open/save/message` | 由 Bridge 转 Tauri dialog 插件 |
| 生命周期 / 事件 | 见 bridge_builder 生成的适配器 |
## 主题集成
MiniApp 在 iframe 中运行时自动与主应用主题同步,避免界面风格与主应用差距过大。
### 只读属性与事件
| 成员 | 说明 |
|------|------|
| `app.theme` | 当前主题类型字符串:`'dark'` 或 `'light'`(随主应用切换更新) |
| `app.onThemeChange(fn)` | 注册主题变更回调,参数为 payload:`{ type, id, vars }` |
### data-theme-type 属性
编译后的 HTML 根元素 `<html>` 带有 `data-theme-type="dark"` 或 `"light"`,便于用 CSS 按主题写样式,例如:
```css
[data-theme-type="light"] .panel { background: #f5f5f5; }
[data-theme-type="dark"] .panel { background: #1a1a1a; }
```
### --bitfun-* CSS 变量
宿主会将主应用主题映射为以下 CSS 变量并注入 iframe 的 `:root`。在 MiniApp 的 CSS 中建议用 `var(--bitfun-*, <fallback>)` 引用,以便在 BitFun 内与主应用一致,导出为独立应用时 fallback 生效。
**背景**
- `--bitfun-bg` — 主背景
- `--bitfun-bg-secondary` — 次级背景(如工具栏、面板)
- `--bitfun-bg-tertiary` — 第三级背景
- `--bitfun-bg-elevated` — 浮层/卡片背景
**文字**
- `--bitfun-text` — 主文字
- `--bitfun-text-secondary` — 次要文字
- `--bitfun-text-muted` — 弱化文字
**强调与语义**
- `--bitfun-accent`、`--bitfun-accent-hover` — 强调色及悬停
- `--bitfun-success`、`--bitfun-warning`、`--bitfun-error`、`--bitfun-info` — 语义色
**边框与元素**
- `--bitfun-border`、`--bitfun-border-subtle` — 边框
- `--bitfun-element-bg`、`--bitfun-element-hover` — 控件背景与悬停
**圆角与字体**
- `--bitfun-radius`、`--bitfun-radius-lg` — 圆角
- `--bitfun-font-sans`、`--bitfun-font-mono` — 无衬线与等宽字体
**滚动条**
- `--bitfun-scrollbar-thumb`、`--bitfun-scrollbar-thumb-hover` — 滚动条滑块
示例(在 `style.css` 中):
```css
:root {
--bg: var(--bitfun-bg, #121214);
--text: var(--bitfun-text, #e8e8e8);
--accent: var(--bitfun-accent, #60a5fa);
}
body {
font-family: var(--bitfun-font-sans, system-ui, sans-serif);
color: var(--text);
background: var(--bg);
}
```
### 同步时机
- iframe 加载后 bridge 会向宿主发送 `bitfun/request-theme`,宿主回推当前主题变量,iframe 内 `_applyThemeVars` 写入 `:root`。
- 主应用切换主题时,宿主会向 iframe 发送 `themeChange` 事件,bridge 更新变量并触发 `onThemeChange` 回调。
## 开发约定
### 新增 Agent 工具
当前仅 **InitMiniApp**。若扩展:
1. `implementations/miniapp_xxx_tool.rs` 实现 `Tool`
2. `mod.rs` + `registry.rs` 注册
3. `flow_chat/tool-cards/index.ts` 与 `MiniAppToolDisplay.tsx` 增加对应卡片
### 修改编译器
`compiler.rs`:注入 Import Map(`build_import_map`)、Runtime Adapter(`build_bridge_script`)、CSP;用户脚本以 `<script type="module">` 注入 `ui_js`。
### 前端事件
后端 `miniapp-created` / `miniapp-updated` / `miniapp-deleted` / `miniapp-worker-*`,前端 `useMiniAppCatalogSync` 统一监听并刷新 store。
## 场景注册检查清单
同前:`SceneBar/types.ts`、`scenes/registry.ts`、`SceneViewport.tsx`、`NavPanel/config.ts`、`app/types/index.ts`、locales。
## 参考
- 重构计划: `.cursor/plans/miniapp_v2_full_refactor_*.plan.md`
- 架构说明见 plan 内「MiniApp V2 一步到位重构计划」Related Skills
xlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.
writing-skills
Use when creating new skills, editing existing skills, or verifying skills work before deployment
writing-plans
Use when you have a spec or requirements for a multi-step task, before touching code
verification-before-completion
Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always
using-superpowers
Use when starting any conversation - establishes how to find and use skills, requiring Skill tool invocation before ANY response including clarifying questions
using-git-worktrees
Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification
test-driven-development
Use when implementing any feature or bugfix, before writing implementation code
systematic-debugging
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
subagent-driven-development
Use when executing implementation plans with independent tasks in the current session
requesting-code-review
Use when completing tasks, implementing major features, or before merging to verify work meets requirements
receiving-code-review
Use when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation
pptx
Use this skill any time a .pptx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates, layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx filename, regardless of what they plan to do with the content afterward. If a .pptx file needs to be opened, created, or touched, use this skill.