loop: update git commit instruction to use --trailer, add Change-ID
We have run 'git config' for the user, so we can trim those instructions and simplify.
(And in unsafe mode, the user has 'git config' set up anyway.)
Instead of prompting the model to manually add 'Co-Authored-By' as a line in the
commit message, now instruct it to use the --trailer option.
This streamlines adding a Change-ID trailer with a random string (s<random_hex>k format).
I'd actually like to use precommmit hooks to automatically do all the trailer,
but that doesn't play nicely with -unsafe, so for now, do it this way.
At least we'll have Change-IDs that we can start using.
(Pity the official change-id support in git hasn't landed yet.)
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s9b68cbfa4c7eeb82k
diff --git a/loop/donetool.go b/loop/donetool.go
index 48818d6..0870fb1 100644
--- a/loop/donetool.go
+++ b/loop/donetool.go
@@ -16,7 +16,7 @@
// not as reliable as it could be. Historically, we've found that Claude ignores
// the tool results here, so we don't tell the tool to say "hey, really check this"
// at the moment, though we've tried.
-func makeDoneTool(codereview *codereview.CodeReviewer, gitUsername, gitEmail string) *llm.Tool {
+func makeDoneTool(codereview *codereview.CodeReviewer) *llm.Tool {
description := doneDescription
if experiment.Enabled("not_done") {
description = backtrackDoneDescription
@@ -24,7 +24,7 @@
return &llm.Tool{
Name: "done",
Description: description,
- InputSchema: json.RawMessage(doneChecklistJSONSchema(gitUsername, gitEmail)),
+ InputSchema: json.RawMessage(doneChecklistSchema()),
Run: func(ctx context.Context, input json.RawMessage) (string, error) {
if experiment.Enabled("not_done") {
if strings.Contains(strings.ToLower(string(input)), "cancel done tool call") {
@@ -62,26 +62,17 @@
}
}
-func doneChecklistJSONSchema(gitUsername, gitEmail string) string {
- gitCommitDescription := fmt.Sprintf(`Create git commits for any code changes you made. Match the style of recent commit messages. Include 'Co-Authored-By: sketch <hello@sketch.dev>' and the original user prompt. Use GIT_AUTHOR_NAME="%s" GIT_AUTHOR_EMAIL="%s" (not git config).`,
- gitUsername, gitEmail)
- desc, err := json.Marshal(gitCommitDescription)
- if err != nil {
- panic(err)
- }
- prefix := doneChecklistJSONSchemaPrefix
- suffix := doneChecklistJSONSchemaSuffix
+func doneChecklistSchema() string {
if experiment.Enabled("not_done") {
- prefix = backtrackDoneChecklistJSONSchemaPrefix
- suffix = backtrackDoneChecklistJSONSchemaSuffix
+ return backtrackDoneChecklistJSONSchema
}
- return prefix + string(desc) + suffix
+ return doneChecklistJSONSchema
}
// TODO: this is ugly, maybe JSON-encode a deeply nested map[string]any instead? also ugly.
const (
- doneDescription = `Use this tool when you have achieved the user's goal. The parameters form a checklist which you should evaluate.`
- doneChecklistJSONSchemaPrefix = `{
+ doneDescription = `Use this tool when you have achieved the user's goal. The parameters form a checklist which you should evaluate.`
+ doneChecklistJSONSchema = `{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Checklist",
"description": "A schema for tracking checklist items with status and comments",
@@ -106,9 +97,7 @@
},
"git_commit": {
"$ref": "#/definitions/checklistItem",
- "description": `
-
- doneChecklistJSONSchemaSuffix = `
+ "description": "Create git commits for any code changes you made, adding --trailer 'Co-Authored-By: sketch <hello@sketch.dev>' and --trailer 'Change-ID: s$(openssl rand -hex 8)k'. The git user is already configured correctly."
}
},
"additionalProperties": {
@@ -141,8 +130,8 @@
)
const (
- backtrackDoneDescription = `This tool marks task completion. Review the checklist items carefully - if any item's status is "cancel" or any thoughts contain "Cancel done tool call", the entire call will be ignored without user notification. Cancellation is free and preferred over inaccurately marking items as "done" or "not applicable".`
- backtrackDoneChecklistJSONSchemaPrefix = `{
+ backtrackDoneDescription = `This tool marks task completion. Review the checklist items carefully - if any item's status is "cancel" or any thoughts contain "Cancel done tool call", the entire call will be ignored without user notification. Cancellation is free and preferred over inaccurately marking items as "done" or "not applicable".`
+ backtrackDoneChecklistJSONSchema = `{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Checklist",
"description": "A schema for tracking checklist items",
@@ -167,9 +156,7 @@
},
"git_commit": {
"$ref": "#/definitions/checklistItem",
- "description": `
-
- backtrackDoneChecklistJSONSchemaSuffix = `
+ "description": "Create git commits for any code changes you made, adding --trailer 'Co-Authored-By: sketch <hello@sketch.dev>' and --trailer 'Change-ID: s$(openssl rand -hex 8)k'. The git user is already configured correctly."
}
},
"additionalProperties": {