Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of Changes
✂️ Markdown Chunking Utility Added: Introduced a new
chunkMarkdown
function to split markdown files into manageable chunks without breaking the heading structure. This supports efficient token-based chunking for large markdown files.🧪 Comprehensive Test Coverage: Added a robust test suite (
mdchunk.test.ts
) to validate thechunkMarkdown
functionality, including edge cases like empty markdown, nested headings, large sections, and backtracking logic.🚀 Global Utility Enhancement: Extended the
installGlobals
method to include thechunk
method under the globalMD
interface, enabling markdown chunking with optional parameters likemaxTokens
andmodel
.📄 New Sample Script: Added a sample script (
mdchunk.genai.mjs
) demonstrating the usage of thechunk
method to process markdown files with token limits.🛠️ Integration with File and Token Utilities: Incorporated
resolveFileContent
andresolveTokenEncoder
to handle file content resolution and token encoding seamlessly during markdown chunking.📝 Type Definition Update: Updated the
MD
interface inprompt_template.d.ts
to include the newchunk
method, ensuring proper type support for markdown chunking.These changes enhance the system's ability to handle large markdown files efficiently while maintaining structural integrity, improving both flexibility and usability.