MCPcopy Create free account
hub / github.com/diillson/chatcli / diffReviewScript

Function diffReviewScript

cli/agent/workers/agents_reviewer.go:128–170  ·  view source on GitHub ↗

diffReviewScript fetches staged diff and changed files for review.

(ctx context.Context, input map[string]string, _ *engine.Engine)

Source from the content-addressed store, hash-verified

126
127// diffReviewScript fetches staged diff and changed files for review.
128func diffReviewScript(ctx context.Context, input map[string]string, _ *engine.Engine) (string, error) {
129 dir := input["dir"]
130 if dir == "" {
131 dir = "."
132 }
133
134 commands := []struct {
135 name string
136 cmd string
137 args []string
138 }{
139 {"Changed Files", "git-changed", []string{"--dir", dir}},
140 {"Staged Diff", "git-diff", []string{"--staged", "true", "--dir", dir}},
141 {"Unstaged Diff", "git-diff", []string{"--dir", dir}},
142 }
143
144 var results strings.Builder
145 results.WriteString("## Diff Review Data\n\n")
146
147 for _, c := range commands {
148 var buf bytes.Buffer
149 outWriter := engine.NewStreamWriter(func(line string) {
150 buf.WriteString(line)
151 buf.WriteString("\n")
152 })
153 errWriter := engine.NewStreamWriter(func(line string) {
154 buf.WriteString(line)
155 buf.WriteString("\n")
156 })
157
158 eng := engine.NewEngine(outWriter, errWriter, "")
159 err := eng.Execute(ctx, c.cmd, c.args)
160 outWriter.Flush()
161 errWriter.Flush()
162
163 fmt.Fprintf(&results, "### %s\n%s\n", c.name, buf.String())
164 if err != nil {
165 fmt.Fprintf(&results, "Error: %v\n", err)
166 }
167 }
168
169 return results.String(), nil
170}
171
172// scanLintScript runs go vet (and staticcheck if available) to find issues.
173func scanLintScript(ctx context.Context, input map[string]string, _ *engine.Engine) (string, error) {

Callers

nothing calls this directly

Calls 5

ExecuteMethod · 0.95
FlushMethod · 0.95
NewStreamWriterFunction · 0.92
NewEngineFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected