Skip to content

Commit 7e60a50

Browse files
committed
readme
1 parent cff6c55 commit 7e60a50

3 files changed

Lines changed: 126 additions & 79 deletions

File tree

CLAUDE.md

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,26 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## Project Overview
66

7-
This is a TypeScript library that provides an AST-based Markdown text splitter with section-aware chunking capabilities. The splitter intelligently breaks markdown text into chunks using a hierarchical approach while preserving markdown formatting and semantic relationships between content (e.g., keeping headings with their related content when possible).
7+
This is a TypeScript library called "chunkdown" that provides an AST-based Markdown text splitter with section-aware chunking capabilities. The splitter intelligently breaks markdown text into chunks using a hierarchical approach while preserving markdown formatting and semantic relationships between content (e.g., keeping headings with their related content when possible).
88

99
## Key Architecture
1010

1111
### Main Components
1212

13-
1. **text-splitter.ts** - Core implementation containing:
14-
- `createMarkdownSplitter()` - Factory function that creates a configured splitter instance
13+
1. **src/splitter.ts** - Core implementation containing:
14+
- `chunkdown()` - Factory function that creates a configured splitter instance
1515
- AST-based parsing using `mdast-util-from-markdown` and `mdast-util-to-markdown`
1616
- Section-aware chunking logic that combines related content (headings + following content)
1717
- Hierarchical text splitting fallback for oversized content
1818

19-
2. **hierarchical-ast.ts** - AST transformation utilities:
19+
2. **src/ast.ts** - AST transformation utilities:
2020
- `createHierarchicalAST()` - Transforms flat mdast AST into hierarchical sections
2121
- `Section` interface representing headings with their associated content
2222
- Helper functions for working with hierarchical AST structures
2323

24-
3. **text-splitter.test.ts** - Comprehensive test suite using Vitest that validates:
25-
- Basic functionality and chunk size limits
26-
- Markdown formatting preservation
27-
- Breaking point behavior at different levels (paragraphs, sentences, punctuation, words)
24+
3. **src/markdown.ts** - Markdown parsing utilities:
25+
- Wrapper functions around mdast utilities with GFM (GitHub Flavored Markdown) support
26+
- `fromMarkdown()` and `toMarkdown()` functions with GFM extensions enabled
2827

2928
### Core Algorithm
3029

@@ -53,10 +52,19 @@ pnpm test
5352
pnpm test -- --watch
5453

5554
# Run a specific test file
56-
pnpm test src/text-splitter.test.ts
55+
pnpm test src/splitter.test.ts
5756

5857
# Run tests matching a pattern
5958
pnpm test -- -t "Basic Functionality"
59+
60+
# Build the library
61+
pnpm build
62+
63+
# Lint and format code
64+
pnpm lint
65+
66+
# Check type definitions
67+
pnpm types
6068
```
6169

6270
## Testing Approach
@@ -66,4 +74,16 @@ The project uses Vitest for testing. Tests are organized into logical groups:
6674
- Markdown Formatting Preservation - Ensures all markdown elements are preserved correctly
6775
- Breaking Point Behavior - Validates the hierarchical splitting logic
6876

69-
When adding new features or fixing bugs, ensure corresponding tests are added to maintain coverage.
77+
Test files are located alongside their implementation files:
78+
- `src/splitter.test.ts` - Main splitter functionality tests
79+
- `src/ast.test.ts` - AST transformation tests
80+
- `src/markdown.test.ts` - Markdown parsing tests
81+
82+
When adding new features or fixing bugs, ensure corresponding tests are added to maintain coverage.
83+
84+
## Package Structure
85+
86+
The library exports multiple entry points:
87+
- Main export: `chunkdown` function from `src/index.ts`
88+
- Sub-exports: `./ast`, `./splitter`, `./markdown` modules can be imported directly
89+
- Built outputs: CommonJS and ESM formats in `dist/` directory

0 commit comments

Comments
 (0)