claude-statusline-powerline
Version:
Beautiful powerline-style statusline for Claude Code with git integration, session tracking, and cost monitoring
243 lines • 7.79 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_PRICING = exports.MODEL_PRICING = exports.DEFAULT_CONFIG_TEMPLATE = exports.DEFAULT_CONFIG = exports.DEFAULT_SEGMENTS_CONFIG = void 0;
exports.get_config_path = get_config_path;
exports.load_config = load_config;
const fs = __importStar(require("node:fs"));
const os = __importStar(require("node:os"));
const path = __importStar(require("node:path"));
const themes_1 = require("./themes");
// Default separator configuration - simple and clean
const DEFAULT_SEPARATORS = {
model: 'thick',
directory: 'thick',
git: {
clean: 'thick',
dirty: 'thick',
ahead: 'thick',
behind: 'thick',
conflicts: 'thick',
staged: 'thick',
untracked: 'thick',
},
session: 'thick',
context: 'thick',
usage: 'thick',
};
// Default segments configuration with basic styling
exports.DEFAULT_SEGMENTS_CONFIG = {
segments: [
{
type: 'model',
},
{
type: 'directory',
},
{
type: 'git',
},
{
type: 'session',
},
{
type: 'context',
},
],
};
// Default configuration
exports.DEFAULT_CONFIG = {
separators: DEFAULT_SEPARATORS,
segment_config: exports.DEFAULT_SEGMENTS_CONFIG,
};
// Load config from JSON file
function load_config_from_file() {
// If STATUSLINE_CONFIG is set (demo mode), use only that config
if (process.env.STATUSLINE_CONFIG) {
try {
if (fs.existsSync(process.env.STATUSLINE_CONFIG)) {
const file_content = fs.readFileSync(process.env.STATUSLINE_CONFIG, 'utf8');
return JSON.parse(file_content);
}
}
catch (error) {
console.error(`Failed to load config from ${process.env.STATUSLINE_CONFIG}:`, error);
}
return null;
}
// Normal config loading hierarchy
const config_sources = [
{
name: 'global',
path: path.join(os.homedir(), '.claude', 'claude-statusline-powerline.json'),
},
{
name: 'project',
path: path.join(process.cwd(), '.claude', 'claude-statusline-powerline.json'),
},
];
let merged_config = {};
// Load configs in order, with later ones overriding earlier ones
for (const source of config_sources) {
try {
if (fs.existsSync(source.path)) {
const file_content = fs.readFileSync(source.path, 'utf8');
const parsed_config = JSON.parse(file_content);
merged_config = { ...merged_config, ...parsed_config };
}
}
catch (error) {
console.error(`Failed to load config from ${source.path}:`, error);
}
}
return Object.keys(merged_config).length > 0 ? merged_config : null;
}
// Get the primary config file path
function get_config_path() {
return path.join(os.homedir(), '.claude', 'claude-statusline-powerline.json');
}
// Create default config template
exports.DEFAULT_CONFIG_TEMPLATE = {
color_theme: 'dark',
font_profile: 'powerline',
segment_config: {
segments: [
{
type: 'model',
style: {
bg_color: '#1e40af',
fg_color: '#ffffff',
separator: {
style: 'thick',
color: '#1e40af',
},
},
},
{
type: 'directory',
},
{
type: 'git',
},
{
type: 'session',
},
],
},
};
// Load configuration from JSON file or use defaults
function load_config() {
// Load from JSON file
const file_config = load_config_from_file();
// Start with default configuration
let config = {
...exports.DEFAULT_CONFIG,
color_theme: 'dark',
font_profile: 'powerline',
current_theme: (0, themes_1.get_theme)('dark'),
};
// Merge file config if available
if (file_config) {
config = {
...config,
...file_config,
// Ensure theme gets updated if specified in file
current_theme: (0, themes_1.get_theme)(file_config.color_theme || config.color_theme || 'dark'),
// Merge segment configurations if provided
segment_config: file_config.segment_config || config.segment_config,
};
}
return config;
}
// Model pricing configuration (per million tokens)
exports.MODEL_PRICING = {
// Claude Opus 4.1 (Max plan only)
'claude-opus-4-1-20250805': {
name: 'Claude Opus 4.1',
input_tokens: 15,
output_tokens: 75,
cache_tokens: 1.5,
context_window: 200000,
},
// Claude Opus 4 (Max plan only)
'claude-opus-4-20250514': {
name: 'Claude Opus 4',
input_tokens: 15,
output_tokens: 75,
cache_tokens: 1.5,
context_window: 200000,
},
// Claude Sonnet 4 - 1M context support with tiered pricing
'claude-sonnet-4-20250514': {
name: 'Sonnet 4',
input_tokens: 3, // ≤200K tokens, 6 for >200K
output_tokens: 15, // ≤200K tokens, 22.5 for >200K
cache_tokens: 0.3,
context_window: 1000000, // 1M tokens
},
// Claude Sonnet 4 (simplified alias)
'claude-sonnet-4': {
name: 'Sonnet 4',
input_tokens: 3, // ≤200K tokens, 6 for >200K
output_tokens: 15, // ≤200K tokens, 22.5 for >200K
cache_tokens: 0.3,
context_window: 1000000, // 1M tokens
},
// Claude Sonnet 3.7
'claude-3-7-sonnet-20250219': {
name: 'Sonnet 3.7',
input_tokens: 3,
output_tokens: 15,
cache_tokens: 0.3,
context_window: 200000,
},
// Claude Haiku 3.5
'claude-3-5-haiku-20241022': {
name: 'Haiku 3.5',
input_tokens: 0.8,
output_tokens: 4,
cache_tokens: 0.08,
context_window: 200000,
},
};
// Default pricing for unknown models (Sonnet rates)
exports.DEFAULT_PRICING = {
name: 'Unknown 🤷',
input_tokens: 3,
output_tokens: 15,
cache_tokens: 0.3,
context_window: 200000,
};
//# sourceMappingURL=config.js.map