dsh-ws-recency 0.20.0 → 0.21.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.
Files changed (4) hide show
  1. package/README.md +11 -10
  2. package/client.js +151 -62
  3. package/index.js +1 -1
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -120,17 +120,18 @@ DSH 原生的置顶只把会话顶到**它所属工作区分组的第一行**,
120
120
 
121
121
  ## 八、交接到新会话
122
122
 
123
- 长期会话的上下文迟早会满,被动压缩往往比"换个新会话、带上交接"更差。交接全程在**对话里**完成,不会弹窗:
123
+ 长期会话的上下文迟早会满,被动压缩往往比"换个新会话、带上交接"更差。交接全程在对话里完成,不弹窗:
124
124
 
125
- 1. 每轮回复底部的动作行(复制 / 点赞 / 分支那一排)里点 **交接到新会话**:插件把一段固定指令放进输入框并尝试直接发送(发不出去就在卡片上提示你按回车);
126
- 2. 当前会话的 AI 按指令输出一个 ```handoff 代码块——**只写文档路径和要点,不粘贴文档内容**;
127
- 3. 插件每 2 秒读一次这个会话的最新回复,抓到代码块后,**在该轮回复下方**出现一张卡片:可编辑预览 + 三个按钮;
128
- 4. **交接到新会话**:在当前工作区开一个新会话,把"开场要求 + 交接块"预填进输入框,你按回车开始;**继续补充**回到输入框接着打磨(新一轮回复会刷新卡片);**放弃交接**收起卡片。
129
- 5. 轮询最多 5 分钟后自动收起,避免一直挂着。
125
+ 1. 每轮回复底部的动作行(复制 / 点赞 / 分支那一排)里点 **交接到新会话**:插件把交接指令放进输入框并尝试直接发送(发不出去会在卡片上提示你按回车);
126
+ 2. 当前会话的 AI 输出一个 ```handoff 代码块——**只写文档路径和要点,不粘贴文档内容**;
127
+ 3. 抓到代码块后,**在该轮回复下方**出现一张问询卡片,和工具向用户提问的形态一致:
128
+ - **确认,交接到新会话**(默认选中):当前工作区开新会话,内容预填进输入框;
129
+ - **不满意,重新生成一版**:让当前会话按同样的要求再写一份;
130
+ - 底部输入框:填写调整意见(例如"多写接口约束、少写历史"),提交后按这些要求重写;
131
+ - 「查看内容」展开只读预览,「放弃交接」收起卡片。
132
+ 4. 交接内容另存一份到 `~/.hypers-work/.wsr/handoff/<sessionId>-<时间>.md`。
130
133
 
131
- - 交接内容另存一份到 `~/.hypers-work/.wsr/handoff/<sessionId>-<时间>.md`;
132
- - 新会话是草稿形态:侧栏显示为「新会话」,发出第一条消息后才转正;
133
- - 「…」菜单里的同名入口保留。
134
+ 细节想改不用在这里改——新会话的输入框里直接调更顺手。轮询最多 5 分钟自动收起。
134
135
 
135
136
  ## 设置
136
137
 
@@ -168,7 +169,7 @@ dsh plugin --profile <profile> add github:chyxhtc/dsh-ws-recency
168
169
  或固定版本的预构建包:
169
170
 
170
171
  ```powershell
171
- dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.20.0/dsh-ws-recency-0.20.0.tgz
172
+ dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.21.0/dsh-ws-recency-0.21.0.tgz
172
173
  ```
173
174
 
174
175
  装完把 `dsh-ws-recency` 加进 `~/.hypers-work/profiles/<profile>/package.json` 的 `dsh.profile.bundles`,重启应用。
package/client.js CHANGED
@@ -140,6 +140,14 @@
140
140
  ".wsr-footer-action{display:flex;box-sizing:border-box;flex:none;align-items:center;justify-content:flex-start;gap:8px;width:calc(100% + 4px);min-width:0;height:42px;margin:4px -2px;padding:0 10px 0 8px;border:0;border-radius:12px;background:transparent;color:var(--dsw-alias-label-primary);font-family:inherit;font-size:14px;line-height:22px;text-align:left;cursor:pointer}",
