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

@blecsd/ai

v0.6.0

Published

AI-focused widgets for blECSd - conversation, streaming markdown, token tracking, tool use, agent workflow

Downloads

47

Readme

@blecsd/ai

AI-focused widgets for blECSd - conversation, streaming markdown, token tracking, tool use, agent workflow.

Installation

pnpm add @blecsd/ai

Overview

@blecsd/ai provides specialized terminal UI components for building LLM-powered interfaces. It includes widgets for displaying conversations, rendering streaming markdown, tracking token usage, visualizing tool execution, and managing agent workflows.

Quick Start

import { createWorld } from 'blecsd';
import { createConversation, createStreamingMarkdown, createTokenTracker } from '@blecsd/ai';

const world = createWorld();

// Create a conversation widget
const conversation = createConversation(world, {
  x: 0,
  y: 0,
  width: 80,
  height: 20,
  messages: [
    { role: 'user', content: 'Hello!' },
    { role: 'assistant', content: 'Hi there! How can I help you?' }
  ]
});

// Create a streaming markdown widget for LLM responses
const markdown = createStreamingMarkdown(world, {
  x: 0,
  y: 21,
  width: 80,
  height: 10
});

// Stream content to the markdown widget
markdown.append('## Response\n\n');
markdown.append('This is a **streaming** response.\n');

// Track token usage
const tracker = createTokenTracker(world, {
  x: 0,
  y: 32,
  width: 40,
  height: 3,
  maxTokens: 4096,
  currentTokens: 1250
});

Namespace Imports

The @blecsd/ai package provides namespace objects that group related functions for each widget type. These frozen objects make it easy to explore available functions via IDE autocomplete:

import { conversation, streamingMarkdown, tokenTracker } from '@blecsd/ai';

// Conversation operations
const conv = conversation.createConversation(world, { width: 80, height: 30 });
conversation.addMessage(eid, { role: 'user', content: 'Hello!' });
conversation.startStreamingMessage(eid, { role: 'assistant', content: '' });
conversation.appendToMessage(eid, msgId, 'Hi there!');

// Streaming markdown operations
const md = streamingMarkdown.createStreamingMarkdown(world, { width: 80, height: 30 });
streamingMarkdown.appendMarkdown(eid, '## Response\n\n');
streamingMarkdown.appendMarkdown(eid, 'This is **bold** text.\n');
streamingMarkdown.scrollMarkdownByLines(eid, -5);

// Token tracking operations
const tracker = tokenTracker.createTokenTracker(world, { width: 40, height: 10 });
tokenTracker.recordTokens(eid, { inputTokens: 100, outputTokens: 200 });
const stats = tokenTracker.getTokenStats(eid);

Available Namespaces

| Namespace | Purpose | Key Methods | |-----------|---------|-------------| | conversation | Chat-style conversation threads | createConversation, addMessage, startStreamingMessage, appendToMessage, endStreamingMessage, collapseMessage, expandMessage, searchMessages | | streamingMarkdown | Real-time markdown rendering | createStreamingMarkdown, appendMarkdown, clearMarkdownState, scrollMarkdownByLines, scrollMarkdownToLine, renderBlock, renderAllBlocks | | tokenTracker | LLM token usage tracking | createTokenTracker, recordTokens, resetTokenState, getTokenStats, formatTokenDisplay | | toolUse | Tool/function call visualization | createToolUse, recordToolCall, updateToolResult, formatToolDisplay | | agentWorkflow | Multi-step agent workflow | createAgentWorkflow, addTask, updateTaskStatus, getWorkflowProgress, formatWorkflowDisplay |

API

Widgets

| Widget | Description | |--------|-------------| | createConversation() | Chat-style conversation view with role-based message display | | createStreamingMarkdown() | Real-time markdown rendering for streaming LLM responses | | createTokenTracker() | Token usage visualization with progress bar and limits | | createToolUse() | Visual display of tool/function calls with parameters and results | | createAgentWorkflow() | Multi-step agent workflow visualization with task tracking |

Conversation Widget

  • Message history management
  • Role-based styling (user, assistant, system)
  • Auto-scrolling to latest message
  • Markdown rendering support

Streaming Markdown Widget

  • Real-time content streaming
  • Progressive markdown parsing
  • Syntax highlighting for code blocks
  • Auto-scroll during streaming

Token Tracker Widget

  • Current token count display
  • Token limit visualization
  • Progress bar with color-coded zones
  • Estimated cost tracking (optional)

Tool Use Widget

  • Tool name and description display
  • Parameter visualization
  • Result rendering
  • Execution status tracking

Agent Workflow Widget

  • Multi-step task visualization
  • Task dependency tracking
  • Progress indicators per task
  • Status badges (pending, running, complete, failed)

Requirements

  • blecsd (peer dependency)
  • Node.js 18+

License

MIT