@aaronshaf/ger 0.1.0
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/.ast-grep/rules/no-as-casting.yml +13 -0
- package/.eslintrc.js +12 -0
- package/.github/workflows/ci-simple.yml +53 -0
- package/.github/workflows/ci.yml +171 -0
- package/.github/workflows/claude-code-review.yml +78 -0
- package/.github/workflows/claude.yml +64 -0
- package/.github/workflows/dependency-update.yml +84 -0
- package/.github/workflows/release.yml +166 -0
- package/.github/workflows/security-scan.yml +113 -0
- package/.github/workflows/security.yml +96 -0
- package/.husky/pre-commit +16 -0
- package/.husky/pre-push +25 -0
- package/.lintstagedrc.json +6 -0
- package/.tool-versions +1 -0
- package/CLAUDE.md +103 -0
- package/DEVELOPMENT.md +361 -0
- package/LICENSE +21 -0
- package/README.md +325 -0
- package/bin/ger +3 -0
- package/biome.json +36 -0
- package/bun.lock +688 -0
- package/bunfig.toml +8 -0
- package/oxlint.json +24 -0
- package/package.json +55 -0
- package/scripts/check-coverage.ts +69 -0
- package/scripts/check-file-size.ts +38 -0
- package/scripts/fix-test-mocks.ts +55 -0
- package/src/api/gerrit.ts +466 -0
- package/src/cli/commands/abandon.ts +65 -0
- package/src/cli/commands/comment.ts +460 -0
- package/src/cli/commands/comments.ts +85 -0
- package/src/cli/commands/diff.ts +71 -0
- package/src/cli/commands/incoming.ts +226 -0
- package/src/cli/commands/init.ts +164 -0
- package/src/cli/commands/mine.ts +115 -0
- package/src/cli/commands/open.ts +57 -0
- package/src/cli/commands/review.ts +593 -0
- package/src/cli/commands/setup.ts +230 -0
- package/src/cli/commands/show.ts +303 -0
- package/src/cli/commands/status.ts +35 -0
- package/src/cli/commands/workspace.ts +200 -0
- package/src/cli/index.ts +420 -0
- package/src/prompts/default-review.md +80 -0
- package/src/prompts/system-inline-review.md +88 -0
- package/src/prompts/system-overall-review.md +152 -0
- package/src/schemas/config.test.ts +245 -0
- package/src/schemas/config.ts +75 -0
- package/src/schemas/gerrit.ts +455 -0
- package/src/services/ai-enhanced.ts +167 -0
- package/src/services/ai.ts +182 -0
- package/src/services/config.test.ts +414 -0
- package/src/services/config.ts +206 -0
- package/src/test-utils/mock-generator.ts +73 -0
- package/src/utils/comment-formatters.ts +153 -0
- package/src/utils/diff-context.ts +103 -0
- package/src/utils/diff-formatters.ts +141 -0
- package/src/utils/formatters.ts +85 -0
- package/src/utils/message-filters.ts +26 -0
- package/src/utils/shell-safety.ts +117 -0
- package/src/utils/status-indicators.ts +100 -0
- package/src/utils/url-parser.test.ts +123 -0
- package/src/utils/url-parser.ts +91 -0
- package/tests/abandon.test.ts +163 -0
- package/tests/ai-service.test.ts +489 -0
- package/tests/comment-batch-advanced.test.ts +431 -0
- package/tests/comment-gerrit-api-compliance.test.ts +414 -0
- package/tests/comment.test.ts +707 -0
- package/tests/comments.test.ts +323 -0
- package/tests/config-service-simple.test.ts +100 -0
- package/tests/diff.test.ts +419 -0
- package/tests/helpers/config-mock.ts +27 -0
- package/tests/incoming.test.ts +357 -0
- package/tests/interactive-incoming.test.ts +173 -0
- package/tests/mine.test.ts +318 -0
- package/tests/mocks/fetch-mock.ts +139 -0
- package/tests/mocks/msw-handlers.ts +80 -0
- package/tests/open.test.ts +233 -0
- package/tests/review.test.ts +669 -0
- package/tests/setup.ts +13 -0
- package/tests/show.test.ts +439 -0
- package/tests/unit/schemas/gerrit.test.ts +85 -0
- package/tests/unit/test-utils/mock-generator.test.ts +154 -0
- package/tests/unit/utils/comment-formatters.test.ts +415 -0
- package/tests/unit/utils/diff-context.test.ts +171 -0
- package/tests/unit/utils/diff-formatters.test.ts +165 -0
- package/tests/unit/utils/formatters.test.ts +411 -0
- package/tests/unit/utils/message-filters.test.ts +227 -0
- package/tests/unit/utils/prompt-helpers.test.ts +175 -0
- package/tests/unit/utils/shell-safety.test.ts +230 -0
- package/tests/unit/utils/status-indicators.test.ts +137 -0
- package/tsconfig.json +40 -0
package/DEVELOPMENT.md
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
# Development Guide
|
|
2
|
+
|
|
3
|
+
This document contains information for developers working on the Gerrit CLI project.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- **Bun 1.0+** - Primary runtime and package manager
|
|
8
|
+
- **Node.js 18+** - For tooling compatibility
|
|
9
|
+
- **Git** - Version control
|
|
10
|
+
|
|
11
|
+
## Getting Started
|
|
12
|
+
|
|
13
|
+
### Initial Setup
|
|
14
|
+
```bash
|
|
15
|
+
git clone https://github.com/your-org/gerrit-cli
|
|
16
|
+
cd gerrit-cli
|
|
17
|
+
bun install
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Development Commands
|
|
21
|
+
```bash
|
|
22
|
+
# Development
|
|
23
|
+
bun run dev # Run CLI in development mode
|
|
24
|
+
bun run dev --help # Show CLI help
|
|
25
|
+
bun run build # Build for production
|
|
26
|
+
|
|
27
|
+
# Testing
|
|
28
|
+
bun test # Run all tests
|
|
29
|
+
bun run test:coverage # Run tests with coverage report
|
|
30
|
+
bun test tests/unit/ # Run only unit tests
|
|
31
|
+
bun test tests/integration/ # Run only integration tests
|
|
32
|
+
|
|
33
|
+
# Code Quality
|
|
34
|
+
bun run typecheck # TypeScript type checking
|
|
35
|
+
bun run lint # Run oxlint
|
|
36
|
+
bun run format # Format code with Biome
|
|
37
|
+
bun run format:check # Check code formatting
|
|
38
|
+
bun run check:all # Run all checks (typecheck, lint, format, test)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Architecture
|
|
42
|
+
|
|
43
|
+
The project follows a clean, functional architecture using Effect:
|
|
44
|
+
|
|
45
|
+
### Directory Structure
|
|
46
|
+
```
|
|
47
|
+
src/
|
|
48
|
+
├── cli/ # Ink components and command definitions
|
|
49
|
+
│ ├── commands/ # Individual command implementations
|
|
50
|
+
│ └── index.ts # Main CLI entry point
|
|
51
|
+
├── services/ # Effect services
|
|
52
|
+
│ └── config.ts # Configuration management
|
|
53
|
+
├── api/ # Gerrit REST API client
|
|
54
|
+
│ └── gerrit.ts # API service implementation
|
|
55
|
+
├── db/ # SQLite caching layer
|
|
56
|
+
│ ├── database.ts # Database service
|
|
57
|
+
│ └── schema.ts # SQL schema definitions
|
|
58
|
+
├── schemas/ # Effect Schema definitions
|
|
59
|
+
│ └── gerrit.ts # Type-safe data models
|
|
60
|
+
├── i18n/ # Internationalization (future)
|
|
61
|
+
└── utils/ # Shared utilities
|
|
62
|
+
|
|
63
|
+
tests/
|
|
64
|
+
├── unit/ # Unit tests
|
|
65
|
+
├── integration/ # Integration tests
|
|
66
|
+
├── mocks/ # MSW mock handlers
|
|
67
|
+
└── setup.ts # Test setup and configuration
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Key Technologies
|
|
71
|
+
|
|
72
|
+
- **Effect** - Functional effect system for managing side effects
|
|
73
|
+
- **Effect Schema** - Type-safe data validation and transformation
|
|
74
|
+
- **Ink** - React for CLIs, providing interactive terminal UI
|
|
75
|
+
- **Bun SQLite** - Built-in SQLite support for caching
|
|
76
|
+
- **MSW** - Mock Service Worker for API testing
|
|
77
|
+
- **Commander.js** - CLI argument parsing
|
|
78
|
+
|
|
79
|
+
### Design Principles
|
|
80
|
+
|
|
81
|
+
1. **Functional Programming** - Use Effect for all side effects
|
|
82
|
+
2. **Type Safety** - Leverage TypeScript with strict settings
|
|
83
|
+
3. **Local-First** - Cache everything, work offline when possible
|
|
84
|
+
4. **Error Handling** - Comprehensive error types and handling
|
|
85
|
+
5. **Testing** - High test coverage with shared schemas
|
|
86
|
+
|
|
87
|
+
## Code Quality Standards
|
|
88
|
+
|
|
89
|
+
### TypeScript Configuration
|
|
90
|
+
- `isolatedDeclarations: true` - Explicit type exports
|
|
91
|
+
- `noImplicitAny: true` - No implicit any types
|
|
92
|
+
- `strictNullChecks: true` - Strict null checking
|
|
93
|
+
- Only `.ts` files allowed (no `.js/.jsx/.tsx`)
|
|
94
|
+
|
|
95
|
+
### Linting & Formatting
|
|
96
|
+
- **oxlint** - Fast, strict linting
|
|
97
|
+
- **Biome** - Consistent code formatting
|
|
98
|
+
- **ast-grep** - Pattern-based code rules
|
|
99
|
+
|
|
100
|
+
### File Size Limits
|
|
101
|
+
- **Warning** at 500 lines
|
|
102
|
+
- **Error** at 700 lines
|
|
103
|
+
- Enforced in pre-commit hooks
|
|
104
|
+
|
|
105
|
+
### Banned Patterns
|
|
106
|
+
- `as` type casting (except `as const` and `as unknown`)
|
|
107
|
+
- `--no-verify` flag usage
|
|
108
|
+
- Implicit any types
|
|
109
|
+
- console.log in production code
|
|
110
|
+
|
|
111
|
+
## Testing Strategy
|
|
112
|
+
|
|
113
|
+
### Test Types
|
|
114
|
+
1. **Unit Tests** - Pure functions, schemas, utilities
|
|
115
|
+
2. **Integration Tests** - API clients with MSW mocks
|
|
116
|
+
3. **Component Tests** - CLI command behavior
|
|
117
|
+
|
|
118
|
+
### Shared Schemas
|
|
119
|
+
Test mocks use the same Effect Schemas as production code, ensuring type safety and consistency.
|
|
120
|
+
|
|
121
|
+
### Coverage Requirements
|
|
122
|
+
- **Minimum 80%** line coverage
|
|
123
|
+
- **Minimum 80%** function coverage
|
|
124
|
+
- **Minimum 80%** branch coverage
|
|
125
|
+
- **Minimum 80%** statement coverage
|
|
126
|
+
|
|
127
|
+
### Running Tests
|
|
128
|
+
```bash
|
|
129
|
+
# All tests
|
|
130
|
+
bun test
|
|
131
|
+
|
|
132
|
+
# Watch mode
|
|
133
|
+
bun test --watch
|
|
134
|
+
|
|
135
|
+
# Specific test file
|
|
136
|
+
bun test tests/unit/schemas/gerrit.test.ts
|
|
137
|
+
|
|
138
|
+
# Coverage report
|
|
139
|
+
bun run test:coverage
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Git Workflow
|
|
143
|
+
|
|
144
|
+
### Branch Strategy
|
|
145
|
+
- `main` branch for stable releases
|
|
146
|
+
- Feature branches: `feat/feature-name`
|
|
147
|
+
- Bug fixes: `fix/bug-description`
|
|
148
|
+
- Use conventional commit messages
|
|
149
|
+
|
|
150
|
+
### Pre-commit Hooks
|
|
151
|
+
Automatically run on every commit:
|
|
152
|
+
- TypeScript type checking
|
|
153
|
+
- Code linting (oxlint)
|
|
154
|
+
- Code formatting check (Biome)
|
|
155
|
+
- File size validation
|
|
156
|
+
- ast-grep pattern checks
|
|
157
|
+
- Tests for changed files
|
|
158
|
+
|
|
159
|
+
### Pre-push Hooks
|
|
160
|
+
Run before pushing to remote:
|
|
161
|
+
- Full test suite
|
|
162
|
+
- Code coverage validation
|
|
163
|
+
- Complete build verification
|
|
164
|
+
- All linting and formatting checks
|
|
165
|
+
|
|
166
|
+
### Conventional Commits
|
|
167
|
+
```bash
|
|
168
|
+
feat: add support for patch comparison
|
|
169
|
+
fix: handle empty diff responses
|
|
170
|
+
docs: update API documentation
|
|
171
|
+
test: add integration tests for diff command
|
|
172
|
+
refactor: simplify error handling logic
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Adding New Commands
|
|
176
|
+
|
|
177
|
+
### 1. Define Schema
|
|
178
|
+
Add types to `src/schemas/gerrit.ts`:
|
|
179
|
+
```typescript
|
|
180
|
+
export const NewCommandOptions = Schema.Struct({
|
|
181
|
+
option1: Schema.String,
|
|
182
|
+
option2: Schema.optional(Schema.Number),
|
|
183
|
+
})
|
|
184
|
+
export type NewCommandOptions = Schema.Schema.Type<typeof NewCommandOptions>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### 2. Extend API Service
|
|
188
|
+
Add methods to `src/api/gerrit.ts`:
|
|
189
|
+
```typescript
|
|
190
|
+
readonly newMethod: (param: string) => Effect.Effect<ReturnType, ApiError>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### 3. Create Command Component
|
|
194
|
+
Create `src/cli/commands/new-command.tsx`:
|
|
195
|
+
```typescript
|
|
196
|
+
import React from 'react'
|
|
197
|
+
import { Box, Text } from 'ink'
|
|
198
|
+
// Implementation...
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### 4. Register Command
|
|
202
|
+
Add to `src/cli/index.ts`:
|
|
203
|
+
```typescript
|
|
204
|
+
program
|
|
205
|
+
.command('new-command <param>')
|
|
206
|
+
.description('Description of new command')
|
|
207
|
+
.action(/* implementation */)
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### 5. Add Tests
|
|
211
|
+
Create test files in `tests/unit/` and `tests/integration/`
|
|
212
|
+
|
|
213
|
+
### 6. Update Documentation
|
|
214
|
+
Update README.md with usage examples
|
|
215
|
+
|
|
216
|
+
## Database Management
|
|
217
|
+
|
|
218
|
+
### Schema Changes
|
|
219
|
+
1. Update `src/db/schema.ts` with new tables/columns
|
|
220
|
+
2. Add migration logic to `src/db/database.ts`
|
|
221
|
+
3. Test with fresh database creation
|
|
222
|
+
4. Update cache invalidation logic if needed
|
|
223
|
+
|
|
224
|
+
### Caching Strategy
|
|
225
|
+
- **Cache-first** - Always check local cache first
|
|
226
|
+
- **Smart invalidation** - Update cache on write operations
|
|
227
|
+
- **Offline support** - Gracefully handle network failures
|
|
228
|
+
|
|
229
|
+
## MSW Mock Setup
|
|
230
|
+
|
|
231
|
+
### Adding New API Endpoints
|
|
232
|
+
1. Define response schema in `src/schemas/gerrit.ts`
|
|
233
|
+
2. Add handler to `tests/mocks/handlers.ts`
|
|
234
|
+
3. Use schema validation in mock responses
|
|
235
|
+
4. Test both success and error cases
|
|
236
|
+
|
|
237
|
+
### Mock Data Generation
|
|
238
|
+
```typescript
|
|
239
|
+
const mockData: Schema.Schema.Type<typeof YourSchema> = {
|
|
240
|
+
// Properly typed mock data
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const validated = Schema.decodeUnknownSync(YourSchema)(mockData)
|
|
244
|
+
return HttpResponse.json(validated)
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Performance Considerations
|
|
248
|
+
|
|
249
|
+
### Caching
|
|
250
|
+
- Cache API responses in SQLite
|
|
251
|
+
- Implement cache expiration
|
|
252
|
+
- Provide cache management commands
|
|
253
|
+
|
|
254
|
+
### Bundle Size
|
|
255
|
+
- Use dynamic imports for large dependencies
|
|
256
|
+
- Tree-shake unused code
|
|
257
|
+
- Monitor bundle size in CI
|
|
258
|
+
|
|
259
|
+
### CLI Responsiveness
|
|
260
|
+
- Show loading indicators
|
|
261
|
+
- Stream large outputs
|
|
262
|
+
- Implement request cancellation
|
|
263
|
+
|
|
264
|
+
## Security Guidelines
|
|
265
|
+
|
|
266
|
+
### Credential Storage
|
|
267
|
+
- Store in `~/.gi/credentials.json` with 600 permissions
|
|
268
|
+
- Never log credentials
|
|
269
|
+
- Use secure environment variable handling
|
|
270
|
+
|
|
271
|
+
### API Communication
|
|
272
|
+
- Always use HTTPS
|
|
273
|
+
- Validate all inputs with Effect Schema
|
|
274
|
+
- Handle authentication errors gracefully
|
|
275
|
+
|
|
276
|
+
### Error Messages
|
|
277
|
+
- Never expose sensitive information
|
|
278
|
+
- Provide helpful debugging information
|
|
279
|
+
- Log errors for debugging without sensitive data
|
|
280
|
+
|
|
281
|
+
## Release Process
|
|
282
|
+
|
|
283
|
+
### Version Management
|
|
284
|
+
- Use semantic versioning (semver)
|
|
285
|
+
- Update version in `package.json`
|
|
286
|
+
- Create git tags for releases
|
|
287
|
+
|
|
288
|
+
### Build Process
|
|
289
|
+
```bash
|
|
290
|
+
bun run build # Build optimized bundle
|
|
291
|
+
bun test # Ensure all tests pass
|
|
292
|
+
bun run check:all # Run all quality checks
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Distribution
|
|
296
|
+
- Create platform-specific binaries
|
|
297
|
+
- Upload to GitHub releases
|
|
298
|
+
- Update installation instructions
|
|
299
|
+
|
|
300
|
+
## Contributing Guidelines
|
|
301
|
+
|
|
302
|
+
### Code Review Checklist
|
|
303
|
+
- [ ] All tests pass
|
|
304
|
+
- [ ] Code coverage maintained
|
|
305
|
+
- [ ] TypeScript strict mode compliance
|
|
306
|
+
- [ ] Follows existing patterns
|
|
307
|
+
- [ ] Documentation updated
|
|
308
|
+
- [ ] Error handling implemented
|
|
309
|
+
- [ ] Security considerations addressed
|
|
310
|
+
|
|
311
|
+
### Pull Request Process
|
|
312
|
+
1. Create feature branch
|
|
313
|
+
2. Implement changes with tests
|
|
314
|
+
3. Run `bun run check:all`
|
|
315
|
+
4. Create pull request with description
|
|
316
|
+
5. Address review feedback
|
|
317
|
+
6. Merge after approval
|
|
318
|
+
|
|
319
|
+
## Troubleshooting
|
|
320
|
+
|
|
321
|
+
### Common Development Issues
|
|
322
|
+
|
|
323
|
+
**Build failures**
|
|
324
|
+
```bash
|
|
325
|
+
rm -rf node_modules bun.lockb
|
|
326
|
+
bun install
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
**Test failures**
|
|
330
|
+
```bash
|
|
331
|
+
bun test --verbose
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
**Type errors**
|
|
335
|
+
```bash
|
|
336
|
+
bun run typecheck
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
**Lint errors**
|
|
340
|
+
```bash
|
|
341
|
+
bun run format # Auto-fix formatting
|
|
342
|
+
bun run lint # Check for issues
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### Debug Mode
|
|
346
|
+
```bash
|
|
347
|
+
DEBUG=1 bun run dev <command> # Enable debug logging
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Database Issues
|
|
351
|
+
```bash
|
|
352
|
+
rm -rf ~/.gi/cache.db # Reset local cache
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
## Resources
|
|
356
|
+
|
|
357
|
+
- [Effect Documentation](https://effect.website/)
|
|
358
|
+
- [Ink Documentation](https://github.com/vadimdemedes/ink)
|
|
359
|
+
- [Bun Documentation](https://bun.sh/docs)
|
|
360
|
+
- [MSW Documentation](https://mswjs.io/)
|
|
361
|
+
- [Gerrit REST API](https://gerrit-review.googlesource.com/Documentation/rest-api.html)
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Aaron Shafovaloff
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
# ger
|
|
2
|
+
|
|
3
|
+
Gerrit CLI built with Bun. XML output by default for LLM/automation compatibility, human-readable output with `--pretty`.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **LLM-Friendly**: XML output for AI/automation pipelines
|
|
8
|
+
- **Interactive UI**: Terminal UI for change selection and navigation
|
|
9
|
+
- **Secure**: Credentials stored in system keychain
|
|
10
|
+
- **Effect-based**: Robust error handling and functional architecture
|
|
11
|
+
- **Batch Comments**: JSON array input with line/range targeting and side support
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Install Bun runtime
|
|
17
|
+
curl -fsSL https://bun.sh/install | bash
|
|
18
|
+
|
|
19
|
+
# Install ger
|
|
20
|
+
bun install -g @aaronshaf/ger
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Getting Started
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
ger setup
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
This will prompt for your Gerrit credentials:
|
|
30
|
+
- Gerrit host URL
|
|
31
|
+
- Username
|
|
32
|
+
- HTTP password (from Gerrit settings)
|
|
33
|
+
|
|
34
|
+
Credentials are securely stored in your system keychain.
|
|
35
|
+
|
|
36
|
+
## Common Commands
|
|
37
|
+
|
|
38
|
+
### Daily Workflow
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Check your connection status
|
|
42
|
+
ger status
|
|
43
|
+
|
|
44
|
+
# View your changes
|
|
45
|
+
ger mine
|
|
46
|
+
|
|
47
|
+
# View incoming reviews
|
|
48
|
+
ger incoming
|
|
49
|
+
|
|
50
|
+
# View a specific change
|
|
51
|
+
ger show 12345
|
|
52
|
+
|
|
53
|
+
# Add a comment
|
|
54
|
+
ger comment 12345 -m "LGTM"
|
|
55
|
+
|
|
56
|
+
# Get diff for review
|
|
57
|
+
ger diff 12345
|
|
58
|
+
|
|
59
|
+
# AI-powered code review (requires claude, llm, or opencode CLI)
|
|
60
|
+
ger review 12345
|
|
61
|
+
ger review 12345 --dry-run # Preview without posting
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Commands
|
|
65
|
+
|
|
66
|
+
### Connection Status
|
|
67
|
+
```bash
|
|
68
|
+
ger status
|
|
69
|
+
ger status --pretty
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Show Change Details
|
|
73
|
+
```bash
|
|
74
|
+
# Complete change info with metadata, diff, inline comments, and review activity
|
|
75
|
+
ger show 12345
|
|
76
|
+
ger show 12345 --pretty
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### List Changes
|
|
80
|
+
```bash
|
|
81
|
+
# Your changes
|
|
82
|
+
ger mine
|
|
83
|
+
ger mine --pretty
|
|
84
|
+
|
|
85
|
+
# Incoming reviews
|
|
86
|
+
ger incoming
|
|
87
|
+
ger incoming --pretty
|
|
88
|
+
|
|
89
|
+
# Workspace changes (local branch tracking)
|
|
90
|
+
ger workspace
|
|
91
|
+
ger workspace --pretty
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Comments
|
|
95
|
+
|
|
96
|
+
#### Overall Comments
|
|
97
|
+
```bash
|
|
98
|
+
# Using -m flag
|
|
99
|
+
ger comment 12345 -m "LGTM"
|
|
100
|
+
|
|
101
|
+
# Piping plain text (becomes overall comment message)
|
|
102
|
+
echo "Review text" | ger comment 12345
|
|
103
|
+
cat review.txt | ger comment 12345
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
#### Line-Specific Comments
|
|
107
|
+
```bash
|
|
108
|
+
# Single line comment (line numbers refer to post-merge view)
|
|
109
|
+
ger comment 12345 --file src/main.ts --line 42 -m "Consider error handling"
|
|
110
|
+
|
|
111
|
+
# Mark as unresolved
|
|
112
|
+
ger comment 12345 --file src/main.ts --line 42 -m "Fix this" --unresolved
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### Batch Line Comments (JSON Array)
|
|
116
|
+
|
|
117
|
+
The batch comment feature accepts a JSON array of comment objects. Each comment can target specific lines, ranges, or sides of the diff.
|
|
118
|
+
|
|
119
|
+
##### Basic Structure
|
|
120
|
+
```javascript
|
|
121
|
+
[
|
|
122
|
+
{
|
|
123
|
+
"file": "path/to/file.js", // Required: File path
|
|
124
|
+
"line": 42, // Optional: Line number (omit when using range)
|
|
125
|
+
"message": "Your comment", // Required: Comment text
|
|
126
|
+
"side": "REVISION", // Optional: "PARENT" or "REVISION" (default: REVISION)
|
|
127
|
+
"range": { // Optional: Comment on multiple lines or characters
|
|
128
|
+
"start_line": 10,
|
|
129
|
+
"end_line": 20,
|
|
130
|
+
"start_character": 0, // Optional: Character position (0-indexed)
|
|
131
|
+
"end_character": 80
|
|
132
|
+
},
|
|
133
|
+
"unresolved": true // Optional: Mark as unresolved (default: false)
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
##### Examples
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# Basic batch comments
|
|
142
|
+
echo '[
|
|
143
|
+
{"file": "src/main.ts", "line": 10, "message": "Add type annotation"},
|
|
144
|
+
{"file": "src/utils.ts", "line": 25, "message": "Extract to constant"},
|
|
145
|
+
{"file": "src/api.ts", "line": 100, "message": "Handle error", "unresolved": true}
|
|
146
|
+
]' | ger comment 12345 --batch
|
|
147
|
+
|
|
148
|
+
# Comment on different sides of the diff
|
|
149
|
+
# PARENT: The original code before changes
|
|
150
|
+
# REVISION: The new code after changes
|
|
151
|
+
echo '[
|
|
152
|
+
{"file": "src/Calculator.java", "line": 5, "side": "PARENT", "message": "Why was this removed?"},
|
|
153
|
+
{"file": "src/Calculator.java", "line": 5, "side": "REVISION", "message": "Good improvement"}
|
|
154
|
+
]' | ger comment 12345 --batch
|
|
155
|
+
|
|
156
|
+
# Range comments for blocks of code
|
|
157
|
+
echo '[
|
|
158
|
+
{
|
|
159
|
+
"file": "src/Service.java",
|
|
160
|
+
"range": {"start_line": 50, "end_line": 55},
|
|
161
|
+
"message": "This entire method needs refactoring"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"file": "src/Service.java",
|
|
165
|
+
"range": {"start_line": 10, "start_character": 8, "end_line": 10, "end_character": 25},
|
|
166
|
+
"message": "This variable name is confusing"
|
|
167
|
+
}
|
|
168
|
+
]' | ger comment 12345 --batch
|
|
169
|
+
|
|
170
|
+
# Combined features: range + side + unresolved
|
|
171
|
+
echo '[
|
|
172
|
+
{
|
|
173
|
+
"file": "src/UserService.java",
|
|
174
|
+
"range": {"start_line": 20, "end_line": 35},
|
|
175
|
+
"side": "PARENT",
|
|
176
|
+
"message": "Why was this error handling removed?",
|
|
177
|
+
"unresolved": true
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"file": "src/UserService.java",
|
|
181
|
+
"range": {"start_line": 20, "end_line": 35},
|
|
182
|
+
"side": "REVISION",
|
|
183
|
+
"message": "New error handling looks good, but consider extracting to a method"
|
|
184
|
+
}
|
|
185
|
+
]' | ger comment 12345 --batch
|
|
186
|
+
|
|
187
|
+
# Load comments from a file
|
|
188
|
+
cat comments.json | ger comment 12345 --batch
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
#### View Comments
|
|
192
|
+
```bash
|
|
193
|
+
# View all comments with diff context
|
|
194
|
+
ger comments 12345
|
|
195
|
+
ger comments 12345 --pretty
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Diff
|
|
199
|
+
```bash
|
|
200
|
+
# Full diff
|
|
201
|
+
ger diff 12345
|
|
202
|
+
ger diff 12345 --pretty
|
|
203
|
+
|
|
204
|
+
# List changed files
|
|
205
|
+
ger diff 12345 --files-only
|
|
206
|
+
|
|
207
|
+
# Specific file
|
|
208
|
+
ger diff 12345 --file src/main.ts
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Change Management
|
|
212
|
+
```bash
|
|
213
|
+
# Open in browser
|
|
214
|
+
ger open 12345
|
|
215
|
+
|
|
216
|
+
# Abandon
|
|
217
|
+
ger abandon 12345
|
|
218
|
+
ger abandon 12345 -m "Reason"
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### AI-Powered Review
|
|
222
|
+
|
|
223
|
+
The `ger review` command provides automated code review using AI tools (claude, llm, or opencode CLI).
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
# Full AI review with inline and overall comments
|
|
227
|
+
ger review 12345
|
|
228
|
+
|
|
229
|
+
# Preview what would be posted without actually posting
|
|
230
|
+
ger review 12345 --dry-run
|
|
231
|
+
|
|
232
|
+
# Show debug output including AI responses
|
|
233
|
+
ger review 12345 --debug
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
The review command performs a two-stage review process:
|
|
237
|
+
1. **Inline comments**: Specific code issues with line-by-line feedback
|
|
238
|
+
2. **Overall review**: High-level assessment and recommendations
|
|
239
|
+
|
|
240
|
+
Requirements:
|
|
241
|
+
- One of these AI tools must be installed: `claude`, `llm`, or `opencode`
|
|
242
|
+
- Gerrit credentials must be configured (`ger setup`)
|
|
243
|
+
|
|
244
|
+
## LLM Integration
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# Review with AI
|
|
248
|
+
ger diff 12345 | llm "Review this code"
|
|
249
|
+
|
|
250
|
+
# AI-generated comment
|
|
251
|
+
llm "Review change 12345" | ger comment 12345
|
|
252
|
+
|
|
253
|
+
# Complete change analysis
|
|
254
|
+
ger show 12345 | llm "Summarize this change and its review status"
|
|
255
|
+
|
|
256
|
+
# Automated approvals
|
|
257
|
+
echo "LGTM" | ger comment 12345
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Output Formats
|
|
261
|
+
|
|
262
|
+
### XML (Default)
|
|
263
|
+
```xml
|
|
264
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
265
|
+
<comment_result>
|
|
266
|
+
<status>success</status>
|
|
267
|
+
<change_id>12345</change_id>
|
|
268
|
+
<message><![CDATA[LGTM]]></message>
|
|
269
|
+
</comment_result>
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Pretty (--pretty flag)
|
|
273
|
+
```
|
|
274
|
+
Comment posted successfully
|
|
275
|
+
Change: Fix authentication bug (NEW)
|
|
276
|
+
Message: LGTM
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
## Upgrading
|
|
280
|
+
|
|
281
|
+
To upgrade gi to the latest version:
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
bun update -g @aaronshaf/ger
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
After upgrading, you may want to review new configuration options:
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
ger setup # Review and update your configuration
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
## Development
|
|
294
|
+
|
|
295
|
+
For local development:
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
git clone https://github.com/aaronshaf/ger
|
|
299
|
+
cd ger
|
|
300
|
+
bun install
|
|
301
|
+
|
|
302
|
+
# Run locally
|
|
303
|
+
bun run dev
|
|
304
|
+
|
|
305
|
+
# Run tests
|
|
306
|
+
bun test
|
|
307
|
+
bun run test:coverage
|
|
308
|
+
|
|
309
|
+
# Type checking
|
|
310
|
+
bun run typecheck
|
|
311
|
+
|
|
312
|
+
# Linting
|
|
313
|
+
bun run lint
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### Stack
|
|
317
|
+
- **Bun** - Runtime and package manager
|
|
318
|
+
- **Effect** - Type-safe error handling and functional architecture
|
|
319
|
+
- **TypeScript** - With isolatedDeclarations
|
|
320
|
+
- **Ink** - Terminal UI components
|
|
321
|
+
- **Commander** - CLI argument parsing
|
|
322
|
+
|
|
323
|
+
## License
|
|
324
|
+
|
|
325
|
+
MIT
|
package/bin/ger
ADDED