ai-cmds 0.4.1 → 0.5.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/README.md +15 -2
- package/dist/{index-VeIKmeup.d.ts → index.d.mts} +32 -31
- package/dist/index.mjs +3 -0
- package/dist/main.d.mts +1 -0
- package/dist/main.mjs +19 -0
- package/dist/{review-pr-C3lBSGhM.js → set-global-envs-CyKhXAY_.mjs} +603 -555
- package/package.json +6 -6
- package/dist/index.js +0 -3
- package/dist/main-BG1maKLq.d.ts +0 -1
- package/dist/main.js +0 -18
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ AI-powered CLI tool that uses OpenAI and Google Gemini models to review code cha
|
|
|
7
7
|
- Multiple AI models: GPT-5, GPT-5-mini, GPT-4o-mini, Gemini 2.5 Pro, Gemini 2.0 Flash
|
|
8
8
|
- Configurable review setups from light to heavy
|
|
9
9
|
- Custom setups with full control over reviewer and validator models
|
|
10
|
-
-
|
|
10
|
+
- Six commands: `commit` for AI commit messages, `review-code-changes` for local development, `advanced-review-changes` for guided/customized local review focus, `review-pr` for CI, `create-pr` for PR creation, `set-global-envs` for global API key setup
|
|
11
11
|
- Parallel reviews with a single structured validation pass for higher accuracy
|
|
12
12
|
- Optional provider-aware concurrency limits for reviewer fan-out
|
|
13
13
|
- AI-generated commit messages with interactive editing
|
|
@@ -182,6 +182,19 @@ ai-cmds create-pr --title "Fix login validation"
|
|
|
182
182
|
- Supports `<!-- AI_DESCRIPTION -->` marker in templates for AI content placement
|
|
183
183
|
- Opens GitHub compare URL with pre-filled title and body
|
|
184
184
|
|
|
185
|
+
### `set-global-envs` - Global API Key Setup
|
|
186
|
+
|
|
187
|
+
Create a global `.env` file at `~/.config/ai-cmds/.env` for API keys shared across all projects.
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
ai-cmds set-global-envs
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Behavior:**
|
|
194
|
+
- Creates `~/.config/ai-cmds/.env` with commented-out placeholders for `OPENAI_API_KEY`, `GOOGLE_GENERATIVE_AI_API_KEY`, and `AI_CLI_LOGS_DIR`
|
|
195
|
+
- If the file already exists, reports its location without overwriting
|
|
196
|
+
- The global `.env` is loaded as a fallback when no local `.env` file exists in the project root
|
|
197
|
+
|
|
185
198
|
## Review Setups
|
|
186
199
|
|
|
187
200
|
| Setup | Reviewers | Description |
|
|
@@ -271,7 +284,7 @@ export default defineConfig({
|
|
|
271
284
|
});
|
|
272
285
|
```
|
|
273
286
|
|
|
274
|
-
By default, `.env` is loaded automatically before the config file is imported, allowing you to reference environment variables in your config.
|
|
287
|
+
By default, `.env` is loaded automatically before the config file is imported, allowing you to reference environment variables in your config. When no local `.env` file exists, the CLI falls back to the global env file at `~/.config/ai-cmds/.env` (see [`set-global-envs`](#set-global-envs---global-api-key-setup)).
|
|
275
288
|
|
|
276
289
|
### Configuration Options
|
|
277
290
|
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
+
import * as _ls_stack_cli0 from "@ls-stack/cli";
|
|
1
2
|
import { JSONValue, LanguageModel } from "ai";
|
|
2
3
|
|
|
3
4
|
//#region src/lib/config.d.ts
|
|
4
|
-
|
|
5
5
|
/**
|
|
6
6
|
* Configuration for a custom AI model used in code review.
|
|
7
7
|
*/
|
|
8
8
|
type CustomModelConfig = {
|
|
9
|
-
/** Optional display name for this model in logs and output */
|
|
10
|
-
|
|
11
|
-
/** Vercel AI SDK LanguageModel instance (e.g., openai('gpt-5'), google('gemini-2.5-pro')) */
|
|
12
|
-
model: LanguageModel;
|
|
13
|
-
/** Provider-specific options passed to the model (e.g., { reasoningEffort: 'high' } for OpenAI) */
|
|
9
|
+
/** Optional display name for this model in logs and output */label?: string; /** Vercel AI SDK LanguageModel instance (e.g., openai('gpt-5'), google('gemini-2.5-pro')) */
|
|
10
|
+
model: LanguageModel; /** Provider-specific options passed to the model (e.g., { reasoningEffort: 'high' } for OpenAI) */
|
|
14
11
|
providerOptions?: Record<string, JSONValue>;
|
|
15
12
|
};
|
|
16
13
|
/**
|
|
@@ -18,13 +15,9 @@ type CustomModelConfig = {
|
|
|
18
15
|
* Allows full control over which models are used for each review phase.
|
|
19
16
|
*/
|
|
20
17
|
type SetupConfig = {
|
|
21
|
-
/** Identifier for this setup, used for selection via CLI --setup flag */
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
label: string;
|
|
25
|
-
/** Models that perform parallel code reviews. At least one reviewer is required. */
|
|
26
|
-
reviewers: CustomModelConfig[];
|
|
27
|
-
/** Model that validates and consolidates findings from all reviewers. Defaults to first reviewer if not specified. */
|
|
18
|
+
/** Identifier for this setup, used for selection via CLI --setup flag */id: string; /** Display label shown in UI */
|
|
19
|
+
label: string; /** Models that perform parallel code reviews. At least one reviewer is required. */
|
|
20
|
+
reviewers: CustomModelConfig[]; /** Model that validates and consolidates findings from all reviewers. Defaults to first reviewer if not specified. */
|
|
28
21
|
validator?: CustomModelConfig;
|
|
29
22
|
};
|
|
30
23
|
/**
|
|
@@ -37,9 +30,7 @@ type ReviewConcurrencyConfig = number | Record<string, number>;
|
|
|
37
30
|
* Context provided to scope's getFiles function with all available file lists.
|
|
38
31
|
*/
|
|
39
32
|
type ScopeContext = {
|
|
40
|
-
/** Files currently staged for commit */
|
|
41
|
-
stagedFiles: string[];
|
|
42
|
-
/** All files changed compared to base branch (or PR files if reviewing a PR) */
|
|
33
|
+
/** Files currently staged for commit */stagedFiles: string[]; /** All files changed compared to base branch (or PR files if reviewing a PR) */
|
|
43
34
|
allFiles: string[];
|
|
44
35
|
};
|
|
45
36
|
/**
|
|
@@ -47,9 +38,7 @@ type ScopeContext = {
|
|
|
47
38
|
* Allows defining which files should be included in the review.
|
|
48
39
|
*/
|
|
49
40
|
type ScopeConfig = {
|
|
50
|
-
/** Identifier for this scope, used for selection via CLI --scope flag */
|
|
51
|
-
id: string;
|
|
52
|
-
/** Display label shown in UI */
|
|
41
|
+
/** Identifier for this scope, used for selection via CLI --scope flag */id: string; /** Display label shown in UI */
|
|
53
42
|
label: string;
|
|
54
43
|
/**
|
|
55
44
|
* Which git diff source this scope should use.
|
|
@@ -57,8 +46,7 @@ type ScopeConfig = {
|
|
|
57
46
|
* - `staged` reviews staged changes
|
|
58
47
|
* @default 'branch'
|
|
59
48
|
*/
|
|
60
|
-
diffSource?: 'branch' | 'staged';
|
|
61
|
-
/** Function that receives available file lists and returns the files to review */
|
|
49
|
+
diffSource?: 'branch' | 'staged'; /** Function that receives available file lists and returns the files to review */
|
|
62
50
|
getFiles: (ctx: ScopeContext) => string[] | Promise<string[]>;
|
|
63
51
|
showFileCount?: boolean;
|
|
64
52
|
};
|
|
@@ -291,18 +279,9 @@ declare const DEFAULT_SCOPES: {
|
|
|
291
279
|
* ```
|
|
292
280
|
*/
|
|
293
281
|
declare const BUILT_IN_SCOPE_OPTIONS: ScopeConfig[];
|
|
294
|
-
/**
|
|
295
|
-
* Resolves a scope by id. Checks custom scopes first, then built-in defaults.
|
|
296
|
-
* Returns undefined if no scope is specified (to trigger interactive selection).
|
|
297
|
-
*/
|
|
298
|
-
|
|
299
282
|
//#endregion
|
|
300
283
|
//#region src/commands/shared/setups.d.ts
|
|
301
|
-
|
|
302
284
|
declare const BUILT_IN_SETUP_OPTIONS: SetupConfig[];
|
|
303
|
-
/**
|
|
304
|
-
* Converts setup configs to CLI select options.
|
|
305
|
-
*/
|
|
306
285
|
//#endregion
|
|
307
286
|
//#region src/commands/advanced-review-changes/advanced-review-changes.d.ts
|
|
308
287
|
declare const advancedReviewChangesCommand: {
|
|
@@ -495,4 +474,26 @@ declare const reviewPRCommand: {
|
|
|
495
474
|
}[] | undefined;
|
|
496
475
|
};
|
|
497
476
|
//#endregion
|
|
498
|
-
|
|
477
|
+
//#region src/commands/set-global-envs/set-global-envs.d.ts
|
|
478
|
+
declare const setGlobalEnvsCommand: {
|
|
479
|
+
short: string | undefined;
|
|
480
|
+
description: string;
|
|
481
|
+
run: (cmdArgs: {
|
|
482
|
+
[x: string]: string | number | boolean | undefined;
|
|
483
|
+
} | undefined) => Promise<void> | void;
|
|
484
|
+
args: Record<string, _ls_stack_cli0.Arg> | undefined;
|
|
485
|
+
examples: {
|
|
486
|
+
args: string[];
|
|
487
|
+
description: string;
|
|
488
|
+
}[] | undefined;
|
|
489
|
+
};
|
|
490
|
+
//#endregion
|
|
491
|
+
//#region src/lib/global-env.d.ts
|
|
492
|
+
declare function getGlobalEnvPath(): string;
|
|
493
|
+
declare function globalEnvExists(): boolean;
|
|
494
|
+
declare function createGlobalEnvFile(): {
|
|
495
|
+
created: boolean;
|
|
496
|
+
path: string;
|
|
497
|
+
};
|
|
498
|
+
//#endregion
|
|
499
|
+
export { BUILT_IN_SCOPE_OPTIONS, BUILT_IN_SETUP_OPTIONS, type CommitConfig, type Config, type CreatePRConfig, type CustomModelConfig, DEFAULT_SCOPES, type ReviewCodeChangesConfig, type ReviewConcurrencyConfig, type ScopeConfig, type ScopeContext, type SetupConfig, advancedReviewChangesCommand, commitCommand, createGlobalEnvFile, createPRCommand, defineConfig, getGlobalEnvPath, globalEnvExists, reviewCodeChangesCommand, reviewPRCommand, setGlobalEnvsCommand };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as advancedReviewChangesCommand, c as BUILT_IN_SCOPE_OPTIONS, d as createGlobalEnvFile, f as getGlobalEnvPath, i as commitCommand, l as DEFAULT_SCOPES, n as reviewPRCommand, o as reviewCodeChangesCommand, p as globalEnvExists, r as createPRCommand, s as BUILT_IN_SETUP_OPTIONS, t as setGlobalEnvsCommand, u as defineConfig } from "./set-global-envs-CyKhXAY_.mjs";
|
|
2
|
+
|
|
3
|
+
export { BUILT_IN_SCOPE_OPTIONS, BUILT_IN_SETUP_OPTIONS, DEFAULT_SCOPES, advancedReviewChangesCommand, commitCommand, createGlobalEnvFile, createPRCommand, defineConfig, getGlobalEnvPath, globalEnvExists, reviewCodeChangesCommand, reviewPRCommand, setGlobalEnvsCommand };
|
package/dist/main.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/main.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { a as advancedReviewChangesCommand, i as commitCommand, n as reviewPRCommand, o as reviewCodeChangesCommand, r as createPRCommand, t as setGlobalEnvsCommand } from "./set-global-envs-CyKhXAY_.mjs";
|
|
3
|
+
import { createCLI } from "@ls-stack/cli";
|
|
4
|
+
|
|
5
|
+
//#region src/main.ts
|
|
6
|
+
await createCLI({
|
|
7
|
+
name: "✨ ai-cmds",
|
|
8
|
+
baseCmd: "ai-cmds"
|
|
9
|
+
}, {
|
|
10
|
+
commit: commitCommand,
|
|
11
|
+
"review-code-changes": reviewCodeChangesCommand,
|
|
12
|
+
"review-pr": reviewPRCommand,
|
|
13
|
+
"create-pr": createPRCommand,
|
|
14
|
+
"advanced-review-changes": advancedReviewChangesCommand,
|
|
15
|
+
"set-global-envs": setGlobalEnvsCommand
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { };
|