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

kshard / thinker / 15084249817

17 May 2025 10:20AM UTC coverage: 54.037% (-4.2%) from 58.222%
15084249817

push

github

web-flow
establish agent taxonomy - prompter, manifold, automata (#20)

331 of 612 new or added lines in 28 files covered. (54.08%)

8 existing lines in 4 files now uncovered.

609 of 1127 relevant lines covered (54.04%)

0.57 hits per line

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

62.79
/command/bash.go
1
//
2
// Copyright (C) 2025 Dmitry Kolesnikov
3
//
4
// This file may be modified and distributed under the terms
5
// of the MIT license.  See the LICENSE file for details.
6
// https://github.com/kshard/thinker
7
//
8

9
package command
10

11
import (
12
        "bytes"
13
        "encoding/json"
14
        "fmt"
15
        "os/exec"
16

17
        "github.com/kshard/thinker"
18
)
19

20
// A unique name for bash (the shell)
21
const BASH = "bash"
22

23
// Create new bash command, defining the os variant and working dir
24
func Bash(os, dir string) thinker.Cmd {
1✔
25
        return thinker.Cmd{
1✔
26
                Cmd:   BASH,
1✔
27
                About: fmt.Sprintf("Executes shell command on %s operating system.", os),
1✔
28
                Args: []thinker.Arg{
1✔
29
                        {
1✔
30
                                Name:  "script",
1✔
31
                                Type:  "string",
1✔
32
                                About: `script is single or sequence of bash commands passed to bash -c "script".`,
1✔
33
                        },
1✔
34
                },
1✔
35
                Run: bash(os, dir),
1✔
36
        }
1✔
37
}
1✔
38

39
type script struct {
40
        Script string `json:"script"`
41
}
42

43
func bash(os string, dir string) func(json.RawMessage) ([]byte, error) {
1✔
44
        return func(command json.RawMessage) ([]byte, error) {
2✔
45
                var code script
1✔
46
                if err := json.Unmarshal(command, &code); err != nil {
1✔
NEW
47
                        err := thinker.Feedback(
×
NEW
48
                                "The input does not contain valid JSON object",
×
NEW
49
                                "JSON parsing has failed with an error "+err.Error(),
×
NEW
50
                        )
×
NEW
51
                        return nil, err
×
UNCOV
52
                }
×
53

54
                cmd := exec.Command("bash", "-c", code.Script)
1✔
55
                var stdout bytes.Buffer
1✔
56
                var stderr bytes.Buffer
1✔
57
                cmd.Dir = dir
1✔
58
                cmd.Stdout = &stdout
1✔
59
                cmd.Stderr = &stderr
1✔
60

1✔
61
                if err := cmd.Run(); err != nil {
1✔
62
                        err = thinker.Feedback(
×
NEW
63
                                fmt.Sprintf("The tool %s has failed, improve the response based on feedback:", BASH),
×
64

×
65
                                fmt.Sprintf("Strictly adhere shell command syntaxt to %s.", os),
×
66
                                "Execution of the tool is failed with the error: "+err.Error(),
×
67
                                "The error output is "+stderr.String(),
×
68
                        )
×
NEW
69

×
NEW
70
                        return nil, err
×
UNCOV
71
                }
×
72

73
                return stdout.Bytes(), nil
1✔
74
        }
75
}
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