Skip to content

Commit 9ee1d21

Browse files
author
Jaakko Heusala
committed
Initial gndc
1 parent f5a4ddd commit 9ee1d21

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

cmd/gndc/main.go

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"path/filepath"
7+
"strings"
8+
)
9+
10+
// Prompt represents a single LLM prompt
11+
type Prompt struct {
12+
ID string
13+
Content string
14+
Description string
15+
}
16+
17+
// SplitPrompt splits a large prompt into smaller LLM-based prompts
18+
func SplitPrompt(content string) ([]Prompt, error) {
19+
// TODO: Implement actual LLM-based prompt splitting
20+
// For now, just create a single prompt
21+
return []Prompt{
22+
{
23+
ID: "main",
24+
Content: content,
25+
Description: "Main prompt",
26+
},
27+
}, nil
28+
}
29+
30+
func main() {
31+
if len(os.Args) != 3 {
32+
fmt.Println("Usage: gndc <input-file> <output-dir>")
33+
os.Exit(1)
34+
}
35+
36+
inputFile := os.Args[1]
37+
outputDir := os.Args[2]
38+
39+
// Read input file
40+
content, err := os.ReadFile(inputFile)
41+
if err != nil {
42+
fmt.Printf("Error reading input file: %v\n", err)
43+
os.Exit(1)
44+
}
45+
46+
// Split prompt
47+
prompts, err := SplitPrompt(string(content))
48+
if err != nil {
49+
fmt.Printf("Error splitting prompt: %v\n", err)
50+
os.Exit(1)
51+
}
52+
53+
// Create output directory if it doesn't exist
54+
if err := os.MkdirAll(outputDir, 0755); err != nil {
55+
fmt.Printf("Error creating output directory: %v\n", err)
56+
os.Exit(1)
57+
}
58+
59+
// Write each prompt to a separate file
60+
for _, prompt := range prompts {
61+
outputFile := filepath.Join(outputDir, prompt.ID+".gnd")
62+
63+
// Format: one instruction per line
64+
// Each line: opcode destination input1 input2 ...
65+
instructions := []string{
66+
"# " + prompt.Description,
67+
"identity _ _", // Start with identity operation
68+
}
69+
70+
// TODO: Process prompt content into actual instructions
71+
// For now, just add a placeholder instruction
72+
instructions = append(instructions, "llm _ _")
73+
74+
output := strings.Join(instructions, "\n")
75+
if err := os.WriteFile(outputFile, []byte(output), 0644); err != nil {
76+
fmt.Printf("Error writing output file: %v\n", err)
77+
os.Exit(1)
78+
}
79+
}
80+
}

0 commit comments

Comments
 (0)