Skip to content

Commit 3f32c87

Browse files
committed
refactor(writer): Remove leetcode_template config and usage
- Remove leetcode configuration from config.yaml - Remove leetcode_template initialization and usage from writer.py - Update prompt to use direct LeetCode URL format (LLM knows correct format) - Keep github_template for proper template substitution - Prevent misleading template configuration for LeetCode links
1 parent f8377be commit 3f32c87

File tree

3 files changed

+33
-15
lines changed

3 files changed

+33
-15
lines changed

tools/ai-markmap-agent/config/config.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ urls:
2929
github:
3030
base: "https://github.com/lufftw/neetcode"
3131
solution_template: "https://github.com/lufftw/neetcode/blob/main/{solution_file}"
32-
33-
leetcode:
34-
base: "https://leetcode.com"
35-
problem_template: "https://leetcode.com/problems/{slug}/"
3632

3733
# -----------------------------------------------------------------------------
3834
# Data Sources Configuration

tools/ai-markmap-agent/prompts/writer/writer_behavior.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,22 @@ Use this data to verify problem information and generate correct links:
4545
{problem_data}
4646

4747
### URL Templates
48-
- For problems WITH solution_file: `{github_template}`
49-
- For problems WITHOUT solution_file: `{leetcode_template}`
48+
49+
**CRITICAL: Link Generation Rules**
50+
51+
1. **If problem has `solution_file` (Has Solution = "Yes"):**
52+
- Use GitHub project link: `{github_template}`
53+
- Replace `{solution_file}` with the actual solution file path from problem metadata
54+
- Example: `https://github.com/lufftw/neetcode/blob/main/solutions/0905_sort_array_by_parity.py`
55+
- This takes priority over LeetCode links
56+
57+
2. **If problem has NO `solution_file` (Has Solution = "No"):**
58+
- Use LeetCode problem link with CORRECT format
59+
- Format: `https://leetcode.com/problems/{slug}/description/`
60+
- The `slug` is provided in the problem metadata table
61+
- **IMPORTANT**: Use the slug as-is from metadata (e.g., `container-with-most-water`), NOT the problem ID format (e.g., NOT `0011_container_with_most_water`)
62+
- You know the correct LeetCode URL format - use it correctly
63+
- Example: `https://leetcode.com/problems/container-with-most-water/description/`
5064

5165
### Ontology Reference
5266
{ontology_summary}
@@ -84,10 +98,23 @@ Use this data to verify problem information and generate correct links:
8498
- Match emoji usage with baseline (if any)
8599

86100
### Link Format
87-
- LeetCode problems: Use full "LeetCode" not "LC"
88-
- Solution links: Use GitHub template when solution exists
89-
- Problem links: Use LeetCode template when no solution
90-
- Format: `[Problem Title](url)`
101+
102+
**Priority Order:**
103+
1. **If solution exists (Has Solution = "Yes"):** Use GitHub project link
104+
- Format: `[Problem Title](https://github.com/lufftw/neetcode/blob/main/solutions/XXXX_problem_name.py)`
105+
- Example: `[LeetCode 905 - Sort Array By Parity](https://github.com/lufftw/neetcode/blob/main/solutions/0905_sort_array_by_parity.py)`
106+
107+
2. **If no solution (Has Solution = "No"):** Use LeetCode problem link
108+
- Format: `[Problem Title](https://leetcode.com/problems/{slug}/description/)`
109+
- Use the `slug` from problem metadata (e.g., `container-with-most-water`)
110+
- **DO NOT** use problem ID format like `0011_container_with_most_water`
111+
- **DO** use the correct slug format: `container-with-most-water`
112+
- Example: `[LeetCode 11 - Container With Most Water](https://leetcode.com/problems/container-with-most-water/description/)`
113+
114+
**General Rules:**
115+
- Always use full "LeetCode" not "LC" in link text
116+
- Format: `[Problem Title](url)`
117+
- Verify all links are correct before outputting
91118

92119
### Markmap Features
93120
- Use `<!-- markmap: fold -->` for collapsible sections

tools/ai-markmap-agent/src/agents/writer.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ def __init__(self, config: dict[str, Any] | None = None):
5555
"solution_template",
5656
"https://github.com/lufftw/neetcode/blob/main/{solution_file}"
5757
)
58-
self.leetcode_template = urls_config.get("leetcode", {}).get(
59-
"problem_template",
60-
"https://leetcode.com/problems/{slug}/"
61-
)
6258

6359
def _load_format_guide(self, model_config: dict) -> str:
6460
"""Load the Markmap format guide."""
@@ -170,7 +166,6 @@ def process(self, state: dict[str, Any]) -> dict[str, Any]:
170166
improvement_details=detailed_descriptions,
171167
problem_data=self._format_problems_for_prompt(problems_lookup),
172168
github_template=self.github_template,
173-
leetcode_template=self.leetcode_template,
174169
ontology_summary=self._format_ontology(ontology),
175170
)
176171

0 commit comments

Comments
 (0)