@yolk_vat-y/dsh-project-memory 0.7.2 → 0.7.3

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 CHANGED
@@ -1,3 +1,14 @@
1
+ ## 0.7.3 (2026-12-01)
2
+
3
+ **兼容**:无新增配置键,无 store 格式变更,`client/` 产物不变,直接覆盖升级。
4
+
5
+ - **任务级记忆按 id 直接读写**:`query_memory` 与 `save_lesson` 都接受 `task_id`(本地任务或宿主团队任务 `task-<n>`),不绑定会话也能读写该任务的记忆;团队任务首次写入时自动建锚点。
6
+ - **归属校验**:未知、别的团队或已删除的团队任务直接报错;`list_tasks`、面板、按 id 更新/删除也只暴露本会话可见的任务;已归档任务不参与召回。
7
+ - **空锚点回收**:超过 30 天没有活动、没有任务级记忆也没有会话绑定的团队锚点自动回收;写盘合并后才删,不会删掉另一进程刚写进去的记忆。
8
+ - **参数冲突显式报错**:`task_id` 与 `type: 'task'` 同时给出时会说明两者区别,显式 `scope` 优先。
9
+ - **内部**:跨进程按 id 合并收敛到同一实现,无行为变化。
10
+ - **工具描述瘦身**:`save_lesson` 的 trigger 细则与 `query_memory` 的用法移进 `project-memory` skill,常驻 schema 变小。
11
+
1
12
  ## 0.7.2 (2026-11-24)
2
13
 
3
14
  **兼容**:无新增配置键,记忆库格式不变;`client/` 产物已重建,直接覆盖升级。
package/README.md CHANGED
@@ -15,7 +15,7 @@ A persistent **project development memory** for [DeepSeek Harness](https://githu
15
15
 
16
16
  ## Features
17
17
 
18
- - **TaskBridge: cross-session development tasks** — the session's todo list and the files it touches are persisted as per-project task entities, so a workflow can be switched and resumed without re-scoping the project. Associated files stay in recency-weighted order (a read never outranks a written file), so a resumed session sees where to look first. New sessions continue with `list_tasks` → `select_task`. Work delegated to subagents creates no task (a teammate can still bind a host team task to share its memory). On hosts without session events the task tools still work as a plain record list.
18
+ - **TaskBridge: cross-session development tasks** — the session's todo list and the files it touches are persisted as per-project task entities, so a workflow can be switched and resumed without re-scoping the project. Associated files stay in recency-weighted order (a read never outranks a written file), so a resumed session sees where to look first. New sessions continue with `list_tasks` → `select_task`. Work delegated to subagents creates no task (a teammate can still bind a host team task to share its memory, or read/write that task's memory directly by `task_id` without binding). On hosts without session events the task tools still work as a plain record list.
19
19
  - **Task panel and editing** — draggable cards show a task's steps and files, and can collapse to a mini-bar or be hidden. Title, steps and status can be edited inline, writing back through the same path as model updates; four visual themes change material, geometry, typeface and density only, and colours follow the host. The panel stays hidden until summoned, syncs in the background on session switch, never reopens itself after a refresh, and a render failure cannot take down the host. Tasks are listed most recently active first; the list scrolls, keeps its height when a card expands, and renders more cards as you reach the bottom.
20
20
  - **Document memory** — PDF, Markdown and plain text are chunked and summarized without a model call. Each entry keeps a short summary for injection, a bounded term set for recall, and a citation back to the source.
21
21
  - **Code symbol memory** — a dependency-free scanner extracts functions, classes, methods, interfaces and type aliases with signatures; covered languages are JavaScript/TypeScript, Python, Go, Rust, C/C++/C#, Java and shell. Where `typescript` is installed, an optional second layer adds inferred return types, generics and interface shapes; it runs in the background and never blocks indexing.
@@ -56,15 +56,15 @@ The tools below are **invoked by the agent**, not typed by the user. In the chat
56
56
  | `index_repo root` | Index a whole project: documents get deterministic summaries, code files get a token-free symbol table. Incremental and self-healing: the store follows the file listing, so deleted, ignored or moved files are dropped (an entry created by an explicit `index_doc` is kept while its file still exists), and documents are cross-linked to symbols. A non-existent or excluded root is rejected before anything is written. |
57
57
  | `watch_repo root` | Enable automatic refresh: a background poll detects new and changed files and re-indexes only those. A watched root is recorded in that project's store, so it resumes when dsh starts there; a non-existent or excluded root is refused, roots that disappear are dropped rather than re-created. |
58
58
  | `pm_stats root` | Show what the store contains: totals, last index time, and the per-file list sorted by recency. Background index failures (watch or lazy, per root, most recent 50) are reported alongside, so a file that never made it into the corpus stays visible. |
