@ksw8954/git-ai-commit 1.1.0 → 1.1.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.1 - 2026-01-07
4
+
5
+ ### Bug Fixes
6
+ - Fix zsh completion not working due to fpath added after compinit
7
+ - Fix install-completion to insert fpath before compinit in zshrc
8
+ - Fix uninstall-completion to properly remove fpath line
9
+
3
10
  ## 1.1.0 - 2026-01-06
4
11
 
5
12
  ### New Features
package/Makefile CHANGED
@@ -46,8 +46,27 @@ install-package: ## Install this package globally via npm
46
46
  install-completion: ## Install shell completion for current shell (bash/zsh)
47
47
  @CURRENT_SHELL=$$(basename "$$SHELL"); \
48
48
  if [ "$$CURRENT_SHELL" = "zsh" ]; then \
49
+ COMP_DIR="$$HOME/.zsh/completions"; \
50
+ COMP_FILE="$$COMP_DIR/_git-ai-commit"; \
49
51
  RCFILE="$$HOME/.zshrc"; \
50
- COMPLETION_LINE='eval "$$(git-ai-commit completion zsh)"'; \
52
+ mkdir -p "$$COMP_DIR"; \
53
+ git-ai-commit completion zsh > "$$COMP_FILE"; \
54
+ echo "Completion file created: $$COMP_FILE"; \
55
+ if ! grep -q 'fpath=.*\.zsh/completions' "$$RCFILE" 2>/dev/null; then \
56
+ if grep -q 'autoload.*compinit' "$$RCFILE" 2>/dev/null; then \
57
+ sed -i.bak '/autoload.*compinit/i\
58
+ fpath=(~/.zsh/completions $$fpath) # git-ai-commit completion\
59
+ ' "$$RCFILE" && rm -f "$$RCFILE.bak"; \
60
+ echo "Added fpath before compinit in $$RCFILE"; \
61
+ else \
62
+ echo "" >> "$$RCFILE"; \
63
+ echo "# git-ai-commit shell completion" >> "$$RCFILE"; \
64
+ echo 'fpath=(~/.zsh/completions $$fpath)' >> "$$RCFILE"; \
65
+ echo 'autoload -Uz compinit && compinit' >> "$$RCFILE"; \
66
+ echo "Added fpath and compinit to $$RCFILE"; \
67
+ fi; \
68
+ fi; \
69
+ echo "Restart your shell or run: exec zsh"; \
51
70
  elif [ "$$CURRENT_SHELL" = "bash" ]; then \
52
71
  if [ -f "$$HOME/.bash_profile" ]; then \
53
72
  RCFILE="$$HOME/.bash_profile"; \
@@ -55,39 +74,49 @@ install-completion: ## Install shell completion for current shell (bash/zsh)
55
74
  RCFILE="$$HOME/.bashrc"; \
56
75
  fi; \
57
76
  COMPLETION_LINE='eval "$$(git-ai-commit completion bash)"'; \
77
+ if grep -q "git-ai-commit completion" "$$RCFILE" 2>/dev/null; then \
78
+ echo "Completion already installed in $$RCFILE"; \
79
+ else \
80
+ echo "" >> "$$RCFILE"; \
81
+ echo "# git-ai-commit shell completion" >> "$$RCFILE"; \
82
+ echo "$$COMPLETION_LINE" >> "$$RCFILE"; \
83
+ echo "Completion installed in $$RCFILE"; \
84
+ echo "Run 'source $$RCFILE' or restart your shell to enable"; \
85
+ fi; \
58
86
  else \
59
87
  echo "Unsupported shell: $$CURRENT_SHELL (only bash and zsh are supported)"; \
60
88
  exit 1; \
61
- fi; \
62
- if grep -q "git-ai-commit completion" "$$RCFILE" 2>/dev/null; then \
63
- echo "Completion already installed in $$RCFILE"; \
64
- else \
65
- echo "" >> "$$RCFILE"; \
66
- echo "# git-ai-commit shell completion" >> "$$RCFILE"; \
67
- echo "$$COMPLETION_LINE" >> "$$RCFILE"; \
68
- echo "Completion installed in $$RCFILE"; \
69
- echo "Run 'source $$RCFILE' or restart your shell to enable"; \
70
89
  fi
