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

fogfish / iq / 19150632324

06 Nov 2025 09:35PM UTC coverage: 40.252%. First build
19150632324

Pull #26

github

fogfish
improve ci/cd auto versioning
Pull Request #26: Compose AI workflow within the shell

1095 of 2628 new or added lines in 34 files covered. (41.67%)

1119 of 2780 relevant lines covered (40.25%)

0.43 hits per line

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

69.01
/cmd/draft.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
        "io"
14
        "os"
15

16
        "github.com/kshard/chatter"
17
        "github.com/spf13/cobra"
18
)
19

20
func init() {
1✔
21
        rootCmd.AddCommand(draftCmd)
1✔
22
        draftCmd.AddCommand(draftYamlCmd)
1✔
23
}
1✔
24

25
var draftCmd = &cobra.Command{
26
        Use:   "draft",
27
        Short: "generate prompt template",
28
        Long: `
29
iq recommends structured prompting using the TELeR framework — a practical
30
taxonomy that breaks prompts into clear components: Task, Environment, Learner,
31
and Response. This approach helps you craft reusable prompts by clearly defining
32
goals, constraints, tone, and expected outputs. Use it to improve prompt quality,
33
automate workflows, and ensure consistent LLM behavior across files and tasks.
34

35
See more info https://github.com/fogfish/iq
36
        `,
37
        Example: `
38
        # Generate prompt template
39
        iq draft
40

41
        # Generate prompt with LLM, using stdin as input for sketching the task
42
        echo "What are the colors of rainbow?" | iq draft
43

44
        # Generate workflow for agent execution
45
        iq draft agent
46
        `,
47
        SilenceUsage:  true,
48
        SilenceErrors: true,
49
        RunE:          draft,
50
}
51

52
func draft(cmd *cobra.Command, args []string) error {
1✔
53
        fi, err := os.Stdin.Stat()
1✔
54
        if err != nil {
1✔
55
                return err
×
56
        }
×
57

58
        if fi.Size() == 0 {
2✔
59
                os.Stdout.Write([]byte(teler()))
1✔
60
                return nil
1✔
61
        }
1✔
62

63
        subj, err := io.ReadAll(os.Stdin)
×
64
        if err != nil {
×
65
                return err
×
66
        }
×
67

NEW
68
        llm, err := fmodel.build()
×
69
        if err != nil {
×
70
                return err
×
71
        }
×
72

73
        var prompt chatter.Prompt
×
74
        prompt.WithTask(`
×
75
          You are a prompt engineer tasked with creating effective instructions
×
76
                for language models. Your task is to write a prompt that clearly defines
×
77
                a specific task for another LLM to perform: %s.
×
78
        `, subj)
×
79

×
80
        prompt.WithRules(
×
81
                `The prompt you write should be:`,
×
82

×
83
                `Define task, guidelines and requirments`,
×
84
                `Clear and unambiguous`,
×
85
                `Purpose-driven (have a clear goal)`,
×
86
                `Engaging and motivating`,
×
87
                `Scalable for variations of the task`,
×
NEW
88
                `The output should be Markdown text with YAML front matter as defined in example below.`,
×
NEW
89
                `Include the prompt only, without any explanation or commentary.
×
90
                        The task should be moderately challenging and involve reasoning,
×
91
                        creativity, or structured output.`,
×
92
        )
×
93

×
94
        prompt.With(
×
95
                chatter.Example{
×
96
                        Input: "What are the colors of rainbow?",
×
NEW
97
                        Reply: "---\nformat: text\n---\nDefine the sequence of colors in a rainbow...",
×
98
                },
×
99
        )
×
100

×
101
        reply, err := llm.Prompt(context.Background(), prompt.ToSeq())
×
102
        if err != nil {
×
103
                return err
×
104
        }
×
105

106
        os.Stdout.Write([]byte(reply.String()))
×
107
        return nil
×
108
}
109

110
func teler() string {
1✔
111
        return `---
1✔
112
format: text
1✔
113
schema:
1✔
114
  input:
1✔
115
    type: object
1✔
116
    required: [attr]
1✔
117
    properties:
1✔
118
      attr: {type: string}
1✔
119
  reply:
1✔
120
    type: object
1✔
121
    required: [attr]
1✔
122
    properties:
1✔
123
      attr: {type: string}
1✔
124
---
1✔
125
[Describe the task and goals clearly and concisely].
1✔
126

1✔
127
Guidelines:
1✔
128
        (1) [High-level principles or approach to follow.]
1✔
129
        (2) ...
1✔
130

1✔
131
Strictly adhere to the following requirements when generating a response.
1✔
132
Do not deviate, ignore, or modify any aspect of them:
1✔
133
        1. [Concrete requirement]
1✔
134
        2. [Another specific rule]
1✔
135
        ...
1✔
136

1✔
137
Example Input:
1✔
138
[Show an example of what the input might look like.]
1✔
139

1✔
140
Expected Output:
1✔
141
[Demonstrate the ideal format or structure of the response.]
1✔
142

1✔
143
Additional Context:
1✔
144
        - [Relevant detail #1]
1✔
145
        - [Constraint or domain knowledge #2]
1✔
146
        - ...
1✔
147

1✔
148
Input:
1✔
149
        [Insert the actual input here]
1✔
150

1✔
151
`
1✔
152
}
1✔
153

154
var draftYamlCmd = &cobra.Command{
155
        Use:   "agent",
156
        Short: "generate agent template",
157
        Long: `
158
xxx
159

160
See more info https://github.com/fogfish/iq
161
        `,
162
        Example: `
163
        # Generate workflow for agent execution
164
        iq draft agent
165
        `,
166
        SilenceUsage:  true,
167
        SilenceErrors: true,
168
        RunE:          draftYaml,
169
}
170

171
func draftYaml(cmd *cobra.Command, args []string) error {
1✔
172
        os.Stdout.Write([]byte(yaml()))
1✔
173
        return nil
1✔
174
}
1✔
175

176
func yaml() string {
1✔
177
        return `name: draft
1✔
178
jobs:
1✔
179
  main:
1✔
180
    steps:
1✔
181
      - uses: prompts/prompt.md
1✔
182

1✔
183
      - name: foobar
1✔
184
        uses: prompts/prompt.md
1✔
185
        output: foobar
1✔
186

1✔
187
      - name: foobar
1✔
188
        uses: prompts/prompt.md
1✔
189
        retry:
1✔
190
          attempts: 3
1✔
191
          delay: 2
1✔
192
          yield: prompts/fallback.md
1✔
193
        output: foobar
1✔
194

1✔
195
      - uses: prompts/prompt.md
1✔
196
        switch:
1✔
197
          - when: choice == "choice" && steps.foobar.category == "foo"
1✔
198
            route: func
1✔
199
        default: unknown
1✔
200

1✔
201
      - uses: prompts/prompt.md
1✔
202
        foreach:
1✔
203
          job: func
1✔
204

1✔
205

1✔
206
  func:
1✔
207
    steps:
1✔
208
      - uses: prompts/prompt.md
1✔
209

1✔
210
  unknown:
1✔
211
    steps:
1✔
212
      - uses: prompts/prompt.md
1✔
213

1✔
214
`
1✔
215
}
1✔
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