lazycommitt 1.0.4 → 1.0.5
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/README.md +12 -13
- package/dist/cli.mjs +41 -37
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -97,12 +97,12 @@ lazycommit --exclude package-lock.json --exclude dist/
|
|
|
97
97
|
|
|
98
98
|
#### Handling large diffs
|
|
99
99
|
|
|
100
|
-
For large commits with many files, lazycommit automatically
|
|
100
|
+
For large commits with many files, lazycommit automatically stays within API limits:
|
|
101
101
|
|
|
102
|
-
- **Automatic detection**: Large diffs
|
|
103
|
-
- **
|
|
104
|
-
- **
|
|
105
|
-
- **
|
|
102
|
+
- **Automatic detection**: Large diffs are detected
|
|
103
|
+
- **Per-file splitting**: Diffs are split by file first
|
|
104
|
+
- **Safe chunking**: Each file diff is chunked conservatively (default: 4000 tokens)
|
|
105
|
+
- **Combination**: Results are combined into one concise message
|
|
106
106
|
|
|
107
107
|
### Git hook
|
|
108
108
|
|
|
@@ -215,7 +215,7 @@ lazycommit config set proxy=
|
|
|
215
215
|
|
|
216
216
|
#### model
|
|
217
217
|
|
|
218
|
-
Default: `
|
|
218
|
+
Default: `openai/gpt-oss-120b`
|
|
219
219
|
|
|
220
220
|
#### timeout
|
|
221
221
|
|
|
@@ -255,9 +255,9 @@ lazycommit config set type=
|
|
|
255
255
|
|
|
256
256
|
#### chunk-size
|
|
257
257
|
|
|
258
|
-
Default: `
|
|
258
|
+
Default: `4000`
|
|
259
259
|
|
|
260
|
-
The maximum number of tokens per chunk when processing large diffs. This helps avoid API
|
|
260
|
+
The maximum number of tokens per chunk when processing large diffs. This helps avoid API limits and keeps requests fast:
|
|
261
261
|
|
|
262
262
|
```sh
|
|
263
263
|
lazycommit config set chunk-size 4000
|
|
@@ -275,11 +275,10 @@ The tool uses Groq's fast inference API to provide quick and accurate commit mes
|
|
|
275
275
|
|
|
276
276
|
For large commits that exceed API token limits, lazycommit automatically:
|
|
277
277
|
|
|
278
|
-
1. **
|
|
279
|
-
2. **Chunks
|
|
280
|
-
3. **Processes
|
|
281
|
-
4. **
|
|
282
|
-
5. **Falls back gracefully** if chunking fails, showing individual chunk messages
|
|
278
|
+
1. **Splits by file** to avoid oversized requests
|
|
279
|
+
2. **Chunks each file** into manageable pieces (default: 4000 tokens)
|
|
280
|
+
3. **Processes chunks** and combines results into a single message
|
|
281
|
+
4. **Falls back gracefully** to a high-level summary if needed
|
|
283
282
|
|
|
284
283
|
This ensures you can commit large changes (like new features, refactoring, or initial project setup) without hitting API limits.
|
|
285
284
|
|
package/dist/cli.mjs
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
2
|
+
var we=Object.defineProperty;var c=(e,t)=>we(e,"name",{value:t,configurable:!0});import{command as K,cli as be}from"cleye";import{readFileSync as ke}from"fs";import{fileURLToPath as X,pathToFileURL as $e}from"url";import S,{dirname as ve,join as Pe}from"path";import{execa as v}from"execa";import{dim as z,bgCyan as V,black as L,green as _,red as T}from"kolorist";import{intro as Z,spinner as G,confirm as xe,isCancel as ee,outro as P,select as Ce}from"@clack/prompts";import y from"fs/promises";import Ae from"os";import te from"ini";import se from"groq-sdk";var Me="1.0.5",_e={version:Me};const q=class q extends Error{};c(q,"KnownError");let u=q;const j=" ",I=c(e=>{e instanceof Error&&!(e instanceof u)&&(e.stack&&console.error(z(e.stack.split(`
|
|
3
3
|
`).slice(1).join(`
|
|
4
4
|
`))),console.error(`
|
|
5
|
-
${
|
|
6
|
-
${
|
|
7
|
-
`),diff:n}},"getStagedDiff"),
|
|
8
|
-
`);let
|
|
9
|
-
`,i=
|
|
10
|
-
`,i+=
|
|
11
|
-
`).filter(Boolean),
|
|
5
|
+
${j}${z(`lazycommit v${_e.version}`)}`),console.error(`
|
|
6
|
+
${j}Please open a Bug report with the information above:`),console.error(`${j}https://github.com/KartikLabhshetwar/lazycommit/issues/new/choose`))},"handleCliError"),ne=c(async()=>{const{stdout:e,failed:t}=await v("git",["rev-parse","--show-toplevel"],{reject:!1});if(t)throw new u("The current directory must be a Git repository!");return e},"assertGitRepo"),E=c(e=>`:(exclude)${e}`,"excludeFromDiff"),N=["package-lock.json","pnpm-lock.yaml","node_modules/**","dist/**","build/**",".next/**","coverage/**",".nyc_output/**","*.log","*.tmp","*.temp","*.cache",".DS_Store","Thumbs.db","*.min.js","*.min.css","*.bundle.js","*.bundle.css","*.lock"].map(E),oe=c(async e=>{const t=["diff","--cached","--diff-algorithm=minimal"],{stdout:s}=await v("git",[...t,"--name-only",...N,...e?e.map(E):[]]);if(!s)return;const{stdout:n}=await v("git",[...t,...N,...e?e.map(E):[]]);return{files:s.split(`
|
|
7
|
+
`),diff:n}},"getStagedDiff"),ae=c(e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`,"getDetectedMessage"),D=c(e=>Math.ceil(e.length/4),"estimateTokenCount"),ie=c((e,t=4e3)=>{if(D(e)<=t)return[e];const n=[],o=e.split(`
|
|
8
|
+
`);let a="",i=0;for(const l of o){const f=D(l);i+f>t&&a.length>0?(n.push(a.trim()),a=l+`
|
|
9
|
+
`,i=f):(a+=l+`
|
|
10
|
+
`,i+=f)}return a.trim().length>0&&n.push(a.trim()),n},"chunkDiff"),Te=c(async e=>{const t=["diff","--cached","--diff-algorithm=minimal"],{stdout:s}=await v("git",[...t,"--name-only",...N,...e?e.map(E):[]]);if(!s)return null;const n=s.split(`
|
|
11
|
+
`).filter(Boolean),o=await Promise.all(n.map(async a=>{try{const{stdout:i}=await v("git",[...t,"--numstat","--",a]),[l,f]=i.split(" ").slice(0,2).map(Number);return{file:a,additions:l||0,deletions:f||0,changes:(l||0)+(f||0)}}catch{return{file:a,additions:0,deletions:0,changes:0}}}));return{files:n,fileStats:o,totalChanges:o.reduce((a,i)=>a+i.changes,0)}},"getDiffSummary"),re=c(e=>{const t=[];let s="";const n=e.split(`
|
|
12
|
+
`);for(const o of n)o.startsWith("diff --git ")?(s.trim().length>0&&t.push(s.trim()),s=o+`
|
|
13
|
+
`):s+=o+`
|
|
14
|
+
`;return s.trim().length>0&&t.push(s.trim()),t},"splitDiffByFile"),ce=c(e=>y.lstat(e).then(()=>!0,()=>!1),"fileExists"),Ie=["","conventional"],{hasOwnProperty:Ee}=Object.prototype,le=c((e,t)=>Ee.call(e,t),"hasOwn"),p=c((e,t,s)=>{if(!t)throw new u(`Invalid config property ${e}: ${s}`)},"parseAssert"),F={GROQ_API_KEY(e){if(!e)throw new u("Please set your Groq API key via `lazycommit config set GROQ_API_KEY=<your token>`");return p("GROQ_API_KEY",e.startsWith("gsk_"),'Must start with "gsk_"'),e},locale(e){return e?(p("locale",e,"Cannot be empty"),p("locale",/^[a-z-]+$/i.test(e),"Must be a valid locale (letters and dashes/underscores). You can consult the list of codes in: https://wikipedia.org/wiki/List_of_ISO_639-1_codes"),e):"en"},generate(e){if(!e)return 1;p("generate",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return p("generate",t>0,"Must be greater than 0"),p("generate",t<=5,"Must be less or equal to 5"),t},type(e){return e?(p("type",Ie.includes(e),"Invalid commit type"),e):""},proxy(e){if(!(!e||e.length===0))return p("proxy",/^https?:\/\//.test(e),"Must be a valid URL"),e},model(e){return!e||e.length===0?"openai/gpt-oss-120b":e},timeout(e){if(!e)return 1e4;p("timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return p("timeout",t>=500,"Must be greater than 500ms"),t},"max-length"(e){if(!e)return 50;p("max-length",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return p("max-length",t>=20,"Must be greater than 20 characters"),t},"chunk-size"(e){if(!e)return 4e3;p("chunk-size",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return p("chunk-size",t>=1e3,"Must be at least 1000 tokens"),p("chunk-size",t<=8e3,"Must be at most 8000 tokens (Groq limit)"),t}},Y=S.join(Ae.homedir(),".lazycommit"),me=c(async()=>{if(!await ce(Y))return Object.create(null);const t=await y.readFile(Y,"utf8");return te.parse(t)},"readConfigFile"),U=c(async(e,t)=>{const s=await me(),n={};for(const o of Object.keys(F)){const a=F[o],i=e?.[o]??s[o];if(t)try{n[o]=a(i)}catch{}else n[o]=a(i)}return n},"getConfig"),Fe=c(async e=>{const t=await me();for(const[s,n]of e){if(!le(F,s))throw new u(`Invalid config property: ${s}`);const o=F[s](n);t[s]=o}await y.writeFile(Y,te.stringify(t),"utf8")},"setConfigs"),Oe={"":"<commit message>",conventional:"<type>(<optional scope>): <commit message>"},fe={"":"",conventional:`Choose the most appropriate type from the following categories that best describes the git diff:
|
|
12
15
|
|
|
13
16
|
${JSON.stringify({feat:"A new feature for the user",fix:"A bug fix",docs:"Documentation only changes",style:"Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)",refactor:"A code change that neither fixes a bug nor adds a feature",perf:"A code change that improves performance",test:"Adding missing tests or correcting existing tests",build:"Changes that affect the build system or external dependencies",ci:"Changes to our CI configuration files and scripts",chore:"Other changes that don't modify src or test files",revert:"Reverts a previous commit"},null,2)}
|
|
14
17
|
|
|
15
|
-
IMPORTANT: Use the exact type name from the list above.`},
|
|
18
|
+
IMPORTANT: Use the exact type name from the list above.`},B=c((e,t,s)=>`You are an expert software engineer and git commit message writer. Your task is to analyze git diffs and generate clear, concise, and professional commit messages.
|
|
16
19
|
|
|
17
20
|
## Instructions:
|
|
18
21
|
1. Analyze the provided git diff carefully
|
|
@@ -33,11 +36,11 @@ IMPORTANT: Use the exact type name from the list above.`},ve=c((e,t,s)=>`You are
|
|
|
33
36
|
|
|
34
37
|
## Language: ${e}
|
|
35
38
|
## Maximum length: ${t} characters
|
|
36
|
-
## Output format: ${
|
|
39
|
+
## Output format: ${Oe[s]||"<commit message>"}
|
|
37
40
|
|
|
38
|
-
${
|
|
41
|
+
${fe[s]?`
|
|
39
42
|
## Commit Type Guidelines:
|
|
40
|
-
${
|
|
43
|
+
${fe[s]}`:""}
|
|
41
44
|
|
|
42
45
|
## Examples of good commit messages:
|
|
43
46
|
- "feat: Add user authentication with JWT tokens"
|
|
@@ -54,43 +57,44 @@ ${Z[s]}`:""}
|
|
|
54
57
|
- "WIP"
|
|
55
58
|
- "Stuff"
|
|
56
59
|
|
|
57
|
-
Remember: Your response will be used directly as the git commit message. Make it professional and informative.`,"generatePrompt"),
|
|
60
|
+
Remember: Your response will be used directly as the git commit message. Make it professional and informative.`,"generatePrompt"),H=c(async(e,t,s,n,o,a,i,l,f,d,h)=>{const b=new se({apiKey:e,timeout:d});try{return f>1?{choices:(await Promise.all(Array.from({length:f},()=>b.chat.completions.create({model:t,messages:s,temperature:n,top_p:o,frequency_penalty:a,presence_penalty:i,max_tokens:l,n:1})))).flatMap(m=>m.choices)}:await b.chat.completions.create({model:t,messages:s,temperature:n,top_p:o,frequency_penalty:a,presence_penalty:i,max_tokens:l,n:1})}catch(r){if(r instanceof se.APIError){let g=`Groq API Error: ${r.status} - ${r.name}`;throw r.message&&(g+=`
|
|
58
61
|
|
|
59
|
-
${r.message}`),r.status===500&&(
|
|
62
|
+
${r.message}`),r.status===500&&(g+=`
|
|
60
63
|
|
|
61
|
-
Check the API status: https://console.groq.com/status`),(r.status===413||r.message&&r.message.includes("rate_limit_exceeded"))&&(
|
|
64
|
+
Check the API status: https://console.groq.com/status`),(r.status===413||r.message&&r.message.includes("rate_limit_exceeded"))&&(g+=`
|
|
62
65
|
|
|
63
66
|
\u{1F4A1} Tip: Your diff is too large. Try:
|
|
64
67
|
1. Commit files in smaller batches
|
|
65
68
|
2. Exclude large files with --exclude
|
|
66
69
|
3. Use a different model with --model
|
|
67
|
-
4. Check if you have build artifacts staged (dist/, .next/, etc.)`),new
|
|
68
|
-
Please generate a commit message that describes the changes in this specific part.
|
|
69
|
-
Focus on the most significant changes in this chunk.
|
|
70
|
+
4. Check if you have build artifacts staged (dist/, .next/, etc.)`),new u(g)}throw r.code==="ENOTFOUND"?new u(`Error connecting to ${r.hostname} (${r.syscall}). Are you connected to the internet?`):r}},"createChatCompletion"),O=c(e=>e.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1"),"sanitizeMessage"),Re=c(e=>Array.from(new Set(e)),"deduplicateMessages"),Se=["feat:","fix:","docs:","style:","refactor:","perf:","test:","build:","ci:","chore:","revert:"],ge=c((e,t)=>{const s=e.replace(/\s+/g," ").trim(),n=s.match(/\b(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)\b\s*:?\s+[^.\n]+/i);let o=n?n[0]:s.split(/[.!?]/)[0];const a=o.toLowerCase();for(const i of Se){const l=i.slice(0,-1);if(a.startsWith(l+" ")&&!a.startsWith(i)){o=l+": "+o.slice(l.length+1);break}}return o=O(o),o?(o.length>t&&(o=o.slice(0,t)),o):null},"deriveMessageFromReasoning"),Q=c(async(e,t,s,n,o,a,i,l,f)=>{try{const d=await H(e,t,[{role:"system",content:B(s,a,i)},{role:"user",content:n}],.7,1,0,0,Math.max(200,a*8),o,l,f),h=d.choices.map(r=>r.message?.content||"").map(r=>O(r)).filter(Boolean);if(h.length>0)return Re(h);const b=d.choices.map(r=>r.message?.reasoning||"").filter(Boolean);for(const r of b){const g=ge(r,a);if(g)return[g]}return[]}catch(d){const h=d;throw h.code==="ENOTFOUND"?new u(`Error connecting to ${h.hostname} (${h.syscall}). Are you connected to the internet?`):h}},"generateCommitMessage"),ze=c(async(e,t,s,n,o,a,i,l,f,d=6e3)=>{const b=re(n).flatMap(m=>ie(m,d)),r=b.length>0?b:ie(n,d);if(r.length===1)try{return await Q(e,t,s,n,o,a,i,l,f)}catch(m){throw new u(`Failed to generate commit message: ${m instanceof Error?m.message:"Unknown error"}`)}const g=[];for(let m=0;m<r.length;m++){const w=r[m],k=D(w)+1200;let $=Math.max(200,a*8);k+$>7500&&($=Math.max(200,7500-k));const C=`Analyze this git diff and propose a concise commit message limited to ${a} characters. Focus on the most significant intent of the change.
|
|
70
71
|
|
|
71
|
-
${
|
|
72
|
+
${w}`;try{const x=await H(e,t,[{role:"system",content:B(s,a,i)},{role:"user",content:C}],.7,1,0,0,$,1,l,f),J=(x.choices||[]).map(A=>A.message?.content).filter(Boolean);if(J.length>0)g.push(O(J[0]));else{const A=x.choices.map(M=>M.message?.reasoning||"").filter(Boolean);if(A.length>0){const M=ge(A[0],a);M&&g.push(M)}}}catch(x){console.warn(`Failed to process chunk ${m+1}:`,x instanceof Error?x.message:"Unknown error")}}if(g.length===0){const m=re(n).map(k=>(k.split(`
|
|
73
|
+
`,1)[0]||"").split(" ")[2]?.replace("a/","")||"").filter(Boolean).slice(0,15),w=`Generate a single, concise commit message (<= ${a} chars) summarizing changes across these files:
|
|
74
|
+
${m.map(k=>`- ${k}`).join(`
|
|
75
|
+
`)}`;try{const $=((await H(e,t,[{role:"system",content:B(s,a,i)},{role:"user",content:w}],.7,1,0,0,Math.max(200,a*8),1,l,f)).choices||[]).map(C=>C.message?.content).filter(Boolean);if($.length>0)return[O($[0])]}catch{}throw new u("Failed to generate commit messages for any chunks")}if(g.length>1){const m=`I have ${g.length} commit messages for different parts of a large change:
|
|
72
76
|
|
|
73
|
-
${
|
|
77
|
+
${g.map((w,k)=>`${k+1}. ${w}`).join(`
|
|
74
78
|
`)}
|
|
75
79
|
|
|
76
80
|
Please generate a single, comprehensive commit message that captures the overall changes.
|
|
77
|
-
The message should be concise but cover the main aspects of all the changes.`;try{return await
|
|
78
|
-
${i.files.map(
|
|
81
|
+
The message should be concise but cover the main aspects of all the changes.`;try{return await Q(e,t,s,m,o,a,i,l,f)}catch{return g}}return g},"generateCommitMessageFromChunks");var Ge=c(async(e,t,s,n,o)=>(async()=>{Z(V(L(" lazycommit "))),await ne();const a=G();s&&await v("git",["add","--update"]),a.start("Detecting staged files");const i=await oe(t);if(!i)throw a.stop("Detecting staged files"),new u("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");const l=await Te(t);i.diff.length>5e4&&l?a.stop(`${ae(i.files)} (${l.totalChanges.toLocaleString()} changes):
|
|
82
|
+
${i.files.map(m=>` ${m}`).join(`
|
|
79
83
|
`)}
|
|
80
84
|
|
|
81
|
-
\u26A0\uFE0F Large diff detected - using chunked processing`):
|
|
82
|
-
${i.files.map(
|
|
83
|
-
`)}`);const{env:
|
|
84
|
-
|
|
85
|
-
${
|
|
86
|
-
`});if(!
|
|
87
|
-
`),
|
|
88
|
-
`),
|
|
89
|
-
${
|
|
90
|
-
`)}`):(i&&(
|
|
91
|
-
`),
|
|
92
|
-
${
|
|
93
|
-
`),await y.appendFile(
|
|
85
|
+
\u26A0\uFE0F Large diff detected - using chunked processing`):a.stop(`${ae(i.files)}:
|
|
86
|
+
${i.files.map(m=>` ${m}`).join(`
|
|
87
|
+
`)}`);const{env:d}=process,h=await U({GROQ_API_KEY:d.GROQ_API_KEY,proxy:d.https_proxy||d.HTTPS_PROXY||d.http_proxy||d.HTTP_PROXY,generate:e?.toString(),type:n?.toString()}),b=G();b.start("The AI is analyzing your changes");let r;try{r=await ze(h.GROQ_API_KEY,h.model,h.locale,i.diff,h.generate,h["max-length"],h.type,h.timeout,h.proxy,h["chunk-size"])}finally{b.stop("Changes analyzed")}if(r.length===0)throw new u("No commit messages were generated. Try again.");let g;if(r.length===1){[g]=r;const m=await xe({message:`Use this commit message?
|
|
88
|
+
|
|
89
|
+
${g}
|
|
90
|
+
`});if(!m||ee(m)){P("Commit cancelled");return}}else{const m=await Ce({message:`Pick a commit message to use: ${z("(Ctrl+c to exit)")}`,options:r.map(w=>({label:w,value:w}))});if(ee(m)){P("Commit cancelled");return}g=m}await v("git",["commit","-m",g,...o]),P(`${_("\u2714")} Successfully committed!`)})().catch(a=>{P(`${T("\u2716")} ${a.message}`),I(a),process.exit(1)}),"lazycommit");const[W,je]=process.argv.slice(2);var Ne=c(()=>(async()=>{if(!W)throw new u('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(je)return;const e=await oe();if(!e)return;Z(V(L(" lazycommit ")));const{env:t}=process,s=await U({GROQ_API_KEY:t.GROQ_API_KEY,proxy:t.https_proxy||t.HTTPS_PROXY||t.http_proxy||t.HTTP_PROXY}),n=G();n.start("The AI is analyzing your changes");let o;try{o=await Q(s.GROQ_API_KEY,s.model,s.locale,e.diff,s.generate,s["max-length"],s.type,s.timeout,s.proxy)}finally{n.stop("Changes analyzed")}const i=await y.readFile(W,"utf8")!=="",l=o.length>1;let f="";i&&(f=`# \u{1F916} AI generated commit${l?"s":""}
|
|
91
|
+
`),l?(i&&(f+=`# Select one of the following messages by uncommeting:
|
|
92
|
+
`),f+=`
|
|
93
|
+
${o.map(d=>`# ${d}`).join(`
|
|
94
|
+
`)}`):(i&&(f+=`# Edit the message below and commit:
|
|
95
|
+
`),f+=`
|
|
96
|
+
${o[0]}
|
|
97
|
+
`),await y.appendFile(W,f),P(`${_("\u2714")} Saved commit message!`)})().catch(e=>{P(`${T("\u2716")} ${e.message}`),I(e),process.exit(1)}),"prepareCommitMessageHook"),De=K({name:"config",parameters:["<mode>","<key=value...>"]},e=>{(async()=>{const{mode:t,keyValue:s}=e._;if(t==="get"){const n=await U({},!0);for(const o of s)le(n,o)&&console.log(`${o}=${n[o]}`);return}if(t==="set"){await Fe(s.map(n=>n.split("=")));return}throw new u(`Invalid mode: ${t}`)})().catch(t=>{console.error(`${T("\u2716")} ${t.message}`),I(t),process.exit(1)})});const he="prepare-commit-msg",ue=`.git/hooks/${he}`,R=X(new URL("cli.mjs",import.meta.url)),Ye=process.argv[1].replace(/\\/g,"/").endsWith(`/${ue}`),de=process.platform==="win32",pe=`
|
|
94
98
|
#!/usr/bin/env node
|
|
95
|
-
import(${JSON.stringify(
|
|
96
|
-
`.trim();var
|
|
99
|
+
import(${JSON.stringify($e(R))})
|
|
100
|
+
`.trim();var Ue=K({name:"hook",parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await ne(),{installUninstall:s}=e._,n=S.join(t,ue),o=await ce(n);if(s==="install"){if(o){if(await y.realpath(n).catch(()=>{})===R){console.warn("The hook is already installed");return}throw new u(`A different ${he} hook seems to be installed. Please remove it before installing lazycommit.`)}await y.mkdir(S.dirname(n),{recursive:!0}),de?await y.writeFile(n,pe):(await y.symlink(R,n,"file"),await y.chmod(n,493)),console.log(`${_("\u2714")} Hook installed`);return}if(s==="uninstall"){if(!o){console.warn("Hook is not installed");return}if(de){if(await y.readFile(n,"utf8")!==pe){console.warn("Hook is not installed");return}}else if(await y.realpath(n)!==R){console.warn("Hook is not installed");return}await y.rm(n),console.log(`${_("\u2714")} Hook uninstalled`);return}throw new u(`Invalid mode: ${s}`)})().catch(t=>{console.error(`${T("\u2716")} ${t.message}`),I(t),process.exit(1)})});const Be=X(import.meta.url),He=ve(Be),Qe=JSON.parse(ke(Pe(He,"../package.json"),"utf8")),{description:We,version:qe}=Qe,ye=process.argv.slice(2);be({name:"lazycommit",version:qe,flags:{generate:{type:Number,description:"Number of messages to generate (Warning: generating multiple costs more) (default: 1)",alias:"g"},exclude:{type:[String],description:"Files to exclude from AI analysis",alias:"x"},all:{type:Boolean,description:"Automatically stage changes in tracked files for the commit",alias:"a",default:!1},type:{type:String,description:"Type of commit message to generate",alias:"t"}},commands:[De,Ue],help:{description:We},ignoreArgv:c(e=>e==="unknown-flag"||e==="argument","ignoreArgv")},e=>{Ye?Ne():Ge(e.flags.generate,e.flags.exclude,e.flags.all,e.flags.type,ye)},ye);
|