solvekit

Toolkit for extending solveit dialogs with custom toolbar buttons and dialog operations

Usage

Installation

Install latest from pypi:

$ pip install solvekit

Documentation

Documentation can be found hosted on this GitHub repositoryโ€™s pages. Additionally you can find package manager specific guidelines on pypi respectively.

How to use

from solvekit import *

Add a toolbar button by calling add_btn with a name, icon, code snippet, and tooltip. Hereโ€™s the simplest case โ€” a single-line Python snippet:

add_btn('dice', 'ii:lucide:dice-5', 'import random; dice_num = random.randint(1,6); print(f"๐ŸŽฒ You rolled a {dice_num}!")', 'Roll a dice!', lang='py')

For longer scripts, use a triple-quoted string. This button picks a random answer and displays it with a short delay:

add_btn('magic8', '๐Ÿ”ฎ', '''
import random
import time
answers = ["It is certain! ๐ŸŽ‰","Ask again later ๐Ÿค”","Don't count on it ๐Ÿ˜ฌ","Absolutely! โœจ","Try again tomorrow ๐Ÿ˜ด","Without a doubt! ๐Ÿš€"]
print(f"๐Ÿ”ฎ {random.choice(answers)}")
time.sleep(5)
''', 'Ask the Magic 8-Ball', lang='py')

Buttons can also trigger AI prompts. This one asks the assistant to clean up the code cell above the current cursor position:

add_btn('cleanup', 'ii:lucide:wand-sparkles', '''
await add_msg(content="""Please clean up the code above:

1. **Fastcore docs format**: Add docstrings and a comment after each parameter (each param on its own line)
2. **General cleanup**: Improve naming, simplify logic, remove duplication

Keep the overall structure and behavior the same.""",
msg_type='prompt', run=True)
''', 'Clean up code above', lang='py')

The same pattern works for any reusable prompt โ€” hereโ€™s one that polishes prose and formatting:

add_btn('optimize', 'ii:lucide:pencil-line', '''
await add_msg(content="""Please optimize the cell input above:

1. **Clarity**: Make the content clearer and more concise
2. **Structure**: Improve formatting and organization
3. **Grammar & Style**: Fix any grammar issues and improve readability

Keep the original intent and meaning the same.""",
msg_type='prompt', run=True)
''', 'Optimize cell input above', lang='py')

## Next steps

add_btn gives you a single toolbar button โ€” useful, but real workflows need more. Hereโ€™s where solvekit is headed:

Dropdown menus. A single toolbar icon that expands into a list of actions, perfect for storing frequently-used prompts.

Token usage bar. A live progress bar showing context window consumption for the current session.

JS helper library. Clean wrappers around solveit internals โ€” solvekit.run_msg(), solvekit.upsert_msg() โ€” so custom buttons are readable and concise, no guessing at private APIs.