@negoziator/ai-commit 1.2.6 → 1.2.7

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 +37 -219
  2. package/dist/cli.mjs +1 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,25 +1,35 @@
1
1
  <div align="center">
2
- <h1>🤖 AI-Commit 🤖 </h1>
2
+ <h1>🤖 AI-Commit 🤖</h1>
3
3
  <p>Your coding companion, ensures that every commit you make is meaningful, insightful, and contributing positively towards your development workflow.</p>
4
4
  <a href="https://www.npmjs.com/package/@negoziator/ai-commit"><img src="https://img.shields.io/npm/v/@negoziator/ai-commit" alt="Current version"></a>
5
5
  </div>
6
6
 
7
7
  ---
8
- ## Setup
9
8
 
10
- > The minimum supported version of Node.js is the latest v14. Check your Node.js version with `node --version`.
9
+ ## Table of Contents
10
+ - [Setup](#setup)
11
+ - [Installation](#installation)
12
+ - [Upgrading](#upgrading)
13
+ - [Usage](#usage)
14
+ - [CLI Mode](#cli-mode)
15
+ - [Configuration](#configuration)
16
+ - [Options](#options)
17
+ - [Maintainers](#maintainers)
18
+ - [Contributing](#contributing)
11
19
 
12
- 1. Install _ai-commit_:
20
+ ## Setup
21
+ > A minimum of Node v18 is required. Check your Node.js version with `node --version`.
13
22
 
14
- ```sh
15
- npm install -g @negoziator/ai-commit
16
- ```
23
+ ### Installation
24
+ 1. **Install AI-Commit:**
25
+ ```sh
26
+ npm install -g @negoziator/ai-commit
17
27
 
18
- 2. Retrieve your API key from [OpenAI](https://platform.openai.com/account/api-keys)
28
+ 2. **Retrieve your API key from [OpenAI](https://platform.openai.com/account/api-keys)**
19
29
 
20
- > Note: If you haven't already, you'll have to create an account and set up billing.
30
+ > Note: This requires an OpenAI account. If you don't have one, you can sign up for a free trial.
21
31
 
22
- 3. Set the key so aicommit can use it:
32
+ 3. **Set the key so aicommit can use it:**
23
33
 
24
34
  ```sh
25
35
  aicommit config set OPENAI_KEY=<your token>
@@ -29,251 +39,59 @@
29
39
 
30
40
  ### Upgrading
31
41
 
32
- Check the installed version with:
33
-
34
- ```
35
- aicommit --version
36
- ```
37
-
38
- If it's not the [latest version](https://github.com/negoziator/aicommit/releases/latest), run:
39
-
40
42
  ```sh
41
43
  npm update -g @negoziator/ai-commit
42
44
  ```
43
45
 
44
46
  ## Usage
45
47
 
46
- ### CLI mode
48
+ ### CLI Mode
47
49
 
48
- You can call `aicommit` directly to generate a commit message for your staged changes:
50
+ Use `aicommit` directly to generate a commit message for your staged changes:
49
51
 
50
52
  ```sh
51
53
  git add <files...>
52
54
  aicommit
53
55
  ```
54
56
 
55
- `aicommit` passes down unknown flags to `git commit`, so you can pass
56
- in [`commit` flags](https://git-scm.com/docs/git-commit).
57
-
58
- For example, you can stage all changes in tracked files with as you commit:
59
-
60
- ```sh
61
- aicommit --all # or -a
62
- ```
63
-
64
- > 👉**Tip:** Use the `aic` alias if `aicommit` is too long for you.
65
-
66
- #### Generate multiple recommendations
67
-
68
- Sometimes the recommended commit message isn't the best so you want it to generate a few to pick from. You can generate
69
- multiple commit messages at once by passing in the `--generate <i>` flag, where 'i' is the number of generated messages:
70
-
71
- ```sh
72
- aicommit --generate <i> # or -g <i>
73
- ```
74
-
75
- > Warning: this uses more tokens, meaning it costs more.
76
-
77
- #### Generating Conventional Commits
78
-
79
- If you'd like to generate [Conventional Commits](https://conventionalcommits.org/), you can use the `--type` flag
80
- followed by `conventional`. This will prompt `aicommit` to format the commit message according to the Conventional
81
- Commits specification:
82
-
83
- ```sh
84
- aicommit --type conventional # or -t conventional
85
- ```
86
-
87
- This feature can be useful if your project follows the Conventional Commits standard or if you're using tools that rely
88
- on this commit format.
89
-
90
- ### Git hook
91
-
92
- You can also integrate _aicommit_ with Git via
93
- the [`prepare-commit-msg`](https://git-scm.com/docs/githooks#_prepare_commit_msg) hook. This lets you use Git like you
94
- normally would, and edit the commit message before committing.
95
-
96
- #### Install
97
-
98
- In the Git repository you want to install the hook in:
99
-
100
- ```sh
101
- aicommit hook install
102
- ```
103
-
104
- #### Uninstall
105
-
106
- In the Git repository you want to uninstall the hook from:
107
-
108
- ```sh
109
- aicommit hook uninstall
110
- ```
111
-
112
- #### Usage
113
-
114
- 1. Stage your files and commit:
115
- ```sh
116
- git add <files...>
117
- git commit # Only generates a message when it's not passed in
118
- ```
119
-
120
- > If you ever want to write your own message instead of generating one, you can simply pass one
121
- in: `git commit -m "My message"`
122
-
123
- 2. aicommit will generate the commit message for you and pass it back to Git. Git will open it with
124
- the [configured editor](https://docs.github.com/en/get-started/getting-started-with-git/associating-text-editors-with-git)
125
- for you to review/edit it.
126
-
127
- 3. Save and close the editor to commit!
128
-
129
57
  ## Configuration
58
+ Manage configuration using the `aicommit config` command.
130
59
 
131
- ### Reading a configuration value
132
-
133
- To retrieve a configuration option, use the command:
60
+ To get a configuration option value, use the command:
134
61
 
135
62
  ```sh
136
63
  aicommit config get <key>
137
64
  ```
138
-
139
65
  For example, to retrieve the API key, you can use:
140
66
 
141
67
  ```sh
142
68
  aicommit config get OPENAI_KEY
69
+ > sk_1234567890
143
70
  ```
144
71
 
145
- You can also retrieve multiple configuration options at once by separating them with spaces:
146
-
147
- ```sh
148
- aicommit config get OPENAI_KEY generate
149
- ```
150
-
151
- ### Setting a configuration value
152
-
153
72
  To set a configuration option, use the command:
154
73
 
155
74
  ```sh
156
75
  aicommit config set <key>=<value>
157
76
  ```
158
77
 
159
- For example, to set the API key, you can use:
160
-
161
- ```sh
162
- aicommit config set OPENAI_KEY=<your-api-key>
163
- ```
164
-
165
- You can also set multiple configuration options at once by separating them with spaces, like
166
-
167
- ```sh
168
- aicommit config set OPENAI_KEY=<your-api-key> generate=3 locale=en
169
- ```
170
-
171
78
  ### Options
172
79
 
173
- #### OPENAI_KEY
174
-
175
- Required
176
-
177
- The OpenAI API key. You can retrieve it from [OpenAI API Keys page](https://platform.openai.com/account/api-keys).
178
-
179
- #### locale
180
-
181
- Default: `en`
182
-
183
- The locale to use for the generated commit messages. Consult the list of codes
184
- in: https://wikipedia.org/wiki/List_of_ISO_639-1_codes.
185
-
186
- #### generate
187
-
188
- Default: `1`
189
-
190
- The number of commit messages to generate to pick from.
191
-
192
- Note, this will use more tokens as it generates more results.
193
-
194
- #### model
195
-
196
- Default: `gpt-3.5-turbo`
197
-
198
- The Chat Completions (`/v1/chat/completions`) model to use. Consult the list of models available in
199
- the [OpenAI Documentation](https://platform.openai.com/docs/models/model-endpoint-compatibility).
200
-
201
- > Tip: If you have access, try upgrading to [`gpt-4`](https://platform.openai.com/docs/models/gpt-4) for next-level code
202
- > analysis. It can handle double the input size, but comes at a higher cost. Check out OpenAI's website to learn more.
203
-
204
- #### timeout
205
-
206
- The timeout for network requests to the OpenAI API in milliseconds.
207
-
208
- Default: `10000` (10 seconds)
209
-
210
- ```sh
211
- aicommit config set timeout=20000 # 20s
212
- ```
213
-
214
- #### max-length
215
-
216
- The maximum character length of the generated commit message.
217
-
218
- Default: `50`
219
-
220
- ```sh
221
- aicommit config set max-length=100
222
- ```
223
-
224
- #### type
225
-
226
- Default: `""` (Empty string)
227
-
228
- The type of commit message to generate. Set this to "conventional" to generate commit messages that follow the
229
- Conventional Commits specification:
230
-
231
- ```sh
232
- aicommit config set type=conventional
233
- ```
234
-
235
- You can clear this option by setting it to an empty string:
236
-
237
- ```sh
238
- aicommit config set type=
239
- ```
240
-
241
- #### auto-confirm
242
-
243
- Default: `false`
244
-
245
- Automatically confirm the generated commit message without prompting the user.
246
-
247
- ```sh
248
- aicommit config set auto-confirm=true
249
- ```
250
-
251
- #### prepend-reference
252
-
253
- Default: `false`
254
-
255
- Prepends issue reference from branch name to commit message.
256
-
257
- branch name: `feature/abc-123-branch-name`
258
-
259
- commit message: `ABC-123: <generated commit message>`
260
-
261
- ```sh
262
- aicommit config set prepend-reference=true
263
- ```
264
-
265
- ## How it works
266
-
267
- This CLI tool runs `git diff` to grab all your latest code changes, sends them to OpenAI's GPT-3, then returns the AI
268
- generated commit message.
269
-
270
- Video coming soon where I rebuild it from scratch to show you how to easily build your own CLI tools powered by AI.
80
+ | Option | Default | Description |
81
+ |---------------------|----------------|-------------------------------------------------------------------------|
82
+ | `OPENAI_KEY` | N/A | The OpenAI API key. |
83
+ | `locale` | `en` | Locale for the generated commit messages. |
84
+ | `generate` | `1` | Number of commit messages to generate. |
85
+ | `model` | `gpt-3.5-turbo`| The Chat Completions model to use. |
86
+ | `timeout` | `10000` ms | Network request timeout to the OpenAI API. |
87
+ | `max-length` | `50` | Maximum character length of the generated commit message. |
88
+ | `type` | `""` | Type of commit message to generate. |
89
+ | `auto-confirm` | `false` | Automatically confirm the generated commit message without user prompt. |
90
+ | `prepend-reference` | `false` | Prepend issue reference from branch name to commit message. |
271
91
 
272
92
  ## Maintainers
273
-
274
- - **Lars Schou**: [@NegoZiatoR](https://github.com/NegoZiatoR) [<img src="https://img.shields.io/twitter/follow/negoziator?style=flat&label=negoziator&logo=twitter&color=0bf&logoColor=fff" align="center">](https://twitter.com/negoziator)
93
+ - **Lars Schou**: <img src="https://img.shields.io/twitter/follow/negoziator?style=flat&label=negoziator&logo=twitter&color=0bf&logoColor=fff" align="center">
275
94
 
276
95
  ## Contributing
277
-
278
96
  If you want to help fix a bug or implement a feature in [Issues](https://github.com/negoziator/ai-commit/issues), checkout
279
97
  the [Contribution Guide](CONTRIBUTING.md) to learn how to setup and test the project.
package/dist/cli.mjs CHANGED
@@ -19,7 +19,7 @@ import fu from"tty";import{Buffer as Vt}from"node:buffer";import W from"node:pat
19
19
  `:"")+(t?this.indentText({text:this.render(t),spaces:e}):"")}
20
20
  `}table({tableData:D,tableOptions:t,tableBreakpoints:e}){return ar(D.map(r=>r.map(o=>this.render(o))),e?Fr(e):t)}flagParameter(D){return D===Boolean?"":D===String?"<string>":D===Number?"<number>":Array.isArray(D)?this.flagParameter(D[0]):"<value>"}flagOperator(D){return" "}flagName(D){const{flag:t,flagFormatted:e,aliasesEnabled:r,aliasFormatted:o}=D;let n="";if(o?n+=`${o}, `:r&&(n+=" "),n+=e,"placeholder"in t&&typeof t.placeholder=="string")n+=`${this.flagOperator(D)}${t.placeholder}`;else{const s=this.flagParameter("type"in t?t.type:t);s&&(n+=`${this.flagOperator(D)}${s}`)}return n}flagDefault(D){return JSON.stringify(D)}flagDescription({flag:D}){let t="description"in D?D.description??"":"";if("default"in D){let{default:e}=D;typeof e=="function"&&(e=e()),e&&(t+=` (default: ${this.flagDefault(e)})`)}return t}render(D){if(typeof D=="string")return D;if(Array.isArray(D))return D.map(t=>this.render(t)).join(`
21
21
  `);if("type"in D&&this[D.type]){const t=this[D.type];if(typeof t=="function")return t.call(this,D.data)}throw new Error(`Invalid node type: ${JSON.stringify(D)}`)}}const Wu=/^[\w.-]+$/,{stringify:_}=JSON,vr=/[|\\{}()[\]^$+*?.]/;function Hu(u){const D=[];let t,e;for(const r of u){if(e)throw new Error(`Invalid parameter: Spread parameter ${_(e)} must be last`);const o=r[0],n=r[r.length-1];let s;if(o==="<"&&n===">"&&(s=!0,t))throw new Error(`Invalid parameter: Required parameter ${_(r)} cannot come after optional parameter ${_(t)}`);if(o==="["&&n==="]"&&(s=!1,t=r),s===void 0)throw new Error(`Invalid parameter: ${_(r)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let i=r.slice(1,-1);const l=i.slice(-3)==="...";l&&(e=r,i=i.slice(0,-3));const F=i.match(vr);if(F)throw new Error(`Invalid parameter: ${_(r)}. Invalid character found ${_(F[0])}`);D.push({name:i,required:s,spread:l})}return D}function qu(u,D,t,e){for(let r=0;r<D.length;r+=1){const{name:o,required:n,spread:s}=D[r],i=Cr(o);if(i in u)throw new Error(`Invalid parameter: ${_(o)} is used more than once.`);const l=s?t.slice(r):t[r];if(s&&(r=D.length),n&&(!l||s&&l.length===0))return console.error(`Error: Missing required parameter ${_(o)}
22
- `),e(),process.exit(1);u[i]=l}}function xr(u){return u===void 0||u!==!1}function me(u,D,t,e){const r={...D.flags},o=D.version;o&&(r.version={type:Boolean,description:"Show version"});const{help:n}=D,s=xr(n);s&&!("help"in r)&&(r.help={type:Boolean,alias:"h",description:"Show help"});const i=On(r,e,{ignore:D.ignoreArgv}),l=()=>{console.log(D.version)};if(o&&i.flags.version===!0)return l(),process.exit(0);const F=new $r,a=s&&n?.render?n.render:f=>F.render(f),c=f=>{const d=yr({...D,...f?{help:f}:{},flags:r});console.log(a(d,F))};if(s&&i.flags.help===!0)return c(),process.exit(0);if(D.parameters){let{parameters:f}=D,d=i._;const p=f.indexOf("--"),h=f.slice(p+1),w=Object.create(null);if(p>-1&&h.length>0){f=f.slice(0,p);const P=i._["--"];d=d.slice(0,-P.length||void 0),qu(w,Hu(f),d,c),qu(w,Hu(h),P,c)}else qu(w,Hu(f),d,c);Object.assign(i._,w)}const C={...i,showVersion:l,showHelp:c};return typeof t=="function"&&t(C),{command:u,...C}}function Sr(u,D){const t=new Map;for(const e of D){const r=[e.options.name],{alias:o}=e.options;o&&(Array.isArray(o)?r.push(...o):r.push(o));for(const n of r){if(t.has(n))throw new Error(`Duplicate command name found: ${_(n)}`);t.set(n,e)}}return t.get(u)}function Or(u,D,t=process.argv.slice(2)){if(!u)throw new Error("Options is required");if("name"in u&&(!u.name||!Wu.test(u.name)))throw new Error(`Invalid script name: ${_(u.name)}`);const e=t[0];if(u.commands&&Wu.test(e)){const r=Sr(e,u.commands);if(r)return me(r.options.name,{...r.options,parent:u},r.callback,t.slice(1))}return me(void 0,u,D,t)}function ge(u,D){if(!u)throw new Error("Command options are required");const{name:t}=u;if(u.name===void 0)throw new Error("Command name is required");if(!Wu.test(t))throw new Error(`Invalid command name ${JSON.stringify(t)}. Command names must be one word.`);return{options:u,callback:D}}var Be="1.2.6",Tr="Writes your git commit messages for you with AI",y=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function j(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u}var q={exports:{}},zu,be;function Ir(){if(be)return zu;be=1,zu=e,e.sync=r;var u=ku;function D(o,n){var s=n.pathExt!==void 0?n.pathExt:process.env.PATHEXT;if(!s||(s=s.split(";"),s.indexOf("")!==-1))return!0;for(var i=0;i<s.length;i++){var l=s[i].toLowerCase();if(l&&o.substr(-l.length).toLowerCase()===l)return!0}return!1}function t(o,n,s){return!o.isSymbolicLink()&&!o.isFile()?!1:D(n,s)}function e(o,n,s){u.stat(o,function(i,l){s(i,i?!1:t(l,o,n))})}function r(o,n){return t(u.statSync(o),o,n)}return zu}var Ku,Ae;function Pr(){if(Ae)return Ku;Ae=1,Ku=D,D.sync=t;var u=ku;function D(o,n,s){u.stat(o,function(i,l){s(i,i?!1:e(l,n))})}function t(o,n){return e(u.statSync(o),n)}function e(o,n){return o.isFile()&&r(o,n)}function r(o,n){var s=o.mode,i=o.uid,l=o.gid,F=n.uid!==void 0?n.uid:process.getuid&&process.getuid(),a=n.gid!==void 0?n.gid:process.getgid&&process.getgid(),c=parseInt("100",8),C=parseInt("010",8),f=parseInt("001",8),d=c|C,p=s&f||s&C&&l===a||s&c&&i===F||s&d&&F===0;return p}return Ku}var gu;process.platform==="win32"||y.TESTING_WINDOWS?gu=Ir():gu=Pr();var _r=Yu;Yu.sync=Rr;function Yu(u,D,t){if(typeof D=="function"&&(t=D,D={}),!t){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(e,r){Yu(u,D||{},function(o,n){o?r(o):e(n)})})}gu(u,D||{},function(e,r){e&&(e.code==="EACCES"||D&&D.ignoreErrors)&&(e=null,r=!1),t(e,r)})}function Rr(u,D){try{return gu.sync(u,D||{})}catch(t){if(D&&D.ignoreErrors||t.code==="EACCES")return!1;throw t}}const z=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",ye=H,kr=z?";":":",we=_r,$e=u=>Object.assign(new Error(`not found: ${u}`),{code:"ENOENT"}),ve=(u,D)=>{const t=D.colon||kr,e=u.match(/\//)||z&&u.match(/\\/)?[""]:[...z?[process.cwd()]:[],...(D.path||process.env.PATH||"").split(t)],r=z?D.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=z?r.split(t):[""];return z&&u.indexOf(".")!==-1&&o[0]!==""&&o.unshift(""),{pathEnv:e,pathExt:o,pathExtExe:r}},xe=(u,D,t)=>{typeof D=="function"&&(t=D,D={}),D||(D={});const{pathEnv:e,pathExt:r,pathExtExe:o}=ve(u,D),n=[],s=l=>new Promise((F,a)=>{if(l===e.length)return D.all&&n.length?F(n):a($e(u));const c=e[l],C=/^".*"$/.test(c)?c.slice(1,-1):c,f=ye.join(C,u),d=!C&&/^\.[\\\/]/.test(u)?u.slice(0,2)+f:f;F(i(d,l,0))}),i=(l,F,a)=>new Promise((c,C)=>{if(a===r.length)return c(s(F+1));const f=r[a];we(l+f,{pathExt:o},(d,p)=>{if(!d&&p)if(D.all)n.push(l+f);else return c(l+f);return c(i(l,F,a+1))})});return t?s(0).then(l=>t(null,l),t):s(0)},Mr=(u,D)=>{D=D||{};const{pathEnv:t,pathExt:e,pathExtExe:r}=ve(u,D),o=[];for(let n=0;n<t.length;n++){const s=t[n],i=/^".*"$/.test(s)?s.slice(1,-1):s,l=ye.join(i,u),F=!i&&/^\.[\\\/]/.test(u)?u.slice(0,2)+l:l;for(let a=0;a<e.length;a++){const c=F+e[a];try{if(we.sync(c,{pathExt:r}))if(D.all)o.push(c);else return c}catch{}}}if(D.all&&o.length)return o;if(D.nothrow)return null;throw $e(u)};var jr=xe;xe.sync=Mr;var Vu={exports:{}};const Se=(u={})=>{const D=u.env||process.env;return(u.platform||process.platform)!=="win32"?"PATH":Object.keys(D).reverse().find(e=>e.toUpperCase()==="PATH")||"Path"};Vu.exports=Se,Vu.exports.default=Se;var Nr=Vu.exports;const Oe=H,Lr=jr,Gr=Nr;function Te(u,D){const t=u.options.env||process.env,e=process.cwd(),r=u.options.cwd!=null,o=r&&process.chdir!==void 0&&!process.chdir.disabled;if(o)try{process.chdir(u.options.cwd)}catch{}let n;try{n=Lr.sync(u.command,{path:t[Gr({env:t})],pathExt:D?Oe.delimiter:void 0})}catch{}finally{o&&process.chdir(e)}return n&&(n=Oe.resolve(r?u.options.cwd:"",n)),n}function Ur(u){return Te(u)||Te(u,!0)}var Wr=Ur,Ju={};const Zu=/([()\][%!^"`<>&|;, *?])/g;function Hr(u){return u=u.replace(Zu,"^$1"),u}function qr(u,D){return u=`${u}`,u=u.replace(/(\\*)"/g,'$1$1\\"'),u=u.replace(/(\\*)$/,"$1$1"),u=`"${u}"`,u=u.replace(Zu,"^$1"),D&&(u=u.replace(Zu,"^$1")),u}Ju.command=Hr,Ju.argument=qr;var zr=/^#!(.*)/;const Kr=zr;var Yr=(u="")=>{const D=u.match(Kr);if(!D)return null;const[t,e]=D[0].replace(/#! ?/,"").split(" "),r=t.split("/").pop();return r==="env"?e:e?`${r} ${e}`:r};const Xu=ku,Vr=Yr;function Jr(u){const t=Buffer.alloc(150);let e;try{e=Xu.openSync(u,"r"),Xu.readSync(e,t,0,150,0),Xu.closeSync(e)}catch{}return Vr(t.toString())}var Zr=Jr;const Xr=H,Ie=Wr,Pe=Ju,Qr=Zr,uo=process.platform==="win32",Do=/\.(?:com|exe)$/i,eo=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function to(u){u.file=Ie(u);const D=u.file&&Qr(u.file);return D?(u.args.unshift(u.file),u.command=D,Ie(u)):u.file}function no(u){if(!uo)return u;const D=to(u),t=!Do.test(D);if(u.options.forceShell||t){const e=eo.test(D);u.command=Xr.normalize(u.command),u.command=Pe.command(u.command),u.args=u.args.map(o=>Pe.argument(o,e));const r=[u.command].concat(u.args).join(" ");u.args=["/d","/s","/c",`"${r}"`],u.command=process.env.comspec||"cmd.exe",u.options.windowsVerbatimArguments=!0}return u}function ro(u,D,t){D&&!Array.isArray(D)&&(t=D,D=null),D=D?D.slice(0):[],t=Object.assign({},t);const e={command:u,args:D,options:t,file:void 0,original:{command:u,args:D}};return t.shell?e:no(e)}var oo=ro;const Qu=process.platform==="win32";function uD(u,D){return Object.assign(new Error(`${D} ${u.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${D} ${u.command}`,path:u.command,spawnargs:u.args})}function so(u,D){if(!Qu)return;const t=u.emit;u.emit=function(e,r){if(e==="exit"){const o=_e(r,D);if(o)return t.call(u,"error",o)}return t.apply(u,arguments)}}function _e(u,D){return Qu&&u===1&&!D.file?uD(D.original,"spawn"):null}function io(u,D){return Qu&&u===1&&!D.file?uD(D.original,"spawnSync"):null}var ao={hookChildProcess:so,verifyENOENT:_e,verifyENOENTSync:io,notFoundError:uD};const Re=Zt,DD=oo,eD=ao;function ke(u,D,t){const e=DD(u,D,t),r=Re.spawn(e.command,e.args,e.options);return eD.hookChildProcess(r,e),r}function co(u,D,t){const e=DD(u,D,t),r=Re.spawnSync(e.command,e.args,e.options);return r.error=r.error||eD.verifyENOENTSync(r.status,e),r}q.exports=ke,q.exports.spawn=ke,q.exports.sync=co,q.exports._parse=DD,q.exports._enoent=eD;var lo=q.exports,Fo=j(lo);function Co(u){const D=typeof u=="string"?`
22
+ `),e(),process.exit(1);u[i]=l}}function xr(u){return u===void 0||u!==!1}function me(u,D,t,e){const r={...D.flags},o=D.version;o&&(r.version={type:Boolean,description:"Show version"});const{help:n}=D,s=xr(n);s&&!("help"in r)&&(r.help={type:Boolean,alias:"h",description:"Show help"});const i=On(r,e,{ignore:D.ignoreArgv}),l=()=>{console.log(D.version)};if(o&&i.flags.version===!0)return l(),process.exit(0);const F=new $r,a=s&&n?.render?n.render:f=>F.render(f),c=f=>{const d=yr({...D,...f?{help:f}:{},flags:r});console.log(a(d,F))};if(s&&i.flags.help===!0)return c(),process.exit(0);if(D.parameters){let{parameters:f}=D,d=i._;const p=f.indexOf("--"),h=f.slice(p+1),w=Object.create(null);if(p>-1&&h.length>0){f=f.slice(0,p);const P=i._["--"];d=d.slice(0,-P.length||void 0),qu(w,Hu(f),d,c),qu(w,Hu(h),P,c)}else qu(w,Hu(f),d,c);Object.assign(i._,w)}const C={...i,showVersion:l,showHelp:c};return typeof t=="function"&&t(C),{command:u,...C}}function Sr(u,D){const t=new Map;for(const e of D){const r=[e.options.name],{alias:o}=e.options;o&&(Array.isArray(o)?r.push(...o):r.push(o));for(const n of r){if(t.has(n))throw new Error(`Duplicate command name found: ${_(n)}`);t.set(n,e)}}return t.get(u)}function Or(u,D,t=process.argv.slice(2)){if(!u)throw new Error("Options is required");if("name"in u&&(!u.name||!Wu.test(u.name)))throw new Error(`Invalid script name: ${_(u.name)}`);const e=t[0];if(u.commands&&Wu.test(e)){const r=Sr(e,u.commands);if(r)return me(r.options.name,{...r.options,parent:u},r.callback,t.slice(1))}return me(void 0,u,D,t)}function ge(u,D){if(!u)throw new Error("Command options are required");const{name:t}=u;if(u.name===void 0)throw new Error("Command name is required");if(!Wu.test(t))throw new Error(`Invalid command name ${JSON.stringify(t)}. Command names must be one word.`);return{options:u,callback:D}}var Be="1.2.7",Tr="Writes your git commit messages for you with AI",y=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function j(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u}var q={exports:{}},zu,be;function Ir(){if(be)return zu;be=1,zu=e,e.sync=r;var u=ku;function D(o,n){var s=n.pathExt!==void 0?n.pathExt:process.env.PATHEXT;if(!s||(s=s.split(";"),s.indexOf("")!==-1))return!0;for(var i=0;i<s.length;i++){var l=s[i].toLowerCase();if(l&&o.substr(-l.length).toLowerCase()===l)return!0}return!1}function t(o,n,s){return!o.isSymbolicLink()&&!o.isFile()?!1:D(n,s)}function e(o,n,s){u.stat(o,function(i,l){s(i,i?!1:t(l,o,n))})}function r(o,n){return t(u.statSync(o),o,n)}return zu}var Ku,Ae;function Pr(){if(Ae)return Ku;Ae=1,Ku=D,D.sync=t;var u=ku;function D(o,n,s){u.stat(o,function(i,l){s(i,i?!1:e(l,n))})}function t(o,n){return e(u.statSync(o),n)}function e(o,n){return o.isFile()&&r(o,n)}function r(o,n){var s=o.mode,i=o.uid,l=o.gid,F=n.uid!==void 0?n.uid:process.getuid&&process.getuid(),a=n.gid!==void 0?n.gid:process.getgid&&process.getgid(),c=parseInt("100",8),C=parseInt("010",8),f=parseInt("001",8),d=c|C,p=s&f||s&C&&l===a||s&c&&i===F||s&d&&F===0;return p}return Ku}var gu;process.platform==="win32"||y.TESTING_WINDOWS?gu=Ir():gu=Pr();var _r=Yu;Yu.sync=Rr;function Yu(u,D,t){if(typeof D=="function"&&(t=D,D={}),!t){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(e,r){Yu(u,D||{},function(o,n){o?r(o):e(n)})})}gu(u,D||{},function(e,r){e&&(e.code==="EACCES"||D&&D.ignoreErrors)&&(e=null,r=!1),t(e,r)})}function Rr(u,D){try{return gu.sync(u,D||{})}catch(t){if(D&&D.ignoreErrors||t.code==="EACCES")return!1;throw t}}const z=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",ye=H,kr=z?";":":",we=_r,$e=u=>Object.assign(new Error(`not found: ${u}`),{code:"ENOENT"}),ve=(u,D)=>{const t=D.colon||kr,e=u.match(/\//)||z&&u.match(/\\/)?[""]:[...z?[process.cwd()]:[],...(D.path||process.env.PATH||"").split(t)],r=z?D.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=z?r.split(t):[""];return z&&u.indexOf(".")!==-1&&o[0]!==""&&o.unshift(""),{pathEnv:e,pathExt:o,pathExtExe:r}},xe=(u,D,t)=>{typeof D=="function"&&(t=D,D={}),D||(D={});const{pathEnv:e,pathExt:r,pathExtExe:o}=ve(u,D),n=[],s=l=>new Promise((F,a)=>{if(l===e.length)return D.all&&n.length?F(n):a($e(u));const c=e[l],C=/^".*"$/.test(c)?c.slice(1,-1):c,f=ye.join(C,u),d=!C&&/^\.[\\\/]/.test(u)?u.slice(0,2)+f:f;F(i(d,l,0))}),i=(l,F,a)=>new Promise((c,C)=>{if(a===r.length)return c(s(F+1));const f=r[a];we(l+f,{pathExt:o},(d,p)=>{if(!d&&p)if(D.all)n.push(l+f);else return c(l+f);return c(i(l,F,a+1))})});return t?s(0).then(l=>t(null,l),t):s(0)},Mr=(u,D)=>{D=D||{};const{pathEnv:t,pathExt:e,pathExtExe:r}=ve(u,D),o=[];for(let n=0;n<t.length;n++){const s=t[n],i=/^".*"$/.test(s)?s.slice(1,-1):s,l=ye.join(i,u),F=!i&&/^\.[\\\/]/.test(u)?u.slice(0,2)+l:l;for(let a=0;a<e.length;a++){const c=F+e[a];try{if(we.sync(c,{pathExt:r}))if(D.all)o.push(c);else return c}catch{}}}if(D.all&&o.length)return o;if(D.nothrow)return null;throw $e(u)};var jr=xe;xe.sync=Mr;var Vu={exports:{}};const Se=(u={})=>{const D=u.env||process.env;return(u.platform||process.platform)!=="win32"?"PATH":Object.keys(D).reverse().find(e=>e.toUpperCase()==="PATH")||"Path"};Vu.exports=Se,Vu.exports.default=Se;var Nr=Vu.exports;const Oe=H,Lr=jr,Gr=Nr;function Te(u,D){const t=u.options.env||process.env,e=process.cwd(),r=u.options.cwd!=null,o=r&&process.chdir!==void 0&&!process.chdir.disabled;if(o)try{process.chdir(u.options.cwd)}catch{}let n;try{n=Lr.sync(u.command,{path:t[Gr({env:t})],pathExt:D?Oe.delimiter:void 0})}catch{}finally{o&&process.chdir(e)}return n&&(n=Oe.resolve(r?u.options.cwd:"",n)),n}function Ur(u){return Te(u)||Te(u,!0)}var Wr=Ur,Ju={};const Zu=/([()\][%!^"`<>&|;, *?])/g;function Hr(u){return u=u.replace(Zu,"^$1"),u}function qr(u,D){return u=`${u}`,u=u.replace(/(\\*)"/g,'$1$1\\"'),u=u.replace(/(\\*)$/,"$1$1"),u=`"${u}"`,u=u.replace(Zu,"^$1"),D&&(u=u.replace(Zu,"^$1")),u}Ju.command=Hr,Ju.argument=qr;var zr=/^#!(.*)/;const Kr=zr;var Yr=(u="")=>{const D=u.match(Kr);if(!D)return null;const[t,e]=D[0].replace(/#! ?/,"").split(" "),r=t.split("/").pop();return r==="env"?e:e?`${r} ${e}`:r};const Xu=ku,Vr=Yr;function Jr(u){const t=Buffer.alloc(150);let e;try{e=Xu.openSync(u,"r"),Xu.readSync(e,t,0,150,0),Xu.closeSync(e)}catch{}return Vr(t.toString())}var Zr=Jr;const Xr=H,Ie=Wr,Pe=Ju,Qr=Zr,uo=process.platform==="win32",Do=/\.(?:com|exe)$/i,eo=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function to(u){u.file=Ie(u);const D=u.file&&Qr(u.file);return D?(u.args.unshift(u.file),u.command=D,Ie(u)):u.file}function no(u){if(!uo)return u;const D=to(u),t=!Do.test(D);if(u.options.forceShell||t){const e=eo.test(D);u.command=Xr.normalize(u.command),u.command=Pe.command(u.command),u.args=u.args.map(o=>Pe.argument(o,e));const r=[u.command].concat(u.args).join(" ");u.args=["/d","/s","/c",`"${r}"`],u.command=process.env.comspec||"cmd.exe",u.options.windowsVerbatimArguments=!0}return u}function ro(u,D,t){D&&!Array.isArray(D)&&(t=D,D=null),D=D?D.slice(0):[],t=Object.assign({},t);const e={command:u,args:D,options:t,file:void 0,original:{command:u,args:D}};return t.shell?e:no(e)}var oo=ro;const Qu=process.platform==="win32";function uD(u,D){return Object.assign(new Error(`${D} ${u.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${D} ${u.command}`,path:u.command,spawnargs:u.args})}function so(u,D){if(!Qu)return;const t=u.emit;u.emit=function(e,r){if(e==="exit"){const o=_e(r,D);if(o)return t.call(u,"error",o)}return t.apply(u,arguments)}}function _e(u,D){return Qu&&u===1&&!D.file?uD(D.original,"spawn"):null}function io(u,D){return Qu&&u===1&&!D.file?uD(D.original,"spawnSync"):null}var ao={hookChildProcess:so,verifyENOENT:_e,verifyENOENTSync:io,notFoundError:uD};const Re=Zt,DD=oo,eD=ao;function ke(u,D,t){const e=DD(u,D,t),r=Re.spawn(e.command,e.args,e.options);return eD.hookChildProcess(r,e),r}function co(u,D,t){const e=DD(u,D,t),r=Re.spawnSync(e.command,e.args,e.options);return r.error=r.error||eD.verifyENOENTSync(r.status,e),r}q.exports=ke,q.exports.spawn=ke,q.exports.sync=co,q.exports._parse=DD,q.exports._enoent=eD;var lo=q.exports,Fo=j(lo);function Co(u){const D=typeof u=="string"?`
23
23
  `:`
24
24
  `.charCodeAt(),t=typeof u=="string"?"\r":"\r".charCodeAt();return u[u.length-1]===D&&(u=u.slice(0,-1)),u[u.length-1]===t&&(u=u.slice(0,-1)),u}function Me(u={}){const{env:D=process.env,platform:t=process.platform}=u;return t!=="win32"?"PATH":Object.keys(D).reverse().find(e=>e.toUpperCase()==="PATH")||"Path"}function fo(u={}){const{cwd:D=A.cwd(),path:t=A.env[Me()],execPath:e=A.execPath}=u;let r;const o=D instanceof URL?Xt.fileURLToPath(D):D;let n=W.resolve(o);const s=[];for(;r!==n;)s.push(W.join(n,"node_modules/.bin")),r=n,n=W.resolve(n,"..");return s.push(W.resolve(o,e,"..")),[...s,t].join(W.delimiter)}function Eo({env:u=A.env,...D}={}){u={...u};const t=Me({env:u});return D.path=u[t],u[t]=fo(D),u}const po=(u,D,t,e)=>{if(t==="length"||t==="prototype"||t==="arguments"||t==="caller")return;const r=Object.getOwnPropertyDescriptor(u,t),o=Object.getOwnPropertyDescriptor(D,t);!ho(r,o)&&e||Object.defineProperty(u,t,o)},ho=function(u,D){return u===void 0||u.configurable||u.writable===D.writable&&u.enumerable===D.enumerable&&u.configurable===D.configurable&&(u.writable||u.value===D.value)},mo=(u,D)=>{const t=Object.getPrototypeOf(D);t!==Object.getPrototypeOf(u)&&Object.setPrototypeOf(u,t)},go=(u,D)=>`/* Wrapped ${u}*/
25
25
  ${D}`,Bo=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),bo=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Ao=(u,D,t)=>{const e=t===""?"":`with ${t.trim()}() `,r=go.bind(null,e,D.toString());Object.defineProperty(r,"name",bo),Object.defineProperty(u,"toString",{...Bo,value:r})};function yo(u,D,{ignoreNonConfigurable:t=!1}={}){const{name:e}=u;for(const r of Reflect.ownKeys(D))po(u,D,r,t);return mo(u,D),Ao(u,D,e),u}const Bu=new WeakMap,je=(u,D={})=>{if(typeof u!="function")throw new TypeError("Expected a function");let t,e=0;const r=u.displayName||u.name||"<anonymous>",o=function(...n){if(Bu.set(o,++e),e===1)t=u.apply(this,n),u=null;else if(D.throw===!0)throw new Error(`Function \`${r}\` can only be called once`);return t};return yo(o,u),Bu.set(o,e),o};je.callCount=u=>{if(!Bu.has(u))throw new Error(`The given function \`${u.name}\` is not wrapped by the \`onetime\` package`);return Bu.get(u)};const wo=()=>{const u=Le-Ne+1;return Array.from({length:u},$o)},$o=(u,D)=>({name:`SIGRT${D+1}`,number:Ne+D,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),Ne=34,Le=64,vo=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}],Ge=()=>{const u=wo();return[...vo,...u].map(xo)},xo=({name:u,number:D,description:t,action:e,forced:r=!1,standard:o})=>{const{signals:{[u]:n}}=YD,s=n!==void 0;return{name:u,number:s?n:D,description:t,supported:s,action:e,forced:r,standard:o}},So=()=>{const u=Ge();return Object.fromEntries(u.map(Oo))},Oo=({name:u,number:D,description:t,supported:e,action:r,forced:o,standard:n})=>[u,{name:u,number:D,description:t,supported:e,action:r,forced:o,standard:n}],To=So(),Io=()=>{const u=Ge(),D=Le+1,t=Array.from({length:D},(e,r)=>Po(r,u));return Object.assign({},...t)},Po=(u,D)=>{const t=_o(u,D);if(t===void 0)return{};const{name:e,description:r,supported:o,action:n,forced:s,standard:i}=t;return{[u]:{name:e,number:u,description:r,supported:o,action:n,forced:s,standard:i}}},_o=(u,D)=>{const t=D.find(({name:e})=>YD.signals[e]===u);return t!==void 0?t:D.find(e=>e.number===u)};Io();const Ro=({timedOut:u,timeout:D,errorCode:t,signal:e,signalDescription:r,exitCode:o,isCanceled:n})=>u?`timed out after ${D} milliseconds`:n?"was canceled":t!==void 0?`failed with ${t}`:e!==void 0?`was killed with ${e} (${r})`:o!==void 0?`failed with exit code ${o}`:"failed",Ue=({stdout:u,stderr:D,all:t,error:e,signal:r,exitCode:o,command:n,escapedCommand:s,timedOut:i,isCanceled:l,killed:F,parsed:{options:{timeout:a,cwd:c=A.cwd()}}})=>{o=o===null?void 0:o,r=r===null?void 0:r;const C=r===void 0?void 0:To[r].description,f=e&&e.code,p=`Command ${Ro({timedOut:i,timeout:a,errorCode:f,signal:r,signalDescription:C,exitCode:o,isCanceled:l})}: ${n}`,h=Object.prototype.toString.call(e)==="[object Error]",w=h?`${p}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@negoziator/ai-commit",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },