dsh-work-fish 0.1.0 → 0.2.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 (40) hide show
  1. package/README.md +44 -12
  2. package/THIRD-PARTY-NOTICES.md +3 -5
  3. package/cordis.patch.yml +5 -6
  4. package/{board → lib/board}/client.js +13 -20
  5. package/{core → lib/core}/approve.mjs +1 -1
  6. package/{core → lib/core}/bootstrap.mjs +7 -7
  7. package/{core → lib/core}/events.mjs +5 -5
  8. package/{core → lib/core}/guard.mjs +7 -7
  9. package/{core → lib/core}/index.mjs +33 -26
  10. package/{tools → lib/tools}/lib/persona.mjs +2 -2
  11. package/{tools → lib/tools}/lib/taskboard.mjs +12 -17
  12. package/{tools → lib/tools}/wf-metrics.mjs +2 -2
  13. package/{tools → lib/tools}/wf-preview.mjs +2 -4
  14. package/{tools → lib/tools}/wf-rule.mjs +2 -2
  15. package/{tools → lib/tools}/wf-spec.mjs +2 -2
  16. package/{tools → lib/tools}/wf-task.mjs +2 -7
  17. package/locale/en.json +1 -1
  18. package/locale/zh.json +1 -1
  19. package/package.json +11 -13
  20. package/rules/experience-pool.md +2 -2
  21. package/rules/file-rules.md +4 -4
  22. package/rules/memory-rules.md +2 -2
  23. package/skills/task-setup/SKILL.md +1 -1
  24. package/template/AGENTS.template.md +1 -1
  25. package/core/pet-bridge.mjs +0 -439
  26. /package/{core → lib/core}/approve-paths.mjs +0 -0
  27. /package/{core → lib/core}/approve-paths.test.mjs +0 -0
  28. /package/{core → lib/core}/parse.mjs +0 -0
  29. /package/{core → lib/core}/persona.mjs +0 -0
  30. /package/{core → lib/core}/report.mjs +0 -0
  31. /package/{core → lib/core}/skills.mjs +0 -0
  32. /package/{tools → lib/tools}/lib/paths.mjs +0 -0
  33. /package/{tools → lib/tools}/wf-audit.cmd +0 -0
  34. /package/{tools → lib/tools}/wf-audit.ps1 +0 -0
  35. /package/{tools → lib/tools}/wf-mem.mjs +0 -0
  36. /package/{tools → lib/tools}/wf-persona.mjs +0 -0
  37. /package/{tools → lib/tools}/wf-pool.mjs +0 -0
  38. /package/{tools → lib/tools}/wf-recent.mjs +0 -0
  39. /package/{tools → lib/tools}/wf-review.mjs +0 -0
  40. /package/{tools → lib/tools}/wf-snapshot.mjs +0 -0
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Work Fish(大肥鱼)
1
+ # Work Fish (dsh-work-fish)
2
2
 
3
3
  A standing work assistant for DeepSeek Harness: it takes an assignment, breaks it down, executes, delivers, and keeps its own task board and memory.
4
4
 
@@ -24,15 +24,9 @@ No install script ships with the package on purpose: the agent on that machine r
24
24
 
25
25
  After install the workbench is created at `%USERPROFILE%\.dsh\work-fish` and holds the task board, memory and rules. To keep it elsewhere, point the `WF_HOME` environment variable at the target directory.
26
26
 
27
- ## The task panel and the desktop pet
27
+ ## The task panel
28
28
 
29
- Work Fish draws no character of its own: the desktop pet belongs to `dsh-pet`, which owns the sprite, the physics, the right-click menu and its settings page. Work Fish adds the ledger side.
30
-
31
- - **Task panel** — a floating card with four tabs (进行中 / 待办 / 等待 / 今日), a button per row (开始 / 推进 / 完成 / 暂停 / 催一下 / 继续) and an inline composer. Open it from the 「🐋 任务」 button in the conversation header, or from the 「大肥鱼」 group in the desktop pet's right-click menu.
32
- - **Pet menu** — 「打开任务板」「开始下一件」「完成进行中」 are registered on the pet at start-up; a click writes through the same `wf-task` CLI the assistant uses.
33
- - **Work status** — the top in-progress row is pushed to the pet as its task line, and a newly overdue row earns one short bubble.
34
-
35
- `dsh-pet` is optional: without it the panel still works from the header button, and `/wf/info` reports the pet as disconnected.
29
+ A floating card with four tabs (进行中 / 待办 / 等待 / 今日), a button per row (开始 / 推进 / 完成 / 暂停 / 催一下 / 继续) and an inline composer. Open it from the 「🐋 任务」 button in the conversation header.
36
30
 
37
31
  ## Usage
38
32
 
@@ -75,9 +69,47 @@ Sandbox escalation asks you every time a call reaches outside the session worksp
75
69
  - DeepSeek Harness 0.2.x
76
70
  - Node.js 22 or newer (the runtime bundled with DSH is enough)
77
71
 
78
- ## Licence
79
72
 
