dsh-codex-subscription 2.4.2 → 2.5.0

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.en.md CHANGED
@@ -105,7 +105,7 @@ This plugin supports the latest DeepSeek Harness release recorded in its package
105
105
  2. Paste this package name, with its version, into the **Package name or address** field:
106
106
 
107
107
  ```text
108
- dsh-codex-subscription@2.4.2
108
+ dsh-codex-subscription@2.5.0
109
109
  ```
110
110
 
111
111
  3. Click **Install** and wait for completion. Follow the page instructions; save your work before restarting if requested.
@@ -220,11 +220,15 @@ Here the reference image is attached to the message and the model copies it on t
220
220
 
221
221
  The SVG runs have finer hair highlights, lace trim and lettering, and Sol was almost 9 minutes faster with SVG than stroke by stroke; Astra spent about 3 extra minutes on SVG for clearly richer detail. Neither model got the face shape right (too long and flat) or the small whale motif on the apron, though Sol's whale looks more like a whale.
222
222
 
223
- The full Chinese prompts for all three subjects are in the [Chinese README](README.md#从草图到作品).
223
+ **The same challenge again, with the model checking itself against the reference**
224
224
 
225
- Each example is a single run, not a measure of consistent quality. Sol Xhigh is much slower; Astra or a lower reasoning level is enough for everyday sketches.
225
+ Same prompt and the same way of attaching the image as above; the plugin just gives the model two more things. It can use `reference` to put the image attached in the chat onto the board as a hidden picture layer, and while previewing it can turn on `compare` (the drawing and the reference blended 50/50, so position errors show up as ghosting) and `grid` (a labelled line every 100 pixels). Same Astra Medium on the official desktop app, one run, no image generation: 20 min 57 s, 7 drawing layers and 686 native strokes. The model also generated hair strands and lace with scripts, and checked against the overlay several times while drawing, fixing lettering and lace overlaps.
226
226
 
227
- </details>
227
+ <table>
228
+ <tr><td><img src="docs/assets/sketch-niang-astra-compare.webp" alt="Astra Medium with overlay checks" width="380"><br><sub><b>Astra Medium</b> · 20 min 57 s · 686 strokes</sub></td><td><img src="docs/assets/sketch-niang-astra-overlay.webp" alt="The overlay preview the model saw" width="260"><br><sub>The overlay the model saw: ghosting on the lettering and hair edges is the error</sub></td></tr>
229
+ </table>
230
+
231
+ The face shape, hair flow, lace, hand and speech-bubble lettering are all closer to the reference than the two Astra runs above, at about twice the time of the SVG run. This is a single run; other prompts and references may behave differently.
228
232
 
229
233
  <details>
230
234
  <summary>View Images & sketch settings</summary>
package/README.md CHANGED
@@ -105,7 +105,7 @@
105
105
  2. 在 **包名或地址** 输入框中粘贴下面的包名(已带版本号):
106
106
 
107
107
  ```text
108
- dsh-codex-subscription@2.4.2
108
+ dsh-codex-subscription@2.5.0
109
109
  ```
110
110
 
111
111
  3. 点击 **安装**,等待安装完成;按页面提示操作,需要重启时先保存工作。
@@ -222,6 +222,16 @@ Sol Xhigh 约 28 分钟,Astra Low 约 5 分钟。两者都保留了主峰、
222
222
 
223
223
  SVG 版的发丝高光、蕾丝褶边和手写字更精细,Sol 用 SVG 还比逐笔绘制快了近 9 分钟;Astra 用 SVG 多花约 3 分钟,换来明显更丰富的细节。两个模型都没能画准脸型(偏长偏平)和围裙上的小鲸鱼图案,Sol 的鲸鱼更像鲸。
224
224
 
225
+ **同一题再跑一次:让模型自己叠图对照**
226
+
227
+ 这一次提示词和附件方式都和上面一样,只是插件多了两样东西:模型可以用 `reference` 把聊天里附的参考图放进画板(作为隐藏的图片图层),并且在预览时打开 `compare`(把画作和参考图各占 50% 叠在一起,位置偏差会显示成重影)和 `grid`(每 100 像素一条带数字的网格)。同一题、同一个 Astra Medium,在官方桌面版上跑了一次,没有调用生图,共 20 分 57 秒、7 个绘画图层、686 条原生笔画;模型还用脚本批量生成了发丝和花边,并在画的过程中多次叠图检查、修正文字和蕾丝遮挡。
228
+
229
+ <table>
230
+ <tr><td><img src="docs/assets/sketch-niang-astra-compare.webp" alt="Astra Medium 叠图对照版" width="380"><br><sub><b>Astra Medium</b> · 20 分 57 秒 · 686 笔</sub></td><td><img src="docs/assets/sketch-niang-astra-overlay.webp" alt="模型看到的叠图对照预览" width="260"><br><sub>模型看到的叠图预览:文字和发丝边缘的重影就是偏差</sub></td></tr>
231
+ </table>
232
+
233
+ 脸型、长发走向、蕾丝、手和气泡字都比上面的两个 Astra 版更接近参考图,耗时约是 SVG 版的两倍。这是单次运行,不同提示词和参考图的效果可能不同。
234
+
225
235
  <details>
226
236
  <summary>展开三道题的完整提示词</summary>
227
237
 
package/lib/client.js CHANGED
@@ -3327,11 +3327,22 @@ window.__ModuleLoader__.load({
3327
3327
  }
3328
3328
  if (request.documentId !== current.documentId) throw Error("Document changed; inspect again");
3329
3329
  if (pending || adapter.busy()) throw Error("Sketch is being edited; retry after it settles");
3330
- if (request.action === "preview") return {
3331
- ...current,
3332
- png: await adapter.preview()
3333
- };
3334
- if (!["apply", "save"].includes(request.action)) throw Error("Unknown sketch action");
3330
+ if (request.action === "preview") {
3331
+ for (const key of ["compare", "grid"]) if (request[key] !== void 0 && typeof request[key] !== "boolean") throw Error(`${key} must be true or false`);
3332
+ return {
3333
+ ...current,
3334
+ png: await adapter.preview({
3335
+ compare: request.compare === true,
3336
+ grid: request.grid === true
3337
+ }),
3338
+ ...request.grid ? { gridStep: 100 } : {}
3339
+ };
3340
+ }
3341
+ if (![
3342
+ "apply",
3343
+ "save",
3344
+ "reference"
3345
+ ].includes(request.action)) throw Error("Unknown sketch action");
3335
3346
  if (typeof request.requestId !== "string" || !request.requestId.length || request.requestId.length > 100) throw Error("A unique requestId is required");
3336
3347
  const key = `${current.documentId}:${request.requestId}`, fingerprint = JSON.stringify({
3337
3348
  ...request,
@@ -3361,6 +3372,14 @@ window.__ModuleLoader__.load({
3361
3372
  layer: l.id,
3362
3373
  id: s.id
3363
3374
  })));
3375
+ } else if (request.action === "reference") {
3376
+ if (typeof request.image !== "string" || !/^data:image\/(png|jpeg|webp);base64,/.test(request.image) || request.image.length > 19e5) throw Error("A PNG, JPEG or WebP reference image is required");
3377
+ pending = true;
3378
+ try {
3379
+ await adapter.addReference(request.image, typeof request.name === "string" ? request.name.slice(0, 40) : "reference");
3380
+ } finally {
3381
+ pending = false;
3382
+ }
3364
3383
  } else {
3365
3384
  if (request.name !== void 0 && (typeof request.name !== "string" || request.name.length > 60)) throw Error("Invalid draft name");
3366
3385
  pending = true;
@@ -3645,7 +3664,7 @@ window.__ModuleLoader__.load({
3645
3664
  name: row.name
3646
3665
  });
3647
3666
  };
3648
- const importImage = async (file) => {
3667
+ const importImage = async (file, { visible = true } = {}) => {
3649
3668
  if (file.name?.toLowerCase().endsWith(".psd") || file.name?.toLowerCase().endsWith(".dsh-sketch.json")) {
3650
3669
  if (file.size > 32 * 1024 * 1024) throw Error("File exceeds 32 MB");
3651
3670
  if (file.name.toLowerCase().endsWith(".psd") && !await confirmPsd()) return;
@@ -3663,7 +3682,7 @@ window.__ModuleLoader__.load({
3663
3682
  const layer = {
3664
3683
  id: doc.current.nextId,
3665
3684
  name: file.name?.slice(0, 40) || t("sketchImport"),
3666
- visible: true,
3685
+ visible,
3667
3686
  strokes: [],
3668
3687
  image: {
3669
3688
  src: image.src,
@@ -3678,7 +3697,7 @@ window.__ModuleLoader__.load({
3678
3697
  doc.current = {
3679
3698
  ...doc.current,
3680
3699
  nextId: layer.id + 1,
3681
- active: layer.id,
3700
+ active: visible ? layer.id : doc.current.active,
3682
3701
  layers: [...doc.current.layers, layer]
3683
3702
  };
3684
3703
  schedule();
@@ -3882,6 +3901,60 @@ window.__ModuleLoader__.load({
3882
3901
  }
3883
3902
  }
3884
3903
  //#endregion
3904
+ //#region src/sketch-preview.js
3905
+ const GRID_STEP = 100;
3906
+ function composeSketchPreview({ doc, images, width, height, options = {}, makeSurface, paintLayers }) {
3907
+ const surface = makeSurface(width, height), context = surface.getContext("2d");
3908
+ if (options.compare) {
3909
+ if (!doc.layers.some((layer) => layer.image)) throw Error("compare needs a reference picture layer on the board; ask the user to add the reference with the pictures button");
3910
+ const reference = makeSurface(width, height), drawing = makeSurface(width, height);
3911
+ paintLayers(reference.getContext("2d"), {
3912
+ ...doc,
3913
+ layers: doc.layers.map((layer) => ({
3914
+ ...layer,
3915
+ strokes: [],
3916
+ visible: Boolean(layer.image)
3917
+ }))
3918
+ }, /* @__PURE__ */ new Map(), width, height, void 0, images);
3919
+ paintLayers(drawing.getContext("2d"), {
3920
+ ...doc,
3921
+ layers: doc.layers.map((layer) => ({
3922
+ ...layer,
3923
+ image: void 0
3924
+ }))
3925
+ }, /* @__PURE__ */ new Map(), width, height, void 0, images);
3926
+ context.drawImage(reference, 0, 0);
3927
+ context.globalAlpha = .5;
3928
+ context.drawImage(drawing, 0, 0);
3929
+ context.globalAlpha = 1;
3930
+ } else paintLayers(context, doc, /* @__PURE__ */ new Map(), width, height, void 0, images);
3931
+ if (options.grid) paintGrid(context, width, height);
3932
+ return surface.toDataURL("image/png");
3933
+ }
3934
+ function paintGrid(context, width, height) {
3935
+ context.save();
3936
+ context.lineWidth = 1;
3937
+ context.strokeStyle = "rgba(214,0,120,0.45)";
3938
+ context.fillStyle = "rgba(214,0,120,0.9)";
3939
+ context.font = "12px sans-serif";
3940
+ context.textBaseline = "top";
3941
+ for (let x = GRID_STEP; x < width; x += GRID_STEP) {
3942
+ context.beginPath();
3943
+ context.moveTo(x + .5, 0);
3944
+ context.lineTo(x + .5, height);
3945
+ context.stroke();
3946
+ context.fillText(String(x), x + 3, 2);
3947
+ }
3948
+ for (let y = GRID_STEP; y < height; y += GRID_STEP) {
3949
+ context.beginPath();
3950
+ context.moveTo(0, y + .5);
3951
+ context.lineTo(width, y + .5);
3952
+ context.stroke();
3953
+ context.fillText(String(y), 3, y + 2);
3954
+ }
3955
+ context.restore();
3956
+ }
3957
+ //#endregion
3885
3958
  //#region src/sketch-files.jsx
3886
3959
  function SketchFiles({ save, load, fresh, importImage, download, hasContent, disabled, t, runOperation }) {
3887
3960
  const [open, setOpen] = (0, react.useState)(false), [rows, setRows] = (0, react.useState)([]), [name, setName] = (0, react.useState)(""), [remove, setRemove] = (0, react.useState)(null), [working, setWorking] = (0, react.useState)(false);
@@ -4101,7 +4174,7 @@ window.__ModuleLoader__.load({
4101
4174
  }
4102
4175
  //#endregion
4103
4176
  //#region src/sketch-agent-run.js
4104
- function createSketchAgentRun({ execute, open, changed, busy = () => false, previewEnabled = () => false, idleMs = 18e4 }) {
4177
+ function createSketchAgentRun({ execute, open, changed, busy = () => false, idleMs = 18e4 }) {
4105
4178
  let state = "idle", generation = 0, runNumber = 0, pending = false, runId, timer, completed;
4106
4179
  const update = (next) => {
4107
4180
  state = next;
@@ -4165,15 +4238,10 @@ window.__ModuleLoader__.load({
4165
4238
  ...value,
4166
4239
  runId
4167
4240
  };
4168
- const result = previewEnabled() ? await execute({
4169
- action: "preview",
4170
- documentId: value.documentId
4171
- }) : value;
4172
- if (version !== generation) throw Error("Drawing interrupted");
4173
4241
  completed = {
4174
4242
  key: JSON.stringify(request),
4175
4243
  value: {
4176
- ...result,
4244
+ ...value,
4177
4245
  runId
4178
4246
  }
4179
4247
  };
@@ -4294,7 +4362,7 @@ window.__ModuleLoader__.load({
4294
4362
  }
4295
4363
  //#endregion
4296
4364
  //#region src/sketch-studio.jsx
4297
- function SketchStudio({ open, agentEnabled, agentPreview, onOpen, onClose, attachSketch, enabled, t, incoming, sessionId, rpc, sessionState }) {
4365
+ function SketchStudio({ open, agentEnabled, onOpen, onClose, attachSketch, enabled, t, incoming, sessionId, rpc, sessionState }) {
4298
4366
  const localSession = (0, react.useRef)(null);
4299
4367
  const psdImport = useSketchImportConfirm(t);
4300
4368
  localSession.current ??= sessionState ?? createSketchSessionState();
@@ -4591,7 +4659,6 @@ window.__ModuleLoader__.load({
4591
4659
  setNoticeHidden(false);
4592
4660
  },
4593
4661
  available: () => enabled && agentEnabled,
4594
- previewEnabled: () => agentPreview,
4595
4662
  open: () => onOpen(),
4596
4663
  busy: () => operationGate.current.running || busy || Boolean(active.current) || Boolean(textEdit) || sizeGesture.current,
4597
4664
  document: () => doc.current,
@@ -4625,9 +4692,24 @@ window.__ModuleLoader__.load({
4625
4692
  setError("");
4626
4693
  schedule();
4627
4694
  },
4628
- preview: async () => {
4629
- paint();
4630
- return canvas.current.toDataURL("image/png");
4695
+ preview: async (options) => {
4696
+ const w = doc.current.width ?? 1024, h = doc.current.height ?? 1024;
4697
+ return composeSketchPreview({
4698
+ doc: doc.current,
4699
+ images: images.current,
4700
+ width: w,
4701
+ height: h,
4702
+ options,
4703
+ paintLayers: paintSketchLayers,
4704
+ makeSurface: (width, height) => Object.assign(document.createElement("canvas"), {
4705
+ width,
4706
+ height
4707
+ })
4708
+ });
4709
+ },
4710
+ addReference: async (dataUrl, name) => {
4711
+ const blob = await (await fetch(dataUrl)).blob();
4712
+ await importImage(new File([blob], name, { type: blob.type }), { visible: false });
4631
4713
  },
4632
4714
  save
4633
4715
  });
@@ -4636,8 +4718,7 @@ window.__ModuleLoader__.load({
4636
4718
  execute: (request) => agentSession.current(request),
4637
4719
  open: () => agentAdapter.current.open(),
4638
4720
  changed: (state) => agentAdapter.current.changed?.(state),
4639
- busy: () => agentAdapter.current.busy(),
4640
- previewEnabled: () => agentAdapter.current.previewEnabled()
4721
+ busy: () => agentAdapter.current.busy()
4641
4722
  });
4642
4723
  (0, react.useEffect)(() => {
4643
4724
  if (!enabled || !agentEnabled || !hydrated) return;
@@ -5317,7 +5398,6 @@ window.__ModuleLoader__.load({
5317
5398
  }), [registerOpen]);
5318
5399
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SketchStudio, {
5319
5400
  sessionState,
5320
- agentPreview: settings.imageSketchAgentPreview,
5321
5401
  agentEnabled: settings.imageSketchAgent,
5322
5402
  onOpen: () => {
5323
5403
  opener.current = document.activeElement;
@@ -5713,10 +5793,6 @@ window.__ModuleLoader__.load({
5713
5793
  sketchRun_failed: "绘制失败",
5714
5794
  sketchRunStop: "停止绘制",
5715
5795
  sketchRunResume: "允许继续绘制",
5716
- sketchAgentPreview: "完成后返回预览 · Beta",
5717
- sketchAgentPreviewHint: "默认关闭;完成绘制后向模型返回画布图片,会增加图片输入用量。",
5718
- sketchAgentPreview_on: "开启",
5719
- sketchAgentPreview_off: "关闭",
5720
5796
  sketchAgent_on: "开启",
5721
5797
  sketchAgent_off: "关闭",
5722
5798
  imageSettings: "图片",
@@ -5922,7 +5998,6 @@ window.__ModuleLoader__.load({
5922
5998
  diagnosticsHint: "遇到问题时生成报告,可复制后用于反馈。不含登录凭据和账号标识。",
5923
5999
  sketchCanvasSetting: "画板入口",
5924
6000
  sketchAgentSetting: "Agent 绘图",
5925
- sketchAgentPreviewSetting: "完成后返回预览",
5926
6001
  quotaShowIndicator: "显示额度",
5927
6002
  quotaIndicatorHint: "输入框只显示图标,点击查看详情。关闭时暂停续航采样。",
5928
6003
  quotaForecastOptional: "续航预测 · 实验",
@@ -6279,10 +6354,6 @@ window.__ModuleLoader__.load({
6279
6354
  sketchRun_failed: "Drawing failed",
6280
6355
  sketchRunStop: "Stop drawing",
6281
6356
  sketchRunResume: "Allow drawing again",
6282
- sketchAgentPreview: "Preview on completion · Beta",
6283
- sketchAgentPreviewHint: "Off by default. Returns the canvas to the model on completion, adding image input usage.",
6284
- sketchAgentPreview_on: "On",
6285
- sketchAgentPreview_off: "Off",
6286
6357
  sketchAgent_on: "On",
6287
6358
  sketchAgent_off: "Off",
6288
6359
  imageSettings: "Images",
@@ -6488,7 +6559,6 @@ window.__ModuleLoader__.load({
6488
6559
  diagnosticsHint: "Generate a report to copy into a support request. Sign-in credentials and account identifiers are excluded.",
6489
6560
  sketchCanvasSetting: "Board entry",
6490
6561
  sketchAgentSetting: "Agent drawing",
6491
- sketchAgentPreviewSetting: "Return preview on completion",
6492
6562
  quotaShowIndicator: "Show quota",
6493
6563
  quotaIndicatorHint: "Show an icon in the composer; click for details. Hiding it pauses forecast sampling.",
6494
6564
  quotaForecastOptional: "Runway forecast · Experimental",
@@ -7796,8 +7866,7 @@ window.__ModuleLoader__.load({
7796
7866
  imageViewer: true,
7797
7867
  imageAnnotations: true,
7798
7868
  imageSketch: false,
7799
- imageSketchAgent: false,
7800
- imageSketchAgentPreview: false
7869
+ imageSketchAgent: false
7801
7870
  });
7802
7871
  function readImageFeatures(value = {}) {
7803
7872
  return Object.fromEntries(Object.entries(IMAGE_FEATURE_DEFAULTS).map(([key, fallback]) => [key, typeof value?.[key] === "boolean" ? value[key] : fallback]));
@@ -8603,7 +8672,7 @@ window.__ModuleLoader__.load({
8603
8672
  }
8604
8673
  //#endregion
8605
8674
  //#region src/version.js
8606
- const PACKAGE_VERSION = "2.4.2";
8675
+ const PACKAGE_VERSION = "2.5.0";
8607
8676
  //#endregion
8608
8677
  //#region src/client-recovery.js
8609
8678
  async function recoveryCall(rpc, endpoint, payload = {}, timeoutMs = 1e4) {
@@ -9202,7 +9271,6 @@ window.__ModuleLoader__.load({
9202
9271
  imageEntryPoints: ["imageShortcut"],
9203
9272
  sketchCanvas: ["imageSketch"],
9204
9273
  sketchAgent: ["imageSketchAgent"],
9205
- sketchAgentPreview: ["imageSketchAgentPreview"],
9206
9274
  imageBrowsing: ["imageViewer", "imageAnnotations"]
9207
9275
  });
9208
9276
  function imageGroupValue(snapshot, group) {