@aaronshaf/ger 1.2.11 → 2.0.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.
Files changed (180) hide show
  1. package/.ast-grep/rules/no-as-casting.yml +13 -0
  2. package/.claude-plugin/plugin.json +22 -0
  3. package/.github/workflows/ci-simple.yml +53 -0
  4. package/.github/workflows/ci.yml +171 -0
  5. package/.github/workflows/claude-code-review.yml +83 -0
  6. package/.github/workflows/claude.yml +50 -0
  7. package/.github/workflows/dependency-update.yml +84 -0
  8. package/.github/workflows/release.yml +166 -0
  9. package/.github/workflows/security-scan.yml +113 -0
  10. package/.github/workflows/security.yml +96 -0
  11. package/.husky/pre-commit +16 -0
  12. package/.husky/pre-push +25 -0
  13. package/.lintstagedrc.json +6 -0
  14. package/.tool-versions +1 -0
  15. package/CLAUDE.md +105 -0
  16. package/DEVELOPMENT.md +361 -0
  17. package/EXAMPLES.md +457 -0
  18. package/README.md +831 -16
  19. package/bin/ger +3 -18
  20. package/biome.json +36 -0
  21. package/bun.lock +678 -0
  22. package/bunfig.toml +8 -0
  23. package/docs/adr/0001-use-effect-for-side-effects.md +65 -0
  24. package/docs/adr/0002-use-bun-runtime.md +64 -0
  25. package/docs/adr/0003-store-credentials-in-home-directory.md +75 -0
  26. package/docs/adr/0004-use-commander-for-cli.md +76 -0
  27. package/docs/adr/0005-use-effect-schema-for-validation.md +93 -0
  28. package/docs/adr/0006-use-msw-for-api-mocking.md +89 -0
  29. package/docs/adr/0007-git-hooks-for-quality.md +94 -0
  30. package/docs/adr/0008-no-as-typecasting.md +83 -0
  31. package/docs/adr/0009-file-size-limits.md +82 -0
  32. package/docs/adr/0010-llm-friendly-xml-output.md +93 -0
  33. package/docs/adr/0011-ai-tool-strategy-pattern.md +102 -0
  34. package/docs/adr/0012-build-status-message-parsing.md +94 -0
  35. package/docs/adr/0013-git-subprocess-integration.md +98 -0
  36. package/docs/adr/0014-group-management-support.md +95 -0
  37. package/docs/adr/0015-batch-comment-processing.md +111 -0
  38. package/docs/adr/0016-flexible-change-identifiers.md +94 -0
  39. package/docs/adr/0017-git-worktree-support.md +102 -0
  40. package/docs/adr/0018-auto-install-commit-hook.md +103 -0
  41. package/docs/adr/0019-sdk-package-exports.md +95 -0
  42. package/docs/adr/0020-code-coverage-enforcement.md +105 -0
  43. package/docs/adr/0021-typescript-isolated-declarations.md +83 -0
  44. package/docs/adr/0022-biome-oxlint-tooling.md +124 -0
  45. package/docs/adr/README.md +30 -0
  46. package/docs/prd/README.md +12 -0
  47. package/docs/prd/architecture.md +325 -0
  48. package/docs/prd/commands.md +433 -0
  49. package/docs/prd/data-model.md +349 -0
  50. package/docs/prd/overview.md +124 -0
  51. package/index.ts +219 -0
  52. package/oxlint.json +24 -0
  53. package/package.json +82 -15
  54. package/scripts/check-coverage.ts +69 -0
  55. package/scripts/check-file-size.ts +38 -0
  56. package/scripts/fix-test-mocks.ts +55 -0
  57. package/skills/gerrit-workflow/SKILL.md +247 -0
  58. package/skills/gerrit-workflow/examples.md +572 -0
  59. package/skills/gerrit-workflow/reference.md +728 -0
  60. package/src/api/gerrit.ts +696 -0
  61. package/src/cli/commands/abandon.ts +65 -0
  62. package/src/cli/commands/add-reviewer.ts +156 -0
  63. package/src/cli/commands/build-status.ts +282 -0
  64. package/src/cli/commands/checkout.ts +422 -0
  65. package/src/cli/commands/comment.ts +460 -0
  66. package/src/cli/commands/comments.ts +85 -0
  67. package/src/cli/commands/diff.ts +71 -0
  68. package/src/cli/commands/extract-url.ts +266 -0
  69. package/src/cli/commands/groups-members.ts +104 -0
  70. package/src/cli/commands/groups-show.ts +169 -0
  71. package/src/cli/commands/groups.ts +137 -0
  72. package/src/cli/commands/incoming.ts +226 -0
  73. package/src/cli/commands/init.ts +164 -0
  74. package/src/cli/commands/mine.ts +115 -0
  75. package/src/cli/commands/open.ts +57 -0
  76. package/src/cli/commands/projects.ts +68 -0
  77. package/src/cli/commands/push.ts +430 -0
  78. package/src/cli/commands/rebase.ts +71 -0
  79. package/src/cli/commands/remove-reviewer.ts +123 -0
  80. package/src/cli/commands/restore.ts +50 -0
  81. package/src/cli/commands/review.ts +486 -0
  82. package/src/cli/commands/search.ts +162 -0
  83. package/src/cli/commands/setup.ts +286 -0
  84. package/src/cli/commands/show.ts +491 -0
  85. package/src/cli/commands/status.ts +35 -0
  86. package/src/cli/commands/submit.ts +108 -0
  87. package/src/cli/commands/vote.ts +119 -0
  88. package/src/cli/commands/workspace.ts +200 -0
  89. package/src/cli/index.ts +53 -0
  90. package/src/cli/register-commands.ts +659 -0
  91. package/src/cli/register-group-commands.ts +88 -0
  92. package/src/cli/register-reviewer-commands.ts +97 -0
  93. package/src/prompts/default-review.md +86 -0
  94. package/src/prompts/system-inline-review.md +135 -0
  95. package/src/prompts/system-overall-review.md +206 -0
  96. package/src/schemas/config.test.ts +245 -0
  97. package/src/schemas/config.ts +84 -0
  98. package/src/schemas/gerrit.ts +681 -0
  99. package/src/services/commit-hook.ts +314 -0
  100. package/src/services/config.test.ts +150 -0
  101. package/src/services/config.ts +250 -0
  102. package/src/services/git-worktree.ts +342 -0
  103. package/src/services/review-strategy.ts +292 -0
  104. package/src/test-utils/mock-generator.ts +138 -0
  105. package/src/utils/change-id.test.ts +98 -0
  106. package/src/utils/change-id.ts +63 -0
  107. package/src/utils/comment-formatters.ts +153 -0
  108. package/src/utils/diff-context.ts +103 -0
  109. package/src/utils/diff-formatters.ts +141 -0
  110. package/src/utils/formatters.ts +85 -0
  111. package/src/utils/git-commit.test.ts +277 -0
  112. package/src/utils/git-commit.ts +122 -0
  113. package/src/utils/index.ts +55 -0
  114. package/src/utils/message-filters.ts +26 -0
  115. package/src/utils/review-formatters.ts +89 -0
  116. package/src/utils/review-prompt-builder.ts +110 -0
  117. package/src/utils/shell-safety.ts +117 -0
  118. package/src/utils/status-indicators.ts +100 -0
  119. package/src/utils/url-parser.test.ts +271 -0
  120. package/src/utils/url-parser.ts +118 -0
  121. package/tests/abandon.test.ts +230 -0
  122. package/tests/add-reviewer.test.ts +579 -0
  123. package/tests/build-status-watch.test.ts +344 -0
  124. package/tests/build-status.test.ts +789 -0
  125. package/tests/change-id-formats.test.ts +268 -0
  126. package/tests/checkout/integration.test.ts +653 -0
  127. package/tests/checkout/parse-input.test.ts +55 -0
  128. package/tests/checkout/validation.test.ts +178 -0
  129. package/tests/comment-batch-advanced.test.ts +431 -0
  130. package/tests/comment-gerrit-api-compliance.test.ts +414 -0
  131. package/tests/comment.test.ts +708 -0
  132. package/tests/comments.test.ts +323 -0
  133. package/tests/config-service-simple.test.ts +100 -0
  134. package/tests/diff.test.ts +419 -0
  135. package/tests/extract-url.test.ts +517 -0
  136. package/tests/groups-members.test.ts +256 -0
  137. package/tests/groups-show.test.ts +323 -0
  138. package/tests/groups.test.ts +334 -0
  139. package/tests/helpers/build-status-test-setup.ts +83 -0
  140. package/tests/helpers/config-mock.ts +27 -0
  141. package/tests/incoming.test.ts +357 -0
  142. package/tests/init.test.ts +70 -0
  143. package/tests/integration/commit-hook.test.ts +246 -0
  144. package/tests/interactive-incoming.test.ts +173 -0
  145. package/tests/mine.test.ts +285 -0
  146. package/tests/mocks/msw-handlers.ts +80 -0
  147. package/tests/open.test.ts +233 -0
  148. package/tests/projects.test.ts +259 -0
  149. package/tests/rebase.test.ts +368 -0
  150. package/tests/remove-reviewer.test.ts +357 -0
  151. package/tests/restore.test.ts +237 -0
  152. package/tests/review.test.ts +135 -0
  153. package/tests/search.test.ts +712 -0
  154. package/tests/setup.test.ts +63 -0
  155. package/tests/show-auto-detect.test.ts +324 -0
  156. package/tests/show.test.ts +813 -0
  157. package/tests/status.test.ts +145 -0
  158. package/tests/submit.test.ts +316 -0
  159. package/tests/unit/commands/push.test.ts +194 -0
  160. package/tests/unit/git-branch-detection.test.ts +82 -0
  161. package/tests/unit/git-worktree.test.ts +55 -0
  162. package/tests/unit/patterns/push-patterns.test.ts +148 -0
  163. package/tests/unit/schemas/gerrit.test.ts +85 -0
  164. package/tests/unit/services/commit-hook.test.ts +132 -0
  165. package/tests/unit/services/review-strategy.test.ts +349 -0
  166. package/tests/unit/test-utils/mock-generator.test.ts +154 -0
  167. package/tests/unit/utils/comment-formatters.test.ts +415 -0
  168. package/tests/unit/utils/diff-context.test.ts +171 -0
  169. package/tests/unit/utils/diff-formatters.test.ts +165 -0
  170. package/tests/unit/utils/formatters.test.ts +411 -0
  171. package/tests/unit/utils/message-filters.test.ts +227 -0
  172. package/tests/unit/utils/shell-safety.test.ts +230 -0
  173. package/tests/unit/utils/status-indicators.test.ts +137 -0
  174. package/tests/vote.test.ts +317 -0
  175. package/tests/workspace.test.ts +295 -0
  176. package/tsconfig.json +36 -5
  177. package/src/commands/branch.ts +0 -196
  178. package/src/ger.ts +0 -22
  179. package/src/types.d.ts +0 -35
  180. package/src/utils.ts +0 -130
