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

fogfish / iq / 14808938208

03 May 2025 07:52AM UTC coverage: 40.625%. First build
14808938208

Pull #17

github

fogfish
configurable context for large files
Pull Request #17: configurable context for large files

78 of 130 new or added lines in 7 files covered. (60.0%)

338 of 832 relevant lines covered (40.63%)

0.44 hits per line

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

79.59
/cmd/task.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/fogfish/iq
7
//
8

9
package cmd
10

11
import (
12
        "context"
13
        "fmt"
14
        "io"
15
        "os"
16
        "path/filepath"
17

18
        "github.com/fogfish/iq/internal/reader"
19
        "github.com/spf13/cobra"
20
)
21

22
var (
23
        execWithBash   bool
24
        execWithGolang bool
25
        execWithPython bool
26
        execWorkDir    string
27
)
28

29
func init() {
1✔
30
        rootCmd.AddCommand(execCmd)
1✔
31

1✔
32
        execCmd.Flags().BoolVar(&execWithBash, "bash", false, "enable bash in the command registry")
1✔
33
        execCmd.Flags().BoolVar(&execWithGolang, "golang", false, "enable golang in the command registry")
1✔
34
        execCmd.Flags().BoolVar(&execWithPython, "python", false, "enable python in the command registry")
1✔
35
        execCmd.Flags().StringVar(&execWorkDir, "workdir", "", "work directory for tools and commands")
1✔
36
}
1✔
37

38
var execCmd = &cobra.Command{
39
        Use:   "task",
40
        Short: "execute LLM-agent with prompt instructions",
41
        Long: `
42
We assume LLM-powered agent is a system that dynamically direct their own
43
processes and available tool to accomplish task. Unlike a single prompt,
44
a workflow allows the model to reason through multiple steps — such as reading,
45
generating, modifying, and combining files — to accomplish a complex goal.
46
Each step builds on the last, forming a coherent process that mimics how a human
47
might complete a task using a shell or scripting environment.
48

49
It empowers LLMs with Bash, Golang and Python as available tools to accomplish
50
defined task.
51

52

53
See more info https://github.com/fogfish/iq
54
        `,
55
        Example: `
56
        iq task -p mytask.yml
57
        iq task -p mytask.yml FILE1 FILE2 ...
58
        echo "Using available tools draw the rainbow?" | iq task --python
59
        `,
60
        SilenceUsage:  true,
61
        SilenceErrors: true,
62
        RunE:          withUsage(exec),
63
}
64

65
func exec(cmd *cobra.Command, args []string) error {
1✔
66
        spinner := createSpinner()
1✔
67
        defer spinner.Finish()
1✔
68

1✔
69
        agt, req, err := agentForTasks(execWorkDir)
1✔
70
        if err != nil {
1✔
71
                return err
×
72
        }
×
73

74
        if len(args) == 0 {
2✔
75
                spinner.Describe("processing ...")
1✔
76
                reply, err := agt.PromptOnce(context.Background(), req)
1✔
77
                if err != nil {
1✔
78
                        return err
×
79
                }
×
80
                spinner.Finish()
1✔
81

1✔
82
                os.Stdout.Write(reply)
1✔
83
                os.Stdout.WriteString("\n")
1✔
84
                return nil
1✔
85
        }
86

87
        q, err := createSpool("/", "stdout", false, true)
1✔
88
        if err != nil {
1✔
NEW
89
                return err
×
NEW
90
        }
×
91

92
        for i, arg := range args {
2✔
93
                path, err := filepath.Abs(arg)
1✔
94
                if err != nil {
1✔
95
                        return err
×
96
                }
×
97
                args[i] = filepath.Clean(path)
1✔
98
        }
99

100
        err = q.ForEachPath(context.Background(), args,
1✔
101
                func(ctx context.Context, path string, r io.Reader, w io.Writer) error {
2✔
102
                        spinner.Describe(fmt.Sprintf("processing with %s", ellipses(filepath.Base(path))))
1✔
103
                        defer spinner.Reset()
1✔
104

1✔
105
                        fd := reader.New(rootScanner, rootScannerChars, rootScannerChunk, r)
1✔
106
                        return reader.Process(ctx, agt, req, fd, w)
1✔
107
                },
1✔
108
        )
109
        if err != nil {
1✔
NEW
110
                return err
×
111
        }
×
112

113
        return nil
1✔
114
}
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