difit 3.1.18 → 4.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 (100) hide show
  1. package/README.ja.md +44 -16
  2. package/README.ko.md +44 -16
  3. package/README.md +44 -16
  4. package/README.zh.md +44 -16
  5. package/dist/cli/github.d.ts +65 -0
  6. package/dist/cli/github.js +296 -0
  7. package/dist/cli/github.test.d.ts +1 -0
  8. package/dist/cli/github.test.js +341 -0
  9. package/dist/cli/index.js +42 -1
  10. package/dist/cli/index.test.js +330 -4
  11. package/dist/cli/utils.d.ts +2 -8
  12. package/dist/cli/utils.js +4 -43
  13. package/dist/cli/utils.test.js +50 -67
  14. package/dist/client/assets/{_basePickBy-DyiQWUmK.js → _basePickBy-ChXFkTMC.js} +1 -1
  15. package/dist/client/assets/{_baseUniq-DivSZEOF.js → _baseUniq-Mj_sFFQW.js} +1 -1
  16. package/dist/client/assets/{arc-c0kacVOL.js → arc-BMA6S9F1.js} +1 -1
  17. package/dist/client/assets/{architectureDiagram-2XIMDMQ5-ubymLNEe.js → architectureDiagram-2XIMDMQ5-0uiM_v5K.js} +1 -1
  18. package/dist/client/assets/{blockDiagram-WCTKOSBZ-F9D8w4_S.js → blockDiagram-WCTKOSBZ-CM7ZLL6F.js} +1 -1
  19. package/dist/client/assets/{c4Diagram-IC4MRINW-JE9Kx4yQ.js → c4Diagram-IC4MRINW-DKtCnVwn.js} +1 -1
  20. package/dist/client/assets/channel-D057yzDp.js +1 -0
  21. package/dist/client/assets/{chunk-4BX2VUAB-CYOCoDMc.js → chunk-4BX2VUAB-Wsl8DxEB.js} +1 -1
  22. package/dist/client/assets/{chunk-55IACEB6-PRBuiJg9.js → chunk-55IACEB6-CHm9X5i7.js} +1 -1
  23. package/dist/client/assets/{chunk-FMBD7UC4-C0eJ7JsI.js → chunk-FMBD7UC4-BSa8SHgd.js} +1 -1
  24. package/dist/client/assets/{chunk-JSJVCQXG-QZotPSqo.js → chunk-JSJVCQXG-Cpk76oJ3.js} +1 -1
  25. package/dist/client/assets/{chunk-KX2RTZJC-B8du3tt8.js → chunk-KX2RTZJC-D8YvfZVu.js} +1 -1
  26. package/dist/client/assets/{chunk-NQ4KR5QH-B10ldi5m.js → chunk-NQ4KR5QH-BogviJOv.js} +1 -1
  27. package/dist/client/assets/{chunk-QZHKN3VN-CpwW9rUQ.js → chunk-QZHKN3VN-DwLJYu26.js} +1 -1
  28. package/dist/client/assets/{chunk-WL4C6EOR-DwKPHpbL.js → chunk-WL4C6EOR-BFDpGxW2.js} +1 -1
  29. package/dist/client/assets/classDiagram-VBA2DB6C---D4iOts.js +1 -0
  30. package/dist/client/assets/classDiagram-v2-RAHNMMFH---D4iOts.js +1 -0
  31. package/dist/client/assets/clone-xSR3otEf.js +1 -0
  32. package/dist/client/assets/{cose-bilkent-S5V4N54A-p76yal75.js → cose-bilkent-S5V4N54A-oEosZ_5y.js} +1 -1
  33. package/dist/client/assets/{dagre-KLK3FWXG-CdDyed3V.js → dagre-KLK3FWXG-gFld4u1H.js} +1 -1
  34. package/dist/client/assets/{diagram-E7M64L7V-BaC8dXuW.js → diagram-E7M64L7V-gJq3kSrf.js} +1 -1
  35. package/dist/client/assets/{diagram-IFDJBPK2-BGf8xwJI.js → diagram-IFDJBPK2-BsUm_q22.js} +1 -1
  36. package/dist/client/assets/{diagram-P4PSJMXO-D3j16gBZ.js → diagram-P4PSJMXO-juB-sfcR.js} +1 -1
  37. package/dist/client/assets/{erDiagram-INFDFZHY-DFpDdocf.js → erDiagram-INFDFZHY-Dn77qXAt.js} +1 -1
  38. package/dist/client/assets/{flowDiagram-PKNHOUZH-Cz4mb4IF.js → flowDiagram-PKNHOUZH-DtmvDYdN.js} +1 -1
  39. package/dist/client/assets/{ganttDiagram-A5KZAMGK-CNzY9ua5.js → ganttDiagram-A5KZAMGK-BlDaKLbQ.js} +1 -1
  40. package/dist/client/assets/{gitGraphDiagram-K3NZZRJ6-DCSxL8EQ.js → gitGraphDiagram-K3NZZRJ6-DeAAeuMS.js} +1 -1
  41. package/dist/client/assets/{graph-BC2BV1-T.js → graph-NX9gBP47.js} +1 -1
  42. package/dist/client/assets/index-VxkpzDXr.css +1 -0
  43. package/dist/client/assets/index-kJdw4DY-.js +98 -0
  44. package/dist/client/assets/{infoDiagram-LFFYTUFH-BKSspZbH.js → infoDiagram-LFFYTUFH-CAaX023c.js} +1 -1
  45. package/dist/client/assets/{ishikawaDiagram-PHBUUO56-DZ2IRYwc.js → ishikawaDiagram-PHBUUO56-CmiTQStv.js} +1 -1
  46. package/dist/client/assets/{journeyDiagram-4ABVD52K-BrjXAkii.js → journeyDiagram-4ABVD52K-B0SHC7mz.js} +1 -1
  47. package/dist/client/assets/{kanban-definition-K7BYSVSG-B1mfOekw.js → kanban-definition-K7BYSVSG-IfRdhzz7.js} +1 -1
  48. package/dist/client/assets/{layout-CWTG02uT.js → layout-l3OdNQhJ.js} +1 -1
  49. package/dist/client/assets/{linear-CGgOKp1d.js → linear-CQ0hx5Qs.js} +1 -1
  50. package/dist/client/assets/{mermaid.core-DTPtVBG7.js → mermaid.core-DqlPTabt.js} +4 -4
  51. package/dist/client/assets/{mindmap-definition-YRQLILUH-DByVRPFT.js → mindmap-definition-YRQLILUH-DIgSmG_f.js} +1 -1
  52. package/dist/client/assets/{pieDiagram-SKSYHLDU-DEgvAxAy.js → pieDiagram-SKSYHLDU-FzM5qoIB.js} +1 -1
  53. package/dist/client/assets/{prism-csharp-DqTrHqwJ.js → prism-csharp-DCfUUOUs.js} +1 -1
  54. package/dist/client/assets/{prism-elixir-DEJaM00V.js → prism-elixir-riuOL1mm.js} +1 -1
  55. package/dist/client/assets/{prism-hcl-HvJ0aPiH.js → prism-hcl-CizuX1s4.js} +1 -1
  56. package/dist/client/assets/{prism-java-DDUFERTh.js → prism-java-DYCKrDUh.js} +1 -1
  57. package/dist/client/assets/{prism-perl-CNA3SNC9.js → prism-perl-BJwBYR3Y.js} +1 -1
  58. package/dist/client/assets/{prism-php-hBQuhE2A.js → prism-php-BMhFuA7y.js} +1 -1
  59. package/dist/client/assets/{prism-ruby-BKap8imy.js → prism-ruby-Bcu0cDEh.js} +1 -1
  60. package/dist/client/assets/{prism-solidity-DHc7LZHq.js → prism-solidity-DDDs3w-w.js} +1 -1
  61. package/dist/client/assets/{quadrantDiagram-337W2JSQ-DTtikTvc.js → quadrantDiagram-337W2JSQ-BBrApyD7.js} +1 -1
  62. package/dist/client/assets/{requirementDiagram-Z7DCOOCP-B34R-xD0.js → requirementDiagram-Z7DCOOCP-CLXiwUaA.js} +1 -1
  63. package/dist/client/assets/{sankeyDiagram-WA2Y5GQK-Dts1ZXRC.js → sankeyDiagram-WA2Y5GQK-9Y3Ly5qe.js} +1 -1
  64. package/dist/client/assets/{sequenceDiagram-2WXFIKYE-DzM3WhEY.js → sequenceDiagram-2WXFIKYE-DEpX1BA5.js} +1 -1
  65. package/dist/client/assets/{stateDiagram-RAJIS63D-B2dF8YnK.js → stateDiagram-RAJIS63D-Ck3ullwA.js} +1 -1
  66. package/dist/client/assets/stateDiagram-v2-FVOUBMTO-X6UiDsar.js +1 -0
  67. package/dist/client/assets/{timeline-definition-YZTLITO2-BO4OtcEm.js → timeline-definition-YZTLITO2-CMezf3XV.js} +1 -1
  68. package/dist/client/assets/{treemap-KZPCXAKY-DaXnvVRH.js → treemap-KZPCXAKY-DqrcV0gQ.js} +1 -1
  69. package/dist/client/assets/{vennDiagram-LZ73GAT5-AIMhd8Js.js → vennDiagram-LZ73GAT5-eQg945Fz.js} +1 -1
  70. package/dist/client/assets/{xychartDiagram-JWTSCODW-Ch6W1f7P.js → xychartDiagram-JWTSCODW-_hqdXeX1.js} +1 -1
  71. package/dist/client/index.html +2 -2
  72. package/dist/server/generated-file-check.js +113 -58
  73. package/dist/server/generated-file-check.test.js +2 -0
  74. package/dist/server/git-diff-tui.d.ts +1 -1
  75. package/dist/server/git-diff-tui.js +7 -5
  76. package/dist/server/git-diff-tui.test.d.ts +1 -0
  77. package/dist/server/git-diff-tui.test.js +60 -0
  78. package/dist/server/git-diff.d.ts +4 -1
  79. package/dist/server/git-diff.js +73 -9
  80. package/dist/server/git-diff.test.js +46 -0
  81. package/dist/server/server.d.ts +3 -0
  82. package/dist/server/server.js +111 -37
  83. package/dist/server/server.test.js +152 -0
  84. package/dist/tui/App.d.ts +1 -0
  85. package/dist/tui/App.js +2 -2
  86. package/dist/types/diff.d.ts +74 -14
  87. package/dist/utils/commentFormatting.d.ts +4 -2
  88. package/dist/utils/commentFormatting.js +57 -19
  89. package/dist/utils/commentImports.d.ts +9 -0
  90. package/dist/utils/commentImports.js +264 -0
  91. package/dist/utils/commentImports.test.d.ts +1 -0
  92. package/dist/utils/commentImports.test.js +197 -0
  93. package/package.json +1 -1
  94. package/dist/client/assets/channel-Ca4c0q8d.js +0 -1
  95. package/dist/client/assets/classDiagram-VBA2DB6C-CJLw9sK7.js +0 -1
  96. package/dist/client/assets/classDiagram-v2-RAHNMMFH-CJLw9sK7.js +0 -1
  97. package/dist/client/assets/clone-D0mDLEir.js +0 -1
  98. package/dist/client/assets/index-DHt9OwVU.css +0 -1
  99. package/dist/client/assets/index-mE8CA51x.js +0 -95
  100. package/dist/client/assets/stateDiagram-v2-FVOUBMTO-ReD0hBzH.js +0 -1
