chatccc 0.2.11 → 0.2.13
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
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// 与 Cursor 实际跑的 Composer 2 Fast 等真实模型无关
|
|
10
10
|
//
|
|
11
11
|
// 存储:
|
|
12
|
-
// 文件
|
|
12
|
+
// 文件 state/cursor-session-meta.json,结构:
|
|
13
13
|
// { "<sessionId>": { "cwd": "...", "model": "..." } }
|
|
14
14
|
//
|
|
15
15
|
// API 设计:
|
|
@@ -28,7 +28,7 @@ import { PROJECT_ROOT } from "../config.ts";
|
|
|
28
28
|
/** 持久化文件默认路径(生产)。测试可通过 createCursorSessionMetaStore(filePath) 注入。 */
|
|
29
29
|
export const CURSOR_SESSION_META_FILE = join(
|
|
30
30
|
PROJECT_ROOT,
|
|
31
|
-
"
|
|
31
|
+
"state",
|
|
32
32
|
"cursor-session-meta.json",
|
|
33
33
|
);
|
|
34
34
|
|
|
@@ -150,5 +150,5 @@ export function createCursorSessionMetaStore(
|
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
/** 生产环境共享的全局默认实例(指向
|
|
153
|
+
/** 生产环境共享的全局默认实例(指向 state/cursor-session-meta.json)。 */
|
|
154
154
|
export const defaultCursorSessionMetaStore = createCursorSessionMetaStore();
|
package/src/config.ts
CHANGED
|
@@ -13,12 +13,12 @@ import { appendStartupTrace, setupFileLogging } from "./shared.ts";
|
|
|
13
13
|
|
|
14
14
|
export const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
15
15
|
export const PROJECT_ROOT = join(__dirname, "..");
|
|
16
|
-
export const PID_FILE = join(PROJECT_ROOT, "
|
|
16
|
+
export const PID_FILE = join(PROJECT_ROOT, "state", "runtime.pid");
|
|
17
17
|
|
|
18
18
|
export const LOG_DIR = join(PROJECT_ROOT, "logs");
|
|
19
19
|
export const fileLog = setupFileLogging(LOG_DIR, "index");
|
|
20
20
|
|
|
21
|
-
export const CHAT_LOGS_DIR = join(PROJECT_ROOT, "
|
|
21
|
+
export const CHAT_LOGS_DIR = join(PROJECT_ROOT, "state", "chat_logs");
|
|
22
22
|
|
|
23
23
|
export async function appendChatLog(chatId: string, sender: string, text: string): Promise<void> {
|
|
24
24
|
try {
|
|
@@ -144,13 +144,13 @@ export const CURSOR_AGENT_ARGS = resolveCursorAgentArgs();
|
|
|
144
144
|
|
|
145
145
|
// 新建会话的默认工作路径(/cd 命令设置,持久化到本地文件)
|
|
146
146
|
// 该路径仅影响通过 /new 新建的会话,不影响已有会话的 resume。
|
|
147
|
-
export const DEFAULT_CWD_FILE = join(PROJECT_ROOT, "
|
|
147
|
+
export const DEFAULT_CWD_FILE = join(PROJECT_ROOT, "state", "working_dir.txt");
|
|
148
148
|
|
|
149
149
|
/** 会话工具类型持久化文件 */
|
|
150
|
-
export const SESSIONS_FILE = join(PROJECT_ROOT, "
|
|
150
|
+
export const SESSIONS_FILE = join(PROJECT_ROOT, "state", "sessions.json");
|
|
151
151
|
|
|
152
152
|
/** 最近成功新建会话的工作路径记录(最多 10 条) */
|
|
153
|
-
export const RECENT_DIRS_FILE = join(PROJECT_ROOT, "
|
|
153
|
+
export const RECENT_DIRS_FILE = join(PROJECT_ROOT, "state", "recent_dirs.json");
|
|
154
154
|
export const MAX_RECENT_DIRS = 10;
|
|
155
155
|
|
|
156
156
|
/** 读取最近使用过的工作路径列表(最新的在前) */
|
package/src/index.ts
CHANGED
|
@@ -593,7 +593,7 @@ async function handleCommand(text: string, chatId: string, openId: string, msgTi
|
|
|
593
593
|
console.error(`[${ts()}] [GIT] getSessionInfo FAIL: ${(err as Error).message}`);
|
|
594
594
|
}
|
|
595
595
|
if (!cwd) {
|
|
596
|
-
// Cursor 会话的 cwd 依赖
|
|
596
|
+
// Cursor 会话的 cwd 依赖 state/cursor-session-meta.json 持久化映射;
|
|
597
597
|
// 升级前创建的旧会话或映射文件丢失时,向会话发送一次普通消息即可触发
|
|
598
598
|
// adapter 自动学习并补全(resume 流首条 init 事件携带 cwd)。
|
|
599
599
|
const isCursor = descriptionTool === "cursor";
|
package/src/session.ts
CHANGED
|
@@ -106,7 +106,7 @@ export function getAdapterForTool(tool: string): ToolAdapter {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
// ---------------------------------------------------------------------------
|
|
109
|
-
// Session tool persistence (
|
|
109
|
+
// Session tool persistence (state/sessions.json)
|
|
110
110
|
// ---------------------------------------------------------------------------
|
|
111
111
|
|
|
112
112
|
interface SessionToolRecord {
|