@vimukthid/ccsl 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,707 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ StatusInputSchema: () => StatusInputSchema,
34
+ availableWidgets: () => availableWidgets,
35
+ defaultConfig: () => defaultConfig,
36
+ formatStatusLine: () => formatStatusLine,
37
+ getClaudeSettingsPath: () => getClaudeSettingsPath,
38
+ installToClaudeSettings: () => installToClaudeSettings,
39
+ isInstalledInClaude: () => isInstalledInClaude,
40
+ loadConfig: () => loadConfig,
41
+ parseStatusInput: () => parseStatusInput,
42
+ sampleStatusInput: () => sampleStatusInput,
43
+ themeNames: () => themeNames,
44
+ themes: () => themes,
45
+ uninstallFromClaudeSettings: () => uninstallFromClaudeSettings
46
+ });
47
+ module.exports = __toCommonJS(src_exports);
48
+
49
+ // src/themes/index.ts
50
+ var neonTheme = {
51
+ name: "neon",
52
+ colors: {
53
+ model: { fg: "#00ffff", bold: true },
54
+ context: { fg: "#ff00ff" },
55
+ contextHigh: { fg: "#ffff00" },
56
+ contextCritical: { fg: "#ff0000", bold: true },
57
+ tokens: { fg: "#00ff00" },
58
+ cost: { fg: "#ffff00" },
59
+ duration: { fg: "#00aaff" },
60
+ lines: { fg: "#ff6600" },
61
+ linesAdded: { fg: "#00ff00" },
62
+ linesRemoved: { fg: "#ff0066" },
63
+ directory: { fg: "#00ffff" },
64
+ version: { fg: "#aaaaff" },
65
+ separator: { fg: "#666666" }
66
+ }
67
+ };
68
+ var rainbowTheme = {
69
+ name: "rainbow",
70
+ colors: {
71
+ model: { fg: "#ff0000", bold: true },
72
+ context: { fg: "#ff7f00" },
73
+ contextHigh: { fg: "#ffff00" },
74
+ contextCritical: { fg: "#ff0000", bold: true },
75
+ tokens: { fg: "#00ff00" },
76
+ cost: { fg: "#0000ff" },
77
+ duration: { fg: "#4b0082" },
78
+ lines: { fg: "#9400d3" },
79
+ linesAdded: { fg: "#00ff00" },
80
+ linesRemoved: { fg: "#ff0000" },
81
+ directory: { fg: "#ff7f00" },
82
+ version: { fg: "#9400d3" },
83
+ separator: { fg: "#888888" }
84
+ }
85
+ };
86
+ var oceanTheme = {
87
+ name: "ocean",
88
+ colors: {
89
+ model: { fg: "#00bcd4", bold: true },
90
+ context: { fg: "#2d8b8b" },
91
+ contextHigh: { fg: "#4dd0e1" },
92
+ contextCritical: { fg: "#ff5252", bold: true },
93
+ tokens: { fg: "#80deea" },
94
+ cost: { fg: "#4dd0e1" },
95
+ duration: { fg: "#0288d1" },
96
+ lines: { fg: "#26c6da" },
97
+ linesAdded: { fg: "#69f0ae" },
98
+ linesRemoved: { fg: "#ff5252" },
99
+ directory: { fg: "#00bcd4" },
100
+ version: { fg: "#80deea" },
101
+ separator: { fg: "#37474f" }
102
+ }
103
+ };
104
+ var minimalTheme = {
105
+ name: "minimal",
106
+ colors: {
107
+ model: { fg: "#888888" },
108
+ context: { fg: "#ffffff" },
109
+ contextHigh: { fg: "#e5c07b" },
110
+ contextCritical: { fg: "#e06c75", bold: true },
111
+ tokens: { fg: "#666666", dim: true },
112
+ cost: { fg: "#61afef" },
113
+ duration: { fg: "#666666", dim: true },
114
+ lines: { fg: "#abb2bf" },
115
+ linesAdded: { fg: "#98c379" },
116
+ linesRemoved: { fg: "#e06c75" },
117
+ directory: { fg: "#888888" },
118
+ version: { fg: "#5c6370" },
119
+ separator: { fg: "#444444" }
120
+ },
121
+ icons: {
122
+ model: "",
123
+ context: "",
124
+ tokens: "",
125
+ duration: "",
126
+ lines: "",
127
+ directory: ""
128
+ }
129
+ };
130
+ var monochromeTheme = {
131
+ name: "monochrome",
132
+ colors: {
133
+ model: { fg: "#ffffff", bold: true },
134
+ context: { fg: "#cccccc" },
135
+ contextHigh: { fg: "#ffffff", bold: true },
136
+ contextCritical: { fg: "#ffffff", bold: true, underline: true },
137
+ tokens: { fg: "#aaaaaa" },
138
+ cost: { fg: "#999999" },
139
+ duration: { fg: "#888888" },
140
+ lines: { fg: "#777777" },
141
+ linesAdded: { fg: "#cccccc" },
142
+ linesRemoved: { fg: "#888888" },
143
+ directory: { fg: "#aaaaaa" },
144
+ version: { fg: "#666666" },
145
+ separator: { fg: "#444444" }
146
+ },
147
+ icons: {
148
+ model: "",
149
+ context: "",
150
+ tokens: "",
151
+ duration: "",
152
+ lines: "",
153
+ directory: ""
154
+ }
155
+ };
156
+ var corporateTheme = {
157
+ name: "corporate",
158
+ colors: {
159
+ model: { fg: "#3b82f6", bold: true },
160
+ context: { fg: "#64748b" },
161
+ contextHigh: { fg: "#f59e0b" },
162
+ contextCritical: { fg: "#ef4444", bold: true },
163
+ tokens: { fg: "#4682b4" },
164
+ cost: { fg: "#6b7280" },
165
+ duration: { fg: "#64748b" },
166
+ lines: { fg: "#94a3b8" },
167
+ linesAdded: { fg: "#22c55e" },
168
+ linesRemoved: { fg: "#ef4444" },
169
+ directory: { fg: "#3b82f6" },
170
+ version: { fg: "#94a3b8" },
171
+ separator: { fg: "#334155" }
172
+ }
173
+ };
174
+ var themes = {
175
+ neon: neonTheme,
176
+ rainbow: rainbowTheme,
177
+ ocean: oceanTheme,
178
+ minimal: minimalTheme,
179
+ monochrome: monochromeTheme,
180
+ corporate: corporateTheme
181
+ };
182
+ var themeNames = Object.keys(themes);
183
+
184
+ // src/utils/icons.ts
185
+ var nerdIcons = {
186
+ model: "\u25C8",
187
+ context: "\u25D0",
188
+ tokens: "\u{F0284}",
189
+ cost: "$",
190
+ duration: "\u23F1",
191
+ lines: "\xB1",
192
+ directory: "",
193
+ version: ""
194
+ };
195
+ var unicodeIcons = {
196
+ model: "\u25C8",
197
+ context: "\u25D0",
198
+ tokens: "\u21C5",
199
+ cost: "$",
200
+ duration: "\u23F1",
201
+ lines: "\xB1",
202
+ directory: "\u{1F4C1}",
203
+ version: "v"
204
+ };
205
+ var asciiIcons = {
206
+ model: "*",
207
+ context: "%",
208
+ tokens: "",
209
+ cost: "$",
210
+ duration: "",
211
+ lines: "",
212
+ directory: "",
213
+ version: "v"
214
+ };
215
+ var detectedIconMode = null;
216
+ function detectIconSupport() {
217
+ if (detectedIconMode !== null) {
218
+ return detectedIconMode;
219
+ }
220
+ const term = process.env.TERM || "";
221
+ const termProgram = process.env.TERM_PROGRAM || "";
222
+ const nerdFontEnv = process.env.NERD_FONT || "";
223
+ if (nerdFontEnv === "1" || nerdFontEnv.toLowerCase() === "true") {
224
+ detectedIconMode = "nerd";
225
+ return "nerd";
226
+ }
227
+ const nerdFontTerminals = ["iTerm.app", "WezTerm", "Alacritty", "kitty", "Hyper", "Tabby"];
228
+ if (nerdFontTerminals.some((t) => termProgram.includes(t))) {
229
+ detectedIconMode = "nerd";
230
+ return "nerd";
231
+ }
232
+ if (term.includes("256color") || term.includes("truecolor")) {
233
+ detectedIconMode = "unicode";
234
+ return "unicode";
235
+ }
236
+ detectedIconMode = "ascii";
237
+ return "ascii";
238
+ }
239
+ function getIcon(key, theme, mode) {
240
+ if (theme.icons && theme.icons[key]) {
241
+ return theme.icons[key] || "";
242
+ }
243
+ const effectiveMode = mode === "auto" ? detectIconSupport() : mode;
244
+ switch (effectiveMode) {
245
+ case "nerd":
246
+ return nerdIcons[key] || "";
247
+ case "unicode":
248
+ return unicodeIcons[key] || "";
249
+ case "ascii":
250
+ return asciiIcons[key] || "";
251
+ default:
252
+ return unicodeIcons[key] || "";
253
+ }
254
+ }
255
+
256
+ // src/utils/colors.ts
257
+ var import_chalk = __toESM(require("chalk"), 1);
258
+ function applyStyle(text, style) {
259
+ if (!style) return text;
260
+ let result = import_chalk.default;
261
+ if (style.fg) {
262
+ result = result.hex(style.fg);
263
+ }
264
+ if (style.bg) {
265
+ result = result.bgHex(style.bg);
266
+ }
267
+ if (style.bold) {
268
+ result = result.bold;
269
+ }
270
+ if (style.dim) {
271
+ result = result.dim;
272
+ }
273
+ if (style.italic) {
274
+ result = result.italic;
275
+ }
276
+ if (style.underline) {
277
+ result = result.underline;
278
+ }
279
+ return result(text);
280
+ }
281
+
282
+ // src/utils/format.ts
283
+ function formatNumber(num) {
284
+ if (num >= 1e6) {
285
+ return `${(num / 1e6).toFixed(1)}m`;
286
+ }
287
+ if (num >= 1e3) {
288
+ return `${(num / 1e3).toFixed(1)}k`;
289
+ }
290
+ return num.toString();
291
+ }
292
+ function formatDuration(ms) {
293
+ const seconds = Math.floor(ms / 1e3);
294
+ if (seconds < 60) {
295
+ return `${seconds}s`;
296
+ }
297
+ const minutes = Math.floor(seconds / 60);
298
+ if (minutes < 60) {
299
+ const remainingSeconds = seconds % 60;
300
+ return remainingSeconds > 0 ? `${minutes}m${remainingSeconds}s` : `${minutes}m`;
301
+ }
302
+ const hours = Math.floor(minutes / 60);
303
+ const remainingMinutes = minutes % 60;
304
+ return remainingMinutes > 0 ? `${hours}h${remainingMinutes}m` : `${hours}h`;
305
+ }
306
+ function formatCost(usd) {
307
+ if (usd < 0.01) {
308
+ return usd.toFixed(4);
309
+ }
310
+ if (usd < 1) {
311
+ return usd.toFixed(2);
312
+ }
313
+ return usd.toFixed(2);
314
+ }
315
+
316
+ // src/widgets/index.ts
317
+ var import_path = __toESM(require("path"), 1);
318
+ var availableWidgets = [
319
+ "model",
320
+ "context",
321
+ "tokens",
322
+ "cost",
323
+ "duration",
324
+ "lines",
325
+ "directory",
326
+ "version"
327
+ ];
328
+ function renderWidget(widget, input, theme, config) {
329
+ switch (widget) {
330
+ case "model":
331
+ return renderModel(input, theme, config);
332
+ case "context":
333
+ return renderContext(input, theme, config);
334
+ case "tokens":
335
+ return renderTokens(input, theme, config);
336
+ case "cost":
337
+ return renderCostWidget(input, theme, config);
338
+ case "duration":
339
+ return renderDurationWidget(input, theme, config);
340
+ case "lines":
341
+ return renderLines(input, theme, config);
342
+ case "directory":
343
+ return renderDirectory(input, theme, config);
344
+ case "version":
345
+ return renderVersion(input, theme, config);
346
+ default:
347
+ return { content: "", visible: false };
348
+ }
349
+ }
350
+ function renderModel(input, theme, config) {
351
+ const displayName = input.model?.display_name;
352
+ if (!displayName) {
353
+ return { content: "", visible: false };
354
+ }
355
+ const icon = getIcon("model", theme, config.icons);
356
+ const text = icon ? `${icon} ${displayName}` : displayName;
357
+ const content = applyStyle(text, theme.colors.model);
358
+ return { content, visible: true };
359
+ }
360
+ function renderContext(input, theme, config) {
361
+ const percentage = input.context_window?.used_percentage;
362
+ if (percentage === void 0) {
363
+ return { content: "", visible: false };
364
+ }
365
+ const icon = getIcon("context", theme, config.icons);
366
+ const roundedPercent = Math.round(percentage);
367
+ const progressBar = renderProgressBar(percentage, theme);
368
+ const value = `${roundedPercent}%`;
369
+ const text = icon ? `${icon} ${progressBar} ${value}` : `${progressBar} ${value}`;
370
+ let colorKey = "context";
371
+ if (percentage >= 80) {
372
+ colorKey = "contextCritical";
373
+ } else if (percentage >= 60) {
374
+ colorKey = "contextHigh";
375
+ }
376
+ const style = theme.colors[colorKey] || theme.colors.context;
377
+ const content = applyStyle(text, style);
378
+ return { content, visible: true };
379
+ }
380
+ function renderProgressBar(percentage, theme) {
381
+ const totalBars = 10;
382
+ const filledBars = Math.round(percentage / 100 * totalBars);
383
+ const emptyBars = totalBars - filledBars;
384
+ const filledChar = "\u2588";
385
+ const emptyChar = "\u2591";
386
+ let filledStyle = theme.colors.context;
387
+ if (percentage >= 80) {
388
+ filledStyle = theme.colors.contextCritical || theme.colors.context;
389
+ } else if (percentage >= 60) {
390
+ filledStyle = theme.colors.contextHigh || theme.colors.context;
391
+ }
392
+ const filled = applyStyle(filledChar.repeat(filledBars), filledStyle);
393
+ const empty = applyStyle(emptyChar.repeat(emptyBars), { fg: "#444444", dim: true });
394
+ return `${filled}${empty}`;
395
+ }
396
+ function renderTokens(input, theme, config) {
397
+ const inputTokens = input.context_window?.total_input_tokens;
398
+ const outputTokens = input.context_window?.total_output_tokens;
399
+ if (inputTokens === void 0 && outputTokens === void 0) {
400
+ return { content: "", visible: false };
401
+ }
402
+ const icon = getIcon("tokens", theme, config.icons);
403
+ const inStr = formatNumber(inputTokens ?? 0);
404
+ const outStr = formatNumber(outputTokens ?? 0);
405
+ const text = icon ? `${icon} \u2191${inStr} \u2193${outStr}` : `\u2191${inStr} \u2193${outStr}`;
406
+ const content = applyStyle(text, theme.colors.tokens);
407
+ return { content, visible: true };
408
+ }
409
+ function renderCostWidget(input, theme, config) {
410
+ const costUsd = input.cost?.total_cost_usd;
411
+ if (costUsd === void 0) {
412
+ return { content: "", visible: false };
413
+ }
414
+ const icon = getIcon("cost", theme, config.icons);
415
+ const value = formatCost(costUsd);
416
+ const text = icon ? `${icon}${value}` : `$${value}`;
417
+ const content = applyStyle(text, theme.colors.cost);
418
+ return { content, visible: true };
419
+ }
420
+ function renderDurationWidget(input, theme, config) {
421
+ const durationMs = input.cost?.total_duration_ms;
422
+ if (durationMs === void 0) {
423
+ return { content: "", visible: false };
424
+ }
425
+ const icon = getIcon("duration", theme, config.icons);
426
+ const value = formatDuration(durationMs);
427
+ const text = icon ? `${icon} ${value}` : value;
428
+ const content = applyStyle(text, theme.colors.duration);
429
+ return { content, visible: true };
430
+ }
431
+ function renderLines(input, theme, config) {
432
+ const added = input.cost?.total_lines_added;
433
+ const removed = input.cost?.total_lines_removed;
434
+ if (added === void 0 && removed === void 0) {
435
+ return { content: "", visible: false };
436
+ }
437
+ const icon = getIcon("lines", theme, config.icons);
438
+ const addedStr = applyStyle(`+${added ?? 0}`, theme.colors.linesAdded || theme.colors.lines);
439
+ const removedStr = applyStyle(`-${removed ?? 0}`, theme.colors.linesRemoved || theme.colors.lines);
440
+ const text = icon ? `${icon} ${addedStr} ${removedStr}` : `${addedStr} ${removedStr}`;
441
+ return { content: text, visible: true };
442
+ }
443
+ function renderDirectory(input, theme, config) {
444
+ const dir = input.workspace?.current_dir || input.cwd;
445
+ if (!dir) {
446
+ return { content: "", visible: false };
447
+ }
448
+ const icon = getIcon("directory", theme, config.icons);
449
+ const dirName = import_path.default.basename(dir);
450
+ const text = icon ? `${icon} ${dirName}` : dirName;
451
+ const content = applyStyle(text, theme.colors.directory);
452
+ return { content, visible: true };
453
+ }
454
+ function renderVersion(input, theme, config) {
455
+ const version = input.version;
456
+ if (!version) {
457
+ return { content: "", visible: false };
458
+ }
459
+ const icon = getIcon("version", theme, config.icons);
460
+ const text = icon ? `${icon}${version}` : `v${version}`;
461
+ const content = applyStyle(text, theme.colors.version);
462
+ return { content, visible: true };
463
+ }
464
+
465
+ // src/formatter.ts
466
+ function formatStatusLine(input, config) {
467
+ const theme = config.customTheme || themes[config.theme] || themes.minimal;
468
+ const renderedWidgets = [];
469
+ for (const widget of config.widgets) {
470
+ const result = renderWidget(widget, input, theme, config);
471
+ if (result.visible && result.content) {
472
+ renderedWidgets.push(result.content);
473
+ }
474
+ }
475
+ if (renderedWidgets.length === 0) {
476
+ return "";
477
+ }
478
+ const separator = applyStyle(config.separator, theme.colors.separator);
479
+ const statusLine = renderedWidgets.join(separator);
480
+ const padding = " ".repeat(config.padding);
481
+ return `\x1B[0m${padding}${statusLine}${padding}`;
482
+ }
483
+ var sampleStatusInput = {
484
+ hook_event_name: "Status",
485
+ session_id: "sample-session-123",
486
+ model: {
487
+ id: "claude-opus-4-1",
488
+ display_name: "Opus"
489
+ },
490
+ workspace: {
491
+ current_dir: "/home/user/my-project",
492
+ project_dir: "/home/user/my-project"
493
+ },
494
+ version: "1.0.80",
495
+ cost: {
496
+ total_cost_usd: 0.0234,
497
+ total_duration_ms: 45e3,
498
+ total_api_duration_ms: 2300,
499
+ total_lines_added: 156,
500
+ total_lines_removed: 23
501
+ },
502
+ context_window: {
503
+ total_input_tokens: 15234,
504
+ total_output_tokens: 4521,
505
+ context_window_size: 2e5,
506
+ used_percentage: 42.5,
507
+ remaining_percentage: 57.5,
508
+ current_usage: {
509
+ input_tokens: 8500,
510
+ output_tokens: 1200,
511
+ cache_creation_input_tokens: 5e3,
512
+ cache_read_input_tokens: 2e3
513
+ }
514
+ }
515
+ };
516
+
517
+ // src/parser.ts
518
+ var import_zod = require("zod");
519
+ var StatusInputSchema = import_zod.z.object({
520
+ hook_event_name: import_zod.z.string().optional(),
521
+ session_id: import_zod.z.string().optional(),
522
+ transcript_path: import_zod.z.string().optional(),
523
+ cwd: import_zod.z.string().optional(),
524
+ model: import_zod.z.object({
525
+ id: import_zod.z.string().optional(),
526
+ display_name: import_zod.z.string().optional()
527
+ }).optional(),
528
+ workspace: import_zod.z.object({
529
+ current_dir: import_zod.z.string().optional(),
530
+ project_dir: import_zod.z.string().optional()
531
+ }).optional(),
532
+ version: import_zod.z.string().optional(),
533
+ output_style: import_zod.z.object({
534
+ name: import_zod.z.string().optional()
535
+ }).optional(),
536
+ cost: import_zod.z.object({
537
+ total_cost_usd: import_zod.z.number().optional(),
538
+ total_duration_ms: import_zod.z.number().optional(),
539
+ total_api_duration_ms: import_zod.z.number().optional(),
540
+ total_lines_added: import_zod.z.number().optional(),
541
+ total_lines_removed: import_zod.z.number().optional()
542
+ }).optional(),
543
+ context_window: import_zod.z.object({
544
+ total_input_tokens: import_zod.z.number().optional(),
545
+ total_output_tokens: import_zod.z.number().optional(),
546
+ context_window_size: import_zod.z.number().optional(),
547
+ used_percentage: import_zod.z.number().optional(),
548
+ remaining_percentage: import_zod.z.number().optional(),
549
+ current_usage: import_zod.z.object({
550
+ input_tokens: import_zod.z.number().optional(),
551
+ output_tokens: import_zod.z.number().optional(),
552
+ cache_creation_input_tokens: import_zod.z.number().optional(),
553
+ cache_read_input_tokens: import_zod.z.number().optional()
554
+ }).nullable().optional()
555
+ }).optional()
556
+ }).passthrough();
557
+ function parseStatusInput(input) {
558
+ try {
559
+ const trimmed = input.trim();
560
+ if (!trimmed) {
561
+ return null;
562
+ }
563
+ const parsed = JSON.parse(trimmed);
564
+ const result = StatusInputSchema.safeParse(parsed);
565
+ if (result.success) {
566
+ return result.data;
567
+ }
568
+ return parsed;
569
+ } catch {
570
+ return null;
571
+ }
572
+ }
573
+
574
+ // src/config/loader.ts
575
+ var import_cosmiconfig = require("cosmiconfig");
576
+
577
+ // src/config/defaults.ts
578
+ var defaultWidgets = ["model", "context", "tokens", "cost"];
579
+ var defaultConfig = {
580
+ theme: "minimal",
581
+ widgets: defaultWidgets,
582
+ separator: " \u2502 ",
583
+ icons: "auto",
584
+ padding: 1
585
+ };
586
+
587
+ // src/config/loader.ts
588
+ var explorer = (0, import_cosmiconfig.cosmiconfig)("ccsl", {
589
+ searchPlaces: [
590
+ ".ccslrc",
591
+ ".ccslrc.json",
592
+ ".ccslrc.yaml",
593
+ ".ccslrc.yml",
594
+ ".ccslrc.js",
595
+ ".ccslrc.cjs",
596
+ ".config/ccsl/config.json",
597
+ "ccsl.config.js",
598
+ "ccsl.config.cjs"
599
+ ]
600
+ });
601
+ async function loadConfig(searchFrom) {
602
+ try {
603
+ const result = await explorer.search(searchFrom);
604
+ if (result && result.config) {
605
+ return mergeConfig(defaultConfig, result.config);
606
+ }
607
+ } catch {
608
+ }
609
+ return { ...defaultConfig };
610
+ }
611
+ function mergeConfig(defaults, userConfig) {
612
+ return {
613
+ theme: userConfig.theme ?? defaults.theme,
614
+ widgets: userConfig.widgets ?? defaults.widgets,
615
+ separator: userConfig.separator ?? defaults.separator,
616
+ icons: userConfig.icons ?? defaults.icons,
617
+ padding: userConfig.padding ?? defaults.padding,
618
+ customTheme: userConfig.customTheme
619
+ };
620
+ }
621
+
622
+ // src/config/claude.ts
623
+ var import_fs = require("fs");
624
+ var import_path2 = require("path");
625
+ var import_os = require("os");
626
+ function getClaudeSettingsPath() {
627
+ const claudeDir = process.env.CLAUDE_CONFIG_DIR || (0, import_path2.join)((0, import_os.homedir)(), ".claude");
628
+ return (0, import_path2.join)(claudeDir, "settings.json");
629
+ }
630
+ function getClaudeSettings() {
631
+ const settingsPath = getClaudeSettingsPath();
632
+ if (!(0, import_fs.existsSync)(settingsPath)) {
633
+ return null;
634
+ }
635
+ try {
636
+ const content = (0, import_fs.readFileSync)(settingsPath, "utf8");
637
+ return JSON.parse(content);
638
+ } catch {
639
+ return null;
640
+ }
641
+ }
642
+ function installToClaudeSettings(command = "npx @vimukthid/ccsl") {
643
+ const settingsPath = getClaudeSettingsPath();
644
+ const dir = (0, import_path2.dirname)(settingsPath);
645
+ if (!(0, import_fs.existsSync)(dir)) {
646
+ (0, import_fs.mkdirSync)(dir, { recursive: true });
647
+ }
648
+ let settings = {};
649
+ if ((0, import_fs.existsSync)(settingsPath)) {
650
+ try {
651
+ const content = (0, import_fs.readFileSync)(settingsPath, "utf8");
652
+ settings = JSON.parse(content);
653
+ } catch {
654
+ settings = {};
655
+ }
656
+ }
657
+ settings.statusLine = {
658
+ type: "command",
659
+ command
660
+ };
661
+ try {
662
+ (0, import_fs.writeFileSync)(settingsPath, JSON.stringify(settings, null, 2));
663
+ return true;
664
+ } catch {
665
+ return false;
666
+ }
667
+ }
668
+ function uninstallFromClaudeSettings() {
669
+ const settingsPath = getClaudeSettingsPath();
670
+ if (!(0, import_fs.existsSync)(settingsPath)) {
671
+ return true;
672
+ }
673
+ try {
674
+ const content = (0, import_fs.readFileSync)(settingsPath, "utf8");
675
+ const settings = JSON.parse(content);
676
+ delete settings.statusLine;
677
+ (0, import_fs.writeFileSync)(settingsPath, JSON.stringify(settings, null, 2));
678
+ return true;
679
+ } catch {
680
+ return false;
681
+ }
682
+ }
683
+ function isInstalledInClaude() {
684
+ const settings = getClaudeSettings();
685
+ if (!settings?.statusLine) {
686
+ return false;
687
+ }
688
+ const command = settings.statusLine.command || "";
689
+ return command.includes("ccsl") || command.includes("@vimukthid/ccsl");
690
+ }
691
+ // Annotate the CommonJS export names for ESM import in node:
692
+ 0 && (module.exports = {
693
+ StatusInputSchema,
694
+ availableWidgets,
695
+ defaultConfig,
696
+ formatStatusLine,
697
+ getClaudeSettingsPath,
698
+ installToClaudeSettings,
699
+ isInstalledInClaude,
700
+ loadConfig,
701
+ parseStatusInput,
702
+ sampleStatusInput,
703
+ themeNames,
704
+ themes,
705
+ uninstallFromClaudeSettings
706
+ });
707
+ //# sourceMappingURL=index.cjs.map