Open meain opened 1 month ago
Just going off of the demo screencast on that repo, it looks like a cool idea! I think being able to support use-cases like this would be worth it, especially if it can be done without adding a hardcoded command to the plug itself.
As SB has no way to do "get me the task that the cursor is on", if there is some way this plug can provide "work on the currently selected text", we could probably do something like this.
Silverbullet does havedetermineItemBounds
to get the start/end position of a task, I'm using it like this in a spacescript:
const cursorPos = await syscall("editor.getCursor");
const text = await syscall("editor.getText");
const currentItemBounds = await syscall("system.invokeFunction", "editor.determineItemBounds", text, cursorPos, undefined, true);
const currentItemText = text.slice(currentItemBounds.from, currentItemBounds.to);
Thinking about it, this is almost already possible. Templated Prompts support aiPrompt.insertAt: cursor
to have the result inserted at the current cursor location. There are two things we'd need:
end-of-line
or next-line
etc for insertAt
<USER_CURSOR_POS>
to indicate where the cursor isNone of the "editor" syscalls seem to be available to Space Script. I also get an error when I use in a space script. Am I missing something?
iirc not all of the syscalls show up on the documentation page, there's a discussion about it on https://github.com/silverbulletmd/silverbullet/issues/839 and the linked issue.
I also forgot to mention that editor.determineItemBounds
was only recently exposed, I think in 0.9.0. And it's only exposed using the system.invokeFunction
syscall, not as a syscall itself.
Full syscall docs are now here: https://jsr.io/@silverbulletmd/silverbullet/doc/syscalls/~
@meain
I just merged #68 into main. It should support use cases like the one you linked to. I also added a 'AI Split Todo' template prompt to test with and see how it works.
When you get a chance, could you give it a try and see if you have any feedback?
(note to self: I still need to add support for replacing a whole paragraph or selected text, but there is a 'replace-line' option now)
It is possible that I might end up having to build out a separate plugin, but just wondering if it would be possible/worth it to support these use-cases in this PLUG.
I was trying to replicate what b-yp/logseq-magic-todo does but I don't think we currently have a way target to anything specific(
task
under cursor) like in this case in this case. In case of LogSeq, since it works on a block level, there is option to get the current block which would be analogous to getting a task.As SB has no way to do "get me the task that the cursor is on", if there is some way this plug can provide "work on the currently selected text", we could probably do something like this.
PS: I'm just exploring possibilities, not in any rush to have this feature :D