gut-cli 0.1.26 → 0.1.28
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 +19 -0
- package/dist/index.js +82 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 godai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -16,6 +16,25 @@ No subscription required. Just bring your own API key from Gemini, OpenAI, or An
|
|
|
16
16
|
npm install -g gut-cli
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# 1. Set up your API key (stored securely in system keychain)
|
|
23
|
+
gut auth login --provider gemini
|
|
24
|
+
|
|
25
|
+
# 2. Start using gut
|
|
26
|
+
gut commit # Generate commit message
|
|
27
|
+
gut pr # Generate PR description
|
|
28
|
+
gut review # Get AI code review
|
|
29
|
+
|
|
30
|
+
# 3. (Optional) Customize templates for your project
|
|
31
|
+
gut init # Creates .gut/ with editable prompt templates
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Supported providers: `gemini` (default), `openai`, `anthropic`
|
|
35
|
+
|
|
36
|
+
See [Authentication](#gut-auth) and [Template Configuration](#template-configuration) for more details.
|
|
37
|
+
|
|
19
38
|
## Commands
|
|
20
39
|
|
|
21
40
|
| Command | Description |
|
package/dist/index.js
CHANGED
|
@@ -273,13 +273,71 @@ async function readSecretInput(prompt) {
|
|
|
273
273
|
stdin.on("data", onData);
|
|
274
274
|
});
|
|
275
275
|
}
|
|
276
|
+
async function selectProvider() {
|
|
277
|
+
return new Promise((resolve) => {
|
|
278
|
+
let selectedIndex = 0;
|
|
279
|
+
const stdin = process.stdin;
|
|
280
|
+
const render = () => {
|
|
281
|
+
process.stdout.write(`\x1B[${PROVIDERS.length}A`);
|
|
282
|
+
for (let i = 0; i < PROVIDERS.length; i++) {
|
|
283
|
+
const provider = PROVIDERS[i];
|
|
284
|
+
const displayName = getProviderDisplayName(provider);
|
|
285
|
+
const prefix = i === selectedIndex ? chalk.cyan("\u276F") : " ";
|
|
286
|
+
const text = i === selectedIndex ? chalk.cyan(displayName) : displayName;
|
|
287
|
+
process.stdout.write(`\x1B[2K${prefix} ${text}
|
|
288
|
+
`);
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
const initialRender = () => {
|
|
292
|
+
console.log(chalk.bold("\n\u{1F511} Select AI Provider:\n"));
|
|
293
|
+
for (let i = 0; i < PROVIDERS.length; i++) {
|
|
294
|
+
const provider = PROVIDERS[i];
|
|
295
|
+
const displayName = getProviderDisplayName(provider);
|
|
296
|
+
const prefix = i === selectedIndex ? chalk.cyan("\u276F") : " ";
|
|
297
|
+
const text = i === selectedIndex ? chalk.cyan(displayName) : displayName;
|
|
298
|
+
console.log(`${prefix} ${text}`);
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
initialRender();
|
|
302
|
+
stdin.setRawMode(true);
|
|
303
|
+
stdin.resume();
|
|
304
|
+
stdin.setEncoding("utf8");
|
|
305
|
+
const onData = (data) => {
|
|
306
|
+
const key = data;
|
|
307
|
+
if (key === "\x1B[A" || key === "k") {
|
|
308
|
+
selectedIndex = (selectedIndex - 1 + PROVIDERS.length) % PROVIDERS.length;
|
|
309
|
+
render();
|
|
310
|
+
} else if (key === "\x1B[B" || key === "j") {
|
|
311
|
+
selectedIndex = (selectedIndex + 1) % PROVIDERS.length;
|
|
312
|
+
render();
|
|
313
|
+
} else if (key === "\r" || key === "\n") {
|
|
314
|
+
stdin.setRawMode(false);
|
|
315
|
+
stdin.pause();
|
|
316
|
+
stdin.removeListener("data", onData);
|
|
317
|
+
console.log();
|
|
318
|
+
resolve(PROVIDERS[selectedIndex]);
|
|
319
|
+
} else if (key === "") {
|
|
320
|
+
stdin.setRawMode(false);
|
|
321
|
+
stdin.pause();
|
|
322
|
+
console.log();
|
|
323
|
+
process.exit(0);
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
stdin.on("data", onData);
|
|
327
|
+
});
|
|
328
|
+
}
|
|
276
329
|
var authCommand = new Command("auth").description("Manage API key authentication");
|
|
277
|
-
authCommand.command("login").description("Save an API key to the system keychain").
|
|
278
|
-
|
|
279
|
-
if (
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
330
|
+
authCommand.command("login").description("Save an API key to the system keychain").option("-p, --provider <provider>", "AI provider (gemini, openai, anthropic)").option("-k, --key <key>", "API key (if not provided, will prompt)").action(async (options) => {
|
|
331
|
+
let provider;
|
|
332
|
+
if (options.provider) {
|
|
333
|
+
provider = options.provider.toLowerCase();
|
|
334
|
+
if (!PROVIDERS.includes(provider)) {
|
|
335
|
+
console.error(chalk.red(`Invalid provider: ${options.provider}`));
|
|
336
|
+
console.error(chalk.gray(`Valid providers: ${PROVIDERS.join(", ")}`));
|
|
337
|
+
process.exit(1);
|
|
338
|
+
}
|
|
339
|
+
} else {
|
|
340
|
+
provider = await selectProvider();
|
|
283
341
|
}
|
|
284
342
|
let apiKey = options.key;
|
|
285
343
|
if (!apiKey) {
|
|
@@ -869,6 +927,20 @@ function requireGhCli() {
|
|
|
869
927
|
}
|
|
870
928
|
return true;
|
|
871
929
|
}
|
|
930
|
+
function getDefaultBranch() {
|
|
931
|
+
if (!isGhCliInstalled()) {
|
|
932
|
+
return null;
|
|
933
|
+
}
|
|
934
|
+
try {
|
|
935
|
+
const result = execSync2('gh repo view --json defaultBranchRef --jq ".defaultBranchRef.name"', {
|
|
936
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
937
|
+
});
|
|
938
|
+
const branch = result.toString().trim();
|
|
939
|
+
return branch || null;
|
|
940
|
+
} catch {
|
|
941
|
+
return null;
|
|
942
|
+
}
|
|
943
|
+
}
|
|
872
944
|
|
|
873
945
|
// src/commands/branch.ts
|
|
874
946
|
function getIssueInfo(issueNumber) {
|
|
@@ -2329,7 +2401,10 @@ var prCommand = new Command14("pr").description("Generate a pull request title a
|
|
|
2329
2401
|
const currentBranch = branchInfo.current;
|
|
2330
2402
|
let baseBranch = options.base;
|
|
2331
2403
|
if (!baseBranch) {
|
|
2332
|
-
|
|
2404
|
+
const ghDefaultBranch = getDefaultBranch();
|
|
2405
|
+
if (ghDefaultBranch) {
|
|
2406
|
+
baseBranch = ghDefaultBranch;
|
|
2407
|
+
} else if (branchInfo.all.includes("main")) {
|
|
2333
2408
|
baseBranch = "main";
|
|
2334
2409
|
} else if (branchInfo.all.includes("master")) {
|
|
2335
2410
|
baseBranch = "master";
|