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.
Files changed (116) hide show
  1. package/README.md +34 -160
  2. package/dist/commands/commit/commitFlags.js +7 -0
  3. package/dist/commands/commit/context/buildPrompt.js +16 -0
  4. package/dist/commands/commit/context/summaryPrompt.js +20 -0
  5. package/dist/commands/commit/context/systemPrompt.js +4 -1
  6. package/dist/commands/commit/context/userPrompt.js +4 -1
  7. package/dist/commands/commit/generateCommitMessage.js +16 -37
  8. package/dist/commands/commit/index.js +187 -178
  9. package/dist/commands/commit/summarizeDiff.js +193 -0
  10. package/dist/commands/config.js +24 -9
  11. package/dist/commands/hook/index.js +68 -0
  12. package/dist/commands/middleware/capabilitiesMiddleware/ghCapability.js +20 -20
  13. package/dist/commands/middleware/capabilitiesMiddleware/gitCapability.js +13 -10
  14. package/dist/commands/middleware/capabilitiesMiddleware/index.js +12 -11
  15. package/dist/commands/middleware/hasStagedChangesMiddleware.js +9 -6
  16. package/dist/commands/middleware/setupMiddleware/defaultModels.js +15 -0
  17. package/dist/commands/middleware/setupMiddleware/index.js +66 -38
  18. package/dist/commands/model.js +7 -4
  19. package/dist/commands/passthroughArgs.js +11 -0
  20. package/dist/commands/pr/context/systemPrompt.js +4 -1
  21. package/dist/commands/pr/context/userPrompt.js +4 -1
  22. package/dist/commands/pr/generatePRDetails.js +25 -31
  23. package/dist/commands/pr/getPRContext.js +37 -62
  24. package/dist/commands/pr/index.js +57 -62
  25. package/dist/commands/reset.js +26 -0
  26. package/dist/commands/review/index.js +31 -0
  27. package/dist/commands/setup.js +38 -13
  28. package/dist/config.js +63 -55
  29. package/dist/index.js +31 -62
  30. package/dist/llm/budget.js +10 -0
  31. package/dist/llm/index.js +12 -12
  32. package/dist/llm/providers/anthropic/index.js +31 -0
  33. package/dist/llm/providers/apiKey.js +41 -0
  34. package/dist/llm/providers/apple/client.js +77 -0
  35. package/dist/llm/providers/apple/index.js +69 -0
  36. package/dist/llm/providers/apple/models.js +29 -0
  37. package/dist/llm/providers/base.js +36 -0
  38. package/dist/llm/providers/local/index.js +84 -0
  39. package/dist/llm/providers/openai/index.js +19 -0
  40. package/dist/llm/providers/openaiCompatible.js +66 -0
  41. package/dist/llm/providers/openrouter/index.js +19 -0
  42. package/dist/llm/registry.js +39 -0
  43. package/dist/llm/setup/getAvailableModels.js +17 -0
  44. package/dist/llm/setup/selectModel.js +40 -0
  45. package/dist/llm/tokenCount.js +5 -0
  46. package/dist/package.js +67 -0
  47. package/dist/services/gh/createPullRequest.js +38 -58
  48. package/dist/services/gh/index.js +6 -3
  49. package/dist/services/gh/isAvailable.js +10 -8
  50. package/dist/services/git/executeGitAdd.js +11 -12
  51. package/dist/services/git/executeGitCommit.js +10 -11
  52. package/dist/services/git/getAmendChanges.js +23 -0
  53. package/dist/services/git/getChangedFiles.js +28 -61
  54. package/dist/services/git/getCommitsSinceBaseBranch.js +28 -56
  55. package/dist/services/git/getCurrentBranch.js +10 -8
  56. package/dist/services/git/getDefaultBranch.js +35 -60
  57. package/dist/services/git/getStagedChanges.js +10 -8
  58. package/dist/services/git/getStagedFiles.js +10 -9
  59. package/dist/services/git/hasStagedChanges.js +9 -8
  60. package/dist/services/git/index.js +17 -12
  61. package/dist/services/git/isAvailable.js +10 -8
  62. package/dist/services/git/isGitRepository.js +10 -8
  63. package/dist/utils/commitlint.js +97 -135
  64. package/dist/utils/formatBaseURL.js +7 -6
  65. package/dist/utils/maskApiKey.js +6 -7
  66. package/package.json +19 -5
  67. package/dist/commands/commit/context/systemPrompt.d.ts +0 -1
  68. package/dist/commands/commit/context/userPrompt.d.ts +0 -1
  69. package/dist/commands/commit/generateCommitMessage.d.ts +0 -1
  70. package/dist/commands/commit/index.d.ts +0 -7
  71. package/dist/commands/config.d.ts +0 -1
  72. package/dist/commands/middleware/capabilitiesMiddleware/ghCapability.d.ts +0 -1
  73. package/dist/commands/middleware/capabilitiesMiddleware/gitCapability.d.ts +0 -1
  74. package/dist/commands/middleware/capabilitiesMiddleware/index.d.ts +0 -3
  75. package/dist/commands/middleware/hasStagedChangesMiddleware.d.ts +0 -1
  76. package/dist/commands/middleware/setupMiddleware/getAvailableModels.d.ts +0 -4
  77. package/dist/commands/middleware/setupMiddleware/getAvailableModels.js +0 -11
  78. package/dist/commands/middleware/setupMiddleware/getOrUpdateApiKey.d.ts +0 -1
  79. package/dist/commands/middleware/setupMiddleware/getOrUpdateApiKey.js +0 -39
  80. package/dist/commands/middleware/setupMiddleware/index.d.ts +0 -4
  81. package/dist/commands/middleware/setupMiddleware/selectModel.d.ts +0 -5
  82. package/dist/commands/middleware/setupMiddleware/selectModel.js +0 -38
  83. package/dist/commands/middleware/setupMiddleware/setupLocalLLM.d.ts +0 -5
  84. package/dist/commands/middleware/setupMiddleware/setupLocalLLM.js +0 -60
  85. package/dist/commands/middleware/setupMiddleware/setupOpenRouter.d.ts +0 -2
  86. package/dist/commands/middleware/setupMiddleware/setupOpenRouter.js +0 -66
  87. package/dist/commands/middleware/setupMiddleware/types.d.ts +0 -13
  88. package/dist/commands/middleware/setupMiddleware/types.js +0 -1
  89. package/dist/commands/model.d.ts +0 -1
  90. package/dist/commands/pr/context/systemPrompt.d.ts +0 -1
  91. package/dist/commands/pr/context/userPrompt.d.ts +0 -1
  92. package/dist/commands/pr/generatePRDetails.d.ts +0 -4
  93. package/dist/commands/pr/getPRContext.d.ts +0 -1
  94. package/dist/commands/pr/index.d.ts +0 -10
  95. package/dist/commands/setup.d.ts +0 -3
  96. package/dist/config.d.ts +0 -18
  97. package/dist/index.d.ts +0 -2
  98. package/dist/llm/index.d.ts +0 -5
  99. package/dist/services/gh/createPullRequest.d.ts +0 -1
  100. package/dist/services/gh/index.d.ts +0 -4
  101. package/dist/services/gh/isAvailable.d.ts +0 -1
  102. package/dist/services/git/executeGitAdd.d.ts +0 -1
  103. package/dist/services/git/executeGitCommit.d.ts +0 -1
  104. package/dist/services/git/getChangedFiles.d.ts +0 -1
  105. package/dist/services/git/getCommitsSinceBaseBranch.d.ts +0 -1
  106. package/dist/services/git/getCurrentBranch.d.ts +0 -1
  107. package/dist/services/git/getDefaultBranch.d.ts +0 -1
  108. package/dist/services/git/getStagedChanges.d.ts +0 -1
  109. package/dist/services/git/getStagedFiles.d.ts +0 -1
  110. package/dist/services/git/hasStagedChanges.d.ts +0 -1
  111. package/dist/services/git/index.d.ts +0 -13
  112. package/dist/services/git/isAvailable.d.ts +0 -1
  113. package/dist/services/git/isGitRepository.d.ts +0 -1
  114. package/dist/utils/commitlint.d.ts +0 -25
  115. package/dist/utils/formatBaseURL.d.ts +0 -1
  116. 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,13 +0,0 @@
