opencommit 3.0.10 → 3.0.12

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 (3) hide show
  1. package/README.md +11 -8
  2. package/out/cli.cjs +33 -16
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  <h1 align="center">OpenCommit</h1>
5
5
  <h4 align="center">Follow the bird <a href="https://twitter.com/_sukharev_"><img src="https://img.shields.io/twitter/follow/_sukharev_?style=flat&label=_sukharev_&logo=twitter&color=0bf&logoColor=fff" align="center"></a>
6
6
  </div>
7
- <h2>Auto-generate meaningful commits in 1 second</h2>
7
+ <h2>Auto-generate meaningful commits in a second</h2>
8
8
  <p>Killing lame commits with AI đŸ¤¯đŸ”Ģ</p>
9
9
  <a href="https://www.npmjs.com/package/opencommit"><img src="https://img.shields.io/npm/v/opencommit" alt="Current version"></a>
10
10
  <h4 align="center">đŸĒŠ Winner of <a href="https://twitter.com/_sukharev_/status/1683448136973582336">GitHub 2023 hackathon</a> đŸĒŠ</h4>
@@ -68,20 +68,22 @@ You can also run it with local model through ollama:
68
68
 
69
69
  ```sh
70
70
  git add <files...>
71
- AI_PROVIDER='ollama' opencommit
71
+ OCO_AI_PROVIDER='ollama' opencommit
72
72
  ```
73
73
 
74
74
  ### Flags
75
+
75
76
  There are multiple optional flags that can be used with the `oco` command:
76
77
 
77
78
  #### Use Full GitMoji Specification
79
+
78
80
  This flag can only be used if the `OCO_EMOJI` configuration item is set to `true`. This flag allows users to use all emojis in the GitMoji specification, By default, the GitMoji full specification is set to `false`, which only includes 10 emojis (🐛✨📝🚀✅â™ģī¸âŦ†ī¸đŸ”§đŸŒđŸ’Ą).
79
81
  This is due to limit the number of tokens sent in each request. However, if you would like to use the full GitMoji specification, you can use the `--fgm` flag.
80
82
 
81
83
  ```
82
84
  oco --fgm
83
85
  ```
84
-
86
+
85
87
  ## Configuration
86
88
 
87
89
  ### Local per repo configuration
@@ -95,10 +97,11 @@ OCO_TOKENS_MAX_OUTPUT=<max response tokens (default: 500)>
95
97
  OCO_OPENAI_BASE_PATH=<may be used to set proxy path to OpenAI api>
96
98
  OCO_DESCRIPTION=<postface a message with ~3 sentences description of the changes>
97
99
  OCO_EMOJI=<boolean, add GitMoji>
98
- OCO_MODEL=<either 'gpt-4', 'gpt-3.5-turbo-16k' (default), 'gpt-3.5-turbo-0613' or 'gpt-3.5-turbo'>
100
+ OCO_MODEL=<either 'gpt-4', 'gpt-3.5-turbo' (default), 'gpt-3.5-turbo-0125', 'gpt-4-1106-preview', 'gpt-4-turbo-preview' or 'gpt-4-0125-preview'>
99
101
  OCO_LANGUAGE=<locale, scroll to the bottom to see options>
100
102
  OCO_MESSAGE_TEMPLATE_PLACEHOLDER=<message template placeholder, default: '$msg'>
101
103
  OCO_PROMPT_MODULE=<either conventional-commit or @commitlint, default: conventional-commit>
104
+ OCO_ONE_LINE_COMMIT=<one line commit message, default: false>
102
105
  ```
103
106
 
104
107
  ### Global config for all repos
@@ -125,7 +128,7 @@ oco config set OCO_EMOJI=false
125
128
 
126
129
  ### Switch to GPT-4 or other models
127
130
 
128
- By default, OpenCommit uses `gpt-3.5-turbo-16k` model.
131
+ By default, OpenCommit uses `gpt-3.5-turbo` model.
129
132
 
130
133
  You may switch to GPT-4 which performs better, but costs ~x15 times more 🤠
131
134
 
@@ -142,7 +145,7 @@ oco config set OCO_MODEL=gpt-3.5-turbo
142
145
  or for GPT-4 Turbo (Preview) which is more capable, has knowledge of world events up to April 2023, a 128k context window and 2-3x cheaper vs GPT-4:
143
146
 
144
147
  ```sh
