From a7c51e28715976b26ad8e41f8f3a6a7998027020 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Fri, 23 May 2025 23:43:47 -0700 Subject: [PATCH] Don't execute fragments/attachments in !edit sessions, closes #1074 --- docs/fragments.md | 2 +- llm/cli.py | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/fragments.md b/docs/fragments.md index 3128db9..99584f4 100644 --- a/docs/fragments.md +++ b/docs/fragments.md @@ -73,7 +73,7 @@ Explain the difference between fragments and templates to me !end ``` -Additionally, any `!fragment` lines found in a prompt created with `!edit` will also be parsed. +Any `!fragment` lines found in a prompt created with `!edit` will not be parsed. (fragments-browsing)= ## Browsing fragments diff --git a/llm/cli.py b/llm/cli.py index 82f57e0..d840449 100644 --- a/llm/cli.py +++ b/llm/cli.py @@ -1156,11 +1156,7 @@ def chat( if edited_prompt is None: click.echo("Editor closed without saving.", err=True) continue - prompt, fragments, attachments = process_fragments_in_chat( - db, edited_prompt.strip() - ) - if not prompt and not fragments and not attachments: - continue + prompt = edited_prompt.strip() if prompt.strip().startswith("!fragment "): prompt, fragments, attachments = process_fragments_in_chat(db, prompt)