getownit 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +18 -2
- package/dist/api.js +57 -0
- package/dist/commands/badge.js +19 -0
- package/dist/commands/hook.js +145 -0
- package/dist/commands/init.js +73 -0
- package/dist/commands/interview.js +82 -0
- package/dist/commands/key.js +79 -0
- package/dist/commands/login.js +118 -0
- package/dist/config.js +46 -0
- package/dist/debrief.js +142 -0
- package/dist/diff.js +174 -0
- package/dist/git.js +76 -0
- package/dist/hooks.js +103 -0
- package/dist/index.js +77 -0
- package/dist/providers.js +36 -0
- package/dist/pushRange.js +57 -0
- package/dist/secret.js +47 -0
- package/dist/ui.js +97 -0
- package/package.json +43 -4
package/dist/secret.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createInterface } from 'node:readline';
|
|
2
|
+
/** Reads one line without echoing it on a TTY. Piped input is read as-is. */
|
|
3
|
+
export function readSecret(prompt) {
|
|
4
|
+
const stdin = process.stdin;
|
|
5
|
+
const out = process.stderr;
|
|
6
|
+
if (!stdin.isTTY) {
|
|
7
|
+
return new Promise((resolve) => {
|
|
8
|
+
const rl = createInterface({ input: stdin });
|
|
9
|
+
let done = false;
|
|
10
|
+
rl.once('line', (line) => {
|
|
11
|
+
done = true;
|
|
12
|
+
rl.close();
|
|
13
|
+
resolve(line);
|
|
14
|
+
});
|
|
15
|
+
rl.once('close', () => done || resolve(''));
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
out.write(prompt);
|
|
19
|
+
return new Promise((resolve) => {
|
|
20
|
+
let value = '';
|
|
21
|
+
stdin.setRawMode(true);
|
|
22
|
+
stdin.resume();
|
|
23
|
+
stdin.setEncoding('utf8');
|
|
24
|
+
const onData = (chunk) => {
|
|
25
|
+
for (const ch of chunk) {
|
|
26
|
+
if (ch === '\r' || ch === '\n' || ch === '\u0004') {
|
|
27
|
+
stdin.setRawMode(false);
|
|
28
|
+
stdin.pause();
|
|
29
|
+
stdin.off('data', onData);
|
|
30
|
+
out.write('\n');
|
|
31
|
+
resolve(value);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (ch === '\u0003') {
|
|
35
|
+
stdin.setRawMode(false);
|
|
36
|
+
out.write('\n');
|
|
37
|
+
process.exit(130);
|
|
38
|
+
}
|
|
39
|
+
if (ch === '\u007f' || ch === '\b')
|
|
40
|
+
value = value.slice(0, -1);
|
|
41
|
+
else
|
|
42
|
+
value += ch;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
stdin.on('data', onData);
|
|
46
|
+
});
|
|
47
|
+
}
|
package/dist/ui.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
/** "1 commit", "2 commits". Pass the plural form for irregular words. */
|
|
9
|
+
export const plural = (n, singular, pluralForm = `${singular}s`) => (n === 1 ? singular : pluralForm);
|
|
10
|
+
/** The message of whatever was thrown. */
|
|
11
|
+
export const errorMessage = (error) => (error instanceof Error ? error.message : String(error));
|
|
12
|
+
/** Ends a message with a period unless it already ends a sentence (server messages usually do). */
|
|
13
|
+
export function sentence(text) {
|
|
14
|
+
return /[.!?]$/.test(text.trimEnd()) ? text.trimEnd() : `${text.trimEnd()}.`;
|
|
15
|
+
}
|
|
16
|
+
export function createPrompter(input, out) {
|
|
17
|
+
const terminal = Boolean(input.isTTY && out.isTTY);
|
|
18
|
+
const rl = createInterface({ input, output: out, terminal });
|
|
19
|
+
const lines = [];
|
|
20
|
+
let waiter = null;
|
|
21
|
+
let closed = false;
|
|
22
|
+
rl.on('line', (line) => {
|
|
23
|
+
if (waiter) {
|
|
24
|
+
const w = waiter;
|
|
25
|
+
waiter = null;
|
|
26
|
+
w(line);
|
|
27
|
+
}
|
|
28
|
+
else
|
|
29
|
+
lines.push(line);
|
|
30
|
+
});
|
|
31
|
+
rl.on('close', () => {
|
|
32
|
+
closed = true;
|
|
33
|
+
waiter?.(null);
|
|
34
|
+
waiter = null;
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
out,
|
|
38
|
+
ask(prompt, timeoutMs) {
|
|
39
|
+
out.write(prompt);
|
|
40
|
+
if (lines.length)
|
|
41
|
+
return Promise.resolve(lines.shift());
|
|
42
|
+
if (closed)
|
|
43
|
+
return Promise.resolve(null);
|
|
44
|
+
return new Promise((resolve) => {
|
|
45
|
+
const timer = timeoutMs
|
|
46
|
+
? setTimeout(() => {
|
|
47
|
+
waiter = null;
|
|
48
|
+
out.write('\n');
|
|
49
|
+
resolve(null);
|
|
50
|
+
}, timeoutMs)
|
|
51
|
+
: null;
|
|
52
|
+
waiter = (line) => {
|
|
53
|
+
if (timer)
|
|
54
|
+
clearTimeout(timer);
|
|
55
|
+
resolve(line);
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
close() {
|
|
60
|
+
rl.close();
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** A spinner on a TTY; a single static line otherwise. */
|
|
65
|
+
export function spinner(out, text) {
|
|
66
|
+
const tty = Boolean(out.isTTY);
|
|
67
|
+
if (!tty) {
|
|
68
|
+
out.write(`${text}\n`);
|
|
69
|
+
return { stop() { } };
|
|
70
|
+
}
|
|
71
|
+
const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
72
|
+
let i = 0;
|
|
73
|
+
const timer = setInterval(() => out.write(`\r${frames[i++ % frames.length]} ${text}`), 80);
|
|
74
|
+
return {
|
|
75
|
+
stop() {
|
|
76
|
+
clearInterval(timer);
|
|
77
|
+
out.write(`\r${' '.repeat(text.length + 2)}\r`);
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/** Word-wraps text to the terminal width with an indent. */
|
|
82
|
+
export function wrap(text, indent = ' ', width = Math.min(process.stderr.columns || 80, 100)) {
|
|
83
|
+
const words = text.split(/\s+/).filter(Boolean);
|
|
84
|
+
const lines = [];
|
|
85
|
+
let line = '';
|
|
86
|
+
for (const word of words) {
|
|
87
|
+
if (line && indent.length + line.length + 1 + word.length > width) {
|
|
88
|
+
lines.push(line);
|
|
89
|
+
line = word;
|
|
90
|
+
}
|
|
91
|
+
else
|
|
92
|
+
line = line ? `${line} ${word}` : word;
|
|
93
|
+
}
|
|
94
|
+
if (line)
|
|
95
|
+
lines.push(line);
|
|
96
|
+
return lines.map((l) => indent + l).join('\n');
|
|
97
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "getownit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
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
|
+
}
|