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 🙏

© 2026 – Pkg Stats / Ryan Hefner

magitsh

v1.0.2

Published

A simple Git-like version control system built with Node.js

Downloads

308

Readme

Magitsh

Ever wondered how Git actually works? magitsh is a fully functional Git implementation built with Node.js. No magic, just clean code you can read and understand.

✨ Features

  • Real Git Objects - Implements blobs, trees, and commits with SHA-1 hashing and zlib compression
  • Async File System - Built on Node.js fs/promises for efficient non-blocking file operations and recursive directory handling
  • Graph Algorithms - Uses DAG data structures with BFS traversal for commit history and merge base detection
  • Smart Merging - Three-way merge algorithm with automatic conflict detection and resolution
  • Complete CLI - All essential Git commands: init, add, commit, branch, checkout, merge, diff, log, status
  • Production Ready - Published on npm with full test coverage using Jest


🎯 Commands

magitsh init              # Initialize repository
magitsh add <files>       # Stage files
magitsh commit -m "msg"   # Create commit
magitsh status            # Check status
magitsh log               # View history
magitsh branch            # List branches
magitsh checkout <branch> # Switch branches
magitsh checkout -b <br>  # Create new branch
magitsh merge <branch>    # Merge branches
magitsh diff              # Show changes

🏗️ How It Works

Repository Structure

.magitsh/
├── objects/           # Content-addressed storage
│   ├── [ab]/[cdef]   # Blobs, trees, commits (SHA-1 based)
│   ├── info/
│   └── pack/
├── refs/
│   ├── heads/        # Branch pointers
│   └── tags/         # Tag references
├── hooks/            # Hook samples
│   ├── pre-commit.sample
│   └── commit-msg.sample
├── info/
│   └── exclude       # Gitignore patterns
├── HEAD              # Current branch (ref: refs/heads/main)
├── index.json        # Staging area
├── config            # Repository config
└── description       # Repository description

Core Concepts

Objects: Everything is stored as content-addressed objects

  • Blobs: File contents (compressed with zlib)
  • Trees: Directory structures (mode + name + hash)
  • Commits: Snapshots with parent pointers (supports multiple parents)

DAG (Graph): Commits form a directed acyclic graph

  • BFS traversal for finding lowest common ancestor
  • Distance tracking for merge base detection
  • Topological ordering for commit history

Branches: Lightweight references to commits

  • Stored as text files in refs/heads/
  • HEAD points to current branch
  • Branch validation ensures safe names

🛠️ Built With

  • Node.js - Runtime environment
  • Commander.js - CLI argument parsing
  • Chalk - Terminal styling and colors
  • Jest - Testing framework
  • zlib - Compression (deflate/inflate)
  • crypto - SHA-1 hashing
  • fs/promises - Async file operations

🎯 Key Algorithms

Three-Way Merge

Base (LCA)     Current (HEAD)    Incoming (feature)
    |               |                    |
    └───────────────┴────────────────────┘
                    ↓
         Conflict Detection:
         • modify-modify: Both changed differently
         • add-add: Both added different content
         • delete-modify: Deleted vs modified
         • modify-delete: Modified vs deleted
                    ↓
         Auto-merge clean changes
                    ↓
         Create conflict markers for conflicts

Lowest Common Ancestor (LCA)

// BFS from both commits simultaneously
const ancestors1 = getAncestorsWithDistance(commit1);
const ancestors2 = getAncestorsWithDistance(commit2);

// Find common ancestors
const common = findIntersection(ancestors1, ancestors2);

// Select LCA with minimum total distance
return common.sort((a, b) => 
  (a.dist1 + a.dist2) - (b.dist1 + b.dist2)
)[0];

Installation

npm install -g magitsh

🧪 Testing

npm test

👥 Contributors

Thanks goes to these wonderful people in the team: