Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

883 B
Raw Blame
/**
 * Tracks the last known working directory from an active session.
 * Used by Settings/BuiltinToolsSection to populate the workingDir
 * for project-level tool configuration without URL plumbing.
 */

import { normalizeWorkingDirForStorage } from '../../shared/workingDir';

let _lastWorkingDir: string | null = null;
const listeners = new Set<() => void>();

export function setLastWorkingDir(dir: string | null): void {
  // Keep the active session cwd. Consumers that intentionally group managed
  // worktrees into their base repository must do so in their own scope.
  _lastWorkingDir = normalizeWorkingDirForStorage(dir);
  for (const l of listeners) l();
}

export function getLastWorkingDir(): string | null {
  return _lastWorkingDir;
}

export function subscribeToLastWorkingDir(cb: () => void): () => void {
  listeners.add(cb);
  return () => listeners.delete(cb);
}