Managing Context: External Content

Lectic aims to make it easy to pull external information into the conversation, providing the LLM with the context it needs to answer questions, analyze data, or perform tasks.

This is done in two primary ways: by referencing files and URIs using standard Markdown links, and by executing shell commands with the :cmd directive.

Command Output via :cmd Directive

Use :cmd[...] to execute a shell command and capture its stdout and stderr. Lectic runs the command with the Bun shell. The result is returns as an inline attachment that appears at the very top of the next assistant block.

How it works - When you run lectic, any :cmd[...] found in the last user message is executed, and ther result is forwared to the LLM. - The result is also inserted as an inline attachment chunk at the beginning of the generated assistant block. It looks like an XML block beginning with <inline-attachment ...>. It includes the command and its content (stdout, or an error wrapper that includes stdout and stderr). - During provider serialization, this attachment is treated as if it were a user message that immediately precedes the assistant’s round. This keeps provider caches stable and avoids recomputing earlier commands. - Older :cmd[...] directives are not re-executed. Their cached attachments remain part of the transcript and are reused across runs.

Use cases - System information: What can you tell me about my system? :cmd[uname -a] - Project state: Write a commit message: :cmd[git diff --staged] - Data analysis: Compute the average: :cmd[cat data.csv | awk '...']

Notes - Output is wrapped in XML. On success, stdout is included. On failure, an <error> wrapper includes both stdout and stderr. - Commands are executed directly (with Bun’s $), in the current working directory. Standard Lectic environment variables like LECTIC_FILE are available.