141
141
  ".wsr-footer-action:hover{background:var(--dsw-alias-interactive-bg-hover)}",
142
142
  ".wsr-page{display:flex;flex-direction:column;gap:10px;padding:16px 18px;min-width:0;box-sizing:border-box;height:100%;overflow:auto}",
143
+ ".wsr-handoff-option{display:flex;align-items:flex-start;gap:8px;padding:6px 8px;border-radius:8px;cursor:pointer}",
144
+ ".wsr-handoff-option:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.06))}",
145
+ ".wsr-handoff-option input{margin-top:2px}",
146
+ ".wsr-handoff-option-text{display:flex;flex-direction:column;gap:2px;min-width:0}",
147
+ ".wsr-handoff-option-title{font-size:13px;color:var(--dsw-alias-label-primary)}",
148
+ ".wsr-handoff-option-desc{font-size:11px;color:var(--dsw-alias-label-tertiary)}",
149
+ ".wsr-handoff-extra{width:100%;box-sizing:border-box;min-height:56px;max-height:140px;resize:vertical;font:inherit;font-size:12px;line-height:1.6;padding:8px 10px;border-radius:8px;border:.5px solid var(--dsw-alias-border-l2,rgba(255,255,255,.16));background:var(--dsw-alias-bg-layer-1,#1b1b1b);color:var(--dsw-alias-label-primary,#e6e6e6)}",
150
+ ".wsr-handoff-body{white-space:pre-wrap;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;line-height:1.6;max-height:220px;overflow:auto;padding:8px 10px;border-radius:8px;background:var(--dsw-alias-bg-layer-1,#1b1b1b)}",
143
151
  ".wsr-handoff-card{display:flex;flex-direction:column;gap:8px;margin:8px 0;padding:12px 14px;border:.5px solid var(--dsw-alias-border-l2,rgba(255,255,255,.16));border-radius:10px;background:var(--dsw-alias-bg-layer-2,rgba(255,255,255,.04))}",
144
152
  ".wsr-handoff-head{font-size:12px;color:var(--dsw-alias-label-secondary)}",
145
153
  ".wsr-handoff-actions{display:flex;gap:6px;align-items:center;white-space:nowrap}",
@@ -282,6 +290,17 @@
282
290
  "handoff.noService": "没能自动开新会话,交接内容已复制到剪贴板,手动新建会话粘贴即可。",
283
291
  "handoff.preamble": "以下是一个会话交接说明,来自上一个会话。请先按「文档引用」逐份阅读文档,再结合要点接续工作;已经完成的部分不要重做。",
284
292
  "handoff.footnote": "交接内容会另存一份到 .wsr/handoff/,方便追溯。",
293
+ "handoff.preparing": "正在准备交接,等这一轮回复写完…",
294
+ "handoff.pressEnter": "指令已放进输入框,请按回车发送(自动发送没有生效)。",
295
+ "handoff.cancel": "放弃交接",
296
+ "handoff.confirmDesc": "带着这份内容在当前工作区开一个新会话",
297
+ "handoff.regen": "不满意,重新生成一版",
298
+ "handoff.regenDesc": "让当前会话按同样的要求再写一份",
299
+ "handoff.extraPlaceholder": "补充调整意见(填了就按这些要求重写,例如:多写接口约束、少写历史)",
300
+ "handoff.preview": "查看内容",
301
+ "handoff.submit": "提交",
302
+ "handoff.regeneratePrompt": "这份交接说明需要重写。请按最初同样的要求再输出一份,同样写进 ```handoff 代码块,路径与要点保持精炼。",
303
+ "handoff.adjustPrompt": "请按下面的补充要求重写交接说明,保持 ```handoff 代码块格式:",
285
304
  "move.title": "移动到工作区",
286
305
  "move.warning": "只移动会话本身:它在旧工作区里创建或修改的文件不会跟着走,仍留在原目录。",