@@ -0,0 +1,433 @@
1
+ # Commands
2
+
3
+ Complete specification of all CLI commands.
4
+
5
+ ## Change Viewing
6
+
7
+ ### show
8
+
9
+ Display comprehensive change information.
10
+
11
+ ```bash
12
+ ger show [change-id]
13
+ ger show 12345
14
+ ger show If5a3ae8... # Change-ID format
15
+ ger show # Auto-detect from HEAD
16
+ ```
17
+
18
+ | Option | Description |
19
+ |--------|-------------|
20
+ | `--xml` | Output as XML for LLM consumption |
21
+ | `--no-diff` | Skip diff output |
22
+ | `--no-comments` | Skip comments |
23
+
24
+ **Output includes:**
25
+ - Change metadata (number, project, branch, status)
26
+ - Owner and reviewer information
27
+ - Submit requirements
28
+ - Full diff
29
+ - All comments with context
30
+
31
+ ### diff
32
+
33
+ Get change diff in various formats.
34
+
35
+ ```bash
36
+ ger diff <change-id>
37
+ ger diff 12345 --files-only
38
+ ger diff 12345 --base 1 # Diff against patchset 1
39
+ ```
40
+
41
+ | Option | Description |
42
+ |--------|-------------|
43
+ | `--xml` | Output as XML |
44
+ | `--files-only` | List only changed files |
45
+ | `--base <ps>` | Diff against specific patchset |
46
+
47
+ ### comments
48
+
49
+ View all comments on a change with diff context.
50
+
51
+ ```bash
52
+ ger comments <change-id>
53
+ ger comments 12345 --xml
54
+ ```
55
+
56
+ | Option | Description |
57
+ |--------|-------------|
58
+ | `--xml` | Output as XML |
59
+ | `--context <n>` | Lines of context (default: 3) |
60
+
61
+ ### search
62
+
63
+ Query changes with Gerrit syntax.
64
+
65
+ ```bash
66
+ ger search "owner:self status:open"
67
+ ger search "project:canvas-lms branch:main"
68
+ ```
69
+
70
+ | Option | Description |
71
+ |--------|-------------|
72
+ | `--xml` | Output as XML |
73
+ | `--limit <n>` | Max results (default: 25) |
74
+
75
+ ## Change Management
76
+
77
+ ### mine
78
+
79
+ List user's open changes.
80
+
81
+ ```bash
82
+ ger mine
83
+ ger mine --xml
84
+ ```
85
+
86
+ **Output:** Changes grouped by project with status indicators.
87
+
88
+ ### incoming
89
+
90
+ View changes needing your review.
91
+
92
+ ```bash
93
+ ger incoming
94
+ ger incoming --xml
95
+ ```
96
+
97
+ **Output:** Changes where you're a reviewer, grouped by project.
98
+
99
+ ### abandon
100
+
101
+ Abandon a change.
102
+
103
+ ```bash
104
+ ger abandon <change-id>
105
+ ger abandon <change-id> -m "No longer needed"
106
+ ger abandon # Interactive selection
107
+ ```
108
+
109
+ | Option | Description |
110
+ |--------|-------------|
111
+ | `-m <message>` | Abandon reason |
112
+
113
+ ### restore
114
+
115
+ Restore an abandoned change.
116
+
117
+ ```bash
118
+ ger restore <change-id>
119
+ ger restore <change-id> -m "Needed after all"
120
+ ```
121
+
122
+ ### workspace
123
+
124
+ View local git branch tracking information.
125
+
126
+ ```bash
127
+ ger workspace
128
+ ```
129
+
130
+ **Output:** Current branch and associated Gerrit change.
131
+
132
+ ## Code Review
133
+
134
+ ### comment
135
+
136
+ Post comments (overall or inline).
137
+
138
+ ```bash
139
+ # Overall comment
140
+ ger comment <change-id> -m "LGTM"
141
+
142
+ # Inline comments via JSON
143
+ echo '[{"file":"src/index.ts","line":42,"message":"Consider null check"}]' | ger comment 12345
144
+
145
+ # From file
146
+ cat comments.json | ger comment 12345
147
+ ```
148
+
149
+ | Option | Description |
150
+ |--------|-------------|
151
+ | `-m <message>` | Overall comment message |
152
+ | `--unresolved` | Mark inline comments as unresolved |
153
+
154
+ **JSON schema for inline comments:**
155
+ ```json
156
+ [{
157
+ "file": "path/to/file.ts",
158
+ "line": 42,
159
+ "message": "Comment text",
160
+ "range": {
161
+ "start_line": 40,
162
+ "end_line": 45,
163
+ "start_character": 0,
164
+ "end_character": 80
165
+ },
166
+ "side": "REVISION",
167
+ "unresolved": true
168
+ }]
169
+ ```
170
+
171
+ ### vote
172
+
173
+ Cast review votes.
174
+
175
+ ```bash
176
+ ger vote <change-id> --code-review +1
177
+ ger vote <change-id> --code-review +2 --verified +1
178
+ ger vote <change-id> --label "Custom-Label" +1
179
+ ```
180
+
181
+ | Option | Description |
182
+ |--------|-------------|
183
+ | `--code-review <score>` | Code-Review vote (-2 to +2) |
184
+ | `--verified <score>` | Verified vote (-1 to +1) |
185
+ | `--label <name> <score>` | Custom label vote |
186
+ | `-m <message>` | Optional message with vote |
187
+
188
+ ### review
189
+
190
+ AI-powered code review (multi-stage).
191
+
192
+ ```bash
193
+ ger review <change-id>
194
+ ger review <change-id> --tool claude # Specific AI tool
195
+ ger review # Auto-detect change from HEAD
196
+ ```
197
+
198
+ | Option | Description |
199
+ |--------|-------------|
200
+ | `--tool <name>` | AI tool (claude, llm, opencode, gemini) |
201
+ | `--inline-only` | Only post inline comments |
202
+ | `--overall-only` | Only post overall review |
203
+
204
+ **Stages:**
205
+ 1. **Inline**: Generate line-specific comments
206
+ 2. **Overall**: Generate high-level assessment
207
+
208
+ ### add-reviewer
209
+
210
+ Add reviewers or groups to a change.
211
+
212
+ ```bash
213
+ ger add-reviewer <change-id> <user1> <user2>
214
+ ger add-reviewer <change-id> --group frontend-team
215
+ ger add-reviewer <change-id> user@example.com --cc
216
+ ```
217
+
218
+ | Option | Description |
219
+ |--------|-------------|
220
+ | `--group <name>` | Add group as reviewer |
221
+ | `--cc` | Add as CC instead of reviewer |
222
+
223
+ ### remove-reviewer
224
+
225
+ Remove reviewers from a change.
226
+
227
+ ```bash
228
+ ger remove-reviewer user@example.com -c 12345
229
+ ger remove-reviewer user1@example.com user2@example.com -c 12345
230
+ ger remove-reviewer johndoe -c 12345 --notify none
231
+ ```
232
+
233
+ Supports email addresses, usernames, or account IDs as reviewer identifiers.
234
+
235
+ | Option | Description |
236
+ |--------|-------------|
237
+ | `-c, --change <id>` | Change ID (required) |
238
+ | `--notify <level>` | Notification level (none, owner, owner_reviewers, all) |
239
+ | `--xml` | Output as XML |
240
+
241
+ ## Git Operations
242
+
243
+ ### checkout
244
+
245
+ Checkout a change locally.
246
+
247
+ ```bash
248
+ ger checkout <change-id>
249
+ ger checkout <change-id> --patchset 3
250
+ ger checkout https://gerrit.example.com/c/project/+/12345
251
+ ```
252
+
253
+ | Option | Description |
254
+ |--------|-------------|
255
+ | `--patchset <n>` | Specific patchset |
256
+ | `--branch <name>` | Custom branch name |
257
+
258
+ **Creates:** `review/12345` branch by default.
259
+
260
+ ### push
261
+
262
+ Push changes for review.
263
+
264
+ ```bash
265
+ ger push
266
+ ger push --reviewers alice bob
267
+ ger push --topic "feature-x"
268
+ ger push --wip
269
+ ```
270
+
271
+ | Option | Description |
272
+ |--------|-------------|
273
+ | `--reviewers <users>` | Add reviewers |
274
+ | `--topic <name>` | Set topic |
275
+ | `--wip` | Push as work-in-progress |
276
+ | `--ready` | Mark ready for review |
277
+ | `--private` | Push as private |
278
+
279
+ **Auto-installs:** Gerrit commit-msg hook if missing.
280
+
281
+ ### rebase
282
+
283
+ Rebase a change on target branch.
284
+
285
+ ```bash
286
+ ger rebase [change-id]
287
+ ger rebase 12345
288
+ ger rebase If5a3ae8... # Change-ID format
289
+ ger rebase # Auto-detect from HEAD
290
+ ger rebase --base <ref> # Rebase onto specific ref
291
+ ```
292
+
293
+ | Option | Description |
294
+ |--------|-------------|
295
+ | `--base <ref>` | Base revision to rebase onto |
296
+ | `--xml` | Output as XML for LLM consumption |
297
+
298
+ ### submit
299
+
300
+ Submit a change for merge.
301
+
302
+ ```bash
303
+ ger submit <change-id>
304
+ ```
305
+
306
+ **Validates:** All submit requirements met.
307
+
308
+ ## Group Management
309
+
310
+ ### groups
311
+
312
+ List Gerrit groups.
313
+
314
+ ```bash
315
+ ger groups
316
+ ger groups --pattern "team-*"
317
+ ger groups --owned
318
+ ger groups --project canvas-lms
319
+ ger groups --user john.doe
320
+ ```
321
+
322
+ | Option | Description |
323
+ |--------|-------------|
324
+ | `--pattern <glob>` | Filter by name |
325
+ | `--owned` | Only groups you own |
326
+ | `--project <name>` | Groups with project access |
327
+ | `--user <name>` | Groups containing user |
328
+ | `--xml` | Output as XML |
329
+
330
+ ### groups-show
331
+
332
+ Display group details.
333
+
334
+ ```bash
335
+ ger groups-show <group-id>
336
+ ger groups-show frontend-team
337
+ ```
338
+
339
+ **Output:** Name, description, owner, members, options.
340
+
341
+ ### groups-members
342
+
343
+ List group members.
344
+
345
+ ```bash
346
+ ger groups-members <group-id>
347
+ ger groups-members frontend-team --xml
348
+ ```
349
+
350
+ ## Utilities
351
+
352
+ ### status
353
+
354
+ Check connection and authentication.
355
+
356
+ ```bash
357
+ ger status
358
+ ```
359
+
360
+ **Verifies:** API connectivity, credentials valid.
361
+
362
+ ### setup / init
363
+
364
+ Configure credentials interactively.
365
+
366
+ ```bash
367
+ ger setup
368
+ ger init # Alias
369
+ ```
370
+
371
+ **Creates:** `~/.ger/config.json` with secure permissions.
372
+
373
+ ### open
374
+
375
+ Open change in browser.
376
+
377
+ ```bash
378
+ ger open <change-id>
379
+ ger open # Auto-detect from HEAD
380
+ ```
381
+
382
+ ### extract-url
383
+
384
+ Extract URLs from change messages.
385
+
386
+ ```bash
387
+ ger extract-url <change-id>
388
+ ger extract-url <change-id> --pattern "jenkins"
389
+ ger extract-url <change-id> --include-comments
390
+ ```
391
+
392
+ | Option | Description |
393
+ |--------|-------------|
394
+ | `--pattern <regex>` | Filter URLs |
395
+ | `--include-comments` | Include comment URLs |
396
+ | `--json` | Output as JSON |
397
+
398
+ **Use case:** Get Jenkins build URL for `jk` integration.
399
+
400
+ ### build-status
401
+
402
+ Check CI build status.
403
+
404
+ ```bash
405
+ ger build-status <change-id>
406
+ ger build-status <change-id> --watch
407
+ ger build-status <change-id> --watch --interval 30 --timeout 1800
408
+ ```
409
+
410
+ | Option | Description |
411
+ |--------|-------------|
412
+ | `--watch` | Poll until terminal state |
413
+ | `--interval <sec>` | Poll interval (default: 30) |
414
+ | `--timeout <sec>` | Max wait time |
415
+ | `--exit-status` | Exit 1 on failure |
416
+
417
+ **States:** `pending`, `running`, `success`, `failure`, `not_found`
418
+
419
+ **Exit codes:**
420
+ - 0: Completed (any state)
421
+ - 1: Failure (with `--exit-status`)
422
+ - 2: Timeout
423
+ - 3: API error
424
+
425
+ ## Global Options
426
+
427
+ Available on most commands:
428
+
429
+ | Option | Description |
430
+ |--------|-------------|
431
+ | `--xml` | Output as XML for LLM consumption |
432
+ | `--help` | Show command help |
433
+ | `--version` | Show version |