@nekoline/ccline 1.1.2-nekoline.1

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/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # @nekoline/ccline
2
+
3
+ CCometixLine - High-performance Claude Code StatusLine tool
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @nekoline/ccline
9
+ ```
10
+
11
+ ## Features
12
+
13
+ - 🚀 **Fast**: Written in Rust for maximum performance
14
+ - 🌍 **Cross-platform**: Works on Windows, macOS, and Linux
15
+ - 📦 **Easy installation**: One command via npm
16
+ - 🔄 **Auto-update**: Built-in update notifications
17
+ - 🎨 **Beautiful**: Nerd Font icons and colors
18
+
19
+ ## Usage
20
+
21
+ After installation, ccline is automatically configured for Claude Code at `~/.claude/ccline/ccline`.
22
+
23
+ You can also use it directly:
24
+
25
+ ```bash
26
+ ccline --help
27
+ ccline --version
28
+ ```
29
+
30
+ ## For Users in China
31
+
32
+ Use npm mirror for faster installation:
33
+
34
+ ```bash
35
+ npm install -g @nekoline/ccline --registry https://registry.npmmirror.com
36
+ ```
37
+
38
+ ## More Information
39
+
40
+ - GitHub: https://github.com/LemonYangZW/CCometixLine
41
+ - Issues: https://github.com/LemonYangZW/CCometixLine/issues
42
+ - License: MIT
package/bin/ccline.js ADDED
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env node
2
+ const { spawnSync } = require('child_process');
3
+ const path = require('path');
4
+ const fs = require('fs');
5
+ const os = require('os');
6
+
7
+ // 1. Priority: Use ~/.claude/ccline/ccline if exists
8
+ const claudePath = path.join(
9
+ os.homedir(),
10
+ '.claude',
11
+ 'ccline',
12
+ process.platform === 'win32' ? 'ccline.exe' : 'ccline'
13
+ );
14
+
15
+ if (fs.existsSync(claudePath)) {
16
+ const result = spawnSync(claudePath, process.argv.slice(2), {
17
+ stdio: 'inherit',
18
+ shell: false
19
+ });
20
+ process.exit(result.status || 0);
21
+ }
22
+
23
+ // 2. Fallback: Use npm package binary
24
+ const platform = process.platform;
25
+ const arch = process.arch;
26
+
27
+ // Handle special cases
28
+ let platformKey = `${platform}-${arch}`;
29
+ if (platform === 'linux') {
30
+ // Detect libc type and version
31
+ function getLibcInfo() {
32
+ try {
33
+ const { execSync } = require('child_process');
34
+ const lddOutput = execSync('ldd --version 2>/dev/null || echo ""', {
35
+ encoding: 'utf8',
36
+ timeout: 1000
37
+ });
38
+
39
+ // Check for musl explicitly
40
+ if (lddOutput.includes('musl')) {
41
+ return { type: 'musl' };
42
+ }
43
+
44
+ // Parse glibc version: "ldd (GNU libc) 2.35" format
45
+ const match = lddOutput.match(/(?:GNU libc|GLIBC).*?(\d+)\.(\d+)/);
46
+ if (match) {
47
+ const major = parseInt(match[1]);
48
+ const minor = parseInt(match[2]);
49
+ return { type: 'glibc', major, minor };
50
+ }
51
+
52
+ // If we can't detect, default to musl for safety (more portable)
53
+ return { type: 'musl' };
54
+ } catch (e) {
55
+ // If detection fails, default to musl (more portable)
56
+ return { type: 'musl' };
57
+ }
58
+ }
59
+
60
+ const libcInfo = getLibcInfo();
61
+
62
+ if (arch === 'arm64') {
63
+ // ARM64 Linux: choose based on libc type and version
64
+ if (libcInfo.type === 'musl' ||
65
+ (libcInfo.type === 'glibc' && (libcInfo.major < 2 || (libcInfo.major === 2 && libcInfo.minor < 35)))) {
66
+ platformKey = 'linux-arm64-musl';
67
+ } else {
68
+ platformKey = 'linux-arm64';
69
+ }
70
+ } else {
71
+ // x64 Linux: choose based on libc type and version
72
+ if (libcInfo.type === 'musl' ||
73
+ (libcInfo.type === 'glibc' && (libcInfo.major < 2 || (libcInfo.major === 2 && libcInfo.minor < 35)))) {
74
+ platformKey = 'linux-x64-musl';
75
+ }
76
+ }
77
+ }
78
+
79
+ const packageMap = {
80
+ 'darwin-x64': '@nekoline/ccline-darwin-x64',
81
+ 'darwin-arm64': '@nekoline/ccline-darwin-arm64',
82
+ 'linux-x64': '@nekoline/ccline-linux-x64',
83
+ 'linux-x64-musl': '@nekoline/ccline-linux-x64-musl',
84
+ 'linux-arm64': '@nekoline/ccline-linux-arm64',
85
+ 'linux-arm64-musl': '@nekoline/ccline-linux-arm64-musl',
86
+ 'win32-x64': '@nekoline/ccline-win32-x64',
87
+ 'win32-ia32': '@nekoline/ccline-win32-x64', // Use 64-bit for 32-bit systems
88
+ };
89
+
90
+ const packageName = packageMap[platformKey];
91
+ if (!packageName) {
92
+ console.error(`Error: Unsupported platform ${platformKey}`);
93
+ console.error('Supported platforms: darwin (x64/arm64), linux (x64/arm64), win32 (x64)');
94
+ console.error('Please visit https://github.com/LemonYangZW/CCometixLine for manual installation');
95
+ process.exit(1);
96
+ }
97
+
98
+ const binaryName = platform === 'win32' ? 'ccline.exe' : 'ccline';
99
+ const binaryPath = path.join(__dirname, '..', 'node_modules', packageName, binaryName);
100
+
101
+ if (!fs.existsSync(binaryPath)) {
102
+ console.error(`Error: Binary not found at ${binaryPath}`);
103
+ console.error('This might indicate a failed installation or unsupported platform.');
104
+ console.error('Please try reinstalling: npm install -g @nekoline/ccline');
105
+ console.error(`Expected package: ${packageName}`);
106
+ process.exit(1);
107
+ }
108
+
109
+ const result = spawnSync(binaryPath, process.argv.slice(2), {
110
+ stdio: 'inherit',
111
+ shell: false
112
+ });
113
+
114
+ process.exit(result.status || 0);
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@nekoline/ccline",
3
+ "version": "1.1.2-nekoline.1",
4
+ "description": "CCometixLine - High-performance Claude Code StatusLine with Sub2API usage tracking",
5
+ "bin": {
6
+ "ccline": "./bin/ccline.js"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node scripts/postinstall.js"
10
+ },
11
+ "optionalDependencies": {
12
+ "@nekoline/ccline-darwin-x64": "1.1.2-nekoline.1",
13
+ "@nekoline/ccline-darwin-arm64": "1.1.2-nekoline.1",
14
+ "@nekoline/ccline-linux-x64": "1.1.2-nekoline.1",
15
+ "@nekoline/ccline-linux-x64-musl": "1.1.2-nekoline.1",
16
+ "@nekoline/ccline-linux-arm64": "1.1.2-nekoline.1",
17
+ "@nekoline/ccline-linux-arm64-musl": "1.1.2-nekoline.1",
18
+ "@nekoline/ccline-win32-x64": "1.1.2-nekoline.1"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/LemonYangZW/CCometixLine"
23
+ },
24
+ "keywords": [
25
+ "claude",
26
+ "statusline",
27
+ "claude-code",
28
+ "rust",
29
+ "cli",
30
+ "sub2api"
31
+ ],
32
+ "author": "LemonYangZW",
33
+ "license": "MIT",
34
+ "engines": {
35
+ "node": ">=14.0.0"
36
+ }
37
+ }
@@ -0,0 +1,181 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const os = require('os');
4
+
5
+ // Silent mode detection
6
+ const silent = process.env.npm_config_loglevel === 'silent' ||
7
+ process.env.CCLINE_SKIP_POSTINSTALL === '1';
8
+
9
+ if (!silent) {
10
+ console.log('🚀 Setting up CCometixLine for Claude Code...');
11
+ }
12
+
13
+ try {
14
+ const platform = process.platform;
15
+ const arch = process.arch;
16
+ const homeDir = os.homedir();
17
+ const claudeDir = path.join(homeDir, '.claude', 'ccline');
18
+
19
+ // Create directory
20
+ fs.mkdirSync(claudeDir, { recursive: true });
21
+
22
+ // Determine platform key
23
+ let platformKey = `${platform}-${arch}`;
24
+ if (platform === 'linux') {
25
+ // Detect libc type and version
26
+ function getLibcInfo() {
27
+ try {
28
+ const { execSync } = require('child_process');
29
+ const lddOutput = execSync('ldd --version 2>/dev/null || echo ""', {
30
+ encoding: 'utf8',
31
+ timeout: 1000
32
+ });
33
+
34
+ // Check for musl explicitly
35
+ if (lddOutput.includes('musl')) {
36
+ return { type: 'musl' };
37
+ }
38
+
39
+ // Parse glibc version: "ldd (GNU libc) 2.35" format
40
+ const match = lddOutput.match(/(?:GNU libc|GLIBC).*?(\d+)\.(\d+)/);
41
+ if (match) {
42
+ const major = parseInt(match[1]);
43
+ const minor = parseInt(match[2]);
44
+ return { type: 'glibc', major, minor };
45
+ }
46
+
47
+ // If we can't detect, default to musl for safety (more portable)
48
+ return { type: 'musl' };
49
+ } catch (e) {
50
+ // If detection fails, default to musl (more portable)
51
+ return { type: 'musl' };
52
+ }
53
+ }
54
+
55
+ const libcInfo = getLibcInfo();
56
+
57
+ if (arch === 'arm64') {
58
+ // ARM64 Linux: choose based on libc type and version
59
+ if (libcInfo.type === 'musl' ||
60
+ (libcInfo.type === 'glibc' && (libcInfo.major < 2 || (libcInfo.major === 2 && libcInfo.minor < 35)))) {
61
+ platformKey = 'linux-arm64-musl';
62
+ } else {
63
+ platformKey = 'linux-arm64';
64
+ }
65
+ } else {
66
+ // x64 Linux: choose based on libc type and version
67
+ if (libcInfo.type === 'musl' ||
68
+ (libcInfo.type === 'glibc' && (libcInfo.major < 2 || (libcInfo.major === 2 && libcInfo.minor < 35)))) {
69
+ platformKey = 'linux-x64-musl';
70
+ }
71
+ }
72
+ }
73
+
74
+ const packageMap = {
75
+ 'darwin-x64': '@nekoline/ccline-darwin-x64',
76
+ 'darwin-arm64': '@nekoline/ccline-darwin-arm64',
77
+ 'linux-x64': '@nekoline/ccline-linux-x64',
78
+ 'linux-x64-musl': '@nekoline/ccline-linux-x64-musl',
79
+ 'linux-arm64': '@nekoline/ccline-linux-arm64',
80
+ 'linux-arm64-musl': '@nekoline/ccline-linux-arm64-musl',
81
+ 'win32-x64': '@nekoline/ccline-win32-x64',
82
+ 'win32-ia32': '@nekoline/ccline-win32-x64', // Use 64-bit for 32-bit
83
+ };
84
+
85
+ const packageName = packageMap[platformKey];
86
+ if (!packageName) {
87
+ if (!silent) {
88
+ console.log(`Platform ${platformKey} not supported for auto-setup`);
89
+ }
90
+ process.exit(0);
91
+ }
92
+
93
+ const binaryName = platform === 'win32' ? 'ccline.exe' : 'ccline';
94
+ const targetPath = path.join(claudeDir, binaryName);
95
+
96
+ // Multiple path search strategies for different package managers
97
+ const findBinaryPath = () => {
98
+ const possiblePaths = [
99
+ // npm/yarn: nested in node_modules
100
+ path.join(__dirname, '..', 'node_modules', packageName, binaryName),
101
+ // pnpm: try require.resolve first
102
+ (() => {
103
+ try {
104
+ const packagePath = require.resolve(packageName + '/package.json');
105
+ return path.join(path.dirname(packagePath), binaryName);
106
+ } catch {
107
+ return null;
108
+ }
109
+ })(),
110
+ // pnpm: flat structure fallback with version detection
111
+ (() => {
112
+ const currentPath = __dirname;
113
+ const pnpmMatch = currentPath.match(/(.+\.pnpm)[\\/]([^\\//]+)[\\/]/);
114
+ if (pnpmMatch) {
115
+ const pnpmRoot = pnpmMatch[1];
116
+ const packageNameEncoded = packageName.replace('/', '+');
117
+
118
+ try {
119
+ // Try to find any version of the package
120
+ const pnpmContents = fs.readdirSync(pnpmRoot);
121
+ const packagePattern = new RegExp(`^${packageNameEncoded.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}@`);
122
+ const matchingPackage = pnpmContents.find(dir => packagePattern.test(dir));
123
+
124
+ if (matchingPackage) {
125
+ return path.join(pnpmRoot, matchingPackage, 'node_modules', packageName, binaryName);
126
+ }
127
+ } catch {
128
+ // Fallback to current behavior if directory reading fails
129
+ }
130
+ }
131
+ return null;
132
+ })()
133
+ ].filter(p => p !== null);
134
+
135
+ for (const testPath of possiblePaths) {
136
+ if (fs.existsSync(testPath)) {
137
+ return testPath;
138
+ }
139
+ }
140
+ return null;
141
+ };
142
+
143
+ const sourcePath = findBinaryPath();
144
+ if (!sourcePath) {
145
+ if (!silent) {
146
+ console.log('Binary package not installed, skipping Claude Code setup');
147
+ console.log('The global ccline command will still work via npm');
148
+ }
149
+ process.exit(0);
150
+ }
151
+
152
+ // Copy or link the binary
153
+ if (platform === 'win32') {
154
+ // Windows: Copy file
155
+ fs.copyFileSync(sourcePath, targetPath);
156
+ } else {
157
+ // Unix: Try hard link first, fallback to copy
158
+ try {
159
+ if (fs.existsSync(targetPath)) {
160
+ fs.unlinkSync(targetPath);
161
+ }
162
+ fs.linkSync(sourcePath, targetPath);
163
+ } catch {
164
+ fs.copyFileSync(sourcePath, targetPath);
165
+ }
166
+ fs.chmodSync(targetPath, '755');
167
+ }
168
+
169
+ if (!silent) {
170
+ console.log('✨ CCometixLine is ready for Claude Code!');
171
+ console.log(`📍 Location: ${targetPath}`);
172
+ console.log('🎉 You can now use: ccline --help');
173
+ }
174
+ } catch (error) {
175
+ // Silent failure - don't break installation
176
+ if (!silent) {
177
+ console.log('Note: Could not auto-configure for Claude Code');
178
+ console.log('The global ccline command will still work.');
179
+ console.log('You can manually copy ccline to ~/.claude/ccline/ if needed');
180
+ }
181
+ }