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

kshard / thinker / 15083532464

17 May 2025 08:42AM UTC coverage: 33.807% (-24.4%) from 58.222%
15083532464

Pull #20

github

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

241 of 612 new or added lines in 28 files covered. (39.38%)

144 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
//
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
UNCOV
24
func Bash(os, dir string) thinker.Cmd {
×
UNCOV
25
        return thinker.Cmd{
×
NEW
26
                Cmd:   BASH,
×
NEW
27
                About: fmt.Sprintf("Executes shell command on %s operating system.", os),
×
NEW
28
                Args: []thinker.Arg{
×
NEW
29
                        {
×
NEW
30
                                Name:  "script",
×
NEW
31
                                Type:  "string",
×
NEW
32
                                About: `script is single or sequence of bash commands passed to bash -c "script".`,
×
NEW
33
                        },
×
NEW
34
                },
×
NEW
35
                Run: bash(os, dir),
×
UNCOV
36
        }
×
UNCOV
37
}
×
38

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

NEW
43
func bash(os string, dir string) func(json.RawMessage) ([]byte, error) {
×
NEW
44
        return func(command json.RawMessage) ([]byte, error) {
×
NEW
45
                var code script
×
NEW
46
                if err := json.Unmarshal(command, &code); err != nil {
×
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

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

×
UNCOV
61
                if err := cmd.Run(); err != nil {
×
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

NEW
73
                return stdout.Bytes(), nil
×
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