@kirkchinese/dsh-citeciter 0.1.1 → 0.2.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.
- package/README.md +50 -20
- package/README.zh.md +56 -35
- package/lib/client.js +5056 -472
- package/lib/index.js +321 -12
- package/lib/thread-D7ig_Lk7.js +68 -0
- package/lib/typert-common-CLPMRe7a.js +51 -0
- package/lib/typert.host.js +23 -0
- package/lib/typert.remote-client.js +9 -0
- package/lib/types/client/components/CitePanel.d.ts +4 -6
- package/lib/types/client/components/SelectionMenu.d.ts +7 -5
- package/lib/types/client/explainer-controller.d.ts +19 -20
- package/lib/types/client/explainer.d.ts +5 -9
- package/lib/types/client/index.d.ts +3 -14
- package/lib/types/client/prompt.d.ts +5 -5
- package/lib/types/client/selection.d.ts +8 -3
- package/lib/types/client/thread.d.ts +22 -0
- package/lib/types/client/transcript.d.ts +14 -0
- package/lib/types/client/types.d.ts +11 -0
- package/lib/types/index.d.ts +27 -11
- package/lib/types/projection.d.ts +4 -0
- package/lib/types/read-only.d.ts +13 -0
- package/lib/types/thread.d.ts +107 -0
- package/lib/types/typert-common.d.ts +88 -0
- package/lib/types/typert.host.d.ts +115 -0
- package/lib/types/typert.remote-client.d.ts +21 -0
- package/lib/types/validation.d.ts +4 -0
- package/package.json +44 -7
package/README.md
CHANGED
|
@@ -1,35 +1,65 @@
|
|
|
1
1
|
# `@kirkchinese/dsh-citeciter`
|
|
2
2
|
|
|
3
|
-
|
|
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.
|
|
4
4
|
|
|
5
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
6
|
|
|
7
|
-
> **Early development:** v0.
|
|
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.
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
|
-
CiteCiter requires Node.js `^22.19.0 || >=24.0.0`, DSH Web, and a configured model provider.
|
|
11
|
+
CiteCiter requires Node.js `^22.19.0 || >=24.0.0`, DSH Web, and a configured model provider.
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
|
-
dsh plugin --profile web add @kirkchinese/dsh-citeciter
|
|
14
|
+
dsh plugin --profile web add @kirkchinese/dsh-citeciter@0.2.1
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
Restart the corresponding DSH Web process and refresh the page.
|
|
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
18
|
|
|
19
|
-
|
|
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.
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
- It resolves the DOM anchor key through the active parent-session snapshot and forks at that node's real `anchorSeq`. It never treats the numeric prefix of a conversation key as an event sequence.
|
|
23
|
-
- The child opens without becoming the current session. CiteCiter runs `/permission read-only` and sends the explanation prompt only when DSH reports both command success and a matched command.
|
|
24
|
-
- A child is reused only while both the parent session and resolved anchor remain unchanged. Repeated requests baseline existing assistant nodes so an earlier answer cannot be shown as the new result.
|
|
25
|
-
- The parent session is never written by CiteCiter. The child log owns the prompt, model response, cancellation, and errors.
|
|
26
|
-
- The panel streams Markdown, KaTeX, and code. Complete safe `svg` fences become inert data-URI images. Complete `html` fences render in a script-free, network-free sandboxed iframe. Rejected or incomplete fences remain Markdown code blocks.
|
|
21
|
+
## Use
|
|
27
22
|
|
|
28
|
-
|
|
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.
|
|
29
28
|
|
|
30
|
-
|
|
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.
|
|
31
30
|
|
|
32
|
-
|
|
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
|
+
```
|
|
51
|
+
|
|
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).
|
|
53
|
+
|
|
54
|
+
## Compatibility and limitations
|
|
55
|
+
|
|
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.
|
|
33
63
|
|
|
34
64
|
## Development
|
|
35
65
|
|
|
@@ -37,15 +67,15 @@ From the repository root:
|
|
|
37
67
|
|
|
38
68
|
```sh
|
|
39
69
|
pnpm install
|
|
40
|
-
pnpm
|
|
41
|
-
pnpm --
|
|
42
|
-
pnpm
|
|
70
|
+
pnpm run typecheck
|
|
71
|
+
pnpm --dir packages/citeciter test
|
|
72
|
+
pnpm run build
|
|
43
73
|
```
|
|
44
74
|
|
|
45
|
-
The
|
|
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).
|
|
46
76
|
|
|
47
77
|
## Contributing and license
|
|
48
78
|
|
|
49
|
-
CiteCiter is
|
|
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).
|
|
50
80
|
|
|
51
81
|
MIT © CiteCiter contributors
|
package/README.zh.md
CHANGED
|
@@ -1,76 +1,97 @@
|
|
|
1
1
|
# `@kirkchinese/dsh-citeciter`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**基于精确历史上下文的、隔离式学习伴侣。** 在 DeepSeek Harness(DSH)的一条已完成助手回复中选中文字,右键点击 `Citer!`,提出你真正想问的问题,并在持久 Citation Thread 中继续追问;源会话不会被写入。
|
|
4
4
|
|
|
5
5
|
[English](README.md) · [GitHub](https://github.com/kirkchinese/CiteCiter) · [问题反馈](https://github.com/kirkchinese/CiteCiter/issues)
|
|
6
6
|
|
|
7
|
-
> **开发状态:** v0.
|
|
7
|
+
> **开发状态:** v0.2.0 引入持久化 Host+Client 架构;v0.2.1 修复了 DSH 将已生效的 read-only 重复切换视为幂等 no-op 时,后续追问准备失败的问题。当前仍处于早期开发阶段,API、兼容范围和安装方式仍可能变化。
|
|
8
8
|
|
|
9
9
|
## 安装
|
|
10
10
|
|
|
11
|
-
需要 Node.js `^22.19.0 || >=24.0.0`、DSH Web
|
|
11
|
+
需要 Node.js `^22.19.0 || >=24.0.0`、DSH Web 和已配置的模型提供方。
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
|
-
dsh plugin --profile web add @kirkchinese/dsh-citeciter
|
|
14
|
+
dsh plugin --profile web add @kirkchinese/dsh-citeciter@0.2.1
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
安装或升级后,请重启对应的 DSH Web 进程并刷新页面。Host 与 Typert 清单在进程启动时加载,因此不能只替换浏览器 bundle。
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
包声明的 DSH peer range 从 `^0.1.0-rc.6` 开始。focused build 使用 rc.6 包集;v0.2 浏览器全链路也在一个全新启动的 DSH `0.1.0-rc.7` 进程中通过验证。
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
- 先用 DOM anchor key 在父会话 snapshot 中查找节点,再用该节点真实的 `anchorSeq` 在已完成轮次边界 fork;不会把会话 key 开头的 kind 长度误当成事件序号。
|
|
23
|
-
- 子会话打开但不会成为当前会话。只有 `/permission read-only` 执行成功且 DSH 确认命令确实匹配后,插件才发送解释提示词。
|
|
24
|
-
- 仅当父会话与解析后的 anchor 都没有变化时才复用子会话。重复请求会先记录已有助手节点,避免把旧回答误当成新结果。
|
|
25
|
-
- 插件不向父会话写入内容。提示词、模型回复、取消动作和错误都属于解释子会话日志。
|
|
26
|
-
- 面板流式渲染 Markdown、KaTeX 和代码。完整且安全的 `svg` 围栏作为惰性 data-URI 图片渲染;完整 `html` 围栏在禁脚本、禁网络的 sandbox iframe 中渲染。被拒绝或未闭合的围栏仍按 Markdown 代码块显示。
|
|
21
|
+
## 使用
|
|
27
22
|
|
|
28
|
-
|
|
23
|
+
1. 在一条已经完成的助手回复内部选中文字。
|
|
24
|
+
2. 右键点击 `Citer!`。
|
|
25
|
+
3. 输入自定义首问,或选择一个快捷问题。
|
|
26
|
+
4. 在同一 Thread 中继续真实的多轮追问。
|
|
27
|
+
5. 通过常驻入口恢复、切换、重命名或归档 Thread。
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
每条 Citation 都会在所选历史边界创建或复用一个隔离子会话。插件不会切换 DSH 主界面的当前会话,也不会修改源会话日志。
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
## v0.2 已实现能力
|
|
33
32
|
|
|
34
|
-
|
|
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、订阅、动画帧和异步状态都可逆;销毁后的延迟异步结果不能重新安装状态。
|
|
35
42
|
|
|
36
|
-
##
|
|
43
|
+
## 模型输入结构
|
|
44
|
+
|
|
45
|
+
```text
|
|
46
|
+
system:仅作用于该 Thread 的 CiteCiter Tutor
|
|
47
|
+
history:截至所选助手边界的精确源会话前缀
|
|
48
|
+
user context:持久、被引用的 Citation JSON(不可信数据)
|
|
49
|
+
user:用户真正输入的首问与后续追问
|
|
50
|
+
```
|
|
51
|
+
|
|
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)。
|
|
53
|
+
|
|
54
|
+
## 兼容性与已知限制
|
|
55
|
+
|
|
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 变化可能要求同步适配。
|
|
63
|
+
|
|
64
|
+
## 构建与验证
|
|
37
65
|
|
|
38
66
|
在仓库根目录运行:
|
|
39
67
|
|
|
40
68
|
```sh
|
|
41
69
|
pnpm install
|
|
42
|
-
pnpm
|
|
43
|
-
pnpm --
|
|
44
|
-
pnpm
|
|
70
|
+
pnpm run typecheck
|
|
71
|
+
pnpm --dir packages/citeciter test
|
|
72
|
+
pnpm run build
|
|
45
73
|
```
|
|
46
74
|
|
|
47
|
-
|
|
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)。
|
|
48
76
|
|
|
49
|
-
|
|
77
|
+
## 本地浏览器验证
|
|
50
78
|
|
|
51
79
|
```sh
|
|
52
80
|
pnpm --filter @kirkchinese/dsh-citeciter exec playwright install chromium
|
|
81
|
+
rm -rf /tmp/citeciter-dsh-home
|
|
53
82
|
mkdir -p /tmp/citeciter-dsh-home/profiles/node_modules/@kirkchinese
|
|
54
83
|
ln -sfn "$(pwd)/packages/citeciter" \
|
|
55
84
|
/tmp/citeciter-dsh-home/profiles/node_modules/@kirkchinese/dsh-citeciter
|
|
56
|
-
node packages/citeciter/dev/seed-smoke-session.mjs
|
|
85
|
+
node packages/citeciter/dev/seed-smoke-session.mjs \
|
|
86
|
+
/tmp/citeciter-dsh-home "$(pwd)"
|
|
57
87
|
DSH_HOME=/tmp/citeciter-dsh-home dsh --profile web \
|
|
58
88
|
--patch "$(pwd)/packages/citeciter/dev/patch.yml" --port 3907
|
|
59
|
-
node packages/citeciter/dev/smoke.mjs
|
|
89
|
+
node packages/citeciter/dev/smoke.mjs \
|
|
90
|
+
http://127.0.0.1:3907 CiteCiter \
|
|
60
91
|
/tmp/citeciter-dsh-home/citeciter-smoke.json
|
|
61
92
|
```
|
|
62
93
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
## 实时浏览器开发
|
|
66
|
-
|
|
67
|
-
1. 按上面的方式把包链接到临时 Web profile,并通过 `dev/patch.yml` 挂载。
|
|
68
|
-
2. 启动 profile 并至少打开一次 URL;DSH Web 会挂载 Cordis client-HMR 的 Host 与浏览器插件。
|
|
69
|
-
3. 运行 `pnpm --filter @kirkchinese/dsh-citeciter dev`,同时监听 declaration 模块与浏览器 bundle。
|
|
70
|
-
|
|
71
|
-
DSH Host 检测 bundle 变化后会发送 `/plugins/events` rebuild 帧,浏览器随后替换 CiteCiter 的 Cordis fiber。插件内 React 和面板状态会重置,DSH 持有的会话数据不会重置。只有修改 DSH 自有 client package 时,完整 DSH 源码检出目录才需要运行自己的 `pnpm run dev:web`。
|
|
72
|
-
|
|
73
|
-
开发服务器已挂载插件时,可运行 `node packages/citeciter/dev/hmr-smoke.mjs http://127.0.0.1:3907`。脚本会原子修改并还原 bundle,验证 rebuild 帧、旧 fiber 回收、新 fiber 交互和浏览器错误。
|
|
94
|
+
Smoke 使用真实渲染的 `14:assistant-step1:1` 节点和真实 `anchorSeq: 6`,验证自定义首问、持久投影、恢复、重命名、常驻入口、侧栏宽度、父日志 revision 与浏览器错误。临时 profile 没有模型凭据时,正常的 provider 错误也只会在 read-only、Remote 准备、Citation Context 和真实用户消息全部成功后出现。
|
|
74
95
|
|
|
75
96
|
## 贡献与许可证
|
|
76
97
|
|