deepccc 0.1.14 → 0.1.15

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 CHANGED
@@ -45,16 +45,18 @@ deepccc 的本地缓存优化实测命中率 **96.7%**,有效降低重复请
45
45
 
46
46
  ```bash
47
47
  export DEEPCCC_API_KEY="sk-..."
48
- export DEEPCCC_BASE_URL="https://api.deepseek.com/v1"
49
- export DEEPCCC_MODEL="deepseek-v4-pro"
48
+ export DEEPCCC_BASE_URL="https://api.deepseek.com/v1"
49
+ export DEEPCCC_MODEL="deepseek-v4-pro"
50
+ export DEEPCCC_STREAMING="true"
50
51
  ```
51
52
 
52
53
  Windows PowerShell:
53
54
 
54
55
  ```powershell
55
56
  $env:DEEPCCC_API_KEY="sk-..."
56
- $env:DEEPCCC_BASE_URL="https://api.deepseek.com/v1"
57
- $env:DEEPCCC_MODEL="deepseek-v4-pro"
57
+ $env:DEEPCCC_BASE_URL="https://api.deepseek.com/v1"
58
+ $env:DEEPCCC_MODEL="deepseek-v4-pro"
59
+ $env:DEEPCCC_STREAMING="true"
58
60
  ```
59
61
 
60
62
  也兼容这些 DeepSeek 别名:
@@ -70,16 +72,20 @@ $env:DEEPCCC_MODEL="deepseek-v4-pro"
70
72
  {
71
73
  "apiKey": "sk-...",
72
74
  "baseURL": "https://api.deepseek.com/v1",
73
- "model": "deepseek-v4-pro",
74
- "effort": "",
75
+ "model": "deepseek-v4-pro",
76
+ "effort": "",
77
+ "streaming": true,
75
78
  "rawStreamLogs": {
76
79
  "enabled": false,
77
80
  "maxBytesPerTurn": 1048576,
78
81
  "retentionDays": 7,
79
82
  "keepCompleted": false
80
83
  }
81
- }
82
- ```
84
+ }
85
+ ```
86
+
87
+ `streaming` 控制主对话是否使用流式请求,默认 `true`;也可以通过
88
+ `DEEPCCC_STREAMING=true|false` 覆盖。关闭后,终端会在整条模型响应完成后一次性显示结果。
83
89
 
84
90
  ## 命令行交互
85
91
 
package/dist/cli.js CHANGED
@@ -11,7 +11,7 @@
11
11
  * 非 TTY(管道/CI)或 --plain 回退为纯文本流式输出;--stream-json 机器接口不变。
12
12
  */
13
13
  import * as readline from "node:readline";
