gitpt 1.4.0 → 1.7.2
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 +34 -160
- package/dist/commands/commit/commitFlags.js +7 -0
- package/dist/commands/commit/context/buildPrompt.js +16 -0
- package/dist/commands/commit/context/summaryPrompt.js +20 -0
- package/dist/commands/commit/context/systemPrompt.js +4 -1
- package/dist/commands/commit/context/userPrompt.js +4 -1
- package/dist/commands/commit/generateCommitMessage.js +16 -37
- package/dist/commands/commit/index.js +187 -178
- package/dist/commands/commit/summarizeDiff.js +193 -0
- package/dist/commands/config.js +24 -9
- package/dist/commands/hook/index.js +68 -0
- package/dist/commands/middleware/capabilitiesMiddleware/ghCapability.js +20 -20
- package/dist/commands/middleware/capabilitiesMiddleware/gitCapability.js +13 -10
- package/dist/commands/middleware/capabilitiesMiddleware/index.js +12 -11
- package/dist/commands/middleware/hasStagedChangesMiddleware.js +9 -6
- package/dist/commands/middleware/setupMiddleware/defaultModels.js +15 -0
- package/dist/commands/middleware/setupMiddleware/index.js +66 -38
- package/dist/commands/model.js +7 -4
- package/dist/commands/passthroughArgs.js +11 -0
- package/dist/commands/pr/context/systemPrompt.js +4 -1
- package/dist/commands/pr/context/userPrompt.js +4 -1
- package/dist/commands/pr/generatePRDetails.js +25 -31
- package/dist/commands/pr/getPRContext.js +37 -62
- package/dist/commands/pr/index.js +57 -62
- package/dist/commands/reset.js +26 -0
- package/dist/commands/review/index.js +31 -0
- package/dist/commands/setup.js +38 -13
- package/dist/config.js +63 -55
- package/dist/index.js +31 -62
- package/dist/llm/budget.js +10 -0
- package/dist/llm/index.js +12 -12
- package/dist/llm/providers/anthropic/index.js +31 -0
- package/dist/llm/providers/apiKey.js +41 -0
- package/dist/llm/providers/apple/client.js +77 -0
- package/dist/llm/providers/apple/index.js +69 -0
- package/dist/llm/providers/apple/models.js +29 -0
- package/dist/llm/providers/base.js +36 -0
- package/dist/llm/providers/local/index.js +84 -0
- package/dist/llm/providers/openai/index.js +19 -0
- package/dist/llm/providers/openaiCompatible.js +66 -0
- package/dist/llm/providers/openrouter/index.js +19 -0
- package/dist/llm/registry.js +39 -0
- package/dist/llm/setup/getAvailableModels.js +17 -0
- package/dist/llm/setup/selectModel.js +40 -0
- package/dist/llm/tokenCount.js +5 -0
- package/dist/package.js +67 -0
- package/dist/services/gh/createPullRequest.js +38 -58
- package/dist/services/gh/index.js +6 -3
- package/dist/services/gh/isAvailable.js +10 -8
- package/dist/services/git/executeGitAdd.js +11 -12
- package/dist/services/git/executeGitCommit.js +10 -11
- package/dist/services/git/getAmendChanges.js +23 -0
- package/dist/services/git/getChangedFiles.js +28 -61
- package/dist/services/git/getCommitsSinceBaseBranch.js +28 -56
- package/dist/services/git/getCurrentBranch.js +10 -8
- package/dist/services/git/getDefaultBranch.js +35 -60
- package/dist/services/git/getStagedChanges.js +10 -8
- package/dist/services/git/getStagedFiles.js +10 -9
- package/dist/services/git/hasStagedChanges.js +9 -8
- package/dist/services/git/index.js +17 -12
- package/dist/services/git/isAvailable.js +10 -8
- package/dist/services/git/isGitRepository.js +10 -8
- package/dist/utils/commitlint.js +97 -135
- package/dist/utils/formatBaseURL.js +7 -6
- package/dist/utils/maskApiKey.js +6 -7
- package/package.json +19 -5
- package/dist/commands/commit/context/systemPrompt.d.ts +0 -1
- package/dist/commands/commit/context/userPrompt.d.ts +0 -1
- package/dist/commands/commit/generateCommitMessage.d.ts +0 -1
- package/dist/commands/commit/index.d.ts +0 -7
- package/dist/commands/config.d.ts +0 -1
- package/dist/commands/middleware/capabilitiesMiddleware/ghCapability.d.ts +0 -1
- package/dist/commands/middleware/capabilitiesMiddleware/gitCapability.d.ts +0 -1
- package/dist/commands/middleware/capabilitiesMiddleware/index.d.ts +0 -3
- package/dist/commands/middleware/hasStagedChangesMiddleware.d.ts +0 -1
- package/dist/commands/middleware/setupMiddleware/getAvailableModels.d.ts +0 -4
- package/dist/commands/middleware/setupMiddleware/getAvailableModels.js +0 -11
- package/dist/commands/middleware/setupMiddleware/getOrUpdateApiKey.d.ts +0 -1
- package/dist/commands/middleware/setupMiddleware/getOrUpdateApiKey.js +0 -39
- package/dist/commands/middleware/setupMiddleware/index.d.ts +0 -4
- package/dist/commands/middleware/setupMiddleware/selectModel.d.ts +0 -5
- package/dist/commands/middleware/setupMiddleware/selectModel.js +0 -38
- package/dist/commands/middleware/setupMiddleware/setupLocalLLM.d.ts +0 -5
- package/dist/commands/middleware/setupMiddleware/setupLocalLLM.js +0 -60
- package/dist/commands/middleware/setupMiddleware/setupOpenRouter.d.ts +0 -2
- package/dist/commands/middleware/setupMiddleware/setupOpenRouter.js +0 -66
- package/dist/commands/middleware/setupMiddleware/types.d.ts +0 -13
- package/dist/commands/middleware/setupMiddleware/types.js +0 -1
- package/dist/commands/model.d.ts +0 -1
- package/dist/commands/pr/context/systemPrompt.d.ts +0 -1
- package/dist/commands/pr/context/userPrompt.d.ts +0 -1
- package/dist/commands/pr/generatePRDetails.d.ts +0 -4
- package/dist/commands/pr/getPRContext.d.ts +0 -1
- package/dist/commands/pr/index.d.ts +0 -10
- package/dist/commands/setup.d.ts +0 -3
- package/dist/config.d.ts +0 -18
- package/dist/index.d.ts +0 -2
- package/dist/llm/index.d.ts +0 -5
- package/dist/services/gh/createPullRequest.d.ts +0 -1
- package/dist/services/gh/index.d.ts +0 -4
- package/dist/services/gh/isAvailable.d.ts +0 -1
- package/dist/services/git/executeGitAdd.d.ts +0 -1
- package/dist/services/git/executeGitCommit.d.ts +0 -1
- package/dist/services/git/getChangedFiles.d.ts +0 -1
- package/dist/services/git/getCommitsSinceBaseBranch.d.ts +0 -1
- package/dist/services/git/getCurrentBranch.d.ts +0 -1
- package/dist/services/git/getDefaultBranch.d.ts +0 -1
- package/dist/services/git/getStagedChanges.d.ts +0 -1
- package/dist/services/git/getStagedFiles.d.ts +0 -1
- package/dist/services/git/hasStagedChanges.d.ts +0 -1
- package/dist/services/git/index.d.ts +0 -13
- package/dist/services/git/isAvailable.d.ts +0 -1
- package/dist/services/git/isGitRepository.d.ts +0 -1
- package/dist/utils/commitlint.d.ts +0 -25
- package/dist/utils/formatBaseURL.d.ts +0 -1
- package/dist/utils/maskApiKey.d.ts +0 -1
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import inquirer from "inquirer";
|
|
3
|
-
import { OPENROUTER_API_URL } from "../../../llm/index.js";
|
|
4
|
-
import { saveConfig } from "../../../config.js";
|
|
5
|
-
import { getAvailableModels } from "./getAvailableModels.js";
|
|
6
|
-
import { getOrUpdateApiKey } from "./getOrUpdateApiKey.js";
|
|
7
|
-
import { selectModel } from "./selectModel.js";
|
|
8
|
-
export const setupOpenRouter = async (existingConfig) => {
|
|
9
|
-
// Get API key - either the existing one or a new one
|
|
10
|
-
const apiKey = await getOrUpdateApiKey(existingConfig.apiKey);
|
|
11
|
-
if (!apiKey) {
|
|
12
|
-
console.error(chalk.red("API key is required for OpenRouter."));
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
15
|
-
// Update the config with the potentially new API key
|
|
16
|
-
const updatedConfig = { ...existingConfig, apiKey };
|
|
17
|
-
// Display current model if any
|
|
18
|
-
if (updatedConfig.model) {
|
|
19
|
-
console.log("Current model:", chalk.yellow(updatedConfig.model));
|
|
20
|
-
console.log("");
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
console.log(chalk.gray("Fetching available models from OpenRouter..."));
|
|
24
|
-
const models = await getAvailableModels({
|
|
25
|
-
baseURLOverride: OPENROUTER_API_URL,
|
|
26
|
-
});
|
|
27
|
-
if (models.length > 0) {
|
|
28
|
-
console.log(chalk.green(`✓ Found ${models.length} models available with your API key`));
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
console.log(chalk.yellow("No models found from OpenRouter. Please specify a model manually."));
|
|
32
|
-
}
|
|
33
|
-
const selectedModel = await selectModel(models, updatedConfig.model);
|
|
34
|
-
const finalConfig = {
|
|
35
|
-
...updatedConfig,
|
|
36
|
-
model: selectedModel,
|
|
37
|
-
useLocalLLM: false,
|
|
38
|
-
};
|
|
39
|
-
// Save the config
|
|
40
|
-
saveConfig(finalConfig);
|
|
41
|
-
console.log(chalk.green(`✓ Model set to: ${chalk.yellow(selectedModel)}`));
|
|
42
|
-
return finalConfig;
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
console.error(chalk.yellow(`Error fetching models: ${error}`));
|
|
46
|
-
// Fallback to manual input if API call fails
|
|
47
|
-
const modelAnswer = await inquirer.prompt([
|
|
48
|
-
{
|
|
49
|
-
type: "input",
|
|
50
|
-
name: "model",
|
|
51
|
-
message: "Enter model identifier:",
|
|
52
|
-
validate: (input) => input ? true : "Model identifier is required",
|
|
53
|
-
},
|
|
54
|
-
]);
|
|
55
|
-
const selectedModel = modelAnswer.model;
|
|
56
|
-
const finalConfig = {
|
|
57
|
-
...updatedConfig,
|
|
58
|
-
model: selectedModel,
|
|
59
|
-
useLocalLLM: false,
|
|
60
|
-
};
|
|
61
|
-
// Save the config
|
|
62
|
-
saveConfig(finalConfig);
|
|
63
|
-
console.log(chalk.green(`✓ Model set to: ${chalk.yellow(selectedModel)}`));
|
|
64
|
-
return finalConfig;
|
|
65
|
-
}
|
|
66
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/commands/model.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const modelCommand: () => Promise<void>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const systemPrompt = "\nYou are a helpful assistant that generates clear, informative GitHub pull request titles and descriptions.\n\nFor the title:\n- Keep it concise (under 80 characters)\n- Start with a verb in present tense (e.g., \"Add\", \"Fix\", \"Update\")\n- Clearly summarize the main purpose of the changes\n\nFor the description:\n- Start with a brief summary (1-2 sentences) of what the PR accomplishes\n- Include a more detailed explanation of changes if needed\n- List key changes as bullet points if there are multiple components\n- Include any relevant context that reviewers should know\n- End with any testing instructions if applicable\n\nFormat the description in Markdown with sections.\nDo not include \"PR\" or \"Pull Request\" in the title.\n";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const userPrompt: (context: string) => string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getPRContext: () => string[];
|
package/dist/commands/setup.d.ts
DELETED
package/dist/config.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface GitPTConfig {
|
|
2
|
-
provider?: "openrouter" | "local";
|
|
3
|
-
customLLMEndpoint?: string;
|
|
4
|
-
model?: string;
|
|
5
|
-
apiKey?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const getConfig: () => GitPTConfig;
|
|
8
|
-
export declare const saveConfig: (newConfig: GitPTConfig) => void;
|
|
9
|
-
export declare enum ConfigErrors {
|
|
10
|
-
CustomLLMEndpointRequired = "Custom LLM endpoint is required for local LLM provider.",
|
|
11
|
-
APIKeyRequired = "API key is required for OpenRouter provider.",
|
|
12
|
-
ModelRequired = "Model is required."
|
|
13
|
-
}
|
|
14
|
-
export declare const validateConfig: () => {
|
|
15
|
-
isValid: boolean;
|
|
16
|
-
errors?: string[];
|
|
17
|
-
};
|
|
18
|
-
export declare const clearConfig: () => void;
|
package/dist/index.d.ts
DELETED
package/dist/llm/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const createPullRequest: (title: string, body: string, baseBranch: string, draft: boolean) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isAvailable: () => boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const executeGitAdd: (files: string[]) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const executeGitCommit: (message: string, additionalArgs?: string[]) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getChangedFiles: (baseBranch: string) => string[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getCommitsSinceBaseBranch: (baseBranch: string) => string[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getCurrentBranch: () => string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getDefaultBranch: () => string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getStagedChanges: () => string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getStagedFiles: () => string[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const hasStagedChanges: () => boolean;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare const git: {
|
|
2
|
-
add: (files: string[]) => void;
|
|
3
|
-
commit: (message: string, additionalArgs?: string[]) => void;
|
|
4
|
-
getChangedFiles: (baseBranch: string) => string[];
|
|
5
|
-
getCommitsSinceBaseBranch: (baseBranch: string) => string[];
|
|
6
|
-
getCurrentBranch: () => string;
|
|
7
|
-
getDefaultBranch: () => string;
|
|
8
|
-
hasStagedChanges: () => boolean;
|
|
9
|
-
getStagedChanges: () => string;
|
|
10
|
-
getStagedFiles: () => string[];
|
|
11
|
-
isAvailable: () => boolean;
|
|
12
|
-
isGitRepository: () => boolean;
|
|
13
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isAvailable: () => boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isGitRepository: () => boolean;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export interface CommitlintConfig {
|
|
2
|
-
rules?: Record<string, any>;
|
|
3
|
-
extends?: string | string[];
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Check if a commitlint configuration exists in the repository
|
|
7
|
-
*/
|
|
8
|
-
export declare function hasCommitlintConfig(): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Read commitlint config file (using @commitlint/load) and print it out
|
|
11
|
-
*/
|
|
12
|
-
export declare function readCommitlintConfig(): Promise<any>;
|
|
13
|
-
/**
|
|
14
|
-
* Get the commitlint configuration format rules as a string
|
|
15
|
-
*/
|
|
16
|
-
export declare function getCommitlintRules(): string;
|
|
17
|
-
/**
|
|
18
|
-
* Validate a commit message against commitlint rules
|
|
19
|
-
* @param message The commit message to validate
|
|
20
|
-
* @returns An object with success status and error message if applicable
|
|
21
|
-
*/
|
|
22
|
-
export declare function validateCommitMessage(message: string): Promise<{
|
|
23
|
-
valid: boolean;
|
|
24
|
-
errors?: string;
|
|
25
|
-
}>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const formatBaseURL: (baseURL: string) => string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const maskApiKey: (apiKey: string) => string;
|