287
306
  "move.note": "会话属于哪个工作区,由它创建时的目录决定;移动会改写会话记录的 cwd,把日志搬到新工作区目录,旧日志备份在 .trash/ws-recency。",
@@ -402,6 +421,17 @@
402
421
  "handoff.noService": "Could not open a Session automatically; the handoff was copied to the clipboard.",
403
422
  "handoff.preamble": "Below is a handoff note from the previous Session. Read the referenced documents first, then continue from the notes; do not redo what is already done.",
404
423
  "handoff.footnote": "A copy is saved under .wsr/handoff/ for later reference.",
424
+ "handoff.preparing": "Preparing the handoff; waiting for this turn to finish…",
425
+ "handoff.pressEnter": "The instruction is in the composer; press Enter to send it (automatic send did not take).",
426
+ "handoff.cancel": "Cancel handoff",
427
+ "handoff.confirmDesc": "Open a new Session in this workspace with this note",
428
+ "handoff.regen": "Not good enough, regenerate",
429
+ "handoff.regenDesc": "Ask the current Session to write it again with the same rules",
430
+ "handoff.extraPlaceholder": "Adjustments (if filled, the note is rewritten with them: more constraints, less history, …)",
431
+ "handoff.preview": "Show note",
432
+ "handoff.submit": "Submit",
433
+ "handoff.regeneratePrompt": "Rewrite the handoff note with the same rules as before, again inside a ```handoff block.",
434
+ "handoff.adjustPrompt": "Rewrite the handoff note following these adjustments, keeping the ```handoff block format:",
405
435
  "move.title": "Move to workspace",
406
436
  "move.warning": "Only the session moves: files it created or changed in the old workspace stay where they are.",
407
437
  "move.note": "A session belongs to the workspace of the directory it was created in. Moving rewrites the stored cwd, relocates the log and keeps the old one as a backup in .trash/ws-recency.",
@@ -1874,7 +1904,31 @@
1874
1904
 
1875
1905
  /* ------------------------------ handoff ------------------------------ */
1876
1906
 
1877
- var handoffStore = null;
1907
+ /* A plain observable, not a slot store: the turn card and the turn action are
1908
+ different slot instances, and a store handle would hand each its own copy. */
1909
+ var handoffState = { sessionId: "", phase: "idle", block: "", needsEnter: false };
1910
+ var handoffListeners = [];
1911
+
1912
+ function currentHandoffState() {
1913
+ return handoffState;
1914
+ }
1915
+
1916
+ function setHandoffState(patch) {
1917
+ handoffState = Object.assign({}, handoffState, patch);
1918
+ var listeners = handoffListeners.slice();
1919
+ for (var i = 0; i < listeners.length; i += 1) {
1920
+ try { listeners[i](handoffState); } catch (error) { /* a dead component */ }
1921
+ }
1922
+ }
1923
+
1924
+ function subscribeHandoff(listener) {
1925
+ handoffListeners.push(listener);
1926
+ return function () {
1927
+ var at = handoffListeners.indexOf(listener);
1928
+ if (at !== -1) handoffListeners.splice(at, 1);
1929
+ };
1930
+ }
1931
+
1878
1932
  var handoffTimer = null;
1879
1933
  var handoffBaseline = 0;
1880
1934
  var handoffTries = 0;
@@ -1896,9 +1950,8 @@
1896
1950
  }
1897
1951
 
1898
1952
  /** Write text into the composer and send it, if the editor is reachable. */