14
- import * as process from "node:process";
14
+ import process from "node:process";
15
15
  import { appendFileSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
16
16
  import { homedir } from "node:os";
17
17
  import { join, resolve as resolvePath } from "node:path";
@@ -595,7 +595,8 @@ async function main() {
595
595
  const args = parseArgs();
596
596
  if (args.streamJson) {
597
597
  const code = await runStreamJson(args);
598
- process.exit(code);
598
+ process.exitCode = code;
599
+ return;
599
600
  }
600
601
  if (args.help) {
601
602
  const { appConfig } = await loadRuntime();
package/dist/config.d.ts CHANGED
@@ -4,6 +4,8 @@ export interface DeepCccConfig {
4
4
  model: string;
5
5
  /** Reasoning effort(none/minimal/low/medium/high/xhigh/max),留空不传 reasoning_effort */
6
6
  effort: string;
7
+ /** 主对话是否使用流式请求;默认开启 */
8
+ streaming: boolean;
7
9
  rawStreamLogs: {
8
10
  enabled: boolean;
9
11
  maxBytesPerTurn: number;
package/dist/config.js CHANGED
@@ -9,6 +9,7 @@ const DEFAULT_CONFIG = {
9
9
  baseURL: "https://api.deepseek.com/v1",
10
10
  model: "deepseek-v4-pro",
11
11
  effort: "",
12
+ streaming: true,
12
13
  rawStreamLogs: {
13
14
  enabled: false,
14
15
  maxBytesPerTurn: 1024 * 1024,
@@ -50,6 +51,7 @@ function loadConfig() {
50
51
  baseURL: env("DEEPCCC_BASE_URL") ?? env("DEEPSEEK_BASE_URL") ?? file.baseURL ?? DEFAULT_CONFIG.baseURL,
51
52
  model: env("DEEPCCC_MODEL") ?? env("DEEPSEEK_MODEL") ?? file.model ?? DEFAULT_CONFIG.model,
52
53
  effort: env("DEEPCCC_EFFORT") ?? env("DEEPSEEK_EFFORT") ?? file.effort ?? DEFAULT_CONFIG.effort,
54
+ streaming: boolEnv("DEEPCCC_STREAMING") ?? file.streaming ?? DEFAULT_CONFIG.streaming,
53
55
  rawStreamLogs: {
54
56
  enabled: boolEnv("DEEPCCC_RAW_STREAM_LOGS") ?? rawLogs.enabled ?? DEFAULT_CONFIG.rawStreamLogs.enabled,
55
57
  maxBytesPerTurn: numberEnv("DEEPCCC_RAW_STREAM_MAX_BYTES") ?? rawLogs.maxBytesPerTurn ?? DEFAULT_CONFIG.rawStreamLogs.maxBytesPerTurn,
package/dist/index.js CHANGED
@@ -171,6 +171,7 @@ export class ChatSession {
171
171
  name: "deepccc",
172
172
  baseURL,
173
173
  apiKey,
174
+ includeUsage: true,
174
175
  });
175
176
  this.model = provider(modelId);
176
177
  this.cwd = options.cwd ?? process.cwd();
@@ -259,7 +260,7 @@ export class ChatSession {
259
260
  const skills = await scanSkillsDirs(this.skillDirs);
260
261
  const system = this.buildSystemPrompt(skills);
261
262
  this.systemPrompt = system;
262
- const result = streamText({
263
+ const generationOptions = {
263
264
  model: this.model,
264
265
  system,
265
266
  messages: this.context.buildModelMessages(),
@@ -269,8 +270,16 @@ export class ChatSession {
269
270
  // DeepSeek OpenAI 兼容接口:providerOptions.deepseek.reasoningEffort
270
271
  // 由 @ai-sdk/openai-compatible 自动映射为请求体 reasoning_effort 字段
271
272
  ...(this.effort ? { providerOptions: { deepseek: { reasoningEffort: this.effort } } } : {}),
272
- });
273
- const stream = result.fullStream ?? textStreamToFullStream(result.textStream);
273
+ };
274
+ let stream;
275
+ if (appConfig.streaming) {
276
+ const result = streamText(generationOptions);
277
+ stream = result.fullStream ?? textStreamToFullStream(result.textStream);
278
+ }
279
+ else {
280
+ const result = await generateText(generationOptions);
281
+ stream = generateResultToFullStream(result);
282
+ }
274
283
  for await (const part of stream) {
275
284
  rawLog?.writeLine(safeRawStreamJson(part));
276
285
  if (part.type === "text-delta") {
@@ -432,6 +441,34 @@ async function* textStreamToFullStream(stream) {
432
441
  yield { type: "text-delta", text };
433
442
  }
434
443
  }
444
+ async function* generateResultToFullStream(result) {
445
+ let emittedText = false;
446
+ for (const step of result.steps ?? []) {
447
+ for (const call of step.toolCalls ?? []) {
448
+ yield {
449
+ type: "tool-call",
450
+ toolCallId: call.toolCallId,
451
+ toolName: call.toolName,
452
+ input: call.input,
453
+ };
454
+ }
455
+ for (const toolResult of step.toolResults ?? []) {
456
+ yield {
457
+ type: "tool-result",
458
+ toolCallId: toolResult.toolCallId,
459
+ toolName: toolResult.toolName,
460
+ output: toolResult.output,
461
+ };
462
+ }
463
+ if (step.text) {
464
+ emittedText = true;
465
+ yield { type: "text-delta", text: step.text };
466
+ }
467
+ }
468
+ if (!emittedText && result.text) {
469
+ yield { type: "text-delta", text: result.text };
470
+ }
471
+ }
435
472
  function safeJson(value) {
436
473
  try {
437
474
  return JSON.stringify(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepccc",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "A lightweight DeepSeek-optimized coding agent with OpenAI-compatible model support.",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [