UNPKG

scai

Version:

> AI-powered CLI tool for commit messages **and** pull request reviews — using local models.

68 lines (67 loc) 2.02 kB
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 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'); /** * 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 } } /** * Limit for number of related files included in model prompt. */ export const RELATED_FILES_LIMIT = 5; /** * Limit for number of candidate files to score. */ export const CANDIDATE_LIMIT = 100; /** * Limit number of summary lines */ export const MAX_SUMMARY_LINES = 12; /** * Limit number of function content */ export const MAX_FUNCTION_LINES = 12;