Merge remote-tracking branch 'origin/v0.15.0rc' into feature/bug-startup-warning-ignores-claude-oauth-credenti-fuzx

This commit is contained in:
Shirone
2026-02-15 17:37:17 +01:00
73 changed files with 6064 additions and 647 deletions

View File

@@ -30,15 +30,15 @@ const model2 = resolveModelString('haiku');
// Returns: 'claude-haiku-4-5'
const model3 = resolveModelString('opus');
// Returns: 'claude-opus-4-5-20251101'
// Returns: 'claude-opus-4-6'
// Use with custom default
const model4 = resolveModelString(undefined, 'claude-sonnet-4-20250514');
// Returns: 'claude-sonnet-4-20250514' (default)
// Direct model ID passthrough
const model5 = resolveModelString('claude-opus-4-5-20251101');
// Returns: 'claude-opus-4-5-20251101' (unchanged)
const model5 = resolveModelString('claude-opus-4-6');
// Returns: 'claude-opus-4-6' (unchanged)
```
### Get Effective Model
@@ -72,7 +72,7 @@ console.log(DEFAULT_MODELS.chat); // 'claude-sonnet-4-20250514'
// Model alias mappings
console.log(CLAUDE_MODEL_MAP.haiku); // 'claude-haiku-4-5'
console.log(CLAUDE_MODEL_MAP.sonnet); // 'claude-sonnet-4-20250514'
console.log(CLAUDE_MODEL_MAP.opus); // 'claude-opus-4-5-20251101'
console.log(CLAUDE_MODEL_MAP.opus); // 'claude-opus-4-6'
```
## Usage Example
@@ -103,7 +103,7 @@ const feature: Feature = {
};
prepareFeatureExecution(feature);
// Output: Executing feature with model: claude-opus-4-5-20251101
// Output: Executing feature with model: claude-opus-4-6
```
## Supported Models
@@ -112,7 +112,7 @@ prepareFeatureExecution(feature);
- `haiku``claude-haiku-4-5`
- `sonnet``claude-sonnet-4-20250514`
- `opus``claude-opus-4-5-20251101`
- `opus``claude-opus-4-6`
### Model Selection Guide

View File

@@ -484,12 +484,12 @@ describe('model-resolver', () => {
it('should handle full Claude model string in entry', () => {
const entry: PhaseModelEntry = {
model: 'claude-opus-4-5-20251101',
model: 'claude-opus-4-6',
thinkingLevel: 'high',
};
const result = resolvePhaseModel(entry);
expect(result.model).toBe('claude-opus-4-5-20251101');
expect(result.model).toBe('claude-opus-4-6');
expect(result.thinkingLevel).toBe('high');
});
});

View File

@@ -188,3 +188,37 @@ export {
findTerminalById,
openInExternalTerminal,
} from './terminal.js';
// RC Generator - Shell configuration file generation
export {
hexToXterm256,
getThemeANSIColors,
generateBashrc,
generateZshrc,
generateCommonFunctions,
generateThemeColors,
getShellName,
type TerminalConfig,
type TerminalTheme,
type ANSIColors,
} from './rc-generator.js';
// RC File Manager - Shell configuration file I/O
export {
RC_FILE_VERSION,
getTerminalDir,
getThemesDir,
getRcFilePath,
ensureTerminalDir,
checkRcFileVersion,
needsRegeneration,
writeAllThemeFiles,
writeThemeFile,
writeRcFiles,
ensureRcFilesUpToDate,
deleteTerminalDir,
ensureUserCustomFile,
} from './rc-file-manager.js';
// Terminal Theme Colors - Raw theme color data for all 40 themes
export { terminalThemeColors, getTerminalThemeColors } from './terminal-theme-colors.js';

View File

@@ -0,0 +1,308 @@
/**
* RC File Manager - Manage shell configuration files in .automaker/terminal/
*
* This module handles file I/O operations for generating and managing shell RC files,
* including version checking and regeneration logic.
*/
import * as fs from 'node:fs/promises';
import * as path from 'node:path';
import { createHash } from 'node:crypto';
import type { ThemeMode } from '@automaker/types';
import {
generateBashrc,
generateZshrc,
generateCommonFunctions,
generateThemeColors,
type TerminalConfig,
type TerminalTheme,
} from './rc-generator.js';
/**
* Current RC file format version
*/
export const RC_FILE_VERSION = 11;
const RC_SIGNATURE_FILENAME = 'config.sha256';
/**
* Get the terminal directory path
*/
export function getTerminalDir(projectPath: string): string {
return path.join(projectPath, '.automaker', 'terminal');
}
/**
* Get the themes directory path
*/
export function getThemesDir(projectPath: string): string {
return path.join(getTerminalDir(projectPath), 'themes');
}
/**
* Get RC file path for specific shell
*/
export function getRcFilePath(projectPath: string, shell: 'bash' | 'zsh' | 'sh'): string {
const terminalDir = getTerminalDir(projectPath);
switch (shell) {
case 'bash':
return path.join(terminalDir, 'bashrc.sh');
case 'zsh':
return path.join(terminalDir, '.zshrc'); // Zsh looks for .zshrc in ZDOTDIR
case 'sh':
return path.join(terminalDir, 'common.sh');
}
}
/**
* Ensure terminal directory exists
*/
export async function ensureTerminalDir(projectPath: string): Promise<void> {
const terminalDir = getTerminalDir(projectPath);
const themesDir = getThemesDir(projectPath);
await fs.mkdir(terminalDir, { recursive: true, mode: 0o755 });
await fs.mkdir(themesDir, { recursive: true, mode: 0o755 });
}
/**
* Write RC file with atomic write (write to temp, then rename)
*/
async function atomicWriteFile(
filePath: string,
content: string,
mode: number = 0o644
): Promise<void> {
const tempPath = `${filePath}.tmp`;
await fs.writeFile(tempPath, content, { encoding: 'utf8', mode });
await fs.rename(tempPath, filePath);
}
function sortObjectKeys(value: unknown): unknown {
if (Array.isArray(value)) {
return value.map((item) => sortObjectKeys(item));
}
if (value && typeof value === 'object') {
const sortedEntries = Object.entries(value as Record<string, unknown>)
.filter(([, entryValue]) => entryValue !== undefined)
.sort(([left], [right]) => left.localeCompare(right));
const sortedObject: Record<string, unknown> = {};
for (const [key, entryValue] of sortedEntries) {
sortedObject[key] = sortObjectKeys(entryValue);
}
return sortedObject;
}
return value;
}
function buildConfigSignature(theme: ThemeMode, config: TerminalConfig): string {
const payload = { theme, config: sortObjectKeys(config) };
const serializedPayload = JSON.stringify(payload);
return createHash('sha256').update(serializedPayload).digest('hex');
}
async function readSignatureFile(projectPath: string): Promise<string | null> {
const signaturePath = path.join(getTerminalDir(projectPath), RC_SIGNATURE_FILENAME);
try {
const signature = await fs.readFile(signaturePath, 'utf8');
return signature.trim() || null;
} catch {
return null;
}
}
async function writeSignatureFile(projectPath: string, signature: string): Promise<void> {
const signaturePath = path.join(getTerminalDir(projectPath), RC_SIGNATURE_FILENAME);
await atomicWriteFile(signaturePath, `${signature}\n`, 0o644);
}
/**
* Check current RC file version
*/
export async function checkRcFileVersion(projectPath: string): Promise<number | null> {
const versionPath = path.join(getTerminalDir(projectPath), 'version.txt');
try {
const content = await fs.readFile(versionPath, 'utf8');
const version = parseInt(content.trim(), 10);
return isNaN(version) ? null : version;
} catch (error) {
return null; // File doesn't exist or can't be read
}
}
/**
* Write version file
*/
async function writeVersionFile(projectPath: string, version: number): Promise<void> {
const versionPath = path.join(getTerminalDir(projectPath), 'version.txt');
await atomicWriteFile(versionPath, `${version}\n`, 0o644);
}
/**
* Check if RC files need regeneration
*/
export async function needsRegeneration(
projectPath: string,
theme: ThemeMode,
config: TerminalConfig
): Promise<boolean> {
const currentVersion = await checkRcFileVersion(projectPath);
// Regenerate if version doesn't match or files don't exist
if (currentVersion !== RC_FILE_VERSION) {
return true;
}
const expectedSignature = buildConfigSignature(theme, config);
const existingSignature = await readSignatureFile(projectPath);
if (!existingSignature || existingSignature !== expectedSignature) {
return true;
}
// Check if critical files exist
const bashrcPath = getRcFilePath(projectPath, 'bash');
const zshrcPath = getRcFilePath(projectPath, 'zsh');
const commonPath = path.join(getTerminalDir(projectPath), 'common.sh');
const themeFilePath = path.join(getThemesDir(projectPath), `${theme}.sh`);
try {
await Promise.all([
fs.access(bashrcPath),
fs.access(zshrcPath),
fs.access(commonPath),
fs.access(themeFilePath),
]);
return false; // All files exist
} catch {
return true; // Some files are missing
}
}
/**
* Write all theme color files (all 40 themes)
*/
export async function writeAllThemeFiles(
projectPath: string,
terminalThemes: Record<ThemeMode, TerminalTheme>
): Promise<void> {
const themesDir = getThemesDir(projectPath);
await fs.mkdir(themesDir, { recursive: true, mode: 0o755 });
const themeEntries = Object.entries(terminalThemes);
await Promise.all(
themeEntries.map(async ([themeName, theme]) => {
const themeFilePath = path.join(themesDir, `${themeName}.sh`);
const content = generateThemeColors(theme);
await atomicWriteFile(themeFilePath, content, 0o644);
})
);
}
/**
* Write a single theme color file
*/
export async function writeThemeFile(
projectPath: string,
theme: ThemeMode,
themeColors: TerminalTheme
): Promise<void> {
const themesDir = getThemesDir(projectPath);
await fs.mkdir(themesDir, { recursive: true, mode: 0o755 });
const themeFilePath = path.join(themesDir, `${theme}.sh`);
const content = generateThemeColors(themeColors);
await atomicWriteFile(themeFilePath, content, 0o644);
}
/**
* Write all RC files
*/
export async function writeRcFiles(
projectPath: string,
theme: ThemeMode,
config: TerminalConfig,
themeColors: TerminalTheme,
allThemes: Record<ThemeMode, TerminalTheme>
): Promise<void> {
await ensureTerminalDir(projectPath);
// Write common functions file
const commonPath = path.join(getTerminalDir(projectPath), 'common.sh');
const commonContent = generateCommonFunctions(config);
await atomicWriteFile(commonPath, commonContent, 0o644);
// Write bashrc
const bashrcPath = getRcFilePath(projectPath, 'bash');
const bashrcContent = generateBashrc(themeColors, config);
await atomicWriteFile(bashrcPath, bashrcContent, 0o644);
// Write zshrc
const zshrcPath = getRcFilePath(projectPath, 'zsh');
const zshrcContent = generateZshrc(themeColors, config);
await atomicWriteFile(zshrcPath, zshrcContent, 0o644);
// Write all theme files (40 themes)
await writeAllThemeFiles(projectPath, allThemes);
// Write version file
await writeVersionFile(projectPath, RC_FILE_VERSION);
// Write config signature for change detection
const signature = buildConfigSignature(theme, config);
await writeSignatureFile(projectPath, signature);
}
/**
* Ensure RC files are up to date
*/
export async function ensureRcFilesUpToDate(
projectPath: string,
theme: ThemeMode,
config: TerminalConfig,
themeColors: TerminalTheme,
allThemes: Record<ThemeMode, TerminalTheme>
): Promise<void> {
const needsRegen = await needsRegeneration(projectPath, theme, config);
if (needsRegen) {
await writeRcFiles(projectPath, theme, config, themeColors, allThemes);
}
}
/**
* Delete terminal directory (for disable flow)
*/
export async function deleteTerminalDir(projectPath: string): Promise<void> {
const terminalDir = getTerminalDir(projectPath);
try {
await fs.rm(terminalDir, { recursive: true, force: true });
} catch (error) {
// Ignore errors if directory doesn't exist
}
}
/**
* Create user-custom.sh placeholder if it doesn't exist
*/
export async function ensureUserCustomFile(projectPath: string): Promise<void> {
const userCustomPath = path.join(getTerminalDir(projectPath), 'user-custom.sh');
try {
await fs.access(userCustomPath);
} catch {
// File doesn't exist, create it
const content = `#!/bin/sh
# Automaker User Customizations
# Add your custom shell configuration here
# This file will not be overwritten by Automaker
# Example: Add custom aliases
# alias myalias='command'
# Example: Add custom environment variables
# export MY_VAR="value"
`;
await atomicWriteFile(userCustomPath, content, 0o644);
}
}

View File

@@ -0,0 +1,972 @@
/**
* RC Generator - Generate shell configuration files for custom terminal prompts
*
* This module generates bash/zsh/sh configuration files that sync with Automaker's themes,
* providing custom prompts with theme-matched colors while preserving user's existing RC files.
*/
import type { ThemeMode } from '@automaker/types';
/**
* Terminal configuration options
*/
export interface TerminalConfig {
enabled: boolean;
customPrompt: boolean;
promptFormat: 'standard' | 'minimal' | 'powerline' | 'starship';
showGitBranch: boolean;
showGitStatus: boolean;
showUserHost: boolean;
showPath: boolean;
pathStyle: 'full' | 'short' | 'basename';
pathDepth: number;
showTime: boolean;
showExitStatus: boolean;
customAliases: string;
customEnvVars: Record<string, string>;
rcFileVersion?: number;
}
/**
* Terminal theme colors (hex values)
*/
export interface TerminalTheme {
background: string;
foreground: string;
cursor: string;
cursorAccent: string;
selectionBackground: string;
selectionForeground?: string;
black: string;
red: string;
green: string;
yellow: string;
blue: string;
magenta: string;
cyan: string;
white: string;
brightBlack: string;
brightRed: string;
brightGreen: string;
brightYellow: string;
brightBlue: string;
brightMagenta: string;
brightCyan: string;
brightWhite: string;
}
/**
* ANSI color codes for shell prompts
*/
export interface ANSIColors {
user: string;
host: string;
path: string;
gitBranch: string;
gitDirty: string;
prompt: string;
reset: string;
}
const STARTUP_COLOR_PRIMARY = 51;
const STARTUP_COLOR_SECONDARY = 39;
const STARTUP_COLOR_ACCENT = 33;
const DEFAULT_PATH_DEPTH = 0;
const DEFAULT_PATH_STYLE: TerminalConfig['pathStyle'] = 'full';
const OMP_THEME_ENV_VAR = 'AUTOMAKER_OMP_THEME';
const OMP_BINARY = 'oh-my-posh';
const OMP_SHELL_BASH = 'bash';
const OMP_SHELL_ZSH = 'zsh';
/**
* Convert hex color to RGB
*/
function hexToRgb(hex: string): { r: number; g: number; b: number } {
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
if (!result) {
throw new Error(`Invalid hex color: ${hex}`);
}
return {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16),
};
}
/**
* Calculate Euclidean distance between two RGB colors
*/
function colorDistance(
c1: { r: number; g: number; b: number },
c2: { r: number; g: number; b: number }
): number {
return Math.sqrt(Math.pow(c1.r - c2.r, 2) + Math.pow(c1.g - c2.g, 2) + Math.pow(c1.b - c2.b, 2));
}
/**
* xterm-256 color palette (simplified - standard colors + 6x6x6 RGB cube + grayscale)
*/
const XTERM_256_PALETTE: Array<{ r: number; g: number; b: number }> = [];
// Standard colors (0-15) - already handled by ANSI basic colors
// RGB cube (16-231): 6x6x6 cube with levels 0, 95, 135, 175, 215, 255
const levels = [0, 95, 135, 175, 215, 255];
for (let r = 0; r < 6; r++) {
for (let g = 0; g < 6; g++) {
for (let b = 0; b < 6; b++) {
XTERM_256_PALETTE.push({ r: levels[r], g: levels[g], b: levels[b] });
}
}
}
// Grayscale (232-255): 24 shades from #080808 to #eeeeee
for (let i = 0; i < 24; i++) {
const gray = 8 + i * 10;
XTERM_256_PALETTE.push({ r: gray, g: gray, b: gray });
}
/**
* Convert hex color to closest xterm-256 color code
*/
export function hexToXterm256(hex: string): number {
const rgb = hexToRgb(hex);
let closestIndex = 16; // Start from RGB cube
let minDistance = Infinity;
XTERM_256_PALETTE.forEach((color, index) => {
const distance = colorDistance(rgb, color);
if (distance < minDistance) {
minDistance = distance;
closestIndex = index + 16; // Offset by 16 (standard colors)
}
});
return closestIndex;
}
/**
* Get ANSI color codes from theme colors
*/
export function getThemeANSIColors(theme: TerminalTheme): ANSIColors {
return {
user: `\\[\\e[38;5;${hexToXterm256(theme.cyan)}m\\]`,
host: `\\[\\e[38;5;${hexToXterm256(theme.blue)}m\\]`,
path: `\\[\\e[38;5;${hexToXterm256(theme.yellow)}m\\]`,
gitBranch: `\\[\\e[38;5;${hexToXterm256(theme.magenta)}m\\]`,
gitDirty: `\\[\\e[38;5;${hexToXterm256(theme.red)}m\\]`,
prompt: `\\[\\e[38;5;${hexToXterm256(theme.green)}m\\]`,
reset: '\\[\\e[0m\\]',
};
}
/**
* Escape shell special characters in user input
*/
function shellEscape(str: string): string {
return str.replace(/([`$\\"])/g, '\\$1');
}
/**
* Validate environment variable name
*/
function isValidEnvVarName(name: string): boolean {
return /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name);
}
function stripPromptEscapes(ansiColor: string): string {
return ansiColor.replace(/\\\[/g, '').replace(/\\\]/g, '');
}
function normalizePathStyle(
pathStyle: TerminalConfig['pathStyle'] | undefined
): TerminalConfig['pathStyle'] {
if (pathStyle === 'short' || pathStyle === 'basename') {
return pathStyle;
}
return DEFAULT_PATH_STYLE;
}
function normalizePathDepth(pathDepth: number | undefined): number {
const depth =
typeof pathDepth === 'number' && Number.isFinite(pathDepth) ? pathDepth : DEFAULT_PATH_DEPTH;
return Math.max(DEFAULT_PATH_DEPTH, Math.floor(depth));
}
function generateOhMyPoshInit(
shell: typeof OMP_SHELL_BASH | typeof OMP_SHELL_ZSH,
fallback: string
) {
const themeVar = `$${OMP_THEME_ENV_VAR}`;
const initCommand = `${OMP_BINARY} init ${shell} --config`;
return `if [ -n "${themeVar}" ] && command -v ${OMP_BINARY} >/dev/null 2>&1; then
automaker_omp_theme="$(automaker_resolve_omp_theme)"
if [ -n "$automaker_omp_theme" ]; then
eval "$(${initCommand} "$automaker_omp_theme")"
else
${fallback}
fi
else
${fallback}
fi`;
}
/**
* Generate common shell functions (git prompt, etc.)
*/
export function generateCommonFunctions(config: TerminalConfig): string {
const gitPrompt = config.showGitBranch
? `
automaker_git_prompt() {
local branch=""
local dirty=""
# Check if we're in a git repository
if git rev-parse --git-dir > /dev/null 2>&1; then
# Get current branch name
branch=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
${
config.showGitStatus
? `
# Check if working directory is dirty
if [ -n "$(git status --porcelain 2>/dev/null)" ]; then
dirty="*"
fi
`
: ''
}
if [ -n "$branch" ]; then
echo -n " ($branch$dirty)"
fi
fi
}
`
: `
automaker_git_prompt() {
# Git prompt disabled
echo -n ""
}
`;
return `#!/bin/sh
# Automaker Terminal Configuration - Common Functions v1.0
${gitPrompt}
AUTOMAKER_INFO_UNKNOWN="Unknown"
AUTOMAKER_BANNER_LABEL_WIDTH=12
AUTOMAKER_BYTES_PER_KIB=1024
AUTOMAKER_KIB_PER_MIB=1024
AUTOMAKER_MIB_PER_GIB=1024
AUTOMAKER_COLOR_PRIMARY="\\033[38;5;${STARTUP_COLOR_PRIMARY}m"
AUTOMAKER_COLOR_SECONDARY="\\033[38;5;${STARTUP_COLOR_SECONDARY}m"
AUTOMAKER_COLOR_ACCENT="\\033[38;5;${STARTUP_COLOR_ACCENT}m"
AUTOMAKER_COLOR_RESET="\\033[0m"
AUTOMAKER_SHOW_TIME="${config.showTime === true ? 'true' : 'false'}"
AUTOMAKER_SHOW_EXIT_STATUS="${config.showExitStatus === true ? 'true' : 'false'}"
AUTOMAKER_SHOW_USER_HOST="${config.showUserHost === false ? 'false' : 'true'}"
AUTOMAKER_SHOW_PATH="${config.showPath === false ? 'false' : 'true'}"
AUTOMAKER_PATH_STYLE="${normalizePathStyle(config.pathStyle)}"
AUTOMAKER_PATH_DEPTH=${normalizePathDepth(config.pathDepth)}
automaker_default_themes_dir="\${XDG_DATA_HOME:-\$HOME/.local/share}/oh-my-posh/themes"
if [ -z "$POSH_THEMES_PATH" ] || [ ! -d "$POSH_THEMES_PATH" ]; then
POSH_THEMES_PATH="$automaker_default_themes_dir"
fi
export POSH_THEMES_PATH
automaker_resolve_omp_theme() {
automaker_theme_name="$AUTOMAKER_OMP_THEME"
if [ -z "$automaker_theme_name" ]; then
return 1
fi
if [ -f "$automaker_theme_name" ]; then
printf '%s' "$automaker_theme_name"
return 0
fi
automaker_themes_base="\${POSH_THEMES_PATH%/}"
if [ -n "$automaker_themes_base" ]; then
if [ -f "$automaker_themes_base/$automaker_theme_name.omp.json" ]; then
printf '%s' "$automaker_themes_base/$automaker_theme_name.omp.json"
return 0
fi
if [ -f "$automaker_themes_base/$automaker_theme_name.omp.yaml" ]; then
printf '%s' "$automaker_themes_base/$automaker_theme_name.omp.yaml"
return 0
fi
fi
return 1
}
automaker_command_exists() {
command -v "$1" >/dev/null 2>&1
}
automaker_get_os() {
if [ -f /etc/os-release ]; then
. /etc/os-release
if [ -n "$PRETTY_NAME" ]; then
echo "$PRETTY_NAME"
return
fi
if [ -n "$NAME" ] && [ -n "$VERSION" ]; then
echo "$NAME $VERSION"
return
fi
fi
if automaker_command_exists sw_vers; then
echo "$(sw_vers -productName) $(sw_vers -productVersion)"
return
fi
uname -s 2>/dev/null || echo "$AUTOMAKER_INFO_UNKNOWN"
}
automaker_get_uptime() {
if automaker_command_exists uptime; then
if uptime -p >/dev/null 2>&1; then
uptime -p
return
fi
uptime 2>/dev/null | sed 's/.*up \\([^,]*\\).*/\\1/' || uptime 2>/dev/null
return
fi
echo "$AUTOMAKER_INFO_UNKNOWN"
}
automaker_get_cpu() {
if automaker_command_exists lscpu; then
lscpu | sed -n 's/Model name:[[:space:]]*//p' | head -n 1
return
fi
if automaker_command_exists sysctl; then
sysctl -n machdep.cpu.brand_string 2>/dev/null || sysctl -n hw.model 2>/dev/null
return
fi
uname -m 2>/dev/null || echo "$AUTOMAKER_INFO_UNKNOWN"
}
automaker_get_memory() {
if automaker_command_exists free; then
free -h | awk '/Mem:/ {print $3 " / " $2}'
return
fi
if automaker_command_exists vm_stat; then
local page_size
local pages_free
local pages_active
local pages_inactive
local pages_wired
local pages_total
page_size=$(vm_stat | awk '/page size of/ {print $8}')
pages_free=$(vm_stat | awk '/Pages free/ {print $3}' | tr -d '.')
pages_active=$(vm_stat | awk '/Pages active/ {print $3}' | tr -d '.')
pages_inactive=$(vm_stat | awk '/Pages inactive/ {print $3}' | tr -d '.')
pages_wired=$(vm_stat | awk '/Pages wired down/ {print $4}' | tr -d '.')
pages_total=$((pages_free + pages_active + pages_inactive + pages_wired))
awk -v total="$pages_total" -v free="$pages_free" -v size="$page_size" \
-v bytes_kib="$AUTOMAKER_BYTES_PER_KIB" \
-v kib_mib="$AUTOMAKER_KIB_PER_MIB" \
-v mib_gib="$AUTOMAKER_MIB_PER_GIB" \
'BEGIN {
total_gb = total * size / bytes_kib / kib_mib / mib_gib;
used_gb = (total - free) * size / bytes_kib / kib_mib / mib_gib;
printf("%.1f GB / %.1f GB", used_gb, total_gb);
}'
return
fi
if automaker_command_exists sysctl; then
local total_bytes
total_bytes=$(sysctl -n hw.memsize 2>/dev/null)
if [ -n "$total_bytes" ]; then
awk -v total="$total_bytes" \
-v bytes_kib="$AUTOMAKER_BYTES_PER_KIB" \
-v kib_mib="$AUTOMAKER_KIB_PER_MIB" \
-v mib_gib="$AUTOMAKER_MIB_PER_GIB" \
'BEGIN {printf("%.1f GB", total / bytes_kib / kib_mib / mib_gib)}'
return
fi
fi
echo "$AUTOMAKER_INFO_UNKNOWN"
}
automaker_get_disk() {
if automaker_command_exists df; then
df -h / 2>/dev/null | awk 'NR==2 {print $3 " / " $2}'
return
fi
echo "$AUTOMAKER_INFO_UNKNOWN"
}
automaker_get_ip() {
if automaker_command_exists hostname; then
local ip_addr
ip_addr=$(hostname -I 2>/dev/null | awk '{print $1}')
if [ -n "$ip_addr" ]; then
echo "$ip_addr"
return
fi
fi
if automaker_command_exists ipconfig; then
local ip_addr
ip_addr=$(ipconfig getifaddr en0 2>/dev/null)
if [ -n "$ip_addr" ]; then
echo "$ip_addr"
return
fi
fi
echo "$AUTOMAKER_INFO_UNKNOWN"
}
automaker_trim_path_depth() {
local path="$1"
local depth="$2"
if [ -z "$depth" ] || [ "$depth" -le 0 ]; then
echo "$path"
return
fi
echo "$path" | awk -v depth="$depth" -F/ '{
prefix=""
start=1
if ($1=="") { prefix="/"; start=2 }
else if ($1=="~") { prefix="~/"; start=2 }
n=NF
if (n < start) {
if (prefix=="/") { print "/" }
else if (prefix=="~/") { print "~" }
else { print $0 }
next
}
segCount = n - start + 1
d = depth
if (d > segCount) { d = segCount }
out=""
for (i = n - d + 1; i <= n; i++) {
out = out (out=="" ? "" : "/") $i
}
if (prefix=="/") {
if (out=="") { out="/" } else { out="/" out }
} else if (prefix=="~/") {
if (out=="") { out="~" } else { out="~/" out }
}
print out
}'
}
automaker_shorten_path() {
local path="$1"
echo "$path" | awk -F/ '{
prefix=""
start=1
if ($1=="") { prefix="/"; start=2 }
else if ($1=="~") { prefix="~/"; start=2 }
n=NF
if (n < start) {
if (prefix=="/") { print "/" }
else if (prefix=="~/") { print "~" }
else { print $0 }
next
}
out=""
for (i = start; i <= n; i++) {
seg = $i
if (i < n && length(seg) > 0) { seg = substr(seg, 1, 1) }
out = out (out=="" ? "" : "/") seg
}
if (prefix=="/") { out="/" out }
else if (prefix=="~/") { out="~/" out }
print out
}'
}
automaker_prompt_path() {
if [ "$AUTOMAKER_SHOW_PATH" != "true" ]; then
return
fi
local current_path="$PWD"
if [ -n "$HOME" ] && [ "\${current_path#"$HOME"}" != "$current_path" ]; then
current_path="~\${current_path#$HOME}"
fi
if [ "$AUTOMAKER_PATH_DEPTH" -gt 0 ]; then
current_path=$(automaker_trim_path_depth "$current_path" "$AUTOMAKER_PATH_DEPTH")
fi
case "$AUTOMAKER_PATH_STYLE" in
basename)
if [ "$current_path" = "/" ] || [ "$current_path" = "~" ]; then
echo -n "$current_path"
else
echo -n "\${current_path##*/}"
fi
;;
short)
echo -n "$(automaker_shorten_path "$current_path")"
;;
full|*)
echo -n "$current_path"
;;
esac
}
automaker_prompt_time() {
if [ "$AUTOMAKER_SHOW_TIME" != "true" ]; then
return
fi
date +%H:%M
}
automaker_prompt_status() {
automaker_last_status=$?
if [ "$AUTOMAKER_SHOW_EXIT_STATUS" != "true" ]; then
return
fi
if [ "$automaker_last_status" -eq 0 ]; then
return
fi
printf "✗ %s" "$automaker_last_status"
}
automaker_show_banner() {
local label_width="$AUTOMAKER_BANNER_LABEL_WIDTH"
local logo_line_1=" █▀▀█ █ █ ▀▀█▀▀ █▀▀█ █▀▄▀█ █▀▀█ █ █ █▀▀ █▀▀█ "
local logo_line_2=" █▄▄█ █ █ █ █ █ █ ▀ █ █▄▄█ █▀▄ █▀▀ █▄▄▀ "
local logo_line_3=" ▀ ▀ ▀▀▀ ▀ ▀▀▀▀ ▀ ▀ ▀ ▀ ▀ ▀ ▀▀▀ ▀ ▀▀ "
local accent_color="\${AUTOMAKER_COLOR_PRIMARY}"
local secondary_color="\${AUTOMAKER_COLOR_SECONDARY}"
local tertiary_color="\${AUTOMAKER_COLOR_ACCENT}"
local label_color="\${AUTOMAKER_COLOR_SECONDARY}"
local reset_color="\${AUTOMAKER_COLOR_RESET}"
printf "%b%s%b\n" "$accent_color" "$logo_line_1" "$reset_color"
printf "%b%s%b\n" "$secondary_color" "$logo_line_2" "$reset_color"
printf "%b%s%b\n" "$tertiary_color" "$logo_line_3" "$reset_color"
printf "\n"
local shell_name="\${SHELL##*/}"
if [ -z "$shell_name" ]; then
shell_name=$(basename "$0" 2>/dev/null || echo "shell")
fi
local user_host="\${USER:-unknown}@$(hostname 2>/dev/null || echo unknown)"
printf "%b%s%b\n" "$label_color" "$user_host" "$reset_color"
printf "%b%-\${label_width}s%b %s\n" "$label_color" "OS:" "$reset_color" "$(automaker_get_os)"
printf "%b%-\${label_width}s%b %s\n" "$label_color" "Uptime:" "$reset_color" "$(automaker_get_uptime)"
printf "%b%-\${label_width}s%b %s\n" "$label_color" "Shell:" "$reset_color" "$shell_name"
printf "%b%-\${label_width}s%b %s\n" "$label_color" "Terminal:" "$reset_color" "\${TERM_PROGRAM:-$TERM}"
printf "%b%-\${label_width}s%b %s\n" "$label_color" "CPU:" "$reset_color" "$(automaker_get_cpu)"
printf "%b%-\${label_width}s%b %s\n" "$label_color" "Memory:" "$reset_color" "$(automaker_get_memory)"
printf "%b%-\${label_width}s%b %s\n" "$label_color" "Disk:" "$reset_color" "$(automaker_get_disk)"
printf "%b%-\${label_width}s%b %s\n" "$label_color" "Local IP:" "$reset_color" "$(automaker_get_ip)"
printf "\n"
}
automaker_show_banner_once() {
case "$-" in
*i*) ;;
*) return ;;
esac
if [ "$AUTOMAKER_BANNER_SHOWN" = "true" ]; then
return
fi
automaker_show_banner
export AUTOMAKER_BANNER_SHOWN="true"
}
`;
}
/**
* Generate prompt based on format
*/
function generatePrompt(
format: TerminalConfig['promptFormat'],
colors: ANSIColors,
config: TerminalConfig
): string {
const userHostSegment = config.showUserHost
? `${colors.user}\\u${colors.reset}@${colors.host}\\h${colors.reset}`
: '';
const pathSegment = config.showPath
? `${colors.path}\\$(automaker_prompt_path)${colors.reset}`
: '';
const gitSegment = config.showGitBranch
? `${colors.gitBranch}\\$(automaker_git_prompt)${colors.reset}`
: '';
const timeSegment = config.showTime
? `${colors.gitBranch}[\\$(automaker_prompt_time)]${colors.reset}`
: '';
const statusSegment = config.showExitStatus
? `${colors.gitDirty}\\$(automaker_prompt_status)${colors.reset}`
: '';
switch (format) {
case 'minimal': {
const minimalSegments = [timeSegment, userHostSegment, pathSegment, gitSegment, statusSegment]
.filter((segment) => segment.length > 0)
.join(' ');
return `PS1="${minimalSegments ? `${minimalSegments} ` : ''}${colors.prompt}\\$${colors.reset} "`;
}
case 'powerline': {
const powerlineCoreSegments = [
userHostSegment ? `[${userHostSegment}]` : '',
pathSegment ? `[${pathSegment}]` : '',
].filter((segment) => segment.length > 0);
const powerlineCore = powerlineCoreSegments.join('─');
const powerlineExtras = [gitSegment, timeSegment, statusSegment]
.filter((segment) => segment.length > 0)
.join(' ');
const powerlineLine = [powerlineCore, powerlineExtras]
.filter((segment) => segment.length > 0)
.join(' ');
return `PS1="┌─${powerlineLine}\\n└─${colors.prompt}\\$${colors.reset} "`;
}
case 'starship': {
let starshipLine = '';
if (userHostSegment && pathSegment) {
starshipLine = `${userHostSegment} in ${pathSegment}`;
} else {
starshipLine = [userHostSegment, pathSegment]
.filter((segment) => segment.length > 0)
.join(' ');
}
if (gitSegment) {
starshipLine = `${starshipLine}${starshipLine ? ' on ' : ''}${gitSegment}`;
}
const starshipSegments = [timeSegment, starshipLine, statusSegment]
.filter((segment) => segment.length > 0)
.join(' ');
return `PS1="${starshipSegments}\\n${colors.prompt}${colors.reset} "`;
}
case 'standard':
default: {
const standardSegments = [
timeSegment,
userHostSegment ? `[${userHostSegment}]` : '',
pathSegment,
gitSegment,
statusSegment,
]
.filter((segment) => segment.length > 0)
.join(' ');
return `PS1="${standardSegments ? `${standardSegments} ` : ''}${colors.prompt}\\$${colors.reset} "`;
}
}
}
/**
* Generate Zsh prompt based on format
*/
function generateZshPrompt(
format: TerminalConfig['promptFormat'],
colors: ANSIColors,
config: TerminalConfig
): string {
// Convert bash-style \u, \h, \w to zsh-style %n, %m, %~
// Remove bash-style escaping \[ \] (not needed in zsh)
const zshColors = {
user: colors.user
.replace(/\\[\[\]\\e]/g, '')
.replace(/\\e/g, '%{')
.replace(/m\\]/g, 'm%}'),
host: colors.host
.replace(/\\[\[\]\\e]/g, '')
.replace(/\\e/g, '%{')
.replace(/m\\]/g, 'm%}'),
path: colors.path
.replace(/\\[\[\]\\e]/g, '')
.replace(/\\e/g, '%{')
.replace(/m\\]/g, 'm%}'),
gitBranch: colors.gitBranch
.replace(/\\[\[\]\\e]/g, '')
.replace(/\\e/g, '%{')
.replace(/m\\]/g, 'm%}'),
gitDirty: colors.gitDirty
.replace(/\\[\[\]\\e]/g, '')
.replace(/\\e/g, '%{')
.replace(/m\\]/g, 'm%}'),
prompt: colors.prompt
.replace(/\\[\[\]\\e]/g, '')
.replace(/\\e/g, '%{')
.replace(/m\\]/g, 'm%}'),
reset: colors.reset
.replace(/\\[\[\]\\e]/g, '')
.replace(/\\e/g, '%{')
.replace(/m\\]/g, 'm%}'),
};
const userHostSegment = config.showUserHost
? `[${zshColors.user}%n${zshColors.reset}@${zshColors.host}%m${zshColors.reset}]`
: '';
const pathSegment = config.showPath
? `${zshColors.path}$(automaker_prompt_path)${zshColors.reset}`
: '';
const gitSegment = config.showGitBranch
? `${zshColors.gitBranch}$(automaker_git_prompt)${zshColors.reset}`
: '';
const timeSegment = config.showTime
? `${zshColors.gitBranch}[$(automaker_prompt_time)]${zshColors.reset}`
: '';
const statusSegment = config.showExitStatus
? `${zshColors.gitDirty}$(automaker_prompt_status)${zshColors.reset}`
: '';
const segments = [timeSegment, userHostSegment, pathSegment, gitSegment, statusSegment].filter(
(segment) => segment.length > 0
);
const inlineSegments = segments.join(' ');
const inlineWithSpace = inlineSegments ? `${inlineSegments} ` : '';
switch (format) {
case 'minimal': {
return `PROMPT="${inlineWithSpace}${zshColors.prompt}%#${zshColors.reset} "`;
}
case 'powerline': {
const powerlineCoreSegments = [
userHostSegment ? `[${userHostSegment}]` : '',
pathSegment ? `[${pathSegment}]` : '',
].filter((segment) => segment.length > 0);
const powerlineCore = powerlineCoreSegments.join('─');
const powerlineExtras = [gitSegment, timeSegment, statusSegment]
.filter((segment) => segment.length > 0)
.join(' ');
const powerlineLine = [powerlineCore, powerlineExtras]
.filter((segment) => segment.length > 0)
.join(' ');
return `PROMPT="┌─${powerlineLine}
└─${zshColors.prompt}%#${zshColors.reset} "`;
}
case 'starship': {
let starshipLine = '';
if (userHostSegment && pathSegment) {
starshipLine = `${userHostSegment} in ${pathSegment}`;
} else {
starshipLine = [userHostSegment, pathSegment]
.filter((segment) => segment.length > 0)
.join(' ');
}
if (gitSegment) {
starshipLine = `${starshipLine}${starshipLine ? ' on ' : ''}${gitSegment}`;
}
const starshipSegments = [timeSegment, starshipLine, statusSegment]
.filter((segment) => segment.length > 0)
.join(' ');
return `PROMPT="${starshipSegments}
${zshColors.prompt}${zshColors.reset} "`;
}
case 'standard':
default: {
const standardSegments = [
timeSegment,
userHostSegment ? `[${userHostSegment}]` : '',
pathSegment,
gitSegment,
statusSegment,
]
.filter((segment) => segment.length > 0)
.join(' ');
return `PROMPT="${standardSegments ? `${standardSegments} ` : ''}${zshColors.prompt}%#${zshColors.reset} "`;
}
}
}
/**
* Generate custom aliases section
*/
function generateAliases(config: TerminalConfig): string {
if (!config.customAliases) return '';
// Escape and validate aliases
const escapedAliases = shellEscape(config.customAliases);
return `
# Custom aliases
${escapedAliases}
`;
}
/**
* Generate custom environment variables section
*/
function generateEnvVars(config: TerminalConfig): string {
if (!config.customEnvVars || Object.keys(config.customEnvVars).length === 0) {
return '';
}
const validEnvVars = Object.entries(config.customEnvVars)
.filter(([name]) => isValidEnvVarName(name))
.map(([name, value]) => `export ${name}="${shellEscape(value)}"`)
.join('\n');
return validEnvVars
? `
# Custom environment variables
${validEnvVars}
`
: '';
}
/**
* Generate bashrc configuration
*/
export function generateBashrc(theme: TerminalTheme, config: TerminalConfig): string {
const colors = getThemeANSIColors(theme);
const promptLine = generatePrompt(config.promptFormat, colors, config);
const promptInitializer = generateOhMyPoshInit(OMP_SHELL_BASH, promptLine);
return `#!/bin/bash
# Automaker Terminal Configuration v1.0
# This file is automatically generated - manual edits will be overwritten
# Source user's original bashrc first (preserves user configuration)
if [ -f "$HOME/.bashrc" ]; then
source "$HOME/.bashrc"
fi
# Load Automaker theme colors
AUTOMAKER_THEME="\${AUTOMAKER_THEME:-dark}"
if [ -f "\${BASH_SOURCE%/*}/themes/$AUTOMAKER_THEME.sh" ]; then
source "\${BASH_SOURCE%/*}/themes/$AUTOMAKER_THEME.sh"
fi
# Load common functions (git prompt)
if [ -f "\${BASH_SOURCE%/*}/common.sh" ]; then
source "\${BASH_SOURCE%/*}/common.sh"
fi
# Show Automaker banner on shell start
if command -v automaker_show_banner_once >/dev/null 2>&1; then
automaker_show_banner_once
fi
# Set custom prompt (only if enabled)
if [ "$AUTOMAKER_CUSTOM_PROMPT" = "true" ]; then
${promptInitializer}
fi
${generateAliases(config)}${generateEnvVars(config)}
# Load user customizations (if exists)
if [ -f "\${BASH_SOURCE%/*}/user-custom.sh" ]; then
source "\${BASH_SOURCE%/*}/user-custom.sh"
fi
`;
}
/**
* Generate zshrc configuration
*/
export function generateZshrc(theme: TerminalTheme, config: TerminalConfig): string {
const colors = getThemeANSIColors(theme);
const promptLine = generateZshPrompt(config.promptFormat, colors, config);
const promptInitializer = generateOhMyPoshInit(OMP_SHELL_ZSH, promptLine);
return `#!/bin/zsh
# Automaker Terminal Configuration v1.0
# This file is automatically generated - manual edits will be overwritten
# Source user's original zshrc first (preserves user configuration)
if [ -f "$HOME/.zshrc" ]; then
source "$HOME/.zshrc"
fi
# Load Automaker theme colors
AUTOMAKER_THEME="\${AUTOMAKER_THEME:-dark}"
if [ -f "\${ZDOTDIR:-\${0:a:h}}/themes/$AUTOMAKER_THEME.sh" ]; then
source "\${ZDOTDIR:-\${0:a:h}}/themes/$AUTOMAKER_THEME.sh"
fi
# Load common functions (git prompt)
if [ -f "\${ZDOTDIR:-\${0:a:h}}/common.sh" ]; then
source "\${ZDOTDIR:-\${0:a:h}}/common.sh"
fi
# Enable command substitution in PROMPT
setopt PROMPT_SUBST
# Show Automaker banner on shell start
if command -v automaker_show_banner_once >/dev/null 2>&1; then
automaker_show_banner_once
fi
# Set custom prompt (only if enabled)
if [ "$AUTOMAKER_CUSTOM_PROMPT" = "true" ]; then
${promptInitializer}
fi
${generateAliases(config)}${generateEnvVars(config)}
# Load user customizations (if exists)
if [ -f "\${ZDOTDIR:-\${0:a:h}}/user-custom.sh" ]; then
source "\${ZDOTDIR:-\${0:a:h}}/user-custom.sh"
fi
`;
}
/**
* Generate theme color exports for shell
*/
export function generateThemeColors(theme: TerminalTheme): string {
const colors = getThemeANSIColors(theme);
const rawColors = {
user: stripPromptEscapes(colors.user),
host: stripPromptEscapes(colors.host),
path: stripPromptEscapes(colors.path),
gitBranch: stripPromptEscapes(colors.gitBranch),
gitDirty: stripPromptEscapes(colors.gitDirty),
prompt: stripPromptEscapes(colors.prompt),
reset: stripPromptEscapes(colors.reset),
};
return `#!/bin/sh
# Automaker Theme Colors
# This file is automatically generated - manual edits will be overwritten
# ANSI color codes for prompt
export COLOR_USER="${colors.user}"
export COLOR_HOST="${colors.host}"
export COLOR_PATH="${colors.path}"
export COLOR_GIT_BRANCH="${colors.gitBranch}"
export COLOR_GIT_DIRTY="${colors.gitDirty}"
export COLOR_PROMPT="${colors.prompt}"
export COLOR_RESET="${colors.reset}"
# ANSI color codes for banner output (no prompt escapes)
export COLOR_USER_RAW="${rawColors.user}"
export COLOR_HOST_RAW="${rawColors.host}"
export COLOR_PATH_RAW="${rawColors.path}"
export COLOR_GIT_BRANCH_RAW="${rawColors.gitBranch}"
export COLOR_GIT_DIRTY_RAW="${rawColors.gitDirty}"
export COLOR_PROMPT_RAW="${rawColors.prompt}"
export COLOR_RESET_RAW="${rawColors.reset}"
`;
}
/**
* Get shell name from file extension
*/
export function getShellName(rcFile: string): 'bash' | 'zsh' | 'sh' | null {
if (rcFile.endsWith('.sh') && rcFile.includes('bashrc')) return 'bash';
if (rcFile.endsWith('.zsh') || rcFile.endsWith('.zshrc')) return 'zsh';
if (rcFile.endsWith('.sh')) return 'sh';
return null;
}