145
- oco config set OCO_MODEL=gpt-4-1106-preview
148
+ oco config set OCO_MODEL=gpt-4-0125-preview
146
149
  ```
147
150
 
148
151
  Make sure that you spell it `gpt-4` (lowercase) and that you have API access to the 4th model. Even if you have ChatGPT+, that doesn't necessarily mean that you have API access to GPT-4.
@@ -348,7 +351,7 @@ jobs:
348
351
  OCO_OPENAI_BASE_PATH: ''
349
352
  OCO_DESCRIPTION: false
350
353
  OCO_EMOJI: false
351
- OCO_MODEL: gpt-3.5-turbo-16k
354
+ OCO_MODEL: gpt-3.5-turbo
352
355
  OCO_LANGUAGE: en
353
356
  OCO_PROMPT_MODULE: conventional-commit
354
357
  ```
@@ -365,6 +368,6 @@ You pay for your requests to OpenAI API on your own.
365
368
 
366
369
  OpenCommit stores your key locally.
367
370
 
368
- OpenCommit by default uses 3.5-turbo-16k model, it should not exceed $0.10 per casual working day.
371
+ OpenCommit by default uses 3.5-turbo model, it should not exceed $0.10 per casual working day.
369
372
 
370
373
  You may switch to gpt-4, it's better, but more expensive.