package/README.ja.md CHANGED
@@ -28,9 +28,14 @@ difit # 最新コミットのdiffをWebUIで表示
28
28
  AIエージェントから使えるようにする
29
29
 
30
30
  ```bash
31
- npx skills add yoshiko-pg/difit # エージェントにスキルを追加
31
+ npx skills add yoshiko-pg/difit # エージェントにスキル群を追加
32
32
  ```
33
33
 
34
+ インストールされる主な skill:
35
+
36
+ - `difit`: コード変更後に difit を使ってユーザーへレビューを依頼する
37
+ - `difit-review`: 特定の diff や PR をレビューし、指摘や解説をコメントとして事前投入した difit を起動する
38
+
34
39
  ## 🚀 使い方
35
40
 
36
41
  ### 基本的な使い方
@@ -73,6 +78,7 @@ difit --pr https://github.com/owner/repo/pull/123
73
78
  ```
74
79
 
75
80
  `--pr` モードでは、内部で `gh pr diff --patch` を実行してパッチを取得します。
81
+ 加えて、PR 上の未解決 inline review thread も起動時コメントとして取り込み、difit 上でそのまま表示します。
76
82
 
77
83
  認証は GitHub CLI が処理します:
78
84
 
@@ -86,6 +92,21 @@ Enterprise Server の PR を表示する場合は、GitHub CLI を Enterprise
86
92
  1. `gh auth login --hostname YOUR-ENTERPRISE-SERVER`
87
93
  2. または `GH_HOST=YOUR-ENTERPRISE-SERVER` と `GH_TOKEN` / `GITHUB_TOKEN` を設定
88
94
 
95
+ ### 起動時コメント注入
96
+
97
+ difit の起動時に初期コメントを注入できます。
98
+
99
+ ```bash
100
+ difit --comment '{"type":"thread","filePath":"src/example.ts","position":{"side":"new","line":10},"body":"この変更の背景は…"}'
101
+ ```
102
+
103
+ `--comment` は複数回指定でき、単一の JSON object と JSON array の両方を受け付けます。対応する type は次の 2 種類です。
104
+
105
+ - `thread`: 指定位置に新しい thread を追加
106
+ - `reply`: 同じ位置にある最新 thread に reply を追加
107
+
108
+ 同じコメントが既に存在する場合は import をスキップします。
109
+
89
110
  ### 標準入力
90
111
 
91
112
  パイプを使用して標準入力経由で統一diff形式を渡すことで、任意のツールからのdiffをdifitで表示できます。
@@ -115,19 +136,21 @@ git diff --cached | difit -
115
136
 
116
137
  ## ⚙️ CLIオプション
117
138
 
118
- | フラグ | デフォルト | 説明 |
119
- | --------------------- | ---------- | --------------------------------------------------------------------------------- |
120
- | `<target>` | HEAD | コミットハッシュ、タグ、HEAD~n、ブランチ、または特別な引数 |
121
- | `[compare-with]` | - | 比較対象の2番目のコミット(2つの間のdiffを表示) |
122
- | `--pr <url>` | - | レビューするGitHub PRのURL(例:https://github.com/owner/repo/pull/123) |
123
- | `--port` | 4966 | 優先ポート。使用中の場合は+1にフォールバック |
124
- | `--host` | 127.0.0.1 | サーバーをバインドするホストアドレス(外部からアクセスしたい場合は0.0.0.0を指定) |
125
- | `--no-open` | false | ブラウザを自動的に開かない |
126
- | `--mode` | split | 表示モード。`unified`または`split` |
127
- | `--tui` | false | WebUIの代わりにターミナルUIを使用 |
128
- | `--clean` | false | 起動時に既存コメントと閲覧済みファイルをすべてクリア |
129
- | `--include-untracked` | false | diffにuntrackedファイルを自動的に含める(`.`または`working`のみ有効) |
130
- | `--keep-alive` | false | ブラウザ切断後もサーバーを終了せず起動したままにする(Ctrl+Cで手動停止) |
139
+ | フラグ | デフォルト | 説明 |
140
+ | --------------------- | --------------- | ------------------------------------------------------------------------------------------ |
141
+ | `<target>` | HEAD | コミットハッシュ、タグ、HEAD~n、ブランチ、または特別な引数 |
142
+ | `[compare-with]` | - | 比較対象の2番目のコミット(2つの間のdiffを表示) |
143
+ | `--pr <url>` | - | レビューするGitHub PRのURL(例:https://github.com/owner/repo/pull/123) |
144
+ | `--comment <json>` | - | 起動時に初期コメントを注入(複数指定可。JSON object または array を受け付ける) |
145
+ | `--port` | 4966 | 優先ポート。使用中の場合は+1にフォールバック |
146
+ | `--host` | 127.0.0.1 | サーバーをバインドするホストアドレス(外部からアクセスしたい場合は0.0.0.0を指定) |
147
+ | `--no-open` | false | ブラウザを自動的に開かない |
148
+ | `--mode` | split | 表示モード。`unified`または`split` |
149
+ | `--tui` | false | WebUIの代わりにターミナルUIを使用 |
150
+ | `--clean` | false | 起動時に既存コメントと閲覧済みファイルをすべてクリア |
151
+ | `--include-untracked` | false | diffにuntrackedファイルを自動的に含める(`.`または`working`のみ有効) |
152
+ | `--keep-alive` | false | ブラウザ切断後もサーバーを終了せず起動したままにする(Ctrl+Cで手動停止) |
153
+ | `--context <lines>` | Gitの既定値 (3) | 変更ごとの前後コンテキスト行数を制限(`0` は変更行のみ表示。`--pr` と stdin では使用不可) |
131
154
 
132
155
  ## 💬 コメントシステム
133
156
 
@@ -155,13 +178,18 @@ src/components/Button.tsx:L42-L48 # この行が自動的に追加されます
155
178
 
156
179
  ## 🤖 エージェントからの呼び出し
157
180
 
158
- difitを利用してユーザーにレビューを依頼するSkillを以下でインストールできます。
181
+ AIエージェントから difit を使うための skill 群を以下でインストールできます。
159
182
 
160
183
  ```sh
