UNPKG

agentcrumbs

Version:
40 lines 1.22 kB
import path from "node:path"; import os from "node:os"; import { CrumbStore } from "../collector/store.js"; import { getApp } from "../env.js"; import { getFlag, hasFlag } from "./args.js"; const DEFAULT_BASE = path.join(os.homedir(), ".agentcrumbs"); export function parseAppFlags(args) { const app = getFlag(args, "--app"); const allApps = hasFlag(args, "--all-apps"); return { app, allApps }; } export function resolveApp(ctx) { if (ctx.app) return ctx.app; return getApp(); } export function getStoreForContext(ctx) { if (ctx.allApps) { // For --all-apps, callers should use readAllCrumbs instead // Return a dummy store for the current app as fallback return CrumbStore.forApp(resolveApp(ctx)); } const app = resolveApp(ctx); return CrumbStore.forApp(app); } export function readAllCrumbs(ctx) { if (ctx.allApps) { return CrumbStore.readAllApps(); } const store = getStoreForContext(ctx); return store.readAll(); } export function getStoreFilePath(ctx) { const store = getStoreForContext(ctx); return store.getFilePath(); } export function getBaseDir() { return DEFAULT_BASE; } //# sourceMappingURL=app-store.js.map