gennady 0.2.0 → 0.2.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/cli/gennady.js CHANGED
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env node
2
+
1
3
  import { readFileSync } from 'fs';
2
4
  import { fileURLToPath } from 'url';
3
5
  import { dirname, join } from 'path';
package/package.json CHANGED
@@ -1,17 +1,19 @@
1
1
  {
2
2
  "name": "gennady",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "author": "Konstantin Lebedev <ibnrubaxa@gmail.com>",
5
- "description": "Gennady — Generate Next-level Automated Description Intelligence",
5
+ "description": "Gennady — Generate Next-level Automated Description Yntelligence",
6
6
  "keywords": [
7
7
  "git",
8
8
  "ai",
9
9
  "llm",
10
+ "local",
10
11
  "commit",
11
- "generator"
12
+ "generator",
13
+ "gennady"
12
14
  ],
13
15
  "license": "MIT",
14
- "repository": "https://github.com/rubaxa/commit-gen",
16
+ "repository": "https://github.com/rubaxa/gennady",
15
17
  "type": "module",
16
18
  "bin": "./cli/gennady.js",
17
19
  "main": "index.js",
@@ -85,13 +85,15 @@ export class CommitGen {
85
85
  const maxTokens = codeChanged[codeChanged.length - 1].tokens;
86
86
  const languages = [...new Set(codeChanged.map(f => f.programmingLanguage).filter(Boolean))].join(', ');
87
87
  const mode =
88
- this.init.mode === 'auto'
89
- ? this.init.targetBranch
90
- ? 'detailed'
91
- : commitCount > 1 && codeChanged.length < 5
92
- ? 'oneline'
93
- : 'detailed'
94
- : this.init.mode;
88
+ this.init.oneline
89
+ ? 'oneline'
90
+ : this.init.mode === 'auto'
91
+ ? this.init.targetBranch
92
+ ? 'detailed'
93
+ : commitCount > 1 && codeChanged.length < 5
94
+ ? 'oneline'
95
+ : 'detailed'
96
+ : this.init.mode;
95
97
 
96
98
  this.logger.info(`- Mode: ${style.bold.magentaBright(mode)}`);
97
99
  this.logger.info(`- Languages: ${style.yellow(languages)}`);
@@ -104,16 +106,15 @@ export class CommitGen {
104
106
 
105
107
  const batches = codeChanged.reduce((acc, file) => {
106
108
  if (!acc[0] || acc[0].tokens + file.tokens > maxInputTokens) {
107
- if (acc[0]) {
108
- acc[0].languages = [...new Set(acc[0].languages)];
109
- }
110
-
111
109
  acc.unshift({tokens: 0, diff: '', languages: []});
112
110
  }
113
111
 
114
112
  acc[0].tokens += file.tokens;
115
113
  acc[0].diff += `File: ${file.filename}\n${file.diff.hunks.flatMap(h => h.changes).join('\n')}\n\n`;
116
- acc[0].languages.push(file.programmingLanguage);
114
+
115
+ if (!acc[0].languages.includes(file.programmingLanguage)) {
116
+ acc[0].languages.push(file.programmingLanguage);
117
+ }
117
118
 
118
119
  return acc;
119
120
  }, []);
@@ -139,7 +140,7 @@ export class CommitGen {
139
140
 
140
141
  const startFormatTime = performance.now();
141
142
  const formatted = await this.toFormat(
142
- mode === 'detailed' && !this.init.oneline ? this.init.formatDetailedPromptTemplate : this.init.formatOnelinePromptTemplate,
143
+ mode === 'detailed' ? this.init.formatDetailedPromptTemplate : this.init.formatOnelinePromptTemplate,
143
144
  results.join('\n\n'),
144
145
  );
145
146
  this.logger.info(`- Formatting time: ${style.blueBright(((performance.now() - startFormatTime) / 1000).toFixed(2))}s`);