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

@ai-guide/core

v0.1.0

Published

WASM-based ID generation for AI Guide

Readme

@ai-guide/core

Single source of truth for ID generation across the AI Guide system. This Rust library provides deterministic, stable ID generation that can be used from both Rust (SWC plugin) and JavaScript/TypeScript (Node.js backend) via WebAssembly.

Purpose

Ensures consistent ID generation across:

  • SWC Plugin (Rust): Build-time AST analysis
  • Backend (Node.js): Runtime query processing
  • Webpack Plugin (Node.js): Manifest generation

Architecture

  • Language: Rust
  • Output: WebAssembly (WASM) + Native library
  • Interop: wasm-bindgen for JavaScript/TypeScript
  • Algorithm: MD5 hashing for deterministic IDs

Build Outputs

cargo build --release

Produces:

  • target/release/libai_guide_core.dylib - Native library (macOS)
  • target/release/libai_guide_core.so - Native library (Linux)
  • target/release/ai_guide_core.dll - Native library (Windows)
  • target/wasm32-unknown-unknown/release/ai_guide_core.wasm - WebAssembly module

API Functions

generate_semantic_id(file_path, parent_path, node_type, node_name, sibling_index, attrs_hash)

Generate stable ID based on component hierarchy and semantic structure.

Formula: MD5(file_path:parent_path:node_type:node_name:sibling_index:attrs_hash).substring(0, 12)

Returns: 12-character hex hash

generate_stable_id(file_path, element_name, line_number)

LEGACY: Generate stable ID based on line number.

Formula: MD5(file_path:element_name:line_number).substring(0, 12)

Returns: 12-character hex hash

generate_component_id(file_path, component_name)

Generate component ID from file path and name.

Formula: MD5(file_path:component_name).substring(0, 8)

Returns: 8-character hex hash

generate_action_id(component_id, label, selector)

Generate action ID linked to a component.

Formula: MD5(component_id:label:selector).substring(0, 8)

Returns: 8-character hex hash

hash_stable_attributes(attrs_json)

Generate hash from stable attributes (id, data-testid, key, etc.).

Returns: 8-character hex hash or empty string

Usage

From Rust (SWC Plugin)

use ai_guide_core::generate_semantic_id;

let id = generate_semantic_id(
    "src/components/Button.tsx",
    "App>Layout",
    "component",
    "Button",
    0,
    "id=submit"
);
// Returns: "a1b2c3d4e5f6"

From Node.js (after WASM compilation)

import * as core from '@ai-guide/core';

const id = core.generate_semantic_id(
    "src/components/Button.tsx",
    "App>Layout",
    "component",
    "Button",
    0,
    "id=submit"
);
// Returns: "a1b2c3d4e5f6"

Testing

cargo test

All ID generation functions include unit tests to verify:

  • Deterministic output (same input = same ID)
  • Correct hash length
  • Empty input handling

Why MD5?

  • Fast: Optimized for build-time performance
  • Deterministic: Same input always produces same output
  • Collision-resistant: For our namespace, collisions are extremely rare
  • Compact: Short IDs (8-12 chars) are human-readable

Development

Build for Development

cargo build

Build for Production

cargo build --release

Run Tests

cargo test

Build for WebAssembly (Node.js)

wasm-pack build --target nodejs

Integration Status

  • [x] Core implementation
  • [ ] WASM build configuration
  • [ ] Node.js package wrapper
  • [ ] SWC plugin integration
  • [ ] Backend migration