obsidian-copilot icon indicating copy to clipboard operation
obsidian-copilot copied to clipboard

[PLUS] Copilot Composer

Open logancyang opened this issue 10 months ago • 6 comments

Feature Description

Easily suggest and apply edits to your notes with a single click:

  • [x] Multi-note support: Suggest edits for multiple notes at once.
  • [x] Seamless integration: Works smoothly with existing tools (@vault, @web, @youtube, etc.).
  • [x] Flexible triggering: Supports both automatic suggestions and explicit activation via @composer.
  • [x] Canvas editing: Suggest and apply edits directly within canvas notes.

Example Queries

  • Add content: Add a tl;dr to the beginning of [[example_note]]
  • Remove content: Remove the part related to topic X from [[example_note]]
  • Change tone: Change the tone of [[example_note]] to be more friendly
  • Edit multiple notes: Simplify the writing in both [[example_note_1]] and [[example_note_2]]
  • Web search integration: Update [[investment plan]] based on the current stock market prediction @web
  • Vault search integration: Summarize topic X from my vault into a new note @vault

Implementation

  1. Add a system prompt to output updated note content in a dedicated code block format.
  2. Render the composer code block with an Apply button, showing only relevant changes instead of the full note.
  3. When Apply is clicked, display a diff view so users can accept or reject changes.
  4. Write accepted changes to disk.

Future Improvements

  • Currently, the model always outputs the full note content. In the future, it should output only the changed sections for minor edits, especially in large notes.

Some relevant use cases proposed by copilot users

Single note rewriting with structured format

The primary use case emerges when starting work on an idea. The process involves online research, LLM conversations, and documenting thoughts. Information is typically documented in bullet points, including images and links discovered during research. Once the data is gathered and processed, Composer helps rewrite it in a structured format. The content undergoes continuous refinement until it meets the standards of a sapling note.

Generate YAML properties

Composer assists in populating various YAML fields and tags based on values already present in the vault. Cursorrules contains template information for different types of notes and permissible YAML field values. Using this information, Composer suggests appropriate YAML for the current note under development.

Recommend best place to put the note

The tool also recommends suitable folders within the vault structure for filing the note.

Auto linking

Interlinking often gets overlooked, but Composer helps identify similar ideas in the vault and adjusts the current note's content to enable linking to those notes. It also analyzes whether other notes can or should link back to the current note, making relevant edits accordingly.

In cases where manual research and external webpage linking seems tedious (such as when writing about Dataview and needing links to its documentation), Cursor's composer (using Perplexity's API) automatically discovers URLs and incorporates them in appropriate locations. This applies to multiple concepts within a single note.

logancyang avatar Jan 28 '25 18:01 logancyang

Created this master task to curate ideas, feel free to add more ideas to guide our design later. cc @zeroliu @Emt-lin @wenzhengjiang

logancyang avatar Jan 28 '25 22:01 logancyang

I posted this in Discord, but it might be more useful here. It's a simplified use case, but it feels very related to this idea. It's not the same, but feels very overlapping. From how I understand Composer it might reformat a note, I was looking at creating a new note from a source note. Both approaches would need some sort of context gathering, importing of frontmatter structure, tone of voice etc..


I just tried to update a bit of my content creation workflow. I set it up and almost finished it last summer using a combination of custom scripts and SmartConnections prompts, but it's been sitting there unused, since I got sidetracked with work and uni.

Basically, I'm trying to create social media content drafts for my side projects from my voice notes. The prompts I created last year included things like context, brand voice, etc based on tags on the voice note. (e.g. tag #brandA on the voice note pulls in tone of voice and brand descriptions for that brand). That needs some sort of customised, on-the-fly prompt.

I tried to think about how to achieve that with Copilot. I'd like to limit complex scripts that can break. I was thinking something like:

  • open source note (voice note) in editor
  • trigger custom copilot prompt on active note, maybe read {selection} to steer the prompt/focus on a part -(somehow find brand voice prompt "fragment" and insert it into prompt - essentially add context by searching for tagged files)
  • submit prompt that reads source note and tone of voice etc and drafts a content piece for social media (somehow save to a note and move to correct folder)

