cc-minimal-statusline 1.0.0 ā 1.0.2
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/package.json +1 -1
- package/scripts/postinstall.js +67 -10
- package/statusline.sh +27 -3
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -3,19 +3,76 @@
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const os = require('os');
|
|
6
|
+
const readline = require('readline');
|
|
6
7
|
|
|
7
|
-
const scriptPath = path.join(__dirname, '..', 'statusline.sh');
|
|
8
8
|
const configDir = path.join(os.homedir(), '.claude');
|
|
9
9
|
const settingsPath = path.join(configDir, 'settings.json');
|
|
10
10
|
|
|
11
|
+
const statusLineConfig = {
|
|
12
|
+
type: 'command',
|
|
13
|
+
command: 'cc-minimal-statusline',
|
|
14
|
+
padding: 0
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
function configureSettings() {
|
|
18
|
+
// Create .claude directory if it doesn't exist
|
|
19
|
+
if (!fs.existsSync(configDir)) {
|
|
20
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let settings = {};
|
|
24
|
+
|
|
25
|
+
// Read existing settings if they exist
|
|
26
|
+
if (fs.existsSync(settingsPath)) {
|
|
27
|
+
try {
|
|
28
|
+
const content = fs.readFileSync(settingsPath, 'utf8');
|
|
29
|
+
settings = JSON.parse(content);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
console.log('Warning: Could not parse existing settings.json, creating backup...');
|
|
32
|
+
fs.copyFileSync(settingsPath, settingsPath + '.backup');
|
|
33
|
+
settings = {};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Add statusLine config
|
|
38
|
+
settings.statusLine = statusLineConfig;
|
|
39
|
+
|
|
40
|
+
// Write settings
|
|
41
|
+
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n');
|
|
42
|
+
console.log('\nā
Status line configured in ~/.claude/settings.json');
|
|
43
|
+
console.log('\nš” Tip: Make sure you have a Nerd Font installed for icons to display correctly.');
|
|
44
|
+
console.log(' brew install --cask font-meslo-lg-nerd-font\n');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function showManualInstructions() {
|
|
48
|
+
console.log('\nTo enable manually, add this to your ~/.claude/settings.json:\n');
|
|
49
|
+
console.log(JSON.stringify({ statusLine: statusLineConfig }, null, 2));
|
|
50
|
+
console.log('\nš” Tip: Make sure you have a Nerd Font installed for icons to display correctly.');
|
|
51
|
+
console.log(' brew install --cask font-meslo-lg-nerd-font\n');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Check if running in interactive terminal
|
|
55
|
+
if (!process.stdin.isTTY) {
|
|
56
|
+
console.log('\nš cc-minimal-statusline installed!');
|
|
57
|
+
showManualInstructions();
|
|
58
|
+
process.exit(0);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const rl = readline.createInterface({
|
|
62
|
+
input: process.stdin,
|
|
63
|
+
output: process.stdout
|
|
64
|
+
});
|
|
65
|
+
|
|
11
66
|
console.log('\nš cc-minimal-statusline installed!\n');
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
67
|
+
|
|
68
|
+
rl.question('Configure Claude Code to use this status line? (Y/n) ', (answer) => {
|
|
69
|
+
rl.close();
|
|
70
|
+
|
|
71
|
+
const shouldConfigure = !answer || answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes';
|
|
72
|
+
|
|
73
|
+
if (shouldConfigure) {
|
|
74
|
+
configureSettings();
|
|
75
|
+
} else {
|
|
76
|
+
showManualInstructions();
|
|
18
77
|
}
|
|
19
|
-
}
|
|
20
|
-
console.log('\nš” Tip: Make sure you have a Nerd Font installed for icons to display correctly.');
|
|
21
|
-
console.log(' brew install --cask font-meslo-lg-nerd-font\n');
|
|
78
|
+
});
|
package/statusline.sh
CHANGED
|
@@ -73,11 +73,35 @@ check_latest_version() {
|
|
|
73
73
|
is_outdated=$(check_latest_version)
|
|
74
74
|
|
|
75
75
|
# Check if autocompact is enabled (default: true)
|
|
76
|
-
#
|
|
76
|
+
# Checks both global (~/.claude/) and project-level (.claude/) settings
|
|
77
77
|
autocompact_enabled="true"
|
|
78
|
-
|
|
78
|
+
check_autocompact_disabled() {
|
|
79
|
+
grep -q '"autoCompactEnabled"[[:space:]]*:[[:space:]]*false' "$1" 2>/dev/null
|
|
80
|
+
}
|
|
81
|
+
# Check global settings
|
|
82
|
+
if check_autocompact_disabled ~/.claude/settings.json; then
|
|
79
83
|
autocompact_enabled="false"
|
|
80
84
|
fi
|
|
85
|
+
# Check project settings (overrides global, most specific wins)
|
|
86
|
+
if [ -n "$current_dir" ]; then
|
|
87
|
+
git_root=$(git -C "$current_dir" rev-parse --show-toplevel 2>/dev/null)
|
|
88
|
+
# Check git root first (project-level)
|
|
89
|
+
if [ -n "$git_root" ] && [ -f "$git_root/.claude/settings.json" ]; then
|
|
90
|
+
if check_autocompact_disabled "$git_root/.claude/settings.json"; then
|
|
91
|
+
autocompact_enabled="false"
|
|
92
|
+
elif grep -q '"autoCompactEnabled"[[:space:]]*:[[:space:]]*true' "$git_root/.claude/settings.json" 2>/dev/null; then
|
|
93
|
+
autocompact_enabled="true"
|
|
94
|
+
fi
|
|
95
|
+
fi
|
|
96
|
+
# Check current dir last (subdirectory can override project)
|
|
97
|
+
if [ -n "$git_root" ] && [ "$git_root" != "$current_dir" ] && [ -f "$current_dir/.claude/settings.json" ]; then
|
|
98
|
+
if check_autocompact_disabled "$current_dir/.claude/settings.json"; then
|
|
99
|
+
autocompact_enabled="false"
|
|
100
|
+
elif grep -q '"autoCompactEnabled"[[:space:]]*:[[:space:]]*true' "$current_dir/.claude/settings.json" 2>/dev/null; then
|
|
101
|
+
autocompact_enabled="true"
|
|
102
|
+
fi
|
|
103
|
+
fi
|
|
104
|
+
fi
|
|
81
105
|
|
|
82
106
|
# Adjust for autocompact buffer (22.5% reserved = 77.5% usable)
|
|
83
107
|
# Only apply when autocompact is enabled
|
|
@@ -284,7 +308,7 @@ build_status() {
|
|
|
284
308
|
|
|
285
309
|
# Files and lines changed from git status (only show if there are uncommitted changes)
|
|
286
310
|
if [ "$git_files" != "0" ] || [ "$git_added" != "0" ] || [ "$git_removed" != "0" ]; then
|
|
287
|
-
out="${out} ${sep} ${C_DIM}${ICON_FILES}${git_files}${C_RESET} ${C_GREEN}+${git_added}${C_DIM}/${C_RED}-${git_removed}${C_RESET}"
|
|
311
|
+
out="${out} ${sep} ${C_DIM}${ICON_FILES} ${git_files}${C_RESET} ${C_GREEN}+${git_added}${C_DIM}/${C_RED}-${git_removed}${C_RESET}"
|
|
288
312
|
fi
|
|
289
313
|
|
|
290
314
|
# Context percentage and bar (with compress icon if autocompact enabled)
|