View File

@@ -25,6 +25,16 @@ import fs from 'fs/promises';
// System Tool Path Definitions
// =============================================================================
/**
* Get NVM for Windows (nvm4w) symlink paths for a given CLI tool.
* Reused across getClaudeCliPaths, getCodexCliPaths, and getOpenCodeCliPaths.
*/
function getNvmWindowsCliPaths(cliName: string): string[] {
const nvmSymlink = process.env.NVM_SYMLINK;
if (!nvmSymlink) return [];
return [path.join(nvmSymlink, `${cliName}.cmd`), path.join(nvmSymlink, cliName)];
}
/**
* Get common paths where GitHub CLI might be installed
*/
@@ -60,6 +70,7 @@ export function getClaudeCliPaths(): string[] {
path.join(appData, 'npm', 'claude'),
path.join(appData, '.npm-global', 'bin', 'claude.cmd'),
path.join(appData, '.npm-global', 'bin', 'claude'),
...getNvmWindowsCliPaths('claude'),
];
}
@@ -141,6 +152,7 @@ export function getCodexCliPaths(): string[] {
// pnpm on Windows
path.join(localAppData, 'pnpm', 'codex.cmd'),
path.join(localAppData, 'pnpm', 'codex'),
...getNvmWindowsCliPaths('codex'),
];
}
@@ -1261,6 +1273,7 @@ export function getOpenCodeCliPaths(): string[] {
// Go installation (if OpenCode is a Go binary)
path.join(homeDir, 'go', 'bin', 'opencode.exe'),
path.join(process.env.GOPATH || path.join(homeDir, 'go'), 'bin', 'opencode.exe'),
...getNvmWindowsCliPaths('opencode'),
];
}