71
90
 
72
91
  uninstall-completion: ## Remove shell completion from current shell config
73
92
  @CURRENT_SHELL=$$(basename "$$SHELL"); \
74
93
  if [ "$$CURRENT_SHELL" = "zsh" ]; then \
94
+ COMP_FILE="$$HOME/.zsh/completions/_git-ai-commit"; \
75
95
  RCFILE="$$HOME/.zshrc"; \
96
+ if [ -f "$$COMP_FILE" ]; then \
97
+ rm -f "$$COMP_FILE"; \
98
+ echo "Removed $$COMP_FILE"; \
99
+ fi; \
100
+ if grep -q "git-ai-commit completion" "$$RCFILE" 2>/dev/null; then \
101
+ sed -i.bak '/git-ai-commit completion/d' "$$RCFILE"; \
102
+ rm -f "$$RCFILE.bak"; \
103
+ echo "Removed fpath from $$RCFILE"; \
104
+ fi; \
76
105
  elif [ "$$CURRENT_SHELL" = "bash" ]; then \
77
106
  if [ -f "$$HOME/.bash_profile" ]; then \
78
107
  RCFILE="$$HOME/.bash_profile"; \
79
108
  else \
80
109
  RCFILE="$$HOME/.bashrc"; \
81
110
  fi; \
111
+ if grep -q "git-ai-commit completion" "$$RCFILE" 2>/dev/null; then \
112
+ sed -i.bak '/# git-ai-commit shell completion/d' "$$RCFILE"; \
113
+ sed -i.bak '/git-ai-commit completion/d' "$$RCFILE"; \
114
+ rm -f "$$RCFILE.bak"; \
115
+ echo "Completion removed from $$RCFILE"; \
116
+ else \
117
+ echo "No completion found in $$RCFILE"; \
118
+ fi; \
82
119
  else \
83
120
  echo "Unsupported shell: $$CURRENT_SHELL"; \
84
121
  exit 1; \
85
- fi; \
86
- if grep -q "git-ai-commit completion" "$$RCFILE" 2>/dev/null; then \
87
- sed -i.bak '/# git-ai-commit shell completion/d' "$$RCFILE"; \
88
- sed -i.bak '/git-ai-commit completion/d' "$$RCFILE"; \
89
- rm -f "$$RCFILE.bak"; \
90
- echo "Completion removed from $$RCFILE"; \
91
- else \
92
- echo "No completion found in $$RCFILE"; \
93
122
  fi
