@chatcode/chatcode-cli 3.0.2-rc.4 → 3.0.2-rc.5
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.i18n.yaml +4 -4
- package/README.md +4 -0
- package/README.zh.md +4 -0
- package/lib/{command-errors-uo0j5Wi8.js → command-errors-B-jCwfLt.js} +12 -12
- package/lib/{command-trees-D4SZ2sGk.js → command-trees-CdgUsoW4.js} +2 -2
- package/lib/{component-identity-C02l24iT.js → component-identity-ax93NpoH.js} +3 -3
- package/lib/{extension-events-D6DbIdnG.js → extension-events-DJTP1cCG.js} +20 -20
- package/lib/{host-access-BdqThvw7.js → host-access-D3lpiaUY.js} +1 -1
- package/lib/{keymap-DFoC50J1.js → keymap-DAr6MX8m.js} +2 -2
- package/lib/{plugin-B37GhsdI.js → plugin-BGw2QmPK.js} +1243 -524
- package/lib/{scenes-Dk6DYkO9.js → scenes-BeuL5ow2.js} +3 -3
- package/lib/{settings-sections-D4Ozrymr.js → settings-sections-dGk8gNU7.js} +3 -3
- package/lib/{themes-DDI83rNa.js → themes-O-UQAfC7.js} +12 -12
- package/lib/tui-compat-command-trees.js +1 -1
- package/lib/tui-compat-extensions.js +3 -3
- package/lib/tui-compat-plugin-host.js +5 -5
- package/lib/tui-compat-scenes.js +1 -1
- package/lib/tui-compat-settings-sections.js +1 -1
- package/lib/tui-compat-working-activity.js +1 -1
- package/lib/tui-compat-workspaces.js +1 -1
- package/lib/tui-compat.js +41 -9
- package/lib/{tuiDisplayPrefs-CJ9aBVkB.js → tuiDisplayPrefs-DdU4O_sF.js} +44 -2
- package/lib/types/tui-compat.d.ts +2 -0
- package/lib/{workspaces-Dt_J35P0.js → workspaces-CE18wA21.js} +2 -2
- package/package.json +25 -25
- package/runtime/manifest.json +1 -1
- package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-account/lib/client.js +2 -2
- package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-general/lib/client.js +1 -1
- package/runtime/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/runtime/node_modules/@deepseek-ai/dsh-compaction-basic/lib/index.js +84 -8
- package/runtime/node_modules/@deepseek-ai/dsh-compaction-basic/lib/types/region.d.ts +9 -0
- package/runtime/node_modules/@deepseek-ai/dsh-compaction-basic/lib/types/summarizer.d.ts +7 -0
|
@@ -233,6 +233,32 @@ function assertRatio(name, value) {
|
|
|
233
233
|
/** Tags wrapping the structured summary inside the landed checkpoint node. */
|
|
234
234
|
const SUMMARY_OPEN_TAG = "<compacted-summary>";
|
|
235
235
|
const SUMMARY_CLOSE_TAG = "</compacted-summary>";
|
|
236
|
+
/** Smallest checkpoint body that satisfies the summarizer's required section structure. */
|
|
237
|
+
const MINIMUM_SUMMARY_TEXT = [
|
|
238
|
+
"## Primary Request and Intent",
|
|
239
|
+
"- (none)",
|
|
240
|
+
"",
|
|
241
|
+
"## Key Technical Concepts",
|
|
242
|
+
"- (none)",
|
|
243
|
+
"",
|
|
244
|
+
"## Files and Code",
|
|
245
|
+
"- (none)",
|
|
246
|
+
"",
|
|
247
|
+
"## Errors and Fixes",
|
|
248
|
+
"- (none)",
|
|
249
|
+
"",
|
|
250
|
+
"## Pending Jobs",
|
|
251
|
+
"- (none)",
|
|
252
|
+
"",
|
|
253
|
+
"## Current Work",
|
|
254
|
+
"- (none)",
|
|
255
|
+
"",
|
|
256
|
+
"## Next Step",
|
|
257
|
+
"- (none)",
|
|
258
|
+
"",
|
|
259
|
+
"## Critical Context",
|
|
260
|
+
"- (none)"
|
|
261
|
+
].join("\n");
|
|
236
262
|
/**
|
|
237
263
|
* The summarization directive, delivered as the FINAL user message after the
|
|
238
264
|
* replayed conversation rather than as a distinct summarizer system prompt.
|
|
@@ -301,12 +327,14 @@ async function summarizeWithLlm(ctx, config, input, agent, signal) {
|
|
|
301
327
|
} : void 0;
|
|
302
328
|
const target = configured ?? latest ?? agentTarget;
|
|
303
329
|
if (target === void 0) throw new Error("no provider/model available for summarization: set both BasicCompactionConfig summarization fields, route one request, or set both AgentOptions fields");
|
|
330
|
+
const modelInfo = await ctx.llm.resolveModelInfo(target.provider, target.model, signal);
|
|
331
|
+
const maxTokens = modelInfo.defaultMaxTokens === void 0 ? config.maxTokens : Math.min(config.maxTokens, modelInfo.defaultMaxTokens);
|
|
304
332
|
const assembler = new BlockAssembler();
|
|
305
333
|
const messages = [...input.messages, deepFreeze({
|
|
306
334
|
role: "user",
|
|
307
335
|
content: [{
|
|
308
336
|
type: "text",
|
|
309
|
-
text:
|
|
337
|
+
text: compactionInstruction(input.summaryTokenBudget)
|
|
310
338
|
}]
|
|
311
339
|
})];
|
|
312
340
|
const options = {
|
|
@@ -315,7 +343,7 @@ async function summarizeWithLlm(ctx, config, input, agent, signal) {
|
|
|
315
343
|
messages,
|
|
316
344
|
toolHistory: agent.session.toolHistory(),
|
|
317
345
|
...input.tools === void 0 ? {} : { tools: [...input.tools] },
|
|
318
|
-
maxTokens
|
|
346
|
+
maxTokens,
|
|
319
347
|
sessionId: agent.session.id,
|
|
320
348
|
purpose: "compaction",
|
|
321
349
|
...signal === void 0 ? {} : { signal }
|
|
@@ -332,7 +360,7 @@ async function summarizeWithLlm(ctx, config, input, agent, signal) {
|
|
|
332
360
|
llmStreamCall: true,
|
|
333
361
|
provider: options.provider,
|
|
334
362
|
model: options.model,
|
|
335
|
-
maxTokens
|
|
363
|
+
maxTokens,
|
|
336
364
|
...assembler.usage === void 0 ? {} : { usage: assembler.usage }
|
|
337
365
|
};
|
|
338
366
|
}
|
|
@@ -354,6 +382,21 @@ function frameSummary(summary) {
|
|
|
354
382
|
}
|
|
355
383
|
];
|
|
356
384
|
}
|
|
385
|
+
/**
|
|
386
|
+
* Return the smallest body allowed by the structured-summary instruction.
|
|
387
|
+
* @returns one fresh text block containing every required section.
|
|
388
|
+
*/
|
|
389
|
+
function minimumSummaryContent() {
|
|
390
|
+
return [{
|
|
391
|
+
type: "text",
|
|
392
|
+
text: MINIMUM_SUMMARY_TEXT
|
|
393
|
+
}];
|
|
394
|
+
}
|
|
395
|
+
/** Add the selected region's strict shrink budget to the model instruction. */
|
|
396
|
+
function compactionInstruction(summaryTokenBudget) {
|
|
397
|
+
if (summaryTokenBudget === void 0) return COMPACTION_INSTRUCTION;
|
|
398
|
+
return `${COMPACTION_INSTRUCTION}\n- Keep the complete checkpoint body under ${summaryTokenBudget} estimated tokens. When space is tight, prioritize current work, the next step, constraints, and exact identifiers.`;
|
|
399
|
+
}
|
|
357
400
|
/** Map a terminal summarization finish to its fail-closed error. */
|
|
358
401
|
function finishError(finish) {
|
|
359
402
|
switch (finish.kind) {
|
|
@@ -475,7 +518,7 @@ async function compactSurfaceRegion(dependencies, session, start, end, agent, op
|
|
|
475
518
|
let closing = false;
|
|
476
519
|
let stage = "summary";
|
|
477
520
|
try {
|
|
478
|
-
const summarized = await summarizeCompaction(dependencies, prepareCompaction(dependencies, session, selection), agent, compactionId, options.sourceCommandId, assertStable, signal);
|
|
521
|
+
const summarized = await summarizeCompaction(dependencies, prepareCompaction(dependencies.meter, session, selection), agent, compactionId, options.sourceCommandId, assertStable, signal);
|
|
479
522
|
if (options.owner === null) signal?.throwIfAborted();
|
|
480
523
|
assertStable(dependencies, session, summarized);
|
|
481
524
|
stage = "commit";
|
|
@@ -565,8 +608,8 @@ function validateSurfaceRegion(session, start, end) {
|
|
|
565
608
|
};
|
|
566
609
|
}
|
|
567
610
|
/** Snapshot pricing and replay input for a validated surface range. */
|
|
568
|
-
function prepareCompaction(
|
|
569
|
-
const measurement =
|
|
611
|
+
function prepareCompaction(meter, session, selection) {
|
|
612
|
+
const measurement = meter.measure(session);
|
|
570
613
|
const selectedNodes = measurement.nodes.slice(selection.startIdx, selection.endIdx + 1);
|
|
571
614
|
if (selectedNodes.length !== selection.shadowedSeqs.length || selectedNodes.some((node, index) => node.seq !== selection.shadowedSeqs[index])) throw new SurfaceChangedError("compaction: selected surface changed before summarization began");
|
|
572
615
|
return {
|
|
@@ -578,19 +621,50 @@ function prepareCompaction(dependencies, session, selection) {
|
|
|
578
621
|
input: buildSummarizationInput(session, selection.shadowedSeqs)
|
|
579
622
|
};
|
|
580
623
|
}
|
|
624
|
+
/** Price a framed checkpoint carrying the supplied summary body. */
|
|
625
|
+
function framedSummaryTokenCount(meter, summary) {
|
|
626
|
+
return meter.estimateMessage(createUserMessage({
|
|
627
|
+
content: frameSummary(summary),
|
|
628
|
+
source: { kind: "user" }
|
|
629
|
+
}));
|
|
630
|
+
}
|
|
631
|
+
/** Maximum summary-body tokens that keep the framed checkpoint strictly smaller than the selected source. */
|
|
632
|
+
function summaryTokenBudget(meter, shadowedRouteTokenCount) {
|
|
633
|
+
return shadowedRouteTokenCount - framedSummaryTokenCount(meter, [{
|
|
634
|
+
type: "text",
|
|
635
|
+
text: ""
|
|
636
|
+
}]) - 1;
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Determine whether the selected source can fit the minimum structured checkpoint with a strict token reduction.
|
|
640
|
+
* @param meter - token meter that priced the selected conversation route.
|
|
641
|
+
* @param session - session supplying the current surface.
|
|
642
|
+
* @param start - inclusive first surface-node seq.
|
|
643
|
+
* @param end - inclusive last surface-node seq.
|
|
644
|
+
* @returns `true` when the minimum valid framed checkpoint is smaller than the selected source.
|
|
645
|
+
*/
|
|
646
|
+
function canCompactSurfaceRegion(meter, session, start, end) {
|
|
647
|
+
const prepared = prepareCompaction(meter, session, validateSurfaceRegion(session, start, end));
|
|
648
|
+
return framedSummaryTokenCount(meter, minimumSummaryContent()) < prepared.shadowedRouteTokenCount;
|
|
649
|
+
}
|
|
581
650
|
/** Run the summarizer and frame its replacement checkpoint. */
|
|
582
651
|
async function summarizeCompaction(dependencies, prepared, agent, compactionId, sourceCommandId, assertStable, signal) {
|
|
583
652
|
let summaryResult;
|
|
584
653
|
for (;;) {
|
|
585
654
|
signal?.throwIfAborted();
|
|
586
655
|
try {
|
|
587
|
-
|
|
656
|
+
const budget = summaryTokenBudget(dependencies.meter, prepared.shadowedRouteTokenCount);
|
|
657
|
+
if (budget < 1) throw new Error("selected content is too small to fit a smaller framed summary");
|
|
658
|
+
summaryResult = await dependencies.summarize({
|
|
659
|
+
...prepared.input,
|
|
660
|
+
summaryTokenBudget: budget
|
|
661
|
+
}, agent, signal);
|
|
588
662
|
break;
|
|
589
663
|
} catch (error) {
|
|
590
664
|
if (signal?.aborted === true) throw error;
|
|
591
665
|
assertStable(dependencies, agent.session, prepared);
|
|
592
666
|
if (!dependencies.recover(error, agent, prepared.shadowedSeqs, signal)) throw error;
|
|
593
|
-
prepared = prepareCompaction(dependencies, agent.session, validateSurfaceRegion(agent.session, prepared.start, prepared.end));
|
|
667
|
+
prepared = prepareCompaction(dependencies.meter, agent.session, validateSurfaceRegion(agent.session, prepared.start, prepared.end));
|
|
594
668
|
}
|
|
595
669
|
}
|
|
596
670
|
const checkpointMessage = createUserMessage({
|
|
@@ -989,8 +1063,10 @@ var BasicCompactionEngine = class extends CompactionEngine {
|
|
|
989
1063
|
const operationSignal = AbortSignal.any([agentSignal, signal]);
|
|
990
1064
|
try {
|
|
991
1065
|
operationSignal.throwIfAborted();
|
|
1066
|
+
assertNoActiveCompaction(agent.session, "manual compaction");
|
|
992
1067
|
const range = selectCompactableRange(agent.session, this.ctx.tokenMeter.measure(agent.session), 0);
|
|
993
1068
|
if (range === null) return null;
|
|
1069
|
+
if (!canCompactSurfaceRegion(this.ctx.tokenMeter, agent.session, range.start, range.end)) return null;
|
|
994
1070
|
return await compactSurfaceRegion(this.regionDependencies(), agent.session, range.start, range.end, agent, {
|
|
995
1071
|
owner: null,
|
|
996
1072
|
stability: "selected-span",
|
|
@@ -62,5 +62,14 @@ export declare function compactSurfaceRegion(dependencies: RegionDependencies, s
|
|
|
62
62
|
* @param stage - operation label included in the busy diagnostic.
|
|
63
63
|
*/
|
|
64
64
|
export declare function assertNoActiveCompaction(session: Session, stage: string): void;
|
|
65
|
+
/**
|
|
66
|
+
* Determine whether the selected source can fit the minimum structured checkpoint with a strict token reduction.
|
|
67
|
+
* @param meter - token meter that priced the selected conversation route.
|
|
68
|
+
* @param session - session supplying the current surface.
|
|
69
|
+
* @param start - inclusive first surface-node seq.
|
|
70
|
+
* @param end - inclusive last surface-node seq.
|
|
71
|
+
* @returns `true` when the minimum valid framed checkpoint is smaller than the selected source.
|
|
72
|
+
*/
|
|
73
|
+
export declare function canCompactSurfaceRegion(meter: TokenMeter, session: Session, start: SessionSeq, end: SessionSeq): boolean;
|
|
65
74
|
export {};
|
|
66
75
|
//# sourceMappingURL=region.d.ts.map
|
|
@@ -22,6 +22,8 @@ export interface SummarizationInput {
|
|
|
22
22
|
readonly tools?: readonly ToolSchema[];
|
|
23
23
|
/** The derived system head, when present, followed by the shadowed region in surface order. */
|
|
24
24
|
readonly messages: readonly Message[];
|
|
25
|
+
/** Maximum estimated tokens available to the returned summary text while keeping the framed checkpoint smaller than its source. */
|
|
26
|
+
readonly summaryTokenBudget?: number;
|
|
25
27
|
}
|
|
26
28
|
/** Safe summary content plus the exact auxiliary call envelope recorded with it. */
|
|
27
29
|
export type SummaryResult = {
|
|
@@ -60,5 +62,10 @@ export declare function summarizeWithLlm(ctx: Context, config: SummaryConfig, in
|
|
|
60
62
|
* @returns content for the synthesized replacement user message.
|
|
61
63
|
*/
|
|
62
64
|
export declare function frameSummary(summary: readonly ContentBlock[]): ContentBlock[];
|
|
65
|
+
/**
|
|
66
|
+
* Return the smallest body allowed by the structured-summary instruction.
|
|
67
|
+
* @returns one fresh text block containing every required section.
|
|
68
|
+
*/
|
|
69
|
+
export declare function minimumSummaryContent(): ContentBlock[];
|
|
63
70
|
export {};
|
|
64
71
|
//# sourceMappingURL=summarizer.d.ts.map
|