(specPath, repoRoot, branch, title string, sections map[string]section)
| 920 | } |
| 921 | |
| 922 | func buildCodexPrompt(specPath, repoRoot, branch, title string, sections map[string]section) string { |
| 923 | var b strings.Builder |
| 924 | |
| 925 | writeLine := func(s string) { |
| 926 | b.WriteString(s) |
| 927 | b.WriteByte('\n') |
| 928 | } |
| 929 | |
| 930 | specRef := specRefForPrompt(specPath, repoRoot) |
| 931 | |
| 932 | writeLine("You are Codex in execution mode. Implement exactly from the provided spec with high rigor and minimal drift.") |
| 933 | writeLine("") |
| 934 | writeLine("Execution context:") |
| 935 | if repoRoot != "" { |
| 936 | writeLine(fmt.Sprintf("- Work in: %s", repoRoot)) |
| 937 | } |
| 938 | if branch != "" { |
| 939 | writeLine(fmt.Sprintf("- Branch: %s", branch)) |
| 940 | } |
| 941 | writeLine(fmt.Sprintf("- Task spec: %s", specRef)) |
| 942 | if title != "" { |
| 943 | writeLine(fmt.Sprintf("- Spec title: %s", title)) |
| 944 | } |
| 945 | writeLine("") |
| 946 | writeLine("Primary objective:") |
| 947 | writeLine("- Execute the spec end-to-end with full type/runtime/test integrity.") |
| 948 | writeLine("") |
| 949 | writeLine("Primary instructions:") |
| 950 | writeLine("1. Read the spec file completely before editing any code.") |
| 951 | writeLine("2. Treat the spec as source of truth for scope, order, and acceptance criteria.") |
| 952 | writeLine("3. Do not expand scope beyond the spec unless required to satisfy an explicit invariant.") |
| 953 | writeLine("4. When spec and code disagree, prioritize spec intent and record the exact deviation in your final summary.") |
| 954 | writeLine("5. Keep changes minimal, coherent, and reviewer-friendly.") |
| 955 | writeLine("6. Run verification commands/tests defined by the spec and report results succinctly.") |
| 956 | writeLine("") |
| 957 | writeLine("Output contract for your final response:") |
| 958 | writeLine("1. What changed (grouped by file)") |
| 959 | writeLine("2. Invariants checklist (pass/fail)") |
| 960 | writeLine("3. Exact verification commands run + concise outputs") |
| 961 | writeLine("4. Commit hashes") |
| 962 | writeLine("5. Residual risks / follow-ups") |
| 963 | writeLine("") |
| 964 | |
| 965 | ordered := prioritizedSections(sections) |
| 966 | if len(ordered) > 0 { |
| 967 | writeLine("Key spec excerpts (authoritative):") |
| 968 | for _, s := range ordered { |
| 969 | writeLine("") |
| 970 | writeLine(fmt.Sprintf("## %s", s.Title)) |
| 971 | writeLine(strings.TrimSpace(s.Content)) |
| 972 | } |
| 973 | writeLine("") |
| 974 | } |
| 975 | |
| 976 | writeLine("Mandatory execution gates:") |
| 977 | writeLine("- Follow the spec's implementation order and file manifest.") |
| 978 | writeLine("- Preserve all non-negotiable invariants in the spec.") |
| 979 | writeLine("- Execute required post-edit assertions and tests from the spec.") |
no test coverage detected