1899
- function sendInstruction(sessionId) {
1900
- var text = handoffInstruction();
1901
- if (typeof document === "undefined") return false;
1953
+ function sendToSession(text) {
1954
+ if (typeof document === "undefined" || typeof text !== "string" || text === "") return false;
1902
1955
  var seat = typeof document.querySelector === "function" ? document.querySelector("[data-composer-seat]") : null;
1903
1956
  if (seat === null || seat === undefined) return false;
1904
1957
  var editor = null;
@@ -1959,9 +2012,7 @@
1959
2012
  handoffSession = null;
1960
2013
  handoffBaseline = 0;
1961
2014
  handoffTries = 0;
1962
- if (handoffStore !== null && handoffStore !== undefined) {
1963
- try { handoffStore.actions.setIdle(); } catch (error) { /* store gone */ }
1964
- }
2015
+ setHandoffState({ sessionId: "", phase: "idle", block: "", needsEnter: false });
1965
2016
  }
1966
2017
 
1967
2018
  function handoffBlockOf(text) {
@@ -1989,14 +2040,14 @@
1989
2040
  if (replies > handoffBaseline) {
1990
2041
  var found = handoffBlockOf(answer.text);
1991
2042
  if (found !== "") {
1992
- handoffStore.actions.setReady(found);
2043
+ setHandoffState({ sessionId: sessionId, phase: "ready", block: found, needsEnter: false });
1993
2044
  return;
1994
2045
  }
1995
2046
  handoffBaseline = replies;
1996
2047
  }
1997
2048
  }
1998
2049
  if (handoffTries > 150) {
1999
- handoffStore.actions.setIdle();
2050
+ setHandoffState({ sessionId: "", phase: "idle", block: "", needsEnter: false });
2000
2051
  handoffSession = null;
2001
2052
  return;
2002
2053
  }
@@ -2017,10 +2068,9 @@
2017
2068
 
2018
2069
  /** The turn action: send the instruction and wait for the block. */
2019
2070
  function startHandoff(sessionId) {
2020
- if (handoffStore === null || handoffStore === undefined) return;
2021
2071
  if (typeof sessionId !== "string" || sessionId === "") return;
2022
- var sent = sendInstruction(sessionId);
2023
- handoffStore.actions.setRunning(sessionId, sent);
2072
+ var sent = sendToSession(handoffInstruction());
2073
+ setHandoffState({ sessionId: sessionId, phase: "running", block: "", needsEnter: sent !== true });
2024
2074
  watchHandoff(sessionId);
2025
2075
  }
2026
2076
 
@@ -2051,50 +2101,115 @@
2051
2101
  });
2052
2102
  }
2053
2103
 
2104
+ /** Ask the current Session to rewrite the handoff with the user's adjustments. */
2105
+ function rewriteHandoff(sessionId, extra) {
2106
+ var text = extra.trim() === "" ? t("handoff.regeneratePrompt") : t("handoff.adjustPrompt") + "\n\n" + extra.trim();
2107
+ var sent = sendToSession(text);
2108
+ setHandoffState({ sessionId: sessionId, phase: "running", block: "", needsEnter: sent !== true });
2109
+ handoffBaseline = 0;
2110
+ handoffTries = 0;
2111
+ handoffSession = sessionId;
2112
+ watchHandoff(sessionId);
2113
+ }
2114
+
2054
2115
  /**
2055
- * The handoff card, rendered in the turn tail: it appears only for the
2056
- * Session that started the flow, and only once a block has been produced.
2116
+ * The handoff question card.
2117
+ *
2118
+ * Two mutually exclusive choices and one free-text field, the same shape as a
2119
+ * tool asking the user a question: confirm and carry over, regenerate, or say
2120
+ * what to change. The note itself is read-only here - detail edits belong in
2121
+ * the new Session's composer.
2057
2122
  */
