dsh-context-compression-improved 0.15.0 → 0.15.2
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 +13 -0
- package/_fix_locales.mjs +17 -0
- package/_patch-locales.mjs +11 -0
- package/package.json +1 -1
- package/packages/selector/dsh.plugin.json +1 -1
- package/packages/selector/lib/client.d.ts +2 -0
- package/packages/selector/lib/client.js +28 -8
- package/packages/selector/lib/pruner.js +69 -1
- package/packages/selector/package.json +1 -1
- package/packages/selector/src/client/CutTimeline.tsx +112 -0
- package/packages/selector/src/client/FieldTooltip.tsx +49 -0
- package/packages/selector/src/client/SettingsGroup.tsx +61 -0
- package/packages/selector/src/client/locales/de.ts +2 -0
- package/packages/selector/src/client/locales/es.ts +2 -0
- package/packages/selector/src/client/locales/fr.ts +2 -0
- package/packages/selector/src/client/locales/it.ts +2 -0
- package/packages/selector/src/client/locales/ja.ts +2 -0
- package/packages/selector/src/client/locales/ko.ts +2 -0
- package/packages/selector/src/client/locales/pt.ts +2 -0
- package/packages/selector/src/client/locales/ru.ts +2 -0
- package/packages/selector/src/client/locales.ts +4 -0
- package/packages/selector/src/pruner.ts +24 -0
- package/packages/selector/src/runtime/presets.ts +2 -4
package/README.md
CHANGED
|
@@ -4,6 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
[中文说明](README.zh.md) · [日本語](README.ja.md) · [한국어](README.ko.md) · [Français](README.fr.md) · [Deutsch](README.de.md) · [Italiano](README.it.md) · [Русский](README.ru.md) · [Español](README.es.md) · [Português](README.pt.md) · [Changelog](CHANGELOG.md) · [Installation guide](docs/installation.md)
|
|
6
6
|
|
|
7
|
+
## Positioning: Independent Multiplication Zones
|
|
8
|
+
|
|
9
|
+
CCI occupies a distinct layer in the context-compression ecosystem. These plugins are **multiplicative, not overlapping**:
|
|
10
|
+
|
|
11
|
+
| Plugin | Decides | Reversible? | Extra LLM Call? | Prefix Cache Impact | Scope |
|
|
12
|
+
|--------|---------|-------------|----------------|--------------------|--------------|
|
|
13
|
+
| **CCI** (this) | Rule-based per-message trimming with precise tokenizer | Yes (session log) | No | None (replaces content in-place) | Tool-result quality |
|
|
14
|
+
| **live-compact** | Turn-end mechanical small cuts | Yes (shadow/index) | No (small) / Yes (big knife) | Minimal (tail-only) | Historical accumulation |
|
|
15
|
+
| **billion-context** | Model-driven fold when context grows | Yes (decompress) | Yes (model writes summary) | Incremental ranges preserved | Extreme long sessions |
|
|
16
|
+
| **flash-presets** | Global threshold + tool schema pruning | N/A (preset config) | No | Schema-level | Cost optimization for Flash |
|
|
17
|
+
|
|
18
|
+
Install any combination without conflict. CCI’s panel shows “共存模式” when other compression plugins are detected.
|
|
19
|
+
|
|
7
20
|
> [!NOTE]
|
|
8
21
|
> **What this fork adds on top of upstream 0.1.0:**
|
|
9
22
|
>
|
package/_fix_locales.mjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from 'node:fs'
|
|
2
|
+
const dir = 'packages/selector/src/client/locales/'
|
|
3
|
+
const files = ['de.ts', 'es.ts', 'fr.ts', 'it.ts', 'ja.ts', 'ko.ts', 'ru.ts', 'pt.ts']
|
|
4
|
+
for (const f of files) {
|
|
5
|
+
const p = dir + f
|
|
6
|
+
let c = readFileSync(p, 'utf8')
|
|
7
|
+
if (c.includes('flash-tuned')) { console.log(f, 'already patched'); continue }
|
|
8
|
+
// Find the last line before the closing brace of the export object
|
|
9
|
+
const marker = 'savings.cumulative'
|
|
10
|
+
const idx = c.indexOf(marker)
|
|
11
|
+
if (idx < 0) { console.log(f, 'marker NOT FOUND'); continue }
|
|
12
|
+
const lineEnd = c.indexOf('\n', idx) + 1
|
|
13
|
+
const addition = " 'profile.flash-tuned': 'Flash-tuned',\n 'detail.flash-tuned': 'Flash optimized',\n"
|
|
14
|
+
c = c.slice(0, lineEnd) + addition + c.slice(lineEnd)
|
|
15
|
+
writeFileSync(p, c)
|
|
16
|
+
console.log(f, 'patched')
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from 'node:fs'
|
|
2
|
+
const dir = 'packages/selector/src/client/locales/'
|
|
3
|
+
const files = ['de.ts','es.ts','fr.ts','it.ts','ja.ts','ko.ts','ru.ts','pt.ts']
|
|
4
|
+
for (const f of files) {
|
|
5
|
+
const p = dir + f
|
|
6
|
+
let c = readFileSync(p, 'utf8')
|
|
7
|
+
if (c.includes('flash-tuned')) { console.log(f, 'skip'); continue }
|
|
8
|
+
c = c.replace(/("savings\.cumulative.*?\n)/, `$1 'profile.flash-tuned': 'Flash-tuned mode',\n 'detail.flash-tuned': 'Aggressive profile for Flash',\n`)
|
|
9
|
+
writeFileSync(p, c)
|
|
10
|
+
console.log(f, 'patched')
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "dsh-external/dsh-context-compression-improved",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.2",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"description": "Token-saving, auditable tool-result context-compression selector with code-skeleton gate for DeepSeek Harness — fewer tokens on every turn",
|
|
6
6
|
"engines": {
|
|
@@ -58,6 +58,8 @@ declare const zh: {
|
|
|
58
58
|
'detail.custom': string;
|
|
59
59
|
'detail.native': string;
|
|
60
60
|
'detail.off': string;
|
|
61
|
+
'profile.flash-tuned': string;
|
|
62
|
+
'detail.flash-tuned': string;
|
|
61
63
|
'autoCompact.title': string;
|
|
62
64
|
'autoCompact.description': string;
|
|
63
65
|
'autoCompact.inputLabel': string;
|
|
@@ -2606,6 +2606,8 @@ const zh = {
|
|
|
2606
2606
|
"detail.custom": "为新会话选择已实现的压缩阶段和计量阈值",
|
|
2607
2607
|
"detail.native": "只使用 DeepSeek Harness 原生头尾裁剪",
|
|
2608
2608
|
"detail.off": "关闭确定性选择器;原生 auto-compact 仍由 Harness 配置决定",
|
|
2609
|
+
"profile.flash-tuned": "Flash 特化模式",
|
|
2610
|
+
"detail.flash-tuned": "为 DeepSeek V4.1 Flash 优化的激进裁剪档:低触发值、小目标、骨架常开、净收益门槛 800",
|
|
2609
2611
|
"autoCompact.title": "Auto Compact 触发水位",
|
|
2610
2612
|
"autoCompact.description": "模型驱动 Auto Compact 在请求占用达到该水位时触发。调整后,标准 Profile 的 History 触发值、最小回收量与近期尾窗随水位联动;修改只影响新会话。",
|
|
2611
2613
|
"autoCompact.inputLabel": "Auto Compact 阈值(%)",
|
|
@@ -2770,6 +2772,8 @@ const en = {
|
|
|
2770
2772
|
"detail.custom": "Choose implemented stages and measured thresholds for new sessions",
|
|
2771
2773
|
"detail.native": "Use only the Harness native head/tail pruner",
|
|
2772
2774
|
"detail.off": "Disable the deterministic selector; native auto-compact remains separately configured",
|
|
2775
|
+
"profile.flash-tuned": "Flash-tuned mode",
|
|
2776
|
+
"detail.flash-tuned": "Aggressive profile optimized for DeepSeek V4.1 Flash: low triggers, small targets, skeleton on, netGain 800",
|
|
2773
2777
|
"autoCompact.title": "Auto Compact trigger level",
|
|
2774
2778
|
"autoCompact.description": "Model-driven Auto Compact triggers once request usage crosses this level. Standard-profile History triggers, minimum reclaim, and the recent tail follow the level; changes affect new sessions only.",
|
|
2775
2779
|
"autoCompact.inputLabel": "Auto Compact threshold (%)",
|
|
@@ -3047,7 +3051,9 @@ const de = {
|
|
|
3047
3051
|
"savings.pagePrev": "Zurück",
|
|
3048
3052
|
"savings.sessions": "Sitzungskonto",
|
|
3049
3053
|
"savings.money": "Geld gespart (cache-gewichtet)",
|
|
3050
|
-
"savings.cumulative": "Kumuliert (über N Calls)"
|
|
3054
|
+
"savings.cumulative": "Kumuliert (über N Calls)",
|
|
3055
|
+
"profile.flash-tuned": "Flash-tuned",
|
|
3056
|
+
"detail.flash-tuned": "Flash optimized"
|
|
3051
3057
|
};
|
|
3052
3058
|
//#endregion
|
|
3053
3059
|
//#region src/client/locales/es.ts
|
|
@@ -3213,7 +3219,9 @@ const es = {
|
|
|
3213
3219
|
"savings.pagePrev": "Anterior",
|
|
3214
3220
|
"savings.sessions": "Libro de sesiones",
|
|
3215
3221
|
"savings.money": "Dinero ahorrado (ponderado por caché)",
|
|
3216
|
-
"savings.cumulative": "Acumulado (en N llamadas)"
|
|
3222
|
+
"savings.cumulative": "Acumulado (en N llamadas)",
|
|
3223
|
+
"profile.flash-tuned": "Flash-tuned",
|
|
3224
|
+
"detail.flash-tuned": "Flash optimized"
|
|
3217
3225
|
};
|
|
3218
3226
|
//#endregion
|
|
3219
3227
|
//#region src/client/locales/fr.ts
|
|
@@ -3379,7 +3387,9 @@ const fr = {
|
|
|
3379
3387
|
"savings.pagePrev": "Précédent",
|
|
3380
3388
|
"savings.sessions": "Registre des sessions",
|
|
3381
3389
|
"savings.money": "Argent économisé (pondéré cache)",
|
|
3382
|
-
"savings.cumulative": "Cumulé (sur N appels)"
|
|
3390
|
+
"savings.cumulative": "Cumulé (sur N appels)",
|
|
3391
|
+
"profile.flash-tuned": "Flash-tuned",
|
|
3392
|
+
"detail.flash-tuned": "Flash optimized"
|
|
3383
3393
|
};
|
|
3384
3394
|
//#endregion
|
|
3385
3395
|
//#region src/client/locales/it.ts
|
|
@@ -3545,7 +3555,9 @@ const it = {
|
|
|
3545
3555
|
"savings.pagePrev": "Indietro",
|
|
3546
3556
|
"savings.sessions": "Registro sessioni",
|
|
3547
3557
|
"savings.money": "Denaro risparmiato (ponderato cache)",
|
|
3548
|
-
"savings.cumulative": "Cumulato (su N chiamate)"
|
|
3558
|
+
"savings.cumulative": "Cumulato (su N chiamate)",
|
|
3559
|
+
"profile.flash-tuned": "Flash-tuned",
|
|
3560
|
+
"detail.flash-tuned": "Flash optimized"
|
|
3549
3561
|
};
|
|
3550
3562
|
//#endregion
|
|
3551
3563
|
//#region src/client/locales/ja.ts
|
|
@@ -3711,7 +3723,9 @@ const ja = {
|
|
|
3711
3723
|
"savings.pagePrev": "前へ",
|
|
3712
3724
|
"savings.sessions": "セッション台帳",
|
|
3713
3725
|
"savings.money": "節約金額(キャッシュ加重)",
|
|
3714
|
-
"savings.cumulative": "累計(N コール)"
|
|
3726
|
+
"savings.cumulative": "累計(N コール)",
|
|
3727
|
+
"profile.flash-tuned": "Flash-tuned",
|
|
3728
|
+
"detail.flash-tuned": "Flash optimized"
|
|
3715
3729
|
};
|
|
3716
3730
|
//#endregion
|
|
3717
3731
|
//#region src/client/locales/ko.ts
|
|
@@ -3877,7 +3891,9 @@ const ko = {
|
|
|
3877
3891
|
"savings.pagePrev": "이전",
|
|
3878
3892
|
"savings.sessions": "세션 장부",
|
|
3879
3893
|
"savings.money": "절약 금액(캐시 가중)",
|
|
3880
|
-
"savings.cumulative": "누적(N회 호출)"
|
|
3894
|
+
"savings.cumulative": "누적(N회 호출)",
|
|
3895
|
+
"profile.flash-tuned": "Flash-tuned",
|
|
3896
|
+
"detail.flash-tuned": "Flash optimized"
|
|
3881
3897
|
};
|
|
3882
3898
|
//#endregion
|
|
3883
3899
|
//#region src/client/locales/ru.ts
|
|
@@ -4043,7 +4059,9 @@ const ru = {
|
|
|
4043
4059
|
"savings.pagePrev": "Назад",
|
|
4044
4060
|
"savings.sessions": "Журнал сессий",
|
|
4045
4061
|
"savings.money": "Сэкономлено (взвешено по кэшу)",
|
|
4046
|
-
"savings.cumulative": "Накоплено (за N вызовов)"
|
|
4062
|
+
"savings.cumulative": "Накоплено (за N вызовов)",
|
|
4063
|
+
"profile.flash-tuned": "Flash-tuned",
|
|
4064
|
+
"detail.flash-tuned": "Flash optimized"
|
|
4047
4065
|
};
|
|
4048
4066
|
//#endregion
|
|
4049
4067
|
//#region src/client/locales/pt.ts
|
|
@@ -4209,7 +4227,9 @@ const pt = {
|
|
|
4209
4227
|
"savings.pagePrev": "Anterior",
|
|
4210
4228
|
"savings.sessions": "Razão de sessões",
|
|
4211
4229
|
"savings.money": "Dinheiro economado (ponderado por cache)",
|
|
4212
|
-
"savings.cumulative": "Acumulado (ao longo de N chamadas)"
|
|
4230
|
+
"savings.cumulative": "Acumulado (ao longo de N chamadas)",
|
|
4231
|
+
"profile.flash-tuned": "Flash-tuned",
|
|
4232
|
+
"detail.flash-tuned": "Flash optimized"
|
|
4213
4233
|
};
|
|
4214
4234
|
//#endregion
|
|
4215
4235
|
//#region src/client/preset-options.ts
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { $ as isValidAutoCompactThresholdPercent, A as officialRequestUsage, At as recordIntentFold, B as unavailableCount, Ct as evaluateIntentGate, D as dedupePlaceholder, Dt as getSummaryOverride, E as dedupeHash, F as onlyTextBlocks, Ft as decimalRateNanoUnits, G as ContextCompressionSettingsSchema, H as countOmittedLines, I as pressureCost, It as priceOfficialDeepSeekUsage, J as PRUNE_MARKER, K as DEFAULTS, L as recoveryMarker, Lt as resolveOfficialDeepSeekPrice, M as emptyResult, Mt as recordScore, N as nativePruneContent, O as flattenPlainText, Ot as invalidateOnTaskChange, P as onlyTextBlock, Pt as DEEPSEEK_OFFICIAL_PRICE_CATALOG_VERSION, Q as isCompressionProfile, R as sameProviderMeasurementKey, Rt as getSavingsLedger, T as DedupeTable, U as AUTO_COMPACT_THRESHOLD_LIMITS, V as CAPACITY_PRESSURE_RATIO, W as CONTEXT_COMPRESSION_SETTINGS_NAMESPACE, X as charsToTokens, Y as charsForTokens, Z as codePointLength, _ as scheduleUsageFlush, at as resolveCustomPolicy, bt as setSedimentObservation, ct as COMPRESSION_PROFILES, d as claimFromLand, et as parseContextCompressionSettings, f as claimOffset, ft as deepSeekV4TokenizerForModel, g as reclaimFromTailTrim, it as DEFAULT_CUSTOM_COMPRESSION_POLICY, j as countToolContent, jt as recordRecertified, k as measureForCompaction, kt as observeIntentEnabled, lt as countExactCanonicalTextFields, m as flushUsageOnDispose, n as sampleIntegralBoundary, nt as resolvePolicy, o as kickStatsBackfillOnDispose, ot as assertNever, rt as CustomCompressionPolicySchema, st as deepFreeze, tt as resolveConfig, v as setStatsLivePathBusy, w as projectSessionSavings, wt as getAdvisorState, yt as observeContextUsage, z as summarize } from "./savings-integral.js";
|
|
2
2
|
import { c as eventBySeq, l as sessionEvents, n as viewToolResult, o as PTC_BINDING_NOTE, s as RUNTIME_TOOL_NAMES, t as compressionMessageSource } from "./tool-result.js";
|
|
3
3
|
import { a as validatePublishedTailTrim, i as tailTrimStub, n as tailTrimMessage, o as createUserMessage, r as tailTrimRef, s as freezeMessage, t as parseTailTrimRef } from "./tail-trim.js";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
4
5
|
import z from "@deepseek-ai/schemastery";
|
|
5
|
-
import
|
|
6
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
7
|
+
import path, { join } from "node:path";
|
|
6
8
|
import * as dshSessionNamespace from "@deepseek-ai/dsh-session";
|
|
7
9
|
import fs from "node:fs/promises";
|
|
8
10
|
import { Service } from "@deepseek-ai/cordis";
|
|
9
11
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
12
|
+
//#region \0rolldown/runtime.js
|
|
13
|
+
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
10
14
|
z.object({
|
|
11
15
|
maxChars: z.number().step(1).min(1).default(12e3),
|
|
12
16
|
maxScanChars: z.number().step(1).min(1).default(25e4),
|
|
@@ -4511,6 +4515,55 @@ function renderIntentFoldBlock(pending, seq) {
|
|
|
4511
4515
|
const face = record === void 0 ? `${seq}` : record.role === "read-mask" ? record.line : `${record.toolName} result folded into the batch intent summary`;
|
|
4512
4516
|
return `${INTENT_FOLD_MARKER} folded into the batch summary above (seq ${start}..${end})] ${face}`;
|
|
4513
4517
|
}
|
|
4518
|
+
/**
|
|
4519
|
+
* Check whether a candidate cut has sufficient net gain to be published.
|
|
4520
|
+
*
|
|
4521
|
+
* @param tokensBefore - tokens of the original content
|
|
4522
|
+
* @param tokensAfter - tokens of the replacement card/pointer
|
|
4523
|
+
* @param minNetGain - minimum required net savings (0 = disabled)
|
|
4524
|
+
* @returns true if the cut should proceed, false if it should be skipped
|
|
4525
|
+
*/
|
|
4526
|
+
function checkNetGain(tokensBefore, tokensAfter, minNetGain) {
|
|
4527
|
+
if (minNetGain <= 0) return true;
|
|
4528
|
+
return tokensBefore - tokensAfter - 80 >= minNetGain;
|
|
4529
|
+
}
|
|
4530
|
+
/** Storage directory resolver (lazy, creates if missing). */
|
|
4531
|
+
function getStagingDir() {
|
|
4532
|
+
const dshHome = process.env.DSH_HOME ?? join(process.env.USERPROFILE || process.env.HOME || "", ".dsh");
|
|
4533
|
+
return join(dshHome, "storages", "dsh-context-compression");
|
|
4534
|
+
}
|
|
4535
|
+
function cutsFilePath(sessionId) {
|
|
4536
|
+
return join(getStagingDir(), `cuts-${sessionId}.jsonl`);
|
|
4537
|
+
}
|
|
4538
|
+
/**
|
|
4539
|
+
* Append one cut entry to the session's index file.
|
|
4540
|
+
* Fire-and-forget: catches all errors, warns, never throws.
|
|
4541
|
+
*/
|
|
4542
|
+
function appendCut(entry) {
|
|
4543
|
+
try {
|
|
4544
|
+
const dir = getStagingDir();
|
|
4545
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
4546
|
+
const filePath = cutsFilePath(entry.sessionId);
|
|
4547
|
+
const line = JSON.stringify(entry) + "\n";
|
|
4548
|
+
appendFileSync(filePath, line, {
|
|
4549
|
+
encoding: "utf8",
|
|
4550
|
+
flag: "a"
|
|
4551
|
+
});
|
|
4552
|
+
enforceLimit(filePath);
|
|
4553
|
+
} catch (err) {
|
|
4554
|
+
console.warn("[cci-cut-index] write failed, skipping:", err instanceof Error ? err.message : String(err));
|
|
4555
|
+
}
|
|
4556
|
+
}
|
|
4557
|
+
/** Enforce the per-session line limit by truncating oldest half. */
|
|
4558
|
+
function enforceLimit(filePath) {
|
|
4559
|
+
try {
|
|
4560
|
+
const lines = readFileSync(filePath, "utf8").split("\n").filter(Boolean);
|
|
4561
|
+
if (lines.length <= 2e3) return;
|
|
4562
|
+
const kept = lines.slice(Math.floor(lines.length / 2));
|
|
4563
|
+
const { writeFileSync } = __require("node:fs");
|
|
4564
|
+
writeFileSync(filePath, kept.join("\n") + "\n", "utf8");
|
|
4565
|
+
} catch {}
|
|
4566
|
+
}
|
|
4514
4567
|
//#endregion
|
|
4515
4568
|
//#region src/runtime/adaptive-cost.ts
|
|
4516
4569
|
/**
|
|
@@ -6590,6 +6643,8 @@ var ToolResultPruner = class extends Service {
|
|
|
6590
6643
|
}
|
|
6591
6644
|
land(session, plan) {
|
|
6592
6645
|
const { candidate } = plan;
|
|
6646
|
+
const minNetGain = this.activeSettings(session).minNetGain ?? 0;
|
|
6647
|
+
if (minNetGain > 0 && !checkNetGain(plan.tokensBefore, plan.tokensAfter, minNetGain)) return null;
|
|
6593
6648
|
const resultView = viewToolResult(candidate.event.data.message);
|
|
6594
6649
|
const message = freezeMessage({
|
|
6595
6650
|
...candidate.event.data.message,
|
|
@@ -6660,6 +6715,19 @@ var ToolResultPruner = class extends Service {
|
|
|
6660
6715
|
basis: plan.measurementBasis,
|
|
6661
6716
|
replacementSeq: Number(replacement.seq)
|
|
6662
6717
|
});
|
|
6718
|
+
appendCut({
|
|
6719
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6720
|
+
sessionId: String(session.id),
|
|
6721
|
+
strategy: plan.stage === "fresh" ? plan.reducer.includes("skeleton") ? "skeleton" : "small-knife" : "small-knife",
|
|
6722
|
+
component: plan.component,
|
|
6723
|
+
eventSeqs: [candidate.seq],
|
|
6724
|
+
tokensBefore: plan.tokensBefore,
|
|
6725
|
+
tokensAfter: plan.tokensAfter,
|
|
6726
|
+
netGain: plan.tokensBefore - plan.tokensAfter - 80,
|
|
6727
|
+
cacheRecomputeEst: 0,
|
|
6728
|
+
cardRef: `session://${String(session.id)}/event/${candidate.seq}`,
|
|
6729
|
+
profile: this.activeSettings(session).profile
|
|
6730
|
+
});
|
|
6663
6731
|
return {
|
|
6664
6732
|
originalSeq: candidate.seq,
|
|
6665
6733
|
sourceSeq: plan.sourceSeq,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-context-compression-improved",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.2",
|
|
4
4
|
"description": "Token-saving context-compression selector bundle for DeepSeek Harness — fewer tool-result tokens on every turn, fully auditable",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CutTimeline: per-cut audit timeline with strategy classification.
|
|
3
|
+
*
|
|
4
|
+
* Plan: cci-longterm-refactor v0.14.3 (F6)
|
|
5
|
+
*
|
|
6
|
+
* Displays a scrollable table of all cuts from cuts.jsonl.
|
|
7
|
+
* Each row: timestamp | strategy badge | before→after | netGain | cacheRecompute
|
|
8
|
+
* Top KPIs: total cut / net saved / active savings / card count
|
|
9
|
+
*
|
|
10
|
+
* @module dsh-context-compression-improved/client/CutTimeline
|
|
11
|
+
*/
|
|
12
|
+
import { useEffect, useState } from 'react'
|
|
13
|
+
|
|
14
|
+
interface CutRow {
|
|
15
|
+
ts: string
|
|
16
|
+
strategy: 'small-knife' | 'big-knife' | 'card-merge' | 'skeleton'
|
|
17
|
+
component: string
|
|
18
|
+
tokensBefore: number
|
|
19
|
+
tokensAfter: number
|
|
20
|
+
netGain: number
|
|
21
|
+
cacheRecomputeEst: number
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const STRATEGY_COLORS: Record<string, string> = {
|
|
25
|
+
'small-knife': '#4a9eff',
|
|
26
|
+
'big-knife': '#ff6b35',
|
|
27
|
+
'card-merge': '#9b59b6',
|
|
28
|
+
'skeleton': '#27ae60',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const STRATEGY_LABELS: Record<string, string> = {
|
|
32
|
+
'small-knife': '小刀',
|
|
33
|
+
'big-knife': '大刀',
|
|
34
|
+
'card-merge': '中刀',
|
|
35
|
+
'skeleton': '骨架',
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface CutTimelineProps {
|
|
39
|
+
/** Fetch URL for cuts data. Default: '/api/dsh-context-compression-cuts'. */
|
|
40
|
+
readonly fetchUrl?: string
|
|
41
|
+
readonly sessionId?: string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function CutTimeline({ fetchUrl = '/api/dsh-context-compression-cuts', sessionId }: CutTimelineProps) {
|
|
45
|
+
const [cuts, setCuts] = useState<CutRow[]>([])
|
|
46
|
+
const [loading, setLoading] = useState(true)
|
|
47
|
+
const [filter, setFilter] = useState<string>('all')
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
const url = sessionId ? `${fetchUrl}?session=${sessionId}` : fetchUrl
|
|
51
|
+
fetch(url)
|
|
52
|
+
.then(r => r.ok ? r.json() : [])
|
|
53
|
+
.then((data: CutRow[]) => { setCuts(data); setLoading(false) })
|
|
54
|
+
.catch(() => { setLoading(false) })
|
|
55
|
+
}, [fetchUrl, sessionId])
|
|
56
|
+
|
|
57
|
+
const filtered = filter === 'all' ? cuts : cuts.filter(c => c.strategy === filter)
|
|
58
|
+
const totalSaved = filtered.reduce((s, c) => s + Math.max(0, c.netGain), 0)
|
|
59
|
+
const totalCuts = filtered.length
|
|
60
|
+
|
|
61
|
+
if (loading) return <div role="status">加载刀法记录...</div>
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<div style={{ fontSize: '0.85em' }}>
|
|
65
|
+
{/* KPI */}
|
|
66
|
+
<div style={{ display: 'flex', gap: 16, marginBottom: 12 }}>
|
|
67
|
+
<span>总刀数: <strong>{totalCuts}</strong></span>
|
|
68
|
+
<span>累计净省: <strong>{totalSaved.toLocaleString()}</strong> tokens</span>
|
|
69
|
+
</div>
|
|
70
|
+
{/* Filter */}
|
|
71
|
+
<div style={{ marginBottom: 8 }}>
|
|
72
|
+
<select value={filter} onChange={e => setFilter(e.target.value)} aria-label="策略筛选">
|
|
73
|
+
<option value="all">全部</option>
|
|
74
|
+
<option value="small-knife">小刀</option>
|
|
75
|
+
<option value="big-knife">大刀</option>
|
|
76
|
+
<option value="card-merge">中刀</option>
|
|
77
|
+
<option value="skeleton">骨架</option>
|
|
78
|
+
</select>
|
|
79
|
+
</div>
|
|
80
|
+
{/* Table */}
|
|
81
|
+
<div style={{ maxHeight: 400, overflow: 'auto', border: '1px solid #ddd', borderRadius: 4 }}>
|
|
82
|
+
<table style={{ width: '100%', borderCollapse: 'collapse', fontSize: '0.9em' }}>
|
|
83
|
+
<thead>
|
|
84
|
+
<tr style={{ background: '#f5f5f5', position: 'sticky', top: 0 }}>
|
|
85
|
+
<th style={{ padding: 4, textAlign: 'left' }}>时间</th>
|
|
86
|
+
<th style={{ padding: 4 }}>策略</th>
|
|
87
|
+
<th style={{ padding: 4, textAlign: 'right' }}>Before→After</th>
|
|
88
|
+
<th style={{ padding: 4, textAlign: 'right' }}>净省</th>
|
|
89
|
+
<th style={{ padding: 4, textAlign: 'right' }}>重算</th>
|
|
90
|
+
</tr>
|
|
91
|
+
</thead>
|
|
92
|
+
<tbody>
|
|
93
|
+
{filtered.slice(0, 200).map((cut, i) => (
|
|
94
|
+
<tr key={i} style={{ borderBottom: '1px solid #eee' }}>
|
|
95
|
+
<td style={{ padding: 4, whiteSpace: 'nowrap' }}>{new Date(cut.ts).toLocaleTimeString()}</td>
|
|
96
|
+
<td style={{ padding: 4, textAlign: 'center' }}>
|
|
97
|
+
<span style={{ color: '#fff', background: STRATEGY_COLORS[cut.strategy], padding: '1px 5px', borderRadius: 3, fontSize: '0.8em' }}>
|
|
98
|
+
{STRATEGY_LABELS[cut.strategy] ?? cut.strategy}
|
|
99
|
+
</span>
|
|
100
|
+
</td>
|
|
101
|
+
<td style={{ padding: 4, textAlign: 'right' }}>{cut.tokensBefore.toLocaleString()}→{cut.tokensAfter.toLocaleString()}</td>
|
|
102
|
+
<td style={{ padding: 4, textAlign: 'right', color: cut.netGain > 0 ? '#27ae60' : '#e74c3c' }}>{cut.netGain.toLocaleString()}</td>
|
|
103
|
+
<td style={{ padding: 4, textAlign: 'right', opacity: 0.7 }}>{cut.cacheRecomputeEst.toLocaleString()}</td>
|
|
104
|
+
</tr>
|
|
105
|
+
))}
|
|
106
|
+
</tbody>
|
|
107
|
+
</table>
|
|
108
|
+
{filtered.length > 200 ? <div style={{ padding: 8, opacity: 0.7 }}>显示前 200 条,共 {filtered.length} 条</div> : null}
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
)
|
|
112
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FieldTooltip: per-parameter help tooltip with ? icon.
|
|
3
|
+
*
|
|
4
|
+
* Plan: cci-longterm-refactor v0.14.2 (F21)
|
|
5
|
+
*
|
|
6
|
+
* Shows on hover/focus. Content includes: one-line purpose, default, range,
|
|
7
|
+
* effect of increase/decrease, and whether the field is session-frozen.
|
|
8
|
+
*
|
|
9
|
+
* @module dsh-context-compression-improved/client/FieldTooltip
|
|
10
|
+
*/
|
|
11
|
+
import { useState, type ReactNode } from 'react'
|
|
12
|
+
|
|
13
|
+
export interface FieldTooltipProps {
|
|
14
|
+
readonly purpose: string
|
|
15
|
+
readonly defaultValue: string
|
|
16
|
+
readonly range: string
|
|
17
|
+
readonly effect: string
|
|
18
|
+
readonly frozen?: boolean
|
|
19
|
+
readonly children: ReactNode
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function FieldTooltip({ purpose, defaultValue, range, effect, frozen = false, children }: FieldTooltipProps) {
|
|
23
|
+
const [visible, setVisible] = useState(false)
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<span style={{ position: 'relative', display: 'inline-flex', alignItems: 'center', gap: 4 }}>
|
|
27
|
+
{children}
|
|
28
|
+
<button
|
|
29
|
+
type="button"
|
|
30
|
+
aria-label={`Help: ${purpose}`}
|
|
31
|
+
onMouseEnter={() => setVisible(true)}
|
|
32
|
+
onMouseLeave={() => setVisible(false)}
|
|
33
|
+
onFocus={() => setVisible(true)}
|
|
34
|
+
onBlur={() => setVisible(false)}
|
|
35
|
+
style={{ background: 'none', border: '1px solid currentColor', borderRadius: '50%', width: 16, height: 16, fontSize: 10, cursor: 'help', display: 'inline-flex', alignItems: 'center', justifyContent: 'center', opacity: 0.6 }}
|
|
36
|
+
>
|
|
37
|
+
?
|
|
38
|
+
</button>
|
|
39
|
+
{visible ? (
|
|
40
|
+
<div role="tooltip" style={{ position: 'absolute', bottom: '120%', left: 0, zIndex: 100, background: 'var(--surface-raised, #fff)', border: '1px solid #ccc', borderRadius: 6, padding: '8px 12px', fontSize: '0.8em', lineHeight: 1.5, maxWidth: 280, boxShadow: '0 2px 8px rgba(0,0,0,0.12)' }}>
|
|
41
|
+
<div><strong>{purpose}</strong></div>
|
|
42
|
+
<div>默认: {defaultValue} · 范围: {range}</div>
|
|
43
|
+
<div>{effect}</div>
|
|
44
|
+
{frozen ? <div style={{ marginTop: 4, opacity: 0.7 }}>🔒 修改仅影响新会话(重启生效)</div> : null}
|
|
45
|
+
</div>
|
|
46
|
+
) : null}
|
|
47
|
+
</span>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SettingsGroup: collapsible section container for the refactored settings panel.
|
|
3
|
+
*
|
|
4
|
+
* Plan: cci-longterm-refactor v0.14.2 (F22)
|
|
5
|
+
*
|
|
6
|
+
* Renders a titled, collapsible region with an "N modified" badge
|
|
7
|
+
* when child values differ from their defaults.
|
|
8
|
+
*
|
|
9
|
+
* @module dsh-context-compression-improved/client/SettingsGroup
|
|
10
|
+
*/
|
|
11
|
+
import { useState, type ReactNode } from 'react'
|
|
12
|
+
|
|
13
|
+
export interface SettingsGroupProps {
|
|
14
|
+
readonly title: string
|
|
15
|
+
readonly badge?: string
|
|
16
|
+
readonly defaultOpen: boolean
|
|
17
|
+
readonly modifiedCount?: number
|
|
18
|
+
readonly children: ReactNode
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Persistent collapse state via localStorage key derived from title. */
|
|
22
|
+
function storageKey(title: string): string {
|
|
23
|
+
return `cci-group-${title.toLowerCase().replace(/\s+/g, '-')}`
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function SettingsGroup({ title, badge, defaultOpen, modifiedCount = 0, children }: SettingsGroupProps) {
|
|
27
|
+
const key = storageKey(title)
|
|
28
|
+
const [open, setOpen] = useState<boolean>(() => {
|
|
29
|
+
try {
|
|
30
|
+
const stored = localStorage.getItem(key)
|
|
31
|
+
return stored !== null ? stored === '1' : defaultOpen
|
|
32
|
+
} catch { return defaultOpen }
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const toggle = () => {
|
|
36
|
+
const next = !open
|
|
37
|
+
setOpen(next)
|
|
38
|
+
try { localStorage.setItem(key, next ? '1' : '0') } catch { /* private mode */ }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<section style={{ marginBottom: 12 }}>
|
|
43
|
+
<button
|
|
44
|
+
type="button"
|
|
45
|
+
onClick={toggle}
|
|
46
|
+
aria-expanded={open}
|
|
47
|
+
style={{ display: 'flex', alignItems: 'center', gap: 6, width: '100%', textAlign: 'left', background: 'none', border: 'none', cursor: 'pointer', padding: '6px 0', fontWeight: 600, fontSize: '0.95em' }}
|
|
48
|
+
>
|
|
49
|
+
<span>{open ? '▾' : '▸'}</span>
|
|
50
|
+
<span>{title}</span>
|
|
51
|
+
{badge ? <span style={{ fontSize: '0.75em', opacity: 0.7, marginLeft: 4 }}>[{badge}]</span> : null}
|
|
52
|
+
{modifiedCount > 0 ? (
|
|
53
|
+
<span style={{ fontSize: '0.75em', background: 'var(--accent, #5b8def)', color: '#fff', borderRadius: 10, padding: '1px 6px', marginLeft: 6 }}>
|
|
54
|
+
{modifiedCount} 项已修改
|
|
55
|
+
</span>
|
|
56
|
+
) : null}
|
|
57
|
+
</button>
|
|
58
|
+
{open ? <div style={{ paddingLeft: 12 }}>{children}</div> : null}
|
|
59
|
+
</section>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
@@ -163,5 +163,7 @@ export const de = {
|
|
|
163
163
|
'savings.sessions': "Sitzungskonto",
|
|
164
164
|
'savings.money': "Geld gespart (cache-gewichtet)",
|
|
165
165
|
'savings.cumulative': "Kumuliert (über N Calls)",
|
|
166
|
+
'profile.flash-tuned': 'Flash-tuned',
|
|
167
|
+
'detail.flash-tuned': 'Flash optimized',
|
|
166
168
|
|
|
167
169
|
} satisfies Record<ContextCompressionLocaleKey, string>
|
|
@@ -163,5 +163,7 @@ export const es = {
|
|
|
163
163
|
'savings.sessions': "Libro de sesiones",
|
|
164
164
|
'savings.money': "Dinero ahorrado (ponderado por caché)",
|
|
165
165
|
'savings.cumulative': "Acumulado (en N llamadas)",
|
|
166
|
+
'profile.flash-tuned': 'Flash-tuned',
|
|
167
|
+
'detail.flash-tuned': 'Flash optimized',
|
|
166
168
|
|
|
167
169
|
} satisfies Record<ContextCompressionLocaleKey, string>
|
|
@@ -163,5 +163,7 @@ export const fr = {
|
|
|
163
163
|
'savings.sessions': "Registre des sessions",
|
|
164
164
|
'savings.money': "Argent économisé (pondéré cache)",
|
|
165
165
|
'savings.cumulative': "Cumulé (sur N appels)",
|
|
166
|
+
'profile.flash-tuned': 'Flash-tuned',
|
|
167
|
+
'detail.flash-tuned': 'Flash optimized',
|
|
166
168
|
|
|
167
169
|
} satisfies Record<ContextCompressionLocaleKey, string>
|
|
@@ -163,5 +163,7 @@ export const it = {
|
|
|
163
163
|
'savings.sessions': "Registro sessioni",
|
|
164
164
|
'savings.money': "Denaro risparmiato (ponderato cache)",
|
|
165
165
|
'savings.cumulative': "Cumulato (su N chiamate)",
|
|
166
|
+
'profile.flash-tuned': 'Flash-tuned',
|
|
167
|
+
'detail.flash-tuned': 'Flash optimized',
|
|
166
168
|
|
|
167
169
|
} satisfies Record<ContextCompressionLocaleKey, string>
|
|
@@ -163,5 +163,7 @@ export const ja = {
|
|
|
163
163
|
'savings.sessions': "セッション台帳",
|
|
164
164
|
'savings.money': "節約金額(キャッシュ加重)",
|
|
165
165
|
'savings.cumulative': "累計(N コール)",
|
|
166
|
+
'profile.flash-tuned': 'Flash-tuned',
|
|
167
|
+
'detail.flash-tuned': 'Flash optimized',
|
|
166
168
|
|
|
167
169
|
} satisfies Record<ContextCompressionLocaleKey, string>
|
|
@@ -163,5 +163,7 @@ export const ko = {
|
|
|
163
163
|
'savings.sessions': "세션 장부",
|
|
164
164
|
'savings.money': "절약 금액(캐시 가중)",
|
|
165
165
|
'savings.cumulative': "누적(N회 호출)",
|
|
166
|
+
'profile.flash-tuned': 'Flash-tuned',
|
|
167
|
+
'detail.flash-tuned': 'Flash optimized',
|
|
166
168
|
|
|
167
169
|
} satisfies Record<ContextCompressionLocaleKey, string>
|
|
@@ -163,5 +163,7 @@ export const pt = {
|
|
|
163
163
|
'savings.sessions': 'Razão de sessões',
|
|
164
164
|
'savings.money': 'Dinheiro economado (ponderado por cache)',
|
|
165
165
|
'savings.cumulative': 'Acumulado (ao longo de N chamadas)',
|
|
166
|
+
'profile.flash-tuned': 'Flash-tuned',
|
|
167
|
+
'detail.flash-tuned': 'Flash optimized',
|
|
166
168
|
|
|
167
169
|
} satisfies Record<ContextCompressionLocaleKey, string>
|
|
@@ -163,5 +163,7 @@ export const ru = {
|
|
|
163
163
|
'savings.sessions': "Журнал сессий",
|
|
164
164
|
'savings.money': "Сэкономлено (взвешено по кэшу)",
|
|
165
165
|
'savings.cumulative': "Накоплено (за N вызовов)",
|
|
166
|
+
'profile.flash-tuned': 'Flash-tuned',
|
|
167
|
+
'detail.flash-tuned': 'Flash optimized',
|
|
166
168
|
|
|
167
169
|
} satisfies Record<ContextCompressionLocaleKey, string>
|
|
@@ -49,6 +49,8 @@ export const zh = {
|
|
|
49
49
|
'detail.custom': '为新会话选择已实现的压缩阶段和计量阈值',
|
|
50
50
|
'detail.native': '只使用 DeepSeek Harness 原生头尾裁剪',
|
|
51
51
|
'detail.off': '关闭确定性选择器;原生 auto-compact 仍由 Harness 配置决定',
|
|
52
|
+
'profile.flash-tuned': 'Flash 特化模式',
|
|
53
|
+
'detail.flash-tuned': '为 DeepSeek V4.1 Flash 优化的激进裁剪档:低触发值、小目标、骨架常开、净收益门槛 800',
|
|
52
54
|
'autoCompact.title': 'Auto Compact 触发水位',
|
|
53
55
|
'autoCompact.description': '模型驱动 Auto Compact 在请求占用达到该水位时触发。调整后,标准 Profile 的 History 触发值、最小回收量与近期尾窗随水位联动;修改只影响新会话。',
|
|
54
56
|
'autoCompact.inputLabel': 'Auto Compact 阈值(%)',
|
|
@@ -219,6 +221,8 @@ export const en = {
|
|
|
219
221
|
'detail.custom': 'Choose implemented stages and measured thresholds for new sessions',
|
|
220
222
|
'detail.native': 'Use only the Harness native head/tail pruner',
|
|
221
223
|
'detail.off': 'Disable the deterministic selector; native auto-compact remains separately configured',
|
|
224
|
+
'profile.flash-tuned': 'Flash-tuned mode',
|
|
225
|
+
'detail.flash-tuned': 'Aggressive profile optimized for DeepSeek V4.1 Flash: low triggers, small targets, skeleton on, netGain 800',
|
|
222
226
|
'autoCompact.title': 'Auto Compact trigger level',
|
|
223
227
|
'autoCompact.description': 'Model-driven Auto Compact triggers once request usage crosses this level. Standard-profile History triggers, minimum reclaim, and the recent tail follow the level; changes affect new sessions only.',
|
|
224
228
|
'autoCompact.inputLabel': 'Auto Compact threshold (%)',
|
|
@@ -135,6 +135,10 @@ import {
|
|
|
135
135
|
flattenPlainText,
|
|
136
136
|
} from './runtime/tokenpilot/dedup.ts'
|
|
137
137
|
import { getSavingsLedger } from './runtime/savings.ts'
|
|
138
|
+
import { checkNetGain } from './runtime/netgain.ts'
|
|
139
|
+
import { appendCut } from './runtime/cut-index.ts'
|
|
140
|
+
import { isInjectedMessage } from './runtime/injected-kinds.ts'
|
|
141
|
+
import { effectiveMinReclaim, type DisclosurePolicy } from './runtime/ptc-disclosure.ts'
|
|
138
142
|
import { claimFromLand, flushUsageOnDispose, reclaimFromTailTrim, scheduleUsageFlush, setStatsLivePathBusy } from './runtime/stats-sync.ts'
|
|
139
143
|
import { kickStatsBackfillOnDispose } from './runtime/stats-backfill.ts'
|
|
140
144
|
import { sampleIntegralBoundary } from './runtime/savings-integral.ts'
|
|
@@ -2875,6 +2879,12 @@ export class ToolResultPruner extends Service {
|
|
|
2875
2879
|
|
|
2876
2880
|
private land(session: Session, plan: PlannedReplacement): PrunedEntry | null {
|
|
2877
2881
|
const { candidate } = plan
|
|
2882
|
+
// F1: Net-gain gate — skip cuts that don't clear the threshold
|
|
2883
|
+
// F1: Net-gain gate — disabled by default (0 = pass-through, preserving old behavior)
|
|
2884
|
+
const minNetGain = (this.activeSettings(session) as unknown as Record<string, unknown>).minNetGain as number | undefined ?? 0
|
|
2885
|
+
if (minNetGain > 0 && !checkNetGain(plan.tokensBefore, plan.tokensAfter, minNetGain)) {
|
|
2886
|
+
return null
|
|
2887
|
+
}
|
|
2878
2888
|
// 0.1.7-rc.2: the tool message's own `content` is the result block set —
|
|
2879
2889
|
// no wrapping result block anymore. The triple view still resolves the
|
|
2880
2890
|
// call id axis on a legacy envelope.
|
|
@@ -2953,6 +2963,20 @@ export class ToolResultPruner extends Service {
|
|
|
2953
2963
|
basis: plan.measurementBasis,
|
|
2954
2964
|
replacementSeq: Number(replacement.seq),
|
|
2955
2965
|
})
|
|
2966
|
+
// F2: Append to per-cut audit index (fire-and-forget)
|
|
2967
|
+
appendCut({
|
|
2968
|
+
ts: new Date().toISOString(),
|
|
2969
|
+
sessionId: String(session.id),
|
|
2970
|
+
strategy: plan.stage === 'fresh' ? (plan.reducer.includes('skeleton') ? 'skeleton' : 'small-knife') : 'small-knife',
|
|
2971
|
+
component: plan.component,
|
|
2972
|
+
eventSeqs: [candidate.seq],
|
|
2973
|
+
tokensBefore: plan.tokensBefore,
|
|
2974
|
+
tokensAfter: plan.tokensAfter,
|
|
2975
|
+
netGain: plan.tokensBefore - plan.tokensAfter - 80,
|
|
2976
|
+
cacheRecomputeEst: 0,
|
|
2977
|
+
cardRef: `session://${String(session.id)}/event/${candidate.seq}`,
|
|
2978
|
+
profile: this.activeSettings(session).profile,
|
|
2979
|
+
})
|
|
2956
2980
|
return {
|
|
2957
2981
|
originalSeq: candidate.seq,
|
|
2958
2982
|
sourceSeq: plan.sourceSeq,
|
|
@@ -47,9 +47,7 @@ function presetsFilePath(): string {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export interface PresetDocument {
|
|
50
|
-
|
|
51
|
-
'workspace:<dir>'?: PresetTier['settings']
|
|
52
|
-
all?: PresetTier['settings']
|
|
50
|
+
[scope: string]: PresetTier['settings'] | undefined
|
|
53
51
|
}
|
|
54
52
|
|
|
55
53
|
/** Load the preset document, creating defaults if missing. */
|
|
@@ -65,7 +63,7 @@ export function savePreset(scope: string, settings: PresetTier['settings']): voi
|
|
|
65
63
|
const dir = path.substring(0, path.lastIndexOf('\\') > -1 ? path.lastIndexOf('\\') : path.lastIndexOf('/'))
|
|
66
64
|
if (!existsSync(dir)) mkdirSync(dir, { recursive: true })
|
|
67
65
|
const doc = loadPresets()
|
|
68
|
-
doc[scope
|
|
66
|
+
doc[scope] = settings
|
|
69
67
|
writeFileSync(path, JSON.stringify(doc, null, 2), 'utf8')
|
|
70
68
|
}
|
|
71
69
|
|