dsh-todo-freshness 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +63 -2
- package/client.js +123 -0
- package/cordis.patch.yml +3 -0
- package/icon.svg +10 -0
- package/index.js +81 -0
- package/lib/fold.js +111 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +54 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 lizhi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,64 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-todo-freshness
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
DSH 的任务卡片("任务 1 进行中 · 5 待处理")只是**最后一次 `todo_write` 的快照**。模型做完活直接输出最终答复时,那一步没有工具调用,也就再也没有机会回写,于是面板会一直挂着旧状态。这个插件不替你改数据,而是把"这份清单已经过期"这件事说出来,并催模型自己回写。
|
|
4
|
+
|
|
5
|
+
## 两个部件
|
|
6
|
+
|
|
7
|
+
**Host(`index.js`)**
|
|
8
|
+
|
|
9
|
+
- 注册一个会话投影 `todoFreshness`,从既有事件里折叠出:上次写清单是第几轮第几步、之后又跑了多少次工具调用、清单里还剩几项没有结论、这一轮是不是已经结束。
|
|
10
|
+
- 在 `tools/post-execute` 上挂一个建议:当清单里还有未完成项、且从上次回写起已经连续跑了 6 次(以及 14 次)工具调用时,往下一步注入一条提醒,要求模型用真实状态整表重写。
|
|
11
|
+
- 不写 `todo/write`,不把 `pending` 改成 `completed`。没干完就是没干完。
|
|
12
|
+
|
|
13
|
+
**Client(`client.js`)**
|
|
14
|
+
|
|
15
|
+
- 在 `conversation.input.dock` 的 order 1 注册一条提示条,只在两种情况下出现:
|
|
16
|
+
- `stale`:清单里还有未完成项,但已经连续 6 次以上工具调用没有回写;
|
|
17
|
+
- `closedWithUnfinished`:这一轮已经结束,清单却还留着未完成项。
|
|
18
|
+
- 正常更新清单时它不出现,不会和内置的任务卡片抢位置。
|
|
19
|
+
|
|
20
|
+
## 为什么这么设计
|
|
21
|
+
|
|
22
|
+
两种"修法"里,只有一种不撒谎:
|
|
23
|
+
|
|
24
|
+
| 做法 | 效果 | 问题 |
|
|
25
|
+
|---|---|---|
|
|
26
|
+
| 轮次结束时把遗留项一律标成 `completed` | 面板永远干净 | 没做完的活也显示完成,等于伪造结果 |
|
|
27
|
+
| 如实标注 + 催模型回写 | 面板可能仍然显示未完成 | 但它显示的确实是真话 |
|
|
28
|
+
|
|
29
|
+
这个插件走第二条。清单"对不上"时你看到的是明确的"这份清单还没跟上",而不是一个看起来还在进行的假进度。
|
|
30
|
+
|
|
31
|
+
## 配置
|
|
32
|
+
|
|
33
|
+
`cordis.patch.yml` 里的行可以带 `config`:
|
|
34
|
+
|
|
35
|
+
```yaml
|
|
36
|
+
- insert:
|
|
37
|
+
- id: todo-freshness
|
|
38
|
+
name: dsh-todo-freshness
|
|
39
|
+
config:
|
|
40
|
+
nudge: false
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
| 字段 | 默认 | 含义 |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| `nudge` | `true` | 是否注入中途提醒。关闭后只保留 Client 侧的标注,不产生任何模型请求 |
|
|
46
|
+
|
|
47
|
+
## 限制
|
|
48
|
+
|
|
49
|
+
- 提醒只是建议。模型可以不理会它,这时面板依旧停在旧状态——插件不会替它决定。
|
|
50
|
+
- 阈值(6 / 14 次调用)是经验值,写在 `lib/fold.js` 的 `STALE_CALLS` 和 `NUDGE_AT` 里,可以按自己的任务节奏调。
|
|
51
|
+
- 投影 key `todoFreshness` 是本插件私有的;卸载后它从会话状态里消失,不影响内置的 `todos`。
|
|
52
|
+
|
|
53
|
+
## 安装
|
|
54
|
+
|
|
55
|
+
`desktop` 这个 profile 只归桌面端管,命令行装不了:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
$ dsh plugin --profile desktop add ...
|
|
59
|
+
error: profile "desktop" is managed exclusively by the Electron application
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
所以走桌面端的「插件」界面,或在会话里让 agent 用 `plugin_manager` 的 `install_bundle` 指定这个目录。装完在 bundle 列表里启用,刷新页面即可。
|
|
63
|
+
|
|
64
|
+
`index.js` import 了 `@deepseek-ai/dsh-llm`,所以 `peerDependencies` 里必须声明它——本地链接的包靠这份声明把 core 模块路由到应用自己的安装目录,漏了就报 `Cannot find module`。
|
package/client.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: 'dsh-todo-freshness',
|
|
3
|
+
factory(require) {
|
|
4
|
+
const React = require('react')
|
|
5
|
+
const h = React.createElement
|
|
6
|
+
|
|
7
|
+
/** Inline styles inherit the host theme; no stylesheet is injected into the page. */
|
|
8
|
+
const styles = {
|
|
9
|
+
root: {
|
|
10
|
+
boxSizing: 'border-box',
|
|
11
|
+
flex: 'none',
|
|
12
|
+
overflow: 'hidden',
|
|
13
|
+
margin: '0 auto',
|
|
14
|
+
width: 'calc(100% - var(--dsh-composer-side-clearance) - var(--dsh-composer-side-clearance)'
|
|
15
|
+
+ ' - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset)'
|
|
16
|
+
+ ' - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset))',
|
|
17
|
+
maxWidth: 'calc(var(--dsh-composer-card-max-width) - var(--dsh-composer-dock-inset)'
|
|
18
|
+
+ ' - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset)'
|
|
19
|
+
+ ' - var(--dsh-composer-dock-inset))',
|
|
20
|
+
border: '0',
|
|
21
|
+
borderRadius: 'var(--dsw-radius-lg)',
|
|
22
|
+
background: 'var(--dsw-specific-menu)',
|
|
23
|
+
backdropFilter: 'var(--dsw-menu-backdrop-filter)',
|
|
24
|
+
boxShadow: 'var(--dsw-elevation-panel)',
|
|
25
|
+
},
|
|
26
|
+
body: {
|
|
27
|
+
display: 'flex',
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
gap: '10px',
|
|
30
|
+
padding: '6px 12px',
|
|
31
|
+
},
|
|
32
|
+
glyph: {
|
|
33
|
+
display: 'grid',
|
|
34
|
+
flex: 'none',
|
|
35
|
+
placeItems: 'center',
|
|
36
|
+
width: '16px',
|
|
37
|
+
height: '16px',
|
|
38
|
+
color: 'var(--dsw-alias-state-warn-label)',
|
|
39
|
+
},
|
|
40
|
+
text: {
|
|
41
|
+
flex: '1 1 auto',
|
|
42
|
+
minWidth: '0',
|
|
43
|
+
overflow: 'hidden',
|
|
44
|
+
fontSize: '13px',
|
|
45
|
+
lineHeight: '20px',
|
|
46
|
+
color: 'var(--dsw-alias-label-secondary)',
|
|
47
|
+
textOverflow: 'ellipsis',
|
|
48
|
+
whiteSpace: 'nowrap',
|
|
49
|
+
},
|
|
50
|
+
count: {
|
|
51
|
+
flex: 'none',
|
|
52
|
+
fontSize: '13px',
|
|
53
|
+
lineHeight: '20px',
|
|
54
|
+
fontVariantNumeric: 'tabular-nums',
|
|
55
|
+
color: 'var(--dsw-alias-label-tertiary)',
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** A hollow clock: the list is old, not wrong. */
|
|
60
|
+
function Glyph() {
|
|
61
|
+
return h('svg', { viewBox: '0 0 16 16', width: 14, height: 14, 'aria-hidden': true },
|
|
62
|
+
h('circle', { cx: 8, cy: 8, r: 5.5, fill: 'none', stroke: 'currentColor', strokeWidth: 1.5 }),
|
|
63
|
+
h('path', {
|
|
64
|
+
d: 'M8 4.8v3.6l2.2 1.6',
|
|
65
|
+
fill: 'none',
|
|
66
|
+
stroke: 'currentColor',
|
|
67
|
+
strokeWidth: 1.5,
|
|
68
|
+
strokeLinecap: 'round',
|
|
69
|
+
strokeLinejoin: 'round',
|
|
70
|
+
}))
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The staleness note. Renders nothing while the list still matches the work,
|
|
75
|
+
* and one line when the built-in card describes a moment that has passed.
|
|
76
|
+
* `todoFreshness` is this bundle's own projection; `todos` is the built-in one.
|
|
77
|
+
*/
|
|
78
|
+
function FreshnessNote({ useProjection, t }) {
|
|
79
|
+
const freshness = useProjection('todoFreshness')
|
|
80
|
+
const todos = useProjection('todos')
|
|
81
|
+
if (!freshness || !Array.isArray(todos) || todos.length === 0) return null
|
|
82
|
+
const unfinished = (freshness.active ?? 0) + (freshness.pending ?? 0)
|
|
83
|
+
if (unfinished === 0) return null
|
|
84
|
+
const closed = (freshness.closedWithUnfinished ?? 0) > 0
|
|
85
|
+
if (!freshness.stale && !closed) return null
|
|
86
|
+
return h('section', {
|
|
87
|
+
style: styles.root,
|
|
88
|
+
'data-todo-freshness': closed ? 'closed' : 'stale',
|
|
89
|
+
role: 'status',
|
|
90
|
+
},
|
|
91
|
+
h('div', { style: styles.body },
|
|
92
|
+
h('span', { style: styles.glyph }, h(Glyph)),
|
|
93
|
+
h('span', { style: styles.text }, closed ? t('note.closed') : t('note.stale')),
|
|
94
|
+
h('span', { style: styles.count }, t('note.count', { unfinished }))))
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const dictionaries = {
|
|
98
|
+
zh: {
|
|
99
|
+
'note.stale': '这份清单还没跟上已经做完的工作',
|
|
100
|
+
'note.closed': '这一轮已经结束,清单停在旧状态',
|
|
101
|
+
'note.count': '还有 {unfinished} 项没有结论',
|
|
102
|
+
},
|
|
103
|
+
en: {
|
|
104
|
+
'note.stale': 'This list has not caught up with the work already done',
|
|
105
|
+
'note.closed': 'This turn ended and the list still shows old statuses',
|
|
106
|
+
'note.count': '{unfinished} without a verdict',
|
|
107
|
+
},
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
inject: ['slots', 'locale'],
|
|
112
|
+
apply(ctx) {
|
|
113
|
+
ctx.effect(() => ctx.locale.register('todo-freshness', dictionaries), 'todo-freshness: dictionaries')
|
|
114
|
+
ctx.slots.inject('conversation.input.dock', () => ctx.slots.register({
|
|
115
|
+
name: 'conversation.input.dock',
|
|
116
|
+
id: 'todo-freshness',
|
|
117
|
+
order: 1,
|
|
118
|
+
locale: 'todo-freshness',
|
|
119
|
+
}, FreshnessNote))
|
|
120
|
+
},
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
})
|
package/cordis.patch.yml
ADDED
package/icon.svg
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="Todo freshness">
|
|
2
|
+
<rect x="4" y="4" width="56" height="56" rx="14" fill="#3a4250"/>
|
|
3
|
+
<g transform="translate(32 32)">
|
|
4
|
+
<circle cx="0" cy="0" r="17" fill="none" stroke="#8fb6e8" stroke-width="3"/>
|
|
5
|
+
<path d="M0 -9.5 V1 L6.5 5" fill="none" stroke="#8fb6e8" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>
|
|
6
|
+
<circle cx="0" cy="0" r="2.6" fill="#8fb6e8"/>
|
|
7
|
+
</g>
|
|
8
|
+
<circle cx="47" cy="17" r="6" fill="#e2a33c"/>
|
|
9
|
+
<path d="M47 13.6 V17 L49.2 18.4" fill="none" stroke="#3a4250" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
|
|
10
|
+
</svg>
|
package/index.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host half of `dsh-todo-freshness`.
|
|
3
|
+
*
|
|
4
|
+
* The built-in todo card renders the last `todo/write` snapshot verbatim and has
|
|
5
|
+
* no notion of whether that snapshot still describes the work in progress. This
|
|
6
|
+
* plugin contributes that notion as a separate session projection,
|
|
7
|
+
* `todoFreshness`, and nudges the model to write the list back mid-turn once it
|
|
8
|
+
* has clearly stopped doing so.
|
|
9
|
+
*
|
|
10
|
+
* It never fabricates completion: an unfinished item stays unfinished, and the
|
|
11
|
+
* projection only reports how far the list has drifted from the work.
|
|
12
|
+
*
|
|
13
|
+
* @module dsh-todo-freshness
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { createUserMessage } from '@deepseek-ai/dsh-llm'
|
|
17
|
+
import { anySchema, emptyState, fold, NUDGE_AT, unfinished } from './lib/fold.js'
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The reminder both thresholds send: state the drift, ask for a truthful
|
|
21
|
+
* rewrite, and forbid the shortcut that would silence it.
|
|
22
|
+
*/
|
|
23
|
+
const NUDGE_TEXT = 'Your todo list has not been updated for a while and no longer reflects what you have '
|
|
24
|
+
+ 'done. Call `todo_write` with the COMPLETE list and the true status of every item before continuing. '
|
|
25
|
+
+ 'Do not mark unfinished work `completed` just to clear the panel.'
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The advisory nudge, stamped with a producer source so history shows it as
|
|
29
|
+
* injected context rather than as something the user said.
|
|
30
|
+
* @returns a frozen user message carrying one notice.
|
|
31
|
+
*/
|
|
32
|
+
function nudgeMessage() {
|
|
33
|
+
return createUserMessage({
|
|
34
|
+
content: [{ type: 'text', text: NUDGE_TEXT }],
|
|
35
|
+
source: { kind: 'todo-freshness', form: 'notice', summary: 'todo list out of date' },
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Register the freshness projection and the mid-turn nudge.
|
|
41
|
+
* @param ctx - registrant context carrying the projection and event registries.
|
|
42
|
+
* @param config - deployment config; `nudge: false` keeps the projection and
|
|
43
|
+
* drops the reminder.
|
|
44
|
+
* @returns when the projection is installed.
|
|
45
|
+
*/
|
|
46
|
+
export async function apply(ctx, config) {
|
|
47
|
+
const handle = await ctx.sessionProjections.register({
|
|
48
|
+
key: 'todoFreshness',
|
|
49
|
+
stateSchema: anySchema,
|
|
50
|
+
init: () => emptyState(),
|
|
51
|
+
apply: fold,
|
|
52
|
+
wire: { viewSchema: anySchema, view: state => state, summary: false },
|
|
53
|
+
stateVersion: 1,
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
if (config?.nudge === false) return
|
|
57
|
+
|
|
58
|
+
// Process-local dedup: the tool-call count already reminded at, per live
|
|
59
|
+
// Agent. The projection is a pure fold and must not record that a nudge went
|
|
60
|
+
// out, or the note would change shape depending on who read it.
|
|
61
|
+
const nudged = new WeakMap()
|
|
62
|
+
|
|
63
|
+
// The reminder rides the model-facing surface as injected context, which lands
|
|
64
|
+
// in the next-step inbox and buys exactly one more model step. That is the
|
|
65
|
+
// case the built-in card cannot cover: work finished on the last tool call, so
|
|
66
|
+
// no `todo_write` ever followed it.
|
|
67
|
+
ctx.on('tools/post-execute', async (exec, _result, next) => {
|
|
68
|
+
const decision = await next()
|
|
69
|
+
const agent = exec.agent
|
|
70
|
+
if (agent === undefined) return decision
|
|
71
|
+
const state = handle.stateOf(agent.session)
|
|
72
|
+
if (!state.list || unfinished(state) === 0) return decision
|
|
73
|
+
const at = state.callsSinceWrite
|
|
74
|
+
if (!NUDGE_AT.includes(at) || nudged.get(agent) === at) return decision
|
|
75
|
+
nudged.set(agent, at)
|
|
76
|
+
return {
|
|
77
|
+
...decision,
|
|
78
|
+
additionalContexts: [...(decision.additionalContexts ?? []), nudgeMessage()],
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
}
|
package/lib/fold.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure fold behind the `todoFreshness` projection: no imports, no I/O, so it can
|
|
3
|
+
* be unit-tested outside DSH. The projection registry calls {@link fold} on every
|
|
4
|
+
* committed session event and publishes the result to the Client.
|
|
5
|
+
*
|
|
6
|
+
* @module dsh-todo-freshness/fold
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** Tool calls without a `todo/write` after which the list counts as stale. */
|
|
10
|
+
export const STALE_CALLS = 6
|
|
11
|
+
|
|
12
|
+
/** Tool-call counts, measured from the last write, that each earn exactly one nudge. */
|
|
13
|
+
export const NUDGE_AT = [6, 14]
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* State before the session's first list write.
|
|
17
|
+
* @param turn - the turn being opened, or 0 before any.
|
|
18
|
+
* @returns a fresh state object.
|
|
19
|
+
*/
|
|
20
|
+
export function emptyState(turn = 0) {
|
|
21
|
+
return {
|
|
22
|
+
list: false,
|
|
23
|
+
turn,
|
|
24
|
+
turnOpen: turn > 0,
|
|
25
|
+
step: 0,
|
|
26
|
+
done: 0,
|
|
27
|
+
active: 0,
|
|
28
|
+
pending: 0,
|
|
29
|
+
writeSeq: -1,
|
|
30
|
+
callsSinceWrite: 0,
|
|
31
|
+
stepsSinceWrite: 0,
|
|
32
|
+
closedWithUnfinished: 0,
|
|
33
|
+
stale: false,
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** How many items the list still claims are not done. */
|
|
38
|
+
export function unfinished(state) {
|
|
39
|
+
return state.active + state.pending
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Recompute the derived `stale` flag. Returns a new object only when the flag
|
|
44
|
+
* actually moves, so an unchanged list does not republish.
|
|
45
|
+
* @param state - state carrying the latest counters.
|
|
46
|
+
* @returns the state with a correct `stale` flag.
|
|
47
|
+
*/
|
|
48
|
+
export function settled(state) {
|
|
49
|
+
const stale = state.list && unfinished(state) > 0 && state.turnOpen
|
|
50
|
+
&& state.callsSinceWrite >= STALE_CALLS
|
|
51
|
+
if (stale === state.stale) return state
|
|
52
|
+
return { ...state, stale }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* One session's freshness fold. An event it does not care about returns the same
|
|
57
|
+
* reference, so an idle session publishes nothing and stores nothing.
|
|
58
|
+
* @param state - previous projection state.
|
|
59
|
+
* @param event - the next committed session event.
|
|
60
|
+
* @returns the next state.
|
|
61
|
+
*/
|
|
62
|
+
export function fold(state, event) {
|
|
63
|
+
switch (event.type) {
|
|
64
|
+
case 'turn/start':
|
|
65
|
+
return emptyState(event.data.turn)
|
|
66
|
+
case 'turn/end': {
|
|
67
|
+
if (!state.turnOpen && state.turn === event.data.turn) return state
|
|
68
|
+
return {
|
|
69
|
+
...state,
|
|
70
|
+
turnOpen: false,
|
|
71
|
+
stale: false,
|
|
72
|
+
closedWithUnfinished: state.list ? unfinished(state) : 0,
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
case 'step/start':
|
|
76
|
+
if (!state.list) return state
|
|
77
|
+
return settled({
|
|
78
|
+
...state,
|
|
79
|
+
step: event.data.step,
|
|
80
|
+
stepsSinceWrite: state.stepsSinceWrite + 1,
|
|
81
|
+
})
|
|
82
|
+
case 'tool/call':
|
|
83
|
+
if (!state.list) return state
|
|
84
|
+
return settled({ ...state, callsSinceWrite: state.callsSinceWrite + 1 })
|
|
85
|
+
case 'todo/write': {
|
|
86
|
+
const todos = Array.isArray(event.data?.todos) ? event.data.todos : []
|
|
87
|
+
const count = status => todos.filter(todo => todo.status === status).length
|
|
88
|
+
return settled({
|
|
89
|
+
...state,
|
|
90
|
+
list: todos.length > 0,
|
|
91
|
+
done: count('completed'),
|
|
92
|
+
active: count('in_progress'),
|
|
93
|
+
pending: count('pending'),
|
|
94
|
+
writeSeq: event.seq ?? -1,
|
|
95
|
+
callsSinceWrite: 0,
|
|
96
|
+
stepsSinceWrite: 0,
|
|
97
|
+
closedWithUnfinished: 0,
|
|
98
|
+
stale: false,
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
default:
|
|
102
|
+
return state
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Accepts any persisted payload. The state is plain data whose shape only ever
|
|
108
|
+
* grows, so a stale checkpoint row cannot mislead the fold; `stateVersion` is
|
|
109
|
+
* bumped whenever a field's meaning changes.
|
|
110
|
+
*/
|
|
111
|
+
export const anySchema = { parse: value => value }
|
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-todo-freshness",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Says out loud when the DSH task list is a stale snapshot instead of live progress, and nudges the model to write back.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "lizhi",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/xiaomengxinbb/dsh-todo-freshness.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/xiaomengxinbb/dsh-todo-freshness#readme",
|
|
13
|
+
"icon": "icon.svg",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"dsh",
|
|
16
|
+
"dsh-plugin",
|
|
17
|
+
"todo",
|
|
18
|
+
"task-list",
|
|
19
|
+
"todo-write"
|
|
20
|
+
],
|
|
21
|
+
"exports": {
|
|
22
|
+
".": "./index.js",
|
|
23
|
+
"./client": "./client.js",
|
|
24
|
+
"./locale/*.json": "./locale/*.json",
|
|
25
|
+
"./icon": "./icon.svg"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"index.js",
|
|
29
|
+
"client.js",
|
|
30
|
+
"lib/fold.js",
|
|
31
|
+
"cordis.patch.yml",
|
|
32
|
+
"locale/*.json",
|
|
33
|
+
"icon.svg",
|
|
34
|
+
"README.md",
|
|
35
|
+
"LICENSE"
|
|
36
|
+
],
|
|
37
|
+
"engines": {
|
|
38
|
+
"dsh": ">=0.2.2-rc.3 <0.2.3-0 || >=0.2.3-rc.1 <0.3.0-0",
|
|
39
|
+
"node": ">=20"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
43
|
+
"@deepseek-ai/dsh-llm": ">=0.2.2-rc.3 <0.2.3-0 || >=0.2.3-rc.1 <0.3.0-0"
|
|
44
|
+
},
|
|
45
|
+
"dsh": {
|
|
46
|
+
"manifestVersion": 1,
|
|
47
|
+
"bundle": {
|
|
48
|
+
"patch": "./cordis.patch.yml"
|
|
49
|
+
},
|
|
50
|
+
"client": {
|
|
51
|
+
"platform": "web",
|
|
52
|
+
"immediately": true,
|
|
53
|
+
"inject": ["@deepseek-ai/dsh-client-ui-conversation"]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|