80
- MIT — see [`LICENSE`](LICENSE) for this package's own code. Four skills under `skills/`
73
+ ---
74
+
75
+ ## 中文说明 · 大肥鱼
76
+
77
+ > 常驻在 DeepSeek Harness 里的工作助手。接单、拆解、执行、交付,并自行维护任务板、记忆与规则。
78
+
79
+ > **非官方插件**:第三方作品,与 DeepSeek 官方无关,也未获其背书或授权。
80
+
81
+ 你说一句需求,它先把它变成一份可验收的任务卡,再动手;做完的事留在任务板上,交付物留在 `out/` 里。
82
+ 它不靠记忆里的印象推进工作,靠的是板上的记录和盘上的文件。
83
+
84
+ ## 为什么是它
85
+
86
+ - **模糊需求也接得住**。一句「帮我搞一下 XX」,先写清任务、验收标准、边界和截止,再开工,而不是先猜。
87
+ - **每件事都有账**。任务板一行一件,写验收、下一步、截止;谁在等谁、什么要到期,一眼可查。
88
+ - **做过的判断会沉淀**。重复出现的取舍被记成规则和偏好,下次不必重新交代。
89
+
90
+ ## 能做什么
91
+
92
+ | 场景 | 你可以说 | 它会做 |
93
+ |---|---|---|
94
+ | 说不清的需求 | 帮我搞一下 XX | 先出任务卡,确认验收标准后开工 |
95
+ | 改代码 | 给 XX 加个 YY | 读代码 → 最多问两个问题 → 给两三个方案 → 你点头才改 → 评审后交付 |
96
+ | 提交改动 | 把这几个改动提交了 | 先要授权,过四项检查,按仓库既有格式写消息 |
97
+ | 删东西 | 把 XX 清理掉 | 删除前定级信息损失,留证据,再动手 |
98
+ | 写文档 | 把这整理成一份说明 | 按文档骨架与内容规则产出,落到 `out/` |
99
+ | 长期跟进 | 这个项目你跟着,每周给我进展 | 记成任务板上的长线行,按期推进 |
100
+ | 定规矩 | 以后汇报都用表格 | 记成偏好,不改配置 |
101
+ | 本机出视频 | 在这台机器上生成一段 H3 视频 | 先测硬件,缺什么装什么,跑到出片为止 |
102
+
103
+ 任务面板从会话头部的「🐋 任务」按钮打开。
104
+
105
+ ---
106
+
107
+ ## Licence / 许可
108
+
109
+ MIT — see [LICENSE](LICENSE) for this package's own code. Four skills under `skills/`
81
110
  (`code-review`, `code-simplifier`, `feature-dev`, `frontend-design`) are Apache-2.0 works by
82
111
  Anthropic; their sources, versions, upstream commits and licence files are recorded in
83
- [`THIRD-PARTY-NOTICES.md`](THIRD-PARTY-NOTICES.md).
112
+ [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md).
113
+
114
+ 本包自身的代码以 MIT 发布;`skills/` 下四个 skill 为 Anthropic 的 Apache-2.0 作品,来源与许可见
115
+ [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md)。
@@ -1,6 +1,6 @@
1
1
  # Third-party notices
2
2
 
3
- This package's own code — `core/`, `board/`, `tools/`, `rules/`, `template/`, and the six skills
3
+ This package's own code — `lib/core/`, `lib/board/`, `lib/tools/`, `rules/`, `template/`, and the six skills under `skills/`
4
4
  that carry no licence file of their own — is released under the MIT licence in [`LICENSE`](LICENSE).
5
5
 
6
6
  Four skills under `skills/` are Apache-2.0 works by Anthropic, redistributed here. Their licence
@@ -52,10 +52,8 @@ port; the change list is history, not a summary.
52
52
 
53
53
  | Component | Licence | Where |
54
54
  |---|---|---|
55
- | `dsh-pet` desktop pet (optional) | Code MIT; character artwork may not be used commercially, derivative works must credit | `github.com/PC2005-cloud/dsh-pet` |
56
55
  | ComfyUI (optional, H3 video) | GPL-3.0 | `github.com/comfyanonymous/ComfyUI` |
57
56
  | MiniMax H3 weights (downloaded by the user) | See upstream | `comfy.org/minimax/license` |
58
57
 
59
- None of these ship inside this package. `core/pet-bridge.mjs` calls `dsh-pet`'s own HTTP routes and
60
- contains none of its code or artwork; the `comfyui-h3` skill installs ComfyUI on the user's machine
61
- rather than bundling it.
58
+ None of these ship inside this package: the `comfyui-h3` skill installs ComfyUI on the user's
59
+ machine, and the model weights are downloaded there rather than bundled.
package/cordis.patch.yml CHANGED
@@ -1,13 +1,12 @@
1
- # Work Fish bundle: one preset plus the ledger host that feeds the dsh-pet pet.
1
+ # Work Fish bundle: one preset plus the ledger host behind the task panel.
2
2
  #
3
3
  # Three rows are inserted:
4
4
  # 1. `preset-work-fish` — @deepseek-ai/dsh-agent-preset declaration; mounts the
5
5
  # persona / tools / skills only in sessions that select this preset;
