@gwatch/gwatch-cli 1.0.0 → 1.0.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 +8 -4
- package/dist/commands/create.js +18 -13
- package/dist/index.js +7 -8
- package/dist/utils/ui.js +13 -2
- package/docs/logo.jpg +0 -0
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# G-Watch CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<div align="center">
|
|
4
|
+
<img src="./docs/logo.jpg" width="500px" />
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
G-Watch CLI is a tool for running agentic GPU profiling and optimization using [G-Watch](https://github.com/G-Watch/G-Watch).
|
|
4
8
|
|
|
5
9
|
## Features
|
|
6
10
|
|
|
@@ -20,7 +24,7 @@ npm install -g @gwatch/gwatch-cli
|
|
|
20
24
|
Alternatively, to install from source:
|
|
21
25
|
|
|
22
26
|
```bash
|
|
23
|
-
git clone https://github.com/G-Watch/
|
|
27
|
+
git clone https://github.com/G-Watch/gwatch-cli.git
|
|
24
28
|
cd Watchtower
|
|
25
29
|
npm install -g .
|
|
26
30
|
```
|
|
@@ -29,12 +33,12 @@ npm install -g .
|
|
|
29
33
|
|
|
30
34
|
### 1. Create a container from a remote git repo
|
|
31
35
|
```bash
|
|
32
|
-
gwatch-cli
|
|
36
|
+
gwatch-cli start --repo https://github.com/user/project.git --dockerfile ./Dockerfile
|
|
33
37
|
```
|
|
34
38
|
|
|
35
39
|
### 2. Create a container from current local directory
|
|
36
40
|
```bash
|
|
37
|
-
gwatch-cli
|
|
41
|
+
gwatch-cli start --dir . --dockerfile ./Dockerfile
|
|
38
42
|
```
|
|
39
43
|
|
|
40
44
|
### 3. Enter a container/session
|
package/dist/commands/create.js
CHANGED
|
@@ -30,19 +30,24 @@ async function createAction(options) {
|
|
|
30
30
|
}
|
|
31
31
|
const userName = os_1.default.userInfo().username;
|
|
32
32
|
const db = await (0, db_1.readDb)();
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
33
|
+
const prefixParts = [baseName, userName];
|
|
34
|
+
if (suffix)
|
|
35
|
+
prefixParts.push(suffix);
|
|
36
|
+
const prefix = prefixParts.join('-');
|
|
37
|
+
// Find the largest index among containers with the same prefix
|
|
38
|
+
let maxIndex = 0;
|
|
39
|
+
db.containers.forEach(c => {
|
|
40
|
+
if (c.name.startsWith(prefix)) {
|
|
41
|
+
const parts = c.name.split('-');
|
|
42
|
+
const lastPart = parts[parts.length - 1];
|
|
43
|
+
const idx = parseInt(lastPart, 10);
|
|
44
|
+
if (!isNaN(idx) && idx > maxIndex) {
|
|
45
|
+
maxIndex = idx;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const index = maxIndex + 1;
|
|
50
|
+
const containerName = `${prefix}-${index}`;
|
|
46
51
|
const imageName = await (0, docker_1.buildImage)(dockerfile, baseName, workspacePath);
|
|
47
52
|
const container = await (0, docker_1.createContainer)(imageName, containerName, workspacePath);
|
|
48
53
|
console.log('Setting up environment (Node.js, Tmux, Gemini CLI)...');
|
package/dist/index.js
CHANGED
|
@@ -9,13 +9,12 @@ const stop_1 = require("./commands/stop");
|
|
|
9
9
|
const { version } = require('../package.json');
|
|
10
10
|
const program = new commander_1.Command();
|
|
11
11
|
const LOGO = `
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
██████╗ ██╗ ██╗ █████╗ ████████╗ ██████╗██╗ ██╗
|
|
13
|
+
██╔════╝ ██║ ██║██╔══██╗╚══██╔══╝██╔════╝██║ ██║
|
|
14
|
+
██║ ███╗█████╗██║ █╗ ██║███████║ ██║ ██║ ███████║
|
|
15
|
+
██║ ██║╚════╝██║███╗██║██╔══██║ ██║ ██║ ██╔══██║
|
|
16
|
+
╚██████╔╝ ╚███╔███╔╝██║ ██║ ██║ ╚██████╗██║ ██║
|
|
17
|
+
╚═════╝ ╚══╝╚══╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝
|
|
19
18
|
`;
|
|
20
19
|
program
|
|
21
20
|
.name('gwatch-cli')
|
|
@@ -23,7 +22,7 @@ program
|
|
|
23
22
|
.version(version)
|
|
24
23
|
.addHelpText('before', LOGO);
|
|
25
24
|
program
|
|
26
|
-
.command('
|
|
25
|
+
.command('start')
|
|
27
26
|
.description('Create a container from a remote git repo or local directory')
|
|
28
27
|
.option('--repo <url>', 'Git repository URL')
|
|
29
28
|
.option('--dir <path>', 'Local directory path')
|
package/dist/utils/ui.js
CHANGED
|
@@ -11,8 +11,12 @@ exports.logError = logError;
|
|
|
11
11
|
const boxen_1 = __importDefault(require("boxen"));
|
|
12
12
|
const chalk_1 = __importDefault(require("chalk"));
|
|
13
13
|
const log_update_1 = __importDefault(require("log-update"));
|
|
14
|
+
const wrap_ansi_1 = __importDefault(require("wrap-ansi"));
|
|
14
15
|
function renderBox(content, title, color = 'cyan') {
|
|
15
|
-
|
|
16
|
+
const columns = process.stdout.columns || 80;
|
|
17
|
+
// Account for padding and borders in boxen
|
|
18
|
+
const wrappedContent = (0, wrap_ansi_1.default)(content, columns - 10, { hard: true, trim: false });
|
|
19
|
+
console.log((0, boxen_1.default)(wrappedContent, {
|
|
16
20
|
padding: 1,
|
|
17
21
|
margin: 1,
|
|
18
22
|
borderStyle: 'round',
|
|
@@ -35,10 +39,13 @@ class DynamicBox {
|
|
|
35
39
|
maxLines;
|
|
36
40
|
title;
|
|
37
41
|
color;
|
|
42
|
+
resizeListener;
|
|
38
43
|
constructor(title, maxLines = 10, color = 'cyan') {
|
|
39
44
|
this.title = title;
|
|
40
45
|
this.maxLines = maxLines;
|
|
41
46
|
this.color = color;
|
|
47
|
+
this.resizeListener = () => this.render();
|
|
48
|
+
process.stdout.on('resize', this.resizeListener);
|
|
42
49
|
}
|
|
43
50
|
update(line) {
|
|
44
51
|
if (!line.trim())
|
|
@@ -50,8 +57,11 @@ class DynamicBox {
|
|
|
50
57
|
this.render();
|
|
51
58
|
}
|
|
52
59
|
render() {
|
|
60
|
+
const columns = process.stdout.columns || 80;
|
|
53
61
|
const content = this.lines.join('\n');
|
|
54
|
-
|
|
62
|
+
// Wrap each line or the whole content
|
|
63
|
+
const wrappedContent = (0, wrap_ansi_1.default)(content, columns - 10, { hard: true, trim: false });
|
|
64
|
+
(0, log_update_1.default)((0, boxen_1.default)(wrappedContent, {
|
|
55
65
|
padding: { left: 1, right: 1, top: 0, bottom: 0 },
|
|
56
66
|
margin: 1,
|
|
57
67
|
borderStyle: 'round',
|
|
@@ -61,6 +71,7 @@ class DynamicBox {
|
|
|
61
71
|
}));
|
|
62
72
|
}
|
|
63
73
|
stop() {
|
|
74
|
+
process.stdout.removeListener('resize', this.resizeListener);
|
|
64
75
|
log_update_1.default.done();
|
|
65
76
|
}
|
|
66
77
|
}
|
package/docs/logo.jpg
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gwatch/gwatch-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Watchtower: Persistent development environments wrapper for Docker and Tmux",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"fs-extra": "^11.3.3",
|
|
36
36
|
"log-update": "4.0.0",
|
|
37
37
|
"ora": "5.4.1",
|
|
38
|
+
"wrap-ansi": "^7.0.0",
|
|
38
39
|
"zod": "^4.3.6"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
@@ -43,8 +44,9 @@
|
|
|
43
44
|
"@types/fs-extra": "^11.0.4",
|
|
44
45
|
"@types/log-update": "^3.0.0",
|
|
45
46
|
"@types/node": "^25.2.2",
|
|
46
|
-
"@types/ora": "^
|
|
47
|
+
"@types/ora": "^3.2.0",
|
|
48
|
+
"@types/wrap-ansi": "^3.0.0",
|
|
47
49
|
"ts-node": "^10.9.2",
|
|
48
50
|
"typescript": "^5.9.3"
|
|
49
51
|
}
|
|
50
|
-
}
|
|
52
|
+
}
|