161
184
  npx skills add yoshiko-pg/difit
162
185
  ```
163
186
 
164
- エージェントがコードを編集したあと、difitサーバーを立ち上げるようになります。
187
+ インストールされる主な skill:
188
+
189
+ - `difit`: コード変更後に difit を使ってユーザーへレビューを依頼する
190
+ - `difit-review`: 特定の diff や PR をレビューし、指摘や解説をコメントとして事前投入した difit を起動する
191
+
192
+ コード編集後や自動レビュー時に、目的に応じた skill で difit サーバーを起動できます。
165
193
 
166
194
  ## 🎨 シンタックスハイライト対応言語
167
195
 
package/README.ko.md CHANGED
@@ -28,9 +28,14 @@ difit # WebUI에서 최신 커밋 diff 보기
28
28
  AI 에이전트에서 사용할 수 있도록 설정
29
29
 
30
30
  ```bash
31
- npx skills add yoshiko-pg/difit # 에이전트에 Skill 추가
31
+ npx skills add yoshiko-pg/difit # 에이전트에 Skill 추가
32
32
  ```
33
33
 
34
+ 설치되는 주요 Skill:
35
+
36
+ - `difit`: 코드 변경 후 difit을 통해 사용자에게 리뷰를 요청
37
+ - `difit-review`: 특정 diff 또는 PR을 검토하고, 지적사항이나 설명을 코멘트로 미리 넣은 difit을 실행
38
+
34
39
  ## 🚀 사용법
35
40
 
36
41
  ### 기본 사용법
@@ -73,6 +78,7 @@ difit --pr https://github.com/owner/repo/pull/123
73
78
  ```
