Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions MiniApp/Demo/git-graph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ miniapps/git-graph/

3. **Install dependencies**: inside the MiniApp's app directory, run:
- `bun install` or `npm install` (matching the runtime BitFun detected)
- Or use the "Install Dependencies" action in Toolbox (calls `miniapp_install_deps`)
- Or use the "Install Dependencies" action in the Mini Apps gallery (calls `miniapp_install_deps`)

4. **Compile**: to regenerate `compiled.html`, call `miniapp_recompile` or let BitFun compile automatically when the MiniApp is opened.

5. Open the MiniApp in the Toolbox scene, pick a repository, and the Git Graph will appear.
5. Open the MiniApp in the Mini Apps gallery, pick a repository, and the Git Graph will appear.

### Permissions

Expand Down Expand Up @@ -159,11 +159,11 @@ miniapps/git-graph/

3. **安装依赖**:在 MiniApp 的 app 目录下执行:
- `bun install` 或 `npm install`(与 BitFun 检测到的运行时一致)
- 或在 Toolbox 中对该 MiniApp 执行「安装依赖」操作(调用 `miniapp_install_deps`)
- 或在 Mini Apps 画廊中对该 MiniApp 执行「安装依赖」操作(调用 `miniapp_install_deps`)

4. **编译**:若需重新生成 `compiled.html`,可调用 `miniapp_recompile` 或由 BitFun 在打开该 MiniApp 时自动编译。

5. 在 Toolbox 场景中打开该 MiniApp,选择仓库后即可查看 Git Graph。
5. 在 Mini Apps 画廊中打开该 MiniApp,选择仓库后即可查看 Git Graph。

### 权限说明

Expand Down
20 changes: 11 additions & 9 deletions MiniApp/Skills/miniapp-dev/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: miniapp-dev
description: Develops and maintains the BitFun MiniApp system (Zero-Dialect Runtime). Use when working on miniapp modules, toolbox scene, bridge scripts, agent tool (InitMiniApp), permission policy, or any code under src/crates/core/src/miniapp/ or src/web-ui/src/app/scenes/toolbox/. Also use when the user mentions MiniApp, toolbox, bridge, or zero-dialect.
description: 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.
---

# BitFun MiniApp V2 开发指南
Expand Down Expand Up @@ -52,14 +52,16 @@ src/crates/core/src/agentic/tools/implementations/
### 前端

```
src/web-ui/src/app/scenes/toolbox/
├── ToolboxScene.tsx / .scss
├── toolboxStore.ts
├── views/ GalleryView, AppRunnerView
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
└── useMiniAppList.ts
├── 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
Expand Down Expand Up @@ -213,7 +215,7 @@ body {

### 前端事件

后端 `miniapp-created` / `miniapp-updated` / `miniapp-deleted`,前端 `useMiniAppList` 监听刷新
后端 `miniapp-created` / `miniapp-updated` / `miniapp-deleted` / `miniapp-worker-*`,前端 `useMiniAppCatalogSync` 统一监听并刷新 store

## 场景注册检查清单

Expand Down
27 changes: 15 additions & 12 deletions MiniApp/Skills/miniapp-dev/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ AI 对话 → GenerateMiniApp Tool → MiniAppManager::create()
→ storage.rs 持久化 source + meta.json
→ compiler.rs 生成 compiled_html(注入 Bridge)
→ emit miniapp-created 事件
→ 前端 useMiniAppList 监听 → 刷新 GalleryView
→ 用户点击「打开」→ AppRunnerView → MiniAppRunner
→ 前端 useMiniAppCatalogSync 监听 → 刷新 MiniAppGalleryView
→ 用户点击「打开」→ MiniAppScene → MiniAppRunner
→ <iframe srcDoc={compiled_html}>
→ Bridge Script 拦截 require/fetch → postMessage
→ useMiniAppBridge 路由 → Tauri Commands → Rust 服务
Expand Down Expand Up @@ -129,23 +129,26 @@ struct MiniAppFsRequest {

## 前端状态管理

### toolboxStore (Zustand)
### miniAppStore (Zustand)
```typescript
{
activeView: 'gallery' | 'runner', // 当前视图
currentAppId: string | null, // runner 视图中的 app
apps: MiniAppMeta[], // 画廊列表
loading: boolean,
openApp(id), // 切换到 runner
backToGallery(), // 返回画廊
openedAppIds: string[], // 当前已打开的 MiniApp scene
runningWorkerIds: string[], // 当前运行中的 worker
openApp(id),
closeApp(id),
setRunningWorkerIds(ids),
markWorkerRunning(id),
markWorkerStopped(id),
}
```

### 事件驱动刷新
`useMiniAppList` hook:
- 组件挂载时加载列表
- 监听 `miniapp-created`, `miniapp-updated`, `miniapp-deleted` 事件
- 事件触发时自动重新加载列表
`useMiniAppCatalogSync` hook:
- 组件挂载时加载列表和运行中的 worker
- 监听 `miniapp-created`, `miniapp-updated`, `miniapp-deleted`, `miniapp-worker-restarted`, `miniapp-worker-stopped`
- 事件触发时统一刷新 store,导航入口与画廊共享同一份状态

## 工具卡片集成

Expand All @@ -160,4 +163,4 @@ TOOL_CARD_CONFIGS.set('ListMiniApps', { icon: List, displayName: '列出 MiniApp
卡片支持:
- 流式显示工具调用状态
- 完成后显示应用名/ID/数量
- "在工具箱中打开" 按钮(调用 `sceneManager.openScene('toolbox')`)
- "Open in Mini App" 按钮直达 `sceneManager.openScene(\`miniapp:${appId}\`)`
Loading
Loading