(path, mode string)
| 836 | } |
| 837 | |
| 838 | func buildPromptBundle(path, mode string) (promptBundle, error) { |
| 839 | if mode != "codex" { |
| 840 | return promptBundle{}, fmt.Errorf("unsupported mode %q (supported: codex)", mode) |
| 841 | } |
| 842 | |
| 843 | absPath, err := filepath.Abs(strings.TrimSpace(path)) |
| 844 | if err != nil { |
| 845 | return promptBundle{}, fmt.Errorf("resolve absolute path: %w", err) |
| 846 | } |
| 847 | |
| 848 | contentBytes, err := os.ReadFile(absPath) |
| 849 | if err != nil { |
| 850 | return promptBundle{}, fmt.Errorf("read spec file %s: %w", absPath, err) |
| 851 | } |
| 852 | content := string(contentBytes) |
| 853 | if strings.TrimSpace(content) == "" { |
| 854 | return promptBundle{}, fmt.Errorf("spec file %s is empty", absPath) |
| 855 | } |
| 856 | |
| 857 | repoRoot := findGitRoot(filepath.Dir(absPath)) |
| 858 | branch := currentBranch(repoRoot) |
| 859 | sections := parseSections(content) |
| 860 | title := parseTitle(content) |
| 861 | |
| 862 | prompt := buildCodexPrompt(absPath, repoRoot, branch, title, sections) |
| 863 | |
| 864 | return promptBundle{ |
| 865 | SpecPath: absPath, |
| 866 | RepoRoot: repoRoot, |
| 867 | Branch: branch, |
| 868 | Title: title, |
| 869 | Sections: sections, |
| 870 | Prompt: prompt, |
| 871 | }, nil |
| 872 | } |
| 873 | |
| 874 | func normalizeArgs(args []string) []string { |
| 875 | if len(args) == 0 { |
no test coverage detected