6
- # 2. `work-fish-host` — the ledger host (`core/index.mjs`), a global row:
7
- # installing this bundle seeds the workbench, serves `/wf/*` and pushes the
8
- # current task to the desktop pet regardless of the selected preset. The
9
- # browser half (task panel) is served from the same package through
10
- # `package.json` → `dsh.client`. The character itself belongs to `dsh-pet`.
6
+ # 2. `work-fish-host` — the ledger host (`lib/core/index.mjs`), a global row:
7
+ # installing this bundle seeds the workbench and serves `/wf/*` regardless of
8
+ # the selected preset. The browser half (task panel) is served from the same
9
+ # package through `package.json` → `dsh.client`.
11
10
  # 3. `work-fish-approve` — answers escalation approvals on the user's behalf. Three
12
11
  # kinds of root are trusted: this bundle's own package directory (plus, in a dev
13
12
  # checkout, the checkout that holds `out/`), the workbench directory itself
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Browser half of Work Fish (`dsh-work-fish` client entry).
3
3
  *
4
- * One surface: the task panel. The character that used to stand next to it now
5
- * belongs to `dsh-pet` — that plugin owns the sprite, the physics, the
6
- * right-click menu and the settings page — so this module draws no pet at all.
7
- * What is left is the thing only Work Fish can show: the ledger.
4
+ * One surface: the task panel. It draws no character of its own; what it shows
5
+ * is the thing only Work Fish can show: the ledger.
8
6
  *
9
7
  * Three mounts:
10
8
  *
@@ -15,9 +13,8 @@
15
13
  * by its own header;
16
14
  * - `settings.section` — the persona editor and read-only host facts.
17
15
  *
18
- * The panel is opened from either place: the header button, or the 「大肥鱼」
19
- * group in the desktop pet's right-click menu, which reaches this half through
20
- * the host's `GET /wf/events` long poll.
16
+ * The panel opens from the header button. `GET /wf/events` is the long poll that
17
+ * tells it to refresh after a write elsewhere moved the ledger.
21
18
  *
22
19
  * @module dsh-work-fish/client
23
20
  */
@@ -606,11 +603,11 @@ window.__ModuleLoader__.load({
606
603
  }, [open, load])
607
604
 
608
605
  /**
609
- * Host events: the pet's menu asks for the panel, or a write elsewhere moved
610
- * the ledger. The first poll subscribes from "now", so remounting the panel
611
- * cannot replay a click that happened before it existed; after that the
612
- * cursor follows the host's sequence — zero included, because a restarted
613
- * host starts its sequence over.
606
+ * Host events: a write elsewhere moved the ledger. The first poll
607
+ * subscribes from "now", so remounting the panel cannot replay an event
608
+ * that happened before it existed; after that the cursor follows the
609
+ * host's sequence — zero included, because a restarted host starts its
610
+ * sequence over.
614
611
  */
