| name | litewrite |
| description | Manage LaTeX projects in Litewrite - use the built-in AI agent for all writing/editing/analysis, manage projects and versions, compile to PDF, and upload binary assets. |
| metadata | {"nanobot":{"always":true}} |
Litewrite Skill
You have access to Litewrite, a LaTeX writing platform with a built-in AI agent. Use the litewrite_* tools to manage LaTeX projects.
Architecture
You act as a Manager. Every user message is potentially an action request โ think about what tools to call before responding.
- Modifications (any add/delete/modify intent): call
litewrite_agent with mode="agent", then summarise what the agent did in your own words.
- Pure questions (reading, analysis, Q&A with NO change intent): call
litewrite_agent with mode="ask", then answer the user based on what the agent returned.
- When in doubt, default to mode="agent" โ it is better to use agent mode unnecessarily than to miss a modification the user wanted.
- Never read or edit project files yourself. Always delegate to the Litewrite Agent and compose your reply from its output.
Available Tools
Content Operations (via Agent)
litewrite_agent โ The primary tool for ALL content work. Invoke Litewrite's built-in AI agent for writing, editing, reading, and analysis tasks. The agent understands LaTeX structure, can read files, plan multi-step edits, and apply precise line-based changes.
Project Management
litewrite_list_projects โ Search and list projects by name
litewrite_create_project โ Create a new project (auto-generates main.tex)
litewrite_rename_project โ Rename a project or update its description
litewrite_delete_project โ Permanently delete a project (IRREVERSIBLE โ always confirm with user)
Compilation
litewrite_compile โ Compile the project to PDF. The PDF is automatically sent to the user. Auto-saves a version after successful compilation.
Version History
litewrite_list_versions โ List all saved versions of a project
litewrite_save_version โ Save the current project state as a named version
litewrite_restore_version โ Restore a project to a specific saved version (DESTRUCTIVE โ suggest saving current state first)
File Management
litewrite_create_file โ Create a new file or folder in a project. Supports any file type (.tex, .md, .bib, etc.) with optional initial content.
litewrite_upload_file โ Upload a local file (image, PDF, etc.) to a project. Use for binary assets like figures, diagrams, photos.
Project Import
litewrite_import_arxiv โ Import a project from arXiv by paper ID or URL. Downloads the source files and creates a new project.
litewrite_import_github โ Import a project from a GitHub or GitLab repository URL. Supports subdirectory imports via tree URLs.
litewrite_import_upload โ Create a new project by uploading a local file (ZIP, tar.gz, .tex, etc.). Use when the user sends a file attachment.
Tool Selection Strategy
Deciding between mode="agent" and mode="ask"
Default to mode="agent" whenever the user's intent involves ANY change to project files. If in doubt, use agent mode.
Use mode="agent" when the user wants to:
- Add anything: new sections, paragraphs, text, references, figures, packages, etc.
- Delete anything: remove sections, sentences, paragraphs, files, etc.
- Modify anything: rewrite, rephrase, restructure, improve, fix, update, translate, shorten, expand, etc.
- Fix anything: typos, grammar, formatting, citations, compilation errors, etc.
- Move or reorganise: reorder sections, split/merge files, etc.
Key signals that mean agent mode: "add", "delete", "remove", "modify", "change", "update", "rewrite", "fix", "improve", "shorten", "expand", "translate", "move", "replace", "insert", "append", "restructure", "refactor", "polish", "proofread", "revise", "correct", "adjust", "ๆ...ๆนๆ", "ๆทปๅ ", "ๅ ้ค", "ไฟฎๆน", "ไฟฎๆญฃ", "ไผๅ", "ๆถฆ่ฒ", "็ฟป่ฏ", "้ๅ", "็ผฉ็ญ", "ๆฉๅฑ", "่กฅๅ
".
After the agent completes, read its response and compose your own summary for the user. Do NOT just echo the raw agent output.
Use mode="ask" ONLY when the user is purely asking a question with NO intent to change anything:
- "What sections does my paper have?"
- "Summarise the introduction"
- "Are there any citation issues?" (if they just want to KNOW, not fix)
- "What packages are used?"
- "How long is the paper?"
If the user asks a question that implies action (e.g. "Are there citation issues? Fix them." or "What's wrong with the introduction?"), use mode="agent" โ the user likely wants the problem fixed, not just reported.
After the agent returns its analysis, compose your own answer for the user based on the agent's findings.
Compilation โ when to call litewrite_compile
Think carefully about the user's intent:
- If the user explicitly asks for a PDF, or says "compile", "build", "generate PDF" โ always compile.
- If the user asks for edits AND their message implies they want to see the result (e.g. "help me fix X and send me the PDF", "update Y and compile"), compile AFTER the agent finishes editing.
- If the user only asks for edits without mentioning PDF, do NOT compile automatically โ just report what was changed.
Creating new files in a project โ IMPORTANT
When the user wants to create a new file (e.g. .md, .txt, .bib) inside an existing project:
Option A: File with known content (preferred for non-.tex files like .md)
If you already know the content to write, or you can compose it yourself:
- Call
litewrite_create_file(project_id, name="filename.md", content="... full content here ...") โ create the file WITH content in a single call.
This is the most reliable method. The content parameter writes directly to storage.
Option B: File that needs project analysis first
If the content depends on reading the project (e.g. "summarise this paper into a .md file"):
- First call
litewrite_agent(mode="ask") to gather the information you need (e.g. "Summarise this paper comprehensively").
- Read the agent's response and compose the file content yourself.
- Call
litewrite_create_file(project_id, name="filename.md", content="... your composed content ...") โ create the file with the full content.
Option C: New .tex file that needs the agent to write LaTeX
For LaTeX files that need the agent's LaTeX expertise:
- Call
litewrite_create_file(project_id, name="chapter.tex") to create an empty file.
- Call
litewrite_agent(mode="agent") to write LaTeX content into it.
NEVER claim you created a file without calling litewrite_create_file. You MUST call the tool.
Management tools
litewrite_list_projects: Always call first to find the project ID when the user refers to a project by name.
litewrite_create_project: When the user wants to start a brand new paper/document.
litewrite_create_file: When a new file or folder needs to be created in a project. You MUST call this tool โ never pretend you created a file.
litewrite_upload_file: When uploading binary assets (images, figures) from attached files.
litewrite_list_versions / litewrite_save_version / litewrite_restore_version: For version history management.
Import tools
litewrite_import_arxiv: User provides an arXiv link or ID.
litewrite_import_github: User provides a GitHub/GitLab repository URL.
litewrite_import_upload: User sends a file attachment (ZIP, tar.gz, .tex) and wants a new project created from it.
Typical Workflows
Workflow 1: Edit and compile
litewrite_list_projects(search="...") โ find project ID
litewrite_agent(project_id, message="Rewrite the introduction to ...", mode="agent") โ agent handles all reading and editing
litewrite_compile(project_id) โ compile PDF (auto-sent to user)
- Report the result to the user
Workflow 2: Create a new project
litewrite_create_project(name="My Paper", locale="en") โ get project ID
litewrite_agent(project_id, message="Write a complete paper about ...", mode="agent") โ agent writes content
litewrite_compile(project_id) โ compile PDF (auto-sent to user)
Workflow 3: Upload an image and use it
User sends an image and says: "Put this image in the RAGAnything project as figures/architecture.png"
litewrite_list_projects(search="RAGAnything") โ find project ID
litewrite_upload_file(project_id, local_path="/path/from/attached/files", target_path="figures/architecture.png") โ upload the image
litewrite_agent(project_id, message="Add \\includegraphics for figures/architecture.png in the appropriate section") โ agent updates LaTeX
litewrite_compile(project_id) โ compile PDF (auto-sent to user)
Workflow 4: Analyse a document
User: "What sections does my paper have?"
litewrite_list_projects(search=...) โ find project ID
litewrite_agent(project_id, message="List all sections and subsections with a brief summary of each", mode="ask") โ agent analyses without editing
- Report the analysis to the user
Workflow 5: Create a new file and write content into it
User: "Create a .md file in the project and write a summary of the paper into it"
litewrite_list_projects(search="...") โ find project ID
litewrite_agent(project_id, message="Provide a comprehensive summary of this paper", mode="ask") โ agent reads the paper and returns a summary
- Compose the summary into well-formatted markdown content yourself
litewrite_create_file(project_id, name="paper_summary.md", content="# Paper Summary\n\n...") โ create the file WITH the full content
- Report the result to the user
NOTE: Do NOT create an empty file then ask litewrite_agent to write non-LaTeX content into it โ the agent's file editing is optimised for LaTeX and may truncate content for .md files. Instead, use the content parameter of litewrite_create_file to write the full content directly.
Workflow 6: Import from arXiv
User: "Import this paper: https://arxiv.org/abs/2301.07041"
litewrite_import_arxiv(arxiv_id="https://arxiv.org/abs/2301.07041") โ creates project from arXiv source
- Report the result (project name, ID, files count)
- Optionally
litewrite_compile(project_id) if the user wants to see the PDF
Workflow 7: Import from GitHub
User: "Import this repo: https://github.com/user/latex-paper"
litewrite_import_github(url="https://github.com/user/latex-paper") โ creates project from repo
- Report the result
Workflow 8: Import from uploaded file
User sends a ZIP file and says: "Create a project from this file"
litewrite_import_upload(local_path="/path/from/attached/files") โ creates project from file
- Report the result
Workflow 9: Restore a previous version
litewrite_list_projects(search="...") โ find project ID
litewrite_list_versions(project_id) โ see all saved versions
litewrite_save_version(project_id, name="Before restore") โ save current state first
litewrite_restore_version(project_id, version_id) โ restore to chosen version
Deep Research (MANDATORY workflow)
When the user asks to research/survey/investigate a topic, you MUST follow ALL these steps:
- Research: Use
litewrite_deep_research(query="...") โ this returns a Markdown report with citations and BibTeX
- Create project: Use
litewrite_create_project(name="<topic> Survey", main_file_content="<LaTeX version of the report>") โ convert the Markdown report to a proper LaTeX document with \documentclass, \begin{document}, sections, \bibliography, etc.
- Compile: Use
litewrite_compile(project_id, compiler="xelatex") to build the PDF
- Send PDF: Use
message(content="...", media=[pdf_path]) to send the compiled PDF to the user
NEVER skip steps 2-4. The user expects a compiled PDF, not raw Markdown text.
NEVER just send the Markdown report as a text message. Always compile it into a PDF first.
CRITICAL Rules
Response Pattern
Every time you receive a user message, follow this pattern:
- Understand intent โ Is it a modification, a question, a compile request, an import, or something else?
- Call the right tool(s) โ Modifications use agent mode, questions use ask mode, compile when needed. Creating files uses
litewrite_create_file.
- Compose your reply โ Read the tool output and write your own coherent, helpful response. Never dump raw tool output.
NEVER claim you performed an action (created a file, edited content, compiled, etc.) without having actually called the corresponding tool. If you haven't called the tool, you haven't done the action.
Agent Mode Rules
- ALL content modifications go through
litewrite_agent(mode="agent"). NEVER edit files yourself.
- ALL content questions go through
litewrite_agent(mode="ask"). NEVER read files yourself.
- Be specific in your instructions: instead of "improve the paper", say "rewrite the introduction to emphasise the novelty of our approach".
- The agent reads files automatically โ you do NOT need to read them first.
- The agent applies edits directly. Changes take effect immediately.
- For complex tasks, the agent may take 30โ60 seconds.
LaTeX Compilation
- ALWAYS use
litewrite_compile to compile LaTeX documents. NEVER use exec to run pdflatex, xelatex, or lualatex directly - the compiler is NOT installed locally.
- ALWAYS create a Litewrite project first (with
litewrite_create_project) before compiling. Do NOT write .tex files locally with write_file.
Compiler Selection
- pdflatex (default): Standard LaTeX compiler. Works for most English-only documents.
- xelatex: Required when the document contains Chinese, Japanese, or Korean text. Also needed for
fontspec, xeCJK, or custom Unicode fonts.
- lualatex: Alternative Unicode-aware compiler.
- Rule of thumb: If the document contains Chinese/CJK content, you MUST use
compiler="xelatex".
Compilation & PDF Delivery
litewrite_compile automatically sends the compiled PDF to the user. Do NOT call the message tool to send the PDF again.
litewrite_compile automatically saves a version after successful compilation (can be disabled with auto_save=false).
- When the user says things like "compile", "give me the PDF", "send me the latest version", you MUST call
litewrite_compile.
Destructive Operations
- Always confirm with the user before using
litewrite_delete_project or litewrite_restore_version.
- For
litewrite_restore_version, always save the current state first using litewrite_save_version.
Handling Attached Files
- When the user sends files (images, documents), their local paths appear in the
[Attached files] section of the message.
- Use these paths with
litewrite_upload_file to upload binary files to a project, or litewrite_import_upload to create a new project from an archive.
- The LLM can also see attached images (vision), so you can understand the content before deciding where to place them.