@zuolan/micucodeline 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/README.md +45 -0
- package/bin/micucodeline.js +93 -0
- package/package.json +34 -0
- package/scripts/postinstall.js +160 -0
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# @openclaudecode/micucodeline
|
|
2
|
+
|
|
3
|
+
MicuCodeLine 是 openclaudecode 站特供版 Claude Code 状态栏工具。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
```bash
|
|
7
|
+
npm install -g @openclaudecode/micucodeline
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
安装后默认路径:`~/.claude/micucodeline/micucodeline`
|
|
11
|
+
|
|
12
|
+
## 使用
|
|
13
|
+
```bash
|
|
14
|
+
micucodeline --help
|
|
15
|
+
micucodeline --version
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Claude Code 配置
|
|
19
|
+
在 `~/.claude/settings.json` 中设置:
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"statusLine": {
|
|
23
|
+
"type": "command",
|
|
24
|
+
"command": "~/.claude/micucodeline/micucodeline",
|
|
25
|
+
"padding": 0
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## 余额配置
|
|
31
|
+
在 `settings.json` 的 `env` 中加入:
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"env": {
|
|
35
|
+
"ANTHROPIC_AUTH_TOKEN": "xxx",
|
|
36
|
+
"ANTHROPIC_BASE_URL": "xxx",
|
|
37
|
+
"BALANCE_API_KEY": "YOUR_TOKEN",
|
|
38
|
+
"BALANCE_API_USER": "12345"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
- 官网:https://www.openclaudecode.cn/
|
|
44
|
+
- 当前仓库:https://github.com/zuoliangyu/MICUCODELINE
|
|
45
|
+
- 原作者仓库:https://github.com/Haleclipse/CCometixLine
|
|
@@ -0,0 +1,93 @@
|
|
|
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/micucodeline/micucodeline if exists
|
|
8
|
+
const claudePath = path.join(
|
|
9
|
+
os.homedir(),
|
|
10
|
+
'.claude',
|
|
11
|
+
'micucodeline',
|
|
12
|
+
process.platform === 'win32' ? 'micucodeline.exe' : 'micucodeline'
|
|
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 if static linking is needed based on glibc version
|
|
31
|
+
function shouldUseStaticBinary() {
|
|
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
|
+
// Parse "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
|
+
// Use static binary if glibc < 2.35
|
|
45
|
+
return major < 2 || (major === 2 && minor < 35);
|
|
46
|
+
}
|
|
47
|
+
} catch (e) {
|
|
48
|
+
// If detection fails, default to dynamic binary
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (shouldUseStaticBinary()) {
|
|
56
|
+
platformKey = 'linux-x64-musl';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const packageMap = {
|
|
61
|
+
'darwin-x64': '@openclaudecode/micucodeline-darwin-x64',
|
|
62
|
+
'darwin-arm64': '@openclaudecode/micucodeline-darwin-arm64',
|
|
63
|
+
'linux-x64': '@openclaudecode/micucodeline-linux-x64',
|
|
64
|
+
'linux-x64-musl': '@openclaudecode/micucodeline-linux-x64-musl',
|
|
65
|
+
'win32-x64': '@openclaudecode/micucodeline-win32-x64',
|
|
66
|
+
'win32-ia32': '@openclaudecode/micucodeline-win32-x64', // Use 64-bit for 32-bit systems
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const packageName = packageMap[platformKey];
|
|
70
|
+
if (!packageName) {
|
|
71
|
+
console.error(`Error: Unsupported platform ${platformKey}`);
|
|
72
|
+
console.error('Supported platforms: darwin (x64/arm64), linux (x64), win32 (x64)');
|
|
73
|
+
console.error('Please visit https://github.com/zuoliangyu/MICUCODELINE for manual installation');
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const binaryName = platform === 'win32' ? 'micucodeline.exe' : 'micucodeline';
|
|
78
|
+
const binaryPath = path.join(__dirname, '..', 'node_modules', packageName, binaryName);
|
|
79
|
+
|
|
80
|
+
if (!fs.existsSync(binaryPath)) {
|
|
81
|
+
console.error(`Error: Binary not found at ${binaryPath}`);
|
|
82
|
+
console.error('This might indicate a failed installation or unsupported platform.');
|
|
83
|
+
console.error('Please try reinstalling: npm install -g @openclaudecode/micucodeline');
|
|
84
|
+
console.error(`Expected package: ${packageName}`);
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const result = spawnSync(binaryPath, process.argv.slice(2), {
|
|
89
|
+
stdio: 'inherit',
|
|
90
|
+
shell: false
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
process.exit(result.status || 0);
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zuolan/micucodeline",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MicuCodeLine - High-performance Claude Code StatusLine tool",
|
|
5
|
+
"bin": {
|
|
6
|
+
"micucodeline": "bin/micucodeline.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node scripts/postinstall.js"
|
|
10
|
+
},
|
|
11
|
+
"optionalDependencies": {
|
|
12
|
+
"@zuolan/micucodeline-darwin-x64": "1.0.0",
|
|
13
|
+
"@zuolan/micucodeline-darwin-arm64": "1.0.0",
|
|
14
|
+
"@zuolan/micucodeline-linux-x64": "1.0.0",
|
|
15
|
+
"@zuolan/micucodeline-linux-x64-musl": "1.0.0",
|
|
16
|
+
"@zuolan/micucodeline-win32-x64": "1.0.0"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/zuoliangyu/MICUCODELINE.git"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"claude",
|
|
24
|
+
"statusline",
|
|
25
|
+
"claude-code",
|
|
26
|
+
"rust",
|
|
27
|
+
"cli"
|
|
28
|
+
],
|
|
29
|
+
"author": "Haleclipse",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=14.0.0"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
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.MICUCODELINE_SKIP_POSTINSTALL === '1';
|
|
8
|
+
|
|
9
|
+
if (!silent) {
|
|
10
|
+
console.log('🚀 Setting up MicuCodeLine 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', 'micucodeline');
|
|
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 if static linking is needed based on glibc version
|
|
26
|
+
function shouldUseStaticBinary() {
|
|
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
|
+
// Parse "ldd (GNU libc) 2.35" format
|
|
35
|
+
const match = lddOutput.match(/(?:GNU libc|GLIBC).*?(\d+)\.(\d+)/);
|
|
36
|
+
if (match) {
|
|
37
|
+
const major = parseInt(match[1]);
|
|
38
|
+
const minor = parseInt(match[2]);
|
|
39
|
+
// Use static binary if glibc < 2.35
|
|
40
|
+
return major < 2 || (major === 2 && minor < 35);
|
|
41
|
+
}
|
|
42
|
+
} catch (e) {
|
|
43
|
+
// If detection fails, default to dynamic binary
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (shouldUseStaticBinary()) {
|
|
51
|
+
platformKey = 'linux-x64-musl';
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const packageMap = {
|
|
56
|
+
'darwin-x64': '@openclaudecode/micucodeline-darwin-x64',
|
|
57
|
+
'darwin-arm64': '@openclaudecode/micucodeline-darwin-arm64',
|
|
58
|
+
'linux-x64': '@openclaudecode/micucodeline-linux-x64',
|
|
59
|
+
'linux-x64-musl': '@openclaudecode/micucodeline-linux-x64-musl',
|
|
60
|
+
'win32-x64': '@openclaudecode/micucodeline-win32-x64',
|
|
61
|
+
'win32-ia32': '@openclaudecode/micucodeline-win32-x64', // Use 64-bit for 32-bit
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const packageName = packageMap[platformKey];
|
|
65
|
+
if (!packageName) {
|
|
66
|
+
if (!silent) {
|
|
67
|
+
console.log(`Platform ${platformKey} not supported for auto-setup`);
|
|
68
|
+
}
|
|
69
|
+
process.exit(0);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const binaryName = platform === 'win32' ? 'micucodeline.exe' : 'micucodeline';
|
|
73
|
+
const targetPath = path.join(claudeDir, binaryName);
|
|
74
|
+
|
|
75
|
+
// Multiple path search strategies for different package managers
|
|
76
|
+
const findBinaryPath = () => {
|
|
77
|
+
const possiblePaths = [
|
|
78
|
+
// npm/yarn: nested in node_modules
|
|
79
|
+
path.join(__dirname, '..', 'node_modules', packageName, binaryName),
|
|
80
|
+
// pnpm: try require.resolve first
|
|
81
|
+
(() => {
|
|
82
|
+
try {
|
|
83
|
+
const packagePath = require.resolve(packageName + '/package.json');
|
|
84
|
+
return path.join(path.dirname(packagePath), binaryName);
|
|
85
|
+
} catch {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
})(),
|
|
89
|
+
// pnpm: flat structure fallback with version detection
|
|
90
|
+
(() => {
|
|
91
|
+
const currentPath = __dirname;
|
|
92
|
+
const pnpmMatch = currentPath.match(/(.+\.pnpm)[\\/]([^\\//]+)[\\/]/);
|
|
93
|
+
if (pnpmMatch) {
|
|
94
|
+
const pnpmRoot = pnpmMatch[1];
|
|
95
|
+
const packageNameEncoded = packageName.replace('/', '+');
|
|
96
|
+
|
|
97
|
+
try {
|
|
98
|
+
// Try to find any version of the package
|
|
99
|
+
const pnpmContents = fs.readdirSync(pnpmRoot);
|
|
100
|
+
const packagePattern = new RegExp(`^${packageNameEncoded.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}@`);
|
|
101
|
+
const matchingPackage = pnpmContents.find(dir => packagePattern.test(dir));
|
|
102
|
+
|
|
103
|
+
if (matchingPackage) {
|
|
104
|
+
return path.join(pnpmRoot, matchingPackage, 'node_modules', packageName, binaryName);
|
|
105
|
+
}
|
|
106
|
+
} catch {
|
|
107
|
+
// Fallback to current behavior if directory reading fails
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
})()
|
|
112
|
+
].filter(p => p !== null);
|
|
113
|
+
|
|
114
|
+
for (const testPath of possiblePaths) {
|
|
115
|
+
if (fs.existsSync(testPath)) {
|
|
116
|
+
return testPath;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const sourcePath = findBinaryPath();
|
|
123
|
+
if (!sourcePath) {
|
|
124
|
+
if (!silent) {
|
|
125
|
+
console.log('Binary package not installed, skipping Claude Code setup');
|
|
126
|
+
console.log('The global micucodeline command will still work via npm');
|
|
127
|
+
}
|
|
128
|
+
process.exit(0);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Copy or link the binary
|
|
132
|
+
if (platform === 'win32') {
|
|
133
|
+
// Windows: Copy file
|
|
134
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
135
|
+
} else {
|
|
136
|
+
// Unix: Try hard link first, fallback to copy
|
|
137
|
+
try {
|
|
138
|
+
if (fs.existsSync(targetPath)) {
|
|
139
|
+
fs.unlinkSync(targetPath);
|
|
140
|
+
}
|
|
141
|
+
fs.linkSync(sourcePath, targetPath);
|
|
142
|
+
} catch {
|
|
143
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
144
|
+
}
|
|
145
|
+
fs.chmodSync(targetPath, '755');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (!silent) {
|
|
149
|
+
console.log('✨ MicuCodeLine is ready for Claude Code!');
|
|
150
|
+
console.log(`📍 Location: ${targetPath}`);
|
|
151
|
+
console.log('🎉 You can now use: micucodeline --help');
|
|
152
|
+
}
|
|
153
|
+
} catch (error) {
|
|
154
|
+
// Silent failure - don't break installation
|
|
155
|
+
if (!silent) {
|
|
156
|
+
console.log('Note: Could not auto-configure for Claude Code');
|
|
157
|
+
console.log('The global micucodeline command will still work.');
|
|
158
|
+
console.log('You can manually copy micucodeline to ~/.claude/micucodeline/ if needed');
|
|
159
|
+
}
|
|
160
|
+
}
|