@y1x1n/dsh-prompt-optimizer 0.3.15 → 0.3.16

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
@@ -103,11 +103,19 @@ dsh plugin --profile web remove @y1x1n/dsh-prompt-optimizer
103
103
 
104
104
  ## Compatibility
105
105
 
106
- > **This version targets DeepSeek Harness `0.1.2-rc.1`** | backward compatible with `0.1.0-rc.7` and above | newer alpha builds are unverified.
107
- > This annotation is maintained in every Release note from v0.3.15 onward; earlier Release notes have been retroactively annotated.
108
-
109
- - Development baseline: `@deepseek-ai/*` **0.1.0-rc.7** (matching the packages bundled with `npx @deepseek-ai/dsh@0.1.0-rc.7`); verified on the **0.1.0-rc.8** runtime (2026-08-20, Windows, real-profile install + Web routes / client bundle / session-history RPC / end-to-end LLM call), re-verified on **0.1.1-rc.2** (2026-08-27, Windows: `--dump-config` composition layer, route registration, client bundle all healthy), and adapted + verified on **0.1.2-rc.1** (2026-09-05: 0.1.2-rc.1 rewrote the `dsh-settings` API — plugin 0.3.15+ uses the new `SettingsProvider.installSection` interface; real-profile smoke test passed).
110
- - **dsh-settings API adaptation**: the standalone function `installSettingsSection(ctx, ...)` from 0.1.0-rc.x was removed in 0.1.2-rc.1, replaced by the `installSection(...)` method on the `ctx.settings` service instance. 0.3.15+ awaits the service via `ctx.inject(['settings'])` before mounting; when the settings service is absent (test environments / older versions) it falls back to the composition-layer config, matching the old behavior. **0.3.15+ requires dsh ≥0.1.2-rc.1; to run on 0.1.0-rc.x / 0.1.1-rc.x, use 0.3.14.**
106
+ > **This version (v0.3.16) targets DeepSeek Harness**:
107
+ >
108
+ > | dsh version | Optimize route / model calls | Settings page (incl. GitHub link) | Composer button / result panel |
109
+ > |---|---|---|---|
110
+ > | **0.1.2-rc.1 / 0.1.2-alpha.5** | ✅ verified | ✅ verified | ✅ verified |
111
+ > | **0.1.1-rc.2 and below** (0.1.0-rc.7+) | ✅ verified | ✅ verified | ✅ verified |
112
+ >
113
+ > One build covers 0.1.0-rc.7 through 0.1.2; this annotation is maintained in every Release note from v0.3.15 onward, and earlier Release notes have been retroactively annotated.
114
+
115
+ - Development baseline: `@deepseek-ai/*` **0.1.0-rc.7**; verified on **0.1.0-rc.8** (2026-08-20, Windows, real-profile install + Web routes / client bundle / session-history RPC / end-to-end LLM call), re-verified on **0.1.1-rc.2** (2026-08-27), and adapted + verified on **0.1.2-rc.1 / 0.1.2-alpha.5** (2026-09-05/06, real-profile end-to-end smoke tests: composition layer, route SSE, client bundle, composer button and result panel, settings card).
116
+ - **dsh-settings API compatibility layer**: the 0.1.2 line rewrote the settings API (standalone `installSettingsSection` removed, replaced by the `installSection` method on the `ctx.settings` service instance). 0.3.16+ feature-detects at runtime: uses the new interface when present, otherwise an inline equivalent (register + watch + unload fallback); when the settings service is absent it falls back to the composition-layer config.
117
+ - **Client slot props dual form**: since 0.1.2 the composer slots are session-scoped — components read session/draft state via standard hooks (`useInput`/`useSession`), and registration uses the official two-layer shape (register inside an inject callback on the derived context, with an `inject(sessionId)` hook). Components dispatch on the props shape (hooks on 0.1.2, direct snapshots on older hosts), so both hosts share one build.
118
+ - **Client bundle registration id**: the loader id in `lib/client.js` must equal the plugin npm package name (the host's client-modules validates registration against it); the client inject list no longer names `dsh-client-runtime`, which 0.1.2 merged away.
111
119
  - Protocol contract: `/dsh-prompt-optimizer/optimize` returns 400/405/409/413 as plain JSON on pre-check failure and switches to an SSE stream on success (model errors arrive as `error` events); `/dsh-prompt-optimizer/test-model` **always returns HTTP 200** with an `ok` field in the body (a probe is application-level semantics, deliberately not mapped to transport status codes) — integrate against `ok`, not the status code.
112
120
  - The HTTP carrier service name has drifted between releases (`httpServer` in the npm 0.0.1-rc.x type packages, `webServer` in the 0.1.0-rc.x runtime): the plugin waits on both names via `ctx.inject` with no static hard dependency — if the name changes again, only this plugin's routes fail to register (with a log warning after 10s); the Harness startup is never dragged down.
113
121
  - Client and Host must be the same version (the SSE protocol is a private contract): after upgrading, restart `dsh web` and refresh the browser.
package/README.md CHANGED
@@ -103,11 +103,19 @@ dsh plugin --profile web remove @y1x1n/dsh-prompt-optimizer
103
103
 
104
104
  ## 兼容性
105
105
 
106
- > **当前版本适配 DeepSeek Harness `0.1.2-rc.1`** | 向下兼容 `0.1.0-rc.7` 及以上 | 向上未在更新的 alpha 版本上验证。
107
- > 此标注从 v0.3.15 起在每个 Release 说明中固定维护;更早 Release 的说明已回溯补注。
108
-
109
- - 开发基线:`@deepseek-ai/*` **0.1.0-rc.7**(与 `npx @deepseek-ai/dsh@0.1.0-rc.7` 内置包一致);已在 **0.1.0-rc.8** 运行时实测通过(2026-08-20,Windows,真实 profile 安装 + Web 路由/客户端 bundle/会话历史 RPC/端到端 LLM 调用),在 **0.1.1-rc.2** 上复测通过(2026-08-27,Windows:`--dump-config` 组合层、路由注册、client bundle 均正常),并在 **0.1.2-rc.1** 上完成适配与实测(2026-09-05:0.1.2-rc.1 重写了 `dsh-settings` API,插件自 0.3.15 起改用 `SettingsProvider.installSection` 新接口,真实 profile 冒烟通过)。
110
- - **dsh-settings API 适配**:0.1.0-rc.x 的独立函数 `installSettingsSection(ctx, ...)` 在 0.1.2-rc.1 移除,改为 `ctx.settings` 服务实例上的 `installSection(...)` 方法。0.3.15+ 经 `ctx.inject(['settings'])` 等待服务再挂载;settings 服务缺席(测试环境/更老版本)时自动回落组合层配置,行为与旧版一致。**0.3.15+ 需要 dsh ≥0.1.2-rc.1;如需在 0.1.0-rc.x / 0.1.1-rc.x 上运行,请使用 0.3.14。**
106
+ > **当前版本(v0.3.16)适配 DeepSeek Harness**:
107
+ >
108
+ > | dsh 版本 | 优化路由 / 模型调用 | 设置页(含 GitHub 入口) | 发送栏按钮 / 结果面板 |
109
+ > |---|---|---|---|
110
+ > | **0.1.2-rc.1 / 0.1.2-alpha.5** | ✅ 实测 | ✅ 实测 | ✅ 实测 |
111
+ > | **0.1.1-rc.2 及以下**(0.1.0-rc.7+) | ✅ 实测 | ✅ 实测 | ✅ 实测 |
112
+ >
113
+ > 同一份构建覆盖 0.1.0-rc.7 至 0.1.2 全线;此标注自 v0.3.15 起在每个 Release 说明中固定维护,更早 Release 的说明已回溯补注。
114
+
115
+ - 开发基线:`@deepseek-ai/*` **0.1.0-rc.7**;已实测通过 **0.1.0-rc.8**(2026-08-20,Windows,真实 profile 安装 + Web 路由/客户端 bundle/会话历史 RPC/端到端 LLM 调用)、复测通过 **0.1.1-rc.2**(2026-08-27)、适配并通过 **0.1.2-rc.1 与 0.1.2-alpha.5**(2026-09-05/06,真实 profile 端到端冒烟:组合层注入、路由 SSE、client bundle、发送栏按钮与结果面板、设置卡片)。
116
+ - **dsh-settings API 兼容层**:0.1.2 线重写了设置 API(独立函数 `installSettingsSection` 移除,改为 `ctx.settings` 服务的 `installSection` 方法)。0.3.16+ 运行时按能力探测自动分派:新 API 存在则走新接口,否则内联等价实现(register+watch+卸载回落),settings 服务整体缺席时回落组合层配置。
117
+ - **客户端槽位 props 双形态**:0.1.2 起 composer 槽位改为 session scope,组件经 standard hooks(`useInput`/`useSession`)读取会话与草稿状态,注册需采用「注入回调内 scope 化注册 + `inject(sessionId)` 钩子」的官方双层形态。组件按 props 形态自动分派(0.1.2 走 hooks,旧版读直传快照),两种宿主共用同一份构建。
118
+ - **client bundle 注册 id**:`lib/client.js` 的 loader id 必须等于插件 npm 包名(宿主 client-modules 按包名校验注册);client 注入列表已随 0.1.2 移除已合并的 `dsh-client-runtime`。
111
119
  - HTTP 载体服务名在发布版间漂移过(npm 0.0.1-rc.x 类型包叫 `httpServer`,0.1.0-rc.x 运行时叫 `webServer`):本插件用 `ctx.inject` 同时等待两个名字,且不做静态硬依赖——即使服务名再次变化,也只会使本插件的路由不注册(10 秒后日志告警),不会拖垮整个 Harness 启动。
112
120
  - **客户端协议口径**:`/dsh-prompt-optimizer/optimize` 预校验失败返回 400/405/409/413(普通 JSON),成功后进入 SSE 流,模型错误经 `error` 事件传达;`/dsh-prompt-optimizer/test-model` **无论成败一律 HTTP 200**,由 body 的 `ok` 字段区分(探活是应用层语义,刻意不走传输层状态码)——对接方请以 `ok` 为准。
113
121
  - 客户端与 Host 需同版本(SSE 协议是私有约定):升级插件后请重启 `dsh web` 并刷新浏览器页面。
package/lib/client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  window.__ModuleLoader__.load({
2
- id: "dsh-prompt-optimizer",
2
+ id: "@y1x1n/dsh-prompt-optimizer",
3
3
  factory: (require) => {
4
4
  var module = { exports: {} };
5
5
  var exports = module.exports;
@@ -268,7 +268,9 @@ function createOptimizeButton(controller) {
268
268
  return function OptimizeButton(props) {
269
269
  const state = (0, import_react2.useSyncExternalStore)(controller.subscribe, controller.getSnapshot);
270
270
  const t = useT();
271
- const draft = props.input.draft;
271
+ const p = props;
272
+ const input = p.useInput ? p.useInput((s) => s) : p.input;
273
+ const draft = input?.draft ?? "";
272
274
  const empty = !draft.trim();
273
275
  const loading = state.status === "loading";
274
276
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { display: "inline-flex" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
@@ -279,7 +281,7 @@ function createOptimizeButton(controller) {
279
281
  style: { ...buttonStyle, ...empty || loading ? { opacity: 0.45, cursor: "not-allowed" } : {} },
280
282
  disabled: empty || loading,
281
283
  title: empty ? t("button.titleEmpty") : t("button.title"),
282
- onClick: () => void controller.optimize(draft, props.sessionId),
284
+ onClick: () => void controller.optimize(draft, p.sessionId),
283
285
  children: [
284
286
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SparkleIcon, { spinning: loading }),
285
287
  loading ? t("button.optimizing") : t("button.optimize")
@@ -779,7 +781,11 @@ function createResultDock(controller) {
779
781
  const [copied, setCopied] = (0, import_react3.useState)(false);
780
782
  const [analysisOpen, setAnalysisOpen] = (0, import_react3.useState)(true);
781
783
  const [undoneFlash, setUndoneFlash] = (0, import_react3.useState)(false);
782
- const owns = state.open && state.last?.sessionId === props.sessionId;
784
+ const p = props;
785
+ const input = (p.useInput ? p.useInput((s) => s) : p.input) ?? {};
786
+ const session = (p.useSession ? p.useSession((s) => s) : p.session) ?? {};
787
+ const inputActions = p.inputActions;
788
+ const owns = state.open && state.last?.sessionId === p.sessionId;
783
789
  (0, import_react3.useEffect)(() => {
784
790
  if (!owns) return;
785
791
  const onKey = (event) => {
@@ -791,9 +797,9 @@ function createResultDock(controller) {
791
797
  return () => document.removeEventListener("keydown", onKey);
792
798
  }, [owns]);
793
799
  const applied = state.applied;
794
- const draft = props.input.draft;
795
- const running = Boolean(props.session?.running);
796
- const queued = props.session?.queue?.length ?? 0;
800
+ const draft = input.draft ?? "";
801
+ const running = Boolean(session.running);
802
+ const queued = session.queue?.length ?? 0;
797
803
  const prevRef = (0, import_react3.useRef)({ running, queued });
798
804
  (0, import_react3.useEffect)(() => {
799
805
  const prev = prevRef.current;
@@ -854,12 +860,12 @@ function createResultDock(controller) {
854
860
  const onReplace = () => {
855
861
  if (!result) return;
856
862
  const nextDraft = state.last?.prefix ? `${state.last.prefix} ${result.optimized}` : result.optimized;
857
- controller.markApplied({ backup: props.input.draft, text: nextDraft });
858
- props.inputActions.setDraft(nextDraft);
863
+ controller.markApplied({ backup: input.draft ?? "", text: nextDraft });
864
+ inputActions?.setDraft(nextDraft);
859
865
  };
860
866
  const onUndo = () => {
861
867
  if (!applied) return;
862
- props.inputActions.setDraft(applied.backup);
868
+ inputActions?.setDraft(applied.backup);
863
869
  controller.clearApplied();
864
870
  setUndoneFlash(true);
865
871
  };
@@ -1467,20 +1473,32 @@ function apply(ctx) {
1467
1473
  // R21:看门狗 = 设置超时秒数 + 5s 余量(正常时 Host 的超时错误先到达,文案更友好)。
1468
1474
  getWatchdogMs: () => ((scope.getSnapshot().value?.timeoutSeconds ?? 120) + 5) * 1e3
1469
1475
  });
1470
- ctx.slots.inject(
1471
- "conversation.input.right",
1472
- () => ctx.slots.register(
1473
- { name: "conversation.input.right", id: "prompt-optimizer", order: 30 },
1474
- createOptimizeButton(controller)
1475
- )
1476
- );
1477
- ctx.slots.inject(
1478
- "conversation.input.dock",
1479
- () => ctx.slots.register(
1480
- { name: "conversation.input.dock", id: "prompt-optimizer", order: 30 },
1481
- createResultDock(controller)
1482
- )
1483
- );
1476
+ ctx.inject(["slots", "connection", "remote", "settingsScope"], (scopeCtx) => {
1477
+ scopeCtx.slots.inject(
1478
+ "conversation.input.right",
1479
+ () => scopeCtx.slots.register(
1480
+ {
1481
+ name: "conversation.input.right",
1482
+ id: "prompt-optimizer",
1483
+ order: 30,
1484
+ inject: () => ({})
1485
+ },
1486
+ createOptimizeButton(controller)
1487
+ )
1488
+ );
1489
+ scopeCtx.slots.inject(
1490
+ "conversation.input.dock",
1491
+ () => scopeCtx.slots.register(
1492
+ {
1493
+ name: "conversation.input.dock",
1494
+ id: "prompt-optimizer",
1495
+ order: 30,
1496
+ inject: () => ({})
1497
+ },
1498
+ createResultDock(controller)
1499
+ )
1500
+ );
1501
+ });
1484
1502
  ctx.slots.inject(
1485
1503
  "settings.plugin.item",
1486
1504
  () => ctx.slots.register(
package/lib/index.js CHANGED
@@ -415,12 +415,25 @@ function apply(ctx, config) {
415
415
  ctx.inject(["settings"], (sctx) => {
416
416
  const settings = sctx.settings;
417
417
  if (!settings) return;
418
- settings.installSection(ctx, NS, Config, config, {
418
+ const hooks = {
419
419
  setSource: (source) => {
420
420
  current = source;
421
421
  },
422
422
  onChange: () => {
423
423
  }
424
+ };
425
+ if (typeof settings.installSection === "function") {
426
+ settings.installSection(ctx, NS, Config, config, hooks);
427
+ return;
428
+ }
429
+ const scope = settings.register(NS, Config, { base: config });
430
+ hooks.setSource(() => scope.get());
431
+ hooks.onChange();
432
+ const disposeWatch = scope.watch(() => hooks.onChange());
433
+ ctx.effect(() => () => {
434
+ disposeWatch();
435
+ hooks.setSource(() => config);
436
+ hooks.onChange();
424
437
  });
425
438
  });
426
439
  warnUnknownEnumConfig(config);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y1x1n/dsh-prompt-optimizer",
3
- "version": "0.3.15",
3
+ "version": "0.3.16",
4
4
  "description": "DeepSeek Harness 插件:在发送栏旁一键分析并优化提示词(复用当前会话模型)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -50,7 +50,6 @@
50
50
  "platform": "web",
51
51
  "inject": [
52
52
  "@deepseek-ai/dsh-client-connection",
53
- "@deepseek-ai/dsh-client-runtime",
54
53
  "@deepseek-ai/dsh-client-ui-conversation",
55
54
  "@deepseek-ai/dsh-client-ui-settings",
56
55
  "@deepseek-ai/dsh-client-ui-settings-plugins"