74
79
 
75
80
  `--pr` 모드는 내부적으로 `gh pr diff --patch`를 실행해 패치를 가져옵니다.
81
+ 추가로 PR의 unresolved inline review thread도 시작 코멘트로 가져와 difit에서 그대로 표시합니다.
76
82
 
77
83
  인증은 GitHub CLI가 처리합니다:
78
84
 
@@ -86,6 +92,21 @@ Enterprise Server PR의 경우 GitHub CLI를 Enterprise 호스트에 인증하
86
92
  1. `gh auth login --hostname YOUR-ENTERPRISE-SERVER`
87
93
  2. 또는 `GH_HOST=YOUR-ENTERPRISE-SERVER`와 `GH_TOKEN`/`GITHUB_TOKEN` 설정
88
94
 
95
+ ### 시작 시 코멘트 주입
96
+
97
+ difit 실행 시 초기 리뷰 코멘트를 주입할 수 있습니다:
98
+
99
+ ```bash
100
+ difit --comment '{"type":"thread","filePath":"src/example.ts","position":{"side":"new","line":10},"body":"이 변경의 배경은..."}'
101
+ ```
102
+
103
+ `--comment` 는 여러 번 지정할 수 있으며, 단일 JSON object 와 JSON array 둘 다 받을 수 있습니다. 지원하는 타입은 다음과 같습니다:
104
+
105
+ - `thread`: 지정한 diff 위치에 새 thread 생성
106
+ - `reply`: 같은 diff 위치에 있는 가장 최신 thread 에 reply 추가
107
+
108
+ 같은 코멘트가 이미 있으면 difit 이 import 를 건너뜁니다.
109
+
89
110
  ### 표준 입력
