getownit 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +18 -2
- package/dist/api.js +56 -0
- package/dist/commands/badge.js +19 -0
- package/dist/commands/hook.js +130 -0
- package/dist/commands/init.js +64 -0
- package/dist/commands/interview.js +82 -0
- package/dist/commands/key.js +68 -0
- package/dist/commands/login.js +104 -0
- package/dist/config.js +82 -0
- package/dist/debrief.js +116 -0
- package/dist/diff.js +174 -0
- package/dist/git.js +76 -0
- package/dist/hooks.js +103 -0
- package/dist/index.js +72 -0
- package/dist/pushRange.js +57 -0
- package/dist/secret.js +47 -0
- package/dist/ui.js +93 -0
- package/package.json +43 -4
package/dist/ui.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { createInterface } from 'node:readline';
|
|
2
|
+
const useColor = (out) => !process.env.NO_COLOR && Boolean(out.isTTY);
|
|
3
|
+
export function paint(out) {
|
|
4
|
+
const on = useColor(out);
|
|
5
|
+
const wrap = (code) => (text) => (on ? `\x1b[${code}m${text}\x1b[0m` : text);
|
|
6
|
+
return { bold: wrap('1'), dim: wrap('2'), green: wrap('32'), red: wrap('31'), yellow: wrap('33'), cyan: wrap('36') };
|
|
7
|
+
}
|
|
8
|
+
/** Ends a message with a period unless it already ends a sentence (server messages usually do). */
|
|
9
|
+
export function sentence(text) {
|
|
10
|
+
return /[.!?]$/.test(text.trimEnd()) ? text.trimEnd() : `${text.trimEnd()}.`;
|
|
11
|
+
}
|
|
12
|
+
export function createPrompter(input, out) {
|
|
13
|
+
const terminal = Boolean(input.isTTY && out.isTTY);
|
|
14
|
+
const rl = createInterface({ input, output: out, terminal });
|
|
15
|
+
const lines = [];
|
|
16
|
+
let waiter = null;
|
|
17
|
+
let closed = false;
|
|
18
|
+
rl.on('line', (line) => {
|
|
19
|
+
if (waiter) {
|
|
20
|
+
const w = waiter;
|
|
21
|
+
waiter = null;
|
|
22
|
+
w(line);
|
|
23
|
+
}
|
|
24
|
+
else
|
|
25
|
+
lines.push(line);
|
|
26
|
+
});
|
|
27
|
+
rl.on('close', () => {
|
|
28
|
+
closed = true;
|
|
29
|
+
waiter?.(null);
|
|
30
|
+
waiter = null;
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
out,
|
|
34
|
+
ask(prompt, timeoutMs) {
|
|
35
|
+
out.write(prompt);
|
|
36
|
+
if (lines.length)
|
|
37
|
+
return Promise.resolve(lines.shift());
|
|
38
|
+
if (closed)
|
|
39
|
+
return Promise.resolve(null);
|
|
40
|
+
return new Promise((resolve) => {
|
|
41
|
+
const timer = timeoutMs
|
|
42
|
+
? setTimeout(() => {
|
|
43
|
+
waiter = null;
|
|
44
|
+
out.write('\n');
|
|
45
|
+
resolve(null);
|
|
46
|
+
}, timeoutMs)
|
|
47
|
+
: null;
|
|
48
|
+
waiter = (line) => {
|
|
49
|
+
if (timer)
|
|
50
|
+
clearTimeout(timer);
|
|
51
|
+
resolve(line);
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
close() {
|
|
56
|
+
rl.close();
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** A spinner on a TTY; a single static line otherwise. */
|
|
61
|
+
export function spinner(out, text) {
|
|
62
|
+
const tty = Boolean(out.isTTY);
|
|
63
|
+
if (!tty) {
|
|
64
|
+
out.write(`${text}\n`);
|
|
65
|
+
return { stop() { } };
|
|
66
|
+
}
|
|
67
|
+
const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
68
|
+
let i = 0;
|
|
69
|
+
const timer = setInterval(() => out.write(`\r${frames[i++ % frames.length]} ${text}`), 80);
|
|
70
|
+
return {
|
|
71
|
+
stop() {
|
|
72
|
+
clearInterval(timer);
|
|
73
|
+
out.write(`\r${' '.repeat(text.length + 2)}\r`);
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** Word-wraps text to the terminal width with an indent. */
|
|
78
|
+
export function wrap(text, indent = ' ', width = Math.min(process.stderr.columns || 80, 100)) {
|
|
79
|
+
const words = text.split(/\s+/).filter(Boolean);
|
|
80
|
+
const lines = [];
|
|
81
|
+
let line = '';
|
|
82
|
+
for (const word of words) {
|
|
83
|
+
if (line && indent.length + line.length + 1 + word.length > width) {
|
|
84
|
+
lines.push(line);
|
|
85
|
+
line = word;
|
|
86
|
+
}
|
|
87
|
+
else
|
|
88
|
+
line = line ? `${line} ${word}` : word;
|
|
89
|
+
}
|
|
90
|
+
if (line)
|
|
91
|
+
lines.push(line);
|
|
92
|
+
return lines.map((l) => indent + l).join('\n');
|
|
93
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "getownit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Debrief the code you just pushed, in your terminal, with NVIDIA Nemotron.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/Yoosseph/ownit.git",
|
|
9
|
+
"directory": "cli"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/Yoosseph/ownit#readme",
|
|
12
|
+
"bugs": "https://github.com/Yoosseph/ownit/issues",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"bin": {
|
|
15
|
+
"ownit": "dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=20"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"git",
|
|
26
|
+
"pre-push",
|
|
27
|
+
"learning",
|
|
28
|
+
"code-review",
|
|
29
|
+
"nemotron",
|
|
30
|
+
"nebius"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsc -p tsconfig.json",
|
|
34
|
+
"test": "vitest run",
|
|
35
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^26.6.5",
|
|
39
|
+
"typescript": "^7.0.2",
|
|
40
|
+
"vitest": "^5.0.5"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"ignore": "^7.0.13"
|
|
44
|
+
}
|
|
45
|
+
}
|