@monkey-mini-app/dsh-mini-app 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -0
- package/assets/apps-list.png +0 -0
- package/assets/complex-demo-app.png +0 -0
- package/assets/demo-app.png +0 -0
- package/assets/home.png +0 -0
- package/assets/sidebar-mode.png +0 -0
- package/lib/index.d.ts +3 -2
- package/lib/index.js +9 -9
- package/package.json +3 -2
- package/skills/monkey-mini-app/SKILL.md +9 -0
- package/skills/monkey-mini-app/references/contracts/donut-chart.md +2 -0
- package/skills/monkey-mini-app/references/contracts/gauge.md +2 -0
- package/skills/monkey-mini-app/references/contracts/progress-ring.md +2 -0
- package/skills/monkey-mini-app/references/contracts/radar-chart.md +2 -0
- package/skills/monkey-mini-app/references/contracts/sparkline.md +1 -0
- package/skills/monkey-mini-app/references/contracts/stacked-bar-chart.md +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @monkey-mini-app/dsh-mini-app
|
|
2
|
+
|
|
3
|
+
给 [DeepSeek Harness](https://github.com/deepseek-ai) 加一条 **「小程序」跑道**:让模型可以在对话里直接创建、运行、打开一个个小的 React 应用(`manifest.json` + `ui.tsx` + `main.api.ts`),它们以独立窗口的形式停在侧栏。
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
*安装后侧栏多出「小程序」入口。*
|
|
7
|
+
|
|
8
|
+
## 它能做什么
|
|
9
|
+
|
|
10
|
+
- 模型(或你)用一行 `mini_app_register` 就能**秒建一个 mini-app**,Host 在本机把它跑起来。
|
|
11
|
+
- 侧栏「小程序」面板是个**应用画廊**:打开、切换、钉到侧边、设置主题。
|
|
12
|
+
- 每个 mini-app 有独立的 `ui.tsx`(UI)+ `main.api.ts`(`ctx.llm`/`ctx.http`/`ctx.bash`/`ctx.agent`/`ctx.storage`…)。
|
|
13
|
+
- 打包即用:一个 dsh 插件就带齐 Host(AppsManager / git / Hono / UI 编译 / tools)+ React 面板 + 生成 skill。
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
*小程序画廊(5 个示例 app)。*
|
|
17
|
+
|
|
18
|
+

|
|
19
|
+
*打开一个 mini-app(能力实验室:LLM / Agent / 工具 / 网络 / 命令)。*
|
|
20
|
+
|
|
21
|
+

|
|
22
|
+
*mini-app 钉到侧栏(待办):对话在左、应用在右。*
|
|
23
|
+
|
|
24
|
+

|
|
25
|
+
*复杂 mini-app(AI 热点雷达:多源聚合 + LLM 分析 + 图表)。*
|
|
26
|
+
|
|
27
|
+
## 安装
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
dsh plugin --profile web add @monkey-mini-app/dsh-mini-app
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
然后打开 dsh web:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
dsh web --no-open # http://127.0.0.1:3080 ;apps host 默认 :17880
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
首次启动会自动初始化运行时配置(写出完整 `host.json`),侧栏即出现「小程序」入口。
|
|
40
|
+
|
|
41
|
+
## 使用
|
|
42
|
+
|
|
43
|
+
1. **打开**:侧栏点「小程序」→ 打开任一 app。
|
|
44
|
+
2. **生成**:让模型「做一个 xxx 小程序」,模型会按内置 skill 生成 `manifest.json` + `ui.tsx` + `main.api.ts`(模板在 `skills/monkey-mini-app/templates/`)。
|
|
45
|
+
3. **调用**:mini-app 的 `main.api.ts` 用 `defineDashboard({ api })` 暴露方法;`ui.tsx` 用 `useDashboardApi()` 的 `call(method, args)` 调它们。
|
|
46
|
+
4. **调试**:`mini_app_call` 冒烟、`mini_app_reload` 重编译、`mini_app_open` 打开。
|
|
47
|
+
|
|
48
|
+
## UI 组件库:参考而非规范
|
|
49
|
+
|
|
50
|
+
`@monkey-mini-app/ui` 提供现成组件(表格 / 表单 / 图表 / 弹窗 / 编辑器…),**是用来省事的,不是强制**。合适的场景直接用;需要独特视觉或自由发挥时,**用原生元素 + Tailwind classes 自行实现**也行(可混用)。详见 skill。
|
|
51
|
+
|
|
52
|
+
## 技术备注
|
|
53
|
+
|
|
54
|
+
- **插件入口**:导出 `apply(ctx, config?)`(Cordis)、常量 `name="monkey-mini-app"`、`inject=["tools"]`,以及 `DshCapabilities` / `DshLifecycle` / `DshThemeResource`。
|
|
55
|
+
- **client**:`@monkey-mini-app/dsh-mini-app/client` 导出 `FooterButton` / `createMiniAppPanel` / `appFrameUrl` / `appsOrigin`。
|
|
56
|
+
- **deps**:`@monkey-mini-app/host` / `panel` / `ui` 为运行时 `require`(external,不打进去),发布后仍从 npm 解析。
|
|
57
|
+
- **运行时配置**:首启自动 bootstrap 写完整 `host.json`(缺才建);`host.json` 已存在但损坏仍 fail loud。
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/assets/home.png
ADDED
|
Binary file
|
|
Binary file
|
package/lib/index.d.ts
CHANGED
|
@@ -6,8 +6,9 @@ type DshPluginConfig = {
|
|
|
6
6
|
/** Locate runtimeRoot from plugin config only when provided; else bootstrap seed path. */
|
|
7
7
|
declare function resolveRuntimeRoot(config?: DshPluginConfig): AbsolutePath;
|
|
8
8
|
/**
|
|
9
|
-
* Runtime load: read host.json
|
|
10
|
-
*
|
|
9
|
+
* Runtime load: read host.json.
|
|
10
|
+
* A missing file is bootstrapped on first run (so `dsh plugin add` just works);
|
|
11
|
+
* a present-but-corrupt host.json still fails loud (never silently patched).
|
|
11
12
|
*/
|
|
12
13
|
declare function loadPluginHostConfig(config?: DshPluginConfig): HostConfig;
|
|
13
14
|
|
package/lib/index.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import { createHost } from "@monkey-mini-app/host";
|
|
3
3
|
|
|
4
4
|
// src/apply-config.ts
|
|
5
|
+
import { mkdirSync, writeFileSync } from "fs";
|
|
5
6
|
import { homedir } from "os";
|
|
6
7
|
import path from "path";
|
|
7
8
|
import {
|
|
8
9
|
asAbsolutePath,
|
|
9
10
|
bootstrapHostConfig,
|
|
10
|
-
createHostI18n,
|
|
11
11
|
HostConfigError,
|
|
12
12
|
loadHostConfig,
|
|
13
13
|
WorkspacePaths
|
|
@@ -31,11 +31,6 @@ function resolveRuntimeRoot(config = {}) {
|
|
|
31
31
|
}
|
|
32
32
|
return bootstrapHostConfig({}).runtimeRoot;
|
|
33
33
|
}
|
|
34
|
-
function missingConfigError(file, cause) {
|
|
35
|
-
const i18n = createHostI18n("zh-CN");
|
|
36
|
-
const message = `${i18n.t("config.missingFile", { path: file })} ${i18n.t("config.missingHint")}`;
|
|
37
|
-
return new HostConfigError(message, { code: "HOST_CONFIG_NOT_FOUND", cause });
|
|
38
|
-
}
|
|
39
34
|
function loadPluginHostConfig(config = {}) {
|
|
40
35
|
const runtimeRoot = resolveRuntimeRoot(config);
|
|
41
36
|
const paths = new WorkspacePaths(runtimeRoot);
|
|
@@ -43,7 +38,12 @@ function loadPluginHostConfig(config = {}) {
|
|
|
43
38
|
return loadHostConfig(paths);
|
|
44
39
|
} catch (cause) {
|
|
45
40
|
if (cause instanceof HostConfigError && cause.code === "HOST_CONFIG_NOT_FOUND") {
|
|
46
|
-
|
|
41
|
+
const cfg = bootstrapHostConfig({ runtimeRoot });
|
|
42
|
+
mkdirSync(cfg.runtimeRoot, { recursive: true });
|
|
43
|
+
mkdirSync(paths.appsDir(), { recursive: true });
|
|
44
|
+
writeFileSync(paths.hostConfigFile(), `${JSON.stringify(cfg, null, 2)}
|
|
45
|
+
`);
|
|
46
|
+
return cfg;
|
|
47
47
|
}
|
|
48
48
|
throw cause;
|
|
49
49
|
}
|
|
@@ -729,7 +729,7 @@ var DshCapabilities = class {
|
|
|
729
729
|
};
|
|
730
730
|
|
|
731
731
|
// src/lifecycle.ts
|
|
732
|
-
import { cpSync, mkdirSync } from "fs";
|
|
732
|
+
import { cpSync, mkdirSync as mkdirSync2 } from "fs";
|
|
733
733
|
import { homedir as homedir2 } from "os";
|
|
734
734
|
import path3 from "path";
|
|
735
735
|
|
|
@@ -928,7 +928,7 @@ function registerListCtxTools(ctx, defineTool = null) {
|
|
|
928
928
|
}
|
|
929
929
|
}
|
|
930
930
|
function installSkillDir(src, dest) {
|
|
931
|
-
|
|
931
|
+
mkdirSync2(path3.dirname(dest), { recursive: true });
|
|
932
932
|
cpSync(src, dest, { recursive: true });
|
|
933
933
|
}
|
|
934
934
|
function defaultSkillDest() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monkey-mini-app/dsh-mini-app",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "DeepSeek Harness plugin: mini-app host wiring, panel, and skills",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"lib",
|
|
24
24
|
"cordis.patch.yml",
|
|
25
25
|
"tsup.config.ts",
|
|
26
|
-
"skills"
|
|
26
|
+
"skills",
|
|
27
|
+
"assets"
|
|
27
28
|
],
|
|
28
29
|
"scripts": {
|
|
29
30
|
"build": "rm -rf lib && tsup",
|
|
@@ -83,6 +83,15 @@ mini_app_reload({ appId }) // { ok, errors, compiled, committed? }
|
|
|
83
83
|
|
|
84
84
|
## UI(@monkey-mini-app/ui)
|
|
85
85
|
|
|
86
|
+
**组件库是「参考 / 便利」,不是硬性规范。** 它只是帮你省掉重复造轮子——合适的场景直接用,但**别为了用组件而用**。允许完全自由的发挥:
|
|
87
|
+
|
|
88
|
+
- **先判断**:这个 UI 有没有现成组件?**有且合适 → 用**(省 token、风格统一);**没有、或要独特视觉/交互、或用户明确要「自由发挥」→ 用原生元素(`div`/`span`/`button`/`input`/`table`/`svg`…)+ Tailwind classes 自行实现**,不用迁就组件库去硬凑。
|
|
89
|
+
- **可混用**:骨架(卡片/页头/弹窗)用库组件,细节或视觉特殊处用原生 + Tailwind。
|
|
90
|
+
- **自由发挥的边界**:原生元素 + Tailwind 随意;但 UI 仍**只能** import `react` / `@monkey-mini-app/ui` / `@monkeyagent/host` / 相对 `./lib`(编译器限制,**不能 import 任意 npm 包**)。需要图表/图标/编辑器等能力时从 `@monkey-mini-app/ui` 拿,或自己用 CSS/SVG 实现。
|
|
91
|
+
- **不用管的**:`UiProvider` host 自动包裹;布局用 Tailwind classes(库里没有 Stack/Text 这类布局件)。
|
|
92
|
+
|
|
93
|
+
下面是「常用姿势」示例,**不是唯一写法**——复杂/特殊 UI 完全可以全手写。
|
|
94
|
+
|
|
86
95
|
```tsx
|
|
87
96
|
import { useEffect, useState } from "react";
|
|
88
97
|
import { Button, Input, Card, CardContent, CardHeader, CardTitle, Textarea } from "@monkey-mini-app/ui";
|
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
| field | type | required | note |
|
|
12
12
|
|---|---|:---:|---|
|
|
13
13
|
| `center` | `string \| undefined` | | |
|
|
14
|
+
| `className` | `string \| undefined` | | |
|
|
14
15
|
| `config` | `ChartConfig` | ✓ | |
|
|
15
16
|
| `data` | `Slice[]` | ✓ | |
|
|
17
|
+
| `size` | `number \| undefined` | | |
|
|
16
18
|
|
|
17
19
|
## Types
|
|
18
20
|
|
|
@@ -10,9 +10,11 @@
|
|
|
10
10
|
|
|
11
11
|
| field | type | required | note |
|
|
12
12
|
|---|---|:---:|---|
|
|
13
|
+
| `className` | `string \| undefined` | | |
|
|
13
14
|
| `config` | `ChartConfig` | ✓ | |
|
|
14
15
|
| `data` | `{ label: string; value: number; }[]` | ✓ | |
|
|
15
16
|
| `dataKey` | `string \| undefined` | | |
|
|
17
|
+
| `size` | `number \| undefined` | | |
|
|
16
18
|
|
|
17
19
|
## Types
|
|
18
20
|
|