npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@specmind/format

v0.5.1

Published

.sm file format parser and writer

Downloads

54

Readme

@specmind/format

.sm file format parser and writer for SpecMind.

Overview

This package provides the core .sm file format implementation:

  • Zod schemas for validation and type generation
  • Parser for converting markdown to SmFile objects
  • Writer for generating .sm files from SmFile objects
  • Utilities for feature naming and file paths

Installation

npm install @specmind/format
# or
pnpm add @specmind/format

Usage

import { parseSmFile, writeSmFile, createFeatureName } from '@specmind/format'

// Parse .sm file content
const content = '# Feature Name\n\n## Overview\nDescription...'
const result = parseSmFile(content, 'feature')

if (result.success) {
  console.log(result.data.name) // "Feature Name"
  console.log(result.data.requirements) // ["req1", "req2"]

  // Write back to markdown
  const writeResult = writeSmFile(result.data)
  console.log(writeResult.content) // Generated .sm content
}

// Create feature names
const featureName = createFeatureName('User Authentication')
console.log(featureName.slug) // "user-authentication"
console.log(featureName.filename) // "user-authentication.sm"

Development

Commands

# Build package
pnpm build

# Run unit tests
pnpm test

# Type checking
pnpm lint

# Validate test fixtures (end-to-end)
pnpm validate-fixtures

# Clean build outputs
pnpm clean

Testing Strategy

This package uses two complementary testing approaches:

Unit Tests (pnpm test)

  • Purpose: Test individual functions with controlled inputs
  • Location: src/*.test.ts
  • Speed: Fast (milliseconds)
  • Examples:
    • Function behavior with edge cases
    • Error handling and validation
    • Small, focused test cases

Fixture Validation (pnpm validate-fixtures)

  • Purpose: End-to-end validation with realistic .sm files
  • Location: test-fixtures/ + scripts/validate-fixtures.mjs
  • Speed: Slower (file I/O, full parsing)
  • Examples:
    • Complete feature specifications
    • Complex Mermaid diagrams with subgraphs
    • Real-world content roundtrip testing

Both are important: Unit tests catch regressions and edge cases, while fixture validation ensures real-world usage works correctly.

API Reference

Types

import type { SmFile, FeatureName } from '@specmind/format'

Functions

  • parseSmFile(content, type?) - Parse .sm content to SmFile object
  • writeSmFile(smFile) - Convert SmFile object to markdown
  • validateSmFileForWriting(smFile) - Check for writing issues
  • createFeatureName(name) - Generate slug and filename from feature name
  • slugify(name) - Convert string to kebab-case slug
  • getFeatureFilePath(slug) - Get .specmind/features/{slug}.sm path
  • getSystemFilePath() - Get .specmind/system.sm path

.sm File Format

See CONSTITUTION.md Section 4.2 for complete format specification.

Example:

# Feature Name

## Overview
Feature description here.

## Requirements
- Requirement 1
- Requirement 2

## Architecture
```mermaid
graph TD
    A --> B

Design Decisions

Rationale and trade-offs.

Integration Points

  • Service A: Integration details
  • Service B: Integration details

Notes

Warnings, optimizations, tips.