@335g/pi-git 0.0.1 → 0.0.3
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 +2 -29
- package/README.md +2 -29
- package/dist/commands/agg-commit.d.ts.map +1 -1
- package/dist/commands/agg-commit.js +11 -16
- package/dist/commands/agg-commit.js.map +1 -1
- package/dist/commands/auto-agg-commit.d.ts.map +1 -1
- package/dist/commands/auto-agg-commit.js +36 -68
- package/dist/commands/auto-agg-commit.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +46 -69
- package/dist/commands/config.js.map +1 -1
- package/dist/core/auto-commit-message.d.ts +2 -2
- package/dist/core/auto-commit-message.d.ts.map +1 -1
- package/dist/core/auto-commit-message.js +259 -34
- package/dist/core/auto-commit-message.js.map +1 -1
- package/dist/core/auto-commit.d.ts.map +1 -1
- package/dist/core/auto-commit.js +3 -6
- package/dist/core/auto-commit.js.map +1 -1
- package/dist/core/diff-analyzer.d.ts +2 -10
- package/dist/core/diff-analyzer.d.ts.map +1 -1
- package/dist/core/diff-analyzer.js +190 -71
- package/dist/core/diff-analyzer.js.map +1 -1
- package/dist/core/git.d.ts +0 -25
- package/dist/core/git.d.ts.map +1 -1
- package/dist/core/git.js +0 -65
- package/dist/core/git.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -21
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +0 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/footer-manager.d.ts +11 -0
- package/dist/utils/footer-manager.d.ts.map +1 -1
- package/dist/utils/footer-manager.js +52 -11
- package/dist/utils/footer-manager.js.map +1 -1
- package/dist/utils/lang.d.ts +3 -2
- package/dist/utils/lang.d.ts.map +1 -1
- package/dist/utils/lang.js +3 -2
- package/dist/utils/lang.js.map +1 -1
- package/package.json +1 -1
- package/dist/commands/branch.d.ts +0 -8
- package/dist/commands/branch.d.ts.map +0 -1
- package/dist/commands/branch.js +0 -197
- package/dist/commands/branch.js.map +0 -1
- package/dist/commands/git-diff.d.ts +0 -10
- package/dist/commands/git-diff.d.ts.map +0 -1
- package/dist/commands/git-diff.js +0 -228
- package/dist/commands/git-diff.js.map +0 -1
- package/dist/commands/git-log.d.ts +0 -8
- package/dist/commands/git-log.d.ts.map +0 -1
- package/dist/commands/git-log.js +0 -100
- package/dist/commands/git-log.js.map +0 -1
- package/dist/tui/hunk-review.d.ts +0 -49
- package/dist/tui/hunk-review.d.ts.map +0 -1
- package/dist/tui/hunk-review.js +0 -300
- package/dist/tui/hunk-review.js.map +0 -1
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Singleton instance is exported as `footerManager`.
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
10
|
+
import { t } from "./lang.js";
|
|
11
11
|
import { getAutoAggCommit, getLanguage } from "./settings.js";
|
|
12
12
|
const STATUS_KEY = "pi-git-agg-commit";
|
|
13
13
|
/**
|
|
@@ -20,6 +20,7 @@ class FooterManager {
|
|
|
20
20
|
ui = null;
|
|
21
21
|
cwd;
|
|
22
22
|
running = null;
|
|
23
|
+
elapsedTimer = null;
|
|
23
24
|
/**
|
|
24
25
|
* Initialize the manager with pi API, UI context, and working directory.
|
|
25
26
|
* Call this once at session_start.
|
|
@@ -75,7 +76,8 @@ class FooterManager {
|
|
|
75
76
|
async setRunning(command, phase, lang) {
|
|
76
77
|
if (!this.ui)
|
|
77
78
|
return;
|
|
78
|
-
this.running = { command, phase, lang };
|
|
79
|
+
this.running = { command, phase, lang, phaseStartedAt: Date.now() };
|
|
80
|
+
this.startElapsedTimer();
|
|
79
81
|
this.renderPhase();
|
|
80
82
|
}
|
|
81
83
|
/**
|
|
@@ -89,15 +91,31 @@ class FooterManager {
|
|
|
89
91
|
if (!this.ui || !this.running)
|
|
90
92
|
return;
|
|
91
93
|
this.running.phase = phase;
|
|
94
|
+
this.running.phaseStartedAt = Date.now();
|
|
95
|
+
this.running.commitCurrent = undefined;
|
|
96
|
+
this.running.commitTotal = undefined;
|
|
92
97
|
if (lang !== undefined) {
|
|
93
98
|
this.running.lang = lang;
|
|
94
99
|
}
|
|
95
100
|
this.renderPhase();
|
|
96
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Set commit progress for the current phase.
|
|
104
|
+
* @param current - Current hunk index (1-based)
|
|
105
|
+
* @param total - Total number of hunks
|
|
106
|
+
*/
|
|
107
|
+
async setCommitProgress(current, total) {
|
|
108
|
+
if (!this.ui || !this.running)
|
|
109
|
+
return;
|
|
110
|
+
this.running.commitCurrent = current;
|
|
111
|
+
this.running.commitTotal = total;
|
|
112
|
+
this.renderPhase();
|
|
113
|
+
}
|
|
97
114
|
/**
|
|
98
115
|
* End the running display. Clears the running flag and refreshes base display.
|
|
99
116
|
*/
|
|
100
117
|
async clearRunning() {
|
|
118
|
+
this.stopElapsedTimer();
|
|
101
119
|
this.running = null;
|
|
102
120
|
await this.refresh();
|
|
103
121
|
}
|
|
@@ -109,28 +127,51 @@ class FooterManager {
|
|
|
109
127
|
return;
|
|
110
128
|
const lang = this.running.lang ?? getLanguage(this.cwd);
|
|
111
129
|
const autoCommit = this.running.command === "auto-commit";
|
|
112
|
-
|
|
130
|
+
const elapsed = Math.floor((Date.now() - this.running.phaseStartedAt) / 1000);
|
|
131
|
+
let status = phaseStatusText(lang, this.running.phase, autoCommit);
|
|
132
|
+
// Append commit progress if available
|
|
133
|
+
if (this.running.commitCurrent !== undefined &&
|
|
134
|
+
this.running.commitTotal !== undefined) {
|
|
135
|
+
status += ` (${this.running.commitCurrent}/${this.running.commitTotal})`;
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
// Show elapsed time for phases that take a while
|
|
139
|
+
status += ` (${elapsed}s)`;
|
|
140
|
+
}
|
|
141
|
+
this.ui.setStatus(STATUS_KEY, status);
|
|
142
|
+
}
|
|
143
|
+
/** Start a periodic timer to refresh the elapsed-time display */
|
|
144
|
+
startElapsedTimer() {
|
|
145
|
+
this.stopElapsedTimer();
|
|
146
|
+
this.elapsedTimer = setInterval(() => {
|
|
147
|
+
if (this.running)
|
|
148
|
+
this.renderPhase();
|
|
149
|
+
}, 1000);
|
|
150
|
+
}
|
|
151
|
+
/** Stop the elapsed-time refresh timer */
|
|
152
|
+
stopElapsedTimer() {
|
|
153
|
+
if (this.elapsedTimer !== null) {
|
|
154
|
+
clearInterval(this.elapsedTimer);
|
|
155
|
+
this.elapsedTimer = null;
|
|
156
|
+
}
|
|
113
157
|
}
|
|
114
158
|
}
|
|
115
159
|
/**
|
|
116
160
|
* Generate localized status text for each phase of the commit workflow.
|
|
117
161
|
*/
|
|
118
162
|
function phaseStatusText(lang, key, autoCommit) {
|
|
119
|
-
const ja = isJapanese(lang);
|
|
120
163
|
const prefix = autoCommit ? "[pi-git: auto-commit]" : "[pi-git]";
|
|
121
164
|
switch (key) {
|
|
122
165
|
case "prepare":
|
|
123
|
-
return
|
|
166
|
+
return t(lang, `${prefix} 準備中...`, `${prefix} Preparing...`);
|
|
124
167
|
case "collectDiff":
|
|
125
|
-
return
|
|
168
|
+
return t(lang, `${prefix} diff収集中...`, `${prefix} Collecting diff...`);
|
|
126
169
|
case "analyze":
|
|
127
|
-
return
|
|
170
|
+
return t(lang, `${prefix} hunk解析中...`, `${prefix} Analyzing hunks...`);
|
|
128
171
|
case "generateMessage":
|
|
129
|
-
return
|
|
130
|
-
? `${prefix} コミットメッセージ生成中...`
|
|
131
|
-
: `${prefix} Generating messages...`;
|
|
172
|
+
return t(lang, `${prefix} コミットメッセージ生成中...`, `${prefix} Generating messages...`);
|
|
132
173
|
case "commit":
|
|
133
|
-
return
|
|
174
|
+
return t(lang, `${prefix} コミット実行中...`, `${prefix} Committing...`);
|
|
134
175
|
}
|
|
135
176
|
}
|
|
136
177
|
/** Singleton instance */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"footer-manager.js","sourceRoot":"","sources":["../../src/utils/footer-manager.ts"],"names":[],"mappings":"AA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AAqB,CAAC,CAAC;QACzE,KAAK,SAAS;YACZ,OAAO,CAAC,CAAC,IAAI,EAAE,GAAG,MAAM,aAAa,EAAE,GAAG,MAAM,qBAAqB,CAAC,CAAC;QACzE,KAAK,iBAAiB;YACpB,OAAO,CAAC,CAAC,IAAI,EACX,GAAG,MAAM,kBAAkB,EAC3B,GAAG,MAAM,yBAAyB,CACnC,CAAC;QACJ,KAAK,QAAQ;YACX,OAAO,CAAC,CAAC,IAAI,EAAE,GAAG,MAAM,aAAa,EAAE,GAAG,MAAM,gBAAgB,CAAC,CAAC;IACtE,CAAC;AACH,CAAC;AAED,yBAAyB;AACzB,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC"}
|
package/dist/utils/lang.d.ts
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export declare function isJapanese(lang: string): boolean;
|
|
8
8
|
/**
|
|
9
|
-
* Get localized message based on language
|
|
9
|
+
* Get localized message based on language.
|
|
10
|
+
* Usage: t(lang)`日本語|English` or t(lang, "日本語", "English")
|
|
10
11
|
*/
|
|
11
|
-
export declare function
|
|
12
|
+
export declare function t(lang: string, ja: string, en: string): string;
|
|
12
13
|
//# sourceMappingURL=lang.d.ts.map
|
package/dist/utils/lang.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lang.d.ts","sourceRoot":"","sources":["../../src/utils/lang.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED
|
|
1
|
+
{"version":3,"file":"lang.d.ts","sourceRoot":"","sources":["../../src/utils/lang.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED;;;GAGG;AACH,wBAAgB,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAE9D"}
|
package/dist/utils/lang.js
CHANGED
|
@@ -8,9 +8,10 @@ export function isJapanese(lang) {
|
|
|
8
8
|
return lang === "ja" || lang === "ja-JP" || lang === "japanese";
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* Get localized message based on language
|
|
11
|
+
* Get localized message based on language.
|
|
12
|
+
* Usage: t(lang)`日本語|English` or t(lang, "日本語", "English")
|
|
12
13
|
*/
|
|
13
|
-
export function
|
|
14
|
+
export function t(lang, ja, en) {
|
|
14
15
|
return isJapanese(lang) ? ja : en;
|
|
15
16
|
}
|
|
16
17
|
//# sourceMappingURL=lang.js.map
|
package/dist/utils/lang.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lang.js","sourceRoot":"","sources":["../../src/utils/lang.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,UAAU,CAAC;AAClE,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"lang.js","sourceRoot":"","sources":["../../src/utils/lang.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,UAAU,CAAC;AAClE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,CAAC,CAAC,IAAY,EAAE,EAAU,EAAE,EAAU;IACpD,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACpC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* /git-branch command
|
|
3
|
-
*
|
|
4
|
-
* Manage git branches: list, switch, create, and delete.
|
|
5
|
-
*/
|
|
6
|
-
import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
7
|
-
export declare function handleBranch(pi: ExtensionAPI, ctx: ExtensionCommandContext, args: string): Promise<void>;
|
|
8
|
-
//# sourceMappingURL=branch.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"branch.d.ts","sourceRoot":"","sources":["../../src/commands/branch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,uBAAuB,EACxB,MAAM,iCAAiC,CAAC;AAYzC,wBAAsB,YAAY,CAChC,EAAE,EAAE,YAAY,EAChB,GAAG,EAAE,uBAAuB,EAC5B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAuHf"}
|
package/dist/commands/branch.js
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* /git-branch command
|
|
3
|
-
*
|
|
4
|
-
* Manage git branches: list, switch, create, and delete.
|
|
5
|
-
*/
|
|
6
|
-
import { createAndSwitchBranch, deleteBranch, getBranches, getCurrentBranch, isGitRepository, switchBranch, } from "../core/git.js";
|
|
7
|
-
import { isJapanese } from "../utils/lang.js";
|
|
8
|
-
import { getSettings } from "../utils/settings.js";
|
|
9
|
-
export async function handleBranch(pi, ctx, args) {
|
|
10
|
-
if (!ctx.hasUI) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const lang = getSettings(ctx.cwd).lang ?? "en";
|
|
14
|
-
const ja = isJapanese(lang);
|
|
15
|
-
if (!(await isGitRepository(pi, ctx.cwd))) {
|
|
16
|
-
ctx.ui.notify(ja ? "Gitリポジトリではありません" : "Not a git repository", "warning");
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
const tokens = args.trim().split(/\s+/).filter(Boolean);
|
|
20
|
-
// Parse flags
|
|
21
|
-
let createNew = false;
|
|
22
|
-
let deleteFlag = false;
|
|
23
|
-
let listOnly = false;
|
|
24
|
-
let help = false;
|
|
25
|
-
const positional = [];
|
|
26
|
-
for (const token of tokens) {
|
|
27
|
-
if (token === "-c" || token === "--create")
|
|
28
|
-
createNew = true;
|
|
29
|
-
else if (token === "-d" || token === "--delete")
|
|
30
|
-
deleteFlag = true;
|
|
31
|
-
else if (token === "--list" || token === "-l")
|
|
32
|
-
listOnly = true;
|
|
33
|
-
else if (token === "--help" || token === "-h")
|
|
34
|
-
help = true;
|
|
35
|
-
else
|
|
36
|
-
positional.push(token);
|
|
37
|
-
}
|
|
38
|
-
if (help) {
|
|
39
|
-
const lines = ja
|
|
40
|
-
? [
|
|
41
|
-
"/git-branch [<branch>] [-c|--create] [-d|--delete] [--list] [--help]",
|
|
42
|
-
"",
|
|
43
|
-
"ブランチを管理します。",
|
|
44
|
-
"",
|
|
45
|
-
"引数:",
|
|
46
|
-
" <branch> 切り替えるブランチ名",
|
|
47
|
-
"",
|
|
48
|
-
"フラグ:",
|
|
49
|
-
" -c, --create 新しいブランチを作成して切り替え",
|
|
50
|
-
" -d, --delete ブランチを削除(マージ済みのみ)",
|
|
51
|
-
" --list, -l ブランチ一覧を表示",
|
|
52
|
-
" --help, -h このヘルプを表示",
|
|
53
|
-
"",
|
|
54
|
-
"引数を省略すると、ブランチ一覧を表示します。",
|
|
55
|
-
]
|
|
56
|
-
: [
|
|
57
|
-
"/git-branch [<branch>] [-c|--create] [-d|--delete] [--list] [--help]",
|
|
58
|
-
"",
|
|
59
|
-
"Manage git branches.",
|
|
60
|
-
"",
|
|
61
|
-
"Arguments:",
|
|
62
|
-
" <branch> Branch name to switch to",
|
|
63
|
-
"",
|
|
64
|
-
"Flags:",
|
|
65
|
-
" -c, --create Create a new branch and switch to it",
|
|
66
|
-
" -d, --delete Delete a branch (merged only)",
|
|
67
|
-
" --list, -l List all branches",
|
|
68
|
-
" --help, -h Show this help message",
|
|
69
|
-
"",
|
|
70
|
-
"Without arguments, lists all branches.",
|
|
71
|
-
];
|
|
72
|
-
ctx.ui.notify(lines.join("\n"), "info");
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
// List branches if no branch specified or --list flag
|
|
76
|
-
if (listOnly || (positional.length === 0 && !createNew && !deleteFlag)) {
|
|
77
|
-
await listBranches(pi, ctx, ja);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const branchName = positional[0];
|
|
81
|
-
if (deleteFlag) {
|
|
82
|
-
// Delete branch
|
|
83
|
-
await handleDeleteBranch(pi, ctx, branchName, ja);
|
|
84
|
-
}
|
|
85
|
-
else if (createNew) {
|
|
86
|
-
// Create and switch to new branch
|
|
87
|
-
const result = await createAndSwitchBranch(pi, branchName, ctx.cwd);
|
|
88
|
-
if (result.success) {
|
|
89
|
-
ctx.ui.notify(ja
|
|
90
|
-
? `新しいブランチ '${branchName}' を作成して切り替えました`
|
|
91
|
-
: `Created and switched to new branch '${branchName}'`, "info");
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
ctx.ui.notify(ja
|
|
95
|
-
? `ブランチの作成に失敗しました: ${result.message}`
|
|
96
|
-
: `Failed to create branch: ${result.message}`, "error");
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
// Switch to existing branch
|
|
101
|
-
const result = await switchBranch(pi, branchName, ctx.cwd);
|
|
102
|
-
if (result.success) {
|
|
103
|
-
ctx.ui.notify(ja
|
|
104
|
-
? `ブランチ '${branchName}' に切り替えました`
|
|
105
|
-
: `Switched to branch '${branchName}'`, "info");
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
ctx.ui.notify(ja
|
|
109
|
-
? `ブランチの切り替えに失敗しました: ${result.message}`
|
|
110
|
-
: `Failed to switch branch: ${result.message}`, "error");
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
async function handleDeleteBranch(pi, ctx, branchName, ja) {
|
|
115
|
-
// Check if trying to delete current branch
|
|
116
|
-
try {
|
|
117
|
-
const currentBranch = await getCurrentBranch(pi, ctx.cwd);
|
|
118
|
-
if (currentBranch === branchName) {
|
|
119
|
-
ctx.ui.notify(ja
|
|
120
|
-
? `現在のブランチ '${branchName}' は削除できません。まず他のブランチに切り替えてください`
|
|
121
|
-
: `Cannot delete the current branch '${branchName}'. Please switch to another branch first`, "warning");
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
catch (error) {
|
|
126
|
-
ctx.ui.notify(ja
|
|
127
|
-
? `現在のブランチの取得に失敗しました: ${error instanceof Error ? error.message : String(error)}`
|
|
128
|
-
: `Failed to get current branch: ${error instanceof Error ? error.message : String(error)}`, "error");
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
// Confirm deletion
|
|
132
|
-
const confirmTitle = ja ? "ブランチ削除の確認" : "Confirm Branch Deletion";
|
|
133
|
-
const confirmMessage = ja
|
|
134
|
-
? `ブランチ '${branchName}' を削除してもよろしいですか?`
|
|
135
|
-
: `Are you sure you want to delete branch '${branchName}'?`;
|
|
136
|
-
const confirmed = await ctx.ui.confirm(confirmTitle, confirmMessage);
|
|
137
|
-
if (!confirmed) {
|
|
138
|
-
ctx.ui.notify(ja ? "削除をキャンセルしました" : "Deletion cancelled", "info");
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
// Delete branch
|
|
142
|
-
const result = await deleteBranch(pi, branchName, ctx.cwd);
|
|
143
|
-
if (result.success) {
|
|
144
|
-
ctx.ui.notify(ja
|
|
145
|
-
? `ブランチ '${branchName}' を削除しました`
|
|
146
|
-
: `Deleted branch '${branchName}'`, "info");
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
ctx.ui.notify(ja
|
|
150
|
-
? `ブランチの削除に失敗しました: ${result.message}`
|
|
151
|
-
: `Failed to delete branch: ${result.message}`, "error");
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
async function listBranches(pi, ctx, ja) {
|
|
155
|
-
try {
|
|
156
|
-
const currentBranch = await getCurrentBranch(pi, ctx.cwd);
|
|
157
|
-
const branches = await getBranches(pi, ctx.cwd);
|
|
158
|
-
const localBranches = branches.filter((b) => !b.isRemote);
|
|
159
|
-
const remoteBranches = branches.filter((b) => b.isRemote);
|
|
160
|
-
const lines = [];
|
|
161
|
-
if (ja) {
|
|
162
|
-
lines.push("ローカルブランチ:");
|
|
163
|
-
for (const branch of localBranches) {
|
|
164
|
-
const marker = branch.name === currentBranch ? "* " : " ";
|
|
165
|
-
lines.push(`${marker}${branch.name}`);
|
|
166
|
-
}
|
|
167
|
-
if (remoteBranches.length > 0) {
|
|
168
|
-
lines.push("");
|
|
169
|
-
lines.push("リモートブランチ:");
|
|
170
|
-
for (const branch of remoteBranches) {
|
|
171
|
-
lines.push(` ${branch.name}`);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
lines.push("Local branches:");
|
|
177
|
-
for (const branch of localBranches) {
|
|
178
|
-
const marker = branch.name === currentBranch ? "* " : " ";
|
|
179
|
-
lines.push(`${marker}${branch.name}`);
|
|
180
|
-
}
|
|
181
|
-
if (remoteBranches.length > 0) {
|
|
182
|
-
lines.push("");
|
|
183
|
-
lines.push("Remote branches:");
|
|
184
|
-
for (const branch of remoteBranches) {
|
|
185
|
-
lines.push(` ${branch.name}`);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
ctx.ui.notify(lines.join("\n"), "info");
|
|
190
|
-
}
|
|
191
|
-
catch (error) {
|
|
192
|
-
ctx.ui.notify(ja
|
|
193
|
-
? `ブランチ一覧の取得に失敗しました: ${error instanceof Error ? error.message : String(error)}`
|
|
194
|
-
: `Failed to list branches: ${error instanceof Error ? error.message : String(error)}`, "error");
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
//# sourceMappingURL=branch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1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AI,CAAC,EAAE,MAAM,CAAC,CAAC;IAC1C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,EAAE,CAAC,MAAM,CACX,EAAE;YACA,CAAC,CAAC,qBAAqB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YAC/E,CAAC,CAAC,4BAA4B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EACxF,OAAO,CACR,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* /git-diff command
|
|
3
|
-
*
|
|
4
|
-
* Interactive diff review with sequential hunk approval.
|
|
5
|
-
* Allows reviewing AI-generated hunks, viewing diffs, editing messages,
|
|
6
|
-
* and committing approved hunks one at a time.
|
|
7
|
-
*/
|
|
8
|
-
import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
9
|
-
export declare function handleGitDiff(pi: ExtensionAPI, ctx: ExtensionCommandContext, args: string): Promise<void>;
|
|
10
|
-
//# sourceMappingURL=git-diff.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"git-diff.d.ts","sourceRoot":"","sources":["../../src/commands/git-diff.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,uBAAuB,EACxB,MAAM,iCAAiC,CAAC;AAoDzC,wBAAsB,aAAa,CACjC,EAAE,EAAE,YAAY,EAChB,GAAG,EAAE,uBAAuB,EAC5B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CA+Qf"}
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* /git-diff command
|
|
3
|
-
*
|
|
4
|
-
* Interactive diff review with sequential hunk approval.
|
|
5
|
-
* Allows reviewing AI-generated hunks, viewing diffs, editing messages,
|
|
6
|
-
* and committing approved hunks one at a time.
|
|
7
|
-
*/
|
|
8
|
-
import { analyzeDiff, parseDiffStats, processHunks, splitDiffByFile, } from "../core/diff-analyzer.js";
|
|
9
|
-
import { collectDiff, ensureReadyToCommit, resetStaging, stageFiles, } from "../core/git.js";
|
|
10
|
-
import { isJapanese } from "../utils/lang.js";
|
|
11
|
-
import { getLanguage } from "../utils/settings.js";
|
|
12
|
-
import { footerManager } from "../utils/footer-manager.js";
|
|
13
|
-
import { HunkReviewComponent, } from "../tui/hunk-review.js";
|
|
14
|
-
/**
|
|
15
|
-
* Review a single hunk using the TUI component
|
|
16
|
-
*/
|
|
17
|
-
async function reviewHunk(ctx, hunk, hunkIndex, totalHunks, fileStats, fileDiffs) {
|
|
18
|
-
if (!ctx.hasUI) {
|
|
19
|
-
return { type: "quit" };
|
|
20
|
-
}
|
|
21
|
-
return await ctx.ui.custom((tui, theme, _keybindings, done) => {
|
|
22
|
-
const component = new HunkReviewComponent(hunk, hunkIndex, totalHunks, fileStats, fileDiffs, tui, theme, done);
|
|
23
|
-
return component;
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
export async function handleGitDiff(pi, ctx, args) {
|
|
27
|
-
const lang = getLanguage(ctx.cwd);
|
|
28
|
-
const ja = isJapanese(lang);
|
|
29
|
-
if (/--help/.test(args)) {
|
|
30
|
-
const lines = ja
|
|
31
|
-
? [
|
|
32
|
-
"/git-diff [--help]",
|
|
33
|
-
"",
|
|
34
|
-
"AIが生成したhunkを対話的にレビューし、承認したものをコミットします。",
|
|
35
|
-
"",
|
|
36
|
-
"オプション:",
|
|
37
|
-
" --help このヘルプを表示",
|
|
38
|
-
"",
|
|
39
|
-
"操作:",
|
|
40
|
-
" ↑↓ ファイル間を移動",
|
|
41
|
-
" Enter 選択したファイルのdiffを表示",
|
|
42
|
-
" a hunkを承認してコミット",
|
|
43
|
-
" e コミットメッセージを編集",
|
|
44
|
-
" s hunkをスキップ",
|
|
45
|
-
" x 選択したファイルをhunkから除外",
|
|
46
|
-
" q 終了",
|
|
47
|
-
]
|
|
48
|
-
: [
|
|
49
|
-
"/git-diff [--help]",
|
|
50
|
-
"",
|
|
51
|
-
"Interactively review AI-generated hunks and commit approved ones.",
|
|
52
|
-
"",
|
|
53
|
-
"Options:",
|
|
54
|
-
" --help Show this help message",
|
|
55
|
-
"",
|
|
56
|
-
"Controls:",
|
|
57
|
-
" ↑↓ Navigate between files",
|
|
58
|
-
" Enter View diff for selected file",
|
|
59
|
-
" a Approve and commit hunk",
|
|
60
|
-
" e Edit commit message",
|
|
61
|
-
" s Skip hunk",
|
|
62
|
-
" x Exclude selected file from hunk",
|
|
63
|
-
" q Quit",
|
|
64
|
-
];
|
|
65
|
-
if (ctx.hasUI) {
|
|
66
|
-
ctx.ui.notify(lines.join("\n"), "info");
|
|
67
|
-
}
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (!ctx.hasUI) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
// Check if agg-commit is running
|
|
74
|
-
if (footerManager.isRunning()) {
|
|
75
|
-
ctx.ui.notify(ja
|
|
76
|
-
? "git-agg-commit 実行中です。完了してから再度実行してください。"
|
|
77
|
-
: "git-agg-commit is already running. Please wait for it to complete.", "warning");
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
await footerManager.setRunning("diff", "prepare");
|
|
81
|
-
try {
|
|
82
|
-
const preCheck = await ensureReadyToCommit(pi, ctx.cwd);
|
|
83
|
-
if (preCheck) {
|
|
84
|
-
await footerManager.clearRunning();
|
|
85
|
-
ctx.ui.notify(preCheck === "not_git_repo"
|
|
86
|
-
? ja ? "Gitリポジトリではありません" : "Not a git repository"
|
|
87
|
-
: ja ? "コミットする変更がありません" : "No changes to commit", preCheck === "not_git_repo" ? "warning" : "info");
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
// Collect diff via stash to freeze the working tree
|
|
91
|
-
await footerManager.setPhase("collectDiff");
|
|
92
|
-
const diff = await collectDiff(pi, ctx.cwd);
|
|
93
|
-
if (diff === null) {
|
|
94
|
-
await footerManager.clearRunning();
|
|
95
|
-
ctx.ui.notify(ja ? "変更のstashに失敗しました" : "Failed to stash changes", "warning");
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
if (!diff.trim()) {
|
|
99
|
-
await footerManager.clearRunning();
|
|
100
|
-
ctx.ui.notify(ja ? "コミットする変更がありません" : "No changes to commit", "info");
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
// Parse diff by file
|
|
104
|
-
const fileDiffs = splitDiffByFile(diff);
|
|
105
|
-
const fileStats = parseDiffStats(diff);
|
|
106
|
-
// Analyze diff into hunks
|
|
107
|
-
await footerManager.setPhase("analyze");
|
|
108
|
-
let hunks = await analyzeDiff(pi, ctx, diff);
|
|
109
|
-
if (hunks.length === 0) {
|
|
110
|
-
await footerManager.clearRunning();
|
|
111
|
-
ctx.ui.notify(ja ? "コミット可能なhunkがありません" : "No hunks found to commit", "info");
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
// Sanitize, deduplicate, and filter hunks
|
|
115
|
-
hunks = processHunks(hunks);
|
|
116
|
-
await footerManager.clearRunning();
|
|
117
|
-
// Review each hunk sequentially
|
|
118
|
-
const unassignedFiles = [];
|
|
119
|
-
let committedCount = 0;
|
|
120
|
-
let skippedCount = 0;
|
|
121
|
-
let quitRequested = false;
|
|
122
|
-
for (let i = 0; i < hunks.length; i++) {
|
|
123
|
-
const hunk = hunks[i];
|
|
124
|
-
let currentMessage = hunk.message;
|
|
125
|
-
// Review loop (for message editing)
|
|
126
|
-
while (true) {
|
|
127
|
-
const action = await reviewHunk(ctx, { ...hunk, message: currentMessage }, i, hunks.length, fileStats, fileDiffs);
|
|
128
|
-
if (action.type === "quit") {
|
|
129
|
-
// Add current and remaining hunks' files to unassigned
|
|
130
|
-
for (let j = i; j < hunks.length; j++) {
|
|
131
|
-
unassignedFiles.push(...hunks[j].files);
|
|
132
|
-
}
|
|
133
|
-
quitRequested = true;
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
if (action.type === "edit_message") {
|
|
137
|
-
// Edit message using pi's built-in input dialog (IME-supported)
|
|
138
|
-
const newMessage = await ctx.ui.input(ja ? "コミットメッセージを編集:" : "Edit commit message:", action.currentMessage);
|
|
139
|
-
if (newMessage && newMessage.trim()) {
|
|
140
|
-
currentMessage = newMessage.trim();
|
|
141
|
-
}
|
|
142
|
-
// Continue loop to re-show the hunk with updated message
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
if (action.type === "skip") {
|
|
146
|
-
// Add non-excluded files to unassigned
|
|
147
|
-
const files = hunk.files.filter((f) => !action.excludedFiles.includes(f));
|
|
148
|
-
unassignedFiles.push(...files, ...action.excludedFiles);
|
|
149
|
-
skippedCount++;
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
if (action.type === "approve") {
|
|
153
|
-
// Stage and commit non-excluded files
|
|
154
|
-
const files = hunk.files.filter((f) => !action.excludedFiles.includes(f));
|
|
155
|
-
if (files.length === 0) {
|
|
156
|
-
ctx.ui.notify(ja
|
|
157
|
-
? "コミットするファイルがありません"
|
|
158
|
-
: "No files to commit", "warning");
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
try {
|
|
162
|
-
await stageFiles(pi, files, ctx.cwd);
|
|
163
|
-
}
|
|
164
|
-
catch (error) {
|
|
165
|
-
ctx.ui.notify(ja
|
|
166
|
-
? `ファイルのステージに失敗しました: ${error instanceof Error ? error.message : String(error)}`
|
|
167
|
-
: `Failed to stage files: ${error instanceof Error ? error.message : String(error)}`, "error");
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
const { code: exitCode, stderr } = await pi.exec("git", ["commit", "-m", action.message], { cwd: ctx.cwd });
|
|
171
|
-
if (exitCode !== 0) {
|
|
172
|
-
try {
|
|
173
|
-
await resetStaging(pi, ctx.cwd);
|
|
174
|
-
}
|
|
175
|
-
catch {
|
|
176
|
-
// Ignore reset errors
|
|
177
|
-
}
|
|
178
|
-
const detail = stderr.trim() ? ` — ${stderr.trim()}` : "";
|
|
179
|
-
ctx.ui.notify(ja
|
|
180
|
-
? `コミットに失敗しました: "${action.message}" (exit code ${exitCode})${detail}。ステージをリセットしました。`
|
|
181
|
-
: `Commit failed for "${action.message}" (exit code ${exitCode}).${detail} Staging has been reset.`, "warning");
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
committedCount++;
|
|
185
|
-
// Add excluded files to unassigned
|
|
186
|
-
unassignedFiles.push(...action.excludedFiles);
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (quitRequested)
|
|
191
|
-
break;
|
|
192
|
-
}
|
|
193
|
-
// Show summary
|
|
194
|
-
const parts = [];
|
|
195
|
-
if (committedCount > 0) {
|
|
196
|
-
parts.push(ja
|
|
197
|
-
? `${committedCount}個のhunkをコミットしました`
|
|
198
|
-
: `Committed ${committedCount} hunk${committedCount > 1 ? "s" : ""}`);
|
|
199
|
-
}
|
|
200
|
-
if (skippedCount > 0) {
|
|
201
|
-
parts.push(ja
|
|
202
|
-
? `${skippedCount}個のhunkをスキップしました`
|
|
203
|
-
: `Skipped ${skippedCount} hunk${skippedCount > 1 ? "s" : ""}`);
|
|
204
|
-
}
|
|
205
|
-
if (parts.length > 0) {
|
|
206
|
-
ctx.ui.notify(parts.join(", "), "info");
|
|
207
|
-
}
|
|
208
|
-
// Show unassigned files
|
|
209
|
-
if (unassignedFiles.length > 0) {
|
|
210
|
-
const lines = ja
|
|
211
|
-
? [
|
|
212
|
-
"",
|
|
213
|
-
`⚠ ${unassignedFiles.length}個のファイルが未割り当てです:`,
|
|
214
|
-
...unassignedFiles.map((f) => ` ${f}`),
|
|
215
|
-
]
|
|
216
|
-
: [
|
|
217
|
-
"",
|
|
218
|
-
`⚠ ${unassignedFiles.length} file${unassignedFiles.length > 1 ? "s" : ""} remain unassigned:`,
|
|
219
|
-
...unassignedFiles.map((f) => ` ${f}`),
|
|
220
|
-
];
|
|
221
|
-
ctx.ui.notify(lines.join("\n"), "info");
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
finally {
|
|
225
|
-
await footerManager.clearRunning();
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
//# sourceMappingURL=git-diff.js.map
|