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

Function smartCommitScript

cli/agent/workers/agents_git.go:116–151  ·  view source on GitHub ↗

smartCommitScript runs git status and diff to prepare for a commit.

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

Source from the content-addressed store, hash-verified

114
115// smartCommitScript runs git status and diff to prepare for a commit.
116func smartCommitScript(ctx context.Context, input map[string]string, _ *engine.Engine) (string, error) {
117 var results strings.Builder
118
119 commands := []struct {
120 name string
121 cmd string
122 args []string
123 }{
124 {"Status", "git-status", []string{}},
125 {"Staged Diff", "git-diff", []string{"--staged", "true"}},
126 }
127
128 for _, c := range commands {
129 var buf bytes.Buffer
130 outWriter := engine.NewStreamWriter(func(line string) {
131 buf.WriteString(line)
132 buf.WriteString("\n")
133 })
134 errWriter := engine.NewStreamWriter(func(line string) {
135 buf.WriteString(line)
136 buf.WriteString("\n")
137 })
138
139 eng := engine.NewEngine(outWriter, errWriter, "")
140 err := eng.Execute(ctx, c.cmd, c.args)
141 outWriter.Flush()
142 errWriter.Flush()
143
144 fmt.Fprintf(&results, "### %s\n%s\n", c.name, buf.String())
145 if err != nil {
146 fmt.Fprintf(&results, "Error: %v\n", err)
147 }
148 }
149
150 return results.String(), nil
151}
152
153// reviewChangesScript provides a comprehensive diff review.
154func reviewChangesScript(ctx context.Context, input map[string]string, _ *engine.Engine) (string, error) {

Callers 1

TestSmartCommitScriptFunction · 0.85

Calls 5

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

Tested by 1

TestSmartCommitScriptFunction · 0.68