Render local LLM output directly inside notes using an agent Markdown code block.
- Runs automatically when the note is rendered.
- Reusable agent templates with provider-specific configuration.
- Multiple providers:
- Codex CLI
- Ollama (local)
- Loading state and one-click refresh per block.
- Stop button on running blocks and running execution log entries.
- Execution log in settings with:
- timestamp
- origin note
- provider/template
- duration
- full prompt
- full response
- command line args
- streamed stdout/stderr output
- in-flight status
- Prompt cache with configurable max size (default: 1000 entries).
- Standardized prompt wrapper with Obsidian context:
- vault root path
- current file path
- current note content
- optionally selected linked note content
- Template-configurable context sources (currently linked note content).
- Per-block context source overrides (enable/disable, sizing, filtering, and sorting).
- Global instructions applied to every run.
- Per-block provider overrides (for example model, reasoning, temperature, timeout, mcp, local provider).
- Template and per-block cache mode:
auto-refresh(default)prefer-cache(uses last cached result for that block until manual refresh)
- Desktop Obsidian (
isDesktopOnly: true). - For Codex templates: local
codexCLI installed. - For Ollama templates: local Ollama server and a pulled model.
```agent
Summarize this note into 5 action items.
```linked_content_sort_by supports:
modified-date(default)created-datefrontmatter-date
linked_content_sort_direction supports:
descending(default)ascending
```agent
template: weekly-summary
Focus on blockers and decisions.
``````agent
template: codex-default
model: gpt-5-mini
reasoning: low
mcp: false
timeout: 120
oss: true
local_provider: ollama
Summarize only unresolved items.
``````agent
template: local-ollama
model: llama3.2
temperature: 0.1
num_predict: 700
host: http://127.0.0.1:11434
Summarize this file.
``````agent
template: fast-summary
linked_content: true
linked_content_max_notes: 6
linked_content_max_chars: 1500
linked_content_sort_by: frontmatter-date
linked_content_sort_direction: descending
linked_content_sort_frontmatter_date_field: review_date
linked_content_include_outgoing: true
linked_content_include_backlinks: false
linked_content_filter_required_frontmatter_field: review_date
Summarize this note and key linked context.
``````agent
template: deep-analysis
cache_mode: prefer-cache
Run a thorough analysis using linked context.
```When cache_mode: prefer-cache is active, prompt changes do not auto-run. The block reuses the last cached result for that block and marks it as stale until you click refresh.
For Codex templates, you can enable:
Use local OSS provider(adds--oss)Local provider(adds--local-provider, e.g.ollama,lmstudio,ollama-chat)
This lets Codex route to a local provider while keeping Codex prompt/tooling behavior.
This project is split into layers so behavior is easier to change safely.
src/main.ts- Plugin entrypoint and composition root.
- Wires services and registers the
agentcode block processor.
src/domain/- Shared domain model and rules.
types.ts: canonical plugin types.defaults.ts: default config values and template factory helpers.normalizers.ts: clamping/normalization logic used across layers.template-utils.ts: template conversion/duplication helpers.
src/core/- Application services and stateful orchestration.
settings-normalization.ts: load and normalize persisted settings.agent-runner.ts: provider execution + cancellation lifecycle.execution-log-service.ts: execution log lifecycle and streamed output formatting.prompt-cache.ts: prompt cache pruning policies.process-output.ts: stdout/stderr stream formatting and truncation.
src/agent-block/- Runtime pipeline for
```agentblocks rendered in notes. directives.ts: parse top-of-block directives and produce an execution request.context.ts: gather note/link context.prompt.ts: build standardized wrapped prompt.cache.ts: deterministic cache keys.render.ts: render model response/error into the block.dependencies.ts: runtime contract expected from plugin services.safe-dependencies.ts: wrappers for non-critical dependency calls that should not break rendering.
- Runtime pipeline for
src/ui/- Settings UI code.
ui/settings/agent-setting-tab.ts: settings tab composition and controls.ui/settings/execution-log.ts: execution log display widgets.
src/providers/- Provider adapters (
codex-provider.ts,ollama-provider.ts) and provider interface (types.ts).
- Provider adapters (
Keep imports flowing in this direction:
ui,agent-block,core, andproviderscan import fromdomain.main.tscan import from every layer (composition root).domainshould not import fromui,core, oragent-block.providersshould not import settings UI modules.uishould not own business rules; it should call shared domain/core helpers.
- Obsidian renders an
agentcode block and callsregisterAgentCodeBlockProcessor. agent-block/directives.tsparses directives and resolves template + overrides.agent-block/context.tsgathers current note + linked note context.agent-block/prompt.tsbuilds standardized prompt text.agent-block/cache.tscomputes cache keys and checks cached responses.core/agent-runner.tsexecutes the selected provider (providers/*).core/execution-log-service.tsrecords invocation/output lifecycle.agent-block/render.tsrenders final markdown response (or error) into the note.
- Add or change shared data shape/rules in
domain. - Add orchestration/stateful process logic in
core. - Add note-render runtime behavior in
agent-block. - Add settings UX only in
ui. - Keep
main.tssmall and focused on wiring.
npm install
npm run devBuild:
npm run build