codebuff-cli 1.0.15 → 1.0.16
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 +58 -202
- package/http.js +176 -0
- package/index.js +592 -0
- package/package.json +31 -80
- package/postinstall.js +34 -0
- package/LICENSE +0 -202
- package/NOTICE +0 -4
- package/README.zh-CN.md +0 -251
- package/cli/README.md +0 -84
- package/cli/scripts/download-binary.cjs +0 -129
package/cli/README.md
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# @codebuff/cli
|
|
2
|
-
|
|
3
|
-
A Terminal User Interface (TUI) package built with OpenTUI and React.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
bun install
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Development
|
|
12
|
-
|
|
13
|
-
Run the TUI in development mode:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
bun run dev
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Testing
|
|
20
|
-
|
|
21
|
-
Run the test suite:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
bun test
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### Interactive E2E Testing
|
|
28
|
-
|
|
29
|
-
For testing interactive CLI features, install tmux:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
# macOS
|
|
33
|
-
brew install tmux
|
|
34
|
-
|
|
35
|
-
# Ubuntu/Debian
|
|
36
|
-
sudo apt-get install tmux
|
|
37
|
-
|
|
38
|
-
# Windows (via WSL)
|
|
39
|
-
wsl --install
|
|
40
|
-
sudo apt-get install tmux
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Then run the proof-of-concept:
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
bun run test:tmux-poc
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
**Note:** When sending input to the CLI via tmux, you must use bracketed paste mode. Standard `send-keys` drops characters.
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
# ❌ Broken: tmux send-keys -t session "hello"
|
|
53
|
-
# ✅ Works: tmux send-keys -t session $'\e[200~hello\e[201~'
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
See [tmux.knowledge.md](tmux.knowledge.md) for comprehensive tmux documentation and [src/__tests__/README.md](src/__tests__/README.md) for testing documentation.
|
|
57
|
-
|
|
58
|
-
## Build
|
|
59
|
-
|
|
60
|
-
Build the package:
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
bun run build
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Run
|
|
67
|
-
|
|
68
|
-
Run the built TUI:
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
bun run start
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
Or use the binary directly:
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
codebuff-tui
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## Features
|
|
81
|
-
|
|
82
|
-
- Built with OpenTUI for modern terminal interfaces
|
|
83
|
-
- Uses React for declarative component-based UI
|
|
84
|
-
- TypeScript support out of the box
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const https = require('https');
|
|
5
|
-
const http = require('http');
|
|
6
|
-
const os = require('os');
|
|
7
|
-
|
|
8
|
-
const REPO = 'Marcus-Mok-GH/codebuff-cli';
|
|
9
|
-
const BINARY_NAME = 'codebuff';
|
|
10
|
-
|
|
11
|
-
function getVersion() {
|
|
12
|
-
const candidates = [
|
|
13
|
-
path.join(__dirname, '..', '..', 'package.json'),
|
|
14
|
-
path.join(__dirname, '..', 'package.json'),
|
|
15
|
-
];
|
|
16
|
-
for (const p of candidates) {
|
|
17
|
-
try {
|
|
18
|
-
const pkg = JSON.parse(fs.readFileSync(p, 'utf8'));
|
|
19
|
-
if (pkg.version) return pkg.version;
|
|
20
|
-
} catch {}
|
|
21
|
-
}
|
|
22
|
-
return '1.0.9';
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function getBinaryPath() {
|
|
26
|
-
const binDir = path.join(os.homedir(), '.codebuff');
|
|
27
|
-
const name = process.platform === 'win32' ? `${BINARY_NAME}.exe` : BINARY_NAME;
|
|
28
|
-
return path.join(binDir, name);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function download(url, dest) {
|
|
32
|
-
return new Promise((resolve, reject) => {
|
|
33
|
-
const client = url.startsWith('https:') ? https : http;
|
|
34
|
-
const file = fs.createWriteStream(dest);
|
|
35
|
-
|
|
36
|
-
const req = client.get(
|
|
37
|
-
url,
|
|
38
|
-
{ headers: { 'User-Agent': 'codebuff-cli-installer' } },
|
|
39
|
-
(res) => {
|
|
40
|
-
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
41
|
-
file.close();
|
|
42
|
-
if (fs.existsSync(dest)) fs.unlinkSync(dest);
|
|
43
|
-
download(new URL(res.headers.location, url).href, dest)
|
|
44
|
-
.then(resolve)
|
|
45
|
-
.catch(reject);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (res.statusCode !== 200) {
|
|
50
|
-
file.close();
|
|
51
|
-
if (fs.existsSync(dest)) fs.unlinkSync(dest);
|
|
52
|
-
reject(new Error(`HTTP ${res.statusCode}`));
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
res.pipe(file);
|
|
57
|
-
file.on('finish', () => {
|
|
58
|
-
file.close();
|
|
59
|
-
resolve();
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
req.on('error', (err) => {
|
|
65
|
-
file.close();
|
|
66
|
-
if (fs.existsSync(dest)) fs.unlinkSync(dest);
|
|
67
|
-
reject(err);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
req.setTimeout(30000, () => {
|
|
71
|
-
req.destroy();
|
|
72
|
-
file.close();
|
|
73
|
-
if (fs.existsSync(dest)) fs.unlinkSync(dest);
|
|
74
|
-
reject(new Error('Request timeout'));
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
async function tryDownload(url, dest) {
|
|
80
|
-
try {
|
|
81
|
-
await download(url, dest);
|
|
82
|
-
return true;
|
|
83
|
-
} catch {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async function main() {
|
|
89
|
-
const binaryPath = getBinaryPath();
|
|
90
|
-
|
|
91
|
-
if (fs.existsSync(binaryPath)) {
|
|
92
|
-
console.log('Binary already exists at', binaryPath);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const version = getVersion();
|
|
97
|
-
const baseUrl = `https://github.com/${REPO}/releases/download/v${version}`;
|
|
98
|
-
|
|
99
|
-
// Try platform-specific binary first
|
|
100
|
-
const platformName = `${BINARY_NAME}-${process.platform}-${process.arch}${
|
|
101
|
-
process.platform === 'win32' ? '.exe' : ''
|
|
102
|
-
}`;
|
|
103
|
-
const platformUrl = `${baseUrl}/${platformName}`;
|
|
104
|
-
const genericUrl = `${baseUrl}/${BINARY_NAME}`;
|
|
105
|
-
|
|
106
|
-
fs.mkdirSync(path.dirname(binaryPath), { recursive: true });
|
|
107
|
-
|
|
108
|
-
if (await tryDownload(platformUrl, binaryPath)) {
|
|
109
|
-
console.log(`Downloaded platform-specific binary: ${platformName}`);
|
|
110
|
-
} else if (await tryDownload(genericUrl, binaryPath)) {
|
|
111
|
-
console.log(`Downloaded generic binary: ${BINARY_NAME}`);
|
|
112
|
-
} else {
|
|
113
|
-
console.error(
|
|
114
|
-
`Failed to download binary from:\n ${platformUrl}\n ${genericUrl}`
|
|
115
|
-
);
|
|
116
|
-
process.exit(1);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (process.platform !== 'win32') {
|
|
120
|
-
fs.chmodSync(binaryPath, 0o755);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
console.log(`Binary installed at: ${binaryPath}`);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
main().catch((err) => {
|
|
127
|
-
console.error('Error:', err.message);
|
|
128
|
-
process.exit(1);
|
|
129
|
-
});
|