dsh-context 0.4.0 → 0.5.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/LICENSE +201 -21
- package/README.md +7 -5
- package/lib/client.js +140 -23
- package/package.json +4 -3
package/LICENSE
CHANGED
|
@@ -1,21 +1,201 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 bowenliang123
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -61,11 +61,13 @@ Open any session and click **上下文 / Context** (to the right of Chat and Tra
|
|
|
61
61
|
|
|
62
62
|
## Development
|
|
63
63
|
|
|
64
|
+
The project is a pnpm workspace root (`pnpm-workspace.yaml`), so `pnpm install` never walks up into a parent workspace.
|
|
65
|
+
|
|
64
66
|
```sh
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
pnpm install # devDependencies only — the plugin itself stays dependency-free
|
|
68
|
+
pnpm run typecheck # tsc --noEmit (strict)
|
|
69
|
+
pnpm run build # esbuild: lib/index.js (host) + lib/client.js (client bundle)
|
|
70
|
+
pnpm test # typecheck + functional tests for both halves
|
|
69
71
|
```
|
|
70
72
|
|
|
71
73
|
`build.mjs` also smoke-checks the outputs (both halves must parse; the host half must import with the `name`/`inject`/`apply` plugin shape).
|
|
@@ -84,4 +86,4 @@ npm test # typecheck + functional tests for both halves
|
|
|
84
86
|
|
|
85
87
|
## License
|
|
86
88
|
|
|
87
|
-
|
|
89
|
+
[Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
package/lib/client.js
CHANGED
|
@@ -21,6 +21,8 @@ const DICT_ZH = {
|
|
|
21
21
|
"tools.top": "\u5DE5\u5177\u5B9A\u4E49 Top\uFF1A",
|
|
22
22
|
"tools.more": "\u7B49 {n} \u4E2A",
|
|
23
23
|
"trend.title": "\u5386\u53F2\u8D8B\u52BF",
|
|
24
|
+
"gran.step": "\u6B65\u9AA4",
|
|
25
|
+
"gran.turn": "\u8F6E\u6B21",
|
|
24
26
|
"trend.hint": "\u6BCF\u6B21\u6A21\u578B\u8BF7\u6C42\u4E00\u6BB5\uFF1B\u70B9\u51FB\u67F1\u5B50\u67E5\u770B\u8BE6\u60C5\uFF0C\u2702 \u8868\u793A\u538B\u7F29/\u526A\u679D",
|
|
25
27
|
"trend.empty": "\u53D1\u8D77\u4E00\u8F6E\u5BF9\u8BDD\u540E\uFF0C\u8FD9\u91CC\u4F1A\u5C55\u793A\u6BCF\u6B21\u6A21\u578B\u8BF7\u6C42\u7684\u4E0A\u4E0B\u6587\u6784\u6210",
|
|
26
28
|
"detail.step": "T{t} \xB7 \u7B2C {s} \u6B65",
|
|
@@ -70,6 +72,8 @@ const DICT_EN = {
|
|
|
70
72
|
"tools.top": "Top tool schemas:",
|
|
71
73
|
"tools.more": "of {n}",
|
|
72
74
|
"trend.title": "History",
|
|
75
|
+
"gran.step": "Step",
|
|
76
|
+
"gran.turn": "Turn",
|
|
73
77
|
"trend.hint": "one bar per model request; click a bar for details, \u2702 marks compaction/prune",
|
|
74
78
|
"trend.empty": "Send a message and each model request\u2019s context makeup shows up here",
|
|
75
79
|
"detail.step": "T{t} \xB7 step {s}",
|
|
@@ -118,6 +122,15 @@ function fmtTime(t) {
|
|
|
118
122
|
}
|
|
119
123
|
return p(d.getHours()) + ":" + p(d.getMinutes()) + ":" + p(d.getSeconds());
|
|
120
124
|
}
|
|
125
|
+
function aggregateByTurn(requests) {
|
|
126
|
+
const out = [];
|
|
127
|
+
for (const req of requests) {
|
|
128
|
+
const last = out.length > 0 ? out[out.length - 1] : null;
|
|
129
|
+
if (last !== null && (last.turn ?? 0) === (req.turn ?? 0)) out[out.length - 1] = req;
|
|
130
|
+
else out.push(req);
|
|
131
|
+
}
|
|
132
|
+
return out;
|
|
133
|
+
}
|
|
121
134
|
function makeView(ctx, t) {
|
|
122
135
|
function tr(key, vars) {
|
|
123
136
|
return t(key, vars);
|
|
@@ -159,17 +172,46 @@ function makeView(ctx, t) {
|
|
|
159
172
|
let total = 0;
|
|
160
173
|
for (const p of props.parts) total += p.value;
|
|
161
174
|
const scale = props.max !== void 0 && props.max > total ? props.max : total;
|
|
175
|
+
const wrapRef = React.useRef(null);
|
|
176
|
+
const [tip, setTip] = React.useState(null);
|
|
177
|
+
const showTip = (e, p) => {
|
|
178
|
+
const rect = wrapRef.current?.getBoundingClientRect();
|
|
179
|
+
const left = rect ? e.clientX - rect.left : 50;
|
|
180
|
+
const width = rect?.width ?? 200;
|
|
181
|
+
setTip({
|
|
182
|
+
key: p.key,
|
|
183
|
+
text: catLabel(p.key) + " " + fmt(p.value) + " (" + Math.round(p.value / total * 100) + "%)",
|
|
184
|
+
left: Math.max(48, Math.min(left, width - 48))
|
|
185
|
+
});
|
|
186
|
+
};
|
|
162
187
|
return h(
|
|
163
188
|
"div",
|
|
164
|
-
{ className: "lc-stacked"
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
189
|
+
{ className: "lc-stacked-wrap" },
|
|
190
|
+
h(
|
|
191
|
+
"div",
|
|
192
|
+
{
|
|
193
|
+
className: "lc-stacked",
|
|
194
|
+
style: { height: (props.height || 14) + "px" },
|
|
195
|
+
ref: wrapRef,
|
|
196
|
+
onMouseLeave: () => {
|
|
197
|
+
setTip(null);
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
total <= 0 ? null : props.parts.map((p) => {
|
|
201
|
+
if (!p.value) return null;
|
|
202
|
+
return h("div", {
|
|
203
|
+
key: p.key,
|
|
204
|
+
style: { width: p.value / scale * 100 + "%", background: p.color },
|
|
205
|
+
onMouseEnter: (e) => {
|
|
206
|
+
showTip(e, p);
|
|
207
|
+
},
|
|
208
|
+
onMouseMove: (e) => {
|
|
209
|
+
showTip(e, p);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
})
|
|
213
|
+
),
|
|
214
|
+
tip ? h("div", { className: "lc-bar-tip", style: { left: tip.left + "px" } }, tip.text) : null
|
|
173
215
|
);
|
|
174
216
|
}
|
|
175
217
|
function Legend(props) {
|
|
@@ -197,6 +239,7 @@ function makeView(ctx, t) {
|
|
|
197
239
|
const CHART_H = 112;
|
|
198
240
|
const BAR_W = 14;
|
|
199
241
|
const BAR_GAP = 2;
|
|
242
|
+
const TURN_COLORS = ["#6366f1", "#f59e0b", "#22c55e", "#a855f7", "#3b82f6", "#14b8a6", "#ef4444", "#ec4899"];
|
|
200
243
|
function TrendChart(props) {
|
|
201
244
|
const requests = props.requests;
|
|
202
245
|
let maxTotal = 1;
|
|
@@ -239,22 +282,31 @@ function makeView(ctx, t) {
|
|
|
239
282
|
h(
|
|
240
283
|
"div",
|
|
241
284
|
{ className: "lc-chart-scroll", ref: scrollRef },
|
|
285
|
+
// Hovering a bar previews it in the detail below; leaving the plot
|
|
286
|
+
// clears the preview (a pinned selection, if any, takes over again).
|
|
242
287
|
h(
|
|
243
288
|
"div",
|
|
244
|
-
{ className: "lc-chart"
|
|
289
|
+
{ className: "lc-chart", onMouseLeave: () => {
|
|
290
|
+
props.onHover(null);
|
|
291
|
+
} },
|
|
245
292
|
h("div", { className: "lc-grid lc-grid-top" }),
|
|
246
293
|
h("div", { className: "lc-grid lc-grid-mid" }),
|
|
247
294
|
requests.map((req, i) => {
|
|
248
295
|
const selected = props.selectedSeq === req.seq;
|
|
296
|
+
const hovered = props.hoveredSeq === req.seq;
|
|
297
|
+
const inTurn = props.activeTurn !== null && (req.turn ?? 0) === props.activeTurn;
|
|
249
298
|
const tip = tr("tip.step", { t: req.turn ?? 0, s: req.step ?? 0 }) + " \xB7 " + fmtTime(req.time) + "\n" + tr("tip.total", { n: fmt(req.total) }) + (req.prompt !== void 0 ? tr("tip.actual", { n: fmt(req.prompt) }) : "") + "\n" + CATS.map((c) => catLabel(c.key) + " " + fmt(req[c.key] || 0)).join(" / ");
|
|
250
299
|
return h(
|
|
251
300
|
"div",
|
|
252
301
|
{
|
|
253
302
|
key: req.seq,
|
|
254
|
-
className: "lc-bar" + (selected ? " lc-bar-selected" : ""),
|
|
303
|
+
className: "lc-bar" + (selected ? " lc-bar-selected" : "") + (hovered ? " lc-bar-hovered" : "") + (inTurn ? " lc-bar-in-turn" : ""),
|
|
255
304
|
title: tip,
|
|
256
305
|
onClick: () => {
|
|
257
306
|
props.onSelect(selected ? null : req.seq);
|
|
307
|
+
},
|
|
308
|
+
onMouseEnter: () => {
|
|
309
|
+
props.onHover(req.seq);
|
|
258
310
|
}
|
|
259
311
|
},
|
|
260
312
|
markers[i] ? h("span", { className: "lc-bar-marker", title: eventLabel(markers[i]) }, "\u2702") : null,
|
|
@@ -270,14 +322,29 @@ function makeView(ctx, t) {
|
|
|
270
322
|
);
|
|
271
323
|
})
|
|
272
324
|
),
|
|
325
|
+
// Turn strip: one COLOR BLOCK per turn, spanning exactly its bars'
|
|
326
|
+
// columns, so the partition reads at a glance and lines up with the
|
|
327
|
+
// steps above. Hovering a block highlights that turn's bars in the
|
|
328
|
+
// chart (and hovering a bar highlights its block — the active turn
|
|
329
|
+
// is shared hover-only state).
|
|
273
330
|
h(
|
|
274
331
|
"div",
|
|
275
|
-
{ className: "lc-turns"
|
|
332
|
+
{ className: "lc-turns", onMouseLeave: () => {
|
|
333
|
+
props.onHoverTurn(null);
|
|
334
|
+
} },
|
|
276
335
|
groups.map((grp, gi) => {
|
|
336
|
+
const on = props.activeTurn === grp.turn;
|
|
277
337
|
return h("span", {
|
|
278
338
|
key: "turn-" + gi,
|
|
279
|
-
className: "lc-turn",
|
|
280
|
-
style: {
|
|
339
|
+
className: "lc-turn" + (on ? " lc-turn-on" : ""),
|
|
340
|
+
style: {
|
|
341
|
+
width: grp.count * (BAR_W + BAR_GAP) - BAR_GAP + "px",
|
|
342
|
+
background: TURN_COLORS[gi % TURN_COLORS.length]
|
|
343
|
+
},
|
|
344
|
+
title: "T" + grp.turn,
|
|
345
|
+
onMouseEnter: () => {
|
|
346
|
+
props.onHoverTurn(grp.turn);
|
|
347
|
+
}
|
|
281
348
|
}, "T" + grp.turn);
|
|
282
349
|
})
|
|
283
350
|
)
|
|
@@ -375,7 +442,10 @@ function makeView(ctx, t) {
|
|
|
375
442
|
const [data, setData] = React.useState(null);
|
|
376
443
|
const [error, setError] = React.useState(null);
|
|
377
444
|
const [selectedSeq, setSelectedSeq] = React.useState(null);
|
|
445
|
+
const [hoveredSeq, setHoveredSeq] = React.useState(null);
|
|
446
|
+
const [hoverTurn, setHoverTurn] = React.useState(null);
|
|
378
447
|
const [tick, setTick] = React.useState(0);
|
|
448
|
+
const [granularity, setGranularity] = React.useState("step");
|
|
379
449
|
React.useEffect(() => {
|
|
380
450
|
if (typeof sessionId !== "string" || sessionId === "") return void 0;
|
|
381
451
|
let alive = true;
|
|
@@ -413,9 +483,22 @@ function makeView(ctx, t) {
|
|
|
413
483
|
const requests = data.requests || [];
|
|
414
484
|
const events = data.events || [];
|
|
415
485
|
const nodes = data.nodes || [];
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
486
|
+
const displayRequests = granularity === "turn" ? aggregateByTurn(requests) : requests;
|
|
487
|
+
let pinnedReq = null;
|
|
488
|
+
for (const req of displayRequests) if (req.seq === selectedSeq) pinnedReq = req;
|
|
489
|
+
let activeReq = null;
|
|
490
|
+
if (hoveredSeq !== null) {
|
|
491
|
+
for (const req of displayRequests) if (req.seq === hoveredSeq) activeReq = req;
|
|
492
|
+
}
|
|
493
|
+
if (activeReq === null) activeReq = pinnedReq;
|
|
494
|
+
if (activeReq === null && displayRequests.length > 0) activeReq = displayRequests[displayRequests.length - 1];
|
|
495
|
+
let activeTurn = hoverTurn;
|
|
496
|
+
if (activeTurn === null && hoveredSeq !== null) {
|
|
497
|
+
for (const req of displayRequests) if (req.seq === hoveredSeq) {
|
|
498
|
+
activeTurn = req.turn ?? null;
|
|
499
|
+
break;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
419
502
|
const windowPct = data.contextWindow ? Math.min(100, Math.round(current.total / data.contextWindow * 100)) : null;
|
|
420
503
|
return h(
|
|
421
504
|
"div",
|
|
@@ -460,13 +543,38 @@ function makeView(ctx, t) {
|
|
|
460
543
|
"div",
|
|
461
544
|
{ className: "lc-card-title" },
|
|
462
545
|
t("trend.title"),
|
|
463
|
-
h("span", { className: "lc-card-sub" }, t("trend.hint"))
|
|
546
|
+
h("span", { className: "lc-card-sub" }, t("trend.hint")),
|
|
547
|
+
h(
|
|
548
|
+
"div",
|
|
549
|
+
{ className: "lc-gran" },
|
|
550
|
+
h("button", {
|
|
551
|
+
className: "lc-gran-btn" + (granularity === "step" ? " lc-gran-on" : ""),
|
|
552
|
+
onClick: () => {
|
|
553
|
+
setGranularity("step");
|
|
554
|
+
}
|
|
555
|
+
}, t("gran.step")),
|
|
556
|
+
h("button", {
|
|
557
|
+
className: "lc-gran-btn" + (granularity === "turn" ? " lc-gran-on" : ""),
|
|
558
|
+
onClick: () => {
|
|
559
|
+
setGranularity("turn");
|
|
560
|
+
}
|
|
561
|
+
}, t("gran.turn"))
|
|
562
|
+
)
|
|
464
563
|
),
|
|
465
|
-
|
|
564
|
+
displayRequests.length === 0 ? h("div", { className: "lc-empty" }, t("trend.empty")) : h(
|
|
466
565
|
"div",
|
|
467
566
|
null,
|
|
468
|
-
h(TrendChart, {
|
|
469
|
-
|
|
567
|
+
h(TrendChart, {
|
|
568
|
+
requests: displayRequests.slice(-80),
|
|
569
|
+
events,
|
|
570
|
+
selectedSeq: pinnedReq ? pinnedReq.seq : null,
|
|
571
|
+
hoveredSeq,
|
|
572
|
+
activeTurn,
|
|
573
|
+
onSelect: setSelectedSeq,
|
|
574
|
+
onHover: setHoveredSeq,
|
|
575
|
+
onHoverTurn: setHoverTurn
|
|
576
|
+
}),
|
|
577
|
+
h(RequestDetail, { request: activeReq })
|
|
470
578
|
)
|
|
471
579
|
),
|
|
472
580
|
// ---- events + messages ----
|
|
@@ -501,10 +609,16 @@ const STYLES = [
|
|
|
501
609
|
".lc-card { background: var(--dsw-alias-bg-layer-1); border: 1px solid var(--dsw-alias-border-l1); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }",
|
|
502
610
|
".lc-card-title { font-weight: 600; margin-bottom: 10px; display: flex; align-items: baseline; gap: 8px; }",
|
|
503
611
|
".lc-card-sub { font-weight: 400; color: var(--dsw-alias-label-secondary); font-size: 12px; }",
|
|
612
|
+
".lc-gran { margin-left: auto; display: flex; gap: 2px; background: var(--dsw-alias-bg-layer-2); border: 1px solid var(--dsw-alias-border-l1); border-radius: 6px; padding: 1px; }",
|
|
613
|
+
".lc-gran-btn { border: 0; background: transparent; color: var(--dsw-alias-label-secondary); font-size: 11px; line-height: 1; padding: 3px 8px; border-radius: 5px; cursor: pointer; font-family: inherit; }",
|
|
614
|
+
".lc-gran-btn:hover { color: var(--dsw-alias-label-primary); }",
|
|
615
|
+
".lc-gran-on, .lc-gran-on:hover { background: var(--dsw-alias-brand-primary); color: #fff; }",
|
|
504
616
|
".lc-overview-num { margin-bottom: 8px; }",
|
|
505
617
|
".lc-overview-num b { font-size: 20px; }",
|
|
506
618
|
".lc-overview-num span { color: var(--dsw-alias-label-secondary); }",
|
|
619
|
+
".lc-stacked-wrap { position: relative; width: 100%; }",
|
|
507
620
|
".lc-stacked { display: flex; width: 100%; border-radius: 5px; overflow: hidden; background: rgba(128,128,128,0.18); }",
|
|
621
|
+
".lc-bar-tip { position: absolute; bottom: calc(100% + 6px); transform: translateX(-50%); z-index: 5; white-space: nowrap; background: var(--dsw-alias-bg-layer-2); border: 1px solid var(--dsw-alias-border-l1); border-radius: 6px; padding: 3px 8px; font-size: 12px; color: var(--dsw-alias-label-primary); box-shadow: 0 2px 8px rgba(0,0,0,0.18); pointer-events: none; }",
|
|
508
622
|
".lc-stacked > div { height: 100%; }",
|
|
509
623
|
".lc-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; }",
|
|
510
624
|
".lc-chip { display: inline-flex; align-items: center; gap: 5px; color: var(--dsw-alias-label-primary); }",
|
|
@@ -529,11 +643,14 @@ const STYLES = [
|
|
|
529
643
|
".lc-bar { position: relative; width: 14px; flex: none; height: 100%; display: flex; align-items: flex-end; cursor: pointer; border-radius: 2px; }",
|
|
530
644
|
".lc-bar:hover { background: var(--dsw-alias-bg-layer-2); }",
|
|
531
645
|
".lc-bar-selected { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 1px; }",
|
|
646
|
+
".lc-bar-hovered { outline: 1px dashed var(--dsw-alias-brand-primary); outline-offset: 1px; }",
|
|
647
|
+
".lc-bar-in-turn { background: rgba(99,102,241,0.14); }",
|
|
532
648
|
".lc-bar-stack { display: flex; flex-direction: column-reverse; width: 100%; }",
|
|
533
649
|
".lc-bar-stack > div { width: 100%; }",
|
|
534
650
|
".lc-bar-marker { position: absolute; top: -16px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--dsw-alias-state-warn-primary); }",
|
|
535
|
-
".lc-turns { display: flex; gap: 2px; width: max-content; min-width: 100%; }",
|
|
536
|
-
".lc-turn { flex: none; min-width:
|
|
651
|
+
".lc-turns { display: flex; gap: 2px; width: max-content; min-width: 100%; margin-top: 4px; }",
|
|
652
|
+
".lc-turn { flex: none; min-width: 16px; box-sizing: border-box; text-align: center; font-size: 10px; line-height: 14px; font-weight: 600; color: #fff; border-radius: 3px; height: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: default; transition: filter 120ms; }",
|
|
653
|
+
".lc-turn-on { filter: brightness(1.35); box-shadow: 0 0 0 1px rgba(255,255,255,0.4); }",
|
|
537
654
|
".lc-detail { margin-top: 12px; border-top: 1px solid var(--dsw-alias-border-l1); padding-top: 12px; }",
|
|
538
655
|
".lc-detail-head { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px; color: var(--dsw-alias-label-secondary); }",
|
|
539
656
|
".lc-detail-head b { color: var(--dsw-alias-label-primary); }",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-context",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Context insight panel for DeepSeek Harness: a Context tab (beside Chat/Trajectory) showing what the model's context window is made of and how it evolves — composition, per-request history, compactions, injections, and model switches.",
|
|
5
5
|
"author": "bowenliang123",
|
|
6
6
|
"repository": {
|
|
@@ -53,11 +53,12 @@
|
|
|
53
53
|
"token",
|
|
54
54
|
"ui"
|
|
55
55
|
],
|
|
56
|
-
"license": "
|
|
56
|
+
"license": "Apache-2.0",
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
59
59
|
"@types/react": "^18.3.31",
|
|
60
60
|
"esbuild": "^0.28.2",
|
|
61
61
|
"typescript": "^7.0.2"
|
|
62
|
-
}
|
|
62
|
+
},
|
|
63
|
+
"packageManager": "pnpm@11.9.0"
|
|
63
64
|
}
|