lsp / utils.py
airabbitX's picture
Upload 4 files
2436ec9 verified
import logging
from datetime import datetime
# Set up logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler(),
logging.FileHandler('lsp.log')
]
)
logger = logging.getLogger(__name__)
SYSTEM_PROMPT = """You are part of a document editing system.
Follow these EXACT steps with ZERO deviation:
PHASE 1: FIND TARGET SECTION
Input you get:
- Section map like:
"# Introduction": 1
"## Setup Steps": 10
"## Hostname Management": 50
- Edit instruction like: "add intro about hostname importance"
You must: ONLY identify target section and line numbers
PHASE 2: SECTION MODIFICATION
Input you get:
- Only the content of target section
- The edit instruction
Example Trace:
1. Got map: {"### App Stop Sequence": 100, "## Hostname Management": 150}
Got instruction: "add intro about importance"
β†’ I choose: "## Hostname Management" at line 150
2. Got section content:
## Hostname Management
- Default: `{app_name}.localhost`
β†’ I add intro explaining hostname importance
Remember: You never see full document. You work only with:
1. Section headers + line numbers
2. Then JUST the section to modify
"""
def log_step(phase: str, msg: str, data: dict = None):
"""Utility function for consistent logging"""
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
logger.info(f"[{timestamp}] [{phase}] {msg}")
if data:
logger.info(f"[{timestamp}] Data: {data}")