Are there any ways current or planned, to interact with copilot maybe:

  • via obsidian scripts (JS) or
  • by 'expanding/running dataview queries' before running a custom prompt
  • anything I haven't thought of yet?

As a workaround I might simply make static custom prompts for each "brand voice" and manually compose the prompts with several custom prompts. But I was thinking I can't be the only one thinking about on-the-fly prompt generation and automation. Maybe someone had sucess already? Or I missed part of the docs?

jonashaefele avatar Feb 28 '25 12:02 jonashaefele

@wenzhengjiang could you comment here, I'll assign this to you

logancyang avatar Mar 04 '25 18:03 logancyang

Hi @jonashaefele Copilot Composer will not only update existing notes but can also create new notes in the future. You should be able to try it out pretty soon.

I tried to think about how to achieve that with Copilot. I'd like to limit complex scripts that can break. I was thinking something like:

  • open source note (voice note) in editor
  • trigger custom copilot prompt on active note, maybe read {selection} to steer the prompt/focus on a part -(somehow find brand voice prompt "fragment" and insert it into prompt - essentially add context by searching for tagged files)
  • submit prompt that reads source note and tone of voice etc and drafts a content piece for social media (somehow save to a note and move to correct folder)

Composer will definitely help you achieve the last step - saving the generated content to a new note in the right folder (it will figure out the proper folder based on your file tree).

I want to understand better how you want to fetch the right context, if your context can be created with selected text and notes with certain tags, copilot today can also do that for you. For example, you can send a query like "Create a new social media post using {} as tone and using brand voice in {#tag1, #tag2}" in copilot. Will this work for you? If not, what kind of user query you would like copilot to support?

wenzhengjiang avatar Mar 05 '25 00:03 wenzhengjiang

@wenzhengjiang yes indeed. The above workflow I outlines was an approximation or one way of doing it. Obviously the more can be done in one step the better. Something like you mentioned would be even nicer:

You're a social media specialist. Your job is to read [[source note/rough idea]] write a social media post following the [[platform guidelines]]. Use {#tag1} for more information on the brand identity and {#tag2, #tag3} for brand voice.

  • [[source note]] is a note with inspiration. that could be a voice note, a long-form blog post, etc...
  • [[platform guidelines]] contains information about how to format the post (e.g. title max 50 chars, subtitle max 100 chars for image, caption (max 200 chars)...) -{#tag 1}, {#tag2, #tag3} are fragments of the brand guidelines

even more exciting would be if we could use {active_selection} to add a focus. Say [[source note]] is a long blog post and I selected a sentence from it before calling composer with the following prompt:

You're a social media specialist. Your job is to read [[source note/rough idea]] write a social media post for following the [[platform guidelines]]. Use {#tag1} for more information on the brand identity and {#tag2, #tag3} for brand voice. Make sure to focus the post around the key point: {active_selection}.

The problem with current copilot is that any information passed in curly braces like {#tag1} doesn't persist past the first message in the chat. And {active selection} seems to not work at all for me. Somehow [[]] and {} context behaves very differently.


Potentially unrelated, but could be useful:

What would be even cooler is if I could dynamically create the {#tags} used in the prompt based on YAML frontmatter of the [[source note]], e.g. [[sourcenote]].frontmatter.brandname is brandOne --> tags inserted into the prompt are {#brandvoice/brandOne} etc. That said, we can just create separate prompt templates (one for each brand in this example).

And I assume there will be some sort of API to guide composer how to link and where to store the newly made notes. Like When finished, add relevant links to other notes in YAML propety "x", and save the new note in "/Path/To/{brandname}/drafts"

jonashaefele avatar Mar 11 '25 10:03 jonashaefele

The problem with current copilot is that any information passed in curly braces like {#tag1} doesn't persist past the first message in the chat. And {active selection} seems to not work at all for me. Somehow [[]] and {} context behaves very differently.

@jonashaefele If you use custom prompt, you can use {} to capture the selected text?

Regarding to persisting {#tag} context, you can take a look at the coming "Project" feature https://github.com/logancyang/obsidian-copilot/issues/459. The context you added to a project will always be present.

wenzhengjiang avatar Mar 15 '25 06:03 wenzhengjiang