2058
2123
  function HandoffTailCard(props) {
2059
2124
  var sessionId = props !== undefined && props !== null && typeof props.sessionId === "string" ? props.sessionId : "";
2060
- var state = typeof props.useStore === "function" ? props.useStore(function (value) { return value; }) : null;
2125
+ var pair = react.useState(currentHandoffState());
2126
+ var live = pair[0];
2127
+ var setLive = pair[1];
2128
+ react.useEffect(function () {
2129
+ return subscribeHandoff(function (next) { setLive(next); });
2130
+ }, []);
2131
+ var choice = react.useState("confirm");
2132
+ var picked = choice[0];
2133
+ var setPicked = choice[1];
2134
+ var extraPair = react.useState("");
2135
+ var extra = extraPair[0];
2136
+ var setExtra = extraPair[1];
2137
+
2138
+ var state = live;
2061
2139
  if (state === null || state === undefined || state.sessionId !== sessionId) return null;
2062
2140
  if (state.phase === "running") {
2063
2141
  return h("div", { className: "wsr-handoff-live" }, state.needsEnter === true ? t("handoff.pressEnter") : t("handoff.preparing"));
2064
2142
  }
2065
2143
  if (state.phase !== "ready") return null;
2066
- var body = [
2067
- h("div", { className: "wsr-handoff-head" }, t("handoff.found")),
2144
+
2145
+ var rows = [
2146
+ h("label", { className: "wsr-handoff-option", key: "opt-confirm" },
2147
+ h("input", {
2148
+ type: "radio",
2149
+ name: "wsr-handoff-" + sessionId,
2150
+ checked: picked === "confirm",
2151
+ onChange: function () { setPicked("confirm"); },
2152
+ }),
2153
+ h("span", { className: "wsr-handoff-option-text" },
2154
+ h("span", { className: "wsr-handoff-option-title" }, t("handoff.confirm")),
2155
+ h("span", { className: "wsr-handoff-option-desc" }, t("handoff.confirmDesc")),
2156
+ ),
2157
+ ),
2158
+ h("label", { className: "wsr-handoff-option", key: "opt-redo" },
2159
+ h("input", {
2160
+ type: "radio",
2161
+ name: "wsr-handoff-" + sessionId,
2162
+ checked: picked === "redo",
2163
+ onChange: function () { setPicked("redo"); },
2164
+ }),
2165
+ h("span", { className: "wsr-handoff-option-text" },
2166
+ h("span", { className: "wsr-handoff-option-title" }, t("handoff.regen")),
2167
+ h("span", { className: "wsr-handoff-option-desc" }, t("handoff.regenDesc")),
2168
+ ),
2169
+ ),
2068
2170
  h("textarea", {
2069
- className: "wsr-handoff-text",
2070
- value: state.block,
2071
- onChange: function (event) { props.actions.setBlock(event.target.value); },
2171
+ className: "wsr-handoff-extra",
2172
+ key: "extra",
2173
+ placeholder: t("handoff.extraPlaceholder"),
2174
+ value: extra,
2175
+ onChange: function (event) { setExtra(event.target.value); },
2072
2176
  }),
2073
- h("div", { className: "wsr-handoff-actions" },
2074
- h("button", {
2075
- type: "button",
2076
- className: "wsr-btn",
2077
- onClick: function () { carryHandoff(sessionId, state.block); },
2078
- }, t("handoff.confirm")),
2177
+ h("div", { className: "wsr-handoff-actions", key: "actions" },
2079
2178
  h("button", {
2080
2179
  type: "button",
2081
2180
  className: "wsr-btn",
2082
2181
  onClick: function () {
2083
- props.actions.setRunning(sessionId, false);
2084
- handoffBaseline = 0;
2085
- handoffTries = 0;
2086
- handoffSession = sessionId;
2087
- watchHandoff(sessionId);
2182
+ if (extra.trim() !== "") { rewriteHandoff(sessionId, extra); return; }
2183
+ if (picked === "redo") { rewriteHandoff(sessionId, ""); return; }
2184
+ carryHandoff(sessionId, state.block);
2088
2185
  },
2089
- }, t("handoff.more")),
2186
+ }, t("handoff.submit")),
2090
2187
  h("button", {
2091
2188
  type: "button",
2092
2189
  className: "wsr-btn",
2093
2190
  onClick: function () { resetHandoff(); },
2094
2191
  }, t("handoff.cancel")),
2192
+ h("button", {
2193
+ type: "button",
2194
+ className: "wsr-btn",
2195
+ onClick: function () {
2196
+ var preview = typeof document !== "undefined" ? document.querySelector('[data-wsr-handoff-preview="' + sessionId + '"]') : null;
2197
+ if (preview !== null && preview !== undefined && preview.style !== undefined) {
2198
+ preview.style.display = preview.style.display === "none" ? "" : "none";
2199
+ }
2200
+ },
2201
+ }, t("handoff.preview")),
2095
2202
  ),
2096
2203
  ];
2097
- return h.apply(null, ["div", { className: "wsr-handoff-card" }].concat(body));
2204
+
2205
+ return h("div", { className: "wsr-handoff-card" },
2206
+ h("div", { className: "wsr-handoff-head" }, t("handoff.found")),
2207
+ h("div", { "data-wsr-handoff-preview": sessionId, className: "wsr-handoff-body", style: { display: "none" } }, state.block),
2208
+ rows[0],
2209
+ rows[1],
2210
+ rows[2],
2211
+ rows[3],
2212
+ );
2098
2213
  }
