@dickpy/dsh-imagegen 1.0.0 → 1.0.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 CHANGED
@@ -33,44 +33,49 @@ DeepSeek Harness (DSH) Web GUI 的 AI 生图插件。它通过宿主进程安全
33
33
 
34
34
  ## 快速开始
35
35
 
36
- ### 1. 构建插件
36
+ > 前置条件:已安装 DSH(`npm i -g @deepseek-ai/dsh`)与 pnpm。
37
+ > 装完统一**重启 dsh web**,侧边栏即出现「AI 生图」入口,再到「设置 → 插件 → 可配置」填写 API 地址与密钥。
37
38
 
38
- 前置条件:Node.js 20+、pnpm,以及一个可运行的 DSH Web profile。
39
+ ### 方式一:让 AI 帮你安装(最省事)
40
+
41
+ 把下面提示词直接粘贴给 **DSH**(或 Codex / 其他 coding agent)执行即可:
42
+
43
+ ```text
44
+ 用 dsh plugin --profile web add @dickpy/dsh-imagegen@1.0.0 安装 AI 生图插件(profile 名按实际修改),完成后重启 dsh web。
45
+ ```
46
+
47
+ ### 方式二:npm 安装(推荐)
39
48
 
40
49
  ```bash
41
- git clone https://github.com/dickpy/dsh-imagegen.git
42
- cd dsh-imagegen
43
- pnpm install
44
- pnpm run build
50
+ dsh plugin --profile web add @dickpy/dsh-imagegen@1.0.0
45
51
  ```
46
52
 
47
- ### 2. 接入 DSH Web profile
53
+ dsh 会自动把插件注册进 profile 的 bundle 清单(无需手动改 cordis.patch.yml),重启 dsh web 即可。
48
54
 
49
- DSH Web profile 的 `package.json` 中加入本地依赖:
55
+ ### 方式三:聚合包(tarball)安装
50
56
 
51
- ```json
52
- {
53
- "dependencies": {
54
- "@dickpy/dsh-imagegen": "link:E:/dsh-plugin"
55
- }
56
- }
57
+ 从 [GitHub Releases](https://github.com/dickpy/dsh-imagegen/releases) 下载发布产物
58
+ (如 `dsh-local-dsh-imagegen-1.0.0.tgz`),然后:
59
+
60
+ ```bash
61
+ dsh plugin --profile web add <下载路径>/dsh-local-dsh-imagegen-1.0.0.tgz
57
62
  ```
58
63
 
59
- 然后在该 profile 的 `cordis.patch.yml` 追加插件条目:
64
+ 重启 dsh web。
60
65
 
61
- ```yaml
62
- - insert:
63
- - id: imagegen
64
- name: '@dickpy/dsh-imagegen'
65
- ```
66
+ ### 方式四:源码开发启动(最后的选择)
66
67
 
67
- 在 profile 目录执行安装并重启 DSH:
68
+ 需要改插件源码时才用这种方式:
68
69
 
69
70
  ```bash
71
+ git clone https://github.com/dickpy/dsh-imagegen.git
72
+ cd dsh-imagegen
70
73
  pnpm install
74
+ pnpm run build
75
+ dsh plugin --profile web add link:/绝对路径/dsh-imagegen
71
76
  ```
72
77
 
73
- `lib` 内的宿主与客户端 bundle 变更需要重新构建;开发时可运行 `pnpm run watch` 持续构建。
78
+ 重启 dsh web;开发时可运行 `pnpm run watch` 持续构建,bundle 变更由 client-hmr 自动热更。
74
79
 
75
80
  ## 配置 API
76
81
 
@@ -121,6 +126,14 @@ pnpm run build # 构建宿主与 Web bundle
121
126
  pnpm run watch # 持续构建
122
127
  ```
123
128
 
