@khorsheed/dsh-context-lens 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.en.md +53 -0
- package/README.i18n.yaml +6 -0
- package/README.md +52 -2
- package/cordis.patch.yml +13 -0
- package/lib/client.js +26953 -0
- package/lib/index.js +3943 -0
- package/lib/typert.host.d.ts +3 -0
- package/lib/typert.host.js +1569 -0
- package/lib/typert.remote-client.d.ts +40 -0
- package/lib/typert.remote-client.js +1202 -0
- package/lib/types/changes.d.ts +72 -0
- package/lib/types/changes.js +328 -0
- package/lib/types/client/AgentTabs.d.ts +34 -0
- package/lib/types/client/AgentTabs.js +89 -0
- package/lib/types/client/ChangeList.d.ts +28 -0
- package/lib/types/client/ChangeList.js +109 -0
- package/lib/types/client/ConfigFacts.d.ts +21 -0
- package/lib/types/client/ConfigFacts.js +30 -0
- package/lib/types/client/HeaderUtility.d.ts +12 -0
- package/lib/types/client/HeaderUtility.js +8 -0
- package/lib/types/client/InspectorPanel.d.ts +5 -0
- package/lib/types/client/InspectorPanel.js +486 -0
- package/lib/types/client/RawView.d.ts +18 -0
- package/lib/types/client/RawView.js +8 -0
- package/lib/types/client/RequestFacts.d.ts +19 -0
- package/lib/types/client/RequestFacts.js +39 -0
- package/lib/types/client/RoomDecisionsView.d.ts +24 -0
- package/lib/types/client/RoomDecisionsView.js +52 -0
- package/lib/types/client/SchemaFields.d.ts +13 -0
- package/lib/types/client/SchemaFields.js +96 -0
- package/lib/types/client/SegCtl.d.ts +32 -0
- package/lib/types/client/SegCtl.js +12 -0
- package/lib/types/client/SegmentBlocks.d.ts +28 -0
- package/lib/types/client/SegmentBlocks.js +225 -0
- package/lib/types/client/TimingView.d.ts +17 -0
- package/lib/types/client/TimingView.js +98 -0
- package/lib/types/client/TokenView.d.ts +21 -0
- package/lib/types/client/TokenView.js +22 -0
- package/lib/types/client/ToolCatalog.d.ts +9 -0
- package/lib/types/client/ToolCatalog.js +51 -0
- package/lib/types/client/Trend.d.ts +25 -0
- package/lib/types/client/Trend.js +100 -0
- package/lib/types/client/TurnAction.d.ts +14 -0
- package/lib/types/client/TurnAction.js +31 -0
- package/lib/types/client/TurnMenu.d.ts +36 -0
- package/lib/types/client/TurnMenu.js +50 -0
- package/lib/types/client/aggregate.d.ts +141 -0
- package/lib/types/client/aggregate.js +213 -0
- package/lib/types/client/contract.d.ts +58 -0
- package/lib/types/client/contract.js +1 -0
- package/lib/types/client/definition.d.ts +47 -0
- package/lib/types/client/definition.js +25 -0
- package/lib/types/client/icons-local.d.ts +19 -0
- package/lib/types/client/icons-local.js +3 -0
- package/lib/types/client/icons.d.ts +18 -0
- package/lib/types/client/icons.js +2 -0
- package/lib/types/client/index.d.ts +42 -0
- package/lib/types/client/index.js +139 -0
- package/lib/types/client/locales.d.ts +365 -0
- package/lib/types/client/locales.js +705 -0
- package/lib/types/client/preset-visibility.d.ts +99 -0
- package/lib/types/client/preset-visibility.js +108 -0
- package/lib/types/client/scroll-sync.d.ts +54 -0
- package/lib/types/client/scroll-sync.js +118 -0
- package/lib/types/client/timing.d.ts +29 -0
- package/lib/types/client/timing.js +117 -0
- package/lib/types/client/wire.d.ts +13 -0
- package/lib/types/client/wire.js +11 -0
- package/lib/types/index.d.ts +32 -0
- package/lib/types/index.js +25 -0
- package/lib/types/log-lane.d.ts +198 -0
- package/lib/types/log-lane.js +841 -0
- package/lib/types/messages.d.ts +96 -0
- package/lib/types/messages.js +254 -0
- package/lib/types/prefix-diff.d.ts +4 -0
- package/lib/types/prefix-diff.js +20 -0
- package/lib/types/remote.d.ts +45 -0
- package/lib/types/remote.js +99 -0
- package/lib/types/room.d.ts +66 -0
- package/lib/types/room.js +101 -0
- package/lib/types/segmenter.d.ts +100 -0
- package/lib/types/segmenter.js +184 -0
- package/lib/types/service.d.ts +145 -0
- package/lib/types/service.js +493 -0
- package/lib/types/store.d.ts +424 -0
- package/lib/types/store.js +1920 -0
- package/lib/types/tool-summary.d.ts +6 -0
- package/lib/types/tool-summary.js +7 -0
- package/lib/types/types.d.ts +703 -0
- package/lib/types/types.js +18 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +133 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# 变更记录
|
|
2
|
+
|
|
3
|
+
## 0.1.0(2026-10-26)
|
|
4
|
+
|
|
5
|
+
首个公开发布:上下文透镜——点一下任意一轮对话,就能看到模型这一轮到底收到了什么、token 花在哪、时间耗在哪。随「开发套件」和「多Agent协作」安装。
|
|
6
|
+
|
|
7
|
+
- **从对话直接打开**:每轮回答下面的「请求明细」图标跳到这一轮,会话顶部的图标打开最新一轮;对话还没渲染到的旧轮次也能跳过去,「回到最新」一键回底。
|
|
8
|
+
- **会话地图**:面板顶部是整段会话的轮次地图(有其它 agent 参与的轮次带标记),下面平铺这一轮的参与者——主对话、外部 agent、子 agent、压缩;外部 agent 的页签跨轮保留。长会话按 30 轮一窗加载,可往前往后翻。
|
|
9
|
+
- **看清请求里装了什么**:系统提示、工具定义、历史和本次新增分块显示,系统提示每一段标出来源,可展开原文;「只看重复」挑出重复塞进去的内容,只计多出来的副本。
|
|
10
|
+
- **知道缓存为什么断**:真实的缓存命中与未命中(含缓存写入),和上一次请求的差异精确到字,并逐条列出每一处变化及其背后的宿主事件(替换、压缩、裁剪)。
|
|
11
|
+
- **看时间花在哪**:总耗时拆成模型、工具执行和空档,各 agent 独立泳道,工具表可排序;子 agent 的时间不在主对话里重复计算。
|
|
12
|
+
- **协作间看得清**:协调者交接后,人发给成员的每次派活单独成一轮;Codex / Claude Code / Kimi 这类 CLI 成员的会话按它们的日志重建,一次调用算一次请求、从上一个事件计时;协作间发言卡片的明细按钮直接定位到那位成员的那一轮;「房间」页签列出协作间自动判断的每次模型调用(场景、概率、输入输出 token、延迟、发出的状态与得到的答案)。
|
|
13
|
+
- **装之前的对话也能看**:打开时从会话日志补出插件装上之前的轮次,遵守上下文替换与压缩。
|
|
14
|
+
- **只看不改**:只读监听宿主的三条请求接缝,从不改写发给模型的请求;数据只放在内存里(有总量上限,最旧的回溯先让位)。
|
|
15
|
+
|
|
16
|
+
技术面:Remote 动词 `listTurns` / `getTurn` / `getRequest` / `getTurnTiming` / `getSessionTrend` / `loadTurns`,可带 `filter.scopes` 供可信服务端按授权过滤;需要宿主 0.1.5-rc.1 起,turn 动作行入口需 0.1.7-rc.1 起(旧宿主只有会话头部入口)。本包由仓内的 request-inspector 改名而来,`requestInspector` 服务与 Remote 命名空间保持兼容;迁移时替换依赖与行,不要两个同时挂载。
|
package/README.en.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @khorsheed/dsh-context-lens
|
|
2
|
+
|
|
3
|
+
English | [中文](README.md)
|
|
4
|
+
|
|
5
|
+
Click any turn in the conversation and see exactly what the model received, where the tokens went, and where the time went.
|
|
6
|
+
|
|
7
|
+
When you're tuning a prompt or building a plugin, the questions are always the same: what actually went into this request? Why did the cache miss? Why was this turn so slow? Until now that meant digging through logs and piecing it together yourself. With the context lens, click the icon next to a turn and the right sidebar lays out every model request in it: where each part of the system prompt came from, how many tools came along, what's history and what's new this time, plus a breakdown of the timing. You can tell at a glance whether too much is being injected, at which character the cache broke, and which step ate the time.
|
|
8
|
+
|
|
9
|
+
<img src="https://raw.githubusercontent.com/Khorsheed/dsh-basic/main/docs/screenshots/context-lens-1.png" width="560" alt="Click the request-details icon under a reply and Context Lens opens that turn on the right: one tab for the main conversation and one per member, the requests listed on the left, the cache hit and breakpoint comparison of the selected request on the right">
|
|
10
|
+
|
|
11
|
+
## What it does
|
|
12
|
+
|
|
13
|
+
- **Open it from the conversation**: every answer gets an extra icon underneath that jumps to that turn; the icon at the top of the session opens the latest one, and "Jump to the latest turn" always brings you back to the end.
|
|
14
|
+
- **See what's in the request**: each request is split into system prompt, tool definitions, history and what's new this time; every part of the system prompt is labeled with where it came from, and you can expand the full text.
|
|
15
|
+
- **Find out why the cache broke**: it shows how much really hit the cache, and pinpoints, down to the character, what changed since the previous request.
|
|
16
|
+
- **Catch duplicated content**: press "Duplicates only" to pick out the same text sent more than once, counting only the extra copies.
|
|
17
|
+
- **See where the time went**: switch to "Timing" and the total splits into model, tool execution and the gaps in between, with a sortable list of how long each tool took.
|
|
18
|
+
|
|
19
|
+
<img src="https://raw.githubusercontent.com/Khorsheed/dsh-basic/main/docs/screenshots/context-lens-2.png" width="560" alt=""This exchange": the new input on the left (an assistant message and a few tool results), the model's output and each tool call's arguments on the right">
|
|
20
|
+
|
|
21
|
+
<img src="https://raw.githubusercontent.com/Khorsheed/dsh-basic/main/docs/screenshots/context-lens-3.png" width="560" alt=""Context composition": a colored proportion bar, then groups for system, tools, history and new with their character counts, the new entries listed one by one">
|
|
22
|
+
|
|
23
|
+
<img src="https://raw.githubusercontent.com/Khorsheed/dsh-basic/main/docs/screenshots/context-lens-4.png" width="560" alt=""Time breakdown": the turn's total split into model calls, tool calls and other, a color-coded timeline of thinking, tool execution and idle, and a tool-time table sorted by total">
|
|
24
|
+
|
|
25
|
+
- **Subagents add up correctly**: each delegated subagent gets its own entry, and its time isn't counted twice in the main conversation.
|
|
26
|
+
- **Turns from before you installed it**: when you open it, it fills in earlier turns from the session's record.
|
|
27
|
+
- **It only looks**: it never changes what's sent to the model, and what it collects stays in memory rather than being written into the session.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
In DSH, open Plugins → Add plugin, enter this package name, and press Install:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
@khorsheed/dsh-dev-suite
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The context lens comes with the Dev Suite, and with 「多Agent协作」 (multi-agent, `@khorsheed/dsh-bundle-local-agent`) too. Then open any session, have one exchange, and click the icon under that answer.
|
|
38
|
+
|
|
39
|
+
## Known limitations
|
|
40
|
+
|
|
41
|
+
- A turn that's still running doesn't update live; open it again once it's done.
|
|
42
|
+
- For older turns filled in from the session record, the system prompt shows as one block, without where each part came from.
|
|
43
|
+
- What you see is the content as assembled before sending, not the raw bytes that finally go to the model provider.
|
|
44
|
+
|
|
45
|
+
## Compatibility
|
|
46
|
+
|
|
47
|
+
Needs DSH 0.1.5-rc.1 or later; verified on 0.2.1-rc.1.
|
|
48
|
+
|
|
49
|
+
## For developers
|
|
50
|
+
|
|
51
|
+
- Entry points: `src/index.ts` (capture and service), `src/client/index.ts` (the sidebar panel); `examples/workbench/` previews the panel on made-up data (`pnpm exec tsx packages/context-lens/examples/workbench/serve.mts`).
|
|
52
|
+
- You can install it alone (`dsh plugin --profile web add @khorsheed/dsh-context-lens`); it was renamed from the old request-inspector, so when migrating, replace the old package rather than installing both.
|
|
53
|
+
- Part of [dsh-plugins](https://github.com/Khorsheed/dsh-plugins); open issues and contributions there. Changes: [CHANGELOG.md](CHANGELOG.md).
|
package/README.i18n.yaml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Bilingual-pair consistency record: the git blob hash of each side as of the
|
|
2
|
+
# last confirmed-consistent state. Both languages carry equal authority; after
|
|
3
|
+
# editing either side, bring the other along and re-record with:
|
|
4
|
+
# pnpm run verify-translation-pairing --write packages/context-lens/README.en.md
|
|
5
|
+
packages/context-lens/README.en.md: e599d8a9b4c70027e6f5bfed976447ffb767fc47
|
|
6
|
+
packages/context-lens/README.md: 9f6d8a078c41522614700b7546aa09c81f42e749
|
package/README.md
CHANGED
|
@@ -1,3 +1,53 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @khorsheed/dsh-context-lens
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[English](README.en.md) | 中文
|
|
4
|
+
|
|
5
|
+
点一下任意一轮对话,就能看到模型这一轮到底收到了什么、token 花在哪、时间耗在哪。
|
|
6
|
+
|
|
7
|
+
调提示词、写插件的时候,你最想知道的往往是:这次请求里到底塞了什么?缓存为什么没命中?这一轮怎么这么慢?以前只能翻日志、自己拼。装上上下文透镜,在对话里点一下某一轮旁边的图标,右栏就把这一轮的每一次模型请求摊开给你看:系统提示每一段从哪来、带了多少工具、哪些是历史、哪些是这次新加的,再配上耗时的拆分。你一眼就能看出注入是不是太多、缓存从哪个字开始断的、时间都花在了哪一步。
|
|
8
|
+
|
|
9
|
+
<img src="https://raw.githubusercontent.com/Khorsheed/dsh-basic/main/docs/screenshots/context-lens-1.png" width="560" alt="点回答下面的「请求明细」图标,右栏的上下文透镜摊开这一轮:主对话和每个成员各一个页签,左边逐次列出请求,右边是这次请求的缓存命中和断点对比">
|
|
10
|
+
|
|
11
|
+
## 能做什么
|
|
12
|
+
|
|
13
|
+
- **从对话直接打开**:每一轮回答下面多一个图标,点一下就跳到这一轮;会话顶部的图标打开最新一轮,「定位到最新 turn」随时回到最后。
|
|
14
|
+
- **看清请求里装了什么**:每次请求拆成系统提示、工具定义、历史和本次新增几块,系统提示每一段都标出来源,想看原文就展开。
|
|
15
|
+
- **知道缓存为什么断**:显示真实的缓存命中多少,再把和上一次请求不一样的地方精确到字标出来。
|
|
16
|
+
- **揪出重复内容**:点「只看重复」,把重复塞进去的同一段内容挑出来,只算多出来的那几份。
|
|
17
|
+
- **看时间花在哪**:切到「耗时分布」,总耗时拆成模型、工具执行和中间的空档,每个工具花了多久也能排序看。
|
|
18
|
+
|
|
19
|
+
<img src="https://raw.githubusercontent.com/Khorsheed/dsh-basic/main/docs/screenshots/context-lens-2.png" width="560" alt="「本次交换」:左边是这次新增的输入(助手消息和几条工具结果),右边是模型的输出和每个工具调用的参数">
|
|
20
|
+
|
|
21
|
+
<img src="https://raw.githubusercontent.com/Khorsheed/dsh-basic/main/docs/screenshots/context-lens-3.png" width="560" alt="「上下文构成」:一条彩色比例条,下面按系统、工具、历史、新增分组,每组的字符数,新增的几条逐条列出">
|
|
22
|
+
|
|
23
|
+
<img src="https://raw.githubusercontent.com/Khorsheed/dsh-basic/main/docs/screenshots/context-lens-4.png" width="560" alt="「耗时分布」:本轮总耗时拆成模型调用、工具调用和其他,一条时间线按颜色标出模型思考、工具执行和空闲,下面是按合计排序的工具耗时表">
|
|
24
|
+
|
|
25
|
+
- **子 agent 也算得清**:委派出去的子 agent 单独列出来,主对话里不会把它的时间重复算一遍。
|
|
26
|
+
- **装之前的对话也能看**:打开时会从会话记录里补出插件装上之前的轮次。
|
|
27
|
+
- **只看不改**:它从不改动发给模型的请求,看到的数据只放在内存里,不写进会话。
|
|
28
|
+
|
|
29
|
+
## 安装
|
|
30
|
+
|
|
31
|
+
在 DSH 的「插件 → 添加插件」里输入下面的包名,点安装:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
@khorsheed/dsh-dev-suite
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
上下文透镜会跟着「开发套件」一起装好;「多Agent协作」(`@khorsheed/dsh-bundle-local-agent`)里也带着它。装完随便开一个会话,聊一轮,再点那一轮回答下面的图标就能看。
|
|
38
|
+
|
|
39
|
+
## 已知限制
|
|
40
|
+
|
|
41
|
+
- 正在进行中的那一轮不会实时刷新,要等它结束后重新打开。
|
|
42
|
+
- 从会话记录补出来的旧轮次,系统提示只能显示成一整块,分不出各段来源。
|
|
43
|
+
- 显示的是发出前组装好的内容,不是最终发到模型服务商那里的原始字节。
|
|
44
|
+
|
|
45
|
+
## Compatibility
|
|
46
|
+
|
|
47
|
+
需要 DSH 0.1.5-rc.1 或更新版本,已在 0.2.1-rc.1 上验证。
|
|
48
|
+
|
|
49
|
+
## 给开发者
|
|
50
|
+
|
|
51
|
+
- 入口:`src/index.ts`(采集与服务)、`src/client/index.ts`(右栏面板);`examples/workbench/` 能用假数据单独预览面板(`pnpm exec tsx packages/context-lens/examples/workbench/serve.mts`)。
|
|
52
|
+
- 也可以单独安装(`dsh plugin --profile web add @khorsheed/dsh-context-lens`);本包由旧的 request-inspector 改名而来,迁移时替换掉旧包,不要两个同时装。
|
|
53
|
+
- 隶属 [dsh-plugins](https://github.com/Khorsheed/dsh-plugins),问题与贡献请到该仓库;变更见 [CHANGELOG.md](CHANGELOG.md)。
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# dsh-context-lens bundle patch: inserts the plugin row into the composing
|
|
2
|
+
# profile, so `dsh plugin --profile <name> add @khorsheed/dsh-context-lens`
|
|
3
|
+
# reconciles it into the bundles layer. The row is a bare mount — the host half
|
|
4
|
+
# captures per-call request snapshots and mounts its Remote face; the browser
|
|
5
|
+
# half mounts the Remote contribution and the panel surfaces.
|
|
6
|
+
#
|
|
7
|
+
# NOTE: a composition must mount this row id exactly once. Official images
|
|
8
|
+
# mount no context-lens row, so plugin-adding this package is the install
|
|
9
|
+
# path there; a composition that already mounts the id by other means must NOT
|
|
10
|
+
# also add it — a duplicate loader entry id fails boot.
|
|
11
|
+
- insert:
|
|
12
|
+
- id: context-lens
|
|
13
|
+
name: "@khorsheed/dsh-context-lens"
|