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

@kb-labs/core

v0.6.0

Published

Core utilities and system interfaces for KB Labs ecosystem

Readme

KB Labs Core (@kb-labs/core)

Core library for all KB Labs products and tools. Provides essential utilities, system interfaces, and shared functionality across the KB Labs ecosystem.

License: MIT Node.js pnpm

🎯 Vision

KB Labs Core is the runtime core with profiles resolver/validator and infrastructure abstractions. It provides reliable core utilities, consistent APIs, and extensible architecture for all KB Labs projects. This is the foundation of the @kb-labs ecosystem, enabling all other products to build on top of a stable, well-designed core.

The project solves the problem of code duplication and inconsistent APIs across the KB Labs ecosystem by providing a unified foundation for configuration management, profile resolution, system interfaces, and bundle orchestration. All KB Labs products can rely on Core for consistent behavior, security constraints, and cross-platform compatibility.

This project is part of the @kb-labs ecosystem and integrates seamlessly with other KB Labs tools including CLI, REST API, Analytics, and all AI-powered products.

🚀 Quick Start

Installation

# Install dependencies
pnpm install

Development

# Start development mode for all packages
pnpm dev

# Build all packages
pnpm build

# Run tests
pnpm test

# Lint code
pnpm lint

Basic Usage

The main entry point for KB Labs Core is the bundle loader, which provides a unified interface to configuration, profiles, artifacts, and policy:

import { loadBundle } from '@kb-labs/core-bundle';

const bundle = await loadBundle({
  cwd: process.cwd(),
  product: 'aiReview',
  profileKey: 'default'
});

// Access merged configuration (6 layers)
const config = bundle.config as AiReviewConfig;

// Access artifacts
const rules = await bundle.artifacts.list('rules');

// Check permissions
if (!bundle.policy.permits('aiReview.run')) {
  throw new Error('Permission denied');
}

// Debug with trace
console.log(bundle.trace);

Configuration

Core uses a 6-layer configuration system that merges values from multiple sources. See the Configuration System section for details.

✨ Features

  • 6-Layer Configuration System: Merges runtime defaults, profile defaults, preset defaults, workspace config, local config, and CLI overrides
  • Profile Resolution: Intelligent profile resolution with cycle detection, security constraints, and artifact management
  • Bundle Orchestration: Single entry point (loadBundle()) that coordinates config, profiles, artifacts, and policy
  • System Interfaces: Cross-platform file system operations, structured logging, and Git repository utilities
  • Policy Engine: Fine-grained permission system for product operations
  • Type Safety: Full TypeScript support with strict type checking
  • Performance: LRU caching with automatic invalidation and lazy loading

📁 Repository Structure

kb-labs-core/
├── apps/                    # Example applications and demos
│   └── demo/                # Example app demonstrating core functionality
├── packages/                # Core packages
│   ├── bundle/              # Bundle orchestrator and facade
│   ├── cli/                 # CLI commands for configuration management
│   ├── config/              # Configuration management and runtime utilities
│   ├── policy/              # Policy engine and permission system
│   ├── profile-toolkit/     # Profile utilities and helpers
│   ├── profiles/            # Profile system with artifacts and defaults
│   ├── sys/                 # System interfaces (logging, filesystem, repository)
│   └── types/               # Shared TypeScript types
├── docs/                    # Documentation
│   ├── adr/                 # Architecture Decision Records
│   ├── ADDING_PRODUCT.md    # Guide for adding new products
│   ├── BUNDLE_OVERVIEW.md   # Bundle system architecture
│   ├── CLI_README.md        # CLI documentation
│   ├── CONFIG_API.md         # Configuration API reference
│   ├── DOCUMENTATION.md      # Documentation standards
│   └── MIGRATION_GUIDE.md    # Migration guide
├── scripts/                 # Utility scripts
└── src/                     # Source code

Directory Descriptions

  • apps/ - Example applications demonstrating core functionality and usage patterns
  • packages/ - Individual packages with their own package.json, each serving a specific purpose in the core architecture
  • docs/ - Comprehensive documentation including ADRs, API references, and guides
  • scripts/ - Utility scripts for development and maintenance tasks

📦 Packages

| Package | Description | |---------|-------------| | @kb-labs/core-bundle | Facade orchestrating all components with single entry point (loadBundle()) | | @kb-labs/core-cli | CLI commands for configuration management (kb init, kb config, kb config doctor) | | @kb-labs/core-config | 6-layer configuration management with LRU caching and product normalization | | @kb-labs/core-policy | Policy engine for fine-grained permission checking | | @kb-labs/core-profiles | Profile system with v1.0 manifest format, artifacts API, and security constraints | | @kb-labs/core-sys | System interfaces for logging, filesystem operations, and Git repository utilities | | @kb-labs/core-types | Shared TypeScript types and type definitions | | @kb-labs/core-profile-toolkit | Utilities and helpers for profile management |