90
111
 
91
112
  파이프를 사용하여 표준 입력을 통해 통합 diff를 전달하면 모든 도구의 diff를 difit으로 볼 수 있습니다.
@@ -115,19 +136,21 @@ git diff --cached | difit -
115
136
 
116
137
  ## ⚙️ CLI 옵션
117
138
 
118
- | 플래그 | 기본값 | 설명 |
119
- | --------------------- | --------- | ----------------------------------------------------------------- |
120
- | `<target>` | HEAD | 커밋 해시, 태그, HEAD~n, 브랜치 또는 특수 인수 |
121
- | `[compare-with]` | - | 비교할 선택적 두 번째 커밋 (둘 사이의 diff 표시) |
122
- | `--pr <url>` | - | 검토할 GitHub PR URL (예: https://github.com/owner/repo/pull/123) |
123
- | `--port` | 4966 | 선호 포트; 사용 중인 경우 +1로 대체 |
124
- | `--host` | 127.0.0.1 | 서버를 바인딩할 호스트 주소 (외부 액세스는 0.0.0.0 사용) |
125
- | `--no-open` | false | 브라우저를 자동으로 열지 않음 |
126
- | `--mode` | split | 표시 모드: `unified` 또는 `split` |
127
- | `--tui` | false | WebUI 대신 터미널 UI 모드 사용 |
128
- | `--clean` | false | 시작 모든 기존 코멘트와 열람된 파일 표시 초기화 |
129
- | `--include-untracked` | false | diff에 untracked 파일 자동 포함 (`.` 또는 `working`에서만 유효) |
130
- | `--keep-alive` | false | 브라우저 연결이 끊겨도 서버 유지 (Ctrl+C로 수동 종료) |
139
+ | 플래그 | 기본값 | 설명 |
140
+ | --------------------- | -------------- | --------------------------------------------------------------------------------------------- |
141
+ | `<target>` | HEAD | 커밋 해시, 태그, HEAD~n, 브랜치 또는 특수 인수 |
142
+ | `[compare-with]` | - | 비교할 선택적 두 번째 커밋 (둘 사이의 diff 표시) |
143
+ | `--pr <url>` | - | 검토할 GitHub PR URL (예: https://github.com/owner/repo/pull/123) |
144
+ | `--comment <json>` | - | 초기 코멘트 주입 (반복 가능; JSON object 또는 array 허용) |
145
+ | `--port` | 4966 | 선호 포트; 사용 중인 경우 +1로 대체 |
146
+ | `--host` | 127.0.0.1 | 서버를 바인딩할 호스트 주소 (외부 액세스는 0.0.0.0 사용) |
147
+ | `--no-open` | false | 브라우저를 자동으로 열지 않음 |
148
+ | `--mode` | split | 표시 모드: `unified` 또는 `split` |
149
+ | `--tui` | false | WebUI 대신 터미널 UI 모드 사용 |
150
+ | `--clean` | false | 시작 모든 기존 코멘트와 열람된 파일 표시 초기화 |
151
+ | `--include-untracked` | false | diff에 untracked 파일 자동 포함 (`.` 또는 `working`에서만 유효) |
152
+ | `--keep-alive` | false | 브라우저 연결이 끊겨도 서버 유지 (Ctrl+C로 수동 종료) |
153
+ | `--context <lines>` | Git 기본값 (3) | 변경 주변의 컨텍스트 줄 수를 제한 (`0`이면 변경된 줄만 표시, `--pr` 및 stdin에서는 사용 불가) |
131
154
 
132
155
  ## 💬 코멘트 시스템
133
156
 
@@ -155,13 +178,18 @@ src/components/Button.tsx:L42-L48 # 이 줄은 자동으로 추가됩니다
155
178
 
156
179
  ## 🤖 에이전트에서 호출
157
180
 
158
- difit을 사용해 사용자에게 리뷰를 요청하는 Skill 아래 명령으로 설치할 수 있습니다:
181
+ AI 에이전트에서 difit을 사용하기 위한 Skill들은 아래 명령으로 설치할 수 있습니다:
159
182
 
160
183
  ```sh
161
184
  npx skills add yoshiko-pg/difit
162
185
  ```
163
186
 
164
- 에이전트가 코드를 수정한 뒤에는 difit 서버를 실행합니다.
187
+ 설치되는 주요 Skill:
188
+
189
+ - `difit`: 코드 변경 후 difit을 통해 사용자에게 리뷰를 요청
190
+ - `difit-review`: 특정 diff 또는 PR을 검토하고, 지적사항이나 설명을 코멘트로 미리 넣은 difit을 실행
191
+
192
+ 코드 수정 후나 자동 리뷰 시, 목적에 맞는 Skill로 difit 서버를 실행할 수 있습니다.
165
193
 
166
194
  ## 🎨 구문 강조 언어
167
195
 
package/README.md CHANGED
@@ -28,9 +28,14 @@ difit # View the latest commit diff in WebUI
28
28
  Enable use from AI agents
29
29
 
30
30
  ```bash
31
- npx skills add yoshiko-pg/difit # Add the Skill to your agent
31
+ npx skills add yoshiko-pg/difit # Add the Skills to your agent
32
32
  ```
33
33
 
34
+ Installed skills include:
35
+
36
+ - `difit`: ask the user for a review through difit after code changes
37
+ - `difit-review`: review a specific diff or PR and launch difit with findings or explanations preloaded as comments
38
+
34
39
  ## 🚀 Usage
35
40
 
36
41
  ### Basic Usage
@@ -73,6 +78,7 @@ difit --pr https://github.com/owner/repo/pull/123
73
78
  ```
74
79
 
75
80
  `--pr` mode fetches patches by running `gh pr diff --patch` under the hood.
81
+ It also imports unresolved inline review threads from the PR so they appear as startup comments in difit.
76
82
 
77
83
  Authentication is handled by GitHub CLI:
78
84
 
@@ -86,6 +92,21 @@ For Enterprise Server PRs, authenticate GitHub CLI against your Enterprise host:
86
92
  1. `gh auth login --hostname YOUR-ENTERPRISE-SERVER`
87
93
  2. Or set `GH_HOST=YOUR-ENTERPRISE-SERVER` with `GH_TOKEN`/`GITHUB_TOKEN`
88
94
 
95
+ ### Initial Comments
96
+
97
+ You can inject initial review comments when launching difit:
98
+
99
+ ```bash
100
+ difit --comment '{"type":"thread","filePath":"src/example.ts","position":{"side":"new","line":10},"body":"The background for this change is..."}'
101
+ ```
102
+
103
+ `--comment` is repeatable and accepts either a single JSON object or a JSON array. Supported types:
104
+
105
+ - `thread`: create a new thread at the specified diff position
106
+ - `reply`: add a reply to the latest existing thread at the same diff position
107
+
108
+ If the same comment already exists, difit skips importing it.
109
+
89
110
  ### Stdin
90
111
 
91
112
  By using a pipe to pass unified diffs via stdin, you can view diffs from any tool with difit.
@@ -115,19 +136,21 @@ Stdin mode is selected with intent-first rules:
115
136
 
116
137
  ## ⚙️ CLI Options
117
138
 
118
- | Flag | Default | Description |
119
- | --------------------- | --------- | -------------------------------------------------------------------------- |
120
- | `<target>` | HEAD | Commit hash, tag, HEAD~n, branch, or special arguments |
121
- | `[compare-with]` | - | Optional second commit to compare with (shows diff between the two) |
122
- | `--pr <url>` | - | GitHub PR URL to review (e.g., https://github.com/owner/repo/pull/123) |
123
- | `--port` | 4966 | Preferred port; falls back to +1 if occupied |
124
- | `--host` | 127.0.0.1 | Host address to bind server to (use 0.0.0.0 for external access) |
125
- | `--no-open` | false | Don't automatically open browser |
126
- | `--mode` | split | Display mode: `unified` or `split` |
127
- | `--tui` | false | Use terminal UI mode instead of WebUI |
128
- | `--clean` | false | Clear all existing comments and viewed files on startup |
129
- | `--include-untracked` | false | Automatically include untracked files in diff (only with `.` or `working`) |
130
- | `--keep-alive` | false | Keep server running after browser disconnects (stop manually with Ctrl+C) |
139
+ | Flag | Default | Description |
140
+ | --------------------- | --------------- | ------------------------------------------------------------------------------------------------------- |
141
+ | `<target>` | HEAD | Commit hash, tag, HEAD~n, branch, or special arguments |
142
+ | `[compare-with]` | - | Optional second commit to compare with (shows diff between the two) |
143
+ | `--pr <url>` | - | GitHub PR URL to review (e.g., https://github.com/owner/repo/pull/123) |
144
+ | `--comment <json>` | - | Inject initial comments (repeatable; accepts a JSON object or array) |
145
+ | `--port` | 4966 | Preferred port; falls back to +1 if occupied |
146
+ | `--host` | 127.0.0.1 | Host address to bind server to (use 0.0.0.0 for external access) |
147
+ | `--no-open` | false | Don't automatically open browser |
148
+ | `--mode` | split | Display mode: `unified` or `split` |
149
+ | `--tui` | false | Use terminal UI mode instead of WebUI |
150
+ | `--clean` | false | Clear all existing comments and viewed files on startup |
151
+ | `--include-untracked` | false | Automatically include untracked files in diff (only with `.` or `working`) |
152
+ | `--keep-alive` | false | Keep server running after browser disconnects (stop manually with Ctrl+C) |
153
+ | `--context <lines>` | git default (3) | Limit surrounding context lines per change (`0` shows changes only; not available with `--pr` or stdin) |
131
154
 
132
155
  ## 💬 Comment System
133
156
 
@@ -155,13 +178,18 @@ This section is unnecessary
155
178
 
156
179
  ## 🤖 Calling from Agents
157
180
 
158
- You can install the following Skill to request reviews from users with difit.
181
+ You can install the following Skills to work with difit from AI agents.
159
182
 
160
183
  ```sh
161
184
  npx skills add yoshiko-pg/difit
162
185
  ```
163
186
 
164
- After an agent edits code, it will start the difit server.
187
+ Installed skills include:
188
+
189
+ - `difit`: ask the user for a review through difit after code changes
190
+ - `difit-review`: review a specific diff or PR and launch difit with findings or explanations preloaded as comments
191
+
192
+ After code edits or automated review, the agent can start the difit server with the appropriate skill.
165
193
 
166
194
  ## 🎨 Syntax Highlighting Languages
167
195
 
package/README.zh.md CHANGED
@@ -28,9 +28,14 @@ difit # 在 WebUI 中查看最新提交的差异
28
28
  使其可供 AI 代理使用
29
29
 
30
30
  ```bash
31
- npx skills add yoshiko-pg/difit # 为代理添加 Skill
31
+ npx skills add yoshiko-pg/difit # 为代理添加 Skills
32
32
  ```
33
33
 
34
+ 安装后包含的主要 Skill:
35
+
36
+ - `difit`:在代码修改后通过 difit 向用户请求审查
37
+ - `difit-review`:审查特定 diff 或 PR,并启动一个已预载评论或说明的 difit
38
+
34
39
  ## 🚀 使用方法
35
40
 
36
41
  ### 基本用法
@@ -73,6 +78,7 @@ difit --pr https://github.com/owner/repo/pull/123
73
78
  ```
74
79
 
75
80
  `--pr` 模式会在内部执行 `gh pr diff --patch` 来获取补丁。
81
+ 同时还会导入 PR 中未解决的 inline review thread,并在 difit 中作为启动评论显示出来。
76
82
 
77
83
  认证由 GitHub CLI 处理:
78
84
 
@@ -86,6 +92,21 @@ difit --pr https://github.com/owner/repo/pull/123
86
92
  1. `gh auth login --hostname YOUR-ENTERPRISE-SERVER`
87
93
  2. 或设置 `GH_HOST=YOUR-ENTERPRISE-SERVER`,并配置 `GH_TOKEN` / `GITHUB_TOKEN`
88
94
 
95
+ ### 启动时注入评论
96
+
97
+ 你可以在启动 difit 时注入初始审查评论:
98
+
99
+ ```bash
100
+ difit --comment '{"type":"thread","filePath":"src/example.ts","position":{"side":"new","line":10},"body":"这次修改的背景是……"}'
101
+ ```
102
+
103
+ `--comment` 可重复指定,同时接受单个 JSON object 或 JSON array。支持的类型如下:
104
+
105
+ - `thread`:在指定 diff 位置创建新的 thread
106
+ - `reply`:向相同 diff 位置上最新的现有 thread 添加 reply
107
+
108
+ 如果相同评论已经存在,difit 会跳过导入。
109
+
89
110
  ### 标准输入
90
111
 
91
112
  通过使用管道通过标准输入传递统一差异,您可以使用 difit 查看来自任何工具的差异。
@@ -115,19 +136,21 @@ git diff --cached | difit -
115
136
 
116
137
  ## ⚙️ CLI 选项
117
138
 
118
- | 标志 | 默认值 | 描述 |
119
- | --------------------- | --------- | ---------------------------------------------------------------------- |
120
- | `<target>` | HEAD | 提交哈希、标签、HEAD~n、分支或特殊参数 |
121
- | `[compare-with]` | - | 要比较的可选第二个提交(显示两者之间的差异) |
122
- | `--pr <url>` | - | 要审查的 GitHub PR URL(例如:https://github.com/owner/repo/pull/123) |
123
- | `--port` | 4966 | 首选端口;如果被占用则回退到 +1 |
124
- | `--host` | 127.0.0.1 | 绑定服务器的主机地址(使用 0.0.0.0 进行外部访问) |
125
- | `--no-open` | false | 不自动打开浏览器 |
126
- | `--mode` | split | 显示模式:`unified` 或 `split` |
127
- | `--tui` | false | 使用终端 UI 模式而不是 WebUI |
128
- | `--clean` | false | 启动时清除所有现有评论和已查看的文件 |
129
- | `--include-untracked` | false | 自动将 untracked 文件包含在 diff 中(仅在 `.` 或 `working` 时有效) |
130
- | `--keep-alive` | false | 浏览器断开后保持服务器运行(使用 Ctrl+C 手动停止) |
139
+ | 标志 | 默认值 | 描述 |
140
+ | --------------------- | -------------- | --------------------------------------------------------------------------------- |
141
+ | `<target>` | HEAD | 提交哈希、标签、HEAD~n、分支或特殊参数 |
142
+ | `[compare-with]` | - | 要比较的可选第二个提交(显示两者之间的差异) |
143
+ | `--pr <url>` | - | 要审查的 GitHub PR URL(例如:https://github.com/owner/repo/pull/123) |
144
+ | `--comment <json>` | - | 注入初始评论(可重复指定;接受 JSON object 或 array) |
145
+ | `--port` | 4966 | 首选端口;如果被占用则回退到 +1 |
146
+ | `--host` | 127.0.0.1 | 绑定服务器的主机地址(使用 0.0.0.0 进行外部访问) |
147
+ | `--no-open` | false | 不自动打开浏览器 |
148
+ | `--mode` | split | 显示模式:`unified` `split` |
149
+ | `--tui` | false | 使用终端 UI 模式而不是 WebUI |
150
+ | `--clean` | false | 启动时清除所有现有评论和已查看的文件 |
151
+ | `--include-untracked` | false | 自动将 untracked 文件包含在 diff 中(仅在 `.` 或 `working` 时有效) |
152
+ | `--keep-alive` | false | 浏览器断开后保持服务器运行(使用 Ctrl+C 手动停止) |
153
+ | `--context <lines>` | Git 默认值 (3) | 限制每处变更周围的上下文行数(`0` 仅显示变更行;不可与 `--pr` 或 stdin 一起使用) |
131
154
 
132
155
  ## 💬 评论系统
133
156
 
@@ -155,13 +178,18 @@ src/components/Button.tsx:L42-L48 # 此行自动添加
155
178
 
156
179
  ## 🤖 从代理调用
157
180
 
158
- 你可以通过以下命令安装 Skill,以便使用 difit 向用户请求审查:
181
+ 你可以通过以下命令安装这些 Skill,以便从 AI 代理中使用 difit
159
182
 
160
183
  ```sh
161
184
  npx skills add yoshiko-pg/difit
162
185
  ```
163
186
 
164
- 代理编辑代码后,将会启动 difit 服务器。
187
+ 安装后包含的主要 Skill:
188
+
189
+ - `difit`:在代码修改后通过 difit 向用户请求审查
190
+ - `difit-review`:审查特定 diff 或 PR,并启动一个已预载评论或说明的 difit
191
+
192
+ 在代码修改后或自动审查时,代理可以根据目的使用对应的 Skill 来启动 difit 服务器。
165
193
 
166
194
  ## 🎨 语法高亮语言
167
195
 
@@ -0,0 +1,65 @@
1
+ import type { CommentImport } from '../types/diff.js';
2
+ interface PullRequestInfo {
3
+ owner: string;
4
+ repo: string;
5
+ pullNumber: number;
6
+ hostname: string;
7
+ }
8
+ interface GitHubReviewThreadAuthor {
9
+ login?: string | null;
10
+ }
11
+ interface GitHubReviewThreadCommentNode {
12
+ id?: string | null;
13
+ body?: string | null;
14
+ createdAt?: string | null;
15
+ updatedAt?: string | null;
16
+ author?: GitHubReviewThreadAuthor | null;
17
+ }
18
+ interface GitHubReviewThreadNode {
19
+ id?: string | null;
20
+ isResolved?: boolean | null;
21
+ isOutdated?: boolean | null;
22
+ subjectType?: string | null;
23
+ path?: string | null;
24
+ diffSide?: string | null;
25
+ startDiffSide?: string | null;
26
+ line?: number | null;
27
+ startLine?: number | null;
28
+ originalLine?: number | null;
29
+ originalStartLine?: number | null;
30
+ comments?: {
31
+ nodes?: GitHubReviewThreadCommentNode[] | null;
32
+ } | null;
33
+ }
34
+ interface GitHubReviewThreadsPageInfo {
35
+ hasNextPage?: boolean | null;
36
+ endCursor?: string | null;
37
+ }
38
+ interface GitHubReviewThreadsConnection {
39
+ nodes?: GitHubReviewThreadNode[] | null;
40
+ pageInfo?: GitHubReviewThreadsPageInfo | null;
41
+ }
42
+ interface GitHubReviewThreadsGraphqlResponse {
43
+ data?: {
44
+ repository?: {
45
+ pullRequest?: {
46
+ reviewThreads?: GitHubReviewThreadsConnection | null;
47
+ } | null;
48
+ } | null;
49
+ } | null;
50
+ errors?: Array<{
51
+ message?: string | null;
52
+ }> | null;
53
+ }
54
+ interface PrCommentImportsPage {
55
+ commentImports: CommentImport[];
56
+ pageInfo: {
57
+ hasNextPage: boolean;
58
+ endCursor: string | null;
59
+ };
60
+ }
61
+ export declare function parseGitHubPrUrl(url: string): PullRequestInfo | null;
62
+ export declare function getPrPatch(prArg: string): string;
63
+ export declare function parsePrCommentImportsResponse(response: GitHubReviewThreadsGraphqlResponse): PrCommentImportsPage;
64
+ export declare function getPrCommentImports(prArg: string): Promise<CommentImport[]>;
65
+ export {};