MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / listOnDisk

Function listOnDisk

src/workspaces/adapters/opencode.ts:225–259  ·  view source on GitHub ↗

* List opencode sessions for THIS workspace cwd, for the watcher's post-spawn * id capture. opencode stores sessions as SQLite rows (no per-cwd files), but * `opencode session list --format json` is cwd-scoped — so we shell out with * cwd set to the workspace. Hermetic env (same disables as

(cwd: string)

Source from the content-addressed store, hash-verified

223 * `--continue`.
224 */
225 async listOnDisk(cwd: string): Promise<readonly OnDiskSession[]> {
226 let stdout: string;
227 try {
228 const res = await execFileAsync('opencode', ['session', 'list', '--format', 'json'], {
229 cwd,
230 env: {
231 ...process.env,
232 OPENCODE_DISABLE_MODELS_FETCH: '1',
233 OPENCODE_DISABLE_AUTOUPDATE: '1',
234 OPENCODE_DISABLE_LSP_DOWNLOAD: '1',
235 },
236 timeout: 10_000,
237 maxBuffer: 8 * 1024 * 1024,
238 });
239 stdout = res.stdout;
240 } catch {
241 return [];
242 }
243 let rows: unknown;
244 try {
245 rows = JSON.parse(stdout);
246 } catch {
247 return [];
248 }
249 if (!Array.isArray(rows)) return [];
250 const out: OnDiskSession[] = [];
251 for (const r of rows as Array<Record<string, unknown>>) {
252 const id = r['id'];
253 if (typeof id !== 'string') continue;
254 const ts = r['updated'] ?? r['created'];
255 const mtime = typeof ts === 'number' ? new Date(ts).toISOString() : String(ts ?? '');
256 out.push({ sessionId: id, file: '', mtime, sizeBytes: 0 });
257 }
258 return out;
259 },
260};

Callers

nothing calls this directly

Calls 2

parseMethod · 0.80
pushMethod · 0.65

Tested by

no test coverage detected