difit 3.1.9 → 3.1.10
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.ja.md +22 -13
- package/README.ko.md +22 -13
- package/README.md +22 -13
- package/README.zh.md +22 -13
- package/dist/cli/index.js +55 -45
- package/dist/cli/index.test.js +114 -56
- package/dist/cli/utils.d.ts +1 -4
- package/dist/cli/utils.js +17 -98
- package/dist/client/assets/{index-B1Ye1njT.js → index-CH5h4Jfu.js} +2 -2
- package/dist/client/assets/{prism-csharp-Dv4F6oYg.js → prism-csharp-omuTcU4j.js} +1 -1
- package/dist/client/assets/{prism-hcl-BKiQPDt1.js → prism-hcl-BVGrHlPv.js} +1 -1
- package/dist/client/assets/{prism-java-CsLA9BYF.js → prism-java-BjHLe7qM.js} +1 -1
- package/dist/client/assets/{prism-perl-CjbksjRr.js → prism-perl-Cl4F-f2r.js} +1 -1
- package/dist/client/assets/{prism-php-Blls7Q4g.js → prism-php-BbsdsICU.js} +1 -1
- package/dist/client/assets/{prism-ruby-DVHs5uYA.js → prism-ruby-CSLiFfIy.js} +1 -1
- package/dist/client/assets/{prism-solidity-BxgmEX2j.js → prism-solidity-C3yStBME.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/git-diff.js +38 -22
- package/dist/server/server.d.ts +1 -0
- package/dist/server/server.js +16 -10
- package/dist/server/server.test.js +76 -0
- package/dist/tui/App.js +7 -10
- package/dist/tui/components/SideBySideDiffViewer.js +8 -8
- package/dist/tui/components/StatusBar.js +1 -5
- package/dist/utils/commentFormatting.js +1 -3
- package/package.json +9 -18
package/README.ja.md
CHANGED
|
@@ -66,19 +66,19 @@ difit working # 未ステージ差分のみ
|
|
|
66
66
|
difit --pr https://github.com/owner/repo/pull/123
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
`--pr` モードでは、内部で `gh pr diff --patch` を実行してパッチを取得します。
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
認証は GitHub CLI が処理します:
|
|
72
|
+
|
|
73
|
+
1. **一度ログイン**(推奨):`gh auth login`
|
|
74
|
+
2. **トークン認証**(CI/非対話環境):`GH_TOKEN` または `GITHUB_TOKEN` を設定
|
|
74
75
|
|
|
75
76
|
#### GitHub Enterprise Server
|
|
76
77
|
|
|
77
|
-
Enterprise ServerのPR
|
|
78
|
+
Enterprise Server の PR を表示する場合は、GitHub CLI を Enterprise ホスト向けに認証してください:
|
|
78
79
|
|
|
79
|
-
1. `
|
|
80
|
-
2.
|
|
81
|
-
3. `GITHUB_TOKEN`環境変数として設定
|
|
80
|
+
1. `gh auth login --hostname YOUR-ENTERPRISE-SERVER`
|
|
81
|
+
2. または `GH_HOST=YOUR-ENTERPRISE-SERVER` と `GH_TOKEN` / `GITHUB_TOKEN` を設定
|
|
82
82
|
|
|
83
83
|
### 標準入力
|
|
84
84
|
|
|
@@ -121,6 +121,7 @@ git diff --cached | difit -
|
|
|
121
121
|
| `--tui` | false | WebUIの代わりにターミナルUIを使用 |
|
|
122
122
|
| `--clean` | false | 起動時に既存コメントと閲覧済みファイルをすべてクリア |
|
|
123
123
|
| `--include-untracked` | false | diffにuntrackedファイルを自動的に含める(`.`または`working`のみ有効) |
|
|
124
|
+
| `--keep-alive` | false | ブラウザ切断後もサーバーを終了せず起動したままにする(Ctrl+Cで手動停止) |
|
|
124
125
|
|
|
125
126
|
## 💬 コメントシステム
|
|
126
127
|
|
|
@@ -146,6 +147,14 @@ src/components/Button.tsx:L42-L48 # この行が自動的に追加されます
|
|
|
146
147
|
この部分は不要です
|
|
147
148
|
```
|
|
148
149
|
|
|
150
|
+
## 🤖 エージェントからの呼び出し
|
|
151
|
+
|
|
152
|
+
difitを利用してユーザーにレビューを依頼するSkillを以下でインストールできます
|
|
153
|
+
|
|
154
|
+
```sh
|
|
155
|
+
npx skills add yoshiko-pg/difit
|
|
156
|
+
```
|
|
157
|
+
|
|
149
158
|
## 🎨 シンタックスハイライト対応言語
|
|
150
159
|
|
|
151
160
|
- **JavaScript/TypeScript**:`.js`, `.jsx`, `.ts`, `.tsx`
|
|
@@ -201,10 +210,9 @@ pnpm run build
|
|
|
201
210
|
# テストの実行
|
|
202
211
|
pnpm test
|
|
203
212
|
|
|
204
|
-
#
|
|
205
|
-
pnpm run
|
|
213
|
+
# 型チェックとlintとフォーマット
|
|
214
|
+
pnpm run check
|
|
206
215
|
pnpm run format
|
|
207
|
-
pnpm run typecheck
|
|
208
216
|
```
|
|
209
217
|
|
|
210
218
|
### 開発ワークフロー
|
|
@@ -218,17 +226,18 @@ pnpm run typecheck
|
|
|
218
226
|
|
|
219
227
|
- **CLI**:包括的なバリデーションを備えたCommander.jsでの引数解析
|
|
220
228
|
- **バックエンド**:diff処理用のsimple-gitを備えたExpressサーバー
|
|
221
|
-
- **GitHub
|
|
229
|
+
- **GitHub統合**:GitHub CLI(`gh pr diff --patch`)によるPRパッチ取得
|
|
222
230
|
- **フロントエンド**:React 18 + TypeScript + Vite
|
|
223
231
|
- **スタイリング**:GitHubライクなダークテーマを備えたTailwind CSS v4
|
|
224
232
|
- **シンタックスハイライト**:動的言語ロードを備えたPrism.js
|
|
225
233
|
- **テスト**:同じ場所に配置されたテストファイルを使用したVitestユニットテスト
|
|
226
|
-
- **品質**:
|
|
234
|
+
- **品質**:Oxlint、Biome、lefthookプリコミットフック
|
|
227
235
|
|
|
228
236
|
## 📋 要件
|
|
229
237
|
|
|
230
238
|
- Node.js ≥ 21.0.0
|
|
231
239
|
- レビューするコミットを含むGitリポジトリ
|
|
240
|
+
- `--pr` モード利用時は GitHub CLI(`gh`)
|
|
232
241
|
|
|
233
242
|
## 📄 ライセンス
|
|
234
243
|
|
package/README.ko.md
CHANGED
|
@@ -66,19 +66,19 @@ difit working # 미스테이징 변경 사항만
|
|
|
66
66
|
difit --pr https://github.com/owner/repo/pull/123
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
`--pr` 모드는 내부적으로 `gh pr diff --patch`를 실행해 패치를 가져옵니다.
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
인증은 GitHub CLI가 처리합니다:
|
|
72
|
+
|
|
73
|
+
1. **한 번 로그인** (권장): `gh auth login`
|
|
74
|
+
2. **토큰 인증** (CI/비대화형 환경): `GH_TOKEN` 또는 `GITHUB_TOKEN` 설정
|
|
74
75
|
|
|
75
76
|
#### GitHub Enterprise Server
|
|
76
77
|
|
|
77
|
-
Enterprise Server PR의 경우
|
|
78
|
+
Enterprise Server PR의 경우 GitHub CLI를 Enterprise 호스트에 인증하세요:
|
|
78
79
|
|
|
79
|
-
1. `
|
|
80
|
-
2.
|
|
81
|
-
3. `GITHUB_TOKEN` 환경 변수로 설정
|
|
80
|
+
1. `gh auth login --hostname YOUR-ENTERPRISE-SERVER`
|
|
81
|
+
2. 또는 `GH_HOST=YOUR-ENTERPRISE-SERVER`와 `GH_TOKEN`/`GITHUB_TOKEN` 설정
|
|
82
82
|
|
|
83
83
|
### 표준 입력
|
|
84
84
|
|
|
@@ -121,6 +121,7 @@ git diff --cached | difit -
|
|
|
121
121
|
| `--tui` | false | WebUI 대신 터미널 UI 모드 사용 |
|
|
122
122
|
| `--clean` | false | 시작 시 모든 기존 코멘트와 열람된 파일 표시 초기화 |
|
|
123
123
|
| `--include-untracked` | false | diff에 untracked 파일 자동 포함 (`.` 또는 `working`에서만 유효) |
|
|
124
|
+
| `--keep-alive` | false | 브라우저 연결이 끊겨도 서버 유지 (Ctrl+C로 수동 종료) |
|
|
124
125
|
|
|
125
126
|
## 💬 코멘트 시스템
|
|
126
127
|
|
|
@@ -146,6 +147,14 @@ src/components/Button.tsx:L42-L48 # 이 줄은 자동으로 추가됩니다
|
|
|
146
147
|
이 부분은 불필요합니다
|
|
147
148
|
```
|
|
148
149
|
|
|
150
|
+
## 🤖 에이전트에서 호출
|
|
151
|
+
|
|
152
|
+
difit을 사용해 사용자에게 리뷰를 요청하는 Skill은 아래 명령으로 설치할 수 있습니다:
|
|
153
|
+
|
|
154
|
+
```sh
|
|
155
|
+
npx skills add yoshiko-pg/difit
|
|
156
|
+
```
|
|
157
|
+
|
|
149
158
|
## 🎨 구문 강조 언어
|
|
150
159
|
|
|
151
160
|
- **JavaScript/TypeScript**: `.js`, `.jsx`, `.ts`, `.tsx`
|
|
@@ -201,10 +210,9 @@ pnpm run build
|
|
|
201
210
|
# 테스트 실행
|
|
202
211
|
pnpm test
|
|
203
212
|
|
|
204
|
-
#
|
|
205
|
-
pnpm run
|
|
213
|
+
# 타입체크와 lint와 포맷
|
|
214
|
+
pnpm run check
|
|
206
215
|
pnpm run format
|
|
207
|
-
pnpm run typecheck
|
|
208
216
|
```
|
|
209
217
|
|
|
210
218
|
### 개발 워크플로우
|
|
@@ -218,17 +226,18 @@ pnpm run typecheck
|
|
|
218
226
|
|
|
219
227
|
- **CLI**: 포괄적인 검증을 갖춘 Commander.js로 인수 구문 분석
|
|
220
228
|
- **백엔드**: diff 처리를 위한 simple-git이 포함된 Express 서버
|
|
221
|
-
- **GitHub 통합**:
|
|
229
|
+
- **GitHub 통합**: GitHub CLI(`gh pr diff --patch`) 기반 PR 패치 조회
|
|
222
230
|
- **프론트엔드**: React 18 + TypeScript + Vite
|
|
223
231
|
- **스타일링**: GitHub과 유사한 다크 테마를 갖춘 Tailwind CSS v4
|
|
224
232
|
- **구문 강조**: 동적 언어 로딩을 갖춘 Prism.js
|
|
225
233
|
- **테스트**: 동일 위치에 배치된 테스트 파일을 사용하는 Vitest 단위 테스트
|
|
226
|
-
- **품질**:
|
|
234
|
+
- **품질**: Oxlint, Biome, lefthook 사전 커밋 훅
|
|
227
235
|
|
|
228
236
|
## 📋 요구 사항
|
|
229
237
|
|
|
230
238
|
- Node.js ≥ 21.0.0
|
|
231
239
|
- 검토할 커밋이 포함된 Git 저장소
|
|
240
|
+
- `--pr` 모드 사용 시 GitHub CLI(`gh`)
|
|
232
241
|
|
|
233
242
|
## 📄 라이선스
|
|
234
243
|
|
package/README.md
CHANGED
|
@@ -66,19 +66,19 @@ difit working # Unstaged changes only
|
|
|
66
66
|
difit --pr https://github.com/owner/repo/pull/123
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
`--pr` mode fetches patches by running `gh pr diff --patch` under the hood.
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
Authentication is handled by GitHub CLI:
|
|
72
|
+
|
|
73
|
+
1. **Login once** (recommended): `gh auth login`
|
|
74
|
+
2. **Token-based auth** (CI/non-interactive): set `GH_TOKEN` or `GITHUB_TOKEN`
|
|
74
75
|
|
|
75
76
|
#### GitHub Enterprise Server
|
|
76
77
|
|
|
77
|
-
For Enterprise Server PRs,
|
|
78
|
+
For Enterprise Server PRs, authenticate GitHub CLI against your Enterprise host:
|
|
78
79
|
|
|
79
|
-
1.
|
|
80
|
-
2.
|
|
81
|
-
3. Set it as `GITHUB_TOKEN` environment variable
|
|
80
|
+
1. `gh auth login --hostname YOUR-ENTERPRISE-SERVER`
|
|
81
|
+
2. Or set `GH_HOST=YOUR-ENTERPRISE-SERVER` with `GH_TOKEN`/`GITHUB_TOKEN`
|
|
82
82
|
|
|
83
83
|
### Stdin
|
|
84
84
|
|
|
@@ -121,6 +121,7 @@ Stdin mode is selected with intent-first rules:
|
|
|
121
121
|
| `--tui` | false | Use terminal UI mode instead of WebUI |
|
|
122
122
|
| `--clean` | false | Clear all existing comments and viewed files on startup |
|
|
123
123
|
| `--include-untracked` | false | Automatically include untracked files in diff (only with `.` or `working`) |
|
|
124
|
+
| `--keep-alive` | false | Keep server running after browser disconnects (stop manually with Ctrl+C) |
|
|
124
125
|
|
|
125
126
|
## 💬 Comment System
|
|
126
127
|
|
|
@@ -146,6 +147,14 @@ src/components/Button.tsx:L42-L48 # This line is automatically added
|
|
|
146
147
|
This section is unnecessary
|
|
147
148
|
```
|
|
148
149
|
|
|
150
|
+
## 🤖 Calling from Agents
|
|
151
|
+
|
|
152
|
+
You can install the following Skill to request reviews from users with difit:
|
|
153
|
+
|
|
154
|
+
```sh
|
|
155
|
+
npx skills add yoshiko-pg/difit
|
|
156
|
+
```
|
|
157
|
+
|
|
149
158
|
## 🎨 Syntax Highlighting Languages
|
|
150
159
|
|
|
151
160
|
- **JavaScript/TypeScript**: `.js`, `.jsx`, `.ts`, `.tsx`
|
|
@@ -201,10 +210,9 @@ pnpm run build
|
|
|
201
210
|
# Run tests
|
|
202
211
|
pnpm test
|
|
203
212
|
|
|
204
|
-
#
|
|
205
|
-
pnpm run
|
|
213
|
+
# Run typecheck, lint, and format
|
|
214
|
+
pnpm run check
|
|
206
215
|
pnpm run format
|
|
207
|
-
pnpm run typecheck
|
|
208
216
|
```
|
|
209
217
|
|
|
210
218
|
### Development Workflow
|
|
@@ -218,17 +226,18 @@ pnpm run typecheck
|
|
|
218
226
|
|
|
219
227
|
- **CLI**: Commander.js for argument parsing with comprehensive validation
|
|
220
228
|
- **Backend**: Express server with simple-git for diff processing
|
|
221
|
-
- **GitHub Integration**:
|
|
229
|
+
- **GitHub Integration**: GitHub CLI (`gh pr diff --patch`) for PR patch retrieval
|
|
222
230
|
- **Frontend**: React 18 + TypeScript + Vite
|
|
223
231
|
- **Styling**: Tailwind CSS v4 with GitHub-like dark theme
|
|
224
232
|
- **Syntax Highlighting**: Prism.js with dynamic language loading
|
|
225
233
|
- **Testing**: Vitest for unit tests with co-located test files
|
|
226
|
-
- **Quality**:
|
|
234
|
+
- **Quality**: Oxlint, Biome, lefthook pre-commit hooks
|
|
227
235
|
|
|
228
236
|
## 📋 Requirements
|
|
229
237
|
|
|
230
238
|
- Node.js ≥ 21.0.0
|
|
231
239
|
- Git repository with commits to review
|
|
240
|
+
- GitHub CLI (`gh`) for `--pr` mode
|
|
232
241
|
|
|
233
242
|
## 📄 License
|
|
234
243
|
|
package/README.zh.md
CHANGED
|
@@ -66,19 +66,19 @@ difit working # 仅未暂存的更改
|
|
|
66
66
|
difit --pr https://github.com/owner/repo/pull/123
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
`--pr` 模式会在内部执行 `gh pr diff --patch` 来获取补丁。
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
认证由 GitHub CLI 处理:
|
|
72
|
+
|
|
73
|
+
1. **先登录一次**(推荐):`gh auth login`
|
|
74
|
+
2. **令牌认证**(CI/非交互环境):设置 `GH_TOKEN` 或 `GITHUB_TOKEN`
|
|
74
75
|
|
|
75
76
|
#### GitHub Enterprise Server
|
|
76
77
|
|
|
77
|
-
对于 Enterprise Server PR
|
|
78
|
+
对于 Enterprise Server PR,请先让 GitHub CLI 认证到 Enterprise 主机:
|
|
78
79
|
|
|
79
|
-
1.
|
|
80
|
-
2.
|
|
81
|
-
3. 将其设置为 `GITHUB_TOKEN` 环境变量
|
|
80
|
+
1. `gh auth login --hostname YOUR-ENTERPRISE-SERVER`
|
|
81
|
+
2. 或设置 `GH_HOST=YOUR-ENTERPRISE-SERVER`,并配置 `GH_TOKEN` / `GITHUB_TOKEN`
|
|
82
82
|
|
|
83
83
|
### 标准输入
|
|
84
84
|
|
|
@@ -121,6 +121,7 @@ git diff --cached | difit -
|
|
|
121
121
|
| `--tui` | false | 使用终端 UI 模式而不是 WebUI |
|
|
122
122
|
| `--clean` | false | 启动时清除所有现有评论和已查看的文件 |
|
|
123
123
|
| `--include-untracked` | false | 自动将 untracked 文件包含在 diff 中(仅在 `.` 或 `working` 时有效) |
|
|
124
|
+
| `--keep-alive` | false | 浏览器断开后保持服务器运行(使用 Ctrl+C 手动停止) |
|
|
124
125
|
|
|
125
126
|
## 💬 评论系统
|
|
126
127
|
|
|
@@ -146,6 +147,14 @@ src/components/Button.tsx:L42-L48 # 此行自动添加
|
|
|
146
147
|
此部分是不必要的
|
|
147
148
|
```
|
|
148
149
|
|
|
150
|
+
## 🤖 从代理调用
|
|
151
|
+
|
|
152
|
+
你可以通过以下命令安装 Skill,以便使用 difit 向用户请求审查:
|
|
153
|
+
|
|
154
|
+
```sh
|
|
155
|
+
npx skills add yoshiko-pg/difit
|
|
156
|
+
```
|
|
157
|
+
|
|
149
158
|
## 🎨 语法高亮语言
|
|
150
159
|
|
|
151
160
|
- **JavaScript/TypeScript**:`.js`, `.jsx`, `.ts`, `.tsx`
|
|
@@ -201,10 +210,9 @@ pnpm run build
|
|
|
201
210
|
# 运行测试
|
|
202
211
|
pnpm test
|
|
203
212
|
|
|
204
|
-
#
|
|
205
|
-
pnpm run
|
|
213
|
+
# 运行 typecheck、lint 和格式化
|
|
214
|
+
pnpm run check
|
|
206
215
|
pnpm run format
|
|
207
|
-
pnpm run typecheck
|
|
208
216
|
```
|
|
209
217
|
|
|
210
218
|
### 开发工作流程
|
|
@@ -218,17 +226,18 @@ pnpm run typecheck
|
|
|
218
226
|
|
|
219
227
|
- **CLI**:使用 Commander.js 进行参数解析,具有全面的验证
|
|
220
228
|
- **后端**:Express 服务器配合 simple-git 进行差异处理
|
|
221
|
-
- **GitHub
|
|
229
|
+
- **GitHub 集成**:使用 GitHub CLI(`gh pr diff --patch`)获取 PR 补丁
|
|
222
230
|
- **前端**:React 18 + TypeScript + Vite
|
|
223
231
|
- **样式**:Tailwind CSS v4,带有类似 GitHub 的深色主题
|
|
224
232
|
- **语法高亮**:Prism.js 带动态语言加载
|
|
225
233
|
- **测试**:Vitest 用于单元测试,测试文件与源代码放在一起
|
|
226
|
-
- **质量**:
|
|
234
|
+
- **质量**:Oxlint、Biome、lefthook 预提交钩子
|
|
227
235
|
|
|
228
236
|
## 📋 要求
|
|
229
237
|
|
|
230
238
|
- Node.js ≥ 21.0.0
|
|
231
239
|
- 包含要审查的提交的 Git 仓库
|
|
240
|
+
- 使用 `--pr` 模式时需要 GitHub CLI(`gh`)
|
|
232
241
|
|
|
233
242
|
## 📄 许可证
|
|
234
243
|
|
package/dist/cli/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import pkg from '../../package.json' with { type: 'json' };
|
|
|
6
6
|
import { startServer } from '../server/server.js';
|
|
7
7
|
import { DiffMode } from '../types/watch.js';
|
|
8
8
|
import { DEFAULT_DIFF_VIEW_MODE, normalizeDiffViewMode } from '../utils/diffMode.js';
|
|
9
|
-
import { shouldReadStdin, findUntrackedFiles, markFilesIntentToAdd, promptUser, validateDiffArguments,
|
|
9
|
+
import { shouldReadStdin, findUntrackedFiles, markFilesIntentToAdd, promptUser, validateDiffArguments, getPrPatch, getGitRoot, } from './utils.js';
|
|
10
10
|
function isSpecialArg(arg) {
|
|
11
11
|
return arg === 'working' || arg === 'staged' || arg === '.';
|
|
12
12
|
}
|
|
@@ -43,33 +43,62 @@ program
|
|
|
43
43
|
.option('--pr <url>', 'GitHub PR URL to review (e.g., https://github.com/owner/repo/pull/123)')
|
|
44
44
|
.option('--clean', 'start with a clean slate by clearing all existing comments')
|
|
45
45
|
.option('--include-untracked', 'automatically include untracked files in diff')
|
|
46
|
+
.option('--keep-alive', 'keep server running even after browser disconnects')
|
|
46
47
|
.action(async (commitish, compareWith, options) => {
|
|
47
48
|
try {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
hasTuiOption: Boolean(options.tui),
|
|
54
|
-
});
|
|
55
|
-
if (readFromStdin) {
|
|
56
|
-
// Read unified diff from stdin
|
|
57
|
-
const diffContent = await readStdin();
|
|
58
|
-
if (!diffContent.trim()) {
|
|
59
|
-
console.error('Error: No diff content received from stdin');
|
|
49
|
+
let stdinDiff;
|
|
50
|
+
let stdinReviewLabel = 'diff from stdin';
|
|
51
|
+
if (options.pr) {
|
|
52
|
+
if (commitish !== 'HEAD' || compareWith) {
|
|
53
|
+
console.error('Error: --pr option cannot be used with positional arguments');
|
|
60
54
|
process.exit(1);
|
|
61
55
|
}
|
|
62
|
-
|
|
56
|
+
if (options.tui) {
|
|
57
|
+
console.error('Error: --pr option cannot be used with --tui');
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
stdinDiff = getPrPatch(options.pr);
|
|
62
|
+
stdinReviewLabel = options.pr;
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
console.error(`Error resolving PR: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
// Check if we should read from stdin
|
|
71
|
+
const readFromStdin = shouldReadStdin({
|
|
72
|
+
commitish,
|
|
73
|
+
hasPositionalArgs: program.args.length > 0,
|
|
74
|
+
hasPrOption: false,
|
|
75
|
+
hasTuiOption: Boolean(options.tui),
|
|
76
|
+
});
|
|
77
|
+
if (readFromStdin) {
|
|
78
|
+
// Read unified diff from stdin
|
|
79
|
+
stdinDiff = await readStdin();
|
|
80
|
+
if (!stdinDiff.trim()) {
|
|
81
|
+
console.error('Error: No diff content received from stdin');
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (stdinDiff) {
|
|
87
|
+
// Start server with stdin diff (including --pr patch)
|
|
63
88
|
const { url } = await startServer({
|
|
64
|
-
stdinDiff
|
|
89
|
+
stdinDiff,
|
|
65
90
|
preferredPort: options.port,
|
|
66
91
|
host: options.host,
|
|
67
92
|
openBrowser: options.open,
|
|
68
93
|
mode: options.mode,
|
|
69
94
|
clearComments: options.clean,
|
|
95
|
+
keepAlive: options.keepAlive,
|
|
70
96
|
});
|
|
71
97
|
console.log(`\n🚀 difit server started on ${url}`);
|
|
72
|
-
console.log(`📋 Reviewing:
|
|
98
|
+
console.log(`📋 Reviewing: ${stdinReviewLabel}`);
|
|
99
|
+
if (options.keepAlive) {
|
|
100
|
+
console.log('🔒 Keep-alive mode: server will stay running after browser disconnects');
|
|
101
|
+
}
|
|
73
102
|
console.log('\nPress Ctrl+C to stop the server');
|
|
74
103
|
return;
|
|
75
104
|
}
|
|
@@ -85,26 +114,7 @@ program
|
|
|
85
114
|
// Determine target and base commitish
|
|
86
115
|
let targetCommitish = commitish;
|
|
87
116
|
let baseCommitish;
|
|
88
|
-
|
|
89
|
-
if (options.pr) {
|
|
90
|
-
if (commitish !== 'HEAD' || compareWith) {
|
|
91
|
-
console.error('Error: --pr option cannot be used with positional arguments');
|
|
92
|
-
process.exit(1);
|
|
93
|
-
}
|
|
94
|
-
try {
|
|
95
|
-
const prCommits = await resolvePrCommits(options.pr);
|
|
96
|
-
targetCommitish = prCommits.targetCommitish;
|
|
97
|
-
baseCommitish = prCommits.baseCommitish;
|
|
98
|
-
console.log(`📋 Reviewing PR: ${options.pr}`);
|
|
99
|
-
console.log(`🎯 Target commit: ${targetCommitish.substring(0, 7)}`);
|
|
100
|
-
console.log(`📍 Base commit: ${baseCommitish.substring(0, 7)}`);
|
|
101
|
-
}
|
|
102
|
-
catch (error) {
|
|
103
|
-
console.error(`Error resolving PR: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
104
|
-
process.exit(1);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
else if (compareWith) {
|
|
117
|
+
if (compareWith) {
|
|
108
118
|
// If compareWith is provided, use it as base
|
|
109
119
|
baseCommitish = compareWith;
|
|
110
120
|
}
|
|
@@ -143,15 +153,11 @@ program
|
|
|
143
153
|
}));
|
|
144
154
|
return;
|
|
145
155
|
}
|
|
146
|
-
|
|
147
|
-
if (!
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
console.error(`Error: ${validation.error}`);
|
|
151
|
-
process.exit(1);
|
|
152
|
-
}
|
|
156
|
+
const validation = validateDiffArguments(targetCommitish, compareWith);
|
|
157
|
+
if (!validation.valid) {
|
|
158
|
+
console.error(`Error: ${validation.error}`);
|
|
159
|
+
process.exit(1);
|
|
153
160
|
}
|
|
154
|
-
const diffMode = determineDiffMode(targetCommitish, compareWith);
|
|
155
161
|
const { url, port, isEmpty } = await startServer({
|
|
156
162
|
targetCommitish,
|
|
157
163
|
baseCommitish,
|
|
@@ -160,11 +166,15 @@ program
|
|
|
160
166
|
openBrowser: options.open,
|
|
161
167
|
mode: options.mode,
|
|
162
168
|
clearComments: options.clean,
|
|
163
|
-
|
|
169
|
+
keepAlive: options.keepAlive,
|
|
170
|
+
diffMode: determineDiffMode(targetCommitish, compareWith),
|
|
164
171
|
repoPath,
|
|
165
172
|
});
|
|
166
173
|
console.log(`\n🚀 difit server started on ${url}`);
|
|
167
174
|
console.log(`📋 Reviewing: ${targetCommitish}`);
|
|
175
|
+
if (options.keepAlive) {
|
|
176
|
+
console.log('🔒 Keep-alive mode: server will stay running after browser disconnects');
|
|
177
|
+
}
|
|
168
178
|
if (options.clean) {
|
|
169
179
|
console.log('🧹 Starting with a clean slate - all existing comments will be cleared');
|
|
170
180
|
}
|