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

kshard / thinker / 15084025492

17 May 2025 09:48AM UTC coverage: 54.037% (-4.2%) from 58.222%
15084025492

Pull #20

github

fogfish
use echo for bash test
Pull Request #20: establish agent taxonomy - prompter, manifold, automata

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

65.63
/command/softcmd/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 softcmd
10

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

16
        "github.com/kshard/chatter"
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) Cmd {
1✔
25
        return Cmd{
1✔
26
                Cmd:    BASH,
1✔
27
                About:  fmt.Sprintf("executes shell command, strictly adhere shell command syntaxt to %s. Enclose the bash commands in <codeblock> tags.", os),
1✔
28
                Syntax: "bash <codeblock>source code</codeblock>",
1✔
29
                Run:    bash(os, dir),
1✔
30
        }
1✔
31
}
1✔
32

33
func bash(os string, dir string) func(*chatter.Reply) (float64, CmdOut, error) {
1✔
34
        return func(command *chatter.Reply) (float64, CmdOut, error) {
2✔
35
                code, err := CodeBlock(BASH, command.String())
1✔
36
                if err != nil {
1✔
NEW
37
                        return 0.00, CmdOut{Cmd: BASH}, err
×
NEW
38
                }
×
39

40
                cmd := exec.Command("bash", "-c", code)
1✔
41
                var stdout bytes.Buffer
1✔
42
                var stderr bytes.Buffer
1✔
43
                cmd.Dir = dir
1✔
44
                cmd.Stdout = &stdout
1✔
45
                cmd.Stderr = &stderr
1✔
46

1✔
47
                if err := cmd.Run(); err != nil {
1✔
NEW
48
                        err = thinker.Feedback(
×
NEW
49
                                fmt.Sprintf("The TOOL:%s has failed, improve the response based on feedback:", BASH),
×
NEW
50

×
NEW
51
                                fmt.Sprintf("Strictly adhere shell command syntaxt to %s.", os),
×
NEW
52
                                "Execution of the tool is failed with the error: "+err.Error(),
×
NEW
53
                                "The error output is "+stderr.String(),
×
NEW
54
                        )
×
NEW
55
                        return 0.05, CmdOut{Cmd: BASH}, err
×
NEW
56
                }
×
57

58
                return 1.0, CmdOut{Cmd: BASH, Output: stdout.String()}, nil
1✔
59
        }
60
}
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