Agent Skills › Oleafly/Oleafly › Build and fix

Build and fix

GitHub

驱动文档编译、诊断并修复错误,直至构建成功。适用于 LaTeX、Typst 等引擎的编译失败、日志分析及最小化代码修复。

src-tauri/resources/skills/oleafly-latex-build/SKILL.md Oleafly/Oleafly

Trigger Scenarios

编译失败 出现未定义控制序列或文件未找到错误 用户询问为何构建结果不同

Install

npx skills add Oleafly/Oleafly --skill Build and fix -g -y
More Options

Non-standard path

npx skills add https://github.com/Oleafly/Oleafly/tree/main/src-tauri/resources/skills/oleafly-latex-build -g -y

Use without installing

npx skills use Oleafly/Oleafly@Build and fix

指定 Agent (Claude Code)

npx skills add Oleafly/Oleafly --skill Build and fix -a claude-code -g -y

安装 repo 全部 skill

npx skills add Oleafly/Oleafly --all -g -y

预览 repo 内 skill

npx skills add Oleafly/Oleafly --list

SKILL.md

Frontmatter
{
    "name": "Build and fix",
    "license": "MIT",
    "metadata": {
        "oleafly": {
            "tier": "native",
            "phase": "tooling",
            "tools": [
                "read_file",
                "replace_in_file",
                "write_file",
                "list_files",
                "search_project",
                "project_map",
                "compile",
                "get_log",
                "get_pdf_text",
                "verify_pdf_pages",
                "set_main_doc",
                "run_command",
                "update_todos",
                "read_skill_file"
            ]
        },
        "version": "1.1.1",
        "skill-author": "Oleafly"
    },
    "description": "Drive Oleafly's compile, diagnose, fix loop until the document builds clean. Use when a compile fails, when the log shows undefined control sequence, missing package or file not found, missing $ inserted, runaway argument, undefined citation or reference, a font that will not load, overfull hbox warnings, a bibliography that will not resolve, a Typst error, or when the user says it will not compile, the PDF is stale, or asks why the build is different on another machine.",
    "allowed-tools": "read_file replace_in_file write_file create_file list_files search_project project_map compile get_log get_pdf_text verify_pdf_pages set_main_doc run_command update_todos load_skill read_skill_file",
    "compatibility": "Needs an open Oleafly project on any of the four engines (Tectonic, latexmk, Typst, Markdown). No external tools are required."
}

Build and fix

A compile failure is a lookup, not a puzzle. Read the first error, name its class, apply the smallest edit that fixes that class, compile again. Repeat until compile returns success: true with an empty errors list.

1. Know the engine before touching anything

read_file on project.json. The engine value decides almost everything below. In a Typst project, typst.version in the same file is the Typst version the project pins.

engine What runs Notes
xetex Bundled Tectonic sidecar, XeTeX engine The default. Fetches packages from a pinned TeX Live bundle. fontspec works.
latexmk The user's system TeX (MacTeX, TeX Live, MiKTeX, TinyTeX) The underlying engine is pdfLaTeX unless a % !TeX program = line, or fontspec / polyglossia / unicode-math, forces XeLaTeX or LuaLaTeX. Shell escape is off unless the user granted it for this project on this machine.
typst The Typst CLI, at the version the project pins or the default version from Settings No SyncTeX and no isolated compile. preview_figure still renders a Typst figure on its own. Exports to LaTeX, Word, HTML, Markdown and plain text.
markdown Bundled Pandoc, with bundled Tectonic as its PDF engine Available offline in packaged builds. Settings can repair a missing development copy.

The assistant cannot switch engines. set_main_doc changes the engine as a side effect of the file extension, and that is the only lever it has. Anything else is a Settings change the user makes.

Never write pdflatex as an engine name. Oleafly does not accept it, and a project or template that declares it disappears from the app.