2099
2214
 
2100
2215
  /**
@@ -2832,34 +2947,6 @@
2832
2947
 
2833
2948
  /* The statistics renderer is plain DOM, not a slot component: keep the
2834
2949
  store handle so it can read the argument-mode preference live. */
2835
- /* Handoff progress lives in a store so the turn card re-renders with it. */
2836
- var handoff = clientStore.defineStore({
2837
- init: function () {
2838
- return { sessionId: "", phase: "idle", block: "", needsEnter: false };
2839
- },
2840
- actions: {
2841
- setRunning: function (draft, sessionId, needsEnter) {
2842
- draft.sessionId = sessionId;
2843
- draft.phase = "running";
2844
- draft.block = "";
2845
- draft.needsEnter = needsEnter === true;
2846
- },
2847
- setReady: function (draft, block) {
2848
- draft.phase = "ready";
2849
- draft.block = typeof block === "string" ? block : "";
2850
- },
2851
- setBlock: function (draft, block) {
2852
- draft.block = typeof block === "string" ? block : "";
2853
- },
2854
- setIdle: function (draft) {
2855
- draft.phase = "idle";
2856
- draft.block = "";
2857
- draft.sessionId = "";
2858
- draft.needsEnter = false;
2859
- },
2860
- },
2861
- });
2862
- handoffStore = handoff;
2863
2950
 
2864
2951
  prefsStore = prefs;
2865
2952
 
@@ -2956,7 +3043,6 @@
2956
3043
  name: "conversation.chat.turnTail",
2957
3044
  id: "ws-recency-handoff-card",
2958
3045
  order: 30,
2959
- store: handoff,
2960
3046
  locale: NS,
2961
3047
  inject: function (sessionId) { return { sessionId: sessionId }; },
2962
3048
  }, HandoffTailCard);
@@ -3030,6 +3116,9 @@
3030
3116
  schedule();
3031
3117
  }
3032
3118
 
3119
+ /* Test hook: the card state is a module observable, invisible from outside. */
3120
+ exports.__handoff = { current: currentHandoffState, set: setHandoffState };
3121
+
3033
3122
  exports.name = "dsh-ws-recency";
3034
3123
  exports.inject = inject;
3035
3124
  exports.apply = apply_;
package/index.js CHANGED
@@ -32,7 +32,7 @@ import { dirname, join } from "node:path";
32
32
  export const name = "ws-recency";
33
33
 
34
34
  /** Version marker reported by the health route. */
35
- export const HOST_VERSION = "0.20.0";
35
+ export const HOST_VERSION = "0.21.0";
36
36
 
37
37
  /**
38
38
  * Exact routes the client half calls. Registered on the bare web server, so they
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ws-recency",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Sidebar session management for DeepSeek Harness: workspace groups sorted by latest activity, stale history folded, a global pinned section, follow-up marks, session delete into a recoverable trash, archived sessions managed from that same trash panel, per-session token statistics with an argument/result split and an option to count tool arguments as the agent's writing, and moving a session to another workspace.",
5
5
  "license": "MIT",
6
6
  "author": "chyxhtc",