chatccc 0.2.126 → 0.2.127

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chatccc",
3
- "version": "0.2.126",
3
+ "version": "0.2.127",
4
4
  "description": "Feishu bot bridge for Claude Code",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -5,13 +5,13 @@
5
5
  // 以确保 --mcp-config 参数能正确传递给 CLI 子进程,加载用户 MCP 服务器。
6
6
  // =============================================================================
7
7
 
8
- import { spawn, type ChildProcess } from "node:child_process";
9
- import { createInterface } from "node:readline";
10
- import { existsSync, readFileSync } from "node:fs";
11
- import { join, dirname } from "node:path";
12
- import { homedir } from "node:os";
13
- import { createRequire } from "node:module";
14
- import { fileURLToPath } from "node:url";
8
+ import { spawn, type ChildProcess } from "node:child_process";
9
+ import { createInterface } from "node:readline";
10
+ import { existsSync, readFileSync } from "node:fs";
11
+ import { join, dirname } from "node:path";
12
+ import { homedir } from "node:os";
13
+ import { createRequire } from "node:module";
14
+ import { fileURLToPath } from "node:url";
15
15
 
16
16
  import type {
17
17
  ToolAdapter,
@@ -72,13 +72,13 @@ function resolveClaudeBinary(): string {
72
72
  );
73
73
  }
74
74
 
75
- const CLAUDE_EXE = resolveClaudeBinary();
76
- const PROJECT_ROOT = dirname(dirname(dirname(fileURLToPath(import.meta.url))));
77
- const CLAUDE_SPECIFIC_PROMPT_PATH = join(
78
- PROJECT_ROOT,
79
- "agent-prompts",
80
- "claude_specific.md",
81
- );
75
+ const CLAUDE_EXE = resolveClaudeBinary();
76
+ const PROJECT_ROOT = dirname(dirname(dirname(fileURLToPath(import.meta.url))));
77
+ const CLAUDE_SPECIFIC_PROMPT_PATH = join(
78
+ PROJECT_ROOT,
79
+ "agent-prompts",
80
+ "claude_specific.md",
81
+ );
82
82
 
83
83
  // ---------------------------------------------------------------------------
84
84
  // 类型别名(CLI JSONL 消息格式,与旧 SDK 消息格式兼容)
@@ -289,7 +289,7 @@ function buildCliArgs(
289
289
  "--setting-sources", "user,project,local",
290
290
  "--permission-mode", "bypassPermissions",
291
291
  "--dangerously-skip-permissions",
292
- "--settings", "{\"maxTurns\":0}",
292
+ "--settings", "{\"maxTurns\":999999999,\"maxBudget\":999999999}",
293
293
  ];
294
294
 
295
295
  if (!isEmpty(model)) args.push("--model", model);
@@ -366,45 +366,45 @@ async function* readJsonLines(
366
366
  }
367
367
 
368
368
  /** 构造 stream-json 格式的 stdin 输入行 */
369
- function buildStreamJsonInput(text: string): string {
370
- return JSON.stringify({
371
- type: "user",
372
- message: {
373
- role: "user",
369
+ function buildStreamJsonInput(text: string): string {
370
+ return JSON.stringify({
371
+ type: "user",
372
+ message: {
373
+ role: "user",
374
374
  content: [{ type: "text", text }],
375
375
  },
376
- }) + "\n";
377
- }
378
-
379
- export function readClaudeSpecificInjectionPrompt(): string | null {
380
- try {
381
- if (!existsSync(CLAUDE_SPECIFIC_PROMPT_PATH)) return null;
382
- const prompt = readFileSync(CLAUDE_SPECIFIC_PROMPT_PATH, "utf-8").trim();
383
- return prompt.length > 0 ? prompt : null;
384
- } catch {
385
- return null;
386
- }
387
- }
388
-
389
- export function buildClaudePromptText(
390
- userText: string,
391
- injectionPrompt: string | null = readClaudeSpecificInjectionPrompt(),
392
- ): string {
393
- const prompt = injectionPrompt?.trim();
394
- if (!prompt) return userText;
395
-
396
- return [
397
- "[ChatCCC Claude-specific injection prompt]",
398
- prompt,
399
- "[/ChatCCC Claude-specific injection prompt]",
400
- "",
401
- userText,
402
- ].join("\n");
403
- }
404
-
405
- // ---------------------------------------------------------------------------
406
- // ClaudeAdapter
407
- // ---------------------------------------------------------------------------
376
+ }) + "\n";
377
+ }
378
+
379
+ export function readClaudeSpecificInjectionPrompt(): string | null {
380
+ try {
381
+ if (!existsSync(CLAUDE_SPECIFIC_PROMPT_PATH)) return null;
382
+ const prompt = readFileSync(CLAUDE_SPECIFIC_PROMPT_PATH, "utf-8").trim();
383
+ return prompt.length > 0 ? prompt : null;
384
+ } catch {
385
+ return null;
386
+ }
387
+ }
388
+
389
+ export function buildClaudePromptText(
390
+ userText: string,
391
+ injectionPrompt: string | null = readClaudeSpecificInjectionPrompt(),
392
+ ): string {
393
+ const prompt = injectionPrompt?.trim();
394
+ if (!prompt) return userText;
395
+
396
+ return [
397
+ "[ChatCCC Claude-specific injection prompt]",
398
+ prompt,
399
+ "[/ChatCCC Claude-specific injection prompt]",
400
+ "",
401
+ userText,
402
+ ].join("\n");
403
+ }
404
+
405
+ // ---------------------------------------------------------------------------
406
+ // ClaudeAdapter
407
+ // ---------------------------------------------------------------------------
408
408
 
409
409
  class ClaudeAdapter implements ToolAdapter {
410
410
  readonly displayName = "Claude Code";
@@ -470,13 +470,13 @@ class ClaudeAdapter implements ToolAdapter {
470
470
  const proc = spawnCli(args, cwd, env, true);
471
471
  if (proc.pid !== undefined) options?.onProcessStart?.({ pid: proc.pid });
472
472
 
473
- const onAbort = () => { void killProcessTree(proc.pid); };
474
- signal?.addEventListener("abort", onAbort, { once: true });
475
-
476
- proc.stdin!.write(buildStreamJsonInput(buildClaudePromptText(userText)));
477
- proc.stdin!.end();
478
-
479
- try {
473
+ const onAbort = () => { void killProcessTree(proc.pid); };
474
+ signal?.addEventListener("abort", onAbort, { once: true });
475
+
476
+ proc.stdin!.write(buildStreamJsonInput(buildClaudePromptText(userText)));
477
+ proc.stdin!.end();
478
+
479
+ try {
480
480
  for await (const raw of readJsonLines(proc, signal)) {
481
481
  if (signal?.aborted) break;
482
482
 
@@ -526,4 +526,4 @@ export function createClaudeAdapter(
526
526
  options: ClaudeAdapterOptions,
527
527
  ): ToolAdapter {
528
528
  return new ClaudeAdapter(options);
529
- }
529
+ }