@kirkchinese/dsh-citeciter 0.2.1 → 0.3.1

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 (36) hide show
  1. package/README.md +39 -55
  2. package/README.zh.md +35 -70
  3. package/lib/client.js +16302 -1062
  4. package/lib/index.js +1260 -241
  5. package/lib/topic-BfAp9KoS.js +269 -0
  6. package/lib/typert-common-DXguoziV.js +32 -0
  7. package/lib/typert.host.js +30 -11
  8. package/lib/typert.remote-client.js +2 -2
  9. package/lib/types/client/citation.d.ts +10 -0
  10. package/lib/types/client/companion-controller.d.ts +39 -0
  11. package/lib/types/client/components/CiteCiterSettings.d.ts +7 -0
  12. package/lib/types/client/components/CitePanel.d.ts +7 -10
  13. package/lib/types/client/components/QuestionCard.d.ts +8 -0
  14. package/lib/types/client/components/SelectionMenu.d.ts +6 -11
  15. package/lib/types/client/index.d.ts +2 -2
  16. package/lib/types/client/markdown-source-map.d.ts +16 -0
  17. package/lib/types/client/response-guard.d.ts +4 -0
  18. package/lib/types/client/types.d.ts +16 -31
  19. package/lib/types/index.d.ts +33 -22
  20. package/lib/types/observer.d.ts +44 -0
  21. package/lib/types/topic-runtime.d.ts +56 -0
  22. package/lib/types/topic.d.ts +559 -0
  23. package/lib/types/typert-common.d.ts +226 -69
  24. package/lib/types/typert.host.d.ts +577 -58
  25. package/lib/types/typert.remote-client.d.ts +3 -8
  26. package/package.json +70 -32
  27. package/lib/thread-D7ig_Lk7.js +0 -68
  28. package/lib/typert-common-CLPMRe7a.js +0 -51
  29. package/lib/types/client/explainer-controller.d.ts +0 -31
  30. package/lib/types/client/explainer.d.ts +0 -5
  31. package/lib/types/client/thread.d.ts +0 -22
  32. package/lib/types/client/transcript.d.ts +0 -14
  33. package/lib/types/projection.d.ts +0 -4
  34. package/lib/types/read-only.d.ts +0 -13
  35. package/lib/types/thread.d.ts +0 -107
  36. package/lib/types/validation.d.ts +0 -4
package/README.md CHANGED
@@ -1,81 +1,65 @@
1
1
  # `@kirkchinese/dsh-citeciter`
2
2
 
3
- **A learning companion grounded in an exact point of your DeepSeek Harness conversation.** Select text from a completed assistant reply, choose `Citer!`, ask your own question, and continue learning in a durable Citation Thread without writing to the source session.
3
+ A private learning companion for live DeepSeek Harness conversations. Select text from a committed assistant response, ask beside the source, and continue in an independent multi-turn Topic while the source Agent keeps working.
4
4
 
