Skip to content
Back to search

ellama

Work with local and cloud LLMs from Emacs.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/s-kostyaev--ellama/badge.svg)](/listings/s-kostyaev--ellama)

HTML

<a href="/listings/s-kostyaev--ellama"><img src="/api/listings/s-kostyaev--ellama/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.org · README · 2,375 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. #+TITLE: Ellama
  2. #+EXPORT_FILE_NAME: ellama
  3. [[http://www.gnu.org/licenses/gpl-3.0.txt][file:https://img.shields.io/badge/license-GPL_3-green.svg]]
  4. [[https://melpa.org/#/ellama][file:https://melpa.org/packages/ellama-badge.svg]]
  5. [[https://stable.melpa.org/#/ellama][file:https://stable.melpa.org/packages/ellama-badge.svg]]
  6. [[https://elpa.gnu.org/packages/ellama.html][file:https://elpa.gnu.org/packages/ellama.svg]]
  7. Ellama brings large language models into Emacs without turning Emacs into a web
  8. app. You can use it for ordinary chat, one-shot commands over the current
  9. buffer or region, and longer sessions that keep their history. It also has
  10. agent loops for work that needs several steps: make a plan, call tools, read
  11. project context, and continue from the previous turn.
  12. Ellama is not tied to one backend. It uses the
  13. [[https://elpa.gnu.org/packages/llm.html][llm]] package, so Ollama works with a
  14. local model, and the same Ellama commands can be configured for
  15. OpenAI-compatible APIs, OpenAI, Claude, Gemini, Vertex, GPT4All, LlamaCpp, and
  16. other llm providers. When a provider supports extra capabilities, Ellama uses
  17. them: streaming responses, model lists, image and audio input, tool calls, token
  18. limits, and interactive model switching.
  19. Context is first-class. A request can include buffers, files, directories, Info
  20. nodes, selections, images, and audio files. Chat sessions can be saved,
  21. resumed, renamed, compacted manually, or compacted automatically before they run
  22. past the model context window. The everyday commands cover translation,
  23. summarization, proofreading, code review and editing, extraction, formatting,
  24. commit-message generation, and provider selection.
  25. For tool-using agents, Ellama reads project instructions from ~AGENTS.md~, can
  26. load reusable skills and blueprint prompts, and runs plan-and-act loops or
  27. subagents from the task tool. Tool calls are still subject to project policy:
  28. filesystem checks, edit hooks, and DLP scans can block or warn on reads, writes,
  29. shell commands, and tool output.
  30. The name "ellama" is derived from "Emacs Large LAnguage Model Assistant".
  31. [[file:imgs/reasoning-models.gif]]
  32. * Installation
  33. Install Ellama from GNU ELPA:
  34. #+BEGIN_SRC text
  35. M-x package-install RET ellama RET
  36. #+END_SRC
  37. By default Ellama uses the first available [[https://ollama.com][Ollama]] model.
  38. If you want to use that default, install Ollama and pull a model from the
  39. [[https://ollama.com/library][Ollama library]]:
  40. #+BEGIN_SRC shell
  41. ollama pull qwen3.6:35b
  42. #+END_SRC
  43. The examples below use ~qwen3.6:35b~ for agentic coding. Replace it with a
  44. model that is available in your Ollama installation if needed.
  45. You can also use another LLM provider. The smallest useful Emacs setup is:
  46. #+BEGIN_SRC emacs-lisp
  47. (use-package ellama
  48. :ensure t
  49. :bind ("C-c e" . ellama)
  50. :hook (org-ctrl-c-ctrl-c-hook . ellama-chat-send-last-message)
  51. :init (setopt ellama-auto-scroll t)
  52. :config
  53. (ellama-context-header-line-global-mode +1)
  54. (ellama-session-header-line-global-mode +1))
  55. #+END_SRC
  56. Agentic coding setup:
  57. #+BEGIN_SRC emacs-lisp
  58. (use-package ellama
  59. :ensure t
  60. :bind ("C-c e" . ellama)
  61. :hook (org-ctrl-c-ctrl-c-hook . ellama-chat-send-last-message)
  62. :init
  63. (require 'llm-ollama)
  64. (setopt ellama-provider
  65. (make-llm-ollama
  66. :chat-model "qwen3.6:35b"
  67. :embedding-model "nomic-embed-text"))
  68. :config
  69. ;; Agent defaults for long coding sessions: enable tools, compact old
  70. ;; context, show sub-agent buffers, enforce DLP, block irreversible actions,
  71. ;; and give agent loops enough steps to finish real work.
  72. (ellama-setup-agentic-coding)
  73. ;; With an srt policy, normal tool confirmations are skipped, ordinary DLP
  74. ;; input findings are allowed, output findings are redacted, and
  75. ;; irreversible actions are still blocked. Without SRT, confirmations stay
  76. ;; active and ordinary DLP input/output findings ask first.
  77. ;; (ellama-setup-agentic-coding
  78. ;; "~/.config/ellama/srt-autonomous.json")
  79. (ellama-context-header-line-global-mode +1)
  80. (ellama-session-header-line-global-mode +1))
  81. #+END_SRC
  82. Optional provider-specific settings:
  83. #+BEGIN_SRC emacs-lisp
  84. (use-package ellama
  85. :ensure t
  86. :bind ("C-c e" . ellama)
  87. :hook (org-ctrl-c-ctrl-c-hook . ellama-chat-send-last-message)
  88. :init
  89. (require 'llm-ollama)
  90. (setopt ellama-provider
  91. (make-llm-ollama
  92. :chat-model "qwen3.6:35b"
  93. :embedding-model "nomic-embed-text"
  94. :default-chat-non-standard-params '(("num_ctx" . 32768))))
  95. (setopt ellama-language "German"
  96. ellama-naming-scheme 'ellama-generate-name-by-llm
  97. ellama-chat-display-action-function #'display-buffer-full-frame
  98. ellama-instant-display-action-function #'display-buffer-at-bottom)
  99. :config
  100. (ellama-context-header-line-global-mode +1)
  101. (ellama-session-header-line-global-mode +1)
  102. (advice-add 'pixel-scroll-precision :before #'ellama-disable-scroll)
  103. (advice-add 'end-of-buffer :after #'ellama-enable-scroll))
  104. #+END_SRC
  105. * Commands
  106. ** Core Chat and Agent Setup
  107. - ~ellama~: This is the entry point for Ellama. It displays the main transient
  108. menu, allowing you to access all other Ellama commands from here.
  109. - ~ellama-chat~: Ask Ellama about something by entering a prompt in an
  110. interactive buffer and continue conversation. If called with universal
  111. argument (~C-u~) will start new session with llm model interactive selection.
  112. - ~ellama-chat-send-last-message~: Send last user message extracted from current
  113. ellama chat buffer.
  114. - ~ellama-plan-and-act~: Start an agent loop that first creates a checklist plan
  115. and then acts on it with automatic continuations. It reuses the current chat
  116. session when possible and can be launched from the main transient menu with
  117. ~A~ in the ~Problem solving~ section.
  118. - ~ellama-setup-agentic-coding~: Apply coding-agent defaults for long sessions:
  119. enable all tools, enforce DLP, block irreversible actions, and use longer
  120. agent loops. Pass an ~srt~ settings file to enable lower-prompt tool use
  121. inside that sandbox.
  122. ** Ask and Media Input
  123. - ~ellama-ask-about~: Ask Ellama about a selected region or the current
  124. buffer. Automatically adds selected region or current buffer to ephemeral
  125. context for one request.
  126. - ~ellama-ask-selection~: Send selected region or current buffer to ellama chat.
  127. - ~ellama-ask-line~: Send current line to ellama chat.
  128. - ~ellama-ask-image~: Ask Ellama about one image file by adding it as ephemeral
  129. context for the request. If called with universal argument (~C-u~) will start
  130. new session with llm model interactive selection.
  131. - ~ellama-chat-with-image~: Ask Ellama about one image file. If called with
  132. universal argument (~C-u~) will start new session with llm model interactive
  133. selection.
  134. - ~ellama-chat-with-images~: Ask Ellama about multiple image files. If called
  135. with universal argument (~C-u~) will start new session with llm model
  136. interactive selection.
  137. - ~ellama-ask-audio~: Ask Ellama about one audio file by adding it as ephemeral
  138. context for the request. If called with universal argument (~C-u~) will start
  139. new session with llm model interactive selection.
  140. - ~ellama-chat-with-audio~: Ask Ellama about one audio file. If called with
  141. universal argument (~C-u~) will start new session with llm model interactive
  142. selection.
  143. - ~ellama-chat-with-audios~: Ask Ellama about multiple audio files. If called
  144. with universal argument (~C-u~) will start new session with llm model
  145. interactive selection.
  146. - ~ellama-ask-audio-recording~: Record a short audio message from the microphone
  147. and ask Ellama about it.
  148. - ~ellama-chat-with-audio-recording~: Record a short audio message from the
  149. microphone and send it to chat.
  150. - ~ellama-record-audio~: Record a short audio message from the microphone and
  151. return the recorded file.
  152. - ~ellama-start-audio-recording~: Start microphone recording without a fixed
  153. duration.
  154. - ~ellama-stop-audio-recording~: Stop microphone recording and return the
  155. recorded file.
  156. ** Text Writing and Transformation
  157. - ~ellama-write~: This command allows you to generate text using an LLM. When
  158. called interactively, it prompts for an instruction that is then used to
  159. generate text based on the context. If a region is active, the selected text
  160. is added to ephemeral context before generating the response.
  161. - ~ellama-complete~: Complete text in current buffer with ellama.
  162. - ~ellama-translate~: Ask Ellama to translate a selected region or word at the
  163. point.
  164. - ~ellama-translate-buffer~: Translate current buffer.
  165. - ~ellama-define-word~: Find the definition of the current word using Ellama.
  166. - ~ellama-summarize~: Summarize a selected region or the current buffer using
  167. Ellama.
  168. - ~ellama-summarize-killring~: Summarize text from the kill ring.
  169. - ~ellama-code-review~: Review code in a selected region or the current buffer
  170. using Ellama. Automatically adds selected region or current buffer to
  171. ephemeral context for one request.
  172. - ~ellama-change~: Change text in a selected region or the current buffer
  173. according to a provided change.
  174. - ~ellama-make-list~: Create a markdown list from the active region or the
  175. current buffer using Ellama.
  176. - ~ellama-make-table~: Create a markdown table from the active region or the
  177. current buffer using Ellama.
  178. - ~ellama-summarize-webpage~: Summarize a webpage fetched from a URL using
  179. Ellama.
  180. - ~ellama-proofread~: Proofread selected text.
  181. - ~ellama-improve-wording~: Enhance the wording in the currently selected region
  182. or buffer using Ellama.
  183. - ~ellama-improve-grammar~: Enhance the grammar and spelling in the currently
  184. selected region or buffer using Ellama.
  185. - ~ellama-improve-conciseness~: Make the text of the currently selected region
  186. or buffer concise and simple using Ellama.
  187. - ~ellama-make-format~: Render the currently selected text or the text in the
  188. current buffer as a specified format using Ellama.
  189. ** Code
  190. - ~ellama-code-review~: Review code in a selected region or the current buffer
  191. using Ellama. Automatically adds selected region or current buffer to
  192. ephemeral context for one request.
  193. - ~ellama-code-complete~: Complete selected code or code in the current buffer
  194. according to a provided change using Ellama.
  195. - ~ellama-code-add~: Generate and insert new code based on description. This
  196. function prompts the user to describe the code they want to generate. If a
  197. region is active, it includes the selected text in ephemeral context for code
  198. generation.
  199. - ~ellama-code-edit~: Change selected code or code in the current buffer
  200. according to a provided change using Ellama.
  201. - ~ellama-code-improve~: Change selected code or code in the current buffer
  202. according to a provided change using Ellama.
  203. - ~ellama-generate-commit-message~: Generate commit message based on diff.
  204. ** Providers and Models
  205. - ~ellama-provider-select~: Select ellama provider.
  206. - ~ellama-select-model~: Change the current provider model interactively. The
  207. model transient can switch the provider type as well as the model. Built-in
  208. choices include Ollama, OpenAI-compatible, OpenAI, Claude, Gemini, DeepSeek,
  209. OpenRouter, Azure OpenAI, GitHub Models, Vertex AI, GPT4All, and Llama.cpp.
  210. It also supports providers with a ~chat-model~ slot. URL editing is available
  211. when the provider has a ~url~ slot. It can also set the maximum number of
  212. output tokens. Use "Reset model fields" to clear model, temperature,
  213. context-length, and max-token overrides and let the provider use its defaults;
  214. reset values are shown as ~default~ in the transient.
  215. ** Sessions
  216. - ~ellama-load-session~: Load ellama session from file.
  217. - ~ellama-session-delete~: Delete ellama session.
  218. - ~ellama-session-switch~: Change current active session.
  219. - ~ellama-session-kill~: Select and kill one of active sessions.
  220. - ~ellama-session-rename~: Rename current ellama session.
  221. - ~ellama-session-compact-current~: Compact current Ellama session context.
  222. - ~ellama-session-compact~: Select and compact an active Ellama session context.
  223. ** Context
  224. - ~ellama-context-add-file~: Add file to context.
  225. - ~ellama-context-add-image~: Add image file to context.
  226. - ~ellama-context-add-audio~: Add audio file to context.
  227. - ~ellama-context-add-audio-recording~: Record a short audio message and add it
  228. to context.
  229. - ~ellama-context-start-audio-recording~: Start microphone recording without a
  230. fixed duration.
  231. - ~ellama-context-stop-audio-recording~: Stop microphone recording and add the
  232. recorded file to context.
  233. - ~ellama-context-add-directory~: Add all files in directory to the context.
  234. - ~ellama-context-add-buffer~: Add buffer to context.
  235. - ~ellama-context-add-selection~: Add selected region to context.
  236. - ~ellama-context-add-info-node~: Add info node to context.
  237. - ~ellama-context-reset~: Clear global context.
  238. - ~ellama-context-manage~: Manage the global context. Inside context management
  239. buffer you can see ellama context elements. Available actions with key
  240. bindings:
  241. - ~n~: Move to the next line.
  242. - ~p~: Move to the previous line.
  243. - ~q~: Quit the window.
  244. - ~g~: Update context management buffer.
  245. - ~a~: Open the transient context menu for adding new elements.
  246. - ~d~: Remove the context element at the current point.
  247. - ~RET~: Preview the context element at the current point.
  248. - ~ellama-context-preview-element-at-point~: Preview ellama context element at
  249. point. Works inside ellama context management buffer.
  250. - ~ellama-context-remove-element-at-point~: Remove ellama context element at
  251. point from global context. Works inside ellama context management buffer.
  252. ** Chat Translation
  253. - ~ellama-chat-translation-enable~: Enable chat translation.
  254. - ~ellama-chat-translation-disable~: Disable chat translation.
  255. ** Blueprints and Community Prompts
  256. - ~ellama-community-prompts-select-blueprint~: Select a prompt from the
  257. community prompt collection. The user is prompted to choose a role, and then a
  258. corresponding prompt is inserted into a blueprint buffer.
  259. - ~ellama-blueprint-fill-variables~: Prompt user for values of variables found
  260. in current blueprint buffer and update them.
  261. ** Tools and DLP
  262. - ~ellama-tools-enable-by-name~: Enable a specific tool by its name. Use this
  263. command to activate individual tools. Requires the tool name as input.
  264. - ~ellama-tools-enable-all~: Enable all available tools at once. Use this
  265. command to activate every tool in the system for comprehensive functionality
  266. without manual selection.
  267. - ~ellama-tools-disable-by-name~: Disable a specific tool by its name. Use this
  268. command to deactivate individual tools when their functionality is no longer
  269. needed.
  270. - ~ellama-tools-disable-all~: Disable all enabled tools simultaneously. Use this
  271. command to reset the system to a minimal state, ensuring no tools are active.
  272. - ~ellama-tools-dlp-show-incident-stats~: Show a summary buffer with recent DLP
  273. incident statistics.
  274. - ~ellama-tools-dlp-clear-session-bypasses~: Clear session-scoped DLP bypasses.
  275. - ~ellama-tools-dlp-reset-runtime-state~: Reset in-memory DLP runtime state,
  276. including incident logs and detector caches.
  277. * Keymap
  278. It's better to use a transient menu (~M-x ellama~) instead of a keymap. It
  279. offers a better user experience.
  280. In any buffer where there is active ellama streaming, you can press ~C-g~ and it
  281. will cancel current stream.
  282. Here is a table of keybindings and their associated functions in Ellama, using
  283. the ~ellama-keymap-prefix~ prefix (not set by default):
  284. | Keymap | Function | Description |
  285. |--------+--------------------------------------+------------------------------|
  286. | "w" | ellama-write | Write |
  287. | "c c" | ellama-code-complete | Code complete |
  288. | "c a" | ellama-code-add | Code add |
  289. | "c e" | ellama-code-edit | Code edit |
  290. | "c i" | ellama-code-improve | Code improve |
  291. | "c r" | ellama-code-review | Code review |
  292. | "c m" | ellama-generate-commit-message | Generate commit message |
  293. | "s s" | ellama-summarize | Summarize |
  294. | "s w" | ellama-summarize-webpage | Summarize webpage |
  295. | "s c" | ellama-summarize-killring | Summarize killring |
  296. | "s l" | ellama-load-session | Session Load |
  297. | "s r" | ellama-session-rename | Session rename |
  298. | "s d" | ellama-session-delete | Session delete |
  299. | "s a" | ellama-session-switch | Session activate |
  300. | "P" | ellama-proofread | Proofread |
  301. | "i w" | ellama-improve-wording | Improve wording |
  302. | "i g" | ellama-improve-grammar | Improve grammar and spelling |
  303. | "i c" | ellama-improve-conciseness | Improve conciseness |
  304. | "m l" | ellama-make-list | Make list |
  305. | "m t" | ellama-make-table | Make table |
  306. | "m f" | ellama-make-format | Make format |
  307. | "a a" | ellama-ask-about | Ask about |
  308. | "a i" | ellama-chat | Chat (ask interactively) |
  309. | "a I" | ellama-ask-image | Ask image |
  310. | "a A" | ellama-ask-audio | Ask audio |
  311. | "a R" | ellama-ask-audio-recording | Record audio and ask |
  312. | "a l" | ellama-ask-line | Ask current line |
  313. | "a s" | ellama-ask-selection | Ask selection |
  314. | "t t" | ellama-translate | Text translate |
  315. | "t b" | ellama-translate-buffer | Translate buffer |
  316. | "t e" | ellama-chat-translation-enable | Translation enable |
  317. | "t d" | ellama-chat-translation-disable | Translation disable |
  318. | "t c" | ellama-complete | Text complete |
  319. | "d w" | ellama-define-word | Define word |
  320. | "x b" | ellama-context-add-buffer | Context add buffer |
  321. | "x f" | ellama-context-add-file | Context add file |
  322. | "x d" | ellama-context-add-directory | Context add directory |
  323. | "x I" | ellama-context-add-image | Context add image |
  324. | "x A" | ellama-context-add-audio | Context add audio |
  325. | "x R" | ellama-context-add-audio-recording | Context record audio |
  326. | "x S" | ellama-context-start-audio-recording | Start audio recording |
  327. | "x E" | ellama-context-stop-audio-recording | Stop audio recording |
  328. | "x s" | ellama-context-add-selection | Context add selection |
  329. | "x i" | ellama-context-add-info-node | Context add info node |
  330. | "x r" | ellama-context-reset | Context reset |
  331. | "p s" | ellama-provider-select | Provider select |
  332. * Configuration
  333. Ellama has many options because it covers chat, context, tools, agents, DLP,
  334. SRT, blueprints, and provider-specific workflows. The reference below is
  335. grouped by area so the common settings are easier to find.
  336. ** Option Reference
  337. *** Core Behavior and Providers
  338. - ~ellama-enable-keymap~: Enable the Ellama keymap.
  339. - ~ellama-keymap-prefix~: The keymap prefix for Ellama.
  340. - ~ellama-user-nick~: The user nick in logs.
  341. - ~ellama-assistant-nick~: The assistant nick in logs.
  342. - ~ellama-language~: The language for Ollama translation. Default
  343. language is english.
  344. - ~ellama-provider~: llm provider for ellama.
  345. There are many supported providers: ~ollama~, ~open ai~, ~vertex~,
  346. ~GPT4All~. For more information see
  347. [[https://elpa.gnu.org/packages/llm.html][llm documentation]].
  348. - ~ellama-max-tokens~: Maximum number of tokens to generate. If not set, use
  349. the provider default.
  350. - ~ellama-providers~: association list of model llm providers with name as key.
  351. - ~ellama-spinner-enabled~: Enable spinner during text generation.
  352. - ~ellama-spinner-type~: Spinner type for ellama. Default type is
  353. ~progress-bar~.
  354. - ~ellama-auto-scroll~: If enabled ellama buffer will scroll automatically
  355. during generation. Disabled by default.
  356. - ~ellama-fill-paragraphs~: Option to customize ellama paragraphs filling
  357. behaviour.
  358. - ~ellama-response-process-method~: Configure how LLM responses are processed.
  359. Options include streaming for real-time output, async for asynchronous
  360. processing, or skipping every N messages to reduce resource usage.
  361. *** Sessions and Naming
  362. - ~ellama-name-prompt-words-count~: Count of words in prompt to generate name.
  363. - Prompt templates for every command.
  364. - ~ellama-chat-done-callback~: Callback that will be called on ellama
  365. chat response generation done. It should be a function with single argument
  366. generated text string.
  367. - ~ellama-nick-prefix-depth~: User and assistant nick prefix depth. Default
  368. value is 2.
  369. - ~ellama-sessions-directory~: Directory for saved ellama sessions.
  370. - ~ellama-major-mode~: Major mode for ellama commands. Org mode by default.
  371. - ~ellama-session-auto-save~: Automatically save ellama sessions if set. Enabled
  372. by default.
  373. - ~ellama-session-persist-provider-keys~: Control provider key persistence in
  374. saved session files. Disabled by default; set to ~auth-source~ to restore
  375. provider keys from auth-source lookup references.
  376. - ~ellama-session-auto-compact-enabled~: Automatically compact long chat session
  377. context. Enabled by default.
  378. - ~ellama-session-auto-compact-token-threshold~: Total token count that triggers
  379. automatic session compaction. If not set, Ellama uses
  380. ~ellama-session-auto-compact-threshold-percent~ of the provider context
  381. window.
  382. - ~ellama-session-auto-compact-threshold-percent~: Percentage of provider
  383. context limit that triggers automatic compaction. Default value is 80.
  384. - ~ellama-session-auto-compact-keep-last-turns~: Number of recent user turns to
  385. keep verbatim during compaction. Default value is 3.
  386. - ~ellama-session-auto-compact-allow-fewer-kept-turns~: Allow compaction to keep
  387. fewer recent user turns when the configured keep count would otherwise prevent
  388. short but oversized sessions from being compacted. Enabled by default.
  389. - ~ellama-session-auto-compact-target-token-threshold~: Preferred target token
  390. count after compaction. If not set, Ellama targets half of the compaction
  391. threshold.
  392. - ~ellama-session-auto-compact-provider~: Provider used to summarize old session
  393. context. If not set, Ellama uses ~ellama-summarization-provider~, then the
  394. session provider.
  395. - ~ellama-session-auto-compact-show-message~: Show compaction notices in chat
  396. buffers. Enabled by default.
  397. - ~ellama-session-auto-compact-include-tool-results~: Include tool results in
  398. the history sent to the compaction provider. Disabled by default. Tool calls
  399. are still included so the summary can record actions taken during the session.
  400. - ~ellama-session-auto-compact-prompt-template~: Prompt template for automatic
  401. session context compaction.
  402. - ~ellama-naming-scheme~: How to name new sessions.
  403. - ~ellama-naming-provider~: LLM provider for generating session names by LLM. If
  404. not set ~ellama-provider~ will be used.
  405. *** Task Providers and Media
  406. - ~ellama-chat-translation-enabled~: Enable chat translations if set.
  407. - ~ellama-translation-provider~: LLM translation provider. ~ellama-provider~
  408. will be used if not set.
  409. - ~ellama-coding-provider~: LLM coding tasks provider. ~ellama-provider~ will
  410. be used if not set.
  411. - ~ellama-image-file-extensions~: File extensions supported for image input.
  412. SVG is intentionally unsupported.
  413. - ~ellama-summarization-provider~: LLM summarization provider.
  414. ~ellama-provider~ will be used if not set.
  415. - ~ellama-extraction-provider~: LLM provider for data extraction.
  416. - ~ellama-completion-provider~: LLM provider for code completion tasks.
  417. *** Display Context and Reasoning
  418. - ~ellama-show-quotes~: Show quotes content in chat buffer. Disabled by default.
  419. - ~ellama-chat-display-action-function~: Display action function for
  420. ~ellama-chat~.
  421. - ~ellama-instant-display-action-function~: Display action function for
  422. ~ellama-instant~.
  423. - ~ellama-translate-italic~: Translate italic during markdown to org
  424. transformations. Enabled by default.
  425. - ~ellama-text-display-limit~: Limit for text display in context elements.
  426. - ~ellama-context-poshandler~: Position handler for displaying context buffer.
  427. ~posframe-poshandler-frame-top-center~ will be used if not set.
  428. - ~ellama-context-border-width~: Border width for the context buffer.
  429. - ~ellama-image-context-default-scope~: Default scope for image context added
  430. interactively. Use ~ephemeral~ for one request only, or ~persistent~ to keep
  431. image context until it is removed or reset.
  432. - ~ellama-always-show-chain-steps~: Show chain of intermediate steps during
  433. reasoning.
  434. - ~ellama-session-remove-reasoning~: Remove internal reasoning from the session
  435. after ellama provide an answer. This can improve long-term communication with
  436. reasoning models. Enabled by default.
  437. - ~ellama-session-hide-org-quotes~: Hide org quotes in the Ellama session
  438. buffer. From now on, think tags will be replaced with quote blocks. If this
  439. flag is enabled, reasoning steps will be collapsed after generation and upon
  440. session loading. Enabled by default.
  441. - ~ellama-output-remove-reasoning~: Eliminate internal reasoning from ellama
  442. output to enhance the versatility of reasoning models across diverse
  443. applications.
  444. - ~ellama-context-posframe-enabled~: Enable showing posframe with ellama
  445. context.
  446. - ~ellama-context-manage-display-action-function~: Display action function for
  447. ~ellama-context-manage~. Default value ~display-buffer-same-window~.
  448. - ~ellama-context-preview-element-display-action-function~: Display action
  449. function for ~ellama-context-preview-element~.
  450. - ~ellama-context-line-always-visible~: Make context header or mode line always
  451. visible, even with empty context.
  452. - ~ellama-show-reasoning~: Show reasoning in separate buffer if enabled. Enabled
  453. by default.
  454. - ~ellama-reasoning-display-action-function~: Display action function for
  455. reasoning.
  456. - ~ellama-display-session-buffer-on-generation~: Display the session buffer
  457. whenever generation starts. This also applies to sub-agent sessions started by
  458. the ~task~ tool, so delegated work is visible while it runs.
  459. - ~ellama-session-line-template~: Template for formatting the current session
  460. line.
  461. *** Blueprints Prompts and Conversion
  462. - ~ellama-blueprints~: Directory or list of directories for blueprint storage.
  463. - ~ellama-command-map~: Keymap for ellama commands.
  464. - ~ellama-eval-default-max-steps~: Default maximum number of steps in eval loop.
  465. - ~ellama-eval-keep-workspaces~: Whether to keep workspaces after eval
  466. completion.
  467. - ~ellama-eval-loop-detection-enabled~: Enable detection of infinite loops in
  468. eval loops.
  469. - ~ellama-eval-loop-detection-max-traces~: Maximum number of traces for loop
  470. detection.
  471. - ~ellama-eval-loop-detection-repeated-threshold~: Threshold for repeated
  472. elements to trigger loop detection.
  473. - ~ellama-eval-timeout-seconds~: Timeout in seconds for eval operations.
  474. - ~ellama-markdown-to-org-converter~: Method for markdown to org conversion.
  475. - ~ellama-pandoc-markdown-to-org-args~: Arguments for pandoc markdown-to-org
  476. conversion.
  477. - ~ellama-pandoc-program~: Path to pandoc executable for markdown-to-org
  478. conversion.
  479. *** Tool Prompts and Edit Behavior
  480. - ~ellama-tools-agent-continue-prompt~: Prompt template for agent continue
  481. operation.
  482. - ~ellama-tools-agent-planning-prompt~: Prompt template for agent planning.
  483. - ~ellama-tools-balanced-edit-enabled~: Enable balanced edit mode for tools.
  484. - ~ellama-tools-balanced-edit-modes~: Major modes eligible for balanced edit
  485. mode.
  486. - ~ellama-tools-read-before-write-enabled~: Enable read-before-write for tool
  487. operations.
  488. - ~ellama-tools-shell-command-default-timeout~: Default timeout for shell
  489. command execution.
  490. *** DLP and Irreversible Actions
  491. - ~ellama-tools-dlp-env-secret-entropy-threshold~: Entropy threshold for
  492. detecting environment secrets.
  493. - ~ellama-tools-dlp-env-secret-heuristic-stages~: Stages in env secret heuristic
  494. detection.
  495. - ~ellama-tools-dlp-env-secret-max-length~: Maximum length for environment
  496. secret detection.
  497. - ~ellama-tools-dlp-env-secret-min-length~: Minimum length for environment
  498. secret detection.
  499. - ~ellama-tools-dlp-env-secret-min-score~: Minimum score for environment secret
  500. heuristic.
  501. - ~ellama-tools-dlp-message-prefix~: Prefix for DLP messages in logs.
  502. - ~ellama-tools-dlp-redaction-placeholder-format~: Format template for DLP
  503. redaction placeholders.
  504. - ~ellama-tools-irreversible-high-confidence-block-rules~: Rules for blocking
  505. high-confidence irreversible actions.
  506. *** Transient Menus Community Prompts and Diagnostics
  507. - ~ellama-transient-system-show-limit~: Maximum number of system elements to
  508. show in transient.
  509. - ~ellama-transient-provider-types~: Provider types available for interactive
  510. switching in the model transient. Each entry specifies the provider record
  511. type, display label, library, and constructor.
  512. - ~ellama-community-prompts-url~: The URL of the community prompts collection.
  513. - ~ellama-community-prompts-file~: Path to the CSV file containing community
  514. prompts. This file is expected to be located inside an ~ellama~ subdirectory
  515. within your ~user-emacs-directory~.
  516. - ~ellama-debug~: Enable debug. When enabled, generated text is now logged to a
  517. ~*ellama-debug*~ buffer with a separator for easier tracking of debug
  518. information. The debug output includes the raw text being processed and is
  519. appended to the end of the debug buffer each time.
  520. - ~ellama-undo-on-error~: Undo partial buffer insertions when an LLM request
  521. fails. Disabled by default; when nil, Ellama keeps partial output inserted
  522. before the error.
  523. *** Tool Access and Sandboxing
  524. - ~ellama-tools-allow-all~: Allow ~ellama~ using all the tools without user
  525. confirmation. Dangerous. Use at your own risk.
  526. - ~ellama-tools-allowed~: List of allowed ~ellama~ tools. Tools from this list
  527. will work without user confirmation.
  528. - ~ellama-tools-argument-max-length~: Max length of function argument in the
  529. confirmation prompt. Default value 50.
  530. - ~session_file~: Materialize the full live Ellama session transcript to a
  531. private temporary file and return its path. Use ~read_file~, ~grep_in_file~,
  532. or ~lines_range~ to inspect it. The snapshot is refreshed on each call and
  533. removed with the session buffer. Reading the returned file still goes through
  534. the normal DLP and SRT filesystem checks.
  535. - ~ellama-tools-read-file-default-mode~: Default mode for the ~read_file~
  536. tool. Use ~auto~ to read text files as text and supported image or audio files
  537. as media. Use ~text~, ~image~, or ~audio~ to force a specific mode.
  538. - ~ellama-tools-dlp-safe-read-file-regexps~: Canonical file-name regexps whose
  539. ~read_file~-style outputs skip output DLP scans. Defaults to Ellama source
  540. files in the loaded Ellama directory. Input DLP, other tool outputs, access
  541. checks and output line budgets still apply.
  542. - ~ellama-tools-edit-before-shell-commands~: Shell hook plists to run before
  543. mutating edit tools write files. Hooks run asynchronously from Emacs' UI, but
  544. the edit tool result is returned to the agent only after hook processing
  545. finishes.
  546. - ~ellama-tools-edit-after-shell-commands~: Shell hook plists to run after
  547. mutating edit tools write files. Hooks run asynchronously from Emacs' UI, but
  548. the edit tool result is returned to the agent only after hook processing
  549. finishes.
  550. - ~ellama-tools-use-srt~: Run shell-based tools (~shell_command~, ~grep~ and
  551. ~grep_in_file~) via the external ~srt~ sandbox runtime. Disabled by default.
  552. If enabled, non-shell file tools also perform local filesystem checks derived
  553. from the same ~srt~ settings file to keep behavior aligned. The local checks
  554. currently enforce the filesystem subset ~denyRead~, ~allowWrite~ and
  555. ~denyWrite~ for tools such as ~read_file~, ~write_file~, ~edit_file~,
  556. ~directory_tree~, ~move_file~, ~count_lines~ and ~lines_range~. If enabled
  557. and ~srt~ is not installed, or the relevant ~srt~ settings file is missing or
  558. malformed, the tool call signals a user error (fail closed).
  559. - ~ellama-tools-srt-program~: Sandbox runtime executable name/path used when
  560. ~ellama-tools-use-srt~ is enabled. Default value is ~"srt"~.
  561. - ~ellama-tools-srt-args~: Extra arguments passed to ~srt~ before the wrapped
  562. command (for example ~--settings /path/to/settings.json~). The same arguments
  563. are also used to resolve the settings file path for local non-shell filesystem
  564. checks (default =~/.srt-settings.json= if no ~--settings~/~-s~ is provided).
  565. *** Task Templates Blueprints and Skills
  566. - ~ellama-tools-task-template-dirs~: Directories where direct
  567. ~ellama-tools-task-from-template-tool~ calls search for prompt templates when
  568. no ~template_base~ is supplied. Relative template names are resolved below
  569. these directories.
  570. - ~ellama-tools-task-template-allow-absolute-paths~: Allow absolute file names
  571. in the ~task_from_template~ tool ~template~ argument. Disabled by default.
  572. Relative template names are still supported.
  573. - ~ellama-blueprint-global-dir~: Global directory for storing blueprint files.
  574. - ~ellama-blueprint-local-dir~: Local directory name for project-specific
  575. blueprints.
  576. - ~ellama-blueprint-file-extensions~: File extensions recognized as blueprint
  577. files.
  578. - ~ellama-blueprint-variable-regexp~: Regular expression to match blueprint
  579. variables like ~{var_name}~.
  580. - ~ellama-skills-global-path~: Path to the global directory containing Agent
  581. Skills.
  582. - ~ellama-skills-local-path~: Project-relative path for local Agent Skills.
  583. Default value is ~"skills"~.
  584. *** Agent and Subagent Loops
  585. - ~ellama-tools-agent-default-max-steps~: Default maximum number of automatic
  586. continuation steps for ~ellama-plan-and-act~. Default value is 40.
  587. - ~ellama-tools-subagent-default-max-steps~: Default maximum number of
  588. auto-continue steps for a sub-agent. Default value is 30.
  589. - ~ellama-tools-subagent-loop-detection-enabled~: Detect repeated identical tool
  590. calls in sub-agent sessions. Enabled by default.
  591. - ~ellama-tools-subagent-loop-detection-repeated-threshold~: Number of
  592. consecutive identical sub-agent tool calls that triggers recovery. Default
  593. value is 2.
  594. - ~ellama-tools-subagent-loop-detection-max-traces~: Maximum recent sub-agent
  595. tool calls retained for loop detection. Default value is 50.
  596. - ~ellama-tools-subagent-continue-prompt~: Prompt sent to a sub-agent when it
  597. finishes a turn without calling ~report_result~.
  598. - ~ellama-tools-subagent-roles~: Subagent roles with provider, system prompt and
  599. allowed tools. Configuration of subagents for the ~task~ tool. The built-in
  600. ~explorer~ and ~coder~ roles include ~session_file~ so a compacted sub-agent
  601. can recover details from its own live transcript.
  602. ** Session Provider Keys
  603. Ellama does not persist provider keys as plaintext in session files. Saved
  604. sessions keep provider settings such as model and URL, but provider key slots
  605. are removed before writing the session file. When a session is loaded, Ellama
  606. restores missing keys from the configured provider when possible.
  607. If a saved provider key cannot be restored, the session still loads. Requests
  608. using that provider can fail later with the provider's normal authentication
  609. error until the provider is configured again.
  610. Set ~ellama-session-persist-provider-keys~ to ~auth-source~ to save an
  611. auth-source lookup reference in the session file. The secret itself stays in
  612. auth-source and is resolved when the session is loaded. Ellama uses the
  613. provider URL host when available, otherwise the provider symbol or provider
  614. type, together with ~ellama-session-provider-key-auth-source-user~ and
  615. ~ellama-session-provider-key-auth-source-port~.
  616. Example auth-source entry:
  617. #+BEGIN_SRC authinfo
  618. machine api.example.com login ellama port api-key password example-secret
  619. #+END_SRC
  620. Example configuration:
  621. #+BEGIN_SRC emacs-lisp
  622. (setopt ellama-session-persist-provider-keys 'auth-source)
  623. (setopt ellama-session-provider-key-auth-source-user "ellama")
  624. (setopt ellama-session-provider-key-auth-source-port "api-key")
  625. #+END_SRC
  626. ** Session Compaction
  627. Ellama can compact long chat sessions to keep them within the provider context
  628. window. Compaction summarizes older conversation turns into one synthetic
  629. assistant message and keeps the most recent user turns verbatim. New messages
  630. continue from the compacted prompt, so the session can keep running without
  631. resending the full history.
  632. Automatic compaction is enabled by default with
  633. ~ellama-session-auto-compact-enabled~. It runs after a response when Ellama can
  634. determine or estimate token usage and the session crosses the configured
  635. threshold. Use ~ellama-session-auto-compact-token-threshold~ for an absolute
  636. token threshold, or leave it unset to use
  637. ~ellama-session-auto-compact-threshold-percent~ of the provider context limit.
  638. While a session request or compaction is still running, Ellama rejects another
  639. request for the same session. This prevents accidental duplicate sends, for
  640. example by pressing ~C-c C-c~ twice in a chat buffer.
  641. You can compact sessions manually:
  642. - ~M-x ellama-session-compact-current~ compacts the current session.
  643. - ~M-x ellama-session-compact~ prompts for an active session and compacts it.
  644. Ellama keeps ~ellama-session-auto-compact-keep-last-turns~ recent user turns by
  645. default. When ~ellama-session-auto-compact-allow-fewer-kept-turns~ is non-nil,
  646. short oversized sessions may keep fewer recent turns so there is still older
  647. history to summarize. Disable this option when compaction should fail instead
  648. of reducing the kept-turn count.
  649. The system message is not summarized by the compaction LLM. Ellama restores the
  650. original system message in the compacted session prompt context, including when
  651. an LLM provider moved the system message into a system interaction before the
  652. request.
  653. When ~session_file~ is enabled for the session, the synthetic compaction summary
  654. also tells the model that the full live transcript is available through that
  655. tool. The model can then recover older details on demand with ~grep_in_file~ or
  656. ~lines_range~ instead of keeping the whole transcript in the provider context.
  657. Tool calls and their arguments are included in the history sent to the
  658. compaction provider, but old tool results are omitted by default. Omitted
  659. results remain available in the live transcript when ~session_file~ is enabled.
  660. Set ~ellama-session-auto-compact-include-tool-results~ to a non-nil value when
  661. exact old tool output must stay directly in the compacted model context or
  662. transcript recovery is unavailable.
  663. Example configuration:
  664. #+BEGIN_SRC emacs-lisp
  665. (setopt ellama-session-auto-compact-enabled t)
  666. (setopt ellama-session-auto-compact-threshold-percent 75)
  667. (setopt ellama-session-auto-compact-keep-last-turns 4)
  668. (setopt ellama-session-auto-compact-allow-fewer-kept-turns t)
  669. (setopt ellama-session-auto-compact-provider ellama-summarization-provider)
  670. #+END_SRC
  671. ** Image Input
  672. Ellama can send image files to providers that advertise the ~image-input~
  673. capability through the ~llm~ library. Image data is sent as multipart media and
  674. is supported for PNG, JPEG, WebP and GIF files by default.
  675. Use ~M-x ellama-ask-image~ to ask about one image. This command follows the same
  676. context-based workflow as ~ellama-ask-about~: it adds the image as ephemeral
  677. context, sends the request with ~ellama-chat~, and shows the image link in the
  678. chat buffer. ~M-x ellama-chat-with-image~ and ~M-x ellama-chat-with-images~ use
  679. the same context workflow for compatibility. The main transient menu also
  680. includes "Chat with image".
  681. Programmatic calls can also pass image files directly:
  682. #+BEGIN_SRC emacs-lisp
  683. (ellama-chat "Describe this screenshot." nil
  684. :images '("/path/to/screenshot.png"))
  685. (ellama-stream "Extract visible text."
  686. :images '("/path/to/image.png"))
  687. #+END_SRC
  688. The singular ~:image~ argument is also accepted as a convenience alias.
  689. Use ~M-x ellama-context-add-image~ to add an image to context. Image context is
  690. ephemeral by default, so it is attached to the next request and then removed.
  691. Set ~ellama-image-context-default-scope~ to ~persistent~ to keep image context
  692. until it is removed or the context is reset. The context transient menu also
  693. provides "Add Image"; combine it with ~--ephemeral~ to force one-request image
  694. context.
  695. The built-in ~read_file~ tool supports image and audio files through a
  696. configurable read mode:
  697. - ~auto~: read text files as text and queue supported media files for model
  698. input
  699. - ~text~: force text reading, even for files with image-like extensions
  700. - ~image~: force image handling and return a clear text error for unsupported
  701. image types, missing sessions, or providers without ~image-input~
  702. - ~audio~: force audio handling and return a clear text error for unsupported
  703. audio types, missing sessions, or providers without ~audio-input~
  704. Tool calls can request image handling explicitly:
  705. #+BEGIN_SRC json
  706. {
  707. "file_name": "/path/to/image.png",
  708. "mode": "image"
  709. }
  710. #+END_SRC
  711. ** Audio Input
  712. Ellama can also send audio files to providers with the ~audio-input~ capability.
  713. The default supported extensions are WAV, MP3, M4A, AAC, FLAC, OGG, Opus and
  714. WebM. Audio is sent as multipart media, the same transport used for image
  715. input. Set ~ellama-audio-file-extensions~ if your provider accepts another
  716. format.
  717. Audio transport depends on the installed ~llm~ package. Ellama requires ~llm~
  718. 0.31.1 or newer, which includes audio serialization for OpenAI-compatible and
  719. Ollama providers. Gemini and Vertex use their native inline media format.
  720. Use ~M-x ellama-ask-audio~ for one audio file, or ~M-x ellama-chat-with-audio~
  721. inside a chat workflow. For several files, use ~M-x ellama-chat-with-audios~.
  722. These commands add audio as ephemeral context for the next request, so the file
  723. is not kept around unless you add it as persistent context yourself.
  724. The ~read_file~ tool also accepts audio. In ~auto~ mode it recognizes supported
  725. audio extensions; use ~audio~ to request audio handling explicitly:
  726. #+BEGIN_SRC json
  727. {
  728. "file_name": "/path/to/recording.wav",
  729. "mode": "audio"
  730. }
  731. #+END_SRC
  732. The tool queues the recording as media for the next model turn. It does not
  733. return binary audio as text.
  734. Programmatic calls can pass audio directly:
  735. #+BEGIN_SRC emacs-lisp
  736. (ellama-chat "Transcribe this note." nil
  737. :audios '("/path/to/note.wav"))
  738. (ellama-stream "Summarize the meeting."
  739. :audio "/path/to/meeting.mp3")
  740. #+END_SRC
  741. Use ~:media~ when a request mixes images and audio:
  742. #+BEGIN_SRC emacs-lisp
  743. (ellama-chat "Compare the screenshot with the spoken notes." nil
  744. :media '("/path/to/screenshot.png"
  745. "/path/to/notes.wav"))
  746. #+END_SRC
  747. Ellama selects an installed microphone recorder automatically. On macOS it
  748. tries FFmpeg and then SoX. On GNU/Linux it tries ~arecord~, FFmpeg, and then
  749. SoX. Set ~ellama-audio-recording-command~ if you need another program, input
  750. device, or extra arguments. On macOS, allow microphone access for Emacs in
  751. System Settings under Privacy & Security > Microphone. If Emacs runs in a
  752. terminal, allow access for that terminal instead.
  753. FFmpeg recordings use dynamic speech normalization by default. This helps when
  754. the microphone input is quiet and reduces the chance that an audio model will
  755. invent speech from a weak signal. Set ~ellama-audio-recording-ffmpeg-filter~ to
  756. nil to keep the original input level, or replace it with another FFmpeg audio
  757. filter.
  758. *** macOS microphone permission
  759. Emacs may be missing from the Microphone list when its application bundle has no
  760. ~NSMicrophoneUsageDescription~ entry. This can happen with some ~emacs-plus~
  761. builds. In that case macOS cannot display the permission prompt, and FFmpeg may
  762. exit with ~Abort trap: 6~ or report that no audio device was found.
  763. Quit Emacs, set ~APP~ to the installed application bundle, and check the entry:
  764. #+BEGIN_SRC shell
  765. APP=/Applications/Emacs.app
  766. plutil -extract NSMicrophoneUsageDescription raw \
  767. "$APP/Contents/Info.plist"
  768. #+END_SRC
  769. If ~plutil~ reports that the key is missing, add it, re-sign the application,
  770. and reset the microphone permission:
  771. #+BEGIN_SRC shell
  772. /usr/libexec/PlistBuddy \
  773. -c 'Add :NSMicrophoneUsageDescription string Ellama records audio from the microphone.' \
  774. "$APP/Contents/Info.plist"
  775. codesign --force --deep --sign - "$APP"
  776. BUNDLE_ID=$(plutil -extract CFBundleIdentifier raw \
  777. "$APP/Contents/Info.plist")
  778. tccutil reset Microphone "$BUNDLE_ID"
  779. open "$APP"
  780. #+END_SRC
  781. Start a recording after Emacs opens. macOS should now ask for microphone
  782. access, and Emacs should appear in System Settings under Privacy & Security >
  783. Microphone. A package upgrade may replace the application bundle, so repeat
  784. these steps if the entry disappears after upgrading Emacs.
  785. For short messages, use ~M-x ellama-ask-audio-recording~ or ~M-x
  786. ellama-context-add-audio-recording~. Ellama records for
  787. ~ellama-audio-recording-duration~ seconds and writes a temporary WAV file by
  788. default. Set ~ellama-audio-recording-file-extension~ if your recorder writes
  789. another format.
  790. For longer messages, start and stop recording yourself:
  791. #+BEGIN_SRC text
  792. M-x ellama-context-start-audio-recording
  793. ...speak for as long as needed...
  794. M-x ellama-context-stop-audio-recording
  795. #+END_SRC
  796. While recording is active, the mode line shows ~ellama:recording~. Stopping the
  797. recording adds the file to context, using ~ellama-audio-context-default-scope~
  798. to decide whether it is ephemeral or persistent.
  799. ** Task Tool Subagents
  800. Ellama provides two tools for delegating work to an asynchronous sub-agent. Use
  801. ~task~ with a free-form prompt and ~task_from_template~ with a prompt
  802. template. Keeping these call shapes separate makes both arguments and validation
  803. errors easier for local models to follow.
  804. Both tools return control to the parent model immediately. The sub-agent reports
  805. its final result by calling the injected ~report_result~ tool. If it finishes a
  806. turn without reporting a result, Ellama sends
  807. ~ellama-tools-subagent-continue-prompt~ until the task is complete or
  808. ~ellama-tools-subagent-default-max-steps~ is reached.
  809. Each sub-agent runs in its own Ellama session. When
  810. ~ellama-display-session-buffer-on-generation~ is non-nil, Ellama displays both
  811. the main session and sub-agent session buffers as generation starts. Sub-agent
  812. buffers include the delegated prompt under the ~Main agent:~ label, followed by
  813. the sub-agent response.
  814. Sub-agents also keep session-local tool loop state. When
  815. ~ellama-tools-subagent-loop-detection-enabled~ is non-nil, the second
  816. consecutive identical tool call returns a recovery message instead of the normal
  817. tool result. The message includes the repeated tool name, exact arguments, the
  818. latest tool result and a next action. If the same consecutive call chain
  819. continues beyond ~ellama-tools-subagent-loop-detection-repeated-threshold~,
  820. Ellama finishes the subtask with a loop-detected result. A later repeated call
  821. after a different tool call is treated as a new recovery opportunity, not as an
  822. immediate hard loop.
  823. If a sub-agent LLM request fails before producing a tool result, Ellama keeps
  824. the sub-agent loop alive. The first consecutive request error records the
  825. failure and immediately continues the sub-agent. The second consecutive request
  826. error resets the counter, compacts the sub-agent session automatically, and
  827. continues the loop after compaction finishes or is skipped. Any successful
  828. sub-agent response resets the consecutive error counter.
  829. The ~task~ tool requires a non-empty ~description~ and a configured ~role~:
  830. #+begin_src json
  831. {
  832. "description": "Inspect the parser and report possible edge cases.",
  833. "role": "explorer"
  834. }
  835. #+end_src
  836. Use ~task_from_template~ when a skill provides a reusable prompt:
  837. #+begin_src json
  838. {
  839. "template": "templates/researcher.md",
  840. "template_base": "/path/to/skill",
  841. "arguments": {
  842. "main_topic": "Example topic",
  843. "subtopic_name": "Example subtopic"
  844. },
  845. "role": "explorer"
  846. }
  847. #+end_src
  848. Prompt templates are plain text files with placeholders like ~{main_topic}~. The
  849. ~arguments~ object must provide values whose keys match the placeholder
  850. names. All four ~task_from_template~ arguments are required. Skills that use
  851. this tool should include the exact call shape and use their own directory as
  852. ~template_base~. If validation fails, the tool returns an error with the missing
  853. and unused keys and an example object to retry.
  854. Skills written for the older combined ~task~ interface should change the tool
  855. name to ~task_from_template~. Their template arguments stay the same.
  856. Template resolution is intentionally scoped:
  857. - relative ~template~ paths are resolved under ~template_base~
  858. - direct Lisp calls can omit ~template_base~ and search
  859. ~ellama-tools-task-template-dirs~
  860. - path traversal outside the selected base directory is rejected
  861. - absolute template paths are rejected unless
  862. ~ellama-tools-task-template-allow-absolute-paths~ is non-nil
  863. This keeps large prompts out of the main agent context while still letting
  864. skills bundle reusable task prompts next to their ~SKILL.md~ files.
  865. ** Plan-and-Act Agent Loop
  866. ~ellama-plan-and-act~ runs a local agent in the current Ellama chat session. It
  867. starts with a planning turn, asks the model to submit a checklist, and then
  868. continues automatically through the checklist until the agent reports a result,
  869. marks the plan complete, becomes blocked, or reaches
  870. ~ellama-tools-agent-default-max-steps~.
  871. If the LLM request fails before the loop receives a usable response, Ellama
  872. continues the same agent loop instead of stopping it. The first consecutive
  873. request error is recorded and the loop continues. The second consecutive request
  874. error triggers automatic session compaction, resets the error counter, and then
  875. continues the loop. A successful response resets the consecutive error counter.
  876. The loop adds temporary controller tools to the session:
  877. - ~agent_submit_plan~ records the initial checklist before acting starts
  878. - ~agent_update_plan~ records progress as checklist items move between states
  879. - ~agent_report_result~ finishes the loop and restores the original tool set
  880. Models or providers that cannot call tools can still participate by emitting the
  881. fallback ~BEGIN_ELLAMA_AGENT_STATE~ block described in the controller prompt.
  882. Ellama parses that block, updates the stored state, and prints visible plan or
  883. status snapshots into the chat buffer.
  884. Start the loop with ~M-x ellama-plan-and-act~, or open the main transient with
  885. ~M-x ellama~ and press ~A~ in the ~Problem solving~ section. The transient
  886. entry respects the regular session options: use ~-n~ before ~A~ to create a new
  887. session, and use ~-e~ when ephemeral sessions are enabled.
  888. Without a new-session request, the command reuses the current chat buffer and
  889. session. If that session already has an active plan-and-act loop, a new user
  890. message resumes the same loop instead of replacing the plan. This makes it
  891. possible to interrupt a running request with ~C-g~, add corrective instructions
  892. under the next ~User:~ prompt, and continue the existing loop with ~C-c C-c~ or
  893. another ~ellama-plan-and-act~ call.
  894. Plan-and-act state is stored in the session extra data, so the loop survives
  895. session compaction and regular session persistence. The visible plan/status
  896. notes in the chat buffer are for transparency; the canonical state is the
  897. session state used by the continuation handler.
  898. ** Edit Tool Shell Hooks
  899. Projects can define shell commands that run around mutating edit tools:
  900. ~write_file~, ~append_file~, ~prepend_file~ and ~edit_file~. Hooks are read
  901. from the target file buffer, so project-local values from ~.dir-locals.el~ apply
  902. to the file being edited.
  903. Each hook entry is a plist with a required ~:command~ string. A non-zero exit
  904. status is always returned to the agent. Successful hook output is returned only
  905. when that hook has ~:show-output t~ and produced non-empty output.
  906. Before hooks run after access checks and syntax validation, but before the file
  907. is written. A failing before hook blocks the edit. After hooks run after a
  908. successful write; failure is reported to the agent and does not roll back the
  909. edit.
  910. Hook processes are started asynchronously, so long-running hooks do not block
  911. the Emacs UI. They are still blocking from the agent's point of view: the edit
  912. tool callback runs only after all relevant before/after hooks finish, and the
  913. agent receives the final hook status together with the edit result.
  914. Example project-local configuration:
  915. #+BEGIN_SRC emacs-lisp
  916. ((nil . ((ellama-tools-edit-before-shell-commands
  917. . ((:command "git diff --quiet")))
  918. (ellama-tools-edit-after-shell-commands
  919. . ((:command "make format-elisp" :show-output t)
  920. (:command "make test"))))))
  921. #+END_SRC
  922. Hook commands run from the target file's project root, or from the file
  923. directory when no project is found. The command environment includes:
  924. - ~ELLAMA_HOOK_PHASE~: ~before~ or ~after~
  925. - ~ELLAMA_EDIT_OPERATION~: ~write~, ~append~, ~prepend~ or ~edit~
  926. - ~ELLAMA_TOOL_NAME~: tool name such as ~write_file~
  927. - ~ELLAMA_FILE_NAME~: absolute target file name
  928. - ~ELLAMA_PROJECT_ROOT~: directory used as hook working directory
  929. - ~ELLAMA_HOOK_NAME~: optional ~:name~ value
  930. Hook diagnostics use their own output line budget instead of sharing one limit
  931. with the main tool result. Hook output is operational feedback and is not
  932. scanned by tool output DLP.
  933. ** DLP for Tool Input/Output
  934. Ellama includes an optional DLP (Data Loss Prevention) layer for tool calls. It
  935. can scan:
  936. - tool input (arguments sent from the model to tools)
  937. - tool output (strings returned from tools back to the model)
  938. The DLP layer supports regex-based rules and exact secret detection derived from
  939. environment variables (including common encoded variants such as
  940. base64/base64url and hex). It also includes an optional LLM-based semantic
  941. check as a block-only backstop for payloads that look unsafe but do not match a
  942. deterministic rule.
  943. Recommended initial rollout:
  944. - enable DLP
  945. - keep mode in ~monitor~
  946. - review incidents before switching selected paths to ~enforce~
  947. - if enabling the LLM detector, start with a small tool allowlist
  948. Example minimal setup:
  949. #+BEGIN_SRC emacs-lisp
  950. (setopt ellama-tools-dlp-enabled t)
  951. (setopt ellama-tools-dlp-mode 'monitor)
  952. (setopt ellama-tools-dlp-log-targets '(memory))
  953. #+END_SRC
  954. Key settings:
  955. - ~ellama-tools-dlp-enabled~: Enable DLP scanning for tool input/output.
  956. - ~ellama-tools-dlp-mode~: Rollout mode. Use ~monitor~ for detect+log only, or
  957. ~enforce~ to apply actions.
  958. - ~ellama-tools-dlp-regex-rules~: Regex detector rules (IDs, patterns,
  959. direction/tool/arg scoping, enable/disable, case folding).
  960. - ~ellama-tools-dlp-scan-env-exact-secrets~: Enable exact-secret detection from
  961. environment variables (enabled by default).
  962. - ~ellama-tools-dlp-llm-check-enabled~: Enable the optional isolated LLM safety
  963. classifier (disabled by default).
  964. - ~ellama-tools-dlp-llm-provider~: Provider used for the isolated LLM safety
  965. check. When nil, it falls back to the extraction provider, then the default
  966. provider.
  967. - ~ellama-tools-dlp-llm-directions~: Directions where the LLM detector may run
  968. (~input~, ~output~, or both).
  969. - ~ellama-tools-dlp-llm-max-scan-size~: Maximum bytes eligible for the LLM
  970. detector. Payloads above this limit are skipped for the LLM pass.
  971. - ~ellama-tools-dlp-llm-tool-allowlist~: Optional list of tool names allowed to
  972. use the LLM detector. Nil means all tools are eligible.
  973. - ~ellama-tools-dlp-llm-run-policy~: Run the LLM detector only when
  974. deterministic findings are empty (~clean-only~) or on every non-blocked scan
  975. (~always-unless-blocked~).
  976. - ~ellama-tools-dlp-max-scan-size~: Maximum bytes scanned per input/output
  977. payload (default 5 MB; larger payloads are truncated for scanning).
  978. - ~ellama-tools-dlp-input-default-action~: Default action for input findings in
  979. ~enforce~ mode (~allow~, ~warn~, ~block~).
  980. - ~ellama-tools-dlp-output-default-action~: Default action for output findings
  981. in ~enforce~ mode (~allow~, ~warn~, ~block~, ~redact~).
  982. - ~ellama-tools-dlp-output-warn-behavior~: Handling for output ~warn~ verdicts
  983. (~allow~, ~confirm~, or ~block~).
  984. - ~ellama-tools-dlp-safe-read-file-regexps~: Canonical file-name regexps whose
  985. file-reading outputs skip output DLP scans. This is for trusted source files
  986. that should not prompt on every agent read. It does not bypass input DLP,
  987. non-read tool output DLP, irreversible checks, ~srt~ checks, or line-budget
  988. truncation.
  989. - ~ellama-tools-dlp-policy-overrides~: Per-tool/per-arg overrides and
  990. exceptions. For structured input args, nested string values are scanned with
  991. path-like arg names (for example ~payload.items[0].token~). Override ~:arg~
  992. matches exact names and nested path prefixes (for example ~"payload"~ matches
  993. ~payload.items[0].token~).
  994. - ~ellama-tools-dlp-log-targets~: Incident log targets (~memory~, ~message~,
  995. ~file~).
  996. - ~ellama-tools-dlp-audit-log-file~: JSONL path used when ~file~ sink is
  997. enabled.
  998. - ~ellama-tools-dlp-incident-log-max~: Maximum in-memory incidents retained.
  999. - ~ellama-tools-dlp-input-fail-open~ / ~ellama-tools-dlp-output-fail-open~:
  1000. Behavior when DLP itself errors internally.
  1001. - ~ellama-tools-irreversible-enabled~: Enable irreversible-action handling.
  1002. - ~ellama-tools-irreversible-default-action~: Default irreversible action
  1003. (~warn~ or ~block~, with monitor downgrade to ~warn-strong~).
  1004. - ~ellama-tools-irreversible-unknown-tool-action~: Default action for unknown
  1005. MCP tools (~warn~ or ~allow~).
  1006. - ~ellama-tools-irreversible-require-typed-confirm~: Require typed phrase for
  1007. irreversible warnings.
  1008. - ~ellama-tools-irreversible-project-overrides-enabled~: Enable project-local
  1009. irreversible override policy.
  1010. - ~ellama-tools-irreversible-project-overrides-file~: Project policy file name.
  1011. - ~ellama-tools-irreversible-project-trust-store-file~: User trust store for
  1012. repository approval records (repo root + remote + policy hash).
  1013. - ~ellama-tools-irreversible-scoped-bypass-default-ttl~: Default TTL (seconds)
  1014. for session bypass entries.
  1015. - ~ellama-tools-output-line-budget-enabled~: Enable per-tool output line-budget
  1016. truncation before returning text to the model (enabled by default).
  1017. - ~ellama-tools-output-line-budget-max-lines~: Max lines per tool output
  1018. (default ~200~).
  1019. - ~ellama-tools-output-line-budget-max-line-length~: Max characters per line
  1020. before a single line is truncated (default ~4000~).
  1021. - ~ellama-tools-output-line-budget-save-overflow-file~: Save full overflowing
  1022. output to a temp file when the output source file is unknown (default ~t~).
  1023. Trusted read-file outputs:
  1024. ~ellama-tools-dlp-safe-read-file-regexps~ lets users mark known source files as
  1025. safe for output DLP. By default, Ellama marks its own loaded ~ellama*.el~ source
  1026. files safe, so autonomous agents can inspect Ellama internals without repeated
  1027. DLP approval prompts. The match is performed against the canonical file name.
  1028. Only output scans for file-reading tools are skipped; DLP still scans tool
  1029. inputs and outputs from other tools.
  1030. Example:
  1031. #+BEGIN_SRC emacs-lisp
  1032. (setopt ellama-tools-dlp-safe-read-file-regexps
  1033. (list (concat "\\`"
  1034. (regexp-quote
  1035. (file-truename "/path/to/ellama/"))
  1036. "ellama\\(?:-[[:alnum:]-]+\\)?\\.el\\'")))
  1037. #+END_SRC
  1038. Enforcement behavior (v1):
  1039. - input ~block~ prevents tool execution
  1040. - input ~warn~ asks for explicit confirmation before execution
  1041. - output ~block~ returns a safe denial string
  1042. - output ~redact~ replaces detected fragments with placeholders
  1043. - output ~warn~ follows ~ellama-tools-dlp-output-warn-behavior~ (~confirm~ by
  1044. default)
  1045. LLM safety check behavior (v1):
  1046. - the LLM detector runs only when ~ellama-tools-dlp-llm-check-enabled~ is
  1047. non-nil
  1048. - the checker uses an isolated structured-output request with no tools
  1049. - in ~monitor~, unsafe LLM verdicts are logged but do not change the result
  1050. - in ~enforce~, an unsafe LLM verdict may force ~block~
  1051. - LLM findings never trigger ~warn~ or ~redact~ and do not affect redaction
  1052. Irreversible action safety (v1):
  1053. - irreversible warnings use ~warn-strong~ with typed confirmation phrase ~I
  1054. UNDERSTAND THIS CANNOT BE UNDONE~
  1055. - in ~enforce~, high-confidence irreversible findings hard ~block~
  1056. - in ~monitor~, high-confidence irreversible findings still require typed
  1057. confirmation and do not hard block
  1058. - unknown MCP tool identities default to ~warn~ (configurable via
  1059. ~ellama-tools-irreversible-unknown-tool-action~)
  1060. - policy precedence for irreversible decisions: ~high-confidence enforce block~
  1061. > ~session bypass~ > ~project override~ > global irreversible default
  1062. - project overrides are ignored until the repository policy is explicitly
  1063. trusted; trust is bound to repo root, remote URL, and policy hash
  1064. - audit sink write failure for irreversible decisions is fail-closed; in
  1065. interactive sessions a separate explicit confirmation can override once
  1066. Session bypass helper:
  1067. #+BEGIN_SRC emacs-lisp
  1068. ;; Allow irreversible actions for one tool identity in this session.
  1069. (ellama-tools-dlp-add-session-bypass "mcp-db/query" 3600 "migration window")
  1070. #+END_SRC
  1071. Autonomous agent configuration:
  1072. Autonomous agents need fewer routine prompts, not fewer checks. If every file
  1073. read or harmless edit asks for approval, users learn to approve by reflex. Keep
  1074. the prompts for cases that actually need a decision:
  1075. - clean read/write operations inside the approved workspace run automatically
  1076. - secret leaks and prompt-injection-like output are redacted or blocked
  1077. - ambiguous dangerous actions require typed user confirmation or fail closed
  1078. - high-confidence destructive actions are blocked, not prompted
  1079. - unknown MCP tools warn until they are classified
  1080. ~ellama-tools-allow-all~ bypasses only the normal confirmation wrapper. DLP,
  1081. irreversible-action checks, output scanning, and ~srt~ filesystem checks still
  1082. run because DLP wraps the confirmation layer. Use ~allow-all~ only with DLP in
  1083. ~enforce~ mode and a constrained filesystem policy.
  1084. Recommended baseline for autonomous coding:
  1085. #+BEGIN_SRC emacs-lisp
  1086. ;; General agent defaults. This does not configure a provider or model.
  1087. (ellama-setup-agentic-coding)
  1088. ;; Low-friction autonomous mode with filesystem sandboxing.
  1089. (ellama-setup-agentic-coding
  1090. "~/.config/ellama/srt-autonomous.json")
  1091. #+END_SRC
  1092. The first form enables DLP enforcement, blocks irreversible actions, and tunes
  1093. the agent loop, but keeps global tool auto-approval off. Ordinary DLP
  1094. input/output findings still ask before continuing.
  1095. The second form enables ~srt~ and turns on ~ellama-tools-allow-all~. In that
  1096. mode, ordinary DLP input findings are allowed and ordinary output findings are
  1097. redacted, so the agent can keep working. Irreversible findings still block, and
  1098. built-in shell secret checks still block because SRT cannot tell whether a
  1099. command leaks a token to an allowed destination.
  1100. Use an ~srt~ policy that allows writes only inside the current project and a
  1101. scratch area. Add explicit read/write denials for secrets, credentials, audit
  1102. logs, and system paths. See the project sandbox example in the SRT Filesystem
  1103. Policy for Tools section.
  1104. There are two reasonable policies for dangerous cases. User-handled dangerous
  1105. cases ask only for DLP warnings and irreversible actions:
  1106. #+BEGIN_SRC emacs-lisp
  1107. (setopt ellama-tools-dlp-input-default-action 'warn)
  1108. (setopt ellama-tools-dlp-output-warn-behavior 'confirm)
  1109. (setopt ellama-tools-irreversible-default-action 'warn)
  1110. (setopt ellama-tools-irreversible-require-typed-confirm t)
  1111. #+END_SRC
  1112. Medium-risk irreversible actions require the typed confirmation phrase ~I
  1113. UNDERSTAND THIS CANNOT BE UNDONE~. High-confidence destructive actions are
  1114. still blocked in ~enforce~ mode before session or project overrides apply.
  1115. Secure fallback is better for unattended agents:
  1116. #+BEGIN_SRC emacs-lisp
  1117. (setopt ellama-tools-dlp-input-default-action 'block)
  1118. (setopt ellama-tools-dlp-output-warn-behavior 'block)
  1119. (setopt ellama-tools-irreversible-default-action 'block)
  1120. (setopt ellama-tools-irreversible-require-typed-confirm t)
  1121. #+END_SRC
  1122. With secure fallback, the agent receives a denial string and must find a safer
  1123. path. This avoids turning user confirmation into a routine approval habit.
  1124. Reduce prompt fatigue by tightening tool roles instead of weakening safety.
  1125. Avoid ~:tools :all~ for autonomous subagents. Prefer separate roles such as:
  1126. - read-only explorer without ~shell_command~
  1127. - coder with file tools and sandboxed ~shell_command~
  1128. - bash role only when a task explicitly needs shell access
  1129. - no ~ask_user~ tool unless user interruption is intentional
  1130. For MCP tools, keep ~ellama-tools-irreversible-unknown-tool-action~ as ~warn~
  1131. initially. After observing common safe tools, classify trusted tool identities
  1132. with ~ellama-tools-irreversible-tool-risk-overrides~ or trusted project
  1133. overrides. Use ~ellama-tools-dlp-add-session-bypass~ only for narrow tool
  1134. identities and short TTLs; do not disable DLP globally to reduce prompts.
  1135. If ~srt~ is not available, do not use global ~ellama-tools-allow-all~ for
  1136. autonomous coding. Use a small ~ellama-tools-allowed~ list of safe read-only
  1137. tools instead, and keep mutating tools behind confirmation or DLP fallback.
  1138. Tool output truncation behavior:
  1139. - line budget is applied per tool output payload
  1140. - if a payload exceeds the line budget, the model receives a truncation notice
  1141. plus the truncated snippet
  1142. - if lines exceed ~ellama-tools-output-line-budget-max-line-length~, those lines
  1143. are shortened and marked with ~...[line truncated]~
  1144. - when source is known (for example ~read_file~, ~lines_range~, ~grep_in_file~),
  1145. the notice includes source path and suggests using ~lines_range~ and
  1146. ~grep_in_file~/~grep~
  1147. - when source is unknown (for example generic tool output), full output is saved
  1148. to a temp file (if enabled) and the filename is included in the notice
  1149. Example regex rules:
  1150. #+BEGIN_SRC emacs-lisp
  1151. (setopt ellama-tools-dlp-regex-rules
  1152. '((:id "openai-key"
  1153. :pattern "sk-[[:alnum:]-]+"
  1154. :directions (input output))
  1155. (:id "pem-header"
  1156. :pattern "-----BEGIN [A-Z ]+-----"
  1157. :directions (output)
  1158. :enabled t)))
  1159. #+END_SRC
  1160. Example scoped override (ignore noisy shell command input):
  1161. #+BEGIN_SRC emacs-lisp
  1162. (setopt ellama-tools-dlp-policy-overrides
  1163. '((:tool "shell_command"
  1164. :direction input
  1165. :arg "cmd"
  1166. :except t)))
  1167. #+END_SRC
  1168. Example override for structured input payloads (top-level arg prefix match):
  1169. #+BEGIN_SRC emacs-lisp
  1170. (setopt ellama-tools-dlp-policy-overrides
  1171. '((:tool "write_file"
  1172. :direction input
  1173. :arg "content"
  1174. :action warn)))
  1175. #+END_SRC
  1176. Tuning helpers:
  1177. - ~M-x ellama-tools-dlp-reset-runtime-state~
  1178. - ~M-x ellama-tools-dlp-show-incident-stats~
  1179. - ~(ellama-tools-dlp-recent-incidents)~
  1180. - ~(ellama-tools-dlp-incident-stats)~
  1181. - ~(ellama-tools-dlp-incident-stats-report)~
  1182. Incident stats include rollups by risk class, rule ID, tool identity, and
  1183. decision type (including ~bypass~).
  1184. For a longer rollout/tuning walkthrough and more override examples, see
  1185. ~docs/dlp_rollout_guide.md~.
  1186. Troubleshooting:
  1187. - repeated irreversible warnings: classify trusted MCP tools with
  1188. ~ellama-tools-irreversible-tool-risk-overrides~ or use a short-lived session
  1189. bypass for one tool identity
  1190. - bypass expiry: session bypasses expire by TTL and are removed automatically;
  1191. re-add with ~ellama-tools-dlp-add-session-bypass~ when needed
  1192. - false positives: inspect incidents via ~ellama-tools-dlp-recent-incidents~ and
  1193. tune regex rules / overrides before moving more paths to enforce
  1194. ** SRT Filesystem Policy for Tools
  1195. When ~ellama-tools-use-srt~ is non-nil, the ~srt~ settings file is the source of
  1196. truth for tool filesystem policy:
  1197. - shell-based tools (~shell_command~, ~grep~, ~grep_in_file~) are enforced by
  1198. the external ~srt~ runtime
  1199. - non-shell file tools (~read_file~, ~write_file~, ~append_file~,
  1200. ~prepend_file~, ~edit_file~, ~directory_tree~, ~move_file~, ~count_lines~,
  1201. ~lines_range~) apply local checks derived from the same ~srt~ settings file
  1202. Supported local filesystem subset (current):
  1203. - ~filesystem.denyRead~
  1204. - ~filesystem.allowWrite~
  1205. - ~filesystem.denyWrite~ (takes precedence over ~allowWrite~)
  1206. For irreversible audit hardening, keep ~ellama-tools-dlp-audit-log-file~ outside
  1207. ~allowWrite~ and add explicit ~denyRead~/~denyWrite~ entries for the audit
  1208. directory.
  1209. Local checks intentionally ignore unrelated ~srt~ keys (for example
  1210. ~network.*~). If the ~filesystem~ section is missing, local checks use the same
  1211. defaults as ~srt~ for filesystem access: reads are allowed by default and writes
  1212. are denied unless allowed by ~allowWrite~.
  1213. Path matching notes for local checks:
  1214. - relative paths in ~srt~ rules are resolved against Emacs ~default-directory~
  1215. - ~~ expands to the current user home directory
  1216. - literal paths, directory-prefix rules, and glob patterns are supported
  1217. - malformed/unsupported patterns signal a ~user-error~ (fail closed)
  1218. The local checks fail closed when ~ellama-tools-use-srt~ is enabled and:
  1219. - ~srt~ is not installed
  1220. - the resolved settings file is missing
  1221. - the settings file is malformed JSON
  1222. - relevant ~filesystem~ keys have an invalid shape
  1223. Example ~srt~ config for a project sandbox:
  1224. #+BEGIN_SRC json
  1225. {
  1226. "network": {
  1227. "allowedDomains": [
  1228. "github.com",
  1229. "*.github.com",
  1230. "api.github.com",
  1231. "*.npmjs.org"
  1232. ],
  1233. "deniedDomains": [],
  1234. "allowUnixSockets": [],
  1235. "allowLocalBinding": false
  1236. },
  1237. "filesystem": {
  1238. "denyRead": [
  1239. "~/.srt-settings.json",
  1240. "~/.ssh",
  1241. "~/.aws",
  1242. "~/.gnupg/",
  1243. "~/.config/gcloud/",
  1244. "~/.azure/",
  1245. "~/.kube/",
  1246. "~/.docker/",
  1247. "~/.netrc",
  1248. "~/.npmrc",
  1249. "~/.pypirc",
  1250. "~/.git-credentials",
  1251. "~/.emacs.d/ellama-dlp-audit.jsonl",
  1252. ".env",
  1253. ".env.*",
  1254. ".env*.local",
  1255. "*.env",
  1256. "*-credentials.json",
  1257. "*serviceAccount*.json",
  1258. "*service-account*.json",
  1259. "kubeconfig",
  1260. "*-secret.yaml",
  1261. "secrets.yaml",
  1262. "*.pem",
  1263. "*.key",
  1264. "*.p12",
  1265. "*.pfx",
  1266. "*.tfstate",
  1267. "*.tfstate.backup",
  1268. ".terraform/",
  1269. ".vercel/",
  1270. ".netlify/",
  1271. ".supabase/",
  1272. "dump.sql",
  1273. "backup.sql",
  1274. "*.dump"
  1275. ],
  1276. "allowWrite": [
  1277. ".",
  1278. "src/",
  1279. "test/",
  1280. "docs/",
  1281. "/tmp/ellama-agent"
  1282. ],
  1283. "denyWrite": [
  1284. "~/.srt-settings.json",
  1285. "~/.ssh",
  1286. "~/.aws",
  1287. "~/.gnupg/",
  1288. "~/.config/gcloud/",
  1289. "~/.azure/",
  1290. "~/.kube/",
  1291. "~/.docker/",
  1292. "~/.netrc",
  1293. "~/.npmrc",
  1294. "~/.pypirc",
  1295. "~/.git-credentials",
  1296. "~/.emacs.d/ellama-dlp-audit.jsonl",
  1297. ".env",
  1298. ".env.*",
  1299. ".env*.local",
  1300. "*.env",
  1301. "*-credentials.json",
  1302. "*serviceAccount*.json",
  1303. "*service-account*.json",
  1304. "kubeconfig",
  1305. "*-secret.yaml",
  1306. "secrets.yaml",
  1307. "*.pem",
  1308. "*.key",
  1309. "*.p12",
  1310. "*.pfx",
  1311. "*.tfstate",
  1312. "*.tfstate.backup",
  1313. ".terraform/",
  1314. ".vercel/",
  1315. ".netlify/",
  1316. ".supabase/",
  1317. "dump.sql",
  1318. "backup.sql",
  1319. "*.dump",
  1320. "/etc/",
  1321. "/usr/",
  1322. "/bin/",
  1323. "/sbin/",
  1324. "/boot/",
  1325. "/root/",
  1326. "~/.bash_history",
  1327. "~/.zsh_history",
  1328. "~/.node_repl_history",
  1329. "~/.bashrc",
  1330. "~/.zshrc",
  1331. "~/.profile",
  1332. "~/.bash_profile"
  1333. ]
  1334. },
  1335. "ignoreViolations": {
  1336. "npm": [
  1337. "/private/tmp"
  1338. ]
  1339. },
  1340. "enableWeakerNestedSandbox": false,
  1341. "enableWeakerNetworkIsolation": false
  1342. }
  1343. #+END_SRC
  1344. Keep ~allowUnixSockets~ empty unless the agent explicitly needs a local socket.
  1345. For example, adding ~/var/run/docker.sock~ gives the sandbox broad Docker
  1346. control and should be treated as a privileged capability.
  1347. Example Emacs configuration:
  1348. #+BEGIN_SRC emacs-lisp
  1349. (setopt ellama-tools-use-srt t)
  1350. (setopt ellama-tools-srt-args
  1351. '("--settings" "/path/to/.srt-settings.json"))
  1352. #+END_SRC
  1353. Parity tests (real ~srt~ runtime vs local ~ellama~ checks):
  1354. - ~make test-srt-integration~: Run host parity tests (requires ~srt~ installed)
  1355. - ~make test-srt-integration-linux~: Run parity tests in Docker on Linux
  1356. semantics. Requires Docker and runs a privileged container (~--privileged~).
  1357. * Context Management
  1358. Ellama allows you to provide context to the Large Language Model (LLM) to
  1359. improve the relevance and quality of responses. Context serves as background
  1360. information, data, or instructions that guide the LLM's understanding of your
  1361. prompt. Without context, the LLM relies solely on its pre-existing knowledge,
  1362. which may not always be appropriate.
  1363. A “global context” is maintained, which is a collection of text blocks
  1364. accessible to the LLM when responding to prompts. This global context is
  1365. prepended to your prompt before transmission to the LLM. Additionally, Ellama
  1366. supports an "ephemeral context," which is temporary and only available for a
  1367. single request.
  1368. Some commands add context automatically as ephemeral context:
  1369. ~ellama-ask-about~, ~ellama-code-review~, ~ellama-write~, and ~ellama-code-add~.
  1370. ** Transient Menus for Context Management
  1371. Ellama provides a transient menu accessible through the main menu, offering a
  1372. streamlined way to manage context elements. This menu is accessed via the
  1373. “System” branch of the main transient menu, and then selecting "Context
  1374. Commands."
  1375. The Context Commands transient menu is structured as follows:
  1376. Context Commands:
  1377. - Options: Provides options for managing ephemeral context.
  1378. - “-e” "Use Ephemeral Context" ~--ephemeral~
  1379. - Add: Provides options for adding content to the global or ephemeral context.
  1380. - “b” "Add Buffer" ~ellama-transient-add-buffer~
  1381. - “d” "Add Directory" ~ellama-transient-add-directory~
  1382. - “f” "Add File" ~ellama-transient-add-file~
  1383. - “I” "Add Image" ~ellama-transient-add-image~
  1384. - “A” "Add Audio" ~ellama-transient-add-audio~
  1385. - “R” "Record Audio" ~ellama-transient-add-audio-recording~
  1386. - “s” "Add Selection" ~ellama-transient-add-selection~
  1387. - “i” "Add Info Node" ~ellama-transient-add-info-node~
  1388. - Manage: Provides options for managing the global context.
  1389. - “m” "Manage context" ~ellama-context-manage~ - Opens the context
  1390. management buffer.
  1391. - “D” "Delete element" ~ellama-context-element-remove-by-name~ - Deletes an
  1392. element by name.
  1393. - “r” "Context reset" ~ellama-context-reset~ - Clears the entire global
  1394. context.
  1395. - Recording: Provides start and stop commands for long microphone recordings.
  1396. - “S” "Start Recording" ~ellama-transient-start-audio-recording~
  1397. - “E” "Stop Recording" ~ellama-transient-stop-audio-recording~
  1398. - Quit: (“q” "Quit" ~transient-quit-one~) - Closes the context commands
  1399. transient menu.
  1400. ** Managing the Context
  1401. ~ellama-context-manage~ opens a dedicated buffer, the context management buffer,
  1402. where you can view, modify, and organize the global context. Within this buffer:
  1403. + ~n~: Move to the next context element.
  1404. + ~p~: Move to the previous context element.
  1405. + ~q~: Quit the context management buffer.
  1406. + ~g~: Refresh the contents of the context management buffer.
  1407. + ~a~: Add a new context element (similar to ~ellama-context-add-selection~).
  1408. + ~RET~: Preview the content of the context element at the current point.
  1409. ** Considerations
  1410. Keep context size in check. LLMs have finite context windows, and irrelevant
  1411. information wastes tokens and can distract the model. Remove or refresh stale
  1412. context before switching tasks.
  1413. * Minor modes
  1414. These minor modes show the current context or session ID in the header line or
  1415. mode line. Each has a buffer-local command and a global variant.
  1416. ** ellama-context-header-line-mode
  1417. Shows the Ellama context in the header line. By default, the line appears only
  1418. when the global or ephemeral context is not empty. Set
  1419. ~ellama-context-line-always-visible~ to keep it visible.
  1420. ~M-x ellama-context-header-line-mode~ toggles this mode.
  1421. The mode updates the display on ~window-state-change-hook~. When disabled, it
  1422. removes ~(:eval (ellama-context-line))~ from ~header-line-format~.
  1423. ** ellama-context-header-line-global-mode
  1424. Enables ~ellama-context-header-line-mode~ in all buffers automatically.
  1425. ~M-x ellama-context-header-line-global-mode~ toggles this global mode.
  1426. ** ellama-context-mode-line-mode
  1427. Shows the Ellama context in the mode line. It follows the same visibility rules
  1428. as ~ellama-context-header-line-mode~.
  1429. ~M-x ellama-context-mode-line-mode~ toggles this mode.
  1430. The mode updates the display on ~window-state-change-hook~. When disabled, it
  1431. removes ~(:eval (ellama-context-line))~ from ~mode-line-format~.
  1432. ** ellama-context-mode-line-global-mode
  1433. Enables ~ellama-context-mode-line-mode~ in all buffers automatically.
  1434. ~M-x ellama-context-mode-line-global-mode~ toggles this global mode.
  1435. ** ellama-session-header-line-mode
  1436. Displays the current Ellama session ID in the header line.
  1437. ~M-x ellama-session-header-line-mode~ toggles it in the current buffer; ~M-x
  1438. ellama-session-header-line-global-mode~ toggles it globally.
  1439. The session ID uses the customizable ~ellama-face~ face.
  1440. ** ellama-session-mode-line-mode
  1441. Displays the current Ellama session ID in the mode line.
  1442. ~M-x ellama-session-mode-line-mode~ toggles it in the current buffer; ~M-x
  1443. ellama-session-mode-line-global-mode~ toggles it globally. This mode also uses
  1444. ~ellama-face~.
  1445. * Using Blueprints
  1446. Blueprints are predefined templates for starting chat sessions with a reusable
  1447. prompt.
  1448. ** Key Components
  1449. 1. Act: The blueprint's primary identifier (its name).
  1450. 2. Prompt: Text that initializes the chat session, including instructions and
  1451. context.
  1452. 3. For Developers: A flag marking the blueprint as developer-facing.
  1453. ** Creating and Managing
  1454. - ~ellama-blueprint-create~: Create a blueprint from the current buffer.
  1455. Prompts for a name and developer flag, then saves the buffer content as the
  1456. prompt.
  1457. - ~ellama-blueprint-new~: Create a new buffer for a blueprint, optionally
  1458. inserting the current region if active.
  1459. - ~ellama-blueprint-select~: Select a prompt and optionally filter by developer
  1460. status or source (user, community, files, or all sources).
  1461. ** Blueprint Files
  1462. Store blueprints as plain text files. Place them in:
  1463. - Global: ~ellama-blueprint-global-dir~
  1464. - Project-local: ~ellama-blueprint-local-dir~, relative to the project root
  1465. Files use extensions from ~ellama-blueprint-file-extensions~.
  1466. ** Variables
  1467. Blueprints can include variables that must be filled before the session runs.
  1468. - ~ellama-blueprint-fill-variables~: Prompts for values for all variables found
  1469. in the current buffer.
  1470. ** Keymap and Mode
  1471. ~ellama-blueprint-mode~ is a text-mode derivative that highlights variables in
  1472. curly braces and sets up local keybindings:
  1473. - ~C-c C-c~: Open ~ellama-transient-blueprint-mode-menu~. From there you can
  1474. send the buffer to a chat, set it as the system message, create a blueprint,
  1475. or fill variables.
  1476. - ~C-c C-k~: Kill the current buffer.
  1477. ** Transient Menus
  1478. - ~ellama-transient-blueprint-menu~: Chat with a selected blueprint, create a
  1479. new blueprint, or manage saved blueprints.
  1480. - ~ellama-transient-blueprint-mode-menu~: Act on the blueprint in the current
  1481. buffer.
  1482. - ~ellama-transient-main-menu~: Integrates the blueprint menu into the main
  1483. interface.
  1484. ** Running Blueprints Programmatically
  1485. ~ellama-blueprint-run~ starts a chat session with a blueprint, pre-filling
  1486. variables from the provided arguments.
  1487. #+BEGIN_SRC emacs-lisp
  1488. (defun my-chat-with-morpheus ()
  1489. "Start chat with Morpheus."
  1490. (interactive)
  1491. (ellama-blueprint-run "Character" '(:character "Morpheus" :series "Matrix")))
  1492. (global-set-key (kbd "C-c e M") #'my-chat-with-morpheus)
  1493. #+END_SRC
  1494. * MCP Integration
  1495. Use MCP (Model Context Protocol) tools with ~ellama~. Requires Emacs 30+ and the
  1496. ~mcp.el~ package: https://github.com/lizqwerscott/mcp.el
  1497. Example: adding DuckDuckGo search via the duckduckgo-mcp-server
  1498. (https://github.com/nickclyde/duckduckgo-mcp-server):
  1499. #+begin_src emacs-lisp
  1500. (use-package mcp
  1501. :ensure t
  1502. :demand t
  1503. :custom
  1504. (mcp-hub-servers
  1505. `(("ddg" . (:command "uvx"
  1506. :args
  1507. ("duckduckgo-mcp-server")))))
  1508. :config
  1509. (require 'mcp-hub)
  1510. (mcp-hub-start-all-server
  1511. (lambda ()
  1512. (let ((tools (mcp-hub-get-all-tool :asyncp t :categoryp t)))
  1513. (mapcar #'(lambda (tool)
  1514. (apply #'ellama-tools-define-tool
  1515. (list tool)))
  1516. tools)))))
  1517. #+end_src
  1518. Remote MCP servers work the same way through a ~:url~ entry, so a hosted
  1519. server needs no local process. For example, adding You.com's hosted search
  1520. alongside the DuckDuckGo server above:
  1521. #+begin_src emacs-lisp
  1522. (setq mcp-hub-servers
  1523. `(("ddg" . (:command "uvx"
  1524. :args ("duckduckgo-mcp-server")))
  1525. ("you" . (:url "https://api.you.com/mcp?profile=free"))))
  1526. #+end_src
  1527. The free profile covers web search without an API key, with a limit of 100
  1528. queries per day; the authenticated endpoint, https://api.you.com/mcp, follows
  1529. the same pattern and adds content extraction and research tools.
  1530. When ~:categoryp t~ is used, Ellama derives a stable MCP tool identity as
  1531. ~<category>/<tool-name>~ (e.g., ~mcp-ddg/search~). Irreversible policy, audit,
  1532. and overrides are keyed by this identity.
  1533. * Agent Skills
  1534. Agent Skills provide instructions and supporting files for specific tasks.
  1535. Ellama adds only skill metadata to the initial context; the model reads the full
  1536. instructions when it chooses a skill.
  1537. ** Directory Structure
  1538. Ellama searches for skills in two locations:
  1539. 1. *Global*: =~/.emacs.d/ellama/skills/= by default, customizable via
  1540. ~ellama-skills-global-path~.
  1541. 2. *Project-local*: ~skills/~ inside the project root, customizable via
  1542. ~ellama-skills-local-path~.
  1543. A skill is a directory containing a ~SKILL.md~ file with metadata (~name~,
  1544. ~description~) and instructions for the agent. Skills can also include scripts,
  1545. templates, and reference materials.
  1546. #+begin_src
  1547. my-project/
  1548. └──skills/
  1549. └── pdf-processing/
  1550. ├── SKILL.md # Required: instructions + metadata
  1551. ├── scripts/ # Optional: executable code
  1552. ├── references/ # Optional: documentation
  1553. └── assets/ # Optional: templates, resources
  1554. #+end_src
  1555. ** Creating a Skill
  1556. The ~SKILL.md~ file must include YAML frontmatter:
  1557. #+begin_src markdown
  1558. ---
  1559. name: pdf-processing
  1560. description: Extract text from PDFs and summarize them.
  1561. ---
  1562. # PDF Processing Instructions
  1563. To extract text from a PDF...
  1564. #+end_src
  1565. ** How It Works
  1566. - *Auto-Discovery*: Ellama scans skill directories when each chat starts.
  1567. - *Context*: Skill metadata (name, description, location) is injected into the
  1568. system prompt.
  1569. - *Activation*: The LLM loads ~SKILL.md~ content via ~read_file~ when needed.
  1570. * Acknowledgments
  1571. Thanks to [[https://github.com/jmorganca][Jeffrey Morgan]] for
  1572. [[https://github.com/jmorganca/ollama][ollama]], which made this project
  1573. possible.
  1574. Thanks [[https://github.com/zweifisch][zweifisch]] for ideas from
  1575. [[https://github.com/zweifisch/ollama][ollama.el]] about what an Emacs ollama
  1576. client can do.
  1577. Thanks [[https://github.com/David-Kunz][Dr. David A. Kunz]] for ideas from
  1578. [[https://github.com/David-Kunz/gen.nvim][gen.nvim]].
  1579. Thanks [[https://github.com/ahyatt][Andrew Hyatt]] for the ~llm~ library,
  1580. without which only ~ollama~ would be supported.
  1581. * Contributions
  1582. Submit a pull request or report a bug. This library is part of GNU ELPA; major
  1583. contributions require FSF papers. Alternatively, write a module for MELPA.
  1584. Run ~make check-elisp~ before pushing Elisp changes. It formats Elisp files,
  1585. byte-compiles, runs the ERT suite, native-compiles, and runs checkdoc. Byte and
  1586. native compilation warnings are treated as failures.
  1587. * GNU Free Documentation License
  1588. :PROPERTIES:
  1589. :APPENDIX: t
  1590. :END:
  1591. #+texinfo: @include doclicense.texi
  1592. #+begin_export html
  1593. <pre>
  1594. GNU Free Documentation License
  1595. Version 1.3, 3 November 2008
  1596. Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
  1597. <https://fsf.org/>
  1598. Everyone is permitted to copy and distribute verbatim copies
  1599. of this license document, but changing it is not allowed.
  1600. 0. PREAMBLE
  1601. The purpose of this License is to make a manual, textbook, or other
  1602. functional and useful document "free" in the sense of freedom: to
  1603. assure everyone the effective freedom to copy and redistribute it,
  1604. with or without modifying it, either commercially or noncommercially.
  1605. Secondarily, this License preserves for the author and publisher a way
  1606. to get credit for their work, while not being considered responsible
  1607. for modifications made by others.
  1608. This License is a kind of "copyleft", which means that derivative
  1609. works of the document must themselves be free in the same sense. It
  1610. complements the GNU General Public License, which is a copyleft
  1611. license designed for free software.
  1612. We have designed this License in order to use it for manuals for free
  1613. software, because free software needs free documentation: a free
  1614. program should come with manuals providing the same freedoms that the
  1615. software does. But this License is not limited to software manuals;
  1616. it can be used for any textual work, regardless of subject matter or
  1617. whether it is published as a printed book. We recommend this License
  1618. principally for works whose purpose is instruction or reference.
  1619. 1. APPLICABILITY AND DEFINITIONS
  1620. This License applies to any manual or other work, in any medium, that
  1621. contains a notice placed by the copyright holder saying it can be
  1622. distributed under the terms of this License. Such a notice grants a
  1623. world-wide, royalty-free license, unlimited in duration, to use that
  1624. work under the conditions stated herein. The "Document", below,
  1625. refers to any such manual or work. Any member of the public is a
  1626. licensee, and is addressed as "you". You accept the license if you
  1627. copy, modify or distribute the work in a way requiring permission
  1628. under copyright law.
  1629. A "Modified Version" of the Document means any work containing the
  1630. Document or a portion of it, either copied verbatim, or with
  1631. modifications and/or translated into another language.
  1632. A "Secondary Section" is a named appendix or a front-matter section of
  1633. the Document that deals exclusively with the relationship of the
  1634. publishers or authors of the Document to the Document's overall
  1635. subject (or to related matters) and contains nothing that could fall
  1636. directly within that overall subject. (Thus, if the Document is in
  1637. part a textbook of mathematics, a Secondary Section may not explain
  1638. any mathematics.) The relationship could be a matter of historical
  1639. connection with the subject or with related matters, or of legal,
  1640. commercial, philosophical, ethical or political position regarding
  1641. them.
  1642. The "Invariant Sections" are certain Secondary Sections whose titles
  1643. are designated, as being those of Invariant Sections, in the notice
  1644. that says that the Document is released under this License. If a
  1645. section does not fit the above definition of Secondary then it is not
  1646. allowed to be designated as Invariant. The Document may contain zero
  1647. Invariant Sections. If the Document does not identify any Invariant
  1648. Sections then there are none.
  1649. The "Cover Texts" are certain short passages of text that are listed,
  1650. as Front-Cover Texts or Back-Cover Texts, in the notice that says that
  1651. the Document is released under this License. A Front-Cover Text may
  1652. be at most 5 words, and a Back-Cover Text may be at most 25 words.
  1653. A "Transparent" copy of the Document means a machine-readable copy,
  1654. represented in a format whose specification is available to the
  1655. general public, that is suitable for revising the document
  1656. straightforwardly with generic text editors or (for images composed of

Lines 2,001–2,375 are not shown. The link to the file on GitHub has every line.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.