git-coco 0.15.1 → 0.16.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/dist/index.d.ts CHANGED
@@ -140,6 +140,13 @@ type BaseConfig = {
140
140
  * @default 'main'
141
141
  */
142
142
  defaultBranch: string;
143
+ /**
144
+ * Whether to include the current branch name in the commit prompt for context.
145
+ * When enabled, the current git branch name will be included in the prompt.
146
+ *
147
+ * @default true
148
+ */
149
+ includeBranchName?: boolean;
143
150
  };
144
151
  type ConfigWithServiceObject = BaseConfig & Partial<BaseCommandOptions> & {
145
152
  service: LLMService;
@@ -177,6 +184,7 @@ interface CommitOptions extends BaseCommandOptions {
177
184
  ignoredExtensions: string[];
178
185
  withPreviousCommits: number;
179
186
  conventional: boolean;
187
+ includeBranchName: boolean;
180
188
  }
181
189
  type CommitArgv = Arguments<CommitOptions>;
182
190
 
@@ -338,4 +346,5 @@ declare namespace types_d {
338
346
  export type { types_d_BaseParserInput as BaseParserInput, types_d_BaseParserOptions as BaseParserOptions, types_d_CommandHandler as CommandHandler, types_d_CommitLogParserInput as CommitLogParserInput, types_d_ConfirmMessage as ConfirmMessage, types_d_ConfirmMessageCallback as ConfirmMessageCallback, types_d_DiffNode as DiffNode, types_d_DirectoryDiff as DirectoryDiff, types_d_FileChange as FileChange, types_d_FileChangeParserInput as FileChangeParserInput, types_d_FileChangeStatus as FileChangeStatus, types_d_FileDiff as FileDiff };
339
347
  }
340
348
 
341
- export { type Config$1 as Config, _default$3 as changelog, _default$2 as commit, _default$1 as init, _default as recap, types_d as types };
349
+ export { _default$3 as changelog, _default$2 as commit, _default$1 as init, _default as recap, types_d as types };
350
+ export type { Config$1 as Config };
@@ -40,14 +40,13 @@ import { exec } from 'child_process';
40
40
  import readline$1 from 'node:readline';
41
41
  import require$$0 from 'stream';
42
42
  import * as readline from 'readline';
43
- import { lint, load } from '@commitlint/core';
44
43
 
45
44
  // This file is auto-generated - DO NOT EDIT
46
45
  /* eslint-disable */
47
46
  /**
48
47
  * Current build version from package.json
49
48
  */
50
- const BUILD_VERSION = "0.15.1";
49
+ const BUILD_VERSION = "0.16.1";
51
50
 
52
51
  const isInteractive = (config) => {
53
52
  return config?.mode === 'interactive' || !!config?.interactive;
@@ -610,6 +609,11 @@ const schema$1 = {
610
609
  "type": "string",
611
610
  "description": "Default git branch for the repository.",
612
611
  "default": "main"
612
+ },
613
+ "includeBranchName": {
614
+ "type": "boolean",
615
+ "description": "Whether to include the current branch name in the commit prompt for context. When enabled, the current git branch name will be included in the prompt.",
616
+ "default": true
613
617
  }
614
618
  },
615
619
  "required": [
@@ -6534,6 +6538,7 @@ const getRepo = () => {
6534
6538
  * - format_instructions: Instructions for the output format (JSON with title and body)
6535
6539
  * - additional_context: Optional user-provided context to guide the commit message generation
6536
6540
  * - commit_history: Optional history of previous commits for context
6541
+ * - branch_name_context: String containing formatted branch name (or empty if disabled)
6537
6542
  */
6538
6543
  const template$4 = `Write informative git commit message, in the imperative, based on the diffs & file changes provided in the "Diff Summary" section.
6539
6544
  Commit Messages must have a short description that is less than 50 characters and a longer detailed summary around 300 characters, the shorter and more concise the better.
@@ -6550,6 +6555,8 @@ Please follow the guidelines below when writing your commit message:
6550
6555
  {{summary}}
6551
6556
  """"""
6552
6557
 
6558
+ {{branch_name_context}}
6559
+
6553
6560
  {{format_instructions}}
6554
6561
 
6555
6562
  {{commit_history}}
@@ -6557,7 +6564,7 @@ Please follow the guidelines below when writing your commit message:
6557
6564
  {{additional_context}}
6558
6565
  `;
6559
6566
  // Define the variables that will be passed to the prompt template
6560
- const inputVariables$3 = ['summary', 'format_instructions', 'additional_context', 'commit_history'];
6567
+ const inputVariables$3 = ['summary', 'format_instructions', 'additional_context', 'commit_history', 'branch_name_context'];
6561
6568
  const COMMIT_PROMPT = new PromptTemplate({
6562
6569
  template: template$4,
6563
6570
  inputVariables: inputVariables$3,
@@ -6597,6 +6604,8 @@ Based on the following diff summary, generate a conventional commit message that
6597
6604
  {{summary}}
6598
6605
  """"""
6599
6606
 
6607
+ {{branch_name_context}}
6608
+
6600
6609
  {{format_instructions}}
6601
6610
 
6602
6611
  {{commit_history}}
@@ -6613,6 +6622,7 @@ const conventionalInputVariables = [
6613
6622
  'additional_context',
6614
6623
  'commit_history',
6615
6624
  'format_instructions',
6625
+ 'branch_name_context',
6616
6626
  ];
6617
6627
  const CONVENTIONAL_COMMIT_PROMPT = new PromptTemplate({
6618
6628
  template: CONVENTIONAL_TEMPLATE,
@@ -7029,6 +7039,11 @@ const options$3 = {
7029
7039
  default: false,
7030
7040
  alias: 'c',
7031
7041
  },
7042
+ includeBranchName: {
7043
+ description: 'Include the current branch name in the commit prompt for context',
7044
+ type: 'boolean',
7045
+ default: true,
7046
+ },
7032
7047
  };
7033
7048
  const builder$3 = (yargs) => {
7034
7049
  return yargs.options(options$3).usage(getCommandUsageHeader(command$3));
@@ -10925,7 +10940,6 @@ const handler$3 = async (argv, logger) => {
10925
10940
  const schema = useConventional
10926
10941
  ? ConventionalCommitMessageResponseSchema
10927
10942
  : CommitMessageResponseSchema;
10928
- console.log('schema', schema);
10929
10943
  const parser = new StructuredOutputParser(schema);
10930
10944
  // Use conventional commit prompt if enabled
10931
10945
  const promptTemplate = useConventional ? CONVENTIONAL_COMMIT_PROMPT : COMMIT_PROMPT;
@@ -10951,22 +10965,30 @@ const handler$3 = async (argv, logger) => {
10951
10965
  commit_history = `## Commit History\n${commitHistoryData}`;
10952
10966
  }
10953
10967
  }
10954
- console.log('context', context);
10955
- console.log('prompt', prompt);
10968
+ // Get current branch name - we need this for ticket extraction regardless of prompt inclusion
10969
+ const branchName = await getCurrentBranchName({ git });
10970
+ // Check if branch name should be included in the prompt context
10971
+ const includeBranchName = argv.includeBranchName !== undefined
10972
+ ? argv.includeBranchName
10973
+ : config.includeBranchName !== false; // Default to true if not explicitly set to false
10974
+ // Create branch name context string based on the configuration
10975
+ const branchNameContext = includeBranchName ? `Current git branch name: ${branchName}` : '';
10976
+ // Get variables for the prompt
10977
+ const variables = {
10978
+ summary: context,
10979
+ format_instructions: formatInstructions,
10980
+ additional_context: additional_context,
10981
+ commit_history: commit_history,
10982
+ branch_name_context: branchNameContext,
10983
+ };
10956
10984
  const commitMsg = await executeChain({
10957
10985
  llm,
10958
10986
  prompt,
10959
- variables: {
10960
- summary: context,
10961
- format_instructions: formatInstructions,
10962
- additional_context: additional_context,
10963
- commit_history: commit_history,
10964
- },
10987
+ variables,
10965
10988
  parser,
10966
10989
  });
10967
10990
  // Construct the full commit message
10968
10991
  const appendedText = argv.append ? `\n\n${argv.append}` : '';
10969
- const branchName = await getCurrentBranchName({ git });
10970
10992
  const ticketId = extractTicketIdFromBranchName(branchName);
10971
10993
  const ticketFooter = argv.appendTicket && ticketId ? `\n\nPart of **${ticketId}**` : '';
10972
10994
  const fullMessage = `${commitMsg.title}\n\n${commitMsg.body}${appendedText}${ticketFooter}`;
@@ -14129,12 +14151,15 @@ y.help().parse(process.argv.slice(2));
14129
14151
  * Load commitlint configuration
14130
14152
  */
14131
14153
  async function loadCommitlintConfig() {
14154
+ // Dynamically import commitlint core
14155
+ const commitlint = await import('@commitlint/core');
14156
+ const { load } = commitlint;
14132
14157
  try {
14133
14158
  // Try to load project config
14134
14159
  const config = await load();
14135
14160
  return config;
14136
14161
  }
14137
- catch (error) {
14162
+ catch {
14138
14163
  // If no config found or error loading, use conventional config
14139
14164
  return load({
14140
14165
  extends: ['@commitlint/config-conventional'],
@@ -14147,6 +14172,9 @@ async function loadCommitlintConfig() {
14147
14172
  async function validateCommitMessage(message, options = {}) {
14148
14173
  try {
14149
14174
  const config = await loadCommitlintConfig();
14175
+ // Dynamically import commitlint lint function
14176
+ const commitlint = await import('@commitlint/core');
14177
+ const { lint } = commitlint;
14150
14178
  const result = await lint(message, config.rules, options);
14151
14179
  return {
14152
14180
  valid: result.valid,
package/dist/index.js CHANGED
@@ -39,7 +39,6 @@ var child_process = require('child_process');
39
39
  var readline = require('node:readline');
40
40
  var require$$0 = require('stream');
41
41
  var readline$1 = require('readline');
42
- var core$1 = require('@commitlint/core');
43
42
 
44
43
  function _interopNamespaceDefault(e) {
45
44
  var n = Object.create(null);
@@ -69,7 +68,7 @@ var readline__namespace = /*#__PURE__*/_interopNamespaceDefault(readline$1);
69
68
  /**
70
69
  * Current build version from package.json
71
70
  */
72
- const BUILD_VERSION = "0.15.1";
71
+ const BUILD_VERSION = "0.16.1";
73
72
 
74
73
  const isInteractive = (config) => {
75
74
  return config?.mode === 'interactive' || !!config?.interactive;
@@ -632,6 +631,11 @@ const schema$1 = {
632
631
  "type": "string",
633
632
  "description": "Default git branch for the repository.",
634
633
  "default": "main"
634
+ },
635
+ "includeBranchName": {
636
+ "type": "boolean",
637
+ "description": "Whether to include the current branch name in the commit prompt for context. When enabled, the current git branch name will be included in the prompt.",
638
+ "default": true
635
639
  }
636
640
  },
637
641
  "required": [
@@ -6556,6 +6560,7 @@ const getRepo = () => {
6556
6560
  * - format_instructions: Instructions for the output format (JSON with title and body)
6557
6561
  * - additional_context: Optional user-provided context to guide the commit message generation
6558
6562
  * - commit_history: Optional history of previous commits for context
6563
+ * - branch_name_context: String containing formatted branch name (or empty if disabled)
6559
6564
  */
6560
6565
  const template$4 = `Write informative git commit message, in the imperative, based on the diffs & file changes provided in the "Diff Summary" section.
6561
6566
  Commit Messages must have a short description that is less than 50 characters and a longer detailed summary around 300 characters, the shorter and more concise the better.
@@ -6572,6 +6577,8 @@ Please follow the guidelines below when writing your commit message:
6572
6577
  {{summary}}
6573
6578
  """"""
6574
6579
 
6580
+ {{branch_name_context}}
6581
+
6575
6582
  {{format_instructions}}
6576
6583
 
6577
6584
  {{commit_history}}
@@ -6579,7 +6586,7 @@ Please follow the guidelines below when writing your commit message:
6579
6586
  {{additional_context}}
6580
6587
  `;
6581
6588
  // Define the variables that will be passed to the prompt template
6582
- const inputVariables$3 = ['summary', 'format_instructions', 'additional_context', 'commit_history'];
6589
+ const inputVariables$3 = ['summary', 'format_instructions', 'additional_context', 'commit_history', 'branch_name_context'];
6583
6590
  const COMMIT_PROMPT = new prompts$1.PromptTemplate({
6584
6591
  template: template$4,
6585
6592
  inputVariables: inputVariables$3,
@@ -6619,6 +6626,8 @@ Based on the following diff summary, generate a conventional commit message that
6619
6626
  {{summary}}
6620
6627
  """"""
6621
6628
 
6629
+ {{branch_name_context}}
6630
+
6622
6631
  {{format_instructions}}
6623
6632
 
6624
6633
  {{commit_history}}
@@ -6635,6 +6644,7 @@ const conventionalInputVariables = [
6635
6644
  'additional_context',
6636
6645
  'commit_history',
6637
6646
  'format_instructions',
6647
+ 'branch_name_context',
6638
6648
  ];
6639
6649
  const CONVENTIONAL_COMMIT_PROMPT = new prompts$1.PromptTemplate({
6640
6650
  template: CONVENTIONAL_TEMPLATE,
@@ -7051,6 +7061,11 @@ const options$3 = {
7051
7061
  default: false,
7052
7062
  alias: 'c',
7053
7063
  },
7064
+ includeBranchName: {
7065
+ description: 'Include the current branch name in the commit prompt for context',
7066
+ type: 'boolean',
7067
+ default: true,
7068
+ },
7054
7069
  };
7055
7070
  const builder$3 = (yargs) => {
7056
7071
  return yargs.options(options$3).usage(getCommandUsageHeader(command$3));
@@ -10947,7 +10962,6 @@ const handler$3 = async (argv, logger) => {
10947
10962
  const schema = useConventional
10948
10963
  ? ConventionalCommitMessageResponseSchema
10949
10964
  : CommitMessageResponseSchema;
10950
- console.log('schema', schema);
10951
10965
  const parser = new output_parsers.StructuredOutputParser(schema);
10952
10966
  // Use conventional commit prompt if enabled
10953
10967
  const promptTemplate = useConventional ? CONVENTIONAL_COMMIT_PROMPT : COMMIT_PROMPT;
@@ -10973,22 +10987,30 @@ const handler$3 = async (argv, logger) => {
10973
10987
  commit_history = `## Commit History\n${commitHistoryData}`;
10974
10988
  }
10975
10989
  }
10976
- console.log('context', context);
10977
- console.log('prompt', prompt);
10990
+ // Get current branch name - we need this for ticket extraction regardless of prompt inclusion
10991
+ const branchName = await getCurrentBranchName({ git });
10992
+ // Check if branch name should be included in the prompt context
10993
+ const includeBranchName = argv.includeBranchName !== undefined
10994
+ ? argv.includeBranchName
10995
+ : config.includeBranchName !== false; // Default to true if not explicitly set to false
10996
+ // Create branch name context string based on the configuration
10997
+ const branchNameContext = includeBranchName ? `Current git branch name: ${branchName}` : '';
10998
+ // Get variables for the prompt
10999
+ const variables = {
11000
+ summary: context,
11001
+ format_instructions: formatInstructions,
11002
+ additional_context: additional_context,
11003
+ commit_history: commit_history,
11004
+ branch_name_context: branchNameContext,
11005
+ };
10978
11006
  const commitMsg = await executeChain({
10979
11007
  llm,
10980
11008
  prompt,
10981
- variables: {
10982
- summary: context,
10983
- format_instructions: formatInstructions,
10984
- additional_context: additional_context,
10985
- commit_history: commit_history,
10986
- },
11009
+ variables,
10987
11010
  parser,
10988
11011
  });
10989
11012
  // Construct the full commit message
10990
11013
  const appendedText = argv.append ? `\n\n${argv.append}` : '';
10991
- const branchName = await getCurrentBranchName({ git });
10992
11014
  const ticketId = extractTicketIdFromBranchName(branchName);
10993
11015
  const ticketFooter = argv.appendTicket && ticketId ? `\n\nPart of **${ticketId}**` : '';
10994
11016
  const fullMessage = `${commitMsg.title}\n\n${commitMsg.body}${appendedText}${ticketFooter}`;
@@ -14151,14 +14173,17 @@ y.help().parse(process.argv.slice(2));
14151
14173
  * Load commitlint configuration
14152
14174
  */
14153
14175
  async function loadCommitlintConfig() {
14176
+ // Dynamically import commitlint core
14177
+ const commitlint = await import('@commitlint/core');
14178
+ const { load } = commitlint;
14154
14179
  try {
14155
14180
  // Try to load project config
14156
- const config = await core$1.load();
14181
+ const config = await load();
14157
14182
  return config;
14158
14183
  }
14159
- catch (error) {
14184
+ catch {
14160
14185
  // If no config found or error loading, use conventional config
14161
- return core$1.load({
14186
+ return load({
14162
14187
  extends: ['@commitlint/config-conventional'],
14163
14188
  });
14164
14189
  }
@@ -14169,7 +14194,10 @@ async function loadCommitlintConfig() {
14169
14194
  async function validateCommitMessage(message, options = {}) {
14170
14195
  try {
14171
14196
  const config = await loadCommitlintConfig();
14172
- const result = await core$1.lint(message, config.rules, options);
14197
+ // Dynamically import commitlint lint function
14198
+ const commitlint = await import('@commitlint/core');
14199
+ const { lint } = commitlint;
14200
+ const result = await lint(message, config.rules, options);
14173
14201
  return {
14174
14202
  valid: result.valid,
14175
14203
  errors: result.errors.map((error) => error.message),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-coco",
3
- "version": "0.15.1",
3
+ "version": "0.16.1",
4
4
  "description": "zero-effort git commits with coco.",
5
5
  "author": "gfargo <ghfargo@gmail.com>",
6
6
  "license": "MIT",
@@ -93,7 +93,7 @@
93
93
  "@langchain/community": "^0.3.32",
94
94
  "@langchain/core": "^0.3.40",
95
95
  "@langchain/ollama": "^0.2.0",
96
- "@langchain/openai": "^0.4.4",
96
+ "@langchain/openai": "^0.5.0",
97
97
  "ajv": "^8.16.0",
98
98
  "ajv-formats": "^3.0.1",
99
99
  "chalk": "4.1.2",