scai
Version:
> **AI-powered CLI for local code analysis, commit message suggestions, and natural-language queries.** 100% local, private, GDPR-friendly, made in Denmark/EU with ❤️.
84 lines (83 loc) • 2.62 kB
JavaScript
import os from 'os';
import path from 'path';
import fs from 'fs';
/**
* The base directory where internal SCAI config/state is stored:
* ~/.scai
*/
export const SCAI_HOME = path.join(os.homedir(), '.scai');
/**
* Repos dir for multi-repo setup
*/
export const SCAI_REPOS = path.join(SCAI_HOME, 'repos');
/**
* Path to the daemon process ID file (if running in background mode):
* ~/.scai/daemon.pid
*/
export const PID_PATH = path.join(SCAI_HOME, 'daemon.pid');
/**
* Path to the config file that stores user settings like model, language, indexDir, etc.:
* ~/.scai/config.json
*/
export const CONFIG_PATH = path.join(SCAI_HOME, 'config.json');
/**
* Path to the daemon lock file that prevents starting multiple daemons
* for different repos simultaneously:
* ~/.scai/daemon.lock
*/
export const CONFIG_LOCK_PATH = path.join(SCAI_HOME, 'daemon.lock');
/**
* Path to the daemon log file:
* ~/.scai/daemon.log
*/
export const LOG_PATH = path.join(SCAI_HOME, 'daemon.log');
/**
* Path to the last prompt sent to the model:
* ~/.scai/prompt.log
*/
export const PROMPT_LOG_PATH = path.join(SCAI_HOME, 'prompt.log');
/**
* Default sleep time for the daemon loop in milliseconds.
* This is used when no value is configured in the config file or via environment variables.
*/
export const DEFAULT_DAEMON_SLEEP_MS = 120000; // 1 minute
/**
* Default idle sleep time for the daemon loop in milliseconds.
* Used when the daemon has nothing to process and is idle.
*/
export const DEFAULT_DAEMON_IDLE_SLEEP_MS = 300000; // 5 minutes
/**
* Get the active index directory based on the active repo.
*
* - If there is an active repository, return its `indexDir` from the config.
* - If no active repo is set, default to the user's home directory (`~`).
*/
export function getIndexDir() {
try {
const config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
const activeRepo = config.activeRepo;
if (activeRepo && config.repos[activeRepo]) {
return config.repos[activeRepo].indexDir || os.homedir(); // Repo-specific indexDir or default to home
}
return os.homedir(); // Fallback to home if no active repo
}
catch (e) {
return os.homedir(); // Fallback if config file is missing or invalid
}
}
/**
* Highest ranked results
*/
export const NUM_TOPFILES = 5;
/**
* Limit for number of related files included in model prompt.
*/
export const RELATED_FILES_LIMIT = 50;
/**
* Limit number of summary lines
*/
export const MAX_SUMMARY_LINES = 12;
/**
* Limit number of function content
*/
export const MAX_FUNCTION_LINES = 12;