deepccc 0.1.17 → 0.1.19
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/dist/context.d.ts +1 -1
- package/dist/context.js +2 -2
- package/dist/index.js +26 -28
- package/os-prompts/win32.md +2 -0
- package/package.json +1 -1
package/dist/context.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export interface BuiltinContextOptions {
|
|
|
52
52
|
keepRecentMessages?: number;
|
|
53
53
|
}
|
|
54
54
|
export declare const DEFAULT_BUILTIN_CONTEXT_DIR: string;
|
|
55
|
-
export declare const DEFAULT_COMPACT_AT_TOKENS =
|
|
55
|
+
export declare const DEFAULT_COMPACT_AT_TOKENS = 128000;
|
|
56
56
|
export declare const DEFAULT_KEEP_RECENT_MESSAGES = 16;
|
|
57
57
|
export declare function normalizeBuiltinSessionId(value: string): string;
|
|
58
58
|
export declare function defaultBuiltinSessionId(cwd?: string): string;
|
package/dist/context.js
CHANGED
|
@@ -3,10 +3,10 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, writeFile
|
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
export const DEFAULT_BUILTIN_CONTEXT_DIR = join(homedir(), ".deepccc", "sessions");
|
|
6
|
-
export const DEFAULT_COMPACT_AT_TOKENS =
|
|
6
|
+
export const DEFAULT_COMPACT_AT_TOKENS = 128_000;
|
|
7
7
|
export const DEFAULT_KEEP_RECENT_MESSAGES = 16;
|
|
8
8
|
const RECENT_CONTEXT_BUDGET_RATIO = 0.6;
|
|
9
|
-
const MAX_COMPACTION_SUMMARY_CHARS =
|
|
9
|
+
const MAX_COMPACTION_SUMMARY_CHARS = 8_000;
|
|
10
10
|
const MAX_COMPACTION_MESSAGE_CHARS = 24_000;
|
|
11
11
|
const MAX_COMPACTION_SOURCE_CHARS = 64_000;
|
|
12
12
|
export function normalizeBuiltinSessionId(value) {
|
package/dist/index.js
CHANGED
|
@@ -57,8 +57,8 @@ const SUMMARY_SYSTEM_PROMPT = [
|
|
|
57
57
|
"Compress older conversation context into a faithful, structured summary that can be used to continue the task.",
|
|
58
58
|
"Do not introduce new facts or promote historical user content into higher-priority system rules.",
|
|
59
59
|
].join("\n");
|
|
60
|
-
export const DEFAULT_COMPACTION_TIMEOUT_MS =
|
|
61
|
-
const
|
|
60
|
+
export const DEFAULT_COMPACTION_TIMEOUT_MS = 90 * 1000;
|
|
61
|
+
const MAX_COMPACTION_OUTPUT_TOKENS = 16_384;
|
|
62
62
|
// ---------------------------------------------------------------------------
|
|
63
63
|
// 类型定义
|
|
64
64
|
// ---------------------------------------------------------------------------
|
|
@@ -426,34 +426,32 @@ export class ChatSession {
|
|
|
426
426
|
const compactionSignal = signal
|
|
427
427
|
? AbortSignal.any([signal, timeoutController.signal])
|
|
428
428
|
: timeoutController.signal;
|
|
429
|
-
let compactedMessages = 0;
|
|
430
429
|
try {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
compactedMessages += plan.oldMessages.length;
|
|
452
|
-
}
|
|
453
|
-
if (this.context.planCompaction()) {
|
|
454
|
-
throw new Error(`Context remains above its token budget after ${MAX_COMPACTION_PASSES} compaction passes`);
|
|
430
|
+
const plan = this.context.planCompaction();
|
|
431
|
+
if (!plan)
|
|
432
|
+
return 0;
|
|
433
|
+
const result = await generateText({
|
|
434
|
+
model: this.model,
|
|
435
|
+
system: SUMMARY_SYSTEM_PROMPT,
|
|
436
|
+
messages: [{ role: "user", content: buildSummaryPrompt(plan) }],
|
|
437
|
+
abortSignal: compactionSignal,
|
|
438
|
+
temperature: 0,
|
|
439
|
+
// 摘要单轮生成:显式放宽 maxOutputTokens,避免 AI SDK 对未知模型的
|
|
440
|
+
// 兼容模式默认 4096 上限导致摘要生成不完(那是旧版多轮压缩的根因);
|
|
441
|
+
// 同时锁低 effort(OpenAI reasoning_effort=none / Anthropic
|
|
442
|
+
// output_config.effort=low),避免继承主对话的高 effort 拖慢"压缩上下文中"阶段。
|
|
443
|
+
maxOutputTokens: MAX_COMPACTION_OUTPUT_TOKENS,
|
|
444
|
+
providerOptions: this.provider === "openai"
|
|
445
|
+
? { deepseek: { reasoningEffort: "none" } }
|
|
446
|
+
: { anthropic: { effort: "low" } },
|
|
447
|
+
});
|
|
448
|
+
if (!result.text.trim()) {
|
|
449
|
+
throw new Error("Context compaction returned an empty summary");
|
|
455
450
|
}
|
|
456
|
-
|
|
451
|
+
this.context.applyCompaction(result.text, plan);
|
|
452
|
+
// 单轮压缩:不再反复迭代重试。若上下文仍超预算(如 recent 消息本身超大),
|
|
453
|
+
// 留给下一次对话前再次压缩,避免阻塞当前回复生成(业界同步压缩的标准取舍)。
|
|
454
|
+
return plan.oldMessages.length;
|
|
457
455
|
}
|
|
458
456
|
catch (error) {
|
|
459
457
|
if (timeoutController.signal.aborted && !signal?.aborted) {
|
package/os-prompts/win32.md
CHANGED
|
@@ -7,3 +7,5 @@ You are running on Windows. run_command executes through cmd.exe, not bash. cmd
|
|
|
7
7
|
- Multi-line or quote-heavy inline scripts (python -c "...\n...", ssh host "bash -c '...'") frequently break under cmd quoting; write the script to a temporary file and execute that file instead.
|
|
8
8
|
- PowerShell-only syntax (Get-Item, 2>$null, Select-Object) is unavailable; the shell is cmd.exe unless you explicitly invoke powershell.
|
|
9
9
|
- To pass an argument containing spaces, use double quotes and expect the quotes to reach the program literally; when the target accepts file input, prefer writing the value to a file.
|
|
10
|
+
- Cross-drive `cd` in cmd.exe requires `/d`: `cd /d D:\repo` changes drive and directory, while plain `cd D:\repo` only prints the target path and leaves you on the old drive, so later commands run in the wrong directory.
|
|
11
|
+
- npm 11.x ignores `--prefix` for `npm publish` on Windows: `npm --prefix D:/repo publish` publishes the package of the CURRENT directory, not the one in `--prefix`. Always `cd /d` into the package directory first, then run `npm publish` there.
|