Package Details

@kb-labs/core-config provides configuration management with layered merge:

  • 6-layer configuration system (runtime → profile → preset → workspace → local → CLI)
  • Product normalization (kebab-case ↔ camelCase)
  • LRU caching with automatic invalidation
  • Find-up resolution

@kb-labs/core-profiles implements the profile system with artifacts and defaults:

  • New v1.0 manifest format
  • Artifacts API (list, read, materialize)
  • Extends resolution with cycle detection
  • Security constraints (whitelist, size limits, SHA256 verification)

@kb-labs/core-bundle is the facade orchestrating all components:

  • Single entry point (loadBundle()) for complete bundle
  • Coordinates config, profiles, artifacts, and policy
  • Lazy loading with detailed trace support

@kb-labs/core-cli provides CLI commands for configuration management:

  • kb init setup - Initialize complete workspace
  • kb config get - Get product configuration
  • kb config explain - Explain configuration resolution
  • kb config doctor - Configuration health check with suggestions

@kb-labs/core-sys provides system interfaces and utilities:

  • Logging: Structured logging with multiple sinks
  • Filesystem: Cross-platform file system operations
  • Repository: Git repository utilities and metadata

🛠️ Available Scripts

| Script | Description | |--------|-------------| | pnpm dev | Start development mode for all packages | | pnpm build | Build all packages | | pnpm build:all | Build all packages recursively | | pnpm build:clean | Clean and build all packages | | pnpm test | Run all tests | | pnpm test:watch | Run tests in watch mode | | pnpm test:coverage | Run tests with coverage reporting | | pnpm lint | Lint all code | | pnpm lint:fix | Fix linting issues | | pnpm format | Format code with Prettier | | pnpm type-check | TypeScript type checking | | pnpm check | Run lint, type-check, and tests | | pnpm ci | Full CI pipeline (clean, build, check) | | pnpm clean | Clean build artifacts | | pnpm clean:all | Clean all node_modules and build artifacts | | pnpm devkit:sync | Sync DevKit configurations to workspace | | pnpm devkit:check | Check if DevKit sync is needed | | pnpm devkit:force | Force DevKit sync (overwrite existing) |

📋 Development Policies

  • Code Style: ESLint + Prettier, TypeScript strict mode
  • Testing: Vitest with fixtures for integration testing
  • Versioning: SemVer with automated releases through Changesets
  • Architecture: Document decisions in ADRs (see docs/adr/)
  • API Stability: Core packages maintain backward compatibility
  • Documentation: All public APIs must be documented
  • Cross-platform: Ensure compatibility across different operating systems
  • Error Handling: Provide clear error messages and proper error types

🔧 Requirements

  • Node.js: >= 18.18.0
  • pnpm: >= 9.0.0

⚙️ Configuration System

KB Labs Core implements a powerful 6-layer configuration system that merges values from multiple sources (later layers override earlier ones):

  1. Runtime defaults - Built-in defaults for each product
  2. Profile defaults - From profile manifest
  3. Preset defaults - From org preset package
  4. Workspace config - From kb-labs.config.yaml
  5. Local config - From .kb/<product>/<product>.config.json
  6. CLI overrides - From command line arguments

Example Configuration

kb-labs.config.yaml:

schemaVersion: "1.0"
profiles:
  default: "[email protected]"
products:
  ai-review:
    enabled: true
    rules: ["security", "performance"]

Profile: .kb/profiles/node-ts-lib/profile.json

{
  "schemaVersion": "1.0",
  "name": "node-ts-lib",
  "exports": {
    "ai-review": {
      "rules": "artifacts/ai-review/rules.yml"
    }
  },
  "defaults": {
    "ai-review": {
      "$ref": "./defaults/ai-review.json"
    }
  }
}

📚 Documentation

Guides:

Architecture:

🔗 Related Packages

Dependencies

Used By

Ecosystem

  • KB Labs - Main ecosystem repository

🤝 Contributing

See CONTRIBUTING.md for development guidelines and contribution process.

License

KB Public License v1.1 - see LICENSE for details.

This is open source software with some restrictions on:

  • Offering as a hosted service (SaaS/PaaS)
  • Creating competing platform products

For commercial licensing inquiries: [email protected]

User Guides: