diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0c3f82b --- /dev/null +++ b/.gitignore @@ -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/ diff --git a/main.go b/main.go index 55b386b..02509c1 100644 --- a/main.go +++ b/main.go @@ -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) } @@ -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) } @@ -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) } @@ -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") diff --git a/markdown.go b/markdown.go index eb35636..b1cb86c 100644 --- a/markdown.go +++ b/markdown.go @@ -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() @@ -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) } }