mirror of
https://github.com/di-sukharev/opencommit.git
synced 2026-01-13 07:38:01 -05:00
Compare commits
2 Commits
dev
...
398_make_w
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23a8d76977 | ||
|
|
4387c12552 |
10
README.md
10
README.md
@@ -162,6 +162,16 @@ oco config set OCO_EMOJI=false
|
|||||||
|
|
||||||
Other config options are behaving the same.
|
Other config options are behaving the same.
|
||||||
|
|
||||||
|
### Output WHY the changes were done (WIP)
|
||||||
|
|
||||||
|
You can set the `OCO_WHY` config to `true` to have OpenCommit output a short description of WHY the changes were done after the commit message. Default is `false`.
|
||||||
|
|
||||||
|
To make this perform accurate we must store 'what files do' in some kind of an index or embedding and perform a lookup (kinda RAG) for the accurate git commit message. If you feel like building this comment on this ticket https://github.com/di-sukharev/opencommit/issues/398 and let's go from there together.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
oco config set OCO_WHY=true
|
||||||
|
```
|
||||||
|
|
||||||
### Switch to GPT-4 or other models
|
### Switch to GPT-4 or other models
|
||||||
|
|
||||||
By default, OpenCommit uses `gpt-4o-mini` model.
|
By default, OpenCommit uses `gpt-4o-mini` model.
|
||||||
|
|||||||
43
out/cli.cjs
43
out/cli.cjs
@@ -27752,6 +27752,7 @@ var CONFIG_KEYS = /* @__PURE__ */ ((CONFIG_KEYS2) => {
|
|||||||
CONFIG_KEYS2["OCO_EMOJI"] = "OCO_EMOJI";
|
CONFIG_KEYS2["OCO_EMOJI"] = "OCO_EMOJI";
|
||||||
CONFIG_KEYS2["OCO_MODEL"] = "OCO_MODEL";
|
CONFIG_KEYS2["OCO_MODEL"] = "OCO_MODEL";
|
||||||
CONFIG_KEYS2["OCO_LANGUAGE"] = "OCO_LANGUAGE";
|
CONFIG_KEYS2["OCO_LANGUAGE"] = "OCO_LANGUAGE";
|
||||||
|
CONFIG_KEYS2["OCO_WHY"] = "OCO_WHY";
|
||||||
CONFIG_KEYS2["OCO_MESSAGE_TEMPLATE_PLACEHOLDER"] = "OCO_MESSAGE_TEMPLATE_PLACEHOLDER";
|
CONFIG_KEYS2["OCO_MESSAGE_TEMPLATE_PLACEHOLDER"] = "OCO_MESSAGE_TEMPLATE_PLACEHOLDER";
|
||||||
CONFIG_KEYS2["OCO_PROMPT_MODULE"] = "OCO_PROMPT_MODULE";
|
CONFIG_KEYS2["OCO_PROMPT_MODULE"] = "OCO_PROMPT_MODULE";
|
||||||
CONFIG_KEYS2["OCO_AI_PROVIDER"] = "OCO_AI_PROVIDER";
|
CONFIG_KEYS2["OCO_AI_PROVIDER"] = "OCO_AI_PROVIDER";
|
||||||
@@ -28042,6 +28043,7 @@ var DEFAULT_CONFIG = {
|
|||||||
OCO_ONE_LINE_COMMIT: false,
|
OCO_ONE_LINE_COMMIT: false,
|
||||||
OCO_TEST_MOCK_TYPE: "commit-message",
|
OCO_TEST_MOCK_TYPE: "commit-message",
|
||||||
OCO_FLOWISE_ENDPOINT: ":",
|
OCO_FLOWISE_ENDPOINT: ":",
|
||||||
|
OCO_WHY: false,
|
||||||
OCO_GITPUSH: true
|
OCO_GITPUSH: true
|
||||||
};
|
};
|
||||||
var initGlobalConfig = (configPath = defaultConfigPath) => {
|
var initGlobalConfig = (configPath = defaultConfigPath) => {
|
||||||
@@ -42568,7 +42570,7 @@ Example Git Diff is to follow:`
|
|||||||
];
|
];
|
||||||
var INIT_MAIN_PROMPT = (language, prompts) => ({
|
var INIT_MAIN_PROMPT = (language, prompts) => ({
|
||||||
role: "system",
|
role: "system",
|
||||||
content: `${IDENTITY} Your mission is to create clean and comprehensive commit messages in the given @commitlint convention and explain WHAT were the changes and WHY the changes were done. I'll send you an output of 'git diff --staged' command, and you convert it into a commit message.
|
content: `${IDENTITY} Your mission is to create clean and comprehensive commit messages in the given @commitlint convention and explain WHAT were the changes ${config2.OCO_WHY ? "and WHY the changes were done" : ""}. I'll send you an output of 'git diff --staged' command, and you convert it into a commit message.
|
||||||
${config2.OCO_EMOJI ? "Use GitMoji convention to preface the commit." : "Do not preface the commit with anything."}
|
${config2.OCO_EMOJI ? "Use GitMoji convention to preface the commit." : "Do not preface the commit with anything."}
|
||||||
${config2.OCO_DESCRIPTION ? `Add a short description of WHY the changes are done after the commit message. Don't start it with "This commit", just describe the changes.` : "Don't add any descriptions to the commit, only commit message."}
|
${config2.OCO_DESCRIPTION ? `Add a short description of WHY the changes are done after the commit message. Don't start it with "This commit", just describe the changes.` : "Don't add any descriptions to the commit, only commit message."}
|
||||||
Use the present tense. Use ${language} to answer.
|
Use the present tense. Use ${language} to answer.
|
||||||
@@ -42588,12 +42590,23 @@ var commitlintPrompts = {
|
|||||||
// src/modules/commitlint/pwd-commitlint.ts
|
// src/modules/commitlint/pwd-commitlint.ts
|
||||||
var import_promises = __toESM(require("fs/promises"), 1);
|
var import_promises = __toESM(require("fs/promises"), 1);
|
||||||
var import_path3 = __toESM(require("path"), 1);
|
var import_path3 = __toESM(require("path"), 1);
|
||||||
|
var findModulePath = (moduleName) => {
|
||||||
|
const searchPaths = [
|
||||||
|
import_path3.default.join("node_modules", moduleName),
|
||||||
|
import_path3.default.join("node_modules", ".pnpm")
|
||||||
|
];
|
||||||
|
for (const basePath of searchPaths) {
|
||||||
|
try {
|
||||||
|
const resolvedPath = require.resolve(moduleName, { paths: [basePath] });
|
||||||
|
return resolvedPath;
|
||||||
|
} catch {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error(`Cannot find module ${moduleName}`);
|
||||||
|
};
|
||||||
var getCommitLintModuleType = async () => {
|
var getCommitLintModuleType = async () => {
|
||||||
const packageFile = "node_modules/@commitlint/load/package.json";
|
const packageFile = "@commitlint/load/package.json";
|
||||||
const packageJsonPath = import_path3.default.join(
|
const packageJsonPath = findModulePath(packageFile);
|
||||||
process.env.PWD || process.cwd(),
|
|
||||||
packageFile
|
|
||||||
);
|
|
||||||
const packageJson = JSON.parse(await import_promises.default.readFile(packageJsonPath, "utf8"));
|
const packageJson = JSON.parse(await import_promises.default.readFile(packageJsonPath, "utf8"));
|
||||||
if (!packageJson) {
|
if (!packageJson) {
|
||||||
throw new Error(`Failed to parse ${packageFile}`);
|
throw new Error(`Failed to parse ${packageFile}`);
|
||||||
@@ -42601,21 +42614,15 @@ var getCommitLintModuleType = async () => {
|
|||||||
return packageJson.type === "module" ? "esm" : "cjs";
|
return packageJson.type === "module" ? "esm" : "cjs";
|
||||||
};
|
};
|
||||||
var getCommitLintPWDConfig = async () => {
|
var getCommitLintPWDConfig = async () => {
|
||||||
let load, nodeModulesPath;
|
let load, modulePath;
|
||||||
switch (await getCommitLintModuleType()) {
|
switch (await getCommitLintModuleType()) {
|
||||||
case "cjs":
|
case "cjs":
|
||||||
nodeModulesPath = import_path3.default.join(
|
modulePath = findModulePath("@commitlint/load");
|
||||||
process.env.PWD || process.cwd(),
|
load = require(modulePath).default;
|
||||||
"node_modules/@commitlint/load"
|
|
||||||
);
|
|
||||||
load = require(nodeModulesPath).default;
|
|
||||||
break;
|
break;
|
||||||
case "esm":
|
case "esm":
|
||||||
nodeModulesPath = import_path3.default.join(
|
modulePath = await findModulePath("@commitlint/load/lib/load.js");
|
||||||
process.env.PWD || process.cwd(),
|
load = (await import(modulePath)).default;
|
||||||
"node_modules/@commitlint/load/lib/load.js"
|
|
||||||
);
|
|
||||||
load = (await import(nodeModulesPath)).default;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (load && typeof load === "function") {
|
if (load && typeof load === "function") {
|
||||||
@@ -43350,7 +43357,7 @@ var commitlintConfigCommand = G3(
|
|||||||
const { mode } = argv._;
|
const { mode } = argv._;
|
||||||
if (mode === "get" /* get */) {
|
if (mode === "get" /* get */) {
|
||||||
const commitLintConfig = await getCommitlintLLMConfig();
|
const commitLintConfig = await getCommitlintLLMConfig();
|
||||||
ce(commitLintConfig.toString());
|
ce(JSON.stringify(commitLintConfig, null, 2));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mode === "force" /* force */) {
|
if (mode === "force" /* force */) {
|
||||||
|
|||||||
@@ -46564,6 +46564,7 @@ var CONFIG_KEYS = /* @__PURE__ */ ((CONFIG_KEYS2) => {
|
|||||||
CONFIG_KEYS2["OCO_EMOJI"] = "OCO_EMOJI";
|
CONFIG_KEYS2["OCO_EMOJI"] = "OCO_EMOJI";
|
||||||
CONFIG_KEYS2["OCO_MODEL"] = "OCO_MODEL";
|
CONFIG_KEYS2["OCO_MODEL"] = "OCO_MODEL";
|
||||||
CONFIG_KEYS2["OCO_LANGUAGE"] = "OCO_LANGUAGE";
|
CONFIG_KEYS2["OCO_LANGUAGE"] = "OCO_LANGUAGE";
|
||||||
|
CONFIG_KEYS2["OCO_WHY"] = "OCO_WHY";
|
||||||
CONFIG_KEYS2["OCO_MESSAGE_TEMPLATE_PLACEHOLDER"] = "OCO_MESSAGE_TEMPLATE_PLACEHOLDER";
|
CONFIG_KEYS2["OCO_MESSAGE_TEMPLATE_PLACEHOLDER"] = "OCO_MESSAGE_TEMPLATE_PLACEHOLDER";
|
||||||
CONFIG_KEYS2["OCO_PROMPT_MODULE"] = "OCO_PROMPT_MODULE";
|
CONFIG_KEYS2["OCO_PROMPT_MODULE"] = "OCO_PROMPT_MODULE";
|
||||||
CONFIG_KEYS2["OCO_AI_PROVIDER"] = "OCO_AI_PROVIDER";
|
CONFIG_KEYS2["OCO_AI_PROVIDER"] = "OCO_AI_PROVIDER";
|
||||||
@@ -46854,6 +46855,7 @@ var DEFAULT_CONFIG = {
|
|||||||
OCO_ONE_LINE_COMMIT: false,
|
OCO_ONE_LINE_COMMIT: false,
|
||||||
OCO_TEST_MOCK_TYPE: "commit-message",
|
OCO_TEST_MOCK_TYPE: "commit-message",
|
||||||
OCO_FLOWISE_ENDPOINT: ":",
|
OCO_FLOWISE_ENDPOINT: ":",
|
||||||
|
OCO_WHY: false,
|
||||||
OCO_GITPUSH: true
|
OCO_GITPUSH: true
|
||||||
};
|
};
|
||||||
var initGlobalConfig = (configPath = defaultConfigPath) => {
|
var initGlobalConfig = (configPath = defaultConfigPath) => {
|
||||||
@@ -61380,7 +61382,7 @@ Example Git Diff is to follow:`
|
|||||||
];
|
];
|
||||||
var INIT_MAIN_PROMPT = (language, prompts) => ({
|
var INIT_MAIN_PROMPT = (language, prompts) => ({
|
||||||
role: "system",
|
role: "system",
|
||||||
content: `${IDENTITY} Your mission is to create clean and comprehensive commit messages in the given @commitlint convention and explain WHAT were the changes and WHY the changes were done. I'll send you an output of 'git diff --staged' command, and you convert it into a commit message.
|
content: `${IDENTITY} Your mission is to create clean and comprehensive commit messages in the given @commitlint convention and explain WHAT were the changes ${config2.OCO_WHY ? "and WHY the changes were done" : ""}. I'll send you an output of 'git diff --staged' command, and you convert it into a commit message.
|
||||||
${config2.OCO_EMOJI ? "Use GitMoji convention to preface the commit." : "Do not preface the commit with anything."}
|
${config2.OCO_EMOJI ? "Use GitMoji convention to preface the commit." : "Do not preface the commit with anything."}
|
||||||
${config2.OCO_DESCRIPTION ? `Add a short description of WHY the changes are done after the commit message. Don't start it with "This commit", just describe the changes.` : "Don't add any descriptions to the commit, only commit message."}
|
${config2.OCO_DESCRIPTION ? `Add a short description of WHY the changes are done after the commit message. Don't start it with "This commit", just describe the changes.` : "Don't add any descriptions to the commit, only commit message."}
|
||||||
Use the present tense. Use ${language} to answer.
|
Use the present tense. Use ${language} to answer.
|
||||||
@@ -61400,12 +61402,23 @@ var commitlintPrompts = {
|
|||||||
// src/modules/commitlint/pwd-commitlint.ts
|
// src/modules/commitlint/pwd-commitlint.ts
|
||||||
var import_promises = __toESM(require("fs/promises"), 1);
|
var import_promises = __toESM(require("fs/promises"), 1);
|
||||||
var import_path3 = __toESM(require("path"), 1);
|
var import_path3 = __toESM(require("path"), 1);
|
||||||
|
var findModulePath = (moduleName) => {
|
||||||
|
const searchPaths = [
|
||||||
|
import_path3.default.join("node_modules", moduleName),
|
||||||
|
import_path3.default.join("node_modules", ".pnpm")
|
||||||
|
];
|
||||||
|
for (const basePath of searchPaths) {
|
||||||
|
try {
|
||||||
|
const resolvedPath = require.resolve(moduleName, { paths: [basePath] });
|
||||||
|
return resolvedPath;
|
||||||
|
} catch {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error(`Cannot find module ${moduleName}`);
|
||||||
|
};
|
||||||
var getCommitLintModuleType = async () => {
|
var getCommitLintModuleType = async () => {
|
||||||
const packageFile = "node_modules/@commitlint/load/package.json";
|
const packageFile = "@commitlint/load/package.json";
|
||||||
const packageJsonPath = import_path3.default.join(
|
const packageJsonPath = findModulePath(packageFile);
|
||||||
process.env.PWD || process.cwd(),
|
|
||||||
packageFile
|
|
||||||
);
|
|
||||||
const packageJson = JSON.parse(await import_promises.default.readFile(packageJsonPath, "utf8"));
|
const packageJson = JSON.parse(await import_promises.default.readFile(packageJsonPath, "utf8"));
|
||||||
if (!packageJson) {
|
if (!packageJson) {
|
||||||
throw new Error(`Failed to parse ${packageFile}`);
|
throw new Error(`Failed to parse ${packageFile}`);
|
||||||
@@ -61413,21 +61426,15 @@ var getCommitLintModuleType = async () => {
|
|||||||
return packageJson.type === "module" ? "esm" : "cjs";
|
return packageJson.type === "module" ? "esm" : "cjs";
|
||||||
};
|
};
|
||||||
var getCommitLintPWDConfig = async () => {
|
var getCommitLintPWDConfig = async () => {
|
||||||
let load, nodeModulesPath;
|
let load, modulePath;
|
||||||
switch (await getCommitLintModuleType()) {
|
switch (await getCommitLintModuleType()) {
|
||||||
case "cjs":
|
case "cjs":
|
||||||
nodeModulesPath = import_path3.default.join(
|
modulePath = findModulePath("@commitlint/load");
|
||||||
process.env.PWD || process.cwd(),
|
load = require(modulePath).default;
|
||||||
"node_modules/@commitlint/load"
|
|
||||||
);
|
|
||||||
load = require(nodeModulesPath).default;
|
|
||||||
break;
|
break;
|
||||||
case "esm":
|
case "esm":
|
||||||
nodeModulesPath = import_path3.default.join(
|
modulePath = await findModulePath("@commitlint/load/lib/load.js");
|
||||||
process.env.PWD || process.cwd(),
|
load = (await import(modulePath)).default;
|
||||||
"node_modules/@commitlint/load/lib/load.js"
|
|
||||||
);
|
|
||||||
load = (await import(nodeModulesPath)).default;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (load && typeof load === "function") {
|
if (load && typeof load === "function") {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export enum CONFIG_KEYS {
|
|||||||
OCO_EMOJI = 'OCO_EMOJI',
|
OCO_EMOJI = 'OCO_EMOJI',
|
||||||
OCO_MODEL = 'OCO_MODEL',
|
OCO_MODEL = 'OCO_MODEL',
|
||||||
OCO_LANGUAGE = 'OCO_LANGUAGE',
|
OCO_LANGUAGE = 'OCO_LANGUAGE',
|
||||||
|
OCO_WHY = 'OCO_WHY',
|
||||||
OCO_MESSAGE_TEMPLATE_PLACEHOLDER = 'OCO_MESSAGE_TEMPLATE_PLACEHOLDER',
|
OCO_MESSAGE_TEMPLATE_PLACEHOLDER = 'OCO_MESSAGE_TEMPLATE_PLACEHOLDER',
|
||||||
OCO_PROMPT_MODULE = 'OCO_PROMPT_MODULE',
|
OCO_PROMPT_MODULE = 'OCO_PROMPT_MODULE',
|
||||||
OCO_AI_PROVIDER = 'OCO_AI_PROVIDER',
|
OCO_AI_PROVIDER = 'OCO_AI_PROVIDER',
|
||||||
@@ -376,6 +377,7 @@ export type ConfigType = {
|
|||||||
[CONFIG_KEYS.OCO_OPENAI_BASE_PATH]?: string;
|
[CONFIG_KEYS.OCO_OPENAI_BASE_PATH]?: string;
|
||||||
[CONFIG_KEYS.OCO_DESCRIPTION]: boolean;
|
[CONFIG_KEYS.OCO_DESCRIPTION]: boolean;
|
||||||
[CONFIG_KEYS.OCO_EMOJI]: boolean;
|
[CONFIG_KEYS.OCO_EMOJI]: boolean;
|
||||||
|
[CONFIG_KEYS.OCO_WHY]: boolean;
|
||||||
[CONFIG_KEYS.OCO_MODEL]: string;
|
[CONFIG_KEYS.OCO_MODEL]: string;
|
||||||
[CONFIG_KEYS.OCO_LANGUAGE]: string;
|
[CONFIG_KEYS.OCO_LANGUAGE]: string;
|
||||||
[CONFIG_KEYS.OCO_MESSAGE_TEMPLATE_PLACEHOLDER]: string;
|
[CONFIG_KEYS.OCO_MESSAGE_TEMPLATE_PLACEHOLDER]: string;
|
||||||
@@ -435,6 +437,7 @@ export const DEFAULT_CONFIG = {
|
|||||||
OCO_ONE_LINE_COMMIT: false,
|
OCO_ONE_LINE_COMMIT: false,
|
||||||
OCO_TEST_MOCK_TYPE: 'commit-message',
|
OCO_TEST_MOCK_TYPE: 'commit-message',
|
||||||
OCO_FLOWISE_ENDPOINT: ':',
|
OCO_FLOWISE_ENDPOINT: ':',
|
||||||
|
OCO_WHY: false,
|
||||||
OCO_GITPUSH: true // todo: deprecate
|
OCO_GITPUSH: true // todo: deprecate
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -258,7 +258,9 @@ const INIT_MAIN_PROMPT = (
|
|||||||
prompts: string[]
|
prompts: string[]
|
||||||
): OpenAI.Chat.Completions.ChatCompletionMessageParam => ({
|
): OpenAI.Chat.Completions.ChatCompletionMessageParam => ({
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content: `${IDENTITY} Your mission is to create clean and comprehensive commit messages in the given @commitlint convention and explain WHAT were the changes and WHY the changes were done. I'll send you an output of 'git diff --staged' command, and you convert it into a commit message.
|
content: `${IDENTITY} Your mission is to create clean and comprehensive commit messages in the given @commitlint convention and explain WHAT were the changes ${
|
||||||
|
config.OCO_WHY ? 'and WHY the changes were done' : ''
|
||||||
|
}. I'll send you an output of 'git diff --staged' command, and you convert it into a commit message.
|
||||||
${
|
${
|
||||||
config.OCO_EMOJI
|
config.OCO_EMOJI
|
||||||
? 'Use GitMoji convention to preface the commit.'
|
? 'Use GitMoji convention to preface the commit.'
|
||||||
|
|||||||
Reference in New Issue
Block a user