MCPcopy Index your code
hub / github.com/nikivdev/go / buildPromptBundle

Function buildPromptBundle

cli/spec/main.go:838–872  ·  view source on GitHub ↗
(path, mode string)

Source from the content-addressed store, hash-verified

836}
837
838func 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
874func normalizeArgs(args []string) []string {
875 if len(args) == 0 {

Callers 2

runPromptFunction · 0.85
runExecFunction · 0.85

Calls 5

findGitRootFunction · 0.85
currentBranchFunction · 0.85
parseSectionsFunction · 0.85
parseTitleFunction · 0.85
buildCodexPromptFunction · 0.85

Tested by

no test coverage detected