dsh-as-aistudio 0.4.5 → 0.4.7
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/CHANGELOG.md +16 -0
- package/package.json +1 -1
- package/src/client.js +5 -32
- package/src/components.js +1 -1
- package/src/vendor/host/dsh-edit-turn.js +24 -12
- package/src/vendor/host/dsh-edit-turn.patch.js +1 -1
- package/src/vendor/versions.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
## 中文
|
|
6
6
|
|
|
7
|
+
**0.4.7** —— 打开着的会话不再重新解码整份日志(跟进 `dsh-edit-turn` 0.5.13)。
|
|
8
|
+
|
|
9
|
+
- **组件跟进**:`dsh-edit-turn` **0.5.13**、`dsh-rerun-turn` 0.2.6、`dsh-delete-turn` 0.1.15、`dsh-markdown-bubble` 0.1.5。
|
|
10
|
+
|
|
11
|
+
- 单独计时后:插件的全部计算只有几十毫秒,**读日志 + 解压 1,408 ms** 才是瓶颈。现在宿主已经打开的会话直接用内存快照,不再从磁盘重解一遍 —— 编辑笔的出现从"秒级"降到"几十毫秒级"。
|
|
12
|
+
|
|
13
|
+
**0.4.6** —— 复制已修好,临时诊断撤掉;`/state` 再快一档。
|
|
14
|
+
|
|
15
|
+
- **组件跟进**:`dsh-edit-turn` **0.5.12**、`dsh-rerun-turn` 0.2.6、`dsh-delete-turn` 0.1.15、`dsh-markdown-bubble` 0.1.5。
|
|
16
|
+
|
|
17
|
+
- **复制修好了**:根因是 `/state` 太大太慢(25 MB / 13 秒),那段时间里浏览器半部没有任何编辑条目,按下复制不会被插件接管 —— 瘦身之后复制拿到的是改写后的文本。0.4.4 加的自报诊断按计划撤掉。
|
|
18
|
+
|
|
19
|
+
- **再提速**:`rollbackLedger` 原本自己又折了一遍表面(`/state` 已经折过),31k 事件等于走两遍;现在折一次、四个遍历共用同一份索引。
|
|
20
|
+
|
|
21
|
+
- `dsh-edit-turn` 同时把工具链依赖的 `dsh-session-format-catalog` 写进了 devDependencies(之前只在 node_modules 里,重装就丢)。
|
|
22
|
+
|
|
7
23
|
**0.4.5** —— `/state` 再提速(跟进 `dsh-edit-turn` 0.5.11)。
|
|
8
24
|
|
|
9
25
|
- **组件跟进**:`dsh-edit-turn` **0.5.11**、`dsh-rerun-turn` 0.2.6、`dsh-delete-turn` 0.1.15、`dsh-markdown-bubble` 0.1.5。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-as-aistudio",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "Google-AI-Studio-style turn controls for DeepSeek Harness, in one install: edit a prompt and re-run it, re-run a reply in place, delete a turn from the model context, and render sent prompts as Markdown. Self-contained: the plugin list shows this one row, and the four components are vendored inside it - installing the studio installs nothing else.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
package/src/client.js
CHANGED
|
@@ -43,7 +43,7 @@ window.__ModuleLoader__.load({
|
|
|
43
43
|
const RERUN_PREFIX = '/dsh-rerun-turn'
|
|
44
44
|
|
|
45
45
|
/** Keep in sync with package.json and lib/index.js. */
|
|
46
|
-
const PLUGIN_VERSION = '0.5.
|
|
46
|
+
const PLUGIN_VERSION = '0.5.13'
|
|
47
47
|
|
|
48
48
|
// --- copy -----------------------------------------------------------------
|
|
49
49
|
|
|
@@ -1999,24 +1999,6 @@ window.__ModuleLoader__.load({
|
|
|
1999
1999
|
})()
|
|
2000
2000
|
const rowCopyText = copyRegistry.text
|
|
2001
2001
|
|
|
2002
|
-
// TEMP DIAG (删除时机:复制修好后). 复制按下没被接管时,把原因写进标签页标题:
|
|
2003
|
-
// 不污染剪贴板、不改页面内容,用户念一眼标题即可;成功接管时自动恢复原标题。
|
|
2004
|
-
const copyDiag = (page) => {
|
|
2005
|
-
try {
|
|
2006
|
-
if (page.__dshetTitle === undefined) page.__dshetTitle = document.title
|
|
2007
|
-
const base = String(page.__dshetTitle ?? '')
|
|
2008
|
-
const show = (reason) => {
|
|
2009
|
-
document.title = `[复制诊断] ${reason}${base === '' ? '' : ' · ' + base}`
|
|
2010
|
-
}
|
|
2011
|
-
const clear = () => {
|
|
2012
|
-
if (String(document.title).startsWith('[复制诊断]')) document.title = base
|
|
2013
|
-
}
|
|
2014
|
-
return { show, clear }
|
|
2015
|
-
} catch {
|
|
2016
|
-
return { show: () => {}, clear: () => {} }
|
|
2017
|
-
}
|
|
2018
|
-
}
|
|
2019
|
-
const titleDiag = typeof globalThis !== 'undefined' ? copyDiag(globalThis) : { show: () => {}, clear: () => {} }
|
|
2020
2002
|
const rowHostText = copyRegistry.host
|
|
2021
2003
|
|
|
2022
2004
|
/**
|
|
@@ -2148,11 +2130,6 @@ window.__ModuleLoader__.load({
|
|
|
2148
2130
|
const native = clipboard.writeText.bind(clipboard)
|
|
2149
2131
|
const wrapped = (value) => {
|
|
2150
2132
|
const rewritten = rewriteCopiedText(String(value ?? ''))
|
|
2151
|
-
if (rewritten === null && rowCopyText.size > 0) {
|
|
2152
|
-
titleDiag.show(`写入没匹配上(登记 ${rowCopyText.size} 行,长度 ${String(value ?? '').length})`)
|
|
2153
|
-
} else if (rewritten !== null) {
|
|
2154
|
-
titleDiag.clear()
|
|
2155
|
-
}
|
|
2156
2133
|
return rewritten === null ? native(value) : native(rewritten)
|
|
2157
2134
|
}
|
|
2158
2135
|
wrapped[CLIPBOARD_WRAPPED] = true
|
|
@@ -4993,15 +4970,11 @@ window.__ModuleLoader__.load({
|
|
|
4993
4970
|
// Our own buttons sit in the same bar: theirs is not this press.
|
|
4994
4971
|
if (pluginOwned(button)) return
|
|
4995
4972
|
const row = button.closest('[data-chat-flow-key]')
|
|
4996
|
-
if (row === null)
|
|
4973
|
+
if (row === null) return
|
|
4997
4974
|
const key = row.getAttribute('data-chat-flow-key')
|
|
4998
|
-
if (typeof key !== 'string' || key === '')
|
|
4975
|
+
if (typeof key !== 'string' || key === '') return
|
|
4999
4976
|
const text = rowCopyText.get(key)
|
|
5000
|
-
if (typeof text !== 'string')
|
|
5001
|
-
titleDiag.show(`这一行没登记文本(登记 ${rowCopyText.size} 行)`)
|
|
5002
|
-
return
|
|
5003
|
-
}
|
|
5004
|
-
titleDiag.clear()
|
|
4977
|
+
if (typeof text !== 'string') return
|
|
5005
4978
|
const write = primitives !== null && primitives !== undefined && typeof primitives.writeClipboard === 'function'
|
|
5006
4979
|
? primitives.writeClipboard
|
|
5007
4980
|
: null
|
|
@@ -9224,7 +9197,7 @@ window.__ModuleLoader__.load({
|
|
|
9224
9197
|
const NS = 'dsh-as-aistudio'
|
|
9225
9198
|
|
|
9226
9199
|
/** Keep in sync with package.json and src/components.js. */
|
|
9227
|
-
const PLUGIN_VERSION = '0.4.
|
|
9200
|
+
const PLUGIN_VERSION = '0.4.7'
|
|
9228
9201
|
|
|
9229
9202
|
/** Presence marker the live verifier reads. */
|
|
9230
9203
|
const DEBUG_KEY = '__DSH_AS_AISTUDIO__'
|
package/src/components.js
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
export const STUDIO_ID = 'dsh-as-aistudio'
|
|
27
27
|
|
|
28
28
|
/** Keep in sync with package.json and src/client.js. */
|
|
29
|
-
export const STUDIO_VERSION = '0.4.
|
|
29
|
+
export const STUDIO_VERSION = '0.4.7'
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* The AI Studio action strip this studio composes, in the order the user meets
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// dsh-edit-turn host half (dsh-edit-turn.js), VENDORED by tools/vendor.mjs - DO NOT EDIT.
|
|
2
2
|
//
|
|
3
|
-
// Source: ../dsh-edit-turn/lib/index.js (v0.5.
|
|
3
|
+
// Source: ../dsh-edit-turn/lib/index.js (v0.5.13, sha256 85d229824536a84b)
|
|
4
4
|
// Regenerate with `npm run vendor`; test/sync.test.js fails when this is stale.
|
|
5
5
|
//
|
|
6
6
|
// src/shell.js imports the copy named after the component, which is why the
|
|
@@ -85,7 +85,7 @@ export const PLUGIN_ID = 'dsh-edit-turn'
|
|
|
85
85
|
export const name = PLUGIN_ID
|
|
86
86
|
|
|
87
87
|
/** Keep in sync with package.json and lib/client.js. */
|
|
88
|
-
export const PLUGIN_VERSION = '0.5.
|
|
88
|
+
export const PLUGIN_VERSION = '0.5.13'
|
|
89
89
|
|
|
90
90
|
// A ring of the last few requests, answering "did the browser half even ask, and
|
|
91
91
|
// what did it get?" without needing its console. Read-only diagnostics: the
|
|
@@ -706,10 +706,13 @@ function copyBlock(block) {
|
|
|
706
706
|
* @returns `{ hidden, edits }`: one hidden entry per shadowed seq, and one
|
|
707
707
|
* record per landed rollback.
|
|
708
708
|
*/
|
|
709
|
-
export function rollbackLedger(events) {
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
709
|
+
export function rollbackLedger(events, options = {}) {
|
|
710
|
+
// A caller that already folded the surface (the state route does) hands it in:
|
|
711
|
+
// folding twice over a long session is the single most expensive thing this
|
|
712
|
+
// route did - 31k events, and every fold walks all of them.
|
|
713
|
+
const folded = options.folded ?? foldSurface(events)
|
|
714
|
+
const bySeq = options.bySeq ?? new Map(events.map((event) => [event.seq, event]))
|
|
715
|
+
const turnOf = options.turnOf ?? turnIndex(events)
|
|
713
716
|
const hidden = []
|
|
714
717
|
const edits = []
|
|
715
718
|
for (const replacement of folded.replacements) {
|
|
@@ -1251,8 +1254,8 @@ export function buildReplayWrites(events, plan, baseTurn, replayId, startSeq, pr
|
|
|
1251
1254
|
* @returns one entry per editable prompt, in conversation order.
|
|
1252
1255
|
*/
|
|
1253
1256
|
export function editableTurns(events, surfaceNodes, options = {}) {
|
|
1254
|
-
const eventBySeq = new Map(events.map((event) => [event.seq, event]))
|
|
1255
|
-
const turnOf = turnIndex(events)
|
|
1257
|
+
const eventBySeq = options.bySeq ?? new Map(events.map((event) => [event.seq, event]))
|
|
1258
|
+
const turnOf = options.turnOf ?? turnIndex(events)
|
|
1256
1259
|
const head = surfaceNodes[0]
|
|
1257
1260
|
const out = []
|
|
1258
1261
|
// Surface order, not log order: a prompt rewritten in place travels as a
|
|
@@ -1308,7 +1311,7 @@ export function editableTurns(events, surfaceNodes, options = {}) {
|
|
|
1308
1311
|
*/
|
|
1309
1312
|
export function editableReplies(events, surfaceNodes, options = {}) {
|
|
1310
1313
|
const nodeIndex = new Map(surfaceNodes.map((seq, index) => [seq, index]))
|
|
1311
|
-
const turnOf = turnIndex(events)
|
|
1314
|
+
const turnOf = options.turnOf ?? turnIndex(events)
|
|
1312
1315
|
const head = surfaceNodes[0]
|
|
1313
1316
|
const patches = options.patches instanceof Map ? options.patches : new Map()
|
|
1314
1317
|
const patch = options.patch === true
|
|
@@ -1488,6 +1491,13 @@ function eventsFromLive(session) {
|
|
|
1488
1491
|
// Live-preferred read through the public query service; the live session's own
|
|
1489
1492
|
// snapshot is the fallback when the service is absent.
|
|
1490
1493
|
async function readEvents(ctx, sessionId) {
|
|
1494
|
+
// A session the host has open answers from memory. Going through the query
|
|
1495
|
+
// service instead makes the route re-decode the whole log from disk first:
|
|
1496
|
+
// measured 1.4 s for a 15 MB log, while every computation this route does on
|
|
1497
|
+
// top of it adds up to a few tens of milliseconds. That read was the entire
|
|
1498
|
+
// reason the edit entry took seconds to appear.
|
|
1499
|
+
const live = eventsFromLive(findLiveSession(ctx, sessionId))
|
|
1500
|
+
if (live !== undefined && live.length > 0) return live
|
|
1491
1501
|
const query = ctx.get('sessionQuery')
|
|
1492
1502
|
if (query && typeof query.readSession === 'function') {
|
|
1493
1503
|
try {
|
|
@@ -1776,7 +1786,9 @@ async function stateOf(ctx, sessionId, config) {
|
|
|
1776
1786
|
}
|
|
1777
1787
|
}
|
|
1778
1788
|
const folded = foldSurface(events)
|
|
1779
|
-
const
|
|
1789
|
+
const bySeq = new Map(events.map((event) => [event.seq, event]))
|
|
1790
|
+
const turnOf = turnIndex(events)
|
|
1791
|
+
const ledger = rollbackLedger(events, { folded, bySeq, turnOf })
|
|
1780
1792
|
const patches = patchesOf(events)
|
|
1781
1793
|
// A patch whose target has been retired (a later rerun shadowed it) is inert:
|
|
1782
1794
|
// the projection skips it and no row can show it. Reporting it in /state made
|
|
@@ -1790,8 +1802,8 @@ async function stateOf(ctx, sessionId, config) {
|
|
|
1790
1802
|
// now, so a store that is unmounted (or not yet mounted) cannot leave the
|
|
1791
1803
|
// editor promising to keep blocks the host would have to drop.
|
|
1792
1804
|
const store = resolveAttachmentStore(ctx)
|
|
1793
|
-
const turns = editableTurns(events, folded.nodes, { preview: canPreviewAttachments(store) })
|
|
1794
|
-
const replies = editableReplies(events, folded.nodes, { patches, patch: config.patch === true, light: true }).map(lightReply)
|
|
1805
|
+
const turns = editableTurns(events, folded.nodes, { preview: canPreviewAttachments(store), bySeq, turnOf })
|
|
1806
|
+
const replies = editableReplies(events, folded.nodes, { patches, patch: config.patch === true, light: true, bySeq, turnOf }).map(lightReply)
|
|
1795
1807
|
noteRequest({
|
|
1796
1808
|
kind: 'state',
|
|
1797
1809
|
sessionId,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// dsh-edit-turn host half (dsh-edit-turn.patch.js), VENDORED by tools/vendor.mjs - DO NOT EDIT.
|
|
2
2
|
//
|
|
3
|
-
// Source: ../dsh-edit-turn/lib/patch.js (v0.5.
|
|
3
|
+
// Source: ../dsh-edit-turn/lib/patch.js (v0.5.13, sha256 5e1e8cce1d168f6c)
|
|
4
4
|
// Regenerate with `npm run vendor`; test/sync.test.js fails when this is stale.
|
|
5
5
|
//
|
|
6
6
|
// src/shell.js imports the copy named after the component, which is why the
|
package/src/vendor/versions.json
CHANGED