Skip to content

Commit 99ada2f

Browse files
committed
inserttext simplify and some tool schema mods
1 parent 20d98cc commit 99ada2f

7 files changed

Lines changed: 63 additions & 63 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Grouped under `texttool`.
8383

8484
- `readtextrange`: read lines, optionally constrained by unique start/end marker blocks.
8585
- `findtext`: find matches with context.
86-
- `inserttextlines`: insert lines at start/end/between text blocks.
86+
- `inserttext`: insert lines at start/end/between text blocks.
8787
- `replacetext`: replace exact line blocks, with optional disambiguation using adjacent lines.
8888
- `deletetextlines`: delete exact line blocks, with optional disambiguation using adjacent lines.
8989

internal/integration/helpers_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ func newHarness(t *testing.T, base string, execOpts ...exectool.ExecToolOption)
106106
if err := llmtools.RegisterTypedAsTextTool(r, tt.FindTextTool(), tt.FindText); err != nil {
107107
t.Fatalf("register findtext: %v", err)
108108
}
109-
if err := llmtools.RegisterTypedAsTextTool(r, tt.InsertTextLinesTool(), tt.InsertTextLines); err != nil {
110-
t.Fatalf("register inserttextlines: %v", err)
109+
if err := llmtools.RegisterTypedAsTextTool(r, tt.InsertTextTool(), tt.InsertText); err != nil {
110+
t.Fatalf("register inserttext: %v", err)
111111
}
112112
if err := llmtools.RegisterTypedAsTextTool(r, tt.ReplaceTextTool(), tt.ReplaceText); err != nil {
113113
t.Fatalf("register replacetext: %v", err)

internal/integration/text_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func TestE2E_Text_ReadModifyLoop(t *testing.T) {
7474
})
7575

7676
// 5) Insert after a uniquely-matched anchor.
77-
_ = callJSON[texttool.InsertTextLinesOut](t, h.r, "inserttextlines", texttool.InsertTextLinesArgs{
77+
_ = callJSON[texttool.InsertTextOut](t, h.r, "inserttext", texttool.InsertTextArgs{
7878
Path: docRel,
7979
Position: "between",
8080
TextAbove: stringPtr("<!-- A END -->\n\n"),

registry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func RegisterBuiltins(r *Registry) error {
148148
if err := RegisterTypedAsTextTool(r, tt.FindTextTool(), tt.FindText); err != nil {
149149
return err
150150
}
151-
if err := RegisterTypedAsTextTool(r, tt.InsertTextLinesTool(), tt.InsertTextLines); err != nil {
151+
if err := RegisterTypedAsTextTool(r, tt.InsertTextTool(), tt.InsertText); err != nil {
152152
return err
153153
}
154154
if err := RegisterTypedAsTextTool(r, tt.ReplaceTextTool(), tt.ReplaceText); err != nil {

texttool/inserttextlines.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import (
1313
)
1414

1515
const (
16-
insertTextLinesFuncID spec.FuncID = "github.com/flexigpt/llmtools-go/texttool/inserttextlines.InsertTextLines"
17-
whereBetween string = "between"
18-
whereEnd string = "end"
16+
insertTextFuncID spec.FuncID = "github.com/flexigpt/llmtools-go/texttool/inserttext.InsertText"
17+
whereBetween string = "between"
18+
whereEnd string = "end"
1919
)
2020

21-
var insertTextLinesTool = spec.Tool{
21+
var insertTextTool = spec.Tool{
2222
SchemaVersion: spec.SchemaVersion,
2323
ID: "019c04d3-572e-7d26-b4ca-f37feb7e8368",
24-
Slug: "inserttextlines",
24+
Slug: "inserttext",
2525
Version: "v1.0.0",
2626
DisplayName: "Insert text",
2727
Description: "Insert a text block into a text file at the start, end, or between text. " +
@@ -65,13 +65,13 @@ var insertTextLinesTool = spec.Tool{
6565
"additionalProperties": false
6666
}`),
6767

68-
GoImpl: spec.GoToolImpl{FuncID: insertTextLinesFuncID},
68+
GoImpl: spec.GoToolImpl{FuncID: insertTextFuncID},
6969

7070
CreatedAt: spec.SchemaStartTime,
7171
ModifiedAt: spec.SchemaStartTime,
7272
}
7373

74-
type InsertTextLinesArgs struct {
74+
type InsertTextArgs struct {
7575
Path string `json:"path"`
7676
Text *string `json:"text"`
7777
Position string `json:"position"`
@@ -80,7 +80,7 @@ type InsertTextLinesArgs struct {
8080
LineHint *int `json:"lineHint,omitempty"`
8181
}
8282

83-
type InsertTextLinesOut struct {
83+
type InsertTextOut struct {
8484
InsertedAtLine int `json:"insertedAtLine"` // 1-based, where insertion begins
8585
InsertedLineCount int `json:"insertedLineCount"`
8686
TextAboveMatchedAtLine *int `json:"textAboveMatchedAtLine,omitempty"` // 1-based start line of the matched textAbove boundary block used in the original file
@@ -94,7 +94,7 @@ func normalizeOptionalTextBlock(s *string) []string {
9494
return ioutil.NormalizeTextBlockString(*s)
9595
}
9696

97-
// insertTextLines inserts Text into a UTF‑8 file.
97+
// insertText inserts Text into a UTF‑8 file.
9898
// Behavior notes (entry point):
9999
//
100100
// - File must exist, be regular, not a symlink, and valid UTF‑8.
@@ -104,11 +104,11 @@ func normalizeOptionalTextBlock(s *string) []string {
104104
// and insertion occurs at the start of that blank gap.
105105
// - The resulting insertion location must match exactly once; otherwise it fails.
106106
// - Writes are atomic and preserve newline style and final newline presence.
107-
func insertTextLines(
107+
func insertText(
108108
ctx context.Context,
109-
args InsertTextLinesArgs,
109+
args InsertTextArgs,
110110
p fspolicy.FSPolicy,
111-
) (*InsertTextLinesOut, error) {
111+
) (*InsertTextOut, error) {
112112
if err := ctx.Err(); err != nil {
113113
return nil, err
114114
}
@@ -171,7 +171,7 @@ func insertTextLines(
171171
return nil, err
172172
}
173173

174-
return &InsertTextLinesOut{
174+
return &InsertTextOut{
175175
InsertedAtLine: insertAt + 1,
176176
InsertedLineCount: len(textToInsert),
177177
TextAboveMatchedAtLine: textAboveAt,

0 commit comments

Comments
 (0)