129
+ ## 📬 反馈与提问
130
+
131
+ - **遇到 Bug**:请使用 [Bug 报告模板](https://github.com/dickpy/dsh-imagegen/issues/new?template=bug_report.yml) 提交,
132
+ 并附带插件版本、DSH 版本、安装方式与复现步骤(**请勿在 issue 中粘贴 API 密钥**)。
133
+ - **功能建议**:请使用 [功能建议模板](https://github.com/dickpy/dsh-imagegen/issues/new?template=feature_request.yml) 提交,
134
+ 描述使用场景与期望效果。
135
+ - **安装 / 使用问题**:先查阅本文档「快速开始」与「配置 API」章节。
136
+
124
137
  ## 许可证
125
138
 
126
139
  [Apache-2.0](./LICENSE)
Binary file
package/lib/client.js CHANGED
@@ -64,24 +64,21 @@ window.__ModuleLoader__.load({
64
64
  var ImageGenApi = class {
65
65
  /** Forward one generate request to the host proxy. */
66
66
  async generate(request) {
67
- return { images: (await readEnvelope(await fetch(GENERATE_API, {
67
+ const body = await readEnvelope(await fetch(GENERATE_API, {
68
68
  method: "POST",
69
69
  headers: { "content-type": "application/json" },
70
70
  body: JSON.stringify(request)
71
- }))).images };
71
+ }));
72
+ return {
73
+ images: body.images,
74
+ ...body.history === void 0 ? {} : { history: body.history },
75
+ ...body.historyError === void 0 ? {} : { historyError: body.historyError }
76
+ };
72
77
  }
73
78
  /** List the host-persisted history (newest first). */
74
79
  async historyList() {
75
80
  return (await readEnvelope(await fetch(HISTORY_API.list, { method: "POST" }))).entries;
76
81
  }
77
- /** Append one generation to the host-persisted history. */
78
- async historyAppend(entry) {
79
- return (await readEnvelope(await fetch(HISTORY_API.append, {
80
- method: "POST",
81
- headers: { "content-type": "application/json" },
82
- body: JSON.stringify({ entry })
83
- }))).entries;
84
- }
85
82
  /** Remove one history entry by id. */
86
83
  async historyRemove(id) {
87
84
  return (await readEnvelope(await fetch(HISTORY_API.remove, {
@@ -288,7 +285,7 @@ window.__ModuleLoader__.load({
288
285
  "preview.prev": "Previous",
289
286
  "preview.next": "Next",
290
287
  "preview.index": "{index} / {total}",
291
- "config.missing": "API not configured: open \"Settings → Web UI Plugins\" and fill in api_url and api_key for AI Image.",
288
+ "config.missing": "API not configured: open \"Settings → Plugins Configurable\" and fill in api_url and api_key for AI Image.",
292
289
  "config.configured": "Connected to {url}",
293
290
  "config.disabled": "The plugin is disabled — re-enable it in Settings.",
294
291
  "settings.title": "AI Image (dsh-imagegen)",
@@ -355,85 +352,85 @@ window.__ModuleLoader__.load({
355
352
  document.head.appendChild(tag);
356
353
  }
357
354
  var panel_module_css_default = {
355
+ "optionRow": "Yvqh9W_optionRow",
356
+ "historyPrompt": "Yvqh9W_historyPrompt",
357
+ "uploadHint": "Yvqh9W_uploadHint",
358
+ "optionGrid": "Yvqh9W_optionGrid",
359
+ "historyList": "Yvqh9W_historyList",
360
+ "paramLabel": "Yvqh9W_paramLabel",
361
+ "panelTitle": "Yvqh9W_panelTitle",
362
+ "modelLabel": "Yvqh9W_modelLabel",
358
363
  "referenceActions": "Yvqh9W_referenceActions",
359
- "banner": "Yvqh9W_banner",
360
- "historyThumb": "Yvqh9W_historyThumb",
361
- "configScroll": "Yvqh9W_configScroll",
364
+ "modePill": "Yvqh9W_modePill",
362
365
  "reference": "Yvqh9W_reference",
363
- "card": "Yvqh9W_card",
364
- "grid": "Yvqh9W_grid",
365
- "download": "Yvqh9W_download",
366
- "zoomHint": "Yvqh9W_zoomHint",
366
+ "modelSelect": "Yvqh9W_modelSelect",
367
367
  "lightbox": "Yvqh9W_lightbox",
368
- "optionPill": "Yvqh9W_optionPill",
369
- "prompt": "Yvqh9W_prompt",
370
- "lightboxImage": "Yvqh9W_lightboxImage",
371
368
  "promptCount": "Yvqh9W_promptCount",
372
- "optionRow": "Yvqh9W_optionRow",
373
- "modelWrap": "Yvqh9W_modelWrap",
374
- "canvasError": "Yvqh9W_canvasError",
375
- "lightboxFigure": "Yvqh9W_lightboxFigure",
376
- "dshImageGenSpin": "Yvqh9W_dshImageGenSpin",
377
- "lightboxDownload": "Yvqh9W_lightboxDownload",
378
- "referenceImage": "Yvqh9W_referenceImage",
379
- "historyAction": "Yvqh9W_historyAction",
380
- "optionGrid": "Yvqh9W_optionGrid",
381
- "studio": "Yvqh9W_studio",
382
- "entryLabel": "Yvqh9W_entryLabel",
383
- "panelHeader": "Yvqh9W_panelHeader",
384
- "historyHeader": "Yvqh9W_historyHeader",
385
- "historyThumbPlaceholder": "Yvqh9W_historyThumbPlaceholder",
386
- "historyInfo": "Yvqh9W_historyInfo",
387
- "modeRow": "Yvqh9W_modeRow",
388
369
  "canvasHistoryTag": "Yvqh9W_canvasHistoryTag",
389
- "image": "Yvqh9W_image",
390
- "canvasState": "Yvqh9W_canvasState",
391
- "panelSubtitle": "Yvqh9W_panelSubtitle",
392
- "promptFooter": "Yvqh9W_promptFooter",
393
- "canvasMeta": "Yvqh9W_canvasMeta",
394
- "historyTitle": "Yvqh9W_historyTitle",
395
- "canvasEmptyIcon": "Yvqh9W_canvasEmptyIcon",
396
- "panelTitle": "Yvqh9W_panelTitle",
397
- "paramLabel": "Yvqh9W_paramLabel",
398
- "lightboxIndex": "Yvqh9W_lightboxIndex",
399
- "historyPrompt": "Yvqh9W_historyPrompt",
400
370
  "imageCaption": "Yvqh9W_imageCaption",
401
- "canvasStateTitle": "Yvqh9W_canvasStateTitle",
402
- "config": "Yvqh9W_config",
403
- "uploadHint": "Yvqh9W_uploadHint",
404
- "historyMain": "Yvqh9W_historyMain",
405
- "historyClear": "Yvqh9W_historyClear",
406
- "modelSelect": "Yvqh9W_modelSelect",
407
- "paramGroup": "Yvqh9W_paramGroup",
408
- "generateButton": "Yvqh9W_generateButton",
371
+ "card": "Yvqh9W_card",
372
+ "canvas": "Yvqh9W_canvas",
409
373
  "historyItem": "Yvqh9W_historyItem",
410
- "modelLabel": "Yvqh9W_modelLabel",
411
- "historyMeta": "Yvqh9W_historyMeta",
374
+ "canvasBody": "Yvqh9W_canvasBody",
375
+ "optionPill": "Yvqh9W_optionPill",
376
+ "canvasState": "Yvqh9W_canvasState",
377
+ "footer": "Yvqh9W_footer",
378
+ "download": "Yvqh9W_download",
379
+ "lightboxImage": "Yvqh9W_lightboxImage",
380
+ "uploadIcon": "Yvqh9W_uploadIcon",
412
381
  "bigSpinner": "Yvqh9W_bigSpinner",
413
- "modePill": "Yvqh9W_modePill",
382
+ "lightboxDownload": "Yvqh9W_lightboxDownload",
414
383
  "history": "Yvqh9W_history",
384
+ "promptFooter": "Yvqh9W_promptFooter",
385
+ "lightboxIndex": "Yvqh9W_lightboxIndex",
415
386
  "hiddenFile": "Yvqh9W_hiddenFile",
416
- "lightboxCaption": "Yvqh9W_lightboxCaption",
387
+ "historyClear": "Yvqh9W_historyClear",
417
388
  "generateInner": "Yvqh9W_generateInner",
418
- "imageCard": "Yvqh9W_imageCard",
419
- "view": "Yvqh9W_view",
420
389
  "panel": "Yvqh9W_panel",
421
- "historyEmpty": "Yvqh9W_historyEmpty",
422
- "spinner": "Yvqh9W_spinner",
423
- "paramHint": "Yvqh9W_paramHint",
424
- "lightboxNav": "Yvqh9W_lightboxNav",
390
+ "historyTitle": "Yvqh9W_historyTitle",
391
+ "view": "Yvqh9W_view",
425
392
  "canvasStateHint": "Yvqh9W_canvasStateHint",
426
- "canvas": "Yvqh9W_canvas",
427
- "uploadBox": "Yvqh9W_uploadBox",
428
- "entry": "Yvqh9W_entry",
429
- "canvasBody": "Yvqh9W_canvasBody",
430
- "footer": "Yvqh9W_footer",
393
+ "image": "Yvqh9W_image",
394
+ "panelSubtitle": "Yvqh9W_panelSubtitle",
395
+ "historyInfo": "Yvqh9W_historyInfo",
396
+ "canvasMeta": "Yvqh9W_canvasMeta",
397
+ "historyHeader": "Yvqh9W_historyHeader",
431
398
  "entryIcon": "Yvqh9W_entryIcon",
432
- "historyList": "Yvqh9W_historyList",
433
- "lightboxClose": "Yvqh9W_lightboxClose",
399
+ "banner": "Yvqh9W_banner",
400
+ "generateButton": "Yvqh9W_generateButton",
401
+ "lightboxNav": "Yvqh9W_lightboxNav",
402
+ "historyMain": "Yvqh9W_historyMain",
403
+ "configScroll": "Yvqh9W_configScroll",
404
+ "paramHint": "Yvqh9W_paramHint",
434
405
  "lightboxMeta": "Yvqh9W_lightboxMeta",
435
- "uploadIcon": "Yvqh9W_uploadIcon",
436
- "historyActions": "Yvqh9W_historyActions"
406
+ "config": "Yvqh9W_config",
407
+ "panelHeader": "Yvqh9W_panelHeader",
408
+ "canvasError": "Yvqh9W_canvasError",
409
+ "entry": "Yvqh9W_entry",
410
+ "modelWrap": "Yvqh9W_modelWrap",
411
+ "studio": "Yvqh9W_studio",
412
+ "modeRow": "Yvqh9W_modeRow",
413
+ "prompt": "Yvqh9W_prompt",
414
+ "historyActions": "Yvqh9W_historyActions",
415
+ "imageCard": "Yvqh9W_imageCard",
416
+ "dshImageGenSpin": "Yvqh9W_dshImageGenSpin",
417
+ "lightboxClose": "Yvqh9W_lightboxClose",
418
+ "uploadBox": "Yvqh9W_uploadBox",
419
+ "historyEmpty": "Yvqh9W_historyEmpty",
420
+ "canvasStateTitle": "Yvqh9W_canvasStateTitle",
421
+ "lightboxFigure": "Yvqh9W_lightboxFigure",
422
+ "lightboxCaption": "Yvqh9W_lightboxCaption",
423
+ "paramGroup": "Yvqh9W_paramGroup",
424
+ "entryLabel": "Yvqh9W_entryLabel",
425
+ "historyAction": "Yvqh9W_historyAction",
426
+ "canvasEmptyIcon": "Yvqh9W_canvasEmptyIcon",
427
+ "zoomHint": "Yvqh9W_zoomHint",
428
+ "historyMeta": "Yvqh9W_historyMeta",
429
+ "grid": "Yvqh9W_grid",
430
+ "historyThumbPlaceholder": "Yvqh9W_historyThumbPlaceholder",
431
+ "spinner": "Yvqh9W_spinner",
432
+ "historyThumb": "Yvqh9W_historyThumb",
433
+ "referenceImage": "Yvqh9W_referenceImage"
437
434
  };
438
435
  //#endregion
439
436
  //#region src/client/ImageGenPanel.tsx
@@ -611,7 +608,8 @@ window.__ModuleLoader__.load({
611
608
  quality,
612
609
  n: count,
613
610
  detail,
614
- ...mode === "edit" && refImage !== null ? { image: refImage.dataUrl } : {}
611
+ ...mode === "edit" && refImage !== null ? { image: refImage.dataUrl } : {},
612
+ ...mode === "edit" && refImage !== null ? { refName: refImage.name } : {}
615
613
  };
616
614
  setGenerating(true);
617
615
  setError(null);
@@ -621,22 +619,8 @@ window.__ModuleLoader__.load({
621
619
  const result = await api.generate(request);
622
620
  setImages(result.images);
623
621
  setViewingHistoryId(null);
624
- const entry = {
625
- id: `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`,
626
- createdAt: Date.now(),
627
- mode,
628
- model,
629
- prompt: promptText,
630
- size,
631
- quality,
632
- detail,
633
- n: count,
634
- images: result.images,
635
- ...mode === "edit" && refImage !== null ? { refName: refImage.name } : {}
636
- };
637
- try {
638
- setHistory(await api.historyAppend(entry));
639
- } catch {}
622
+ if (result.history !== void 0) setHistory(result.history);
623
+ if (result.historyError !== void 0) setError(result.historyError);
640
624
  } catch (caught) {
641
625
  setError(errorMessage(caught));
642
626
  } finally {
@@ -1786,32 +1770,32 @@ window.__ModuleLoader__.load({
1786
1770
  document.head.appendChild(tag);
1787
1771
  }
1788
1772
  var settings_card_module_css_default = {
1789
- "discard": "i1cc5G_discard",
1790
- "readOnly": "i1cc5G_readOnly",
1791
- "chevron": "i1cc5G_chevron",
1792
- "save": "i1cc5G_save",
1793
- "reset": "i1cc5G_reset",
1794
- "header": "i1cc5G_header",
1795
- "headText": "i1cc5G_headText",
1796
- "label": "i1cc5G_label",
1773
+ "card": "i1cc5G_card",
1774
+ "badges": "i1cc5G_badges",
1797
1775
  "select": "i1cc5G_select",
1798
- "footer": "i1cc5G_footer",
1799
- "inputInvalid": "i1cc5G_inputInvalid",
1776
+ "body": "i1cc5G_body",
1777
+ "headText": "i1cc5G_headText",
1778
+ "name": "i1cc5G_name",
1779
+ "chevron": "i1cc5G_chevron",
1780
+ "pending": "i1cc5G_pending",
1781
+ "description": "i1cc5G_description",
1800
1782
  "badge": "i1cc5G_badge",
1783
+ "reset": "i1cc5G_reset",
1801
1784
  "input": "i1cc5G_input",
1802
- "card": "i1cc5G_card",
1803
- "badges": "i1cc5G_badges",
1804
1785
  "hint": "i1cc5G_hint",
1786
+ "readOnly": "i1cc5G_readOnly",
1787
+ "header": "i1cc5G_header",
1805
1788
  "chevronOpen": "i1cc5G_chevronOpen",
1806
- "body": "i1cc5G_body",
1807
1789
  "field": "i1cc5G_field",
1808
- "pending": "i1cc5G_pending",
1809
1790
  "notExposed": "i1cc5G_notExposed",
1810
1791
  "head": "i1cc5G_head",
1792
+ "footer": "i1cc5G_footer",
1811
1793
  "invalid": "i1cc5G_invalid",
1794
+ "discard": "i1cc5G_discard",
1795
+ "save": "i1cc5G_save",
1796
+ "inputInvalid": "i1cc5G_inputInvalid",
1812
1797
  "failed": "i1cc5G_failed",
1813
- "name": "i1cc5G_name",
1814
- "description": "i1cc5G_description"
1798
+ "label": "i1cc5G_label"
1815
1799
  };
1816
1800
  //#endregion
1817
1801
  //#region src/client/SettingsCard.tsx