5
- [中文说明](https://github.com/kirkchinese/CiteCiter/blob/main/packages/citeciter/README.zh.md) · [GitHub](https://github.com/kirkchinese/CiteCiter) · [Issues](https://github.com/kirkchinese/CiteCiter/issues)
6
-
7
- > **Early development:** v0.2.0 introduced the durable Host+Client architecture; v0.2.1 fixes later-turn preparation when DSH treats an already-effective read-only switch as an idempotent no-op. APIs, compatibility, and installation details may still change. Issues and pull requests are welcome.
5
+ [简体中文](README.zh.md) · [GitHub](https://github.com/kirkchinese/CiteCiter) · [Issues](https://github.com/kirkchinese/CiteCiter/issues)
8
6
 
9
7
  ## Install
10
8
 
11
- CiteCiter requires Node.js `^22.19.0 || >=24.0.0`, DSH Web, and a configured model provider.
9
+ CiteCiter requires Node.js `^22.19.0 || >=24.0.0`, DSH Web `>=0.1.0-rc.7 <0.1.0-rc.8`, and a configured model provider.
12
10
 
13
11
  ```sh
14
- dsh plugin --profile web add @kirkchinese/dsh-citeciter@0.2.1
12
+ dsh plugin --profile web add @kirkchinese/dsh-citeciter@0.3.1
15
13
  ```
16
14
 
17
- Restart the corresponding DSH Web process and refresh the page. A restart is required after installation or upgrade because the Host and Typert manifests are loaded at process startup.
18
-
19
- The package declares DSH peers from `^0.1.0-rc.6`. Focused builds use the rc.6 package set; the v0.2 browser flow was also verified on a fresh DSH `0.1.0-rc.7` process.
15
+ Restart the corresponding DSH Web process and refresh the page after installation or upgrade.
20
16
 
21
17
  ## Use
22
18
 
23
- 1. Select text wholly inside one completed assistant response.
24
- 2. Right-click and choose `Citer!`.
25
- 3. Write a custom first question or use a quick question.
26
- 4. Continue with genuine follow-up turns in the same Thread.
27
- 5. Reopen, switch, rename, or archive Threads from the persistent launcher.
28
-
29
- Each Citation creates or reuses an isolated child session at the exact historical boundary. The main DSH session never changes and its log is not modified.
30
-
31
- ## What v0.2 implements
32
-
33
- - **Exact historical fork.** The browser resolves `data-chat-anchor-key` through the source-session snapshot, requires a finalized assistant node in a closed turn, and forks at its real `anchorSeq`. Key text is never interpreted as an event sequence.
34
- - **Stable Citation identity.** Source session, anchor seq, exact UTF-16 range, selected text, and bounded surrounding evidence are canonicalized and hashed with SHA-256. Different ranges in one answer remain different Citations.
35
- - **Four separate model-input layers.** A scoped system Tutor, the inherited history prefix, durable user-role Citation Context, and genuine user questions retain distinct authority and persistence.
36
- - **Persistent multi-turn Threads.** The first question and follow-ups are normal child-session user messages. The panel shows only child-owned transcript rows, not inherited history or runtime-context plumbing.
37
- - **Recovery and organization.** Host projection data powers a persistent launcher, parent-grouped picker, page-reload/process-restart recovery, rename, switch, and supported workspace archive.
38
- - **Fail-closed isolation.** CiteCiter opens the concrete child without navigating the main GUI, requires matched admission plus durable successful `/permission read-only` settlement and a current read-only sandbox, validates Host lineage and Citation evidence, and guards model tool execution with an explicit allowlist.
39
- - **Parent noninterference.** Citation context, questions, answers, stop operations, errors, and titles belong to the child. Browser smoke checks that the source log's size and nanosecond mtime do not change.
40
- - **Safe rich answers.** Markdown, code, and KaTeX stream normally. Complete safe `svg` fences become inert data-URI images. Complete `html` fences use a script-free, network-free sandboxed iframe. Rejected or incomplete fences remain Markdown code blocks.
41
- - **Fiber-owned cleanup.** Host Agent effects, Client Remote mounts, slots, listeners, subscriptions, animation frames, and in-flight state are reversible. Late async work cannot reinstall state after disposal.
42
-
43
- ## Input model
44
-
45
- ```text
46
- system: Scoped CiteCiter Tutor
47
- history: exact source-session prefix through the selected assistant boundary
48
- user context: durable, quoted Citation JSON (untrusted data)
49
- user: the person's actual first question and follow-ups
50
- ```
19
+ 1. Select text inside a committed assistant model call. The surrounding Agent turn may still be running.
20
+ 2. Right-click the selection, enter your first question, and choose `Citer!`.
21
+ 3. CiteCiter creates a new Topic in the learning dock.
22
+ 4. Continue asking questions there, or reopen an earlier Topic from CiteCiter's Topic rail.
23
+ 5. Change the Topic model, reasoning effort, title, archive state, or dock width without changing the source Session.
24
+
25
+ ## Highlights
51
26
 
52
- Citation text never receives system authority, even when it contains instruction-like prose, role-shaped JSON, HTML, or delimiters. The accepted architecture decision and real-model comparison are documented in [`docs/architecture/0001-model-input-layering.md`](https://github.com/kirkchinese/CiteCiter/blob/main/docs/architecture/0001-model-input-layering.md).
27
+ - **Model-call citations.** Start as soon as an `assistant/message` is committed; there is no need to wait for the full Agent turn.
28
+ - **Private Topics.** Each submission creates an independent DSH Session under `$DSH_HOME/citeciter/`, outside the ordinary Session list.
29
+ - **Precise selections.** Visible Markdown selections map back to Host-verifiable source ranges.
30
+ - **Bound evidence.** `read_source_session` reads committed events from one fixed source Session without exposing its physical log path.
31
+ - **Open-ended investigation.** The standard read-only `glob` and `grep` tools discover project files and search their contents before `read` opens a known path.
32
+ - **Read-only operation.** CiteCiter cannot write to the source Session or source workspace.
33
+ - **Inspectable workflow.** Live reasoning, prompt injections, tool calls, results, and user questions use compact expandable rows inside the learning dock.
34
+ - **Native workflow.** The selection popover, resizable learning dock, active/archive Topic navigation, and settings remain inside the DSH programming interface.
53
35
 
54
- ## Compatibility and limitations
36
+ ## Context modes
55
37
 
56
- - DSH Web and completed `assistant-step` replies only; user messages, input fields, and arbitrary page text are ignored.
57
- - The selection must stay inside one assistant flow. Cross-message and cross-block Citations are not supported.
58
- - Archive hides a Thread through the DSH workspace archive set. CiteCiter has no unarchive UI; selecting the same Citation after archive may create a new active Thread.
59
- - The current read-only tool allowlist is intentionally conservative. `run_code` remains available for sandboxed analysis, but Host preparation durably verifies the read-only sandbox and every nested tool dispatch still passes the authoritative allowlist guard. A tool absent from the running DSH installation is unavailable.
60
- - Rich HTML/SVG rendering is intentionally conservative; rejected content falls back to visible source rather than executing.
61
- - No settings UI, localization framework, mobile-specific layout, or cross-platform browser CI yet.
62
- - DSH is still prerelease software; later DSH APIs may require a CiteCiter update.
38
+ Observer is the default. It creates an independent Topic and reads committed source evidence on demand, including while the source turn is still running.
63
39
 
64
- ## Development
40
+ Exact Fork is an advanced mode for a source turn that has already ended. `exact-when-available` uses Exact Fork when a stable boundary exists and otherwise falls back to Observer.
65
41
 
66
- From the repository root:
42
+ ## Upgrade from v0.2
67
43
 
68
44
  ```sh
69
- pnpm install
70
- pnpm run typecheck
71
- pnpm --dir packages/citeciter test
72
- pnpm run build
45
+ dsh plugin --profile web add @kirkchinese/dsh-citeciter@0.3.1
46
+ dsh plugin --profile web list --depth 0
73
47
  ```
74
48
 
75
- The repository tracks `packages/citeciter/lib/`. The build removes stale top-level chunks before emitting the Host entry, Client bundle, strict Typert artifacts, and declarations. Reproducible model evaluation, disposable browser smoke, HMR checks, and publish gates are in the [verification guide](https://github.com/kirkchinese/CiteCiter/blob/main/docs/implementation-milestones.md).
49
+ The upgrade does not rewrite source Sessions or import v0.2 Citation Threads. Existing child Sessions remain ordinary DSH data; new discussions use private v0.3 Topics.
50
+
51
+ ## Limitations
52
+
53
+ - A selection must stay inside one committed assistant flow. Streaming fragments and cross-message selections are not supported.
54
+ - Renderer-generated KaTeX layout and footnote numbers cannot be cited directly because they lack stable source coordinates.
55
+ - Exact Fork cannot start from an open source turn.
56
+ - Source-file access depends on the running DSH filesystem service and remains read-only.
57
+ - DSH is prerelease software; later DSH API versions may require a CiteCiter update.
58
+
59
+ ## Contributing
76
60
 
77
- ## Contributing and license
61
+ Issues and pull requests are welcome. Before submitting code, read the [contribution guide](https://github.com/kirkchinese/CiteCiter/blob/main/CONTRIBUTING.md).
78
62
 
79
- CiteCiter is published early so the community can help shape it. Please open an [issue](https://github.com/kirkchinese/CiteCiter/issues) or submit a pull request. Contributor rules are in [AGENTS.md](https://github.com/kirkchinese/CiteCiter/blob/main/AGENTS.md).
63
+ ## License
80
64
 
81
65
  MIT © CiteCiter contributors
package/README.zh.md CHANGED
@@ -1,100 +1,65 @@
1
1
  # `@kirkchinese/dsh-citeciter`
2
2
 
3
- **基于精确历史上下文的、隔离式学习伴侣。** 在 DeepSeek Harness(DSH)的一条已完成助手回复中选中文字,右键点击 `Citer!`,提出你真正想问的问题,并在持久 Citation Thread 中继续追问;源会话不会被写入。
3
+ 服务于进行中 DeepSeek Harness 对话的独立学习伴侣。在已经提交的助手回答中选中文字,就地提问;来源 Agent 可以继续工作,讨论则在独立 Topic 中多轮进行。
4
4
 
5
5
  [English](README.md) · [GitHub](https://github.com/kirkchinese/CiteCiter) · [问题反馈](https://github.com/kirkchinese/CiteCiter/issues)
6
6
 
7
- > **开发状态:** v0.2.0 引入持久化 Host+Client 架构;v0.2.1 修复了 DSH 将已生效的 read-only 重复切换视为幂等 no-op 时,后续追问准备失败的问题。当前仍处于早期开发阶段,API、兼容范围和安装方式仍可能变化。
8
-
9
7
  ## 安装
10
8
 
11
- 需要 Node.js `^22.19.0 || >=24.0.0`、DSH Web 和已配置的模型提供方。
9
+ CiteCiter 需要 Node.js `^22.19.0 || >=24.0.0`、DSH Web `>=0.1.0-rc.7 <0.1.0-rc.8`,以及已经配置的模型提供方。
12
10
 
13
11
  ```sh
14
- dsh plugin --profile web add @kirkchinese/dsh-citeciter@0.2.1
12
+ dsh plugin --profile web add @kirkchinese/dsh-citeciter@0.3.1
15
13
  ```
16
14
 
17
- 安装或升级后,请重启对应的 DSH Web 进程并刷新页面。Host 与 Typert 清单在进程启动时加载,因此不能只替换浏览器 bundle。
18
-
19
- 包声明的 DSH peer range 从 `^0.1.0-rc.6` 开始。focused build 使用 rc.6 包集;v0.2 浏览器全链路也在一个全新启动的 DSH `0.1.0-rc.7` 进程中通过验证。
15
+ 安装或升级后,请重启对应的 DSH Web 进程并刷新页面。
20
16
 
21
17
  ## 使用
22
18
 
23
- 1. 在一条已经完成的助手回复内部选中文字。
24
- 2. 右键点击 `Citer!`。
25
- 3. 输入自定义首问,或选择一个快捷问题。
26
- 4. 在同一 Thread 中继续真实的多轮追问。
27
- 5. 通过常驻入口恢复、切换、重命名或归档 Thread。
28
-
29
- 每条 Citation 都会在所选历史边界创建或复用一个隔离子会话。插件不会切换 DSH 主界面的当前会话,也不会修改源会话日志。
30
-
31
- ## v0.2 已实现能力
32
-
33
- - **精确历史 fork。** 浏览器用 `data-chat-anchor-key` 在源会话 snapshot 中解析真实节点,要求它是已关闭轮次中的最终助手回复,再使用节点的真实 `anchorSeq` fork;绝不从 key 文本猜事件序号。
34
- - **稳定 Citation 身份。** 源会话、anchor seq、UTF-16 精确范围、原文和有界前后文按固定格式序列化并计算 SHA-256。同一回复中的不同选区仍是不同 Citation。
35
- - **四层模型输入。** 受限作用域的 system Tutor、fork 继承的精确历史、持久的 user-role Citation Context,以及真正的用户首问/追问保持不同的权限与持久性。
36
- - **持久多轮 Thread。** 首问和每次追问都是子会话中的普通用户消息。侧栏只展示 Thread 自己拥有的问答/错误,不把继承历史和 runtime-context 内部行混进聊天记录。
37
- - **恢复与组织。** Host projection 驱动常驻入口、按父会话分组的选择器、页面刷新/进程重启恢复、切换、重命名和 DSH workspace 归档。
38
- - **失败即关闭的隔离。** 插件在不导航主界面的情况下打开具体子会话,先要求命令确实匹配,再由 Host 等待 `/permission read-only` 持久成功结算并确认当前 sandbox 仍为只读;随后校验 lineage、边界和 Citation 证据,模型工具执行受显式 allowlist 保护。
39
- - **父日志零干扰。** Citation context、提问、回答、停止、错误和标题都属于子会话。浏览器 smoke 会比较源日志的文件大小和纳秒 mtime。
40
- - **富内容安全。** Markdown、代码和 KaTeX 正常流式显示;完整且安全的 `svg` 围栏成为惰性 data-URI 图片;完整 `html` 围栏进入禁脚本、禁网络的 sandbox iframe;不安全或未闭合内容回退为 Markdown 源码。
41
- - **Fiber 生命周期。** Host Agent 作用域、Client Remote、slot、listener、订阅、动画帧和异步状态都可逆;销毁后的延迟异步结果不能重新安装状态。
42
-
43
- ## 模型输入结构
44
-
45
- ```text
46
- system:仅作用于该 Thread 的 CiteCiter Tutor
47
- history:截至所选助手边界的精确源会话前缀
48
- user context:持久、被引用的 Citation JSON(不可信数据)
49
- user:用户真正输入的首问与后续追问
50
- ```
19
+ 1. 在一次已经提交的助手模型调用中选择文字;外层 Agent 轮次可以仍在运行。
20
+ 2. 右键选区,输入第一个问题,然后点击 `Citer!`。
21
+ 3. CiteCiter 在学习栏中创建一个新 Topic。
22
+ 4. 在 Topic 中继续追问,或从 CiteCiter 的 Topic 栏恢复旧讨论。
23
+ 5. 独立调整模型、思考强度、标题、归档状态和学习栏宽度,不改变来源 Session。
51
24
 
52
- 即使选中文本包含命令口吻、role JSON、HTML 或分隔符,它也不会获得 system 权限。架构决策与同题同模型真实对比见 [`docs/architecture/0001-model-input-layering.md`](https://github.com/kirkchinese/CiteCiter/blob/main/docs/architecture/0001-model-input-layering.md)。
25
+ ## 核心能力
53
26
 
54
- ## 兼容性与已知限制
27
+ - **模型调用级引用。** `assistant/message` 一经提交即可开始,无需等待整个 Agent 轮次结束。
28
+ - **私有 Topic。** 每次提交都会在 `$DSH_HOME/citeciter/` 下创建独立 DSH Session,不进入普通 Session 列表。
29
+ - **精确选区。** 可见 Markdown 选区会映射回 Host 可复验的原文范围。
30
+ - **绑定来源的证据。** `read_source_session` 只读取一个固定来源 Session 的已提交事件,不暴露物理日志路径。
31
+ - **开放式项目调查。** 标准只读 `glob` 与 `grep` 先发现项目文件并搜索内容,再由 `read` 打开已知路径。
32
+ - **只读运行。** CiteCiter 不能写入来源 Session 或来源工作区。
33
+ - **可检查的对话流程。** 实时思考、提示词注入、工具调用、结果和用户提问都在学习栏中以紧凑可展开行显示。
34
+ - **原生工作流。** 选区浮层、可调宽学习栏、活动/归档 Topic 导航和设置都保留在 DSH 编程界面内。
55
35
 
56
- - 只支持 DSH Web 中已完成的 `assistant-step`;不处理用户消息、输入框或任意页面文本。
57
- - 选区必须完整位于同一助手 flow;暂不支持跨消息或跨 block Citation。
58
- - 归档使用 DSH workspace 全局归档集合隐藏 Thread。CiteCiter 暂无取消归档 UI;归档后再次选择同一 Citation 可能创建新的活跃 Thread。
59
- - 只读工具 allowlist 有意保持保守。`run_code` 只用于 sandbox 内分析;Host 准备阶段会持久确认 read-only sandbox,每次嵌套工具分派仍经过权威 allowlist guard。当前 DSH 未安装的工具自然不可用。
60
- - HTML/SVG 安全策略有意保守,被拒绝的内容显示源码而不执行。
61
- - 暂无设置 UI、完整国际化框架、移动端专项布局和跨平台浏览器 CI。
62
- - DSH 仍处于预发布阶段,后续 API 变化可能要求同步适配。
36
+ ## 上下文模式
63
37
 
64
- ## 构建与验证
38
+ Observer 是默认模式。它创建独立 Topic,并按需读取已经提交的来源证据;来源轮次仍在运行时也可以使用。
65
39
 
66
- 在仓库根目录运行:
40
+ Exact Fork 是面向已结束来源轮次的高级模式。`exact-when-available` 在存在稳定边界时使用 Exact Fork,否则回退到 Observer。
41
+
42
+ ## 从 v0.2 升级
67
43
 
68
44
  ```sh
69
- pnpm install
70
- pnpm run typecheck
71
- pnpm --dir packages/citeciter test
72
- pnpm run build
45
+ dsh plugin --profile web add @kirkchinese/dsh-citeciter@0.3.1
46
+ dsh plugin --profile web list --depth 0
73
47
  ```
74
48
 
75
- 仓库跟踪 `packages/citeciter/lib/`。构建会先清理过期的顶层 hash chunk,再生成 Host 入口、Client bundle、严格 Typert 清单和 declaration。真实模型分层实验、临时 DSH_HOME 浏览器 smoke、HMR 检查和发布门禁见 [`docs/implementation-milestones.md`](https://github.com/kirkchinese/CiteCiter/blob/main/docs/implementation-milestones.md)。
49
+ 升级不会改写来源 Session,也不会导入 v0.2 Citation Thread。旧子 Session 仍是普通 DSH 数据;新讨论使用私有 v0.3 Topic。
76
50
 
77
- ## 本地浏览器验证
51
+ ## 已知限制
78
52
 
79
- ```sh
80
- pnpm --filter @kirkchinese/dsh-citeciter exec playwright install chromium
81
- rm -rf /tmp/citeciter-dsh-home
82
- mkdir -p /tmp/citeciter-dsh-home/profiles/node_modules/@kirkchinese
83
- ln -sfn "$(pwd)/packages/citeciter" \
84
- /tmp/citeciter-dsh-home/profiles/node_modules/@kirkchinese/dsh-citeciter
85
- node packages/citeciter/dev/seed-smoke-session.mjs \
86
- /tmp/citeciter-dsh-home "$(pwd)"
87
- DSH_HOME=/tmp/citeciter-dsh-home dsh --profile web \
88
- --patch "$(pwd)/packages/citeciter/dev/patch.yml" --port 3907
89
- node packages/citeciter/dev/smoke.mjs \
90
- http://127.0.0.1:3907 CiteCiter \
91
- /tmp/citeciter-dsh-home/citeciter-smoke.json
92
- ```
53
+ - 选区必须完整位于一个已经提交的助手 flow;暂不支持流式片段和跨消息选区。
54
+ - 渲染器生成的 KaTeX 排版和脚注编号没有稳定原文坐标,不能直接引用。
55
+ - Exact Fork 不能从仍在运行的来源轮次开始。
56
+ - 来源文件访问依赖当前 DSH 文件系统服务,并始终保持只读。
57
+ - DSH 仍处于预发布阶段,后续 API 版本可能要求同步更新 CiteCiter。
93
58
 
94
- Smoke 使用真实渲染的 `14:assistant-step1:1` 节点和真实 `anchorSeq: 6`,验证自定义首问、持久投影、恢复、重命名、常驻入口、侧栏宽度、父日志 revision 与浏览器错误。临时 profile 没有模型凭据时,正常的 provider 错误也只会在 read-only、Remote 准备、Citation Context 和真实用户消息全部成功后出现。
59
+ ## 参与贡献
95
60
 
96
- ## 贡献与许可证
61
+ 欢迎提交 Issue 和 Pull Request。提交代码前请阅读[贡献文档](https://github.com/kirkchinese/CiteCiter/blob/main/CONTRIBUTING.zh.md)。
97
62
 
98
- 请到 [GitHub](https://github.com/kirkchinese/CiteCiter) 提 Issue 或 Pull Request,并先阅读仓库 [`AGENTS.md`](https://github.com/kirkchinese/CiteCiter/blob/main/AGENTS.md)。
63
+ ## 许可证
99
64
 
100
65
  MIT © CiteCiter contributors