package/out/cli.cjs CHANGED
@@ -16384,7 +16384,7 @@ function G3(t, e2) {
16384
16384
  // package.json
16385
16385
  var package_default = {
16386
16386
  name: "opencommit",
16387
- version: "3.0.10",
16387
+ version: "3.0.12",
16388
16388
  description: "Auto-generate impressive commits in 1 second. Killing lame commits with AI \u{1F92F}\u{1F52B}",
16389
16389
  keywords: [
16390
16390
  "git",
@@ -18660,7 +18660,11 @@ var validateConfig = (key, condition, validationMessage) => {
18660
18660
  };
18661
18661
  var configValidators = {
18662
18662
  ["OCO_OPENAI_API_KEY" /* OCO_OPENAI_API_KEY */](value, config8 = {}) {
18663
- validateConfig("API_KEY", value || config8.OCO_AI_PROVIDER == "ollama", "You need to provide an API key");
18663
+ validateConfig(
18664
+ "API_KEY",
18665
+ value || config8.OCO_AI_PROVIDER == "ollama",
18666
+ "You need to provide an API key"
18667
+ );
18664
18668
  validateConfig(
18665
18669
  "OCO_OPENAI_API_KEY" /* OCO_OPENAI_API_KEY */,
18666
18670
  value.startsWith("sk-"),
@@ -18742,12 +18746,13 @@ var configValidators = {
18742
18746
  "OCO_MODEL" /* OCO_MODEL */,
18743
18747
  [
18744
18748
  "gpt-3.5-turbo",
18749
+ "gpt-3.5-turbo-0125",
18745
18750
  "gpt-4",
18746
- "gpt-3.5-turbo-16k",
18747
- "gpt-3.5-turbo-0613",
18748
- "gpt-4-1106-preview"
18751
+ "gpt-4-1106-preview",
18752
+ "gpt-4-turbo-preview",
18753
+ "gpt-4-0125-preview"
18749
18754
  ].includes(value),
18750
- `${value} is not supported yet, use 'gpt-4', 'gpt-3.5-turbo-16k' (default), 'gpt-3.5-turbo-0613', 'gpt-3.5-turbo' or 'gpt-4-1106-preview'`
18755
+ `${value} is not supported yet, use 'gpt-4', 'gpt-3.5-turbo' (default), 'gpt-3.5-turbo-0125', 'gpt-4-1106-preview', 'gpt-4-turbo-preview' or 'gpt-4-0125-preview'`
18751
18756
  );
18752
18757
  return value;
18753
18758
  },
@@ -18778,6 +18783,14 @@ var configValidators = {
18778
18783
  `${value} is not supported yet, use 'ollama' or 'openai' (default)`
18779
18784
  );
18780
18785
  return value;
18786
+ },
18787
+ ["OCO_ONE_LINE_COMMIT" /* OCO_ONE_LINE_COMMIT */](value) {
18788
+ validateConfig(
18789
+ "OCO_ONE_LINE_COMMIT" /* OCO_ONE_LINE_COMMIT */,
18790
+ typeof value === "boolean",
18791
+ "Must be true or false"
18792
+ );
18793
+ return value;
18781
18794
  }
18782
18795
  };
18783
18796
  var configPath = (0, import_path.join)((0, import_os.homedir)(), ".opencommit");
@@ -18789,11 +18802,12 @@ var getConfig = () => {
18789
18802
  OCO_OPENAI_BASE_PATH: process.env.OCO_OPENAI_BASE_PATH,
18790
18803
  OCO_DESCRIPTION: process.env.OCO_DESCRIPTION === "true" ? true : false,
18791
18804
  OCO_EMOJI: process.env.OCO_EMOJI === "true" ? true : false,
18792
- OCO_MODEL: process.env.OCO_MODEL || "gpt-3.5-turbo-16k",
18805
+ OCO_MODEL: process.env.OCO_MODEL || "gpt-3.5-turbo",
18793
18806
  OCO_LANGUAGE: process.env.OCO_LANGUAGE || "en",
18794
18807
  OCO_MESSAGE_TEMPLATE_PLACEHOLDER: process.env.OCO_MESSAGE_TEMPLATE_PLACEHOLDER || "$msg",
18795
18808
  OCO_PROMPT_MODULE: process.env.OCO_PROMPT_MODULE || "conventional-commit",
18796
- OCO_AI_PROVIDER: process.env.OCO_AI_PROVIDER || "openai"
18809
+ OCO_AI_PROVIDER: process.env.OCO_AI_PROVIDER || "openai",
18810
+ OCO_ONE_LINE_COMMIT: process.env.OCO_ONE_LINE_COMMIT === "true" ? true : false
18797
18811
  };
18798
18812
  const configExists = (0, import_fs.existsSync)(configPath);
18799
18813
  if (!configExists)
@@ -19013,6 +19027,7 @@ var INIT_MAIN_PROMPT = (language, prompts) => ({
19013
19027
  ${config2?.OCO_EMOJI ? "Use GitMoji convention to preface the commit." : "Do not preface the commit with anything."}
19014
19028
  ${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."}
19015
19029
  Use the present tense. Use ${language} to answer.
19030
+ ${config2?.OCO_ONE_LINE_COMMIT ? "Craft a concise commit message that encapsulates all changes made, with an emphasis on the primary updates. If the modifications share a common theme or scope, mention it succinctly; otherwise, leave the scope out to maintain focus. The goal is to provide a clear and unified overview of the changes in a one single message, without diverging into a list of commit per file change." : ""}
19016
19031
 
19017
19032
  You will strictly follow the following conventions to generate the content of the commit message:
19018
19033
  - ${prompts.join("\n- ")}
@@ -21991,12 +22006,11 @@ var api = new OpenAi();
21991
22006
  var OllamaAi = class {
21992
22007
  async generateCommitMessage(messages) {
21993
22008
  const model = "mistral";
21994
- let prompt = messages.map((x4) => x4.content).join("\n");
21995
- prompt += "Summarize above git diff in 10 words or less";
21996
- const url3 = "http://localhost:11434/api/generate";
22009
+ const url3 = "http://localhost:11434/api/chat";
21997
22010
  const p4 = {
21998
22011
  model,
21999
- prompt,
22012
+ messages,
22013
+ options: { temperature: 0, top_p: 0.1 },
22000
22014
  stream: false
22001
22015
  };
22002
22016
  try {
@@ -22005,8 +22019,8 @@ var OllamaAi = class {
22005
22019
  "Content-Type": "application/json"
22006
22020
  }
22007
22021
  });
22008
- const answer = response.data?.response;
22009
- return answer;
22022
+ const message = response.data.message;
22023
+ return message?.content;
22010
22024
  } catch (err) {
22011
22025
  const message = err.response?.data?.error ?? err.message;
22012
22026
  throw new Error("local model issues. details: " + message);
@@ -22078,6 +22092,7 @@ var INIT_MAIN_PROMPT2 = (language, fullGitMojiSpec) => ({
22078
22092
  content: `${IDENTITY} Your mission is to create clean and comprehensive commit messages as per the ${fullGitMojiSpec ? "GitMoji specification" : "conventional commit convention"} and explain WHAT were the changes and mainly WHY the changes were done. I'll send you an output of 'git diff --staged' command, and you are to convert it into a commit message.
22079
22093
  ${config5?.OCO_EMOJI ? `Use GitMoji convention to preface the commit. Here are some help to choose the right emoji (emoji, description): \u{1F41B}, Fix a bug; \u2728, Introduce new features; \u{1F4DD}, Add or update documentation; \u{1F680}, Deploy stuff; \u2705, Add, update, or pass tests; \u267B\uFE0F, Refactor code; \u2B06\uFE0F, Upgrade dependencies; \u{1F527}, Add or update configuration files; \u{1F310}, Internationalization and localization; \u{1F4A1}, Add or update comments in source code; ${fullGitMojiSpec ? "\u{1F3A8}, Improve structure / format of the code; \u26A1\uFE0F, Improve performance; \u{1F525}, Remove code or files; \u{1F691}\uFE0F, Critical hotfix; \u{1F484}, Add or update the UI and style files; \u{1F389}, Begin a project; \u{1F512}\uFE0F, Fix security issues; \u{1F510}, Add or update secrets; \u{1F516}, Release / Version tags; \u{1F6A8}, Fix compiler / linter warnings; \u{1F6A7}, Work in progress; \u{1F49A}, Fix CI Build; \u2B07\uFE0F, Downgrade dependencies; \u{1F4CC}, Pin dependencies to specific versions; \u{1F477}, Add or update CI build system; \u{1F4C8}, Add or update analytics or track code; \u2795, Add a dependency; \u2796, Remove a dependency; \u{1F528}, Add or update development scripts; \u270F\uFE0F, Fix typos; \u{1F4A9}, Write bad code that needs to be improved; \u23EA\uFE0F, Revert changes; \u{1F500}, Merge branches; \u{1F4E6}\uFE0F, Add or update compiled files or packages; \u{1F47D}\uFE0F, Update code due to external API changes; \u{1F69A}, Move or rename resources (e.g.: files, paths, routes); \u{1F4C4}, Add or update license; \u{1F4A5}, Introduce breaking changes; \u{1F371}, Add or update assets; \u267F\uFE0F, Improve accessibility; \u{1F37B}, Write code drunkenly; \u{1F4AC}, Add or update text and literals; \u{1F5C3}\uFE0F, Perform database related changes; \u{1F50A}, Add or update logs; \u{1F507}, Remove logs; \u{1F465}, Add or update contributor(s); \u{1F6B8}, Improve user experience / usability; \u{1F3D7}\uFE0F, Make architectural changes; \u{1F4F1}, Work on responsive design; \u{1F921}, Mock things; \u{1F95A}, Add or update an easter egg; \u{1F648}, Add or update a .gitignore file; \u{1F4F8}, Add or update snapshots; \u2697\uFE0F, Perform experiments; \u{1F50D}\uFE0F, Improve SEO; \u{1F3F7}\uFE0F, Add or update types; \u{1F331}, Add or update seed files; \u{1F6A9}, Add, update, or remove feature flags; \u{1F945}, Catch errors; \u{1F4AB}, Add or update animations and transitions; \u{1F5D1}\uFE0F, Deprecate code that needs to be cleaned up; \u{1F6C2}, Work on code related to authorization, roles and permissions; \u{1FA79}, Simple fix for a non-critical issue; \u{1F9D0}, Data exploration/inspection; \u26B0\uFE0F, Remove dead code; \u{1F9EA}, Add a failing test; \u{1F454}, Add or update business logic; \u{1FA7A}, Add or update healthcheck; \u{1F9F1}, Infrastructure related changes; \u{1F9D1}\u200D\u{1F4BB}, Improve developer experience; \u{1F4B8}, Add sponsorships or money related infrastructure; \u{1F9F5}, Add or update code related to multithreading or concurrency; \u{1F9BA}, Add or update code related to validation." : ""}` : "Do not preface the commit with anything. Conventional commit keywords:fix, feat, build, chore, ci, docs, style, refactor, perf, test."}
22080
22094
  ${config5?.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."}
22095
+ ${config5?.OCO_ONE_LINE_COMMIT ? "Craft a concise commit message that encapsulates all changes made, with an emphasis on the primary updates. If the modifications share a common theme or scope, mention it succinctly; otherwise, leave the scope out to maintain focus. The goal is to provide a clear and unified overview of the changes in a one single message, without diverging into a list of commit per file change." : ""}
22081
22096
  Use the present tense. Lines must not be longer than 74 characters. Use ${language} for the commit message.`
22082
22097
  });
22083
22098
  var INIT_DIFF_PROMPT = {
@@ -22413,6 +22428,8 @@ var generateCommitMessageFromGitDiff = async (diff, extraArgs2, fullGitMojiSpec)
22413
22428
  );
22414
22429
  const messageTemplate = checkMessageTemplate(extraArgs2);
22415
22430
  if (config7?.OCO_MESSAGE_TEMPLATE_PLACEHOLDER && typeof messageTemplate === "string") {
22431
+ const messageTemplateIndex = extraArgs2.indexOf(messageTemplate);
22432
+ extraArgs2.splice(messageTemplateIndex, 1);
22416
22433
  commitMessage = messageTemplate.replace(
22417
22434
  config7?.OCO_MESSAGE_TEMPLATE_PLACEHOLDER,
22418
22435
  commitMessage
@@ -22659,7 +22676,7 @@ var hookCommand = G3(
22659
22676
  return ce(`${source_default.green("\u2714")} Hook is removed`);
22660
22677
  }
22661
22678
  throw new Error(
22662
- `Unsupported mode: ${mode2}. Supported modes are: 'set' or 'unset'`
22679
+ `Unsupported mode: ${mode2}. Supported modes are: 'set' or 'unset', do: \`oco hook set\``
22663
22680
  );
22664
22681
  } catch (error) {
22665
22682
  ce(`${source_default.red("\u2716")} ${error}`);
@@ -22764,7 +22781,7 @@ Z2(
22764
22781
  if (await isHookCalled()) {
22765
22782
  prepareCommitMessageHook();
22766
22783
  } else {
22767
- commit(extraArgs, flags.fgm);
22784
+ commit(extraArgs, false, flags.fgm);
22768
22785
  }
22769
22786
  },
22770
22787
  extraArgs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencommit",
3
- "version": "3.0.10",
3
+ "version": "3.0.12",
4
4
  "description": "Auto-generate impressive commits in 1 second. Killing lame commits with AI đŸ¤¯đŸ”Ģ",
5
5
  "keywords": [
6
6
  "git",