615
612
  React.useEffect(() => {
616
613
  let alive = true
@@ -629,7 +626,6 @@ window.__ModuleLoader__.load({
629
626
  if (body?.ok !== true) throw new Error(body?.message ?? 'events')
630
627
  if (typeof body.since === 'number') since = body.since
631
628
  for (const event of Array.isArray(body.events) ? body.events : []) {
632
- if (event?.type === 'open') setBoardOpen(true)
633
629
  if (event?.type === 'changed') void load()
634
630
  }
635
631
  } catch {
@@ -833,10 +829,8 @@ window.__ModuleLoader__.load({
833
829
  }
834
830
 
835
831
  /**
836
- * Settings → 大肥鱼: the persona editor plus read-only host facts.
837
- *
838
- * The pet's own preferences (size, physics, notifications) live in
839
- * `dsh-pet`'s settings page now; this section only owns what Work Fish owns.
832
+ * Settings → 大肥鱼: the persona editor plus read-only host facts — only
833
+ * what Work Fish itself owns.
840
834
  */
841
835
  function WorkFishSettings() {
842
836
  const [info, setInfo] = React.useState(null)
@@ -950,10 +944,9 @@ window.__ModuleLoader__.load({
950
944
  const factsCard = h(
951
945
  'section',
952
946
  { className: 'jps-card' },
953
- h('h3', { className: 'jps-title' }, '台账与桌宠'),
947
+ h('h3', { className: 'jps-title' }, '台账'),
954
948
  infoRow('台账', info?.ledger?.path ?? '—', '唯一事实来源,面板与 CLI 读写同一份'),
955
- infoRow('桌宠', info?.pet?.connected === true ? `已连上 ${info.pet.petId}` : info?.pet?.reason || '未连上', '形象与菜单由 dsh-pet 提供'),
956
- infoRow('写入', info?.allowWrites === true ? '允许' : '已关闭', '关掉后桌宠菜单与面板都只能读'),
949
+ infoRow('写入', info?.allowWrites === true ? '允许' : '已关闭', '关掉后面板只能读'),
957
950
  )
958
951
 
959
952
  const personaCard = h(
@@ -40,7 +40,7 @@ import { fileURLToPath } from 'node:url'
40
40
  import { bundleRoots, inspect, trustedRoots } from './approve-paths.mjs'
41
41
  import { resolveWorkHome } from '../tools/lib/paths.mjs'
42
42
 
43
- /** Absolute path of this package's directory (`app/`), the bundle's own root. */
43
+ /** Absolute path of this package's directory (`lib/`), the bundle's own root. */
44
44
  const PACKAGE_DIR = dirname(dirname(fileURLToPath(import.meta.url)))
45
45
 
46
46
  /** Plugin name used by the loader / Cordis row. */
@@ -11,9 +11,8 @@
11
11
  * Skills are not copied either — `core/skills.mjs` registers them from the
12
12
  * package at activation.
13
13
  *
14
- * Seeding used to ride along with the desktop pet; since the pet moved to
15
- * `dsh-pet`, the host entry (`core/index.mjs`) calls this directly, so a fresh
16
- * install still gets a workbench without any character being drawn.
14
+ * The host entry (`core/index.mjs`) calls this once per start, so a fresh install
15
+ * gets a workbench with no extra step.
17
16
  *
18
17
  * @module dsh-work-fish/core/bootstrap
19
18
  */
@@ -23,9 +22,10 @@ import path from 'node:path'
23
22
  import { fileURLToPath } from 'node:url'
24
23
  import { parseSkillFile } from './skills.mjs'
25
24
 
26
- const HERE = path.dirname(fileURLToPath(import.meta.url)) // <pkg>/core
27
- /** `<pkg>`. The skeletons live beside the code, so a packed tarball carries them. */
28
- const PKG_ROOT = path.resolve(HERE, '..')
25
+ const HERE = path.dirname(fileURLToPath(import.meta.url)) // <pkg>/lib/core
26
+ /** `<pkg>`: code sits in `lib/`, skills/rules/template beside it at the package root. */
27
+ const PKG_ROOT = path.resolve(HERE, '..', '..')
28
+ const LIB_DIR = path.join(PKG_ROOT, 'lib')
29
29
  const SKILLS_DIR = path.join(PKG_ROOT, 'skills')
30
30
 
31
31
  /** Skeleton revision; bump when a new release adds required files. */
@@ -165,7 +165,7 @@ export function bootstrap(homeDir, env = process.env) {
165
165
  const indexTemplate = path.join(PKG_ROOT, 'template', 'rules-index.md')
166
166
  if (fs.existsSync(indexTemplate)) {
167
167
  const rulesDir = path.join(PKG_ROOT, 'rules').split(path.sep).join('/')
168
- const toolsDir = path.join(PKG_ROOT, 'tools').split(path.sep).join('/')
168
+ const toolsDir = path.join(LIB_DIR, 'tools').split(path.sep).join('/')
169
169
  const index = fs.readFileSync(indexTemplate, 'utf8').replace(/\{\{(\w+)\}\}/g, (placeholder, name) => {
170
170
  // One pass, so text inserted for one placeholder is never re-scanned and
171
171
  // a skill description that mentions {{TOOLS_DIR}} stays literal.
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Panel event bus: the bridge pushes, `GET /wf/events` drains.
2
+ * Panel event bus: the host pushes, `GET /wf/events` drains.
3
3
  *
4
4
  * The task panel lives in the browser while the events that should move it are
5
- * detected by the host (a right-click menu item on the `dsh-pet` character, or
6
- * a ledger write performed on its behalf). Polling `/wf/tasks` every second
5
+ * detected by the host (a ledger write from the panel or from `wf-task` on the
6
+ * CLI). Polling `/wf/tasks` every second
7
7
  * would answer "did anything change" by re-reading the ledger each time, so the
8
8
  * host keeps a tiny in-memory sequence instead and the client long-polls it.
9
9
  *
@@ -28,7 +28,7 @@ const waiters = new Set()
28
28
 
29
29
  /**
30
30
  * Record one event and wake every pending poll.
31
- * @param {'open' | 'changed'} type what the panel should do.
31
+ * @param {'changed'} type what the panel should do.
32
32
  * @returns {number} the sequence number assigned.
33
33
  */
34
34
  export function pushEvent(type) {
@@ -43,7 +43,7 @@ export function pushEvent(type) {
43
43
  * Read every event newer than a cursor, optionally waiting for one.
44
44
  *
45
45
  * `since === null` means "subscribe from now": a freshly mounted panel must not
46
- * see the `open` of a click that happened before it existed. A cursor from a
46
+ * see a change that happened before it existed. A cursor from a
47
47
  * previous process (larger than the current sequence) is reported as `reset`
48
48
  * and also starts from now, so a restarted host cannot silently swallow the
49
49
  * next real event.
@@ -29,29 +29,29 @@ export const inject = ['tools']
29
29
  const GUARDED = new Set(['write', 'edit', 'apply_patch'])
30
30
 
31
31
  /** Where the rule-write tool lives, for the refusal text. */
32
- const WF_RULE = 'node app/tools/wf-rule.mjs'
32
+ const WF_RULE = 'node lib/tools/wf-rule.mjs'
33
33
 
34
34
  /** First match wins: which tool owns a protected path. */
35
35
  const OWNERS = [
36
36
  {
37
37
  test: (p) => p === 'persona.md' || p === 'persona.full.md',
38
38
  tool: 'wf-persona',
39
- how: 'node app/tools/wf-persona.mjs',
39
+ how: 'node lib/tools/wf-persona.mjs',
40
40
  },
41
41
  {
42
42
  test: (p) => p.startsWith('tasks/') || p.startsWith('board/'),
43
43
  tool: 'wf-task',
44
- how: 'node app/tools/wf-task.mjs',
44
+ how: 'node lib/tools/wf-task.mjs',
45
45
  },
46
46
  {
47
47
  test: (p) => p === 'memory/pool/experience.md',
48
48
  tool: 'wf-pool',
49
- how: 'node app/tools/wf-pool.mjs',
49
+ how: 'node lib/tools/wf-pool.mjs',
50
50
  },
51
51
  {
52
52
  test: (p) => p.startsWith('memory/'),
53
53
  tool: 'wf-mem',
54
- how: 'node app/tools/wf-mem.mjs',
54
+ how: 'node lib/tools/wf-mem.mjs',
55
55
  },
56
56
  {
57
57
  test: (p) => p === 'rules/INDEX.md',
@@ -65,11 +65,11 @@ const OWNERS = [
65
65
  },
66
66
  ]
67
67
 
68
- /** The package root: app/core → package root. Rules there ship with the plugin. */
68
+ /** The package root: lib/core → package root. Rules there ship with the plugin. */
69
69
  function pluginRoot() {
70
70
  const override = process.env.WF_PLUGIN_ROOT
71
71
  if (override && override.trim()) return resolve(override)
72
- return resolve(dirname(fileURLToPath(import.meta.url)), '..')
72
+ return resolve(dirname(fileURLToPath(import.meta.url)), '..', '..')
73
73
  }
74
74
 
75
75
  /**
@@ -1,19 +1,15 @@
1
1
  /**
2
2
  * Host half of the Work Fish bundle (`dsh-work-fish` root entry).
3
3
  *
4
- * Work Fish no longer draws a character of its own: the desktop pet belongs to
5
- * `dsh-pet`, which owns the sprite, the physics and the right-click menu. This
6
- * half keeps what is Work Fish's own — the task ledger — and offers it to three
7
- * consumers under one prefix:
4
+ * This half keeps what is Work Fish's own — the task ledger — and offers it to
5
+ * two consumers under one prefix:
8
6
  *
9
7
  * 1. the task panel's payload (`GET /wf/tasks`), read from `tasks/index.md`
10
8
  * on every request — never cached, so the panel can never disagree with
11
9
  * the file;
12
10
  * 2. the workbench itself: first-run seeding, the persona store, diagnostics
13
- * (`/wf/info`, `/wf/client-report`);
14
- * 3. `./pet-bridge.mjs`, which feeds the current task to `dsh-pet` and turns
15
- * the pet's menu items into ledger writes, plus `GET /wf/events`, the
16
- * long-poll that tells the panel when to open or refresh.
11
+ * (`/wf/info`, `/wf/client-report`), plus `GET /wf/events`, the long-poll
12
+ * that tells the panel when to open or refresh.
17
13
  *
18
14
  * Writes are CAS-guarded by `expectRev` and go through `tools/wf-task.mjs`, the
19
15
  * same CLI path the assistant uses; there is no second ledger implementation.
@@ -29,8 +25,7 @@ import { execFile } from 'node:child_process'
29
25
 
30
26
  import { buildReport } from './report.mjs'
31
27
  import { bootstrap } from './bootstrap.mjs'
32
- import { waitEvents } from './events.mjs'
33
- import { startPetBridge } from './pet-bridge.mjs'
28
+ import { pushEvent, waitEvents } from './events.mjs'
34
29
 
35
30
  /** Plugin name used by the loader / Cordis row. */
36
31
  export const name = 'work-fish'
@@ -285,17 +280,29 @@ export function apply(ctx, config) {
285
280
  }
286
281
  }
287
282
 
288
- // The character belongs to `dsh-pet`; this is the one place that talks to it.
289
- const bridge = startPetBridge({
290
- options,
291
- logger: ctx.logger,
292
- getOrigin: serverOrigin,
293
- runCli,
294
- buildReport,
295
- })
296
- // The bridge runs its own timers and long poll: hand its shutdown to the
297
- // row's lifetime, or a reloaded row leaves a second poller behind.
298
- web.effect(() => () => bridge.stop(), 'wf: pet bridge')
283
+ /** The ledger this host serves. */
284
+ const ledgerPath = `${options.homeDir}/tasks/index.md`
285
+
286
+ /**
287
+ * Watch the ledger's modification time: a write from `wf-task` on the CLI
288
+ * happens outside this process, so the file is the only way an open panel
289
+ * hears about it before its own slow poll comes round.
290
+ */
291
+ let ledgerStamp = ''
292
+ const watchLedger = setInterval(() => {
293
+ let stamp
294
+ try {
295
+ stamp = String(fs.statSync(ledgerPath).mtimeMs)
296
+ } catch {
297
+ return
298
+ }
299
+ if (ledgerStamp !== '' && stamp !== ledgerStamp) pushEvent('changed')
300
+ ledgerStamp = stamp
301
+ }, 4000)
302
+ // Never hold the process open on this timer's account; the effect below is
303
+ // what actually stops it when the row unloads.
304
+ watchLedger.unref?.()
305
+ web.effect(() => () => clearInterval(watchLedger), 'wf: ledger watch')
299
306
 
300
307
  /**
301
308
  * Register one exact route, containing its failure to that route.
@@ -335,7 +342,6 @@ export function apply(ctx, config) {
335
342
  `${ROUTE_PREFIX}/info`,
336
343
  'GET',
337
344
  async (_request, response) => {
338
- const ledgerPath = `${options.homeDir}/tasks/index.md`
339
345
  let ledgerReadable = false
340
346
  try {
341
347
  ledgerReadable = fs.statSync(ledgerPath).isFile()
@@ -352,7 +358,6 @@ export function apply(ctx, config) {
352
358
  timeZone: options.timeZone,
353
359
  allowWrites: options.allowWrites,
354
360
  ledger: { path: ledgerPath, readable: ledgerReadable },
355
- pet: bridge.status(),
356
361
  client: { reports: clientReports.slice(-10) },
357
362
  })
358
363
  },
@@ -381,7 +386,7 @@ export function apply(ctx, config) {
381
386
  'POST',
382
387
  async (request, response) => {
383
388
  if (!options.allowWrites) {
384
- writeJson(response, 403, { ok: false, code: 'writes-disabled', message: '桌宠写台账已在配置里关闭' })
389
+ writeJson(response, 403, { ok: false, code: 'writes-disabled', message: '写台账已在配置里关闭' })
385
390
  return
386
391
  }
387
392
  if (!admitted(request, serverOrigin())) {
@@ -413,6 +418,9 @@ export function apply(ctx, config) {
413
418
  : result?.verdict === 'MISSING'
414
419
  ? 404
415
420
  : 400
421
+ // Broadcast at once: the file watcher would find the same change
422
+ // within its interval, but the panel that made it is already open.
423
+ if (result?.ok === true) pushEvent('changed')
416
424
  writeJson(response, status, result ?? { ok: false, code: 'empty', message: '写入没有返回结果' })
417
425
  } catch (error) {
418
426
  const code = /** @type {{code?: string}} */ (error)?.code
@@ -428,13 +436,12 @@ export function apply(ctx, config) {
428
436
  )
429
437
  }
430
438
 
431
- /** Every write goes through `wf-task`, tagged so the event log shows 桌宠. */
439
+ /** Every write goes through `wf-task`, so the ledger and its event log agree. */
432
440
  const cli = (command, body, extra = []) => runCli([
433
441
  command,
434
442
  '--task', body.task,
435
443
  '--expect-rev', String(body.expectRev),
436
444
  ...extra,
437
- '--source', '桌宠',
438
445
  ])
439
446
  const move = (body, to, extra = []) => cli('move', body, ['--to', to, ...extra])
440
447
  const passed = (value, flag) => (value === undefined || value === null || value === '' ? [] : [flag, String(value)])
@@ -27,8 +27,8 @@ import { fileURLToPath } from 'node:url'
27
27
  import { resolveWorkHome } from './paths.mjs'
28
28
 
29
29
  const HERE = path.dirname(fileURLToPath(import.meta.url))
30
- /** `<pkg>/tools/lib` → `<pkg>` (holds `template/`). */
31
- const SOURCE_ROOT = path.resolve(HERE, '..', '..')
30
+ /** `<pkg>/lib/tools/lib` → `<pkg>` (holds `template/`). */
31
+ const SOURCE_ROOT = path.resolve(HERE, '..', '..', '..')
32
32
 
33
33
  /** Hard ceiling for either mode, in UTF-8 bytes. */
34
34
  export const LIMIT_BYTES = 32 * 1024
@@ -397,7 +397,7 @@ function decideTaskUnlogged(doc, options = {}) {
397
397
  }
398
398
 
399
399
  export function newTask(file, options = {}) {
400
- const { title, accept, relation, section = '待办', priority = '中', deadline = '未定', next = '确认验收后开工', note = '依据:用户交办', mode = null, eventsFile, source } = options
400
+ const { title, accept, relation, section = '待办', priority = '中', deadline = '未定', next = '确认验收后开工', note = '依据:用户交办', mode = null, eventsFile } = options
401
401
  if (!title) return { ok: false, code: 4, verdict: 'ERROR', message: 'new 需要 task 标题' }
402
402
  if (!accept) return { ok: false, code: 4, verdict: 'ERROR', message: 'new 需要 accept 验收' }
403
403
  const normalized = normalizeRelation(relation)
@@ -420,7 +420,7 @@ export function newTask(file, options = {}) {
420
420
  : [id, title, accept, priority, deadline, next, token]
421
421
  appendRow(doc, section, cells)
422
422
  saveLedger(file, renderLedger(doc))
423
- if (eventsFile) appendEvent(eventsFile, { action: 'new', task: id, rev: 1, relation: normalized, section, title, ...(source === undefined ? {} : { source }) })
423
+ if (eventsFile) appendEvent(eventsFile, { action: 'new', task: id, rev: 1, relation: normalized, section, title })
424
424
  return { ok: true, verdict: 'ACC', task: id, rev: 1, relation: normalized, section, mode }
425
425
  })
426
426
  }
@@ -471,7 +471,7 @@ export function bumpTask(file, options = {}) {
471
471
  cells[noteIndex] = withToken(rest, found.note.rev + 1, relationToUse)
472
472
  section.rows[found.index] = cells
473
473
  saveLedger(file, renderLedger(doc))
474
- if (eventsFile) appendEvent(eventsFile, { action: 'bump', task, fromRev: found.note.rev, toRev: found.note.rev + 1, ...(options.source === undefined ? {} : { source: options.source }) })
474
+ if (eventsFile) appendEvent(eventsFile, { action: 'bump', task, fromRev: found.note.rev, toRev: found.note.rev + 1 })
475
475
  return { ok: true, verdict: 'ACC', task, rev: found.note.rev + 1, relation: relationToUse }
476
476
  })
477
477
  }
@@ -479,7 +479,7 @@ export function bumpTask(file, options = {}) {
479
479
  /**
480
480
  * Move one active row to another section of the ledger.
481
481
  *
482
- * Used by the Work Fish pet's task bubble (start / pause / finish / wait) and by
482
+ * Used by the task panel's per-row buttons (start / pause / finish / wait) and by
483
483
  * the CLI's `move` command. The move is a CAS write: the caller passes the
484
484
  * revision it read, and a mismatch returns STALE without touching the file.
485
485
  *
@@ -499,12 +499,11 @@ export function bumpTask(file, options = {}) {
499
499
  * @param {string} [options.chase] when to chase (等待他人).
500
500
  * @param {string} [options.note] extra text appended to the note.
501
501
  * @param {string} [options.marker] action label appended to the note.
502
- * @param {string} [options.source] writer label, default 桌宠.
503
502
  * @param {string} [options.eventsFile] event log path.
504
503
  * @returns {object} ACC / STALE / MISSING / COMPLETED / ERROR.
505
504
  */
506
505
  export function moveTask(file, options = {}) {
507
- const { task, expectRev, to, relation, priority, deadline, next, result, deliverable, who, what, chase, note, marker, source = '桌宠', eventsFile } = options
506
+ const { task, expectRev, to, relation, priority, deadline, next, result, deliverable, who, what, chase, note, marker, eventsFile } = options
508
507
  if (!task) return { ok: false, code: 4, verdict: 'ERROR', message: 'move 需要 task' }
509
508
  if (!Number.isInteger(expectRev)) return { ok: false, code: 4, verdict: 'ERROR', message: 'move 需要 expectRev' }
510
509
  const targets = ['进行中', '待办', '等待他人', '已完成']
@@ -540,7 +539,7 @@ export function moveTask(file, options = {}) {
540
539
  const sourceNext = from === '待办' || from === '进行中' ? cells[5] : ''
541
540
  const rest = found.note.rest
542
541
  const labels = { 进行中: '开始', 待办: '暂停', 等待他人: '等待', 已完成: '完成' }
543
- const stamp = `${source} ${localDate()} ${localTime()} ${marker || labels[to]}`
542
+ const stamp = `${localDate()} ${localTime()} ${marker || labels[to]}`
544
543
  const newRest = `${rest ? `${rest} · ` : ''}${stamp}${note ? ` ${note}` : ''}`
545
544
  const nextRev = found.note.rev + 1
546
545
  let targetCells
@@ -582,7 +581,6 @@ export function moveTask(file, options = {}) {
582
581
  to,
583
582
  fromRev: found.note.rev,
584
583
  toRev: to === '已完成' ? 0 : nextRev,
585
- source,
586
584
  })
587
585
  }
588
586
  return { ok: true, verdict: 'ACC', task, from, to, rev: to === '已完成' ? 0 : nextRev, relation: relationToUse ?? null }
@@ -600,12 +598,11 @@ export function moveTask(file, options = {}) {
600
598
  * @param {string} options.task task id.
601
599
  * @param {number} options.expectRev revision the caller read.
602
600
  * @param {string} options.reason why the row leaves the board.
603
- * @param {string} [options.source] writer label, default 桌宠.
604
601
  * @param {string} [options.eventsFile] event log path.
605
602
  * @returns {object} ACC / STALE / MISSING / ERROR.
606
603
  */
607
604
  export function dropTask(file, options = {}) {
608
- const { task, expectRev, reason, source = '桌宠', eventsFile } = options
605
+ const { task, expectRev, reason, eventsFile } = options
609
606
  if (!task) return { ok: false, code: 4, verdict: 'ERROR', message: 'drop 需要 task' }
610
607
  if (!Number.isInteger(expectRev)) return { ok: false, code: 4, verdict: 'ERROR', message: 'drop 需要 expectRev' }
611
608
  const why = String(reason ?? '').trim()
@@ -643,7 +640,7 @@ export function dropTask(file, options = {}) {
643
640
  )
644
641
  }
645
642
  fs.appendFileSync(archiveFile, `${joinRow([task, cells[1] ?? '', sectionName, why, stamp, cells.slice(2).join(' / ')])}\n`, 'utf8')
646
- if (eventsFile) appendEvent(eventsFile, { action: 'drop', task, from: sectionName, reason: why, source })
643
+ if (eventsFile) appendEvent(eventsFile, { action: 'drop', task, from: sectionName, reason: why })
647
644
  return { ok: true, verdict: 'ACC', task, from: sectionName, archive: archiveFile }
648
645
  })
649
646
  }
@@ -651,8 +648,8 @@ export function dropTask(file, options = {}) {
651
648
  /**
652
649
  * Append one progress line to an active row and bump its revision.
653
650
  *
654
- * The note keeps its `[rN][relation]` token; the new text is appended with a
655
- * timestamped writer label, so the ledger records who advanced the task.
651
+ * The note keeps its `[rN][relation]` token; the new text is appended after a
652
+ * timestamp, so every progress line is dated in the ledger.
656
653
  *
657
654
  * @param {string} file ledger path.
658
655
  * @param {object} options progress options.
@@ -660,12 +657,11 @@ export function dropTask(file, options = {}) {
660
657
  * @param {number} options.expectRev revision the caller read.
661
658
  * @param {string} options.text progress sentence.
662
659
  * @param {string} [options.next] replacement next step.
663
- * @param {string} [options.source] writer label, default 桌宠.
664
660
  * @param {string} [options.eventsFile] event log path.
665
661
  * @returns {object} ACC / STALE / MISSING / COMPLETED / ERROR.
666
662
  */
667
663
  export function progressTask(file, options = {}) {
668
- const { task, expectRev, text, next, source = '桌宠', eventsFile } = options
664
+ const { task, expectRev, text, next, eventsFile } = options
669
665
  if (!task) return { ok: false, code: 4, verdict: 'ERROR', message: 'progress 需要 task' }
670
666
  if (!Number.isInteger(expectRev)) return { ok: false, code: 4, verdict: 'ERROR', message: 'progress 需要 expectRev' }
671
667
  const addition = String(text ?? '').trim()
@@ -691,7 +687,7 @@ export function progressTask(file, options = {}) {
691
687
  const section = found.section
692
688
  const noteIndex = section.header.length - 1
693
689
  const rest = found.note.rest
694
- const stamp = `${source} ${localDate()} ${localTime()}`
690
+ const stamp = `${localDate()} ${localTime()}`
695
691
  const newRest = `${rest ? `${rest} · ` : ''}${stamp} ${addition}`
696
692
  const cells = found.cells.slice()
697
693
  cells[noteIndex] = withToken(newRest, found.note.rev + 1, relation)
@@ -705,7 +701,6 @@ export function progressTask(file, options = {}) {
705
701
  fromRev: found.note.rev,
706
702
  toRev: found.note.rev + 1,
707
703
  text: addition,
708
- source,
709
704
  })
710
705
  }
711
706
  return { ok: true, verdict: 'ACC', task, rev: found.note.rev + 1, text: addition }
@@ -20,7 +20,7 @@ import { join, sep } from 'node:path'
20
20
  import { loadLedger } from './lib/taskboard.mjs'
21
21
  import { resolveWorkHome } from './lib/paths.mjs'
22
22
 
23
- const POOL_PATH = 'rules/experience-pool.md'
23
+ const POOL_PATH = 'memory/pool/experience.md'
24
24
  const RULES_PATH = 'rules/code-rules.md'
25
25
  const LEDGER_PATH = 'tasks/index.md'
26
26
  const EVENTS_PATH = '.tmp/ledger-events.jsonl'
@@ -30,7 +30,7 @@ const CLOSED_STATUS = ['已提升', '未成规则']
30
30
  // 这几份文档里出现的是设计目标名或在举反例,不是条款引用;计入会误算成「在用」(该提示已停用:条款去编号)
31
31
  const CITATION_SKIP_FILES = new Set([
32
32
  RULES_PATH,
33
- 'rules/experience-pool.md',
33
+ 'memory/pool/experience.md',
34
34
  '设计方案.md',
35
35
  '记账监督机制设计方案.md',
36
36
  '经验提炼与量化设计方案.md',
@@ -61,13 +61,11 @@ function alert(scene) {
61
61
  function sections(scene) {
62
62
  const over = scene === 'warn'
63
63
 
64
- // 桌面偏好(尺寸、物理、通知)已归 dsh-pet 的设置页,这里只剩大肥鱼自己的事实。
65
64
  const facts = card(
66
- '台账与桌宠',
65
+ '台账',
67
66
  [
68
67
  row({ label: '台账', hint: '唯一事实来源,面板与 CLI 读写同一份', value: '%USERPROFILE%\\.dsh\\work-fish\\tasks\\index.md' }),
69
- row({ label: '桌宠', hint: '形象与菜单由 dsh-pet 提供', value: '已连上 main' }),
70
- row({ label: '写入', hint: '关掉后桌宠菜单与面板都只能读', value: '允许' }),
68
+ row({ label: '写入', hint: '关掉后面板只能读', value: '允许' }),
71
69
  ].join(''),
72
70
  )
73
71
 
@@ -52,11 +52,11 @@ function workHome() {
52
52
  return join(dshHome, 'work-fish')
53
53
  }
54
54
 
55
- /** Package root, derived from this file: app/tools → package root. */
55
+ /** Package root, derived from this file: lib/tools → package root. */
56
56
  function pluginRoot() {
57
57
  const override = process.env.WF_PLUGIN_ROOT
58
58
  if (override && override.trim()) return resolve(override)
59
- const root = resolve(dirname(fileURLToPath(import.meta.url)), '..')
59
+ const root = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..')
60
60
  if (root.includes('app.asar')) fail(1, `插件包是只读副本,规则写不进去:${root}`)
61
61
  return root
62
62
  }