Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Promptfoo Promptfoo CLI State

From Leeroopedia
Knowledge Sources
Domains CLI, State_Management
Last Updated 2026-02-14 07:45 GMT

Overview

Concrete shared mutable state object that tracks CLI runtime context including base path, configuration, resume mode, logging paths, and concurrency settings.

Description

The CLI_State module (cliState.ts) exports a single mutable state object of type CliState that serves as the cross-cutting runtime context for CLI operations. Properties include basePath (working directory), config (partial unified config), remote (force remote inference), webUI (web UI mode flag), resume and retryMode (evaluation resumption), debugLogFile/errorLogFile (log paths), and maxConcurrency (from the -j CLI flag).

Usage

Import this module to read or set CLI-wide state that needs to be shared across modules without prop drilling. It is set by the CLI command handlers and read by providers, evaluators, and other core modules.

Code Reference

Source Location

Signature

interface CliState {
  basePath?: string;
  config?: Partial<UnifiedConfig>;
  remote?: boolean;
  webUI?: boolean;
  resume?: boolean;
  retryMode?: boolean;
  _retryErrorResultIds?: string[];
  debugLogFile?: string;
  errorLogFile?: string;
  postActionCallback?: () => Promise<void>;
  maxConcurrency?: number;
}

declare const state: CliState;
export default state;

Import

import cliState from './cliState';

I/O Contract

Inputs

Name Type Required Description
(property assignment) various No Set properties directly on the state object

Outputs

Name Type Description
state CliState Mutable singleton state object

Usage Examples

import cliState from './cliState';

// Set base path from CLI
cliState.basePath = '/path/to/project';

// Check if running in web UI mode
if (cliState.webUI) {
  // Adjust behavior for web UI
}

// Read max concurrency setting
const concurrency = cliState.maxConcurrency ?? 4;

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment