dsh-todo-float-ball 0.8.0 → 0.11.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/CHANGELOG.md +266 -0
- package/README.md +61 -1
- package/README.zh.md +38 -1
- package/cordis.patch.yml +25 -4
- package/lib/client.js +1656 -1115
- package/lib/index.js +86 -8
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1,14 +1,64 @@
|
|
|
1
1
|
// dsh-todo-float-ball - host half.
|
|
2
|
-
//
|
|
3
|
-
// the host registers a loopback-only health route so the bundle has a real
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
2
|
+
// Dual-face mount (identical shape to the verified dsh-font-enhancer):
|
|
3
|
+
// (1) the host registers a loopback-only health route so the bundle has a real
|
|
4
|
+
// cordis activate (inject=['webServer']);
|
|
5
|
+
// (2) since v0.9.0 the host ALSO injects a short "todo discipline" system-prompt
|
|
6
|
+
// section (inject adds 'systemPrompt'), so the todo rules hold in every
|
|
7
|
+
// session / preset / desktop+web build even when the `todo-show-discipline`
|
|
8
|
+
// skill was never loaded (skills are loaded on demand, the prompt section is
|
|
9
|
+
// resident). The long-form rules stay in the skill; this text carries only
|
|
10
|
+
// the 5 hardest ones, because a system-prompt section costs tokens in EVERY
|
|
11
|
+
// session.
|
|
12
|
+
// The visual work still lives in lib/client.js, mounted by the client-modules
|
|
13
|
+
// system once the host activates. Works on both web and desktop profiles.
|
|
14
|
+
|
|
15
|
+
import { readFileSync } from "node:fs";
|
|
16
|
+
import { fileURLToPath } from "node:url";
|
|
17
|
+
import { dirname, join } from "node:path";
|
|
18
|
+
|
|
19
|
+
// Version reported by the health route, read from package.json so it can never
|
|
20
|
+
// drift from the released version again (it was hardcoded to "0.1.0" from the
|
|
21
|
+
// 0.1.0 skeleton until 2026-09-10, and kept reporting 0.1.0 while the package
|
|
22
|
+
// had moved on to 0.8.0/0.9.0). Falls back to "unknown" if the file cannot be
|
|
23
|
+
// read, so the route never throws.
|
|
24
|
+
var PKG_VERSION = (function () {
|
|
25
|
+
try {
|
|
26
|
+
var here = dirname(fileURLToPath(import.meta.url));
|
|
27
|
+
return JSON.parse(readFileSync(join(here, "..", "package.json"), "utf8")).version;
|
|
28
|
+
} catch (e) {
|
|
29
|
+
return "unknown";
|
|
30
|
+
}
|
|
31
|
+
})();
|
|
7
32
|
|
|
8
33
|
var SETTINGS_PREFIX = "/dsh-todo-float-ball";
|
|
9
34
|
|
|
35
|
+
// Stable identifier of the injected prompt section (same naming style as
|
|
36
|
+
// dsh-taskboard's own `TASKBOARD_PROTOCOL` section).
|
|
37
|
+
var DISCIPLINE_SECTION_NAME = "todo-discipline";
|
|
38
|
+
|
|
39
|
+
// Sort position. section() orders are plain numbers sorted ascending; the
|
|
40
|
+
// built-in band is DEPLOYMENT_PERSONA=0 -> PLAN_POLICY=500 -> TEAM_POLICY=600
|
|
41
|
+
// (see @deepseek-ai/dsh-system-prompt SECTION_ORDERS), and dsh-taskboard puts
|
|
42
|
+
// its protocol section at 180. 190 therefore keeps this discipline inside the
|
|
43
|
+
// same "how to work" band as the task-board protocol (rendered right after it,
|
|
44
|
+
// so the two work-discipline blocks stay together), stays clear of the 500
|
|
45
|
+
// plan-policy boundary, and leaves 181..189 free for future sections.
|
|
46
|
+
var DISCIPLINE_SECTION_ORDER = 190;
|
|
47
|
+
|
|
48
|
+
// Injected text - Chinese, deliberately short (hard character budget: <=500,
|
|
49
|
+
// actual ~340). Only the 5 hardest rules; everything else belongs to the
|
|
50
|
+
// `todo-show-discipline` skill, which is loaded on demand.
|
|
51
|
+
var DISCIPLINE_TEXT = [
|
|
52
|
+
"【todo 进度表纪律 · 由 dsh-todo-float-ball 插件常驻注入,无需加载技能】",
|
|
53
|
+
"1. 每个回复 turn 的第一个工具调用必须是 todo_write:覆盖式写回完整清单;先写 todo,再做检查、汇报或执行。",
|
|
54
|
+
"2. 清单只增不减:已完成项保留并标 completed,绝不删除、折叠或合并;新任务到达但旧任务未完成时合并追加,禁止替换式清空重写。",
|
|
55
|
+
"3. 进行中项必须带实时进度数字(如「19号 120rpm 求解 278/1000」);每完成一步立即刷新状态。",
|
|
56
|
+
"4. 用户说「消失/少了/不见了/关了」= 本纪律被违反:立即补全完整清单,并说明当轮首动作漏写。",
|
|
57
|
+
"5. 全部任务实际完成时也要再写一次 todo_write(全标 completed),不得残留 in_progress/pending。"
|
|
58
|
+
].join("\n");
|
|
59
|
+
|
|
10
60
|
export var name = "dsh-todo-float-ball";
|
|
11
|
-
export var inject = ["webServer"];
|
|
61
|
+
export var inject = ["webServer", "systemPrompt"];
|
|
12
62
|
|
|
13
63
|
function isLoopback(req) {
|
|
14
64
|
var a = (req.socket && req.socket.remoteAddress) || "";
|
|
@@ -18,13 +68,41 @@ function isLoopback(req) {
|
|
|
18
68
|
return n.startsWith("127.");
|
|
19
69
|
}
|
|
20
70
|
|
|
21
|
-
export function apply(ctx) {
|
|
71
|
+
export function apply(ctx, config) {
|
|
22
72
|
ctx.logger.info("dsh-todo-float-ball: host half mounted (health api + client)");
|
|
73
|
+
|
|
74
|
+
// Config switch `injectDiscipline` (default true).
|
|
75
|
+
// The default is deliberately permissive: an install that carries no `config`
|
|
76
|
+
// row at all - every existing user, including both local profiles - keeps the
|
|
77
|
+
// discipline ON, so this feature is "install the plugin and it works".
|
|
78
|
+
// Turn it OFF from the inserted bundle row (the plugin's own
|
|
79
|
+
// cordis.patch.yml, or a manual mount line in the profile's patch):
|
|
80
|
+
// - insert:
|
|
81
|
+
// - id: dsh-todo-float-ball
|
|
82
|
+
// name: dsh-todo-float-ball
|
|
83
|
+
// config:
|
|
84
|
+
// injectDiscipline: false
|
|
85
|
+
// Only an explicit boolean false disables it, so "0"/""/typos cannot silently
|
|
86
|
+
// switch the discipline off. When disabled the section is NOT registered at
|
|
87
|
+
// all (no empty-text section is left behind).
|
|
88
|
+
var injectDiscipline = !(config && config.injectDiscipline === false);
|
|
89
|
+
if (injectDiscipline) {
|
|
90
|
+
var disposeSection = ctx.systemPrompt.section({
|
|
91
|
+
name: DISCIPLINE_SECTION_NAME,
|
|
92
|
+
order: DISCIPLINE_SECTION_ORDER,
|
|
93
|
+
text: DISCIPLINE_TEXT
|
|
94
|
+
});
|
|
95
|
+
ctx.effect(function () { return disposeSection; }, "dsh-todo-float-ball: todo discipline section");
|
|
96
|
+
ctx.logger.info("dsh-todo-float-ball: todo discipline prompt section registered (order " + DISCIPLINE_SECTION_ORDER + ", " + DISCIPLINE_TEXT.length + " chars)");
|
|
97
|
+
} else {
|
|
98
|
+
ctx.logger.info("dsh-todo-float-ball: todo discipline prompt section disabled by config (injectDiscipline: false)");
|
|
99
|
+
}
|
|
100
|
+
|
|
23
101
|
ctx.effect(function () {
|
|
24
102
|
var h1 = ctx.webServer.register({ kind: "exact", path: SETTINGS_PREFIX + "/health", handler: function (req, res) {
|
|
25
103
|
if (!isLoopback(req)) { res.writeHead(403); res.end(); return; }
|
|
26
104
|
res.writeHead(200, { "content-type": "application/json; charset=utf-8" });
|
|
27
|
-
res.end(JSON.stringify({ ok: true, plugin: "dsh-todo-float-ball", version:
|
|
105
|
+
res.end(JSON.stringify({ ok: true, plugin: "dsh-todo-float-ball", version: PKG_VERSION }));
|
|
28
106
|
}});
|
|
29
107
|
var h2 = ctx.webServer.register({ kind: "exact", path: SETTINGS_PREFIX + "/client-alive", handler: function (req, res) {
|
|
30
108
|
ctx.logger.info("dsh-todo-float-ball: CLIENT-ALIVE ping received from browser");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-todo-float-ball",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "DSH todo 悬浮球:常驻可拖动悬浮球实时显示当前会话 todo_write 任务清单进度(总数/完成数/进行中),Shadow DOM 样式隔离,点击折叠/展开完整清单,状态颜色(待办灰/进行中橙脉动/完成绿)。数据双路同步:MutationObserver 抓官方 todo 面板为主 + 拦截会话投影帧为辅。双端可用(Desktop 桌面端 + Web 网页端)。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|