@@ -1 +1 @@
1
- {"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/commands/completion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,OAAO,CAAU;;IASzB,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,sBAAsB;IAsG9B,OAAO,CAAC,qBAAqB;IAuH7B,UAAU,IAAI,OAAO;CAGtB"}
1
+ {"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/commands/completion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,OAAO,CAAU;;IASzB,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,sBAAsB;IAsG9B,OAAO,CAAC,qBAAqB;IAqH7B,UAAU,IAAI,OAAO;CAGtB"}
@@ -127,20 +127,15 @@ complete -F _git_ai_commit git-ai-commit
127
127
  generateZshCompletion() {
128
128
  return `#compdef git-ai-commit
129
129
  # git-ai-commit zsh completion
130
- # Add to ~/.zshrc:
131
- # eval "$(git-ai-commit completion zsh)"
132
- # Or save to a file in your $fpath (e.g., ~/.zsh/completions/_git-ai-commit)
130
+ # Installation:
131
+ # mkdir -p ~/.zsh/completions
132
+ # git-ai-commit completion zsh > ~/.zsh/completions/_git-ai-commit
133
+ # # Add to ~/.zshrc (before compinit): fpath=(~/.zsh/completions \$fpath)
134
+ # # Then restart shell or run: autoload -Uz compinit && compinit
133
135
 
134
136
  _git-ai-commit() {
135
- local -a commands
136
- commands=(
137
- 'commit:Generate AI-powered commit message'
138
- 'config:Manage git-ai-commit configuration'
139
- 'pr:Generate a pull request title and summary'
140
- 'tag:Create an annotated git tag with AI-generated notes'
141
- 'history:Manage git-ai-commit command history'
142
- 'completion:Generate shell completion scripts'
143
- )
137
+ local curcontext="\$curcontext" state line
138
+ typeset -A opt_args
144
139
 
145
140
  _arguments -C \\
146
141
  '-v[output the version number]' \\
@@ -148,14 +143,23 @@ _git-ai-commit() {
148
143
  '-h[display help]' \\
149
144
  '--help[display help]' \\
150
145
  '1: :->command' \\
151
- '*:: :->args'
146
+ '*:: :->args' && return
152
147
 
153
148
  case \$state in
154
149
  command)
150
+ local -a commands
151
+ commands=(
152
+ 'commit:Generate AI-powered commit message'
153
+ 'config:Manage git-ai-commit configuration'
154
+ 'pr:Generate a pull request title and summary'
155
+ 'tag:Create an annotated git tag with AI-generated notes'
156
+ 'history:Manage git-ai-commit command history'
157
+ 'completion:Generate shell completion scripts'
158
+ )
155
159
  _describe -t commands 'git-ai-commit commands' commands
156
160
  ;;
157
161
  args)
158
- case \$words[1] in
162
+ case \$line[1] in
159
163
  commit)
160
164
  _arguments \\
161
165
  '-k[OpenAI API key]:key:' \\
@@ -188,13 +192,18 @@ _git-ai-commit() {
188
192
  ;;
189
193
  pr)
190
194
  _arguments \\
191
- '--base[Base branch to diff against]:branch:__git_branch_names' \\
192
- '--compare[Compare branch to describe]:branch:__git_branch_names' \\
195
+ '--base[Base branch to diff against]:branch:->branches' \\
196
+ '--compare[Compare branch to describe]:branch:->branches' \\
193
197
  '-k[Override API key]:key:' \\
194
198
  '--api-key[Override API key]:key:' \\
195
199
  '-b[Override API base URL]:url:' \\
196
200
  '--base-url[Override API base URL]:url:' \\
197
201
  '--model[Override AI model]:model:'
202
+ [[ \$state == branches ]] && {
203
+ local -a branches
204
+ branches=(\${(f)"\$(git branch --format='%(refname:short)' 2>/dev/null)"})
205
+ _describe -t branches 'branches' branches
206
+ }
198
207
  ;;
199
208
  tag)
200
209
  _arguments \\
@@ -205,9 +214,14 @@ _git-ai-commit() {
205
214
  '-m[Model to use]:model:' \\
206
215
  '--model[Model to use]:model:' \\
207
216
  '--message[Tag message to use directly]:message:' \\
208
- '-t[Existing tag to diff against]:tag:__git_tags' \\
209
- '--base-tag[Existing tag to diff against]:tag:__git_tags' \\
217
+ '-t[Existing tag to diff against]:tag:->tags' \\
218
+ '--base-tag[Existing tag to diff against]:tag:->tags' \\
210
219
  '--prompt[Additional AI prompt instructions]:text:'
220
+ [[ \$state == tags ]] && {
221
+ local -a tags
222
+ tags=(\${(f)"\$(git tag 2>/dev/null)"})
223
+ _describe -t tags 'tags' tags
224
+ }
211
225
  ;;
212
226
  history)
213
227
  _arguments \\
@@ -224,22 +238,6 @@ _git-ai-commit() {
224
238
  ;;
225
239
  esac
226
240
  }
227
-
228
- # Helper function to complete git branches
229
- __git_branch_names() {
230
- local -a branches
231
- branches=(\${(f)"\$(git branch --format='%(refname:short)' 2>/dev/null)"})
232
- _describe -t branches 'branches' branches
233
- }
234
-
235
- # Helper function to complete git tags
236
- __git_tags() {
237
- local -a tags
238
- tags=(\${(f)"\$(git tag 2>/dev/null)"})
239
- _describe -t tags 'tags' tags
240
- }
241
-
242
- _git-ai-commit "\$@"
243
241
  `;
244
242
  }
