🐛 fix(vscode): 提交代码改调 generate-git-commit-message 写说明

This commit is contained in:
cruldra committed 2026-10-15 15:34:18 +11:00
1 parent 5e9bf44710
commit d10c29a260
7 files changed
+130 -3

No files matched your search

+5 -1
View File
@@ -14,6 +14,10 @@ import (
type commitRunMsg struct{ err error }
const commitSkill = "/generate-git-commit-message"
const commitPrompt = commitSkill + "\n先加载这条技能,按它的格式根据当前未提交改动生成提交说明,再 git add 并 git commit。\n用 git status 和 git diff(含暂存区)看清改了什么。\n不要把本指令、按钮名或任何操作口令原样当作 commit message。\n没有改动就停下来,不要空提交。不要 push,不要改无关文件。"
type mergePreviewResultMsg struct {
issueNumber int
result git.MergePreviewResult
@@ -30,7 +34,7 @@ func commitRunCmd() tea.Cmd {
return commitRunMsg{err: err}
}
_, err = cc.SpawnClaude(ctx, cc.Opts{
Prompt: "提交下代码",
Prompt: commitPrompt,
Cwd: root,
TimeoutMs: 30 * 60 * 1000,
})
+15
View File
@@ -184,3 +184,18 @@ func TestCommitRun_InFlightGuard(t *testing.T) {
t.Fatal("commitRunMsg must clear commitRunning")
}
}
func TestCommitPrompt_NotLiteralCommand(t *testing.T) {
if !strings.HasPrefix(commitPrompt, commitSkill+"\n") {
t.Fatalf("commitPrompt must start with %q, got %q", commitSkill, commitPrompt)
}
if commitPrompt == "提交下代码" {
t.Fatal("commitPrompt must not be the old literal command")
}
if !strings.Contains(commitPrompt, "不要把本指令") {
t.Errorf("commitPrompt should forbid using the instruction as the commit message, got %q", commitPrompt)
}
if !strings.Contains(commitPrompt, "git commit") {
t.Errorf("commitPrompt should ask for git commit, got %q", commitPrompt)
}
}