Skip to content

Commit d08391c

Browse files
committed
mcp - add modified and committed to code tool results
1 parent 59135e2 commit d08391c

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ gSuneido is the Go implementation of the Suneido integrated language and databas
2828
- use `make` to build the project (**not** `go build`)
2929

3030
## Testing
31+
- **IMPORTANT** Run applicable tests after making changes
3132
- **IMPORTANT** Do not change directories with cd to run tests
3233
- **IMPORTANT** When running `go test` include: `-short -timeout=30s`
3334

mcp/codetool.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func codeTool(library, name string, startLine int, plain bool) (readCodeOutput,
2020
if startLine < 1 {
2121
return readCodeOutput{}, fmt.Errorf("start_line must be >= 1")
2222
}
23-
23+
2424
th := core.NewThread(core.MainThread)
2525
defer th.Close()
2626
libs := th.Dbms().Libraries()
@@ -61,10 +61,22 @@ func codeTool(library, name string, startLine int, plain bool) (readCodeOutput,
6161
StartLine: startLine,
6262
TotalLines: totalLines,
6363
HasMore: hasMore,
64+
Modified: formatDateVal(row.GetVal(hdr, "lib_modified", th, st)),
65+
Committed: formatDateVal(row.GetVal(hdr, "lib_committed", th, st)),
6466
}
6567
return result, nil
6668
}
6769

70+
func formatDateVal(val core.Value) string {
71+
if val == nil {
72+
return ""
73+
}
74+
if d, ok := core.AsDate(val); ok {
75+
return d.Format("yyyy-MM-dd HH:mm:ss")
76+
}
77+
return ""
78+
}
79+
6880
func sliceCode(text string, startLine int, limit int) (string, int, bool) {
6981
if text == "" {
7082
return "", 0, false

mcp/tools.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,15 @@ var _ = addTool(toolSpec{
127127
})
128128

129129
type readCodeOutput struct {
130-
Plain bool `json:"plain" jsonschema:"description=Whether line numbers were omitted"`
131-
Library string `json:"library" jsonschema:"description=Library name the definition was loaded from"`
132-
Name string `json:"name" jsonschema:"description=Definition name"`
133-
Text string `json:"text" jsonschema:"description=The source code content"`
134-
StartLine int `json:"start_line" jsonschema:"description=1-based starting line number for the snippet"`
135-
TotalLines int `json:"total_lines" jsonschema:"description=Total number of lines in the definition"`
136-
HasMore bool `json:"has_more,omitempty" jsonschema:"description=True when additional lines remain past the snippet"`
130+
Plain bool `json:"plain" jsonschema:"description=Whether line numbers were omitted"`
131+
Library string `json:"library" jsonschema:"description=Library name the definition was loaded from"`
132+
Name string `json:"name" jsonschema:"description=Definition name"`
133+
Text string `json:"text" jsonschema:"description=The source code content"`
134+
StartLine int `json:"start_line" jsonschema:"description=1-based starting line number for the returned text"`
135+
TotalLines int `json:"total_lines" jsonschema:"description=Total number of lines in the definition"`
136+
HasMore bool `json:"has_more,omitempty" jsonschema:"description=True when additional lines remain past the returned text"`
137+
Modified string `json:"modified,omitempty" jsonschema:"description=Date/time when the record was last modified"`
138+
Committed string `json:"committed,omitempty" jsonschema:"description=Date/time when the record was last committed to version control"`
137139
}
138140

139141
// search_code

0 commit comments

Comments
 (0)