2. Compile and read the result

  1. compile. The envelope carries success, errors, has_pdf, and log_tail.
  2. get_log for the last 20k characters when log_tail is not enough.
  3. Read the first error, not the last. LaTeX errors cascade, so the tail is usually noise from the first one.
  4. Note whether has_pdf is true. A PDF plus errors means a recoverable error was stepped over and the output is probably wrong even though a file exists.

3. Classify before editing

read_skill_file this skill's references/error-catalog.md and match the log line to a row. It gives the cause, the fix, and the tool call for each pattern, across LaTeX, BibTeX and Biber, fonts, Typst, and Pandoc.

If nothing matches, say so rather than guessing, and fall back to the bisect procedure at the end of the catalog.

4. Fix with the smallest edit

Use replace_in_file with enough surrounding text to be unambiguous. Prefer one class of error per round so the next compile tells you whether that fix worked.

Rules that keep the loop honest:

  • Never delete content to make a compile pass. Comment nothing out permanently without saying so.
  • Never add a package you have not confirmed the engine can resolve.
  • Never change the engine, the class, or the bibliography backend to dodge a single error.
  • If the fix would change what the document says, stop and ask.

5. Recompile until it is actually clean

Clean means success: true and errors: []. A build that produces a PDF while errors remain is not done.

Then check what came out:

  • get_pdf_text to confirm the sections, the title, and the references list are present.
  • verify_pdf_pages when layout matters (column breaks, a table that overflows, a figure that landed on the wrong page). It only exists when the user has enabled PDF page capture in Settings; if it is unavailable, say what you could not check.
  • project_map for unresolvedRefs and unresolvedCites after any citation or reference work.

6. Sweep for the failures that do not error

read_skill_file this skill's references/engine-notes.md when any of these apply. They compile successfully and are still wrong:

  • the log mentions an absolute path under /System/Library, /Library/Fonts, or C:/Windows/Fonts, which means the build is bound to this machine's fonts;
  • the document is CJK and uses ctex;
  • a font was requested and silently fell back;
  • two machines produce visibly different PDFs from the same source;
  • the same source compiles here and fails on a coauthor's machine.

Decision points

Question Answer
biblatex plus Biber, or natbib plus BibTeX? On Oleafly's Tectonic both work, because the app ships a pinned tectonic-biber and recovers when Tectonic misses it. Outside Oleafly, plain Tectonic and biblatex drift apart by version, so natbib plus BibTeX is the portable choice. Never swap a venue's supplied .bst for biblatex.
A package is missing from Tectonic's bundle Say which package and offer the closest bundled alternative. Installing packages needs system TeX, which is the user's engine switch to make, not yours.
A Typst error points into a package, or a feature the project uses needs a newer Typst Read typst.version in project.json. The fix is usually a package version that matches the pinned Typst. Changing the pin changes the output, so suggest it and let the user switch it from the Compile menu.
Overfull box warnings Not errors. Triage rather than chase: reword first, keep microtype loaded, hyphenate one stubborn word, and only then consider local sloppypar. Never \sloppy globally.
The user asks to run latexmk or tectonic by hand run_command can, with approval, but the app's own compile uses the project's engine and artifact layout. Prefer compile; reach for run_command only for something compile cannot do, such as inspecting a produced file.
Nothing works and the error is opaque Bisect. See the end of references/error-catalog.md.

Failure handling

Problem What to do
The same error survives two fixes Stop editing. Report the log line, what you tried, and what you think it means.
The error names a file that is not in the project list_files and search_project before concluding it is missing. Then say whether it must be supplied by the user.
Compile times out or is cancelled Report it as a timeout, not a source error. A first Tectonic build downloads bundle files and is slow.
Pandoc is missing on a Markdown project Tell the user the bundled runtime is unavailable and direct them to Settings to repair it.
The pinned Typst version is not installed This is a missing download, not a source error. The user can install it in Settings or pick another version from the Compile menu.
Biber or biblatex version skew The log carries an [Oleafly] note that distinguishes Biber not found from a version mismatch. Quote it verbatim.
The PDF looks stale Compile again and compare page count with get_pdf_text. Do not delete build directories through run_command unless the user asks.

