[READ-ONLY] Mirror of https://github.com/andrioid/statesman. xstate inspired schema compatible statechart library for Go
fsm
go
statecharts
1.1 kB
45 lines
1package investigate
2
3import (
4 "context"
5 "time"
6
7 "github.com/andrioid/statesman/examples/issues/agent"
8)
9
10// AnalyseInput / AnalyseResult are the analyse promise adapter's I/O.
11type AnalyseInput struct {
12 Number int
13 Title string
14 Body string
15}
16
17type AnalyseResult struct{ Findings string }
18
19const analysePrompt = `Investigate GitHub issue #{{.Number}} in this repository using read-only tools.
20
21Title: {{.Title}}
22
23Body:
24{{.Body}}
25
26Produce concise root-cause findings (a few sentences). Do not modify any files.`
27
28type analyseVars struct {
29 Number int
30 Title string
31 Body string
32}
33
34// AnalyseCode runs the code-analysis agent for the issue (the "LLM agent from
35// shell"). ctx bounds the subprocess so the AnalyseTimeout edge can kill it.
36func AnalyseCode(ctx context.Context, in AnalyseInput) (AnalyseResult, error) {
37 out, err := agent.Invoke(ctx, "analyse", analysePrompt, analyseVars{in.Number, in.Title, in.Body})
38 if err != nil {
39 return AnalyseResult{}, err
40 }
41 return AnalyseResult{Findings: out}, nil
42}
43
44// AnalyseTimeout bounds a single analysis run (delays.go convention).
45const AnalyseTimeout = 5 * time.Minute