View File

@@ -0,0 +1,468 @@
/**
* Terminal Theme Colors - Color definitions for all 40 themes
*
* This module contains only the raw color data for terminal themes,
* extracted from the UI package to avoid circular dependencies.
* These colors are used by both UI (xterm.js) and server (RC file generation).
*/
import type { ThemeMode } from '@automaker/types';
import type { TerminalTheme } from './rc-generator.js';
// Dark theme (default)
const darkTheme: TerminalTheme = {
background: '#0a0a0a',
foreground: '#d4d4d4',
cursor: '#d4d4d4',
cursorAccent: '#0a0a0a',
selectionBackground: '#264f78',
black: '#1e1e1e',
red: '#f44747',
green: '#6a9955',
yellow: '#dcdcaa',
blue: '#569cd6',
magenta: '#c586c0',
cyan: '#4ec9b0',
white: '#d4d4d4',
brightBlack: '#808080',
brightRed: '#f44747',
brightGreen: '#6a9955',
brightYellow: '#dcdcaa',
brightBlue: '#569cd6',
brightMagenta: '#c586c0',
brightCyan: '#4ec9b0',
brightWhite: '#ffffff',
};
// Light theme
const lightTheme: TerminalTheme = {
background: '#ffffff',
foreground: '#383a42',
cursor: '#383a42',
cursorAccent: '#ffffff',
selectionBackground: '#add6ff',
black: '#383a42',
red: '#e45649',
green: '#50a14f',
yellow: '#c18401',
blue: '#4078f2',
magenta: '#a626a4',
cyan: '#0184bc',
white: '#fafafa',
brightBlack: '#4f525e',
brightRed: '#e06c75',
brightGreen: '#98c379',
brightYellow: '#e5c07b',
brightBlue: '#61afef',
brightMagenta: '#c678dd',
brightCyan: '#56b6c2',
brightWhite: '#ffffff',
};
// Retro / Cyberpunk theme - neon green on black
const retroTheme: TerminalTheme = {
background: '#000000',
foreground: '#39ff14',
cursor: '#39ff14',
cursorAccent: '#000000',
selectionBackground: '#39ff14',
selectionForeground: '#000000',
black: '#000000',
red: '#ff0055',
green: '#39ff14',
yellow: '#ffff00',
blue: '#00ffff',
magenta: '#ff00ff',
cyan: '#00ffff',
white: '#39ff14',
brightBlack: '#555555',
brightRed: '#ff5555',
brightGreen: '#55ff55',
brightYellow: '#ffff55',
brightBlue: '#55ffff',
brightMagenta: '#ff55ff',
brightCyan: '#55ffff',
brightWhite: '#ffffff',
};
// Dracula theme
const draculaTheme: TerminalTheme = {
background: '#282a36',
foreground: '#f8f8f2',
cursor: '#f8f8f2',
cursorAccent: '#282a36',
selectionBackground: '#44475a',
black: '#21222c',
red: '#ff5555',
green: '#50fa7b',
yellow: '#f1fa8c',
blue: '#bd93f9',
magenta: '#ff79c6',
cyan: '#8be9fd',
white: '#f8f8f2',
brightBlack: '#6272a4',
brightRed: '#ff6e6e',
brightGreen: '#69ff94',
brightYellow: '#ffffa5',
brightBlue: '#d6acff',
brightMagenta: '#ff92df',
brightCyan: '#a4ffff',
brightWhite: '#ffffff',
};
// Nord theme
const nordTheme: TerminalTheme = {
background: '#2e3440',
foreground: '#d8dee9',
cursor: '#d8dee9',
cursorAccent: '#2e3440',
selectionBackground: '#434c5e',
black: '#3b4252',
red: '#bf616a',
green: '#a3be8c',
yellow: '#ebcb8b',
blue: '#81a1c1',
magenta: '#b48ead',
cyan: '#88c0d0',
white: '#e5e9f0',
brightBlack: '#4c566a',
brightRed: '#bf616a',
brightGreen: '#a3be8c',
brightYellow: '#ebcb8b',
brightBlue: '#81a1c1',
brightMagenta: '#b48ead',
brightCyan: '#8fbcbb',
brightWhite: '#eceff4',
};
// Monokai theme
const monokaiTheme: TerminalTheme = {
background: '#272822',
foreground: '#f8f8f2',
cursor: '#f8f8f2',
cursorAccent: '#272822',
selectionBackground: '#49483e',
black: '#272822',
red: '#f92672',
green: '#a6e22e',
yellow: '#f4bf75',
blue: '#66d9ef',
magenta: '#ae81ff',
cyan: '#a1efe4',
white: '#f8f8f2',
brightBlack: '#75715e',
brightRed: '#f92672',
brightGreen: '#a6e22e',
brightYellow: '#f4bf75',
brightBlue: '#66d9ef',
brightMagenta: '#ae81ff',
brightCyan: '#a1efe4',
brightWhite: '#f9f8f5',
};
// Tokyo Night theme
const tokyonightTheme: TerminalTheme = {
background: '#1a1b26',
foreground: '#a9b1d6',
cursor: '#c0caf5',
cursorAccent: '#1a1b26',
selectionBackground: '#33467c',
black: '#15161e',
red: '#f7768e',
green: '#9ece6a',
yellow: '#e0af68',
blue: '#7aa2f7',
magenta: '#bb9af7',
cyan: '#7dcfff',
white: '#a9b1d6',
brightBlack: '#414868',
brightRed: '#f7768e',
brightGreen: '#9ece6a',
brightYellow: '#e0af68',
brightBlue: '#7aa2f7',
brightMagenta: '#bb9af7',
brightCyan: '#7dcfff',
brightWhite: '#c0caf5',
};
// Solarized Dark theme
const solarizedTheme: TerminalTheme = {
background: '#002b36',
foreground: '#93a1a1',
cursor: '#93a1a1',
cursorAccent: '#002b36',
selectionBackground: '#073642',
black: '#073642',
red: '#dc322f',
green: '#859900',
yellow: '#b58900',
blue: '#268bd2',
magenta: '#d33682',
cyan: '#2aa198',
white: '#eee8d5',
brightBlack: '#002b36',
brightRed: '#cb4b16',
brightGreen: '#586e75',
brightYellow: '#657b83',
brightBlue: '#839496',
brightMagenta: '#6c71c4',
brightCyan: '#93a1a1',
brightWhite: '#fdf6e3',
};
// Gruvbox Dark theme
const gruvboxTheme: TerminalTheme = {
background: '#282828',
foreground: '#ebdbb2',
cursor: '#ebdbb2',
cursorAccent: '#282828',
selectionBackground: '#504945',
black: '#282828',
red: '#cc241d',
green: '#98971a',
yellow: '#d79921',
blue: '#458588',
magenta: '#b16286',
cyan: '#689d6a',
white: '#a89984',
brightBlack: '#928374',
brightRed: '#fb4934',
brightGreen: '#b8bb26',
brightYellow: '#fabd2f',
brightBlue: '#83a598',
brightMagenta: '#d3869b',
brightCyan: '#8ec07c',
brightWhite: '#ebdbb2',
};
// Catppuccin Mocha theme
const catppuccinTheme: TerminalTheme = {
background: '#1e1e2e',
foreground: '#cdd6f4',
cursor: '#f5e0dc',
cursorAccent: '#1e1e2e',
selectionBackground: '#45475a',
black: '#45475a',
red: '#f38ba8',
green: '#a6e3a1',
yellow: '#f9e2af',
blue: '#89b4fa',
magenta: '#cba6f7',
cyan: '#94e2d5',
white: '#bac2de',
brightBlack: '#585b70',
brightRed: '#f38ba8',
brightGreen: '#a6e3a1',
brightYellow: '#f9e2af',
brightBlue: '#89b4fa',
brightMagenta: '#cba6f7',
brightCyan: '#94e2d5',
brightWhite: '#a6adc8',
};
// One Dark theme
const onedarkTheme: TerminalTheme = {
background: '#282c34',
foreground: '#abb2bf',
cursor: '#528bff',
cursorAccent: '#282c34',
selectionBackground: '#3e4451',
black: '#282c34',
red: '#e06c75',
green: '#98c379',
yellow: '#e5c07b',
blue: '#61afef',
magenta: '#c678dd',
cyan: '#56b6c2',
white: '#abb2bf',
brightBlack: '#5c6370',
brightRed: '#e06c75',
brightGreen: '#98c379',
brightYellow: '#e5c07b',
brightBlue: '#61afef',
brightMagenta: '#c678dd',
brightCyan: '#56b6c2',
brightWhite: '#ffffff',
};
// Synthwave '84 theme
const synthwaveTheme: TerminalTheme = {
background: '#262335',
foreground: '#ffffff',
cursor: '#ff7edb',
cursorAccent: '#262335',
selectionBackground: '#463465',
black: '#262335',
red: '#fe4450',
green: '#72f1b8',
yellow: '#fede5d',
blue: '#03edf9',
magenta: '#ff7edb',
cyan: '#03edf9',
white: '#ffffff',
brightBlack: '#614d85',
brightRed: '#fe4450',
brightGreen: '#72f1b8',
brightYellow: '#f97e72',
brightBlue: '#03edf9',
brightMagenta: '#ff7edb',
brightCyan: '#03edf9',
brightWhite: '#ffffff',
};
// Red theme
const redTheme: TerminalTheme = {
background: '#1a0a0a',
foreground: '#c8b0b0',
cursor: '#ff4444',
cursorAccent: '#1a0a0a',
selectionBackground: '#5a2020',
black: '#2a1010',
red: '#ff4444',
green: '#6a9a6a',
yellow: '#ccaa55',
blue: '#6688aa',
magenta: '#aa5588',
cyan: '#558888',
white: '#b0a0a0',
brightBlack: '#6a4040',
brightRed: '#ff6666',
brightGreen: '#88bb88',
brightYellow: '#ddbb66',
brightBlue: '#88aacc',
brightMagenta: '#cc77aa',
brightCyan: '#77aaaa',
brightWhite: '#d0c0c0',
};
// Cream theme
const creamTheme: TerminalTheme = {
background: '#f5f3ee',
foreground: '#5a4a3a',
cursor: '#9d6b53',
cursorAccent: '#f5f3ee',
selectionBackground: '#d4c4b0',
black: '#5a4a3a',
red: '#c85a4f',
green: '#7a9a6a',
yellow: '#c9a554',
blue: '#6b8aaa',
magenta: '#a66a8a',
cyan: '#5a9a8a',
white: '#b0a090',
brightBlack: '#8a7a6a',
brightRed: '#e07060',
brightGreen: '#90b080',
brightYellow: '#e0bb70',
brightBlue: '#80a0c0',
brightMagenta: '#c080a0',
brightCyan: '#70b0a0',
brightWhite: '#d0c0b0',
};
// Sunset theme
const sunsetTheme: TerminalTheme = {
background: '#1e1a24',
foreground: '#f2e8dd',
cursor: '#dd8855',
cursorAccent: '#1e1a24',
selectionBackground: '#3a2a40',
black: '#1e1a24',
red: '#dd6655',
green: '#88bb77',
yellow: '#ddaa66',
blue: '#6699cc',
magenta: '#cc7799',
cyan: '#66ccaa',
white: '#e8d8c8',
brightBlack: '#4a3a50',
brightRed: '#ee8866',
brightGreen: '#99cc88',
brightYellow: '#eebb77',
brightBlue: '#88aadd',
brightMagenta: '#dd88aa',
brightCyan: '#88ddbb',
brightWhite: '#f5e8dd',
};
// Gray theme
const grayTheme: TerminalTheme = {
background: '#2a2d32',
foreground: '#d0d0d5',
cursor: '#8fa0c0',
cursorAccent: '#2a2d32',
selectionBackground: '#3a3f48',
black: '#2a2d32',
red: '#d87070',
green: '#78b088',
yellow: '#d0b060',
blue: '#7090c0',
magenta: '#a880b0',
cyan: '#60a0b0',
white: '#b0b0b8',
brightBlack: '#606068',
brightRed: '#e88888',
brightGreen: '#90c8a0',
brightYellow: '#e0c878',
brightBlue: '#90b0d8',
brightMagenta: '#c098c8',
brightCyan: '#80b8c8',
brightWhite: '#e0e0e8',
};
/**
* Theme color mapping for all 40 themes
*/
export const terminalThemeColors: Record<ThemeMode, TerminalTheme> = {
// Special
system: darkTheme, // Resolved at runtime based on OS preference
// Dark themes (16)
dark: darkTheme,
retro: retroTheme,
dracula: draculaTheme,
nord: nordTheme,
monokai: monokaiTheme,
tokyonight: tokyonightTheme,
solarized: solarizedTheme,
gruvbox: gruvboxTheme,
catppuccin: catppuccinTheme,
onedark: onedarkTheme,
synthwave: synthwaveTheme,
red: redTheme,
sunset: sunsetTheme,
gray: grayTheme,
forest: gruvboxTheme, // Green-ish theme
ocean: nordTheme, // Blue-ish theme
ember: monokaiTheme, // Warm orange theme
'ayu-dark': darkTheme,
'ayu-mirage': darkTheme,
matcha: nordTheme,
// Light themes (16)
light: lightTheme,
cream: creamTheme,
solarizedlight: lightTheme,
github: lightTheme,
paper: lightTheme,
rose: lightTheme,
mint: lightTheme,
lavender: lightTheme,
sand: creamTheme,
sky: lightTheme,
peach: creamTheme,
snow: lightTheme,
sepia: creamTheme,
gruvboxlight: creamTheme,
nordlight: lightTheme,
blossom: lightTheme,
'ayu-light': lightTheme,
onelight: lightTheme,
bluloco: lightTheme,
feather: lightTheme,
};
/**
* Get terminal theme colors for a given theme mode
*/
export function getTerminalThemeColors(theme: ThemeMode): TerminalTheme {
return terminalThemeColors[theme] || darkTheme;
}