Artifacts

A compiled PDF, a clean compile log, and a short written list of what was wrong and what changed. Leave the source in a state where every edit is explainable.

Done when

  • compile returns success: true with an empty errors list
  • No content was removed to achieve that
  • project_map reports no unresolved references or citations, or the remaining ones are listed for the user
  • The output was checked with get_pdf_text, and with verify_pdf_pages when it was available
  • No absolute host font path appears in the log
  • Every change is named in one line, with the error it fixed

From a terminal

Outside the app (a terminal, or a coding agent with a shell), the oleafly command does the same work. Always pass --json and check ok.

In Oleafly From a terminal
compile oleafly build --json
get_log oleafly log --diagnostics --json
project_map oleafly context --json
list_files, read_file, search_project Your own file tools; oleafly context --json for the outline
set_main_doc oleafly config set main <file>

Version History

  • afd83e2 Current 2026-11-02 08:54

Same Skill Collection

src-tauri/resources/skills/citation-management/SKILL.md
src-tauri/resources/skills/desktop-apps/SKILL.md
src-tauri/resources/skills/exploratory-data-analysis/SKILL.md
src-tauri/resources/skills/hypothesis-generation/SKILL.md
src-tauri/resources/skills/import-refine/SKILL.md
src-tauri/resources/skills/literature-review/SKILL.md
src-tauri/resources/skills/oleafly-cli/SKILL.md
src-tauri/resources/skills/oleafly-data-analysis/SKILL.md
src-tauri/resources/skills/oleafly-experiment-loop/SKILL.md
src-tauri/resources/skills/oleafly-figure-prep/SKILL.md
src-tauri/resources/skills/oleafly-manuscript-scaffold/SKILL.md
src-tauri/resources/skills/oleafly-pre-submission/SKILL.md
src-tauri/resources/skills/oleafly-related-work/SKILL.md
src-tauri/resources/skills/oleafly-research-loop/SKILL.md
src-tauri/resources/skills/oleafly-response-letter/SKILL.md
src-tauri/resources/skills/oleafly-review-manuscript/SKILL.md
src-tauri/resources/skills/oleafly-slides-and-posters/SKILL.md
src-tauri/resources/skills/oleafly-verify-claims/SKILL.md
src-tauri/resources/skills/openresearch/SKILL.md
src-tauri/resources/skills/pdf-to-latex/SKILL.md
src-tauri/resources/skills/peer-review/SKILL.md
src-tauri/resources/skills/pptx-posters/SKILL.md
src-tauri/resources/skills/research-grants/SKILL.md
src-tauri/resources/skills/research-lookup/SKILL.md
src-tauri/resources/skills/scholar-evaluation/SKILL.md
src-tauri/resources/skills/scientific-brainstorming/SKILL.md
src-tauri/resources/skills/scientific-critical-thinking/SKILL.md
src-tauri/resources/skills/scientific-slides/SKILL.md
src-tauri/resources/skills/scientific-visualization/SKILL.md
src-tauri/resources/skills/scientific-writing/SKILL.md
src-tauri/resources/skills/template-generate/SKILL.md
src-tauri/resources/skills/venue-templates/SKILL.md
src-tauri/resources/skills/experimental-design/SKILL.md
src-tauri/resources/skills/oleafly-literature-sweep/SKILL.md
src-tauri/resources/skills/paper-lookup/SKILL.md
src-tauri/resources/skills/statistical-analysis/SKILL.md
src-tauri/resources/skills/statistical-power/SKILL.md

Metadata

Files
0
Version
afd83e2
Hash
e8b21226
Indexed
2026-11-02 08:54

trang chủ - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-11-02 22:33
浙ICP备14020137号-1