vibe.assistant.services.draft_manager¶
DraftManager - manages draft block storage and rendering.
Responsibilities: - Block ID generation - Block storage and retrieval - Draft content rendering with semantic IDs - In-memory block accumulation during streaming - Content splitting into blocks
DraftManager ¶
Manages draft blocks for the assistant.
This class consolidates: - _get_next_block_id_direct - _add_block_to_state_direct - _finalize_block_content_direct - get_current_draft - _split_content_into_blocks - _find_block_uuid_by_semantic_id - _add_or_update_block
__init__ ¶
__init__(assistant_name: str, state_getter: Callable[[], dict[str, Any]], state_updater: Callable[[dict[str, Any]], None]) -> None
Initialize the draft manager.
| Parameters: |
|
|---|
get_current_draft ¶
get_current_draft() -> str
Get the current draft content from blocks.
| Returns: |
|
|---|
get_next_block_id ¶
get_next_block_id() -> str
Get next block ID and increment counter.
| Returns: |
|
|---|
find_block_uuid_by_semantic_id ¶
find_block_uuid_by_semantic_id(semantic_id: str) -> str | None
Find block UUID by semantic ID (llm_id).
| Parameters: |
|
|---|
| Returns: |
|
|---|
add_block ¶
add_block(semantic_id: str, content: str = '') -> str
Add a new block with the given semantic ID.
| Parameters: |
|
|---|
| Returns: |
|
|---|
add_or_update_block ¶
add_or_update_block(semantic_id: str, content: str = '') -> str
Add or update a block with the given semantic ID.
| Parameters: |
|
|---|
| Returns: |
|
|---|
finalize_block_content ¶
finalize_block_content(block_id: str, content: str) -> None
Finalize a block by replacing its entire content.
| Parameters: |
|
|---|
add_block_to_state ¶
add_block_to_state(block_id: str, target: str) -> None
Add a new block to the draft state.
| Parameters: |
|
|---|
split_content_into_blocks ¶
split_content_into_blocks(content: str) -> list[str]
Split content into logical blocks based on markdown structure.
| Parameters: |
|
|---|
| Returns: |
|
|---|
start_in_memory_block ¶
start_in_memory_block(block_id: str) -> None
Start accumulating content for an in-memory block.
| Parameters: |
|
|---|
append_to_in_memory_block ¶
append_to_in_memory_block(block_id: str, content: str) -> None
Append content to an in-memory block.
| Parameters: |
|
|---|
flush_in_memory_blocks ¶
flush_in_memory_blocks() -> None
Flush all in-memory blocks to persistent state.
Updates existing blocks or creates new ones as needed.