chatccc 0.2.44 → 0.2.45
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 +1 -1
- package/package.json +1 -1
- package/src/cards.ts +2 -2
- package/src/index.ts +7 -7
package/README.md
CHANGED
|
@@ -324,7 +324,7 @@ ChatCCC 的所有运行参数都集中在包根目录的 `config.json`。
|
|
|
324
324
|
| `/status` | 查看当前会话的状态(轮数、模型、上下文 token 等) |
|
|
325
325
|
| `/cd` | 查看/设置当前会话的默认工作目录 |
|
|
326
326
|
| `/sessions` | 查看所有会话状态 |
|
|
327
|
-
| `/
|
|
327
|
+
| `/newh` | 重置当前会话(创建新 Session,保留工作目录,同一群内继续) |
|
|
328
328
|
| `/git <子命令>` | 在**当前会话工作目录**执行 `git ...` 并把 stdout/stderr 回发到群里(仅会话群内可用,超时见 `config.json` 的 `gitTimeoutSeconds` 字段) |
|
|
329
329
|
| `/restart` | 重启机器人进程 |
|
|
330
330
|
|
package/package.json
CHANGED
package/src/cards.ts
CHANGED
|
@@ -119,7 +119,7 @@ export function buildHelpCard(
|
|
|
119
119
|
"发送 **/new claude** 创建新 Claude 对话",
|
|
120
120
|
"发送 **/new cursor** 创建新 Cursor 会话",
|
|
121
121
|
"发送 **/new codex** 创建新 Codex 会话",
|
|
122
|
-
"发送 **/
|
|
122
|
+
"发送 **/newh** 重置当前会话(保留工作目录,同一群内继续)",
|
|
123
123
|
].join("\n");
|
|
124
124
|
return JSON.stringify({
|
|
125
125
|
config: { wide_screen_mode: true },
|
|
@@ -328,7 +328,7 @@ export function buildSessionsCard(sessions: Array<{
|
|
|
328
328
|
elements: [
|
|
329
329
|
{ tag: "div", text: { tag: "lark_md", content: lines.join("\n") } },
|
|
330
330
|
{ tag: "hr" },
|
|
331
|
-
{ tag: "div", text: { tag: "lark_md", content: "在会话群内发送 **/
|
|
331
|
+
{ tag: "div", text: { tag: "lark_md", content: "在会话群内发送 **/newh** 可重置当前会话(创建新 Session,保留工作目录和群聊)。\n发送 **/session 数字**(如 `/session 1`)可将当前群聊切换到列表中对应编号的会话。" } },
|
|
332
332
|
{ tag: "hr" },
|
|
333
333
|
{
|
|
334
334
|
tag: "action",
|
package/src/index.ts
CHANGED
|
@@ -232,7 +232,7 @@ function parseCardAction(data: unknown): CardActionResult | null {
|
|
|
232
232
|
}
|
|
233
233
|
if (!cmd) return null;
|
|
234
234
|
|
|
235
|
-
const CMD_MAP: Record<string, string> = { stop: "/stop", new: "/new", "new claude": "/new claude", "new cursor": "/new cursor", "new codex": "/new codex", restart: "/restart", status: "/status", cd: "/cd", sessions: "/sessions",
|
|
235
|
+
const CMD_MAP: Record<string, string> = { stop: "/stop", new: "/new", "new claude": "/new claude", "new cursor": "/new cursor", "new codex": "/new codex", restart: "/restart", status: "/status", cd: "/cd", sessions: "/sessions", newh: "/newh" };
|
|
236
236
|
let text = CMD_MAP[cmd] ?? "";
|
|
237
237
|
if (cmd === "cd" && typeof action.value === "object" && action.value !== null) {
|
|
238
238
|
const path = (action.value as Record<string, string>).path;
|
|
@@ -625,8 +625,8 @@ async function handleCommand(text: string, chatId: string, openId: string, msgTi
|
|
|
625
625
|
return;
|
|
626
626
|
}
|
|
627
627
|
|
|
628
|
-
if (textLower === "/
|
|
629
|
-
logTrace(tid, "BRANCH", { cmd: "/
|
|
628
|
+
if (textLower === "/newh") {
|
|
629
|
+
logTrace(tid, "BRANCH", { cmd: "/newh" });
|
|
630
630
|
const adapter = getAdapterForTool(descriptionTool);
|
|
631
631
|
let cwd: string;
|
|
632
632
|
try {
|
|
@@ -653,7 +653,7 @@ async function handleCommand(text: string, chatId: string, openId: string, msgTi
|
|
|
653
653
|
const init = await initClaudeSession(descriptionTool, cwd);
|
|
654
654
|
newSessionId = init.sessionId;
|
|
655
655
|
} catch (err) {
|
|
656
|
-
logTrace(tid, "DONE", { outcome: "
|
|
656
|
+
logTrace(tid, "DONE", { outcome: "newh_session_fail", error: (err as Error).message });
|
|
657
657
|
await sendCardReply(freshToken, chatId, "Error", `Failed to create new session:\n${(err as Error).message}`, "red");
|
|
658
658
|
return;
|
|
659
659
|
}
|
|
@@ -661,7 +661,7 @@ async function handleCommand(text: string, chatId: string, openId: string, msgTi
|
|
|
661
661
|
const descPrefix = sessionPrefixForTool(descriptionTool);
|
|
662
662
|
const newName = sessionChatName("新会话", cwd);
|
|
663
663
|
await updateChatInfo(freshToken, chatId, newName, `${descPrefix} ${newSessionId}`);
|
|
664
|
-
console.log(`[${ts()}] [
|
|
664
|
+
console.log(`[${ts()}] [NEWH] Group updated: name="${newName}" desc="${descPrefix} ${newSessionId}"`);
|
|
665
665
|
|
|
666
666
|
sessionInfoMap.set(chatId, {
|
|
667
667
|
sessionId: newSessionId,
|
|
@@ -692,8 +692,8 @@ async function handleCommand(text: string, chatId: string, openId: string, msgTi
|
|
|
692
692
|
"green"
|
|
693
693
|
);
|
|
694
694
|
|
|
695
|
-
console.log(`[${ts()}] [
|
|
696
|
-
logTrace(tid, "DONE", { outcome: "
|
|
695
|
+
console.log(`[${ts()}] [NEWH] Session ${sessionId} → ${newSessionId} (same cwd=${cwd})`);
|
|
696
|
+
logTrace(tid, "DONE", { outcome: "newh", newSessionId, cwd });
|
|
697
697
|
return;
|
|
698
698
|
}
|
|
699
699
|
|