Add BLIGHT:: document-scope triggers and case-insensitive matching
- Split TRIGGER_PATTERN into INLINE_PATTERN (BLIGHT:) and DOCUMENT_PATTERN (BLIGHT::), both case-insensitive - Inline triggers replace only the trigger line (existing behaviour) - Document-scope triggers replace the entire file; multiple BLIGHT:: triggers in one file are processed sequentially, each seeing the previous result - Updated FAILED_TEMPLATE to two-line format with BLIGHT_FAILED and BLIGHT_ERROR - Added complete_document() to AIProvider ABC and GeminiProvider with a dedicated system prompt instructing the model to return the full document Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
19
ai/base.py
19
ai/base.py
@@ -4,13 +4,14 @@ from abc import ABC, abstractmethod
|
||||
class AIProvider(ABC):
|
||||
"""Base class for all AI provider implementations.
|
||||
|
||||
To add a new provider, subclass this and implement `complete`, then
|
||||
instantiate your provider in `processor.py` instead of GeminiProvider.
|
||||
To add a new provider, subclass this and implement `complete` and
|
||||
`complete_document`, then instantiate your provider in `processor.py`
|
||||
instead of GeminiProvider.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def complete(self, document: str, instruction: str) -> str:
|
||||
"""Process an instruction in the context of a full document.
|
||||
"""Process an inline instruction in the context of a full document.
|
||||
|
||||
Args:
|
||||
document: The full markdown document text (for context).
|
||||
@@ -19,3 +20,15 @@ class AIProvider(ABC):
|
||||
Returns:
|
||||
The text to insert in place of the trigger line.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def complete_document(self, document: str, instruction: str) -> str:
|
||||
"""Apply a document-scope instruction and return the full rewritten document.
|
||||
|
||||
Args:
|
||||
document: The full markdown document text.
|
||||
instruction: The BLIGHT:: instruction extracted from the trigger line.
|
||||
|
||||
Returns:
|
||||
The full rewritten document as a string.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user