# Description

This agent is for proofing one or more documentas general text, such as emails, documents, or any text.

- The input can be a string (with `-i quick-text`) or an existing file (`-f some/some-text.md`).
    - When the input is a string, a `./` prefix and a `.md` suffix will be added if they are not present.
    - If no input is given, the file `.aipack/.prompt/demo@proof/proof-prompt.md` will be used.
    - If the path does not exist, placeholder content will be created for the file.
- If the file content is empty, processing will be skipped with a message.
- If the file has a `====` separator:
    - The first part is the instruction.
    - The second part is the content/code to which the instruction is applied.
- If the file content has no `====`, the content is what needs to be proofread.

# Data

```lua
local p_utils  = require("prompt_utils")
local p_values = require("prompt_values")

-- == Init the prompt file if needed
local prompt_absolute_dir = CTX.WORKSPACE_AIPACK_DIR .. "/.prompt/" .. CTX.PACK_IDENTITY
local prompt_file_path = prompt_absolute_dir .. "/proof-prompt.md"

local prompt_file = p_utils.prep_prompt_file(input, {
    default_prompt_path = prompt_file_path,
    placeholder_suffix = p_values.text_prompt_template
})

local prompt_file_rel_path = aip.path.diff(prompt_file.path, CTX.WORKSPACE_DIR)
if #prompt_file_rel_path == 0 then
    prompt_file_rel_path = prompt_file.path
end
print("Executing demo@craft/text on prompt file:\n➜ " .. prompt_file_rel_path )


-- Split the content
local first_part, content = p_utils.prep_inst_and_content(prompt_file.content, "====\n", {content_is_default = true})

local meta = nil
local inst = nil
if first_part ~= nil then
    -- extract the eventual #!meta params
    meta, inst = aip.md.extract_meta(first_part)
end

local options = nil
if meta then
  options = {}
  options.model_aliases = meta.model_aliases
  options.model         = meta.model
end

local should_skip = p_utils.should_skip(inst, content)
if should_skip ~= nil then
    local pin = {
        label = "Edit prompt:",
        content = prompt_file_rel_path
    }
    aip.run.pin("notice", pin)
    aip.task.pin("notice", pin)
    return should_skip
end

local data = {
    prompt_file_rel_path = prompt_file_rel_path,
    first_part = first_part,
    content    = content,
    inst       = inst,
    path       = prompt_file.path,
}

-- Return the processed data
return aip.flow.data_response({
    data    = data,
    options = options,
})
```

# System

Your goal is to proofread the English of the document the user is giving you.

- Only correct grammar and phrasing when needed or as requested by the user, and make it sound American.
- For code, don't change the HTML code, layout, or any structural aspect of the document.
- Don't wrap the answer in a markdown code block or give an explanation.
- Do not need to add bullet points, but when there are some uses  `-`
- Only when it looks like a tweet with some hashtags, then don't rephrase or remove/add lines, as it's for a short tweet.
- The user might give some User Instruction as well; these will be marked with `<USER_INSTRUCTION>` Tag. 
- Do not use em dash ` as separators in sentences, use other type of separaters
    - So do not say "something—and then" but "something, and then"
- If the User Instruction contradicts some of those system instructions, the User Instruction takes precedence.



# Instruction

{{#if data.inst}}
<USER_INSTRUCTION>
{{data.inst}}}
</USER_INSTRUCTION>
{{/if}}

Here is my content wrapped in the `<CONTENT>`. Obviously, do not return the wrapping tags. 

<CONTENT>
{{data.content}}
</CONTENT>


# Output

```lua
local preamble = "" -- This will be the eventual instruction with a separator
local ai_content = ai_response.content

if data.first_part then
    local content_inst = aip.text.trim_end(data.first_part)
    preamble = content_inst .. "\n\n====\n\n"
    ai_content = aip.text.trim_start(ai_content)
end

local content = preamble .. ai_content

-- Save to the same file
aip.file.save(data.path, content);

-- This will be printed by aipack if it is a string
return "File crafted:\n➜ " .. data.prompt_file_rel_path
```
