Skip to content

Commit 64de35b

Browse files
committed
pkg/aflow/tool/codeeditor: add package
Code editing tool stub. Update #6470
1 parent 3181850 commit 64de35b

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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

Comments
 (0)