fix: simplify walkthrough prompt requests (#1660)
* fix: simplify walkthrough prompt requests * fix: address walkthrough review feedback
This commit is contained in:
@@ -26,7 +26,10 @@ const overloaded529Message = "Internal error: API Error: 529 Overloaded. This is
|
||||
// before recovering (default 1, so the turn self-heals on the first retry).
|
||||
// Use a large N (e.g. `/overloaded:9`) to exhaust the retry budget and fall
|
||||
// through to the red recovery banner.
|
||||
var overloadedCmdRe = regexp.MustCompile(`(?i)^/(?:e2e:)?overloaded(?::(\d+))?$`)
|
||||
var (
|
||||
overloadedCmdRe = regexp.MustCompile(`(?i)^/(?:e2e:)?overloaded(?::(\d+))?$`)
|
||||
changesWalkthroughPromptRefRe = regexp.MustCompile(`^@changes-walkthrough(?:\s|$)`)
|
||||
)
|
||||
|
||||
const changesWalkthroughPromptMarker = "Please create an agent-authored walkthrough of the current changes"
|
||||
|
||||
@@ -35,8 +38,7 @@ func isChangesWalkthroughRequest(prompt string) bool {
|
||||
legacyPrompt := strings.Contains(cmd, changesWalkthroughPromptMarker) &&
|
||||
strings.Contains(cmd, "show_walkthrough_kandev") &&
|
||||
strings.Contains(cmd, "Available changed files:")
|
||||
promptReference := strings.Contains(cmd, "@changes-walkthrough") &&
|
||||
strings.Contains(cmd, "Changed files:")
|
||||
promptReference := changesWalkthroughPromptRefRe.MatchString(cmd)
|
||||
return legacyPrompt || promptReference
|
||||
}
|
||||
|
||||
|
||||
@@ -124,9 +124,6 @@ func TestIsChangesWalkthroughRequest(t *testing.T) {
|
||||
promptReference := strings.Join([]string{
|
||||
"@changes-walkthrough",
|
||||
"",
|
||||
"Changed files:",
|
||||
"- src/app.ts [uncommitted]",
|
||||
"",
|
||||
"<kandev-system>",
|
||||
"EXPANDED PROMPT REFERENCES",
|
||||
"### @changes-walkthrough",
|
||||
@@ -142,6 +139,9 @@ func TestIsChangesWalkthroughRequest(t *testing.T) {
|
||||
if isChangesWalkthroughRequest("show_walkthrough_kandev without the generated prompt shape") {
|
||||
t.Fatal("expected unrelated prompt not to be detected")
|
||||
}
|
||||
if isChangesWalkthroughRequest("what does @changes-walkthrough do?") {
|
||||
t.Fatal("expected incidental prompt reference not to be detected")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDelayRange(t *testing.T) {
|
||||
|
||||
@@ -851,8 +851,8 @@ func walkthroughDemoArgs() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
wtKeyTitle: "Tour of the change",
|
||||
wtKeySteps: []map[string]interface{}{
|
||||
wtStep("Entry point", "walkthrough_a.txt",
|
||||
"Execution starts here. **Step 1** explains the entry point in file A.", 1, 0),
|
||||
wtStep("Overview", "walkthrough_a.txt",
|
||||
"Big picture: this tour explains how the sample changes connect across the touched files.\n\nELI5: first we show the map, then we explain each changed line.", 1, 0),
|
||||
wtStep("The change in A", "walkthrough_a.txt",
|
||||
"Step 2: this is WALKTHROUGH_CHANGE_A the tour narrates.", 2, 3),
|
||||
wtStep("File B", "walkthrough_b.txt",
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
Please create an agent-authored walkthrough of the current changes using `show_walkthrough_kandev`.
|
||||
|
||||
Walkthrough requirements:
|
||||
- Use only files listed below or files you verify exist in this task's local worktree/review diff.
|
||||
- Inspect the changed files yourself instead of relying on UI-provided paths or diff context.
|
||||
- If this is a PR task or PR review task, compare the PR head against the PR base branch.
|
||||
- Otherwise, compare against the task/repository base using the local task state (`git status`, `git diff`, `git diff --cached`, and cumulative diff context when available).
|
||||
- For PR-only files, do not assume the PR head is checked out locally; anchor to the review diff when available, and avoid editor-only/current-worktree claims.
|
||||
- The first walkthrough step must contextualize the whole change before explaining individual hunks.
|
||||
- Anchor the first walkthrough step to the most representative changed line or changed line range available.
|
||||
- Include an `ELI5:` line in the first walkthrough step text that explains the change in the simplest terms possible.
|
||||
- Anchor steps to changed lines or changed line ranges whenever possible.
|
||||
- Use `line_end` whenever a logical explanation spans multiple lines; prefer one range step over adjacent single-line steps.
|
||||
- Keep each step concise and direct. Do not include a `Justification:` preamble.
|
||||
- If a good local/review anchor is unavailable, omit that step instead of referencing a remote-only path.
|
||||
|
||||
Available changed files:
|
||||
{{changed_files}}
|
||||
|
||||
@@ -164,9 +164,13 @@ func TestSQLiteRepository_BuiltinPrompts(t *testing.T) {
|
||||
}
|
||||
for _, want := range []string{
|
||||
"show_walkthrough_kandev",
|
||||
"{{changed_files}}",
|
||||
"Inspect the changed files yourself",
|
||||
"compare the PR head against the PR base branch",
|
||||
"compare against the task/repository base",
|
||||
"Use `line_end`",
|
||||
"do not assume the PR head is checked out locally",
|
||||
"first walkthrough step",
|
||||
"ELI5:",
|
||||
} {
|
||||
if !strings.Contains(changesWalkthroughContent, want) {
|
||||
t.Fatalf("expected changes-walkthrough prompt to contain %q, got:\n%s", want, changesWalkthroughContent)
|
||||
|
||||
Reference in New Issue
Block a user