Append content to an existing chapter.
(
title: Annotated[str, ParamMeta(description="Chapter title to append to (supports multi-level index e.g. 'Intro/Background')")],
content: Annotated[str, ParamMeta(description="Content to append")],
_context: Dict[str, Any] | None = None,
)
| 419 | |
| 420 | |
| 421 | def report_continue_chapter( |
| 422 | title: Annotated[str, ParamMeta(description="Chapter title to append to (supports multi-level index e.g. 'Intro/Background')")], |
| 423 | content: Annotated[str, ParamMeta(description="Content to append")], |
| 424 | _context: Dict[str, Any] | None = None, |
| 425 | ) -> str: |
| 426 | """ |
| 427 | Append content to an existing chapter. |
| 428 | """ |
| 429 | ctx = FileToolContext(_context) |
| 430 | _, report_file = _get_files(ctx) |
| 431 | _, report_lock = _get_locks(ctx) |
| 432 | |
| 433 | with FileLock(report_lock): |
| 434 | lines = _read_report_lines(report_file) |
| 435 | |
| 436 | start, end = _find_chapter_range(lines, title) |
| 437 | if start == -1: |
| 438 | return f"Chapter '{title}' not found." |
| 439 | |
| 440 | # Append content before 'end' (which is the start of next section or end of file) |
| 441 | new_lines = content.splitlines() + [""] |
| 442 | lines[end:end] = new_lines |
| 443 | |
| 444 | _save_report(report_file, lines) |
| 445 | return f"Appended content to chapter '{title}'" |
| 446 | |
| 447 | |
| 448 | def report_reorder_chapters( |
nothing calls this directly
no test coverage detected