245
243
  getCommand() {
@@ -1 +1 @@
1
- {"version":3,"file":"completion.js","sourceRoot":"","sources":["../../src/commands/completion.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AAEpC,MAAa,iBAAiB;IAG5B;QACE,IAAI,CAAC,OAAO,GAAG,IAAI,mBAAO,CAAC,YAAY,CAAC;aACrC,WAAW,CAAC,mCAAmC,CAAC;aAChD,QAAQ,CAAC,SAAS,EAAE,0BAA0B,CAAC;aAC/C,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9C,CAAC;IAEO,gBAAgB,CAAC,KAAa;QACpC,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;QAE9C,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;YAC1B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAAC;QAC7C,CAAC;aAAM,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;YAChC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,sBAAsB,KAAK,EAAE,CAAC,CAAC;YAC7C,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;YAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAEO,sBAAsB;QAC5B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAEO,sBAAsB;QAC5B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkGV,CAAC;IACA,CAAC;IAEO,qBAAqB;QAC3B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiHV,CAAC;IACA,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAtPD,8CAsPC"}
package/package.json CHANGED
@@ -1,21 +1,11 @@
1
1
  {
2
2
  "name": "@ksw8954/git-ai-commit",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "AI-powered git commit message generator",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
7
7
  "git-ai-commit": "./dist/index.js"
8
8
  },
9
- "scripts": {
10
- "build": "tsc",
11
- "dev": "ts-node src/index.ts",
12
- "test": "jest",
13
- "test:file": "jest",
14
- "test:watch": "jest --watch",
15
- "test:coverage": "jest --coverage",
16
- "lint": "eslint src/**/*.ts",
17
- "typecheck": "tsc --noEmit"
18
- },
19
9
  "repository": {
20
10
  "type": "git",
21
11
  "url": "git+https://github.com/onaries/git-ai-commit.git"
@@ -47,5 +37,15 @@
47
37
  "dependencies": {
48
38
  "commander": "^14.0.1",
49
39
  "openai": "^5.20.2"
40
+ },
41
+ "scripts": {
42
+ "build": "tsc",
43
+ "dev": "ts-node src/index.ts",
44
+ "test": "jest",
45
+ "test:file": "jest",
46
+ "test:watch": "jest --watch",
47
+ "test:coverage": "jest --coverage",
48
+ "lint": "eslint src/**/*.ts",
49
+ "typecheck": "tsc --noEmit"
50
50
  }
51
- }
51
+ }
@@ -129,20 +129,15 @@ complete -F _git_ai_commit git-ai-commit
129
129
  private generateZshCompletion(): string {
130
130
  return `#compdef git-ai-commit
131
131
  # git-ai-commit zsh completion
132
- # Add to ~/.zshrc:
133
- # eval "$(git-ai-commit completion zsh)"
134
- # Or save to a file in your $fpath (e.g., ~/.zsh/completions/_git-ai-commit)
132
+ # Installation:
133
+ # mkdir -p ~/.zsh/completions
134
+ # git-ai-commit completion zsh > ~/.zsh/completions/_git-ai-commit
135
+ # # Add to ~/.zshrc (before compinit): fpath=(~/.zsh/completions \$fpath)
136
+ # # Then restart shell or run: autoload -Uz compinit && compinit
135
137
 
136
138
  _git-ai-commit() {
137
- local -a commands
138
- commands=(
139
- 'commit:Generate AI-powered commit message'
140
- 'config:Manage git-ai-commit configuration'
141
- 'pr:Generate a pull request title and summary'
142
- 'tag:Create an annotated git tag with AI-generated notes'
143
- 'history:Manage git-ai-commit command history'
144
- 'completion:Generate shell completion scripts'
145
- )
139
+ local curcontext="\$curcontext" state line
140
+ typeset -A opt_args
146
141
 
147
142
  _arguments -C \\
148
143
  '-v[output the version number]' \\
@@ -150,14 +145,23 @@ _git-ai-commit() {
150
145
  '-h[display help]' \\
151
146
  '--help[display help]' \\
152
147
  '1: :->command' \\
153
- '*:: :->args'
148
+ '*:: :->args' && return
154
149
 
155
150
  case \$state in
156
151
  command)
152
+ local -a commands
153
+ commands=(
154
+ 'commit:Generate AI-powered commit message'
155
+ 'config:Manage git-ai-commit configuration'
156
+ 'pr:Generate a pull request title and summary'
157
+ 'tag:Create an annotated git tag with AI-generated notes'
158
+ 'history:Manage git-ai-commit command history'
159
+ 'completion:Generate shell completion scripts'
160
+ )
157
161
  _describe -t commands 'git-ai-commit commands' commands
158
162
  ;;
159
163
  args)
160
- case \$words[1] in
164
+ case \$line[1] in
161
165
  commit)
162
166
  _arguments \\
163
167
  '-k[OpenAI API key]:key:' \\
@@ -190,13 +194,18 @@ _git-ai-commit() {
190
194
  ;;
191
195
  pr)
192
196
  _arguments \\
193
- '--base[Base branch to diff against]:branch:__git_branch_names' \\
194
- '--compare[Compare branch to describe]:branch:__git_branch_names' \\
197
+ '--base[Base branch to diff against]:branch:->branches' \\
198
+ '--compare[Compare branch to describe]:branch:->branches' \\
195
199
  '-k[Override API key]:key:' \\
196
200
  '--api-key[Override API key]:key:' \\
197
201
  '-b[Override API base URL]:url:' \\
198
202
  '--base-url[Override API base URL]:url:' \\
199
203
  '--model[Override AI model]:model:'
204
+ [[ \$state == branches ]] && {
205
+ local -a branches
206
+ branches=(\${(f)"\$(git branch --format='%(refname:short)' 2>/dev/null)"})
207
+ _describe -t branches 'branches' branches
208
+ }
200
209
  ;;
201
210
  tag)
202
211
  _arguments \\
@@ -207,9 +216,14 @@ _git-ai-commit() {
207
216
  '-m[Model to use]:model:' \\
208
217
  '--model[Model to use]:model:' \\
209
218
  '--message[Tag message to use directly]:message:' \\
210
- '-t[Existing tag to diff against]:tag:__git_tags' \\
211
- '--base-tag[Existing tag to diff against]:tag:__git_tags' \\
219
+ '-t[Existing tag to diff against]:tag:->tags' \\
220
+ '--base-tag[Existing tag to diff against]:tag:->tags' \\
212
221
  '--prompt[Additional AI prompt instructions]:text:'
222
+ [[ \$state == tags ]] && {
223
+ local -a tags
224
+ tags=(\${(f)"\$(git tag 2>/dev/null)"})
225
+ _describe -t tags 'tags' tags
226
+ }
213
227
  ;;
214
228
  history)
215
229
  _arguments \\
@@ -226,22 +240,6 @@ _git-ai-commit() {
226
240
  ;;
227
241
  esac
228
242
  }
229
-
230
- # Helper function to complete git branches
231
- __git_branch_names() {
232
- local -a branches
233
- branches=(\${(f)"\$(git branch --format='%(refname:short)' 2>/dev/null)"})
234
- _describe -t branches 'branches' branches
235
- }
236
-
237
- # Helper function to complete git tags
238
- __git_tags() {
239
- local -a tags
240
- tags=(\${(f)"\$(git tag 2>/dev/null)"})
241
- _describe -t tags 'tags' tags
242
- }
243
-
244
- _git-ai-commit "\$@"
245
243
  `;
246
244
  }
247
245