1
- export interface Model {
2
- id: string;
3
- name?: string;
4
- context_length?: number;
5
- pricing?: {
6
- prompt: number;
7
- completion: number;
8
- };
9
- }
10
- export interface ModelResponse {
11
- data: Model[];
12
- object?: string;
13
- }
@@ -1 +0,0 @@
1
- export {};
@@ -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,4 +0,0 @@
1
- export declare const generatePRDetails: () => Promise<{
2
- title: string;
3
- body: string;
4
- }>;
@@ -1 +0,0 @@
1
- export declare const getPRContext: () => string[];
@@ -1,10 +0,0 @@
1
- interface PullRequestOptions {
2
- title?: string;
3
- body?: string;
4
- draft?: boolean;
5
- base?: string;
6
- edit?: boolean;
7
- [key: string]: any;
8
- }
9
- export declare const prCreateCommand: (options?: PullRequestOptions) => Promise<void>;
10
- export {};
@@ -1,3 +0,0 @@
1
- export declare const setupCommand: (options?: {
2
- clearConfig?: boolean;
3
- }) => Promise<void>;
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
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node --experimental-specifier-resolution=node
2
- export {};
@@ -1,5 +0,0 @@
1
- import openai from "openai";
2
- export declare const OPENROUTER_API_URL = "https://openrouter.ai/api/v1";
3
- export declare const getLLMClient: (options?: {
4
- baseURLOverride?: string;
5
- }) => openai;
@@ -1 +0,0 @@
1
- export declare const createPullRequest: (title: string, body: string, baseBranch: string, draft: boolean) => void;
@@ -1,4 +0,0 @@
1
- export declare const gh: {
2
- createPullRequest: (title: string, body: string, baseBranch: string, draft: boolean) => void;
3
- isAvailable: () => boolean;
4
- };
@@ -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;