• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kshard / thinker / 15082283232

17 May 2025 05:53AM UTC coverage: 33.807% (-24.4%) from 58.222%
15082283232

Pull #20

github

fogfish
establish agent taxonomy - prompter, manifold, automata
Pull Request #20: establish agent taxonomy - prompter, manifold, automata

241 of 611 new or added lines in 28 files covered. (39.44%)

145 existing lines in 5 files now uncovered.

381 of 1127 relevant lines covered (33.81%)

0.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/command/bash.go
1
package command
2

3
import (
4
        "bytes"
5
        "encoding/json"
6
        "fmt"
7
        "os/exec"
8

9
        "github.com/kshard/thinker"
10
)
11

12
// A unique name for bash (the shell)
13
const BASH = "bash"
14

15
// Create new bash command, defining the os variant and working dir
UNCOV
16
func Bash(os, dir string) thinker.Cmd {
×
UNCOV
17
        return thinker.Cmd{
×
NEW
18
                Cmd:   BASH,
×
NEW
19
                About: fmt.Sprintf("Executes shell command on %s operating system.", os),
×
NEW
20
                Args: []thinker.Arg{
×
NEW
21
                        {
×
NEW
22
                                Name:  "script",
×
NEW
23
                                Type:  "string",
×
NEW
24
                                About: `script is single or sequence of bash commands passed to bash -c "script".`,
×
NEW
25
                        },
×
NEW
26
                },
×
NEW
27
                Run: bash(os, dir),
×
UNCOV
28
        }
×
UNCOV
29
}
×
30

31
type script struct {
32
        Script string `json:"script"`
33
}
34

NEW
35
func bash(os string, dir string) func(json.RawMessage) ([]byte, error) {
×
NEW
36
        return func(command json.RawMessage) ([]byte, error) {
×
NEW
37
                var code script
×
NEW
38
                if err := json.Unmarshal(command, &code); err != nil {
×
NEW
39
                        err := thinker.Feedback(
×
NEW
40
                                "The input does not contain valid JSON object",
×
NEW
41
                                "JSON parsing has failed with an error "+err.Error(),
×
NEW
42
                        )
×
NEW
43
                        return nil, err
×
UNCOV
44
                }
×
45

NEW
46
                cmd := exec.Command("bash", "-c", code.Script)
×
UNCOV
47
                var stdout bytes.Buffer
×
UNCOV
48
                var stderr bytes.Buffer
×
UNCOV
49
                cmd.Dir = dir
×
UNCOV
50
                cmd.Stdout = &stdout
×
UNCOV
51
                cmd.Stderr = &stderr
×
UNCOV
52

×
UNCOV
53
                if err := cmd.Run(); err != nil {
×
54
                        err = thinker.Feedback(
×
NEW
55
                                fmt.Sprintf("The tool %s has failed, improve the response based on feedback:", BASH),
×
56

×
57
                                fmt.Sprintf("Strictly adhere shell command syntaxt to %s.", os),
×
58
                                "Execution of the tool is failed with the error: "+err.Error(),
×
59
                                "The error output is "+stderr.String(),
×
60
                        )
×
NEW
61

×
NEW
62
                        return nil, err
×
UNCOV
63
                }
×
64

NEW
65
                return stdout.Bytes(), nil
×
66
        }
67
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc