|
| 1 | +// Copyright 2026 syzkaller project authors. All rights reserved. |
| 2 | +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. |
| 3 | + |
| 4 | +package codeeditor |
| 5 | + |
| 6 | +import ( |
| 7 | + "github.com/google/syzkaller/pkg/aflow" |
| 8 | +) |
| 9 | + |
| 10 | +var Tool = aflow.NewFuncTool("codeeditor", codeeditor, ` |
| 11 | +The tool does one code edit to form the final patch. |
| 12 | +The tool should be called mutiple times to do all required changes one-by-one, |
| 13 | +but avoid changing the same lines multiple times. |
| 14 | +Note: You will not see your edits via the codesearch tool. |
| 15 | +Note: The current code snippet should reflect the previous changes. |
| 16 | +`) |
| 17 | + |
| 18 | +type state struct { |
| 19 | + KernelScratchSrc string |
| 20 | +} |
| 21 | + |
| 22 | +type args struct { |
| 23 | + SourceFile string `jsonschema:"Full source file path."` |
| 24 | + CurrentCode string `jsonschema:"The current code to replace verbatim with new lines, but without line numbers."` |
| 25 | + NewCode string `jsonschema:"New code to replace the current code snippet."` |
| 26 | +} |
| 27 | + |
| 28 | +func codeeditor(ctx *aflow.Context, state state, args args) (struct{}, error) { |
| 29 | + // TODO: check that the SourceFile is not escaping. |
| 30 | + // If SourceFile is incorrect, or CurrentCode is not matched, return aflow.BadCallError |
| 31 | + // with an explanation. Say that it needs to increase context if CurrentCode is not matched. |
| 32 | + // Try to do as fuzzy match for CurrentCode as possible (strip line numbers, |
| 33 | + // ignore white-spaces, etc). |
| 34 | + // Should we accept a reference line number, or function name to disambiguate in the case |
| 35 | + // of multiple matches? |
| 36 | + return struct{}{}, nil |
| 37 | +} |
0 commit comments