59
- | `query_memory query` | Ranked search over documents, symbols, experience and insights, optionally query-expanded by the LLM. `type` selects a layer (`all` / `doc` / `symbol` / `experience` / `insight` / `task`). Returns hits with relative scores, sources or insight ids, and doc→symbol references. |
60
- | `list_tasks` | List task records for the project (archived marked). Call first in a new session before continuing work. |
59
+ | `query_memory query` | Ranked search over documents, symbols, experience and insights, optionally query-expanded by the LLM. `type` selects a layer (`all` / `doc` / `symbol` / `experience` / `insight` / `task`). Returns hits with relative scores, sources or insight ids, and doc→symbol references. `task_id` (local id or host team `task-<n>`) exposes that task's task-level memory for this call without binding the session. |
60
+ | `list_tasks` | List the task records visible to this session (archived marked; another team's task anchors stay hidden). Call first in a new session before continuing work. |
61
61
  | `select_task` | Bind the session to a task so its todo list and file reads sync into it. Exact `taskId`, or exact `title` (multiple matches return candidates; no match creates a new task). Pass `title` with `taskId` to rename. Auto-unarchives. On team-enabled hosts a host team task id (`task-<n>`) also works: teammates selecting the same team task share its task-scoped memory. |
62
62
  | `archive_task` | Archive a task (hide from default views, exclude from capacity, stop syncing, unbind the sessions that had it selected; archived tasks are also skipped by injection and recall). `select_task` restores it. |
63
63
  | `show_task_panel` | Show the task panel in the UI. Call when the user asks to see the task list or when you want to display the panel. |
64
64
  | `/tasks` (typed by the user, not the model) | The only user command: shows the task stack and drives the workflow card (tasks bound to a host team task are labeled with it). Every other action is a **sub-verb** invoked by card buttons: `switch` / `archive` / `unbind` / `rename` / `todos …` / `step` / `step-move` / `step-text` for tasks, `insight list [scope] [offset] [limit]` / `confirm` / `promote` / `demote` / `archive` / `restore` / `delete` / `save` / `edit` for memory. |
65
65
  | `remember problem solution` | Save an experience note. It is a `kind: 'experience'` insight — same store, same dedup and same delete path as lessons / decisions / procedures. Similar problems merge or overwrite instead of duplicating. |
66
66
  | `forget id_or_query` | Delete memories — lessons / decisions / procedures and experience notes alike, across task / project / global in one call, without knowing which layer the entry lives in. An exact id deletes that one entry; keywords match by **query-side coverage** (matched query terms ÷ query terms). Real deletion, no undo; when keywords match more than the cap (default 10) it deletes nothing and only lists the candidates. The **5** most recently deleted entries are kept as full entries in that layer's `deleted.json` next to its store (`<root>/.dsh-project-memory/deleted.json` for the project layer, beside the global file for global), and the deletion result prints that path — read it and save again to recover a mis-delete. |
67
- | `save_lesson` | Save a lesson / decision / procedure at task, project or global scope; passing `id` **overwrites that entry in place** (only the fields you pass, the previous values stay in `prev` — write them back with the same id). Before writing it compares against existing memory: cosine ≥ 0.9 auto-overwrites that entry, ≥ 0.7 reports the nearest id in the result; without `leanvec` it falls back to lexical overlap ≥ 0.7 merge / 0.65–0.7 reinforce. Two tasks hitting the same insight promote it task → project, three or more → global. Key params: `id`, `title`, `kind`, `scope`, the content (`pattern`/`fix`, `choice`/`reason` or `steps`), and `trigger` (`when` is the only trigger surface, `guard` narrows it, `prevents` records what breaks without it). |
67
+ | `save_lesson` | Save a lesson / decision / procedure at task, project or global scope; passing `id` **overwrites that entry in place** (only the fields you pass, the previous values stay in `prev` — write them back with the same id). Before writing it compares against existing memory: cosine ≥ 0.9 auto-overwrites that entry, ≥ 0.7 reports the nearest id in the result; without `leanvec` it falls back to lexical overlap ≥ 0.7 merge / 0.65–0.7 reinforce. Two tasks hitting the same insight promote it task → project, three or more → global. Key params: `id`, `title`, `kind`, `scope`, the content (`pattern`/`fix`, `choice`/`reason` or `steps`), and `trigger` (`when` is the only trigger surface, `guard` narrows it, `prevents` records what breaks without it). `task_id` (local id or host team `task-<n>`) selects that task for task-scope writes; an explicit `scope` wins, and dedup may still merge/promote the entry to project or global. A team task's memory anchor is created on first task-scope write, so no `select_task` is needed. |
68
68
 
69
69
  `/tasks` appears in the web `/` menu inside an icon-bearing **Workflow** group, with three view entries — Tasks / Project Memory / Global Memory (labelled in the UI language). It is the plugin's only registered command; every other action rides it as a sub-verb driven by card buttons.
70
70
 
@@ -194,7 +194,7 @@ These commands are for **maintaining the plugin code** — regular users do not
194
194
 
195
195
  ```bash
196
196
  npm install
197
- npm test # 1136 tests
197
+ npm test # 1149 tests
198
198
  npm run eval:injection # synthetic pool P/R: precision 0.93 / recall 1.00, + a 3-scenario hint-only group
199
199
  npm run eval:injection -- --store .dsh-project-memory/insights.json # replay on YOUR store; control group is a hard gate
200
200
  npm run selfcheck:triggers # which entries can still push, which declarations are dead (reads your local store)
package/README.zh-CN.md CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  ## 特性
16
16
 
17
- - **TaskBridge:跨会话开发任务** — 会话内的任务清单与触碰过的文件持久化为项目任务实体,工作流可以随时切走再续接,不必重新界定项目范围。关联文件按最近活跃排序(读取永远不越过写过的文件),续接时一眼看到该先看哪些。新会话通过 `list_tasks` → `select_task` 续接。委派给子代理的工作不会建档(队友可显式绑定宿主团队任务来共享其记忆)。宿主不提供会话事件时,任务工具仍可作为普通记录列表使用。
17
+ - **TaskBridge:跨会话开发任务** — 会话内的任务清单与触碰过的文件持久化为项目任务实体,工作流可以随时切走再续接,不必重新界定项目范围。关联文件按最近活跃排序(读取永远不越过写过的文件),续接时一眼看到该先看哪些。新会话通过 `list_tasks` → `select_task` 续接。委派给子代理的工作不会建档(队友可显式绑定宿主团队任务来共享其记忆,也可以直接用 `task_id` 读写该任务的记忆,不必绑定)。宿主不提供会话事件时,任务工具仍可作为普通记录列表使用。
18
18
  - **任务面板与编辑** — 卡片可拖拽,展示任务步骤与涉及文件,可折叠为迷你条或彻底隐藏;标题、步骤与状态支持行内编辑,与模型更新走同一条写回路径;四档外观风格只改材质、几何、字型与密度,颜色跟随宿主。面板默认隐藏,仅在显式唤起后出现;会话切换只后台同步,刷新页面不会自行打开;渲染错误有边界兜底,面板崩溃不会拖垮宿主。任务按最近活跃排序(最新的在前);列表可滚动,卡片展开不会被压扁,滚到底部继续渲染后面的卡。
19
19
  - **文档记忆** — PDF、Markdown 与纯文本按块切分并生成摘要,索引期不调用模型。每条保留一段简短摘要供注入、一个有界的检索词集合,以及回源引用。
20
20
  - **代码符号记忆** — 零依赖扫描器提取函数、类、方法、接口与类型别名及其签名,覆盖 JavaScript/TypeScript、Python、Go、Rust、C/C++/C#、Java 与 shell。项目装了 `typescript` 时,可选第二层补推导返回类型、泛型与接口,后台执行、不阻塞索引。
@@ -54,15 +54,15 @@ dsh plugin --profile web add @yolk_vat-y/dsh-project-memory -w
54
54
  | `index_repo root` | 索引整个项目:文档生成确定性摘要,代码文件生成零 token 符号表。增量更新,store 跟随文件清单:已删除、被忽略或移走的文件会被清理(显式 `index_doc` 的条目只要文件还在就保留);文档与符号交叉链接。根目录不存在或在排除名单上时,会在写入任何内容前拒绝。 |
55
55
  | `watch_repo root` | 启用自动刷新:后台轮询检测新增/变更文件,仅重抽这些文件。监听根会记在该项目的 store 里,在该项目下启动 dsh 时恢复监听;不存在或在排除名单上的根目录会被拒绝,已消失的根目录会被丢弃而不是被重新创建。 |
56
56
  | `pm_stats root` | 查看记忆库内容:总量、最近索引时间,以及按时间排序的逐文件清单。后台索引失败(watch / 懒索引,按根记账、最多 50 条)也会一并报出,让「文件一直没进语料」可见。 |
57
- | `query_memory query` | 对文档、符号、经验与 insight 执行排序检索,可选 LLM 查询扩展。`type` 选择层(`all` / `doc` / `symbol` / `experience` / `insight` / `task`)。返回带相对分数、引用或 insight id、以及文档→符号链接的结果。 |
58
- | `list_tasks` | 列出本项目任务记录(含归档,带标记)。新会话/续接前先调用。 |
57
+ | `query_memory query` | 对文档、符号、经验与 insight 执行排序检索,可选 LLM 查询扩展。`type` 选择层(`all` / `doc` / `symbol` / `experience` / `insight` / `task`)。返回带相对分数、引用或 insight id、以及文档→符号链接的结果。`task_id`(本地 id 或宿主团队 `task-<n>`)可在不绑定会话的情况下读取该任务的任务级记忆(仅本次调用)。 |
58
+ | `list_tasks` | 列出本会话可见的任务记录(含归档,带标记;别队的团队任务锚点不出现)。新会话/续接前先调用。 |
59
59
  | `select_task` | 将会话绑定到某任务(此后 todo 清单与读文件同步进该任务)。按 `taskId` 精确绑定,或按 `title` 完全匹配(多个同名返回候选;无则新建)。带 title 可改名;自动解归档。启用团队的宿主上还接受团队任务 id(`task-<n>`):队友选中同一个团队任务即可共享它的任务级记忆。 |
60
60
  | `archive_task` | 归档任务(隐藏默认视图、不占容量、停止同步、清掉选中它的会话绑定;归档任务也不再参与注入与召回)。`select_task` 可恢复。 |
61
61
  | `show_task_panel` | 在 UI 中打开任务面板。用户要求查看任务列表或你想展示面板时调用。 |
62
62
  | `/tasks`(用户输入,不经模型) | 唯一的用户命令:展示任务栈并驱动工作流卡片(绑定宿主团队任务的会标出 `task-<n>`)。其余动作是它的**子动词**,由卡片按钮调用:`switch` / `archive` / `unbind` / `rename` / `todos …` / `step` / `step-move` / `step-text` 为任务动作,`insight list [scope] [offset] [limit]` / `confirm` / `promote` / `demote` / `archive` / `restore` / `delete` / `save` / `edit` 为记忆动作。 |
63
63
  | `remember problem solution` | 保存经验笔记。它就是 `kind: 'experience'` 的 insight——与教训 / 决策 / 流程同库、同去重、同删除入口。相似问题合并或覆盖而非重复。 |
64
64
  | `forget id_or_query` | 删除记忆——教训 / 决策 / 流程与经验笔记一视同仁,task / project / global 全层一次搞定,不必先知道它在哪一层。精确 id 删那一条;关键词按**查询侧覆盖率**匹配(命中词 ÷ 查询词数)。真删、无撤销;关键词命中超过上限(默认 10)时**一条都不删**,只列出候选。最近删除的 **5 条**会以完整条目留在该层 store 同目录的 `deleted.json`(项目层 `<root>/.dsh-project-memory/deleted.json`,global 层在 global 文件旁),删除回报里给出真实路径——删错时读它、重新保存一次即可找回。 |
65
- | `save_lesson` | 在 task/project/global 任一作用域保存教训 / 决策 / 流程;带 `id` 就是**就地覆盖**既有条目(只改本次显式传的字段,旧值留在 `prev`,用同一个 id 再写一次即可写回)。写入前与既有记忆比对:余弦 ≥ 0.9 自动覆盖那一条,≥ 0.7 在返回里提示近邻 id;`leanvec` 不在时退回词法 overlap ≥ 0.7 合并、0.65–0.7 强化。同一 insight 被 2+ 任务命中自动 task→project、3+ → global。主要参数:`id`、`title`、`kind`、`scope`、正文(`pattern`/`fix`、`choice`/`reason` 或 `steps`)、`trigger`(`when` 是唯一触发面,`guard` 只能收窄,`prevents` 记下没有它会坏在哪)。 |
65
+ | `save_lesson` | 在 task/project/global 任一作用域保存教训 / 决策 / 流程;带 `id` 就是**就地覆盖**既有条目(只改本次显式传的字段,旧值留在 `prev`,用同一个 id 再写一次即可写回)。写入前与既有记忆比对:余弦 ≥ 0.9 自动覆盖那一条,≥ 0.7 在返回里提示近邻 id;`leanvec` 不在时退回词法 overlap ≥ 0.7 合并、0.65–0.7 强化。同一 insight 被 2+ 任务命中自动 task→project、3+ → global。主要参数:`id`、`title`、`kind`、`scope`、正文(`pattern`/`fix`、`choice`/`reason` 或 `steps`)、`trigger`(`when` 是唯一触发面,`guard` 只能收窄,`prevents` 记下没有它会坏在哪),以及 `task_id`(本地 id 或宿主团队 `task-<n>`):为任务级写入指定任务;显式 `scope` 优先,去重仍可能把条目合并/提升到 project 或 global。团队任务首次任务级写入时自动建记忆锚点,不必先 `select_task`。 |
66
66
 
67
67
  `/tasks` 在 web 的 `/` 菜单里以带图标的**「工作流」**组呈现 —— 三个视图入口:任务 / 项目记忆 / 全局记忆(标题随界面语言切换)。它是插件唯一注册的命令,其余动作全部作为它的子动词由卡片按钮驱动。
68
68
 
@@ -192,7 +192,7 @@ node scripts/bench.mjs /你的/项目路径 [--json] [--samples 100] [--no-pdf]
192
192
 
193
193
  ```bash
194
194
  npm install
195
- npm test # 1136 项测试
195
+ npm test # 1149 项测试
196
196
  npm run eval:injection # 合成池 P/R:精确率 0.93 / 召回率 1.00,另有 3 个 hint-only 场景
197
197
  npm run eval:injection -- --store .dsh-project-memory/insights.json # 用你自己的 store 重放;对照组是硬闸门
198
198
  npm run selfcheck:triggers # 哪些条目还推得动、哪些声明是死的(读你本地的 store)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yolk_vat-y/dsh-project-memory",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Persistent project memory for dsh agents: index docs (PDF/Markdown/text) and code symbols into a searchable per-workspace store, recall them with cited sources, and keep experience entries (problems -> solutions) searchable on demand.",
5
5
  "author": "00080000 <3388065969@qq.com>",
6
6
  "type": "module",
@@ -20,7 +20,7 @@
20
20
  "url": "https://github.com/00080000/dsh-project-memory.git"
21
21
  },
