- This repo is a small Python generator for the root
README.md. - Inputs:
meta/articles.yaml, existing README table rows used as a metadata cache,solutions/Java files, andsrc/little_algorithm/templates/README.md.j2. - Main package:
src/little_algorithm/ - CLI entrypoint:
generate = little_algorithm.generate:main - Build config:
pyproject.toml
- Python:
3.14from.python-version - Runner/package manager:
uv - Build backend:
setuptools - Runtime deps:
jinja2,pyyaml,requests - No configured linter, formatter, or test runner
- No Cursor rules in
.cursor/rules/ - No
.cursorrules - No
.github/copilot-instructions.md
pyproject.toml— package metadata and console scriptMakefile—makeruns the generatorREADME.md— generated output and metadata cachemeta/articles.yaml— article/problem mapping inputsrc/little_algorithm/generate.py— orchestration logicsrc/little_algorithm/leetcode.py— LeetCode HTTP/API codesrc/little_algorithm/models.py— domain dataclassessrc/little_algorithm/readme.py— Jinja rendering helpersrc/little_algorithm/templates/README.md.j2— README templatesolutions/— Java reference solutions used as data input
Primary command:
uv run generateMake shortcuts:
make
make all- Packaging is managed through
setuptoolsinpyproject.toml. - There is no separate repo build script beyond running the generator.
- No lint command is configured.
- No formatter command is configured.
- Do not invent repo-standard lint or format commands in docs or commits.
- No test suite is currently present.
- No
tests/directory was found. - No
pytest,unittestconfig,tox, ornoxconfig was found. - Do not claim tests were run unless you actually added and ran them.
- There is currently no project-specific single-test command.
- If
pytestis added later, the expected single-test form would be:
uv run pytest path/to/test_file.py::test_name- Only use or document that after
pytestis actually added.
- For generator changes, run:
uv run generate- Then inspect the resulting diff in
README.md. - Confirm ordering, table rows, and links still look correct.
- If you touch
leetcode.py, validation may require network access.
- Follow the existing code style instead of introducing a new one.
- Prefer minimal, local changes.
- Keep functions small and single-purpose.
- Favor straightforward procedural flow over abstraction-heavy designs.
- Prefer readability over cleverness.
- Use
from __future__ import annotationsat the top of Python modules. - Group imports as: standard library, third-party, local package.
- Separate groups with a blank line.
- Prefer explicit imports; avoid wildcard imports.
- Use 4-space indentation.
- Match the repository's current spacing and blank-line style.
- Split long regexes, comprehensions, and constructor calls across lines when it improves readability.
- Prefer f-strings for interpolation.
- Add explicit type hints for public functions and important helpers.
- Use modern built-in generics like
list[str]anddict[str, ProblemMetadata]. - Use
X | Noneinstead ofOptional[X]. - Prefer dataclasses for structured data passed through the generator.
- Use
@dataclass(frozen=True)for immutable value objects when mutation is unnecessary.
- Use
snake_casefor functions, variables, and helpers. - Use
PascalCasefor classes. - Use leading underscores for module-private globals and helpers.
- Keep names descriptive and domain-specific.
- Avoid unnecessary abbreviations, except established ones like
fid.
- Keep error handling simple and explicit.
- Preserve
response.raise_for_status()for HTTP failures. - Use focused custom exceptions when domain-specific signaling is needed, like
GraphQLError. - Do not silently swallow exceptions.
- Avoid broad
except Exception:unless there is a clear recovery path.
- Keep pure transformation logic separate from I/O where practical.
- Read and write text with
encoding="utf-8". - Limit file writes to clear output steps.
- Preserve deterministic output ordering; rows are currently sorted numerically by
fid. - Be careful when changing README parsing because it also acts as a metadata cache.
- Treat
src/little_algorithm/templates/README.md.j2as the source of truth for generated README structure. - If you change output shape, update both the template and supporting Python logic.
- Avoid manual edits to generated sections of
README.mdunless generator behavior is also updated. - Keep Markdown output stable to minimize noisy diffs.
src/little_algorithm/leetcode.pyperforms live HTTP requests.- Prefer cached README-derived metadata when available.
- Avoid adding unnecessary API calls.
- Preserve request timeouts and headers if changing network code.
- Treat this as a code generator repo, not a general app.
README.mdis generated output, not purely handwritten content.solutions/is primarily data input, not Python application logic.- Most code changes should stay inside
src/little_algorithm/. - Preserve the existing data flow: load YAML, inspect README cache, query LeetCode only when needed, render template.
- Avoid broad refactors unless explicitly requested.
- Generator logic changes: edit Python under
src/little_algorithm/, update template/data files only when required, runuv run generate, inspect theREADME.mddiff. - Article mapping changes: edit
meta/articles.yaml, then regenerate README. - Output-format changes: update
README.md.j2, update supporting Python logic if needed, then regenerate README.
- Do not assume JS/TS tooling exists.
- Do not assume pytest, ruff, black, or mypy exist.
- Do not add unrelated infrastructure just to satisfy a generic workflow.
- Do not manually edit generated README content without updating the generator.
- Do not replace simple dataclass-based code with heavier abstractions without a clear reason.