dsh-context 0.32.0 → 0.34.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/README.md +21 -4
- package/lib/client.js +1532 -258
- package/lib/index.d.ts +0 -8
- package/lib/index.js +14 -17
- package/package.json +8 -3
package/lib/index.d.ts
CHANGED
|
@@ -84,10 +84,6 @@ interface Snapshot {
|
|
|
84
84
|
projectedTokens?: number;
|
|
85
85
|
contextWindow?: number;
|
|
86
86
|
};
|
|
87
|
-
toolList: {
|
|
88
|
-
name: string;
|
|
89
|
-
tokens: number;
|
|
90
|
-
}[];
|
|
91
87
|
/**
|
|
92
88
|
* Image blocks live in the CURRENT context (user uploads plus tool-result
|
|
93
89
|
* images, nested blocks included) — the sum over the live surface nodes'
|
|
@@ -285,10 +281,6 @@ interface TimelineState {
|
|
|
285
281
|
sums: Record<Category, number>;
|
|
286
282
|
systemTokens: number;
|
|
287
283
|
toolsTokens: number;
|
|
288
|
-
toolList: {
|
|
289
|
-
name: string;
|
|
290
|
-
tokens: number;
|
|
291
|
-
}[];
|
|
292
284
|
/**
|
|
293
285
|
* The projection-cache precondition is plain JSON: a property whose value
|
|
294
286
|
* is `undefined` makes the whole checkpoint unserializable
|
package/lib/index.js
CHANGED
|
@@ -83,6 +83,8 @@ function solveResizeRatio(height, width, budget) {
|
|
|
83
83
|
let bestWidth;
|
|
84
84
|
if (gridW < 1) {
|
|
85
85
|
let rows = floorDiv(budget - 2, 2);
|
|
86
|
+
/* v8 ignore else -- budget enters at 381 and the tall solve always fits
|
|
87
|
+
(never decrements), so rows is always odd here; parity-defensive. */
|
|
86
88
|
if (rows % 2 === 1) rows -= 1;
|
|
87
89
|
bestWidth = unit;
|
|
88
90
|
bestHeight = rows * unit;
|
|
@@ -162,6 +164,8 @@ function estimateImageTokens(width, height) {
|
|
|
162
164
|
}
|
|
163
165
|
return null;
|
|
164
166
|
} catch {
|
|
167
|
+
/* v8 ignore next -- the only throw site is the clamped-away budget guard
|
|
168
|
+
above; the catch keeps a hostile dimension from ever breaking the fold. */
|
|
165
169
|
return null;
|
|
166
170
|
}
|
|
167
171
|
}
|
|
@@ -370,7 +374,12 @@ const SETTINGS_NAMESPACE = "dsh-context";
|
|
|
370
374
|
/** Section schema: also the wire envelope the browser scope validates against. */
|
|
371
375
|
const SettingsSchema = z$1.object({
|
|
372
376
|
defaultGranularity: z$1.union(["step", "turn"]).default("step"),
|
|
373
|
-
defaultTrendMode: z$1.union(["total", "delta"]).default("total").loose()
|
|
377
|
+
defaultTrendMode: z$1.union(["total", "delta"]).default("total").loose(),
|
|
378
|
+
defaultFileSort: z$1.union([
|
|
379
|
+
"count",
|
|
380
|
+
"latest",
|
|
381
|
+
"path"
|
|
382
|
+
]).default("count").loose()
|
|
374
383
|
});
|
|
375
384
|
/** Serve the namespace while a settings provider is composed; inert otherwise. */
|
|
376
385
|
function installSettings(ctx) {
|
|
@@ -431,7 +440,6 @@ function createTimelineState() {
|
|
|
431
440
|
},
|
|
432
441
|
systemTokens: 0,
|
|
433
442
|
toolsTokens: 0,
|
|
434
|
-
toolList: [],
|
|
435
443
|
requests: [],
|
|
436
444
|
events: [],
|
|
437
445
|
archived: [],
|
|
@@ -619,6 +627,9 @@ function accumulateCost(st, time, usage) {
|
|
|
619
627
|
};
|
|
620
628
|
const nextFam = { ...fam };
|
|
621
629
|
nextFam[period] = {
|
|
630
|
+
/* v8 ignore next 1 -- accumulateCost only runs under the
|
|
631
|
+
`typeof usage.inputTokens === 'number'` guard; the fallback is
|
|
632
|
+
defensive against a hand-built UsageLike. */
|
|
622
633
|
uncached: b.uncached + (usage.inputTokens ?? 0),
|
|
623
634
|
cacheRead: b.cacheRead + (usage.cacheReadTokens ?? 0),
|
|
624
635
|
cacheWrite: b.cacheWrite + (usage.cacheWriteTokens ?? 0),
|
|
@@ -642,7 +653,6 @@ function applyTimeline(state, event, bounds) {
|
|
|
642
653
|
...state,
|
|
643
654
|
surface: [...state.surface],
|
|
644
655
|
sums: { ...state.sums },
|
|
645
|
-
toolList: [...state.toolList],
|
|
646
656
|
requests: [...state.requests],
|
|
647
657
|
events: [...state.events],
|
|
648
658
|
archived: [...state.archived],
|
|
@@ -654,10 +664,6 @@ function applyTimeline(state, event, bounds) {
|
|
|
654
664
|
const header = data?.header ?? {};
|
|
655
665
|
const tools = Array.isArray(header.tools) ? header.tools : [];
|
|
656
666
|
const s = ensure();
|
|
657
|
-
s.toolList = tools.map((t) => ({
|
|
658
|
-
name: typeof t.name === "string" ? t.name : "?",
|
|
659
|
-
tokens: estimateToolSchema(t)
|
|
660
|
-
}));
|
|
661
667
|
s.toolsTokens = estimateToolsTotal(tools);
|
|
662
668
|
s.systemTokens = estimateSystem(header.system);
|
|
663
669
|
if (header.config && typeof header.config.model === "string") s.model = header.config.model;
|
|
@@ -812,7 +818,6 @@ function buildTimelineView(state, bounds) {
|
|
|
812
818
|
tool: state.sums.tool,
|
|
813
819
|
total: surfaceTotal + state.systemTokens + state.toolsTokens
|
|
814
820
|
},
|
|
815
|
-
toolList: state.toolList,
|
|
816
821
|
images: state.surface.reduce((n, node) => n + (node.imgs ?? 0), 0),
|
|
817
822
|
toolCalls: state.surface.reduce((n, node) => node.cat === "tool" ? n + 1 : n, 0),
|
|
818
823
|
requests: state.requests.map((r) => ({ ...r })),
|
|
@@ -971,10 +976,6 @@ const contextTimelineSchema = z.object({
|
|
|
971
976
|
provider: z.string().optional(),
|
|
972
977
|
contextWindow: z.number().optional(),
|
|
973
978
|
current: currentSchema,
|
|
974
|
-
toolList: z.array(z.object({
|
|
975
|
-
name: z.string(),
|
|
976
|
-
tokens: z.number().int().nonnegative()
|
|
977
|
-
}).strict()),
|
|
978
979
|
images: z.number().int().nonnegative().optional(),
|
|
979
980
|
toolCalls: z.number().int().nonnegative().optional(),
|
|
980
981
|
requests: z.array(requestRecordSchema),
|
|
@@ -1005,10 +1006,6 @@ const timelineStateSchema = z.object({
|
|
|
1005
1006
|
}).strict(),
|
|
1006
1007
|
systemTokens: z.number().int().nonnegative(),
|
|
1007
1008
|
toolsTokens: z.number().int().nonnegative(),
|
|
1008
|
-
toolList: z.array(z.object({
|
|
1009
|
-
name: z.string(),
|
|
1010
|
-
tokens: z.number().int().nonnegative()
|
|
1011
|
-
}).strict()),
|
|
1012
1009
|
model: z.string().optional(),
|
|
1013
1010
|
provider: z.string().optional(),
|
|
1014
1011
|
lastModel: z.string().optional(),
|
|
@@ -1056,7 +1053,7 @@ function createContextTimelineDefinition(config) {
|
|
|
1056
1053
|
},
|
|
1057
1054
|
init: () => createTimelineState(),
|
|
1058
1055
|
apply: (state, event) => applyTimeline(state, event, bounds),
|
|
1059
|
-
stateVersion:
|
|
1056
|
+
stateVersion: 10
|
|
1060
1057
|
};
|
|
1061
1058
|
}
|
|
1062
1059
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-context",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"description": "A DeepSeek Harness plugin for context insight and management, with context dashboard and context command, for understanding how the context is made of, and how it evolves.",
|
|
5
5
|
"author": "bowenliang123",
|
|
6
6
|
"repository": {
|
|
@@ -36,8 +36,10 @@
|
|
|
36
36
|
"lint:fix": "oxlint --fix",
|
|
37
37
|
"watch": "tsdown --watch",
|
|
38
38
|
"register": "bash scripts/register.sh",
|
|
39
|
-
"typecheck": "tsc --noEmit",
|
|
40
|
-
"test": "
|
|
39
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.tests.json",
|
|
40
|
+
"test": "pnpm run typecheck && vitest run --coverage",
|
|
41
|
+
"test:bundle": "node scripts/bundle-smoke.mjs",
|
|
42
|
+
"coverage": "vitest run --coverage",
|
|
41
43
|
"release": "bash scripts/publish.sh",
|
|
42
44
|
"hooks": "bash scripts/install-hooks.sh",
|
|
43
45
|
"social-preview": "node docs/social-preview/generate.ts"
|
|
@@ -92,7 +94,10 @@
|
|
|
92
94
|
"@deepseek-ai/dsh-settings": "^0.1.0-rc.7",
|
|
93
95
|
"@deepseek-ai/schemastery": "^3.18.1",
|
|
94
96
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
97
|
+
"@types/node": "^26.2.0",
|
|
95
98
|
"@types/react": "^18.3.31",
|
|
99
|
+
"@types/react-dom": "^19.2.4",
|
|
100
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
96
101
|
"eslint-plugin-sonarjs": "^4.2.0",
|
|
97
102
|
"jsdom": "^30.0.1",
|
|
98
103
|
"lightningcss": "^1.33.0",
|