Tool to send cross-session opencode messages, including as request-response pattern
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

support relative paths for dir filter - resolve to current working directory

rektide 0bfbed9d abc52478

+7 -7
+7 -7
src/session/store.ts
··· 1 1 import { readdir, readFile, access } from "node:fs/promises"; 2 - import { join } from "node:path"; 2 + import { join, resolve } from "node:path"; 3 3 import { homedir } from "node:os"; 4 4 import type { Session } from "./types.ts"; 5 5 ··· 24 24 const projectDirs = await readdir(sessionPath, { withFileTypes: true }); 25 25 const sessions: Session[] = []; 26 26 27 + const targetDir = dir ? resolve(process.cwd(), dir) : undefined; 28 + 27 29 for (const projectDir of projectDirs) { 28 30 if (!projectDir.isDirectory()) continue; 29 31 ··· 37 39 const content = await readFile(sessionFilePath, "utf-8"); 38 40 const session: Session = JSON.parse(content); 39 41 40 - if (dir && !session.directory.match(patternForDir(dir))) continue; 42 + if (targetDir) { 43 + const startsWith = session.directory.startsWith(targetDir); 44 + if (!startsWith) continue; 45 + } 41 46 42 47 sessions.push(session); 43 48 } ··· 45 50 46 51 return sessions.sort((a, b) => b.time.updated - a.time.updated); 47 52 } 48 - 49 - function patternForDir(dir: string | undefined): RegExp | undefined { 50 - if (!dir) return undefined; 51 - return new RegExp(`^${dir.replace(/\*/g, ".*").replace(/\?/g, ".")}(?:/.*)?$`); 52 - }