-
-
Notifications
You must be signed in to change notification settings - Fork 258
Expand file tree
/
Copy pathtest-debug.ts
More file actions
36 lines (30 loc) · 1.1 KB
/
test-debug.ts
File metadata and controls
36 lines (30 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import { ProjectScanner } from './src/main/services/discovery/ProjectScanner';
async function run() {
const projectsDir = fs.mkdtempSync(path.join(os.tmpdir(), 'scanner-'));
const encodedName = '-Users-test-myproject';
const projectDir = path.join(projectsDir, encodedName);
fs.mkdirSync(projectDir);
const filePath = path.join(projectDir, 'session-timestamp-test.jsonl');
const oldDateMs = Date.now() - 30 * 24 * 60 * 60 * 1000;
const oldIsoString = new Date(oldDateMs).toISOString();
fs.writeFileSync(
filePath,
JSON.stringify({
uuid: 'test-uuid',
type: 'user',
message: { role: 'user', content: 'hello' },
timestamp: oldIsoString,
isMeta: false,
}) + '\n'
);
const nowMs = Date.now();
fs.utimesSync(filePath, new Date(nowMs), new Date(nowMs));
const scanner = new ProjectScanner(projectsDir);
const projects = await scanner.scanProject(encodedName);
const sessions = await scanner.listSessions(encodedName);
console.log(JSON.stringify(sessions, null, 2));
}
run();