Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Binary output
coding-agent-context-cli

# Build artifacts
/dist/
/tmp/
9 changes: 4 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ func run(args []string) error {
return fmt.Errorf("invalid usage")
}

taskName := args[0]

if err := os.Mkdir(outputDir, 0755); err != nil {
return fmt.Errorf("failed to create output dir: %w", err)
}
Expand All @@ -71,7 +69,7 @@ func run(args []string) error {
return fmt.Errorf("failed to create bootstrap dir: %w", err)
}

output, err := os.Open(filepath.Join(outputDir, "prompt.md"))
output, err := os.Create(filepath.Join(outputDir, "prompt.md"))
if err != nil {
return fmt.Errorf("failed to create prompt file: %w", err)
}
Expand All @@ -93,14 +91,14 @@ func run(args []string) error {
Bootstrap string `yaml:"bootstrap"`
}

content, err := parseMarkdownFile(filepath.Join(path), &frontmatter)
content, err := parseMarkdownFile(path, &frontmatter)
if err != nil {
return fmt.Errorf("failed to parse markdown file: %w", err)
}

if bootstrap := frontmatter.Bootstrap; bootstrap != "" {
hash := sha256.Sum256([]byte(bootstrap))
bootstrapPath := filepath.Join(bootstrapDir, fmt.Sprint(hash))
bootstrapPath := filepath.Join(bootstrapDir, fmt.Sprintf("%x", hash))
if err := os.WriteFile(bootstrapPath, []byte(bootstrap), 0700); err != nil {
return fmt.Errorf("failed to write bootstrap file: %w", err)
}
Expand All @@ -122,6 +120,7 @@ func run(args []string) error {
return fmt.Errorf("failed to write bootstrap file: %w", err)
}

taskName := args[0]
for _, dir := range dirs {
promptFile := filepath.Join(dir, "prompts", taskName+".md")

Expand Down
4 changes: 2 additions & 2 deletions markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func parseMarkdownFile(path string, frontmatter any) (string, error) {

s := bufio.NewScanner(fh)

if s.Text() != "---" {
if s.Scan() && s.Text() == "---" {
var frontMatterBytes bytes.Buffer
for s.Scan() {
line := s.Text()
Expand All @@ -40,7 +40,7 @@ func parseMarkdownFile(path string, frontmatter any) (string, error) {

var content bytes.Buffer
for s.Scan() {
if _, err := content.Write(s.Bytes()); err != nil {
if _, err := content.WriteString(s.Text() + "\n"); err != nil {
return "", fmt.Errorf("failed to write content: %w", err)
}
}
Expand Down