chatccc 0.2.191 → 0.2.193

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/src/cards.ts CHANGED
@@ -274,8 +274,48 @@ export function buildCdCard(
274
274
  });
275
275
  }
276
276
 
277
- // 所有会话列表卡片(Claude Code 优先,然后 Cursor)
278
- export function buildSessionsCard(sessions: Array<{
277
+ function sessionToolLabel(tool: string): string {
278
+ if (tool === "cursor") return "Cursor";
279
+ if (tool === "codex") return "Codex";
280
+ if (tool === "ccc") return "CCC Agent";
281
+ return "Claude Code";
282
+ }
283
+
284
+ function pushSessionGroup(
285
+ lines: string[],
286
+ title: string,
287
+ sessions: Array<{
288
+ sessionId: string;
289
+ chatName: string;
290
+ chatId: string;
291
+ active: boolean;
292
+ turnCount: number;
293
+ elapsedSeconds: number | null;
294
+ model: string;
295
+ tool: string;
296
+ }>,
297
+ formatSession: (session: {
298
+ sessionId: string;
299
+ chatName: string;
300
+ chatId: string;
301
+ active: boolean;
302
+ turnCount: number;
303
+ elapsedSeconds: number | null;
304
+ model: string;
305
+ tool: string;
306
+ }, index: number) => string,
307
+ index: { value: number },
308
+ ): void {
309
+ if (sessions.length === 0) return;
310
+ if (index.value > 0) lines.push("", `**${title}:**`, "");
311
+ else lines.push(`**${title}:**`, "");
312
+ for (const session of sessions) {
313
+ lines.push(formatSession(session, index.value++));
314
+ }
315
+ }
316
+
317
+ // 所有会话列表卡片(Claude Code 优先,然后 Cursor)
318
+ export function buildSessionsCard(sessions: Array<{
279
319
  sessionId: string;
280
320
  chatName: string;
281
321
  chatId: string;
@@ -285,14 +325,16 @@ export function buildSessionsCard(sessions: Array<{
285
325
  model: string;
286
326
  tool: string;
287
327
  }>, opts: { defaultToolLabel?: string } = {}): string {
288
- const defaultToolLabel = opts.defaultToolLabel ?? "Claude Code";
289
- // 按 tool 分组排序:Claude Code 在前,Cursor 其次,Codex 最后
290
- const claudeCodeSessions = sessions.filter(s => s.tool !== "cursor" && s.tool !== "codex");
291
- const cursorSessions = sessions.filter(s => s.tool === "cursor");
292
- const codexSessions = sessions.filter(s => s.tool === "codex");
293
- const hasClaudeCode = claudeCodeSessions.length > 0;
294
- const hasCursor = cursorSessions.length > 0;
295
- const hasCodex = codexSessions.length > 0;
328
+ const defaultToolLabel = opts.defaultToolLabel ?? "Claude Code";
329
+ // 按 tool 分组排序:Claude Code 在前,Cursor 其次,Codex 最后
330
+ const claudeCodeSessions = sessions.filter(s => s.tool !== "cursor" && s.tool !== "codex" && s.tool !== "ccc");
331
+ const cursorSessions = sessions.filter(s => s.tool === "cursor");
332
+ const codexSessions = sessions.filter(s => s.tool === "codex");
333
+ const cccSessions = sessions.filter(s => s.tool === "ccc");
334
+ const hasClaudeCode = claudeCodeSessions.length > 0;
335
+ const hasCursor = cursorSessions.length > 0;
336
+ const hasCodex = codexSessions.length > 0;
337
+ const hasCcc = cccSessions.length > 0;
296
338
 
297
339
  if (sessions.length === 0) {
298
340
  return JSON.stringify({
@@ -315,37 +357,18 @@ export function buildSessionsCard(sessions: Array<{
315
357
  const secs = s.elapsedSeconds % 60;
316
358
  extra = ` | 本轮: ${mins}分${secs}秒`;
317
359
  }
318
- const toolLabel = s.tool === "cursor" ? "Cursor" : s.tool === "codex" ? "Codex" : "Claude Code";
360
+ const toolLabel = sessionToolLabel(s.tool);
319
361
  const namePart = s.chatName ? `**${s.chatName}** ` : "";
320
362
  const chatTag = !s.chatId ? " (chat id缺失)" : s.chatId.startsWith("oc_") ? " (群聊)" : "";
321
363
  return `**${i + 1}.** ${namePart}${chatTag} \`${shortId}\` ${status} | 工具: ${toolLabel} | 轮数: ${s.turnCount} | ${s.model}${extra}`;
322
364
  };
323
365
 
324
366
  const lines: string[] = [`共 **${sessions.length}** 个会话:`, ""];
325
- let idx = 0;
326
-
327
- if (hasClaudeCode) {
328
- lines.push("**Claude Code 会话:**", "");
329
- for (const s of claudeCodeSessions) {
330
- lines.push(formatSession(s, idx++));
331
- }
332
- }
333
-
334
- if (hasCursor) {
335
- if (hasClaudeCode) lines.push("", "**Cursor 会话:**", "");
336
- else lines.push("**Cursor 会话:**", "");
337
- for (const s of cursorSessions) {
338
- lines.push(formatSession(s, idx++));
339
- }
340
- }
341
-
342
- if (hasCodex) {
343
- if (hasClaudeCode || hasCursor) lines.push("", "**Codex 会话:**", "");
344
- else lines.push("**Codex 会话:**", "");
345
- for (const s of codexSessions) {
346
- lines.push(formatSession(s, idx++));
347
- }
348
- }
367
+ const idx = { value: 0 };
368
+ if (hasClaudeCode) pushSessionGroup(lines, "Claude Code 会话", claudeCodeSessions, formatSession, idx);
369
+ if (hasCursor) pushSessionGroup(lines, "Cursor 会话", cursorSessions, formatSession, idx);
370
+ if (hasCodex) pushSessionGroup(lines, "Codex 会话", codexSessions, formatSession, idx);
371
+ if (hasCcc) pushSessionGroup(lines, "CCC Agent 会话", cccSessions, formatSession, idx);
349
372
 
350
373
  return JSON.stringify({
351
374
  config: { wide_screen_mode: true },
package/src/config.ts CHANGED
@@ -169,7 +169,7 @@ export const AGENT_TOOLS: AgentTool[] = ["claude", "cursor", "codex"];
169
169
  export type CursorAvatarBatteryMode = "apiPercent" | "onDemandUse";
170
170
 
171
171
  /** 获取指定 agent 配置中所有模型相关的值(最多 100 个,去重) */
172
- export function getAllModelsForTool(tool: AgentTool, cfg: AppConfig = config): string[] {
172
+ export function getAllModelsForTool(tool: string, cfg: AppConfig = config): string[] {
173
173
  const seen = new Set<string>();
174
174
  const collect = (v: unknown) => {
175
175
  if (typeof v === "string" && v.trim()) seen.add(v.trim());
@@ -181,10 +181,12 @@ export function getAllModelsForTool(tool: AgentTool, cfg: AppConfig = config): s
181
181
  } else if (tool === "cursor") {
182
182
  collect(cfg.cursor.model);
183
183
  collect(cfg.cursor.alternativeModel);
184
- } else if (tool === "codex") {
185
- collect(cfg.codex.model);
186
- collect(cfg.codex.alternativeModel);
187
- }
184
+ } else if (tool === "codex") {
185
+ collect(cfg.codex.model);
186
+ collect(cfg.codex.alternativeModel);
187
+ } else if (tool === "ccc") {
188
+ collect(cfg.ccc.model);
189
+ }
188
190
 
189
191
  return Array.from(seen).slice(0, 100);
190
192
  }
@@ -192,7 +194,7 @@ export function getAllModelsForTool(tool: AgentTool, cfg: AppConfig = config): s
192
194
  export const CLAUDE_EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"] as const;
193
195
  export const CODEX_EFFORT_LEVELS = ["minimal", "low", "medium", "high", "xhigh"] as const;
194
196
 
195
- export function getAllEffortsForTool(tool: AgentTool): string[] {
197
+ export function getAllEffortsForTool(tool: string): string[] {
196
198
  if (tool === "claude") return [...CLAUDE_EFFORT_LEVELS];
197
199
  if (tool === "codex") return [...CODEX_EFFORT_LEVELS];
198
200
  return [];
@@ -962,22 +964,26 @@ export function explainMissingFeishuCredentialsAndExit(): never {
962
964
  export const CLAUDE_SESSION_PREFIX = "Claude Code Session:";
963
965
  /** 群描述中用于识别 Cursor 会话的前缀 */
964
966
  export const CURSOR_SESSION_PREFIX = "Cursor Session:";
965
- /** 群描述中用于识别 Codex 会话的前缀 */
966
- export const CODEX_SESSION_PREFIX = "Codex Session:";
967
+ /** 群描述中用于识别 Codex 会话的前缀 */
968
+ export const CODEX_SESSION_PREFIX = "Codex Session:";
969
+ /** 群描述中用于识别 hidden ccc agent 会话的前缀 */
970
+ export const CCC_SESSION_PREFIX = "CCC Session:";
967
971
 
968
972
  /** 根据 tool 名称返回对应的群描述前缀 */
969
- export function sessionPrefixForTool(tool: string): string {
970
- if (tool === "cursor") return CURSOR_SESSION_PREFIX;
971
- if (tool === "codex") return CODEX_SESSION_PREFIX;
972
- return CLAUDE_SESSION_PREFIX;
973
- }
973
+ export function sessionPrefixForTool(tool: string): string {
974
+ if (tool === "cursor") return CURSOR_SESSION_PREFIX;
975
+ if (tool === "codex") return CODEX_SESSION_PREFIX;
976
+ if (tool === "ccc") return CCC_SESSION_PREFIX;
977
+ return CLAUDE_SESSION_PREFIX;
978
+ }
974
979
 
975
980
  /** 根据 tool 名称返回用于状态展示的标签 */
976
- export function toolDisplayName(tool: string): string {
977
- if (tool === "cursor") return "Cursor";
978
- if (tool === "codex") return "Codex";
979
- return "Claude Code";
980
- }
981
+ export function toolDisplayName(tool: string): string {
982
+ if (tool === "cursor") return "Cursor";
983
+ if (tool === "codex") return "Codex";
984
+ if (tool === "ccc") return "CCC Agent";
985
+ return "Claude Code";
986
+ }
981
987
 
982
988
  /** 解析 /new 未指定工具时使用的默认 Agent。旧配置缺省 defaultAgent 时保持 Claude 优先。 */
983
989
  export function resolveDefaultAgentTool(cfg: AppConfig = config): AgentTool {
package/src/feishu-api.ts CHANGED
@@ -11,9 +11,10 @@ import {
11
11
  CHAT_LOGS_DIR,
12
12
  PROJECT_ROOT,
13
13
  USER_DATA_DIR,
14
- CLAUDE_SESSION_PREFIX,
15
- CURSOR_SESSION_PREFIX,
16
- CODEX_SESSION_PREFIX,
14
+ CLAUDE_SESSION_PREFIX,
15
+ CURSOR_SESSION_PREFIX,
16
+ CODEX_SESSION_PREFIX,
17
+ CCC_SESSION_PREFIX,
17
18
  ts,
18
19
  resolveDefaultAgentTool,
19
20
  toolDisplayName,
@@ -276,15 +277,16 @@ export async function disbandChat(
276
277
 
277
278
  export function extractSessionInfo(description: string): { sessionId: string; tool: string } | null {
278
279
  const PREFIXES: Array<{ prefix: string; tool: string }> = [
279
- { prefix: CLAUDE_SESSION_PREFIX, tool: "claude" },
280
- { prefix: CURSOR_SESSION_PREFIX, tool: "cursor" },
281
- { prefix: CODEX_SESSION_PREFIX, tool: "codex" },
282
- ];
283
- for (const { prefix, tool } of PREFIXES) {
284
- const idx = description.indexOf(prefix);
285
- if (idx === -1) continue;
286
- const after = description.slice(idx + prefix.length).trim();
287
- const match = after.match(/^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);
280
+ { prefix: CLAUDE_SESSION_PREFIX, tool: "claude" },
281
+ { prefix: CURSOR_SESSION_PREFIX, tool: "cursor" },
282
+ { prefix: CODEX_SESSION_PREFIX, tool: "codex" },
283
+ { prefix: CCC_SESSION_PREFIX, tool: "ccc" },
284
+ ];
285
+ for (const { prefix, tool } of PREFIXES) {
286
+ const idx = description.indexOf(prefix);
287
+ if (idx === -1) continue;
288
+ const after = description.slice(idx + prefix.length).trim();
289
+ const match = after.match(/^([a-zA-Z0-9_.-]+)/);
288
290
  if (match) return { sessionId: match[1], tool };
289
291
  }
290
292
  return null;
@@ -742,7 +742,7 @@ export async function handleCommand(
742
742
  const toolArg = text.slice(5).trim().toLowerCase();
743
743
  const tool = toolArg || resolveDefaultAgentTool();
744
744
  logTrace(tid, "BRANCH", { cmd: "/new", tool });
745
- const validTools = ["claude", "cursor", "codex"];
745
+ const validTools = ["claude", "cursor", "codex", "ccc"];
746
746
  if (!validTools.includes(tool)) {
747
747
  logTrace(tid, "DONE", { outcome: "new_invalid_tool", tool });
748
748
  await platform.sendCard(
package/src/session.ts CHANGED
@@ -27,9 +27,10 @@ import { logTrace } from "./trace.ts";
27
27
  import type { UnifiedBlock } from "./adapters/adapter-interface.ts";
28
28
  import type { ToolAdapter } from "./adapters/adapter-interface.ts";
29
29
  import type { ToolProcessInfo } from "./adapters/adapter-interface.ts";
30
- import { createClaudeAdapter } from "./adapters/claude-adapter.ts";
31
- import { createCursorAdapter } from "./adapters/cursor-adapter.ts";
32
- import { createCodexAdapter } from "./adapters/codex-adapter.ts";
30
+ import { createClaudeAdapter } from "./adapters/claude-adapter.ts";
31
+ import { createCursorAdapter } from "./adapters/cursor-adapter.ts";
32
+ import { createCodexAdapter } from "./adapters/codex-adapter.ts";
33
+ import { createCccAdapter } from "./adapters/ccc-adapter.ts";
33
34
  import { resourceMonitor, registerProcess, unregisterProcess } from "./adapters/resource-monitor.ts";
34
35
  import { buildImSkillsPromptCached, exportSkillSubDocs, clearImSkillsPromptCache } from "./im-skills.ts";
35
36
  import type { PlatformAdapter } from "./platform-adapter.ts";
@@ -370,8 +371,9 @@ export function getEffectiveModelForTool(tool: string, sessionId?: string): stri
370
371
  const override = sessionModelOverrides.get(sessionId);
371
372
  if (override) return override;
372
373
  }
373
- if (tool === "cursor") return config.cursor.model;
374
- if (tool === "codex") return config.codex.model;
374
+ if (tool === "cursor") return config.cursor.model;
375
+ if (tool === "codex") return config.codex.model;
376
+ if (tool === "ccc") return config.ccc.model;
375
377
  return CLAUDE_MODEL;
376
378
  }
377
379
 
@@ -420,6 +422,8 @@ export function getAdapterForTool(tool: string, sessionId?: string): ToolAdapter
420
422
  adapter = createCursorAdapter({ model: effectiveModel || undefined });
421
423
  } else if (tool === "codex") {
422
424
  adapter = createCodexAdapter({ model: effectiveModel || undefined, effort: effectiveEffort || undefined });
425
+ } else if (tool === "ccc") {
426
+ adapter = createCccAdapter({ model: effectiveModel || undefined });
423
427
  } else {
424
428
  adapter = createClaudeAdapter({
425
429
  model: effectiveModel,
@@ -859,12 +863,17 @@ function formatToolConfigForLog(tool: string, sessionModel?: string, sessionId?:
859
863
  if (tool === "codex") {
860
864
  const m = getEffectiveModelForTool(tool, sessionId);
861
865
  const e = getEffectiveEffortForTool(tool, sessionId);
862
- const modelStr = m.trim() !== "" ? m : "(由 codex config.toml 决定)";
863
- const effortStr = e.trim() !== ""
864
- ? `effort=${e}`
865
- : "effort=(由 codex config.toml 决定)";
866
- return `model=${modelStr}, ${effortStr}`;
867
- }
866
+ const modelStr = m.trim() !== "" ? m : "(由 codex config.toml 决定)";
867
+ const effortStr = e.trim() !== ""
868
+ ? `effort=${e}`
869
+ : "effort=(由 codex config.toml 决定)";
870
+ return `model=${modelStr}, ${effortStr}`;
871
+ }
872
+ if (tool === "ccc") {
873
+ const m = getEffectiveModelForTool(tool, sessionId);
874
+ const modelStr = m.trim() !== "" ? m : "(not configured)";
875
+ return `model=${modelStr}, baseURL=${config.ccc.DEEPSEEK_BASE_URL}`;
876
+ }
868
877
  return `model=${anthropicConfigDisplay(getModelForSession(sessionId))}, subagentModel=${anthropicConfigDisplay(CLAUDE_SUBAGENT_MODEL)}, effort=${anthropicConfigDisplay(getEffectiveEffortForTool(tool, sessionId))}`;
869
878
  }
870
879
 
@@ -1784,10 +1793,17 @@ async function resolveModelEffort(
1784
1793
  if (tool === "codex") {
1785
1794
  const m = getEffectiveModelForTool(tool, sessionId);
1786
1795
  const e = getEffectiveEffortForTool(tool, sessionId);
1787
- return {
1788
- model: m.trim() !== "" ? m : UNKNOWN_MODEL_PLACEHOLDER,
1789
- effort: e.trim() !== "" ? e : UNKNOWN_MODEL_PLACEHOLDER,
1790
- };
1796
+ return {
1797
+ model: m.trim() !== "" ? m : UNKNOWN_MODEL_PLACEHOLDER,
1798
+ effort: e.trim() !== "" ? e : UNKNOWN_MODEL_PLACEHOLDER,
1799
+ };
1800
+ }
1801
+ if (tool === "ccc") {
1802
+ const m = getEffectiveModelForTool(tool, sessionId);
1803
+ return {
1804
+ model: m.trim() !== "" ? m : UNKNOWN_MODEL_PLACEHOLDER,
1805
+ effort: null,
1806
+ };
1791
1807
  }
1792
1808
  return {
1793
1809
  model: anthropicConfigDisplay(getModelForSession(sessionId)),