Files
ai-job-search/tests/test_add_template_build_dir.py
Jakob Stender Guldberg 5bb5f79f7c feat(add-template): keep a registered template's intermediates in build/ (#473) (#474)
* feat(add-template): keep a registered template's intermediates in build/

A template registered via /add-template declared a bare compile command, so
every new template scattered .aux/.log/.out beside its source, and Step 4 had to
enumerate six LaTeX extensions to clean up after its test compile.

- The elicited LaTeX command now redirects intermediates to build/ with the
  portable -output-directory (not the MiKTeX-only -aux-directory), creates the
  folder (TeX Live does not), and moves the PDF back beside the source where
  /apply reads it. A leading rm -f ensures a failed compile, which skips the mv,
  never leaves a stale PDF there.
- Toolchains with nothing to redirect (typst compile) keep their command, and
  registration never blocks on the rule. If the redirect alone breaks a
  template (e.g. \include from a subfolder), it is dropped and recorded under
  Known pitfalls.
- The manifest example shows the pattern, Step 4 cleanup deletes build/
  instead of listing extensions, and the ACTIVE-TEMPLATE block tells /apply to
  run the command from the output directory and remove build/ in Step 5e.
- build/ is gitignored.

Stock templates are untouched, so /apply Step 5e stays.

* docs(add-template): drop the MiKTeX aside from the build directory rule

* test(add-template): pin the build directory compile command
2026-09-21 08:20:10 +02:00

27 lines
936 B
Python

"""Guard for /add-template's build directory rule.
The elicited LaTeX compile command redirects intermediates to `build/` and
moves the PDF back beside the source, where `/apply` reads it. Dropping the
leading `rm -f` lets a failed compile leave a stale PDF for `/apply` to
inspect; dropping the `mv` leaves no PDF beside the source at all.
"""
import unittest
from pathlib import Path
REPO = Path(__file__).resolve().parent.parent
ADD_TEMPLATE = REPO / ".claude" / "commands" / "add-template.md"
LATEX_COMMAND = (
"rm -f <file>.pdf && mkdir -p build && lualatex -interaction=nonstopmode "
"-output-directory=build <file>.tex && mv build/<file>.pdf ./"
)
class AddTemplateKeepsIntermediatesInBuild(unittest.TestCase):
def test_latex_command_redirects_to_build_and_returns_a_fresh_pdf(self):
self.assertIn(LATEX_COMMAND, ADD_TEMPLATE.read_text(encoding="utf-8"))
if __name__ == "__main__":
unittest.main()