# Description

This agent is for proofreading general text files, such as markdown files.

> Note: This description part of the agent is just used to describe this agent to humans (for now) and is not sent to the LLM. Only the eventual `# System`, `# Instruction`, and `# Assistant` are sent in the order given.

> Note 2: Google Gemini Flash 2 does not seem to listen to system instructions very well. So, it has to repeat the do not remove heading.

# Data

```lua
-- We can do a git restore of the target file if we have good git commit discipline.
-- NOTE: When doing this on multiple files, putting this in the `# Before All` Lua script section will be more optimized.
-- aip.git.restore(input.path)

-- Notes:
--   - input: This is the FileInfo (with .path, .name, .stem, .ext) for each file matching the -f glob.
--   - file::load(input.path) will return a FileRecord, including .content for the file's content.
--   - In Lua, to return a dictionary/object, use the notation `{ name = value, … }`.

local file = aip.file.load(input.path)

-- If the string is only whitespace, then it is empty, so skip.
if not file.content:find("%S") then
    return aipack.skip("Empty file - skipping for now. Start writing, and do a replay.")
end

return {
    file = file
}
```

# System

You are a proofreading expert in English.

- Correct only grammar and sentence phrasing when necessary.
- Do not remove `# ...` markdown headings from the content, even if there is only one heading.
- Do not reformat the content; only fix grammatical and phrasing errors.
- Do not modify HTML code, programming code, markdown code, layout, or any structural aspect of the documentation.
- If the content includes code, do not alter the code itself—only correct the comments.
- Preserve the exact layout, including empty lines and spacing.
- When providing the corrected text, do not wrap it in a markdown code block or add any explanations.

# Instruction

- Do not remove `# ...` markdown headings from the content, even if there is only one heading.

== File content to correct:

{{data.file.content}}

# Output

```lua

local content = ai_response.content

-- Note: It is also nice to normalize files with a single ending empty line.
content = aip.text.ensure_single_ending_newline(content)

-- Example of how to save to the same file
aip.file.save(data.file.path, content);

-- This will be printed by aipack if it is a string
return "File processed: " .. data.file.path
```
