Session-Level Conversation History Management (#1113)

This commit is contained in:
tanzhenxin
2025-12-03 18:04:48 +08:00
committed by GitHub
parent a7abd8d09f
commit 0a75d85ac9
114 changed files with 9257 additions and 4039 deletions

View File

@@ -14,6 +14,7 @@ export const GOOGLE_ACCOUNTS_FILENAME = 'google_accounts.json';
export const OAUTH_FILE = 'oauth_creds.json';
const TMP_DIR_NAME = 'tmp';
const BIN_DIR_NAME = 'bin';
const PROJECT_DIR_NAME = 'projects';
export class Storage {
private readonly targetDir: string;
@@ -66,6 +67,12 @@ export class Storage {
return path.join(this.targetDir, QWEN_DIR);
}
getProjectDir(): string {
const projectId = this.sanitizeCwd(this.getProjectRoot());
const projectsDir = path.join(Storage.getGlobalQwenDir(), PROJECT_DIR_NAME);
return path.join(projectsDir, projectId);
}
getProjectTempDir(): string {
const hash = this.getFilePathHash(this.getProjectRoot());
const tempDir = Storage.getGlobalTempDir();
@@ -117,4 +124,8 @@ export class Storage {
getHistoryFilePath(): string {
return path.join(this.getProjectTempDir(), 'shell_history');
}
private sanitizeCwd(cwd: string): string {
return cwd.replace(/[^a-zA-Z0-9]/g, '-');
}
}