View File

@@ -140,9 +140,9 @@ const SUPPORTED_TERMINALS: TerminalDefinition[] = [
{
id: 'warp',
name: 'Warp',
cliCommand: 'warp',
cliCommand: 'warp-cli',
cliAliases: ['warp-terminal', 'warp'],
macAppName: 'Warp',
platform: 'darwin',
},
{
id: 'ghostty',
@@ -476,6 +476,11 @@ async function executeTerminalCommand(terminal: TerminalInfo, targetPath: string
await spawnDetached(command, [`--working-directory=${targetPath}`]);
break;
case 'warp':
// Warp: uses --cwd flag (CLI mode, not app bundle)
await spawnDetached(command, ['--cwd', targetPath]);
break;
case 'alacritty':
// Alacritty: uses --working-directory flag
await spawnDetached(command, ['--working-directory', targetPath]);

View File

@@ -0,0 +1,100 @@
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import fs from 'fs/promises';
import path from 'path';
import os from 'os';
import { needsRegeneration, writeRcFiles } from '../src/rc-file-manager';
import { terminalThemeColors } from '../src/terminal-theme-colors';
import type { TerminalConfig } from '../src/rc-generator';
import type { ThemeMode } from '@automaker/types';
describe('rc-file-manager.ts', () => {
let tempDir: string;
let projectPath: string;
const TEMP_DIR_PREFIX = 'platform-rc-files-test-';
const PROJECT_DIR_NAME = 'test-project';
const THEME_DARK = 'dark' as ThemeMode;
const THEME_LIGHT = 'light' as ThemeMode;
const PROMPT_FORMAT_STANDARD: TerminalConfig['promptFormat'] = 'standard';
const PROMPT_FORMAT_MINIMAL: TerminalConfig['promptFormat'] = 'minimal';
const EMPTY_ALIASES = '';
const PATH_STYLE_FULL: TerminalConfig['pathStyle'] = 'full';
const PATH_DEPTH_DEFAULT = 0;
const baseConfig: TerminalConfig = {
enabled: true,
customPrompt: true,
promptFormat: PROMPT_FORMAT_STANDARD,
showGitBranch: true,
showGitStatus: true,
showUserHost: true,
showPath: true,
pathStyle: PATH_STYLE_FULL,
pathDepth: PATH_DEPTH_DEFAULT,
showTime: false,
showExitStatus: false,
customAliases: EMPTY_ALIASES,
customEnvVars: {},
};
beforeEach(async () => {
tempDir = await fs.mkdtemp(path.join(os.tmpdir(), TEMP_DIR_PREFIX));
projectPath = path.join(tempDir, PROJECT_DIR_NAME);
await fs.mkdir(projectPath, { recursive: true });
});
afterEach(async () => {
try {
await fs.rm(tempDir, { recursive: true, force: true });
} catch {
// Ignore cleanup errors
}
});
it('should not regenerate when signature matches', async () => {
await writeRcFiles(
projectPath,
THEME_DARK,
baseConfig,
terminalThemeColors[THEME_DARK],
terminalThemeColors
);
const needsRegen = await needsRegeneration(projectPath, THEME_DARK, baseConfig);
expect(needsRegen).toBe(false);
});
it('should regenerate when config changes', async () => {
await writeRcFiles(
projectPath,
THEME_DARK,
baseConfig,
terminalThemeColors[THEME_DARK],
terminalThemeColors
);
const updatedConfig: TerminalConfig = {
...baseConfig,
promptFormat: PROMPT_FORMAT_MINIMAL,
};
const needsRegen = await needsRegeneration(projectPath, THEME_DARK, updatedConfig);
expect(needsRegen).toBe(true);
});
it('should regenerate when theme changes', async () => {
await writeRcFiles(
projectPath,
THEME_DARK,
baseConfig,
terminalThemeColors[THEME_DARK],
terminalThemeColors
);
const needsRegen = await needsRegeneration(projectPath, THEME_LIGHT, baseConfig);
expect(needsRegen).toBe(true);
});
});

View File

@@ -0,0 +1,55 @@
import { describe, it, expect } from 'vitest';
import { generateCommonFunctions, generateThemeColors } from '../src/rc-generator';
import { terminalThemeColors } from '../src/terminal-theme-colors';
import type { TerminalConfig } from '../src/rc-generator';
import type { ThemeMode } from '@automaker/types';
describe('rc-generator.ts', () => {
const THEME_DARK = 'dark' as ThemeMode;
const PROMPT_FORMAT_STANDARD: TerminalConfig['promptFormat'] = 'standard';
const EMPTY_ALIASES = '';
const EMPTY_ENV_VARS = {};
const PATH_STYLE_FULL: TerminalConfig['pathStyle'] = 'full';
const PATH_DEPTH_DEFAULT = 0;
const EXPECTED_BANNER_FUNCTION = 'automaker_show_banner_once';
const RAW_COLOR_PREFIX = 'export COLOR_USER_RAW=';
const RAW_COLOR_ESCAPE_START = '\\\\[';
const RAW_COLOR_ESCAPE_END = '\\\\]';
const STARTUP_PRIMARY_COLOR = '38;5;51m';
const STARTUP_SECONDARY_COLOR = '38;5;39m';
const STARTUP_ACCENT_COLOR = '38;5;33m';
const baseConfig: TerminalConfig = {
enabled: true,
customPrompt: true,
promptFormat: PROMPT_FORMAT_STANDARD,
showGitBranch: true,
showGitStatus: true,
showUserHost: true,
showPath: true,
pathStyle: PATH_STYLE_FULL,
pathDepth: PATH_DEPTH_DEFAULT,
showTime: false,
showExitStatus: false,
customAliases: EMPTY_ALIASES,
customEnvVars: EMPTY_ENV_VARS,
};
it('includes banner functions in common shell script', () => {
const output = generateCommonFunctions(baseConfig);
expect(output).toContain(EXPECTED_BANNER_FUNCTION);
expect(output).toContain(STARTUP_PRIMARY_COLOR);
expect(output).toContain(STARTUP_SECONDARY_COLOR);
expect(output).toContain(STARTUP_ACCENT_COLOR);
});
it('exports raw banner colors without prompt escape wrappers', () => {
const output = generateThemeColors(terminalThemeColors[THEME_DARK]);
const rawLine = output.split('\n').find((line) => line.startsWith(RAW_COLOR_PREFIX));
expect(rawLine).toBeDefined();
expect(rawLine).not.toContain(RAW_COLOR_ESCAPE_START);
expect(rawLine).not.toContain(RAW_COLOR_ESCAPE_END);
});
});

View File

@@ -6,6 +6,7 @@
* IMPORTANT: All Codex models use 'codex-' prefix to distinguish from Cursor CLI models
*/
export type CodexModelId =
| 'codex-gpt-5.3-codex'
| 'codex-gpt-5.2-codex'
| 'codex-gpt-5.1-codex-max'
| 'codex-gpt-5.1-codex-mini'
@@ -29,31 +30,38 @@ export interface CodexModelConfig {
* All keys use 'codex-' prefix to distinguish from Cursor CLI models
*/
export const CODEX_MODEL_CONFIG_MAP: Record<CodexModelId, CodexModelConfig> = {
'codex-gpt-5.3-codex': {
id: 'codex-gpt-5.3-codex',
label: 'GPT-5.3-Codex',
description: 'Latest frontier agentic coding model',
hasThinking: true,
supportsVision: true,
},
'codex-gpt-5.2-codex': {
id: 'codex-gpt-5.2-codex',
label: 'GPT-5.2-Codex',
description: 'Most advanced agentic coding model for complex software engineering',
description: 'Frontier agentic coding model',
hasThinking: true,
supportsVision: true,
},
'codex-gpt-5.1-codex-max': {
id: 'codex-gpt-5.1-codex-max',
label: 'GPT-5.1-Codex-Max',
description: 'Optimized for long-horizon, agentic coding tasks in Codex',
description: 'Codex-optimized flagship for deep and fast reasoning',
hasThinking: true,
supportsVision: true,
},
'codex-gpt-5.1-codex-mini': {
id: 'codex-gpt-5.1-codex-mini',
label: 'GPT-5.1-Codex-Mini',
description: 'Smaller, more cost-effective version for faster workflows',
description: 'Optimized for codex. Cheaper, faster, but less capable',
hasThinking: false,
supportsVision: true,
},
'codex-gpt-5.2': {
id: 'codex-gpt-5.2',
label: 'GPT-5.2 (Codex)',
description: 'Best general agentic model for tasks across industries and domains via Codex',
description: 'Latest frontier model with improvements across knowledge, reasoning and coding',
hasThinking: true,
supportsVision: true,
},

View File

@@ -46,6 +46,7 @@ export type EventType =
| 'dev-server:started'
| 'dev-server:output'
| 'dev-server:stopped'
| 'dev-server:url-detected'
| 'test-runner:started'
| 'test-runner:progress'
| 'test-runner:output'

View File

@@ -196,6 +196,8 @@ export {
PROJECT_SETTINGS_VERSION,
THINKING_TOKEN_BUDGET,
getThinkingTokenBudget,
isAdaptiveThinkingModel,
getThinkingLevelsForModel,
// Event hook constants
EVENT_HOOK_TRIGGER_LABELS,
// Claude-compatible provider templates (new)

View File

@@ -72,10 +72,18 @@ export const CLAUDE_MODELS: ModelOption[] = [
* Official models from https://developers.openai.com/codex/models/
*/
export const CODEX_MODELS: (ModelOption & { hasReasoning?: boolean })[] = [
{
id: CODEX_MODEL_MAP.gpt53Codex,
label: 'GPT-5.3-Codex',
description: 'Latest frontier agentic coding model.',
badge: 'Premium',
provider: 'codex',
hasReasoning: true,
},
{
id: CODEX_MODEL_MAP.gpt52Codex,
label: 'GPT-5.2-Codex',
description: 'Most advanced agentic coding model for complex software engineering.',
description: 'Frontier agentic coding model.',
badge: 'Premium',
provider: 'codex',
hasReasoning: true,
@@ -83,7 +91,7 @@ export const CODEX_MODELS: (ModelOption & { hasReasoning?: boolean })[] = [
{
id: CODEX_MODEL_MAP.gpt51CodexMax,
label: 'GPT-5.1-Codex-Max',
description: 'Optimized for long-horizon, agentic coding tasks in Codex.',
description: 'Codex-optimized flagship for deep and fast reasoning.',
badge: 'Premium',
provider: 'codex',
hasReasoning: true,
@@ -91,7 +99,7 @@ export const CODEX_MODELS: (ModelOption & { hasReasoning?: boolean })[] = [
{
id: CODEX_MODEL_MAP.gpt51CodexMini,
label: 'GPT-5.1-Codex-Mini',
description: 'Smaller, more cost-effective version for faster workflows.',
description: 'Optimized for codex. Cheaper, faster, but less capable.',
badge: 'Speed',
provider: 'codex',
hasReasoning: false,
@@ -99,7 +107,7 @@ export const CODEX_MODELS: (ModelOption & { hasReasoning?: boolean })[] = [
{
id: CODEX_MODEL_MAP.gpt52,
label: 'GPT-5.2',
description: 'Best general agentic model for tasks across industries and domains.',
description: 'Latest frontier model with improvements across knowledge, reasoning and coding.',
badge: 'Balanced',
provider: 'codex',
hasReasoning: true,
@@ -141,6 +149,7 @@ export const THINKING_LEVELS: ThinkingLevelOption[] = [
{ id: 'medium', label: 'Medium' },
{ id: 'high', label: 'High' },
{ id: 'ultrathink', label: 'Ultrathink' },
{ id: 'adaptive', label: 'Adaptive' },
];
/**
@@ -154,6 +163,7 @@ export const THINKING_LEVEL_LABELS: Record<ThinkingLevel, string> = {
medium: 'Med',
high: 'High',
ultrathink: 'Ultra',
adaptive: 'Adaptive',
};
/**
@@ -211,6 +221,7 @@ export function getModelDisplayName(model: ModelAlias | string): string {
haiku: 'Claude Haiku',
sonnet: 'Claude Sonnet',
opus: 'Claude Opus',
[CODEX_MODEL_MAP.gpt53Codex]: 'GPT-5.3-Codex',
[CODEX_MODEL_MAP.gpt52Codex]: 'GPT-5.2-Codex',
[CODEX_MODEL_MAP.gpt51CodexMax]: 'GPT-5.1-Codex-Max',
[CODEX_MODEL_MAP.gpt51CodexMini]: 'GPT-5.1-Codex-Mini',

View File

@@ -18,7 +18,7 @@ export type ClaudeCanonicalId = 'claude-haiku' | 'claude-sonnet' | 'claude-opus'
export const CLAUDE_CANONICAL_MAP: Record<ClaudeCanonicalId, string> = {
'claude-haiku': 'claude-haiku-4-5-20251001',
'claude-sonnet': 'claude-sonnet-4-5-20250929',
'claude-opus': 'claude-opus-4-5-20251101',
'claude-opus': 'claude-opus-4-6',
} as const;
/**
@@ -29,7 +29,7 @@ export const CLAUDE_CANONICAL_MAP: Record<ClaudeCanonicalId, string> = {
export const CLAUDE_MODEL_MAP: Record<string, string> = {
haiku: 'claude-haiku-4-5-20251001',
sonnet: 'claude-sonnet-4-5-20250929',
opus: 'claude-opus-4-5-20251101',
opus: 'claude-opus-4-6',
} as const;
/**
@@ -50,15 +50,17 @@ export const LEGACY_CLAUDE_ALIAS_MAP: Record<string, ClaudeCanonicalId> = {
*/
export const CODEX_MODEL_MAP = {
// Recommended Codex-specific models
/** Most advanced agentic coding model for complex software engineering (default for ChatGPT users) */
/** Latest frontier agentic coding model */
gpt53Codex: 'codex-gpt-5.3-codex',
/** Frontier agentic coding model */
gpt52Codex: 'codex-gpt-5.2-codex',
/** Optimized for long-horizon, agentic coding tasks in Codex */
/** Codex-optimized flagship for deep and fast reasoning */
gpt51CodexMax: 'codex-gpt-5.1-codex-max',
/** Smaller, more cost-effective version for faster workflows */
/** Optimized for codex. Cheaper, faster, but less capable */
gpt51CodexMini: 'codex-gpt-5.1-codex-mini',
// General-purpose GPT models (also available in Codex)
/** Best general agentic model for tasks across industries and domains */
/** Latest frontier model with improvements across knowledge, reasoning and coding */
gpt52: 'codex-gpt-5.2',
/** Great for coding and agentic tasks across domains */
gpt51: 'codex-gpt-5.1',
@@ -71,6 +73,7 @@ export const CODEX_MODEL_IDS = Object.values(CODEX_MODEL_MAP);
* These models can use reasoning.effort parameter
*/
export const REASONING_CAPABLE_MODELS = new Set([
CODEX_MODEL_MAP.gpt53Codex,
CODEX_MODEL_MAP.gpt52Codex,
CODEX_MODEL_MAP.gpt51CodexMax,
CODEX_MODEL_MAP.gpt52,
@@ -96,9 +99,9 @@ export function getAllCodexModelIds(): CodexModelId[] {
* Uses canonical prefixed IDs for consistent routing.
*/
export const DEFAULT_MODELS = {
claude: 'claude-opus-4-5-20251101',
claude: 'claude-opus-4-6',
cursor: 'cursor-auto', // Cursor's recommended default (with prefix)
codex: CODEX_MODEL_MAP.gpt52Codex, // GPT-5.2-Codex is the most advanced agentic coding model
codex: CODEX_MODEL_MAP.gpt53Codex, // GPT-5.3-Codex is the latest frontier agentic coding model
} as const;
export type ModelAlias = keyof typeof CLAUDE_MODEL_MAP;

View File

@@ -27,14 +27,16 @@ export type { ModelAlias };
*
* Includes system theme and multiple color schemes organized by dark/light:
* - System: Respects OS dark/light mode preference
* - Dark themes (16): dark, retro, dracula, nord, monokai, tokyonight, solarized,
* gruvbox, catppuccin, onedark, synthwave, red, sunset, gray, forest, ocean
* - Light themes (16): light, cream, solarizedlight, github, paper, rose, mint,
* lavender, sand, sky, peach, snow, sepia, gruvboxlight, nordlight, blossom
* - Dark themes (20): dark, retro, dracula, nord, monokai, tokyonight, solarized,
* gruvbox, catppuccin, onedark, synthwave, red, sunset, gray, forest, ocean,
* ember, ayu-dark, ayu-mirage, matcha
* - Light themes (20): light, cream, solarizedlight, github, paper, rose, mint,
* lavender, sand, sky, peach, snow, sepia, gruvboxlight, nordlight, blossom,
* ayu-light, onelight, bluloco, feather
*/
export type ThemeMode =
| 'system'
// Dark themes (16)
// Dark themes (20)
| 'dark'
| 'retro'
| 'dracula'
@@ -51,7 +53,11 @@ export type ThemeMode =
| 'gray'
| 'forest'
| 'ocean'
// Light themes (16)
| 'ember'
| 'ayu-dark'
| 'ayu-mirage'
| 'matcha'
// Light themes (20)
| 'light'
| 'cream'
| 'solarizedlight'
@@ -67,7 +73,138 @@ export type ThemeMode =
| 'sepia'
| 'gruvboxlight'
| 'nordlight'
| 'blossom';
| 'blossom'
| 'ayu-light'
| 'onelight'
| 'bluloco'
| 'feather';
export type TerminalPromptTheme =
| 'custom'
| 'omp-1_shell'
| 'omp-agnoster'
| 'omp-agnoster.minimal'
| 'omp-agnosterplus'
| 'omp-aliens'
| 'omp-amro'
| 'omp-atomic'
| 'omp-atomicBit'
| 'omp-avit'
| 'omp-blue-owl'
| 'omp-blueish'
| 'omp-bubbles'
| 'omp-bubblesextra'
| 'omp-bubblesline'
| 'omp-capr4n'
| 'omp-catppuccin'
| 'omp-catppuccin_frappe'
| 'omp-catppuccin_latte'
| 'omp-catppuccin_macchiato'
| 'omp-catppuccin_mocha'
| 'omp-cert'
| 'omp-chips'
| 'omp-cinnamon'
| 'omp-clean-detailed'
| 'omp-cloud-context'
| 'omp-cloud-native-azure'
| 'omp-cobalt2'
| 'omp-craver'
| 'omp-darkblood'
| 'omp-devious-diamonds'
| 'omp-di4am0nd'
| 'omp-dracula'
| 'omp-easy-term'
| 'omp-emodipt'
| 'omp-emodipt-extend'
| 'omp-fish'
| 'omp-free-ukraine'
| 'omp-froczh'
| 'omp-gmay'
| 'omp-glowsticks'
| 'omp-grandpa-style'
| 'omp-gruvbox'
| 'omp-half-life'
| 'omp-honukai'
| 'omp-hotstick.minimal'
| 'omp-hul10'
| 'omp-hunk'
| 'omp-huvix'
| 'omp-if_tea'
| 'omp-illusi0n'
| 'omp-iterm2'
| 'omp-jandedobbeleer'
| 'omp-jblab_2021'
| 'omp-jonnychipz'
| 'omp-json'
| 'omp-jtracey93'
| 'omp-jv_sitecorian'
| 'omp-kali'
| 'omp-kushal'
| 'omp-lambda'
| 'omp-lambdageneration'
| 'omp-larserikfinholt'
| 'omp-lightgreen'
| 'omp-M365Princess'
| 'omp-marcduiker'
| 'omp-markbull'
| 'omp-material'
| 'omp-microverse-power'
| 'omp-mojada'
| 'omp-montys'
| 'omp-mt'
| 'omp-multiverse-neon'
| 'omp-negligible'
| 'omp-neko'
| 'omp-night-owl'
| 'omp-nordtron'
| 'omp-nu4a'
| 'omp-onehalf.minimal'
| 'omp-paradox'
| 'omp-pararussel'
| 'omp-patriksvensson'
| 'omp-peru'
| 'omp-pixelrobots'
| 'omp-plague'
| 'omp-poshmon'
| 'omp-powerlevel10k_classic'
| 'omp-powerlevel10k_lean'
| 'omp-powerlevel10k_modern'
| 'omp-powerlevel10k_rainbow'
| 'omp-powerline'
| 'omp-probua.minimal'
| 'omp-pure'
| 'omp-quick-term'
| 'omp-remk'
| 'omp-robbyrussell'
| 'omp-rudolfs-dark'
| 'omp-rudolfs-light'
| 'omp-sim-web'
| 'omp-slim'
| 'omp-slimfat'
| 'omp-smoothie'
| 'omp-sonicboom_dark'
| 'omp-sonicboom_light'
| 'omp-sorin'
| 'omp-space'
| 'omp-spaceship'
| 'omp-star'
| 'omp-stelbent-compact.minimal'
| 'omp-stelbent.minimal'
| 'omp-takuya'
| 'omp-the-unnamed'
| 'omp-thecyberden'
| 'omp-tiwahu'
| 'omp-tokyo'
| 'omp-tokyonight_storm'
| 'omp-tonybaloney'
| 'omp-uew'
| 'omp-unicorn'
| 'omp-velvet'
| 'omp-wholespace'
| 'omp-wopian'
| 'omp-xtoys'
| 'omp-ys'
| 'omp-zash';
/** PlanningMode - Planning levels for feature generation workflows */
export type PlanningMode = 'skip' | 'lite' | 'spec' | 'full';
@@ -76,7 +213,7 @@ export type PlanningMode = 'skip' | 'lite' | 'spec' | 'full';
export type ServerLogLevel = 'error' | 'warn' | 'info' | 'debug';
/** ThinkingLevel - Extended thinking levels for Claude models (reasoning intensity) */
export type ThinkingLevel = 'none' | 'low' | 'medium' | 'high' | 'ultrathink';
export type ThinkingLevel = 'none' | 'low' | 'medium' | 'high' | 'ultrathink' | 'adaptive';
/**
* SidebarStyle - Sidebar layout style options
@@ -100,6 +237,7 @@ export const THINKING_TOKEN_BUDGET: Record<ThinkingLevel, number | undefined> =
medium: 10000, // Light reasoning
high: 16000, // Complex tasks (recommended starting point)
ultrathink: 32000, // Maximum safe (above this risks timeouts)
adaptive: undefined, // Adaptive thinking (Opus 4.6) - SDK handles token allocation
};
/**
@@ -110,6 +248,26 @@ export function getThinkingTokenBudget(level: ThinkingLevel | undefined): number
return THINKING_TOKEN_BUDGET[level];
}
/**
* Check if a model uses adaptive thinking (Opus 4.6+)
* Adaptive thinking models let the SDK decide token allocation automatically.
*/
export function isAdaptiveThinkingModel(model: string): boolean {
return model.includes('opus-4-6') || model === 'claude-opus';
}
/**
* Get the available thinking levels for a given model.
* - Opus 4.6: Only 'none' and 'adaptive' (SDK handles token allocation)
* - Others: Full range of manual thinking levels
*/
export function getThinkingLevelsForModel(model: string): ThinkingLevel[] {
if (isAdaptiveThinkingModel(model)) {
return ['none', 'adaptive'];
}
return ['none', 'low', 'medium', 'high', 'ultrathink'];
}
/** ModelProvider - AI model provider for credentials and API key management */
export type ModelProvider = 'claude' | 'cursor' | 'codex' | 'opencode' | 'gemini' | 'copilot';
@@ -840,6 +998,39 @@ export interface GlobalSettings {
// Terminal Configuration
/** How to open terminals from "Open in Terminal" worktree action */
openTerminalMode?: 'newTab' | 'split';
/** Custom terminal configuration settings (prompt theming, aliases, env vars) */
terminalConfig?: {
/** Enable custom terminal configurations (default: false) */
enabled: boolean;
/** Enable custom prompt (default: true when enabled) */
customPrompt: boolean;
/** Prompt format template */
promptFormat: 'standard' | 'minimal' | 'powerline' | 'starship';
/** Prompt theme preset */
promptTheme?: TerminalPromptTheme;
/** Show git branch in prompt (default: true) */
showGitBranch: boolean;
/** Show git status dirty indicator (default: true) */
showGitStatus: boolean;
/** Show user and host in prompt (default: true) */
showUserHost: boolean;
/** Show path in prompt (default: true) */
showPath: boolean;
/** Path display style */
pathStyle: 'full' | 'short' | 'basename';
/** Limit path depth (0 = full path) */
pathDepth: number;
/** Show current time in prompt (default: false) */
showTime: boolean;
/** Show last command exit status when non-zero (default: false) */
showExitStatus: boolean;
/** User-provided custom aliases (multiline string) */
customAliases: string;
/** User-provided custom env vars */
customEnvVars: Record<string, string>;
/** RC file format version (for migration) */
rcFileVersion?: number;
};
// UI State Preferences
/** Whether sidebar is currently open */
@@ -1245,6 +1436,33 @@ export interface ProjectSettings {
*/
defaultFeatureModel?: PhaseModelEntry;
// Terminal Configuration Override (per-project)
/** Project-specific terminal config overrides */
terminalConfig?: {
/** Override global enabled setting */
enabled?: boolean;
/** Override prompt theme preset */
promptTheme?: TerminalPromptTheme;
/** Override showing user/host */
showUserHost?: boolean;
/** Override showing path */
showPath?: boolean;
/** Override path style */
pathStyle?: 'full' | 'short' | 'basename';
/** Override path depth (0 = full path) */
pathDepth?: number;
/** Override showing time */
showTime?: boolean;
/** Override showing exit status */
showExitStatus?: boolean;
/** Project-specific custom aliases */
customAliases?: string;
/** Project-specific env vars */
customEnvVars?: Record<string, string>;
/** Custom welcome message for this project */
welcomeMessage?: string;
};
// Deprecated Claude API Profile Override
/**
* @deprecated Use phaseModelOverrides instead.

View File

@@ -68,7 +68,7 @@ export {
} from './atomic-writer.js';
// Path utilities
export { normalizePath, pathsEqual } from './path-utils.js';
export { normalizePath, pathsEqual, sanitizeFilename } from './path-utils.js';
// Context file loading
export {

View File

@@ -49,3 +49,54 @@ export function pathsEqual(p1: string | undefined | null, p2: string | undefined
if (!p1 || !p2) return p1 === p2;
return normalizePath(p1) === normalizePath(p2);
}
/**
* Sanitize a filename to be safe for cross-platform file system usage
*
* Removes or replaces characters that are invalid on various file systems
* and prevents Windows reserved device names (CON, PRN, AUX, NUL, COM1-9, LPT1-9).
*
* @param filename - The filename to sanitize (without path, just the name)
* @param fallback - Fallback name if sanitization results in empty string (default: 'file')
* @returns A sanitized filename safe for all platforms
*
* @example
* ```typescript
* sanitizeFilename("my file.txt"); // "my_file.txt"
* sanitizeFilename("nul.txt"); // "_nul.txt" (Windows reserved)
* sanitizeFilename("con"); // "_con" (Windows reserved)
* sanitizeFilename("file?.txt"); // "file.txt"
* sanitizeFilename(""); // "file"
* sanitizeFilename("", "unnamed"); // "unnamed"
* ```
*/
export function sanitizeFilename(filename: string, fallback: string = 'file'): string {
if (!filename || typeof filename !== 'string') {
return fallback;
}
// Remove or replace invalid characters:
// - Path separators: / \
// - Windows invalid chars: : * ? " < > |
// - Control characters and other problematic chars
let safeName = filename
.replace(/[/\\:*?"<>|]/g, '') // Remove invalid chars
.replace(/\s+/g, '_') // Replace spaces with underscores
.replace(/\.+$/g, '') // Remove trailing dots (Windows issue)
.replace(/^\.+/g, '') // Remove leading dots
.trim();
// If empty after sanitization, use fallback
if (!safeName || safeName.length === 0) {
return fallback;
}
// Handle Windows reserved device names (case-insensitive)
// Reserved names: CON, PRN, AUX, NUL, COM1-9, LPT1-9
const windowsReserved = /^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i;
if (windowsReserved.test(safeName)) {
safeName = `_${safeName}`;
}
return safeName;
}

View File

@@ -0,0 +1,152 @@
/**
* Path Utilities Tests
*/
import { describe, it, expect } from 'vitest';
import { normalizePath, pathsEqual, sanitizeFilename } from '../src/path-utils.js';
describe('normalizePath', () => {
it('should convert backslashes to forward slashes', () => {
expect(normalizePath('C:\\Users\\foo\\bar')).toBe('C:/Users/foo/bar');
});
it('should leave forward slashes unchanged', () => {
expect(normalizePath('/home/foo/bar')).toBe('/home/foo/bar');
});
it('should handle mixed separators', () => {
expect(normalizePath('C:\\Users/foo\\bar')).toBe('C:/Users/foo/bar');
});
});
describe('pathsEqual', () => {
it('should return true for equal paths', () => {
expect(pathsEqual('/home/user', '/home/user')).toBe(true);
});
it('should return true for paths with different separators', () => {
expect(pathsEqual('C:\\foo\\bar', 'C:/foo/bar')).toBe(true);
});
it('should return false for different paths', () => {
expect(pathsEqual('/home/user', '/home/other')).toBe(false);
});
it('should handle null and undefined', () => {
expect(pathsEqual(null, null)).toBe(true);
expect(pathsEqual(undefined, undefined)).toBe(true);
expect(pathsEqual(null, undefined)).toBe(false);
expect(pathsEqual(null, '/path')).toBe(false);
expect(pathsEqual('/path', null)).toBe(false);
});
});
describe('sanitizeFilename', () => {
describe('Windows reserved names', () => {
it('should prefix Windows reserved device names', () => {
expect(sanitizeFilename('nul')).toBe('_nul');
expect(sanitizeFilename('NUL')).toBe('_NUL');
expect(sanitizeFilename('con')).toBe('_con');
expect(sanitizeFilename('CON')).toBe('_CON');
expect(sanitizeFilename('prn')).toBe('_prn');
expect(sanitizeFilename('aux')).toBe('_aux');
});
it('should prefix COM and LPT port names', () => {
expect(sanitizeFilename('com1')).toBe('_com1');
expect(sanitizeFilename('COM5')).toBe('_COM5');
expect(sanitizeFilename('lpt1')).toBe('_lpt1');
expect(sanitizeFilename('LPT9')).toBe('_LPT9');
});
it('should not prefix reserved names with extensions', () => {
// After removing extension, baseName might be reserved
expect(sanitizeFilename('nul')).toBe('_nul');
});
it('should not prefix non-reserved names that contain reserved words', () => {
expect(sanitizeFilename('null')).toBe('null'); // "null" is not reserved, only "nul"
expect(sanitizeFilename('console')).toBe('console');
expect(sanitizeFilename('auxiliary')).toBe('auxiliary');
});
});
describe('Invalid characters', () => {
it('should remove path separators', () => {
expect(sanitizeFilename('foo/bar')).toBe('foobar');
expect(sanitizeFilename('foo\\bar')).toBe('foobar');
});
it('should remove Windows invalid characters', () => {
expect(sanitizeFilename('file:name')).toBe('filename');
expect(sanitizeFilename('file*name')).toBe('filename');
expect(sanitizeFilename('file?name')).toBe('filename');
expect(sanitizeFilename('file"name')).toBe('filename');
expect(sanitizeFilename('file<name>')).toBe('filename');
expect(sanitizeFilename('file|name')).toBe('filename');
});
it('should replace spaces with underscores', () => {
expect(sanitizeFilename('my file name')).toBe('my_file_name');
expect(sanitizeFilename('file name')).toBe('file_name'); // multiple spaces
});
it('should remove leading and trailing dots', () => {
expect(sanitizeFilename('.hidden')).toBe('hidden');
expect(sanitizeFilename('file...')).toBe('file');
expect(sanitizeFilename('...file...')).toBe('file');
});
});
describe('Edge cases', () => {
it('should return fallback for empty strings', () => {
expect(sanitizeFilename('')).toBe('file');
expect(sanitizeFilename('', 'default')).toBe('default');
});
it('should return fallback for null/undefined', () => {
expect(sanitizeFilename(null as any)).toBe('file');
expect(sanitizeFilename(undefined as any)).toBe('file');
expect(sanitizeFilename(null as any, 'image')).toBe('image');
});
it('should return fallback for strings that become empty after sanitization', () => {
expect(sanitizeFilename('...')).toBe('file');
expect(sanitizeFilename('///\\\\\\')).toBe('file');
expect(sanitizeFilename('???')).toBe('file');
});
it('should handle non-string inputs', () => {
expect(sanitizeFilename(123 as any)).toBe('file');
expect(sanitizeFilename({} as any)).toBe('file');
});
});
describe('Normal filenames', () => {
it('should preserve normal filenames', () => {
expect(sanitizeFilename('document')).toBe('document');
expect(sanitizeFilename('file123')).toBe('file123');
expect(sanitizeFilename('my-file_name')).toBe('my-file_name');
});
it('should handle unicode characters', () => {
expect(sanitizeFilename('文件')).toBe('文件');
expect(sanitizeFilename('файл')).toBe('файл');
expect(sanitizeFilename('café')).toBe('café');
});
});
describe('Real-world examples from bug report', () => {
it('should handle filename that might become "nul"', () => {
// If a filename is "null.png", basename would be "null"
expect(sanitizeFilename('null')).toBe('null'); // "null" is ok
expect(sanitizeFilename('nul')).toBe('_nul'); // "nul" is reserved
});
it('should sanitize typical image filenames', () => {
expect(sanitizeFilename('screenshot')).toBe('screenshot');
expect(sanitizeFilename('image 1')).toBe('image_1');
expect(sanitizeFilename('photo?.jpg')).toBe('photo.jpg'); // ? removed, . is valid
});
});
});