Skip to content

Latest commit

 

History

33 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebAssembly password generator compiled for CLI, Custom Elements, ESM, Node.js, and Web App exploration, powered by ShadowClaw.

ShadowClaw Version WASM Engine Custom Element

📌 Overview

pwgen-knowledge-hub is an interactive documentation platform and demonstration engine built on top of ShadowClaw. It showcases pwgen—the C-based Unix password generator utility compiled to WebAssembly by Karl Herrick.

This repository details:

  • How pwgen was built: Compiling C source code (pwgen.c, pw_phonemes.c, pw_rand.c, sha1.c) with Emscripten into optimized WebAssembly bytecode.
  • Why it was built: Providing standard Unix password security directly to browsers, Node.js, CLI, and Custom Elements with zero external network dependencies or native binary compilation requirements.
  • Evolution of target ecosystems: Exploring modern ESM + Base64 WASM inlining, Custom Elements (<x-pwgen>), as well as historical targets like Chrome Web Bundles (.wbn) and Wasmer WAPM.
  • Interactive AI Agent Integration: Exposing pwgen generation controls directly to AI agents via declarative JSON tools and WebMCP BroadcastChannel inter-process communication.

🚀 Quick Start (Local Development)

Run the pwgen Knowledge Hub locally using the shadow-claw CLI with zero installation:

1. Launch Live Development Server

Start the local server and automatically open the site in your default browser:

npx shadow-claw dev --open -y
  • 🌐 Serves the interactive knowledge hub and live password generator on http://127.0.0.1:8888
  • --open: Automatically opens your default web browser on launch
  • -y: Accepts the default cache directory (.cache) without interactive prompts

2. Common CLI Options

# Run on a custom port
npx shadow-claw dev 3000 --open -y

# Run headlessly without opening a browser
npx shadow-claw dev -y

# Build the static distribution into ./dist/public
npx shadow-claw build

# Serve pre-built static distribution
npx shadow-claw serve

3. Interactive Web Demo & Knowledge Hub

View the live interactive demo and complete documentation on GitHub Pages:

4. Command-Line Usage (npx / npm)

Generate passwords instantly on any terminal:

npx pwgen -sy 20 1

5. Native Web Component (<x-pwgen>)

Embed zero-dependency password generation directly in HTML:

<x-pwgen flags="-sy" length="20" number="1"></x-pwgen>

<script type="module">
  import "https://unpkg.com/pwgen";

  document.addEventListener("x-pwgen-handle-password", ({ detail }) => {
    console.log("Generated Password:", detail.msg);
  });
</script>

📚 Knowledge Hub Chapters

Chapter Title Description
Chapter 1 Architecture, Origins & WASM Evolution History of Theodore Ts'o's C utility and Karl Herrick's WASM port.
Chapter 2 CLI Usage, Options & Node.js Integration CLI flags reference (-s, -y, -0, -A, -B, -v, -r, -H) and Node CJS API.
Chapter 3 C to WASM Compilation Pipeline Dockerized Emscripten (emcc) build scripts & single-file Base64 WASM inlining.
Chapter 4 Native Custom Element (<x-pwgen>) & Frameworks Shadow DOM implementation, event handling, and React/Angular/Vue integration.
Chapter 5 Historical Evolution: .wbn & WAPM Exploring Chrome Web Bundles (.wbn) and Wasmer WAPM distribution history.
Chapter 6 Password Security, Phonetics & SHA1 Seeding Phonetic readability vs. pure random entropy ($E = L \times \log_2 N$) and SHA1 file hashing.
Chapter 7 Web Platform & PWA Performance Workbox Service Worker, sub-millisecond WASM instantiation benchmarks, and PWA setup.
Chapter 8 Agent Skills, Tools & HTTP Discovery Decoupled ESM engine, slash commands, and RFC v0.2.0 well-known discovery index.
Memory Main Technical Memory Reference DeepWiki architecture matrix and component index.

🤖 Declarative Agent Tools & HTTP Discovery

pwgen-knowledge-hub exposes three declarative tools and slash commands (/pwgen, /pwgen-help, /pwgen-entropy):

  1. pwgen: Generates custom passwords via WASM engine. Accepts flags, length, and count.
  2. pwgen_help: Provides human-readable breakdowns of CLI options.
  3. pwgen_entropy: Calculates exact bits of mathematical entropy, pool size, and strength classification.

Decoupled Engine & Presentation Architecture

  • Core Engine Script (pwgen.js): Portable ES module containing pure computation, parameter parsing, and tool execution without DOM dependencies.
  • Custom Element Factory (pwgen-element.js): Portable <x-pwgen> component factory, attribute syncing, and BroadcastChannel bridge installer.
  • Host Presentation Adapter (.agents/scripts/main/pwgen-adapter.js): Manages <x-pwgen> DOM synchronization and UI controls.
  • BroadcastChannel Bridge: Inter-process communication over pwgen-commands and pwgen-results channels.

Standard Discovery Endpoint

Exposed over HTTP per the Agent Skills Discovery RFC:

/.well-known/agent-skills/index.json

About

All Things Pwgen

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages