You are a TypeScript library developer specializing in Markdown parsing and Slack Block Kit.
npm test # Run all tests with Vitest (no watch mode)
npm run build # Compile TypeScript to dist/
npm run clean # Remove dist/ directory
npm run generate-fixtures # Regenerate JSON test fixtures from input.md- Tech Stack: TypeScript 5.9, Node.js ≥18, Vitest 4.0, mdast-util-from-markdown 2.0
- Purpose: Convert Markdown strings into Slack Block Kit JSON format
- Key Options:
mentions(user/channel/group/team mappings),detectColors,preferSectionBlocks,tableBlockType("data_table"default |"table"),tableCaption
src/index.ts– Main entry point, exportsmarkdownToBlocks()andsplitBlocks()functionssrc/parser.ts– Core parsing logic using mdast ASTsrc/splitter.ts– Splits large block arrays to fit Slack's limits (40 blocks, 12k chars)src/types.ts– TypeScript type definitions for Slack blockssrc/validator.ts– Input validation (user IDs, channel IDs, etc.)tests/– Integration and unit teststests/fixtures/– Test input/output JSON files
Naming conventions:
- Functions:
camelCase(parseMarkdown,validateOptions) - Types/Interfaces:
PascalCase(SlackBlock,RichTextElement) - Constants:
UPPER_SNAKE_CASE
Example of good code:
// ✅ Good - explicit types, descriptive names
export function markdownToBlocks(
markdown: string,
options?: MarkdownToBlocksOptions
): SlackBlock[] {
const validated = validateOptions(options);
const ast = fromMarkdown(markdown, mdastOptions);
return convertAstToBlocks(ast, validated);
}
// ❌ Bad - implicit any, vague names
function convert(md, opts) {
return parse(md).map(x => transform(x, opts));
}- All changes must pass tests:
npm test - Tests use fixtures in
tests/fixtures/withinput.mdandoutput*.jsonpairs - To update fixtures: If you change the parser logic and need to update snapshots, run
npm run generate-fixtures. This runsscripts/generate-fixtures.ts. - Run specific test:
npm test tests/integration.test.ts
- ✅ Always: Run
npm testbefore commits, follow existing code patterns, use strict TypeScript, bump version inpackage.jsonafter noticeable changes ⚠️ Ask first: Adding new dependencies, changing the public API- 🚫 Never: Commit
node_modules/, modifydist/directly, break Slack Block Kit JSON schema compatibility