22
22
  "scripts": {
23
- "test": "node test/run-test.mjs && node test/taskbridge.test.mjs && node test/team-task.test.mjs && node test/insight-store.test.mjs && node test/util-value.test.mjs && node test/insight-fields.test.mjs && node test/reflection-pipeline.test.mjs && node test/auto-inject.test.mjs && node test/insight-actions.test.mjs && node test/insight-paging.test.mjs && node test/config-schema.test.mjs && node test/host-contract.test.mjs && node test/session-dir.test.mjs && node test/llm-route.test.mjs && node test/doc-index.test.mjs && node test/chunker.test.mjs && node test/client-hints.test.mjs && node test/client-paging.test.mjs && node test/client-task-sync.test.mjs && node test/client-task-window.test.mjs && node test/recall.test.mjs && node test/recall-vector-fusion.test.mjs && node test/vector-index.test.mjs && node test/readiness.test.mjs && node test/insight-derive.test.mjs && node test/readiness-eval.test.mjs && node test/ops.test.mjs && node test/injection-audit.test.mjs && node test/signal-source.test.mjs && node test/skill.test.mjs && node test/injection-budget.test.mjs && node test/injection-scenarios.test.mjs && node test/bugfix-0.5.7.test.mjs && node test/client-icons.test.mjs && node test/client-slash.test.mjs && node test/client-kind-label.test.mjs && node test/client-toolview.test.mjs && node test/workflow-command.test.mjs && node test/client-session-id.test.mjs && node test/client-degraded.test.mjs && node test/settings-card.test.mjs && node test/watch-idle.test.mjs && node test/citation-paths.test.mjs && node test/task-view.test.mjs && node test/task-order.test.mjs && node test/root-guards.test.mjs && node test/root-policy.test.mjs && node test/gitignore-index.test.mjs && node test/store-gitignore.test.mjs && node test/atomic-write.test.mjs && node test/read-json-file.test.mjs && node test/store-cache.test.mjs && node test/store-concurrent.test.mjs && node test/store-lock.test.mjs && node test/windows-compat.test.mjs && node test/tool-schema-size.test.mjs && node test/enhancer.test.mjs && node test/multilingual-ru.test.mjs && node test/tokenizer-equivalence.test.mjs && node test/lazy-batch.test.mjs && node test/pdfjs-host.test.mjs && node test/index-failures.test.mjs && node test/audit-2026-11-02.test.mjs && node test/memorydir-guard.test.mjs && node test/audit-2026-11-05.test.mjs && node test/fix-2026-11-10-shell-write-ops.test.mjs && node test/fix-2026-11-10-trigger-derived-refresh.test.mjs && node test/fix-2026-11-10-manual-promote-dedup.test.mjs && node test/fix-2026-11-10-old-host-human.test.mjs && node test/fix-2026-11-10-project-memory-service.test.mjs && node test/lazy-ignore-scope.test.mjs && node test/watch-missing-root-warn.test.mjs && node test/inject-visible.test.mjs && node test/inject-reconcile.test.mjs && node test/shard-bucket.test.mjs && node test/audit-2026-11-10.test.mjs && node test/audit-2026-11-11.test.mjs",
23
+ "test": "node test/run-test.mjs && node test/taskbridge.test.mjs && node test/team-task.test.mjs && node test/insight-store.test.mjs && node test/util-value.test.mjs && node test/insight-fields.test.mjs && node test/reflection-pipeline.test.mjs && node test/auto-inject.test.mjs && node test/insight-actions.test.mjs && node test/insight-paging.test.mjs && node test/config-schema.test.mjs && node test/host-contract.test.mjs && node test/session-dir.test.mjs && node test/llm-route.test.mjs && node test/doc-index.test.mjs && node test/chunker.test.mjs && node test/client-hints.test.mjs && node test/client-paging.test.mjs && node test/client-task-sync.test.mjs && node test/client-task-window.test.mjs && node test/recall.test.mjs && node test/recall-vector-fusion.test.mjs && node test/vector-index.test.mjs && node test/readiness.test.mjs && node test/insight-derive.test.mjs && node test/readiness-eval.test.mjs && node test/ops.test.mjs && node test/injection-audit.test.mjs && node test/signal-source.test.mjs && node test/skill.test.mjs && node test/injection-budget.test.mjs && node test/injection-scenarios.test.mjs && node test/bugfix-0.5.7.test.mjs && node test/client-icons.test.mjs && node test/client-slash.test.mjs && node test/client-kind-label.test.mjs && node test/client-toolview.test.mjs && node test/workflow-command.test.mjs && node test/client-session-id.test.mjs && node test/client-degraded.test.mjs && node test/settings-card.test.mjs && node test/watch-idle.test.mjs && node test/citation-paths.test.mjs && node test/task-view.test.mjs && node test/merge-by-id.test.mjs && node test/task-order.test.mjs && node test/root-guards.test.mjs && node test/root-policy.test.mjs && node test/gitignore-index.test.mjs && node test/store-gitignore.test.mjs && node test/atomic-write.test.mjs && node test/read-json-file.test.mjs && node test/store-cache.test.mjs && node test/store-concurrent.test.mjs && node test/store-lock.test.mjs && node test/windows-compat.test.mjs && node test/tool-schema-size.test.mjs && node test/enhancer.test.mjs && node test/multilingual-ru.test.mjs && node test/tokenizer-equivalence.test.mjs && node test/lazy-batch.test.mjs && node test/pdfjs-host.test.mjs && node test/index-failures.test.mjs && node test/audit-2026-11-02.test.mjs && node test/memorydir-guard.test.mjs && node test/audit-2026-11-05.test.mjs && node test/fix-2026-11-10-shell-write-ops.test.mjs && node test/fix-2026-11-10-trigger-derived-refresh.test.mjs && node test/fix-2026-11-10-manual-promote-dedup.test.mjs && node test/fix-2026-11-10-old-host-human.test.mjs && node test/fix-2026-11-10-project-memory-service.test.mjs && node test/lazy-ignore-scope.test.mjs && node test/watch-missing-root-warn.test.mjs && node test/inject-visible.test.mjs && node test/inject-reconcile.test.mjs && node test/shard-bucket.test.mjs && node test/audit-2026-11-10.test.mjs && node test/audit-2026-11-11.test.mjs",
24
24
  "eval:injection": "node test/injection-scenarios.test.mjs",
25
25
  "typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.client.json",
26
26
  "selfcheck:triggers": "node test/injection-scenarios.test.mjs --selfcheck",
@@ -25,15 +25,26 @@ Query it before re-deriving; write to it only after something has been verified.
25
25
  - When resuming: call `list_tasks`, then `select_task` if one matches the current work. In a team,
26
26
  bind the host team task (`select_task task-<n>`) so the lead and teammates share its task-level
27
27
  memory (the returned memory task id starts with `team:`; use that id with the other tools).
28
+ A team task's memory stays inside that team: another team's sessions see no such task in
29
+ `list_tasks` / the panel and cannot read or write it by id.
30
+ Binding is still what drives automatic injection (task card + task-level memories), todo sync
31
+ and the default task scope; for one-off access, `query_memory` / `save_lesson` also accept
32
+ `task_id` (local id or host `task-<n>`) to reach the same task-level memory directly.
28
33
 
29
34
  ## Workflow
30
35
 
31
36
  1. **Locate context**
32
37
  - `query_memory` with `query` = what you actually need ("how are shards written", "why store
33
- scope", "where is X implemented").
38
+ scope", "where is X implemented"). Use it before grepping for orientation, a spec constraint,
39
+ or a past decision.
34
40
  - `type`: `all` (default) / `doc` / `symbol` / `experience` / `insight` / `task`.
41
+ - `task_id` (optional): read one task's task-level memory by id — local `tsk_…` or host team
42
+ `task-<n>` — without binding the session. `type: 'task'` lists task records instead; do not
43
+ combine it with `task_id`.
44
+ - `limit`: per layer, default 8, max 20; `type: all` can return up to 3x (docs/symbols, insights,
45
+ experience).
35
46
  - Results carry ids and citations. Treat them as evidence: read the cited file when the answer
36
- matters.
47
+ matters. If a result is stale or wrong, update that entry in place (`save_lesson` with its id).
37
48
  2. **Refresh the index if it looks empty or stale**
38
49
  - `index_repo root:"<project>"` — incremental; unchanged files are skipped.
39
50
  - `index_doc file_path:"…"` — one document, even outside the corpus.
@@ -41,18 +52,29 @@ Query it before re-deriving; write to it only after something has been verified.
41
52
  3. **Write back what will still be true next session**
42
53
  - `save_lesson` — one insight. Give `kind` (`lesson` / `decision` / `procedure`), a one-line
43
54
  `title`, and the body: `pattern` + `fix`, or `choice` + `reason`, or `steps`.
44
- - `remember problem solution` — shorthand for `kind: experience`.
55
+ - `remember problem solution` — shorthand for `kind: experience`; it always writes project
56
+ scope, so use `save_lesson` with `scope: 'task'` + `task_id` for task-level experience.
45
57
  - `files`: project-relative paths the conclusion is about.
46
58
  - Similar entries are merged or overwritten automatically; a near match returns its id instead
47
59
  of creating a duplicate.
48
- - `trigger.when`: when this should be recalled. `ops` (action), `writes` (file about to change),
49
- `intents` (words the human would use). `guard` only narrows; `prevents` records what breaks
50
- without it. Do **not** write a trigger you have not seen fire.
51
- - `scope`: `task` (needs a bound task), `project` (default), `global` (rarely).
60
+ - `trigger.when`: when this should be recalled. `ops` (action names: `file-write` / `file-delete` /
61
+ `shell-run` / `git-commit` / `git-push` / `release` / `npm-publish` / `go-public` / `deploy` /
62
+ `migrate` / `render-doc` / `index-doc` / `read-image` / `fetch-web` / `run-bench` / `query-memory`),
63
+ `writes` (project-relative paths about to change; `*` wildcards allowed), `intents` (words the
64
+ human would use; CJK ≥2 chars, latin ≥5 chars). **`when` is the only trigger surface: without
65
+ it the entry is retrieval-only.** `guard` only narrows and all conditions must hold: `paths`
66
+ (write target must match one), `not_paths`, `hosts` (e.g. `wsl`), `tags` (profile tag
67
+ intersection). `prevents` records what breaks without it. Do **not** write a trigger you have
68
+ not seen fire.
69
+ - `scope`: `task` (bound task, or pass `task_id` — a host `task-<n>` gets its memory anchor on
70
+ first task-scope write, no `select_task` needed), `project` (the default when there is no
71
+ bound task and no `task_id`), `global` (rarely).
52
72
  4. **Correct or delete**
53
73
  - Same `id` + new fields = in-place update (old value kept in `prev`).
54
- - `forget id_or_query` is a real delete, no undo. Prefer ids; keyword deletes refuse when too many
55
- entries match.
74
+ - `forget id_or_query` is a real delete, no undo. Prefer ids. Keyword matching is query-side
75
+ coverage (matched query terms ÷ query terms); over the cap (default 10) nothing is deleted and
76
+ candidates are listed. The 5 most recently deleted entries are kept in that layer's
77
+ `deleted.json` (the result prints the path) — read it and save again to recover a mis-delete.
56
78
 
57
79
  ## Rules
58
80
 
@@ -8,6 +8,7 @@ import { memoryRootFor, normalizeCitationFiles } from '../util/fs.js'
8
8
  import { cfgInsight, GlobalStore, normalizeInsight, defaultGlobalFile, saveInsight, recordDeleted, carryUsageFields, mergeOrPushInto, demoteToProject, demoteToTask, pruneItems, refreshDerivedTrigger, putInsightField, INSIGHT_KINDS } from '../insight-store.js'
9
9
  import { NO_PROJECT_ROOT_NOTE, projectRootFor } from '../setup/taskbridge.js'
10
10
  import { fencedJson, invocationContext } from './invocation.js'
11
+ import { taskVisibility } from '../setup/team-task.js'
11
12
  import { isoMs } from '../util/value.js'
12
13
  import { bodyFieldOf, pruneKindFields } from '../util/insight-fields.js'
13
14
  import { forgetVectorRows } from '../vector-index.js'
@@ -76,8 +77,10 @@ function insSummary(ins, extra = {}) {
76
77
  }
77
78
  }
78
79
 
79
- function findTaskInsight(store, id) {
80
+ function findTaskInsight(store, id, taskVisible = null) {
80
81
  for (const t of store.getTasks() || []) {
82
+ // 面板动作也可能被别队会话的客户端触发:任务级条目按任务可见性过滤。
83
+ if (taskVisible && !taskVisible(t)) continue
81
84
  const hit = (t.insights || []).find((i) => i.id === id)
82
85
  if (hit) return { task: t, insight: hit }
83
86
  }
@@ -120,11 +123,14 @@ function compareInsightRecency(a, b) {
120
123
  */
121
124
  export function listInsights(store, gs, scope, opts = {}) {
122
125
  const s = scope || 'project'
126
+ const taskVisible = opts.taskVisible || null
123
127
  // 先收集「原始条目 + 附加字段」,**排序在摘要之前**:摘要会丢掉 createdAt,
124
128
  // 而这个字段是稳定全序的第二级键。
125
129
  const collected = []
126
130
  if (s === 'task') {
127
131
  for (const t of store.getTasks() || []) {
132
+ // 面板载荷会写进会话历史:别队的团队任务条目不能出现在列表里。
133
+ if (taskVisible && !taskVisible(t)) continue
128
134
  for (const i of t.insights || []) collected.push({ raw: i, extra: { taskId: t.id, taskTitle: t.title } })
129
135
  }
130
136
  } else if (s === 'global') {
@@ -148,14 +154,14 @@ export function listInsights(store, gs, scope, opts = {}) {
148
154
  * archive | restore | delete;scope: task|project|global(列表里条目的当前 scope)。
149
155
  * demote 到 task 需要 taskId;promote/global 之上无层级时返回错误。
150
156
  */
151
- export function actInsight({ store, gs, action, scope, id, taskId, cfg }) {
157
+ export function actInsight({ store, gs, action, scope, id, taskId, cfg, taskVisible = null }) {
152
158
  const act = action || ''
153
159
  const s = scope || 'project'
154
160
  if (!id) return { ok: false, text: '需要 id' }
155
161
  const invalid = () => ({ ok: false, text: `insight ${id} 不在 ${s} 层(可能已移动/删除)` })
156
162
 
157
163
  if (s === 'task') {
158
- const found = findTaskInsight(store, id)
164
+ const found = findTaskInsight(store, id, taskVisible)
159
165
  if (!found) return invalid()
160
166
  const { task, insight } = found
161
167
  if (act === 'confirm') {
@@ -250,7 +256,7 @@ export function actInsight({ store, gs, action, scope, id, taskId, cfg }) {
250
256
  if (act === 'demote') {
251
257
  // project → task(需目标任务);去重/去留统一走 insight-store 的唯一实现。
252
258
  const task = store.getTask(taskId)
253
- if (!task) return { ok: false, text: '降级到任务需要 taskId' }
259
+ if (!task || (taskVisible && !taskVisible(task))) return { ok: false, text: '降级到任务需要 taskId' }
254
260
  const moved = demoteToTask(store, taskId, id, new Date().toISOString(), cfg)
255
261
  if (!moved.ok) return { ok: false, text: moved.error }
256
262
  return {
@@ -310,7 +316,7 @@ export function saveMemoryItem({ store, gs, cfg, scope, fields }) {
310
316
  const EDIT_FIELDS = new Set(['title', 'kind', 'body', 'pattern', 'fix', 'problem', 'solution', 'choice', 'reason', 'confidence', 'steps', 'trigger', 'tags', 'files', 'symbols'])
311
317
 
312
318
  /** 编辑既有条目(title/kind/正文/trigger 等白名单字段)。任务级按 id 在任务池定位。 */
313
- export function editMemoryItem({ store, gs, scope, id, fields, root }) {
319
+ export function editMemoryItem({ store, gs, scope, id, fields, root, taskVisible = null }) {
314
320
  if (!fields || typeof fields !== 'object') return { ok: false, text: 'edit 需要字段对象' }
315
321
  const applyTo = (item) => {
316
322
  let changed = false
@@ -374,7 +380,7 @@ export function editMemoryItem({ store, gs, scope, id, fields, root }) {
374
380
  const s = scope || 'project'
375
381
  if (!['task', 'project', 'global'].includes(s)) return { ok: false, text: `未知 scope: ${s}(只认 task/project/global)` }
376
382
  if (s === 'task') {
377
- const found = findTaskInsight(store, id)
383
+ const found = findTaskInsight(store, id, taskVisible)
378
384
  if (!found) return { ok: false, text: `insight ${id} 不在任务层` }
379
385
  const applied = applyTo(found.insight)
380
386
  if (!applied.changed) return { ok: false, text: '没有可更新的字段' }
@@ -411,7 +417,8 @@ export function insightCommandDefinition(config, ctx) {
411
417
  input: { hint: 'list [scope] [offset] [limit] | <动作> <scope> <id> [taskId]' },
412
418
  handler: (invocation) => {
413
419
  try {
414
- const { cwd } = invocationContext(invocation)
420
+ const { cwd, agent } = invocationContext(invocation)
421
+ const taskVisible = agent ? taskVisibility({ agent }) : null
415
422
  const lineRaw = (invocation?.rawInput || '').trim()
416
423
  const raw = lineRaw.split(/\s+/).filter(Boolean)
417
424
  const root = projectRootFor(cwd, config)
@@ -455,7 +462,7 @@ export function insightCommandDefinition(config, ctx) {
455
462
  limit = Math.min(n, INSIGHT_PAGE_MAX)
456
463
  }
457
464
  const { store, gs } = openStores()
458
- const payload = listInsights(store, gs, scope, { offset, limit })
465
+ const payload = listInsights(store, gs, scope, { offset, limit, taskVisible })
459
466
  const shown = offset + payload.items.length
460
467
  const range = limit === null ? '' : `(显示 ${shown}/${payload.total})`
461
468
  return { kind: 'success', text: fencedJson(`记忆 ${scope}:${payload.count} 条${range}`, JSON.stringify(payload)) }
@@ -501,7 +508,7 @@ export function insightCommandDefinition(config, ctx) {
501
508
  return { kind: 'error', text: '[insight] edit 需要 JSON 参数(由面板生成)' }
502
509
  }
503
510
  const { store, gs } = openStores()
504
- return commitBoth(store, gs, editMemoryItem({ store, gs, scope, id, fields, root }))
511
+ return commitBoth(store, gs, editMemoryItem({ store, gs, scope, id, fields, root, taskVisible }))
505
512
  }
506
513
  const scope = raw[1]
507
514
  const id = raw[2]
@@ -510,7 +517,7 @@ export function insightCommandDefinition(config, ctx) {
510
517
  return { kind: 'error', text: '[insight] 用法: /tasks insight <动作|save|edit> …' }
511
518
  }
512
519
  const { store, gs, cfg } = openStores()
513
- return commitBoth(store, gs, actInsight({ store, gs, action: verb, scope, id, taskId, cfg }))
520
+ return commitBoth(store, gs, actInsight({ store, gs, action: verb, scope, id, taskId, cfg, taskVisible }))
514
521
  } catch (err) {
515
522
  return { kind: 'error', text: `[insight] ${err?.message || err}` }
516
523
  }
@@ -7,6 +7,7 @@ import { renderTaskSnapshot, buildTaskPayload } from './tasks.js'
7
7
  import { fireReflect } from '../reflection-pipeline.js'
8
8
  import { resolveRoute } from '../llm-route.js'
9
9
  import { fencedJson, invocationContext } from './invocation.js'
10
+ import { recheckTeamAnchor, taskVisibility, taskVisibleTo } from '../setup/team-task.js'
10
11
  import { STEP_STATUSES, sortTasksByRecency, stepContent, stepProgress, stepStatus } from '../util/task-view.js'
11
12
 
12
13
  /**
@@ -39,8 +40,10 @@ function restAfter(raw, n) {
39
40
  return raw.slice(i).replace(/^\s+/, '')
40
41
  }
41
42
 
42
- function withTaskSnapshot(config, cwd, sid, store, note) {
43
- const tasks = store.getTasks()
43
+ function withTaskSnapshot(config, cwd, sid, store, note, exec = null) {
44
+ // 快照会写进会话历史:团队锚点只保留本会话可见的那些(与 /tasks 同一判据)。
45
+ const visible = exec ? taskVisibility(exec) : null
46
+ const tasks = visible ? store.getTasks().filter(visible) : store.getTasks()
44
47
  const active = sortTasksByRecency(tasks.filter((t) => !t.archived))
45
48
  const archived = tasks.length - active.length
46
49
  const boundId = sid ? store.getBoundTaskId(sid) : null
@@ -69,14 +72,14 @@ export function taskCommandDefinition(config, ctx) {
69
72
  input: { hint: 'switch|archive <任务id> | unbind' },
70
73
  handler: (invocation) => {
71
74
  try {
72
- const { session, sid, cwd } = invocationContext(invocation)
75
+ const { agent, session, sid, cwd } = invocationContext(invocation)
73
76
  const raw = (invocation?.rawInput || '').trim()
74
77
  const [verb, taskId, ...rest] = raw.split(/\s+/)
75
78
 
76
79
  // 无参数:等同 /tasks(不报错、不强制输入任务 id)——
77
80
  // switch/archive/unbind 由卡片按钮自动调用,用户无需手敲。
78
81
  if (!verb) {
79
- const snap = renderTaskSnapshot(config, cwd, sid)
82
+ const snap = renderTaskSnapshot(config, cwd, sid, agent ? { agent } : null)
80
83
  if (snap.kind === 'success') {
81
84
  snap.text = `[任务] 用法: /task switch|archive <任务id> | unbind(卡片按钮会自动调用;不带参数等同 /tasks)\n\n${snap.text}`
82
85
  }
@@ -96,14 +99,14 @@ export function taskCommandDefinition(config, ctx) {
96
99
  session.append('todo/write', { todos: [] })
97
100
  }
98
101
  const note = '已取消当前任务绑定并清空会话任务清单(需要时可让模型重新规划)'
99
- return withTaskSnapshot(config, cwd, sid, store, note)
102
+ return withTaskSnapshot(config, cwd, sid, store, note, agent ? { agent } : null)
100
103
  }
101
104
 
102
105
  // 单步原子写:客户端不再回写整份 steps,避免两个并发动作互相覆盖。
103
106
  if (verb === 'step' || verb === 'step-move' || verb === 'step-text') {
104
107
  if (!taskId) return { kind: 'error', text: `[task] ${verb} 需要任务 id` }
105
108
  const task = store.getTask(taskId)
106
- if (!task) return { kind: 'error', text: `[task] 找不到任务: ${taskId}` }
109
+ if (!task || !taskVisibleTo(task, { agent })) return { kind: 'error', text: `[task] 找不到任务: ${taskId}` }
107
110
  if (task.teamTaskId) return teamStepsError(task)
108
111
  if (!Array.isArray(task.steps)) task.steps = []
109
112
  if (verb === 'step') {
@@ -150,7 +153,7 @@ export function taskCommandDefinition(config, ctx) {
150
153
  store.markTasksDirty()
151
154
  store.save()
152
155
  if (shouldAdoptToHost(config)) adoptStepsToSession(session, task)
153
- return withTaskSnapshot(config, cwd, sid, store, `已更新「${task.title}」步骤`)
156
+ return withTaskSnapshot(config, cwd, sid, store, `已更新「${task.title}」步骤`, agent ? { agent } : null)
154
157
  }
155
158
 
156
159
  // /task rename <任务id> <json标题> —— 双击任务标题改名
@@ -165,7 +168,7 @@ export function taskCommandDefinition(config, ctx) {
165
168
  title = title.trim()
166
169
  if (!title) return { kind: 'error', text: '[task] 标题不能为空' }
167
170
  const task = store.getTask(taskId)
168
- if (!task) return { kind: 'error', text: `[task] 找不到任务: ${taskId}` }
171
+ if (!task || !taskVisibleTo(task, { agent })) return { kind: 'error', text: `[task] 找不到任务: ${taskId}` }
169
172
  const oldTitle = task.title
170
173
  task.title = title
171
174
  task.updatedAt = new Date().toISOString()
@@ -175,7 +178,7 @@ export function taskCommandDefinition(config, ctx) {
175
178
  store.save()
176
179
  const teamNote = task.teamTaskId ? '(仅本地记忆标题,宿主团队任务未变)' : ''
177
180
  const note = `已改名「${oldTitle}」→「${title}」${teamNote}`
178
- return withTaskSnapshot(config, cwd, sid, store, note)
181
+ return withTaskSnapshot(config, cwd, sid, store, note, agent ? { agent } : null)
179
182
  }
180
183
 
181
184
  // /task todos <json> —— 卡片双击编辑步骤后,把整份新清单写回绑定任务并推宿主
@@ -199,7 +202,7 @@ export function taskCommandDefinition(config, ctx) {
199
202
  return { kind: 'error', text: '[task] 未绑定任务,无法编辑步骤;先在卡片上“切换到此任务”' }
200
203
  }
201
204
  const task = store.getTask(boundId)
202
- if (!task) return { kind: 'error', text: '[task] 绑定任务不存在' }
205
+ if (!task || !taskVisibleTo(task, { agent })) return { kind: 'error', text: '[task] 绑定任务不存在' }
203
206
  if (task.teamTaskId) return teamStepsError(task)
204
207
  task.steps = norm
205
208
  task.updatedAt = new Date().toISOString()
@@ -210,12 +213,16 @@ export function taskCommandDefinition(config, ctx) {
210
213
  adoptStepsToSession(session, task, { force: true })
211
214
  }
212
215
  const note = `已更新「${task.title}」步骤(${norm.length} 条)`
213
- return withTaskSnapshot(config, cwd, sid, store, note)
216
+ return withTaskSnapshot(config, cwd, sid, store, note, agent ? { agent } : null)
214
217
  }
215
218
 
216
219
  if (verb === 'switch') {
217
220
  const task = store.getTask(taskId)
218
- if (!task) return { kind: 'error', text: `[task] 找不到任务: ${taskId}(/tasks 查看)` }
221
+ if (!task || !taskVisibleTo(task, { agent })) return { kind: 'error', text: `[task] 找不到任务: ${taskId}(/tasks 查看)` }
222
+ // 原始锚点不经过宿主视图:绑定前补一次复核,宿主已删的任务不再切进来。
223
+ const check = recheckTeamAnchor({ agent }, task)
224
+ if (!check.ok && check.reason === 'not-found') return { kind: 'error', text: `[task] 团队任务已不存在: ${task.title}` }
225
+ if (!check.ok) return { kind: 'error', text: `[task] 读取团队任务失败: ${check.error}` }
219
226
  const prevBound = sid ? store.getBoundTaskId(sid) : null
220
227
  if (task.archived) task.archived = false
221
228
  if (sid) {
@@ -236,12 +243,12 @@ export function taskCommandDefinition(config, ctx) {
236
243
  }
237
244
  const teamNote = task.teamTaskId ? ';团队任务只共享任务级记忆(步骤请用宿主团队任务板)' : ''
238
245
  const note = `已切换绑定: ${describeTask(task)}${sid ? '' : '(拿不到会话 id,未持久绑定)'}${teamNote}`
239
- return withTaskSnapshot(config, cwd, sid, store, note)
246
+ return withTaskSnapshot(config, cwd, sid, store, note, agent ? { agent } : null)
240
247
  }
241
248
 
242
249
  if (verb === 'archive') {
243
250
  const task = store.getTask(taskId)
244
- if (!task) return { kind: 'error', text: `[task] 找不到任务: ${taskId}(/tasks 查看)` }
251
+ if (!task || !taskVisibleTo(task, { agent })) return { kind: 'error', text: `[task] 找不到任务: ${taskId}(/tasks 查看)` }
245
252
  if (task.archived) return { kind: 'error', text: `[task] 已归档: ${task.title}` }
246
253
  task.archived = true
247
254
  task.updatedAt = new Date().toISOString()
@@ -253,7 +260,7 @@ export function taskCommandDefinition(config, ctx) {
253
260
  fireReflect(config, { llm: ctx?.llm }, root, taskId, 'archive', resolveRoute(session ? { agent: { session } } : undefined, config))
254
261
  const teamNote = task.teamTaskId ? ';仅本地记忆锚点,宿主团队任务未变' : ''
255
262
  const note = `已归档: ${describeTask(task)}(select_task 可恢复)${teamNote}`
256
- return withTaskSnapshot(config, cwd, sid, store, note)
263
+ return withTaskSnapshot(config, cwd, sid, store, note, agent ? { agent } : null)
257
264
  }
258
265
 
259
266
  return { kind: 'error', text: `[task] 未知动作: ${verb}(switch|archive)` }
@@ -6,6 +6,7 @@ import { ProjectMemoryStore } from '../store.js'
6
6
  import { NO_PROJECT_ROOT_NOTE, projectRootFor } from '../setup/taskbridge.js'
7
7
  import { fencedJson, invocationContext } from './invocation.js'
8
8
  import { sortTasksByRecency, stepContent, stepProgress, stepStatus, timeAgo } from '../util/task-view.js'
9
+ import { taskVisibility } from '../setup/team-task.js'
9
10
 
10
11
  // 快照会原样写进会话历史(command/done),没有上限时一个异常任务就能把单条消息撑到几十 MB。
11
12
  // 截断只发生在**展示载荷**里,不碰 store;超出部分由 totals 告知调用方。
@@ -54,13 +55,19 @@ export function buildTaskPayload(tasks, boundId, archived, root = null) {
54
55
 
55
56
  /**
56
57
  * 生成 /tasks 类快照的完整输出文本(人类可读总览 + JSON 载荷)。
57
- * 任务动作命令复用同一函数,面板只需解析尾部 JSON 即可刷新。
58
+ * `exec`(`{ agent }`)给定时就只保留该会话可见的任务:快照会写进会话历史,
59
+ * 别队的团队锚点连同 insight id/标题都不能从这里漏给模型;没有 agent 上下文时按旧行为展示全部。
60
+ * @param {object} config
61
+ * @param {string} cwd
62
+ * @param {string|null} sid
63
+ * @param {object|null} [exec]
58
64
  */
59
- export function renderTaskSnapshot(config, cwd, sid) {
65
+ export function renderTaskSnapshot(config, cwd, sid, exec = null) {
60
66
  const root = projectRootFor(cwd, config)
61
67
  if (!root) return { kind: 'error', text: NO_PROJECT_ROOT_NOTE }
62
68
  const store = new ProjectMemoryStore(memoryRootFor(root, config.memoryDir)).load()
63
- const tasks = store.getTasks()
69
+ const visible = exec ? taskVisibility(exec) : null
70
+ const tasks = visible ? store.getTasks().filter(visible) : store.getTasks()
64
71
  // 最近活跃的在前:面板/`/tasks`/list_tasks 三处同一份顺序(见 util/task-view.js)。
65
72
  const active = sortTasksByRecency(tasks.filter((t) => !t.archived))
66
73
  const archived = tasks.length - active.length
@@ -100,8 +107,8 @@ export function tasksCommandDefinition(config, ctx) {
100
107
  description: '查看本项目的任务清单(几套任务、进度、涉及文件、当前绑定)',
101
108
  handler: (invocation) => {
102
109
  try {
103
- const { cwd, sid } = invocationContext(invocation)
104
- return renderTaskSnapshot(config, cwd, sid)
110
+ const { agent, cwd, sid } = invocationContext(invocation)
111
+ return renderTaskSnapshot(config, cwd, sid, agent ? { agent } : null)
105
112
  } catch (err) {
106
113
  return { kind: 'error', text: `[tasks] ${err?.message || err}` }
107
114
  }