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

@caphtech/state-gate

v0.3.0

Published

State machine for AI agent workflow management

Readme

state_gate

An orchestrator that governs, visualizes, and makes auditable the development and exploration work of AI agents (such as Claude Code) through external state machines.

Overview

state_gate treats agents not as "smart entities that remember processes," but as executors that generate and submit actions and artifacts required by the state machine. This enables:

  • Explicit processes and auditability
  • Consistency across multiple agents/teams
  • Process diversity absorbed through state/transition/guard definitions rather than proliferating skills

Key Features

  • State-Driven: Agent behavior is determined by the state machine
  • Evidence Submission Model: Agents submit evidence, not transition commands
  • Guard Conditions: Control transitions through artifact requirements, machine verification, approvals, etc.
  • Audit Logs: Record all events and decision results
  • Optimistic Locking: Ensure consistency in concurrent execution through revision numbers

Use Cases

  • Iterative processes including exploration, implementation, evaluation, and review
  • Particularly designed for instant prototyping (short loops in exploration phase)

Architecture

┌─────────────────────────────────────────────────────────────┐
│                    Integration Layer                         │
│  ┌─────────────┐  ┌──────────────┐  ┌────────────────────┐  │
│  │ MCP Server  │  │ Hook Adapter │  │ HTTP API / CLI     │  │
│  │ (Dialog)    │  │ (Execution)  │  │ (Integration)      │  │
│  └──────┬──────┘  └──────┬───────┘  └─────────┬──────────┘  │
└─────────┼────────────────┼───────────────────┼──────────────┘
          │                │                   │
          ▼                ▼                   ▼
┌─────────────────────────────────────────────────────────────┐
│                      State Engine                            │
│  ┌──────────────────────────────────────────────────────┐   │
│  │ Process Definition → Event → Guard Eval → Transition │   │
│  └──────────────────────────────────────────────────────┘   │
└──────────────────────────┬──────────────────────────────────┘
                           │
          ┌────────────────┼────────────────┐
          ▼                ▼                ▼
┌────────────────┐ ┌──────────────┐ ┌──────────────────┐
│ Artifact Store │ │ Audit/Event  │ │ Context/Run      │
│ (Source)       │ │ Log          │ │ Management       │
└────────────────┘ └──────────────┘ └──────────────────┘

Documentation

Design Principles

  1. Truth lives in state_gate - Don't rely on agent memory
  2. state_gate decides transitions - Agents focus on evidence submission
  3. Process differences are contained in DSL - Don't absorb them through skills proliferation
  4. Handle conflicts and retries in specification - revision / idempotency / audit

Quick Start

Local Development

npm install
npm run build
npm link
mkdir -p .state_gate/processes
cp examples/exploration/exploration-process.yaml .state_gate/processes/exploration-process.yaml
state-gate create-run --process-id exploration-process
state-gate get-state --run-id <run_id>
state-gate list-events --run-id <run_id> --include-blocked true

All CLI output is JSON format. Define tool execution permissions in tool_permissions for each state (within process definition). emit-event accumulates artifact_paths and saves them in the latest row.

See examples/exploration/README.md for detailed instructions.

MCP Server

state-gate serve --process=./path/to/process.yaml

Hook Adapter (PreToolUse)

state-gate-hook pre-tool-use --tool-name Edit --tool-input '{"path":"README.md"}'

stdin input example:

echo '{"tool_name":"Edit","tool_input":{"path":"README.md"}}' | state-gate-hook pre-tool-use

Error behavior follows fail-open/fail-close settings in docs/hook-adapter.md.

Use as Claude Code Plugin

state_gate is distributed as a Claude Code Plugin and can be installed easily.

Installation

Method 1: From Marketplace (Recommended)

# Add marketplace
/plugin marketplace add https://github.com/CAPHTECH/state_gate

# Install plugin
/plugin install state-gate

Method 2: Direct from GitHub

/plugin install https://github.com/CAPHTECH/state_gate/tree/main/plugin

What Gets Installed

When you install the plugin, the following become automatically available:

  • Hooks: PreToolUse, PostToolUse, SessionStart hooks for state management
  • PreToolUse Hook: Permission checks before tool execution (based on tool_permissions in process definition)
  • PostToolUse Hook: State display after event emission (automatically inserts new state prompt)
  • SessionStart Hook: State display after compaction

MCP Server Configuration (Required)

The plugin provides hooks only. You need to configure the MCP server in each project's .mcp.json:

{
  "mcpServers": {
    "state-gate": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@caphtech/state-gate", "serve"],
      "env": {
        "STATE_GATE_PROJECT_ROOT": "/path/to/your/project"
      }
    }
  }
}

Important: Set STATE_GATE_PROJECT_ROOT to your project's absolute path. This ensures the MCP server uses the correct .state_gate/ directory.

After npm Publication

The plugin uses npx -y @caphtech/state-gate internally, so you need to publish the npm package first:

npm publish

After publication, users can use the plugin without any prior installation (npx automatically downloads and caches the package).

Usage in Projects

Create a Run in your project directory to automatically start state management:

# Create Run (saved in .state_gate/state-gate.json)
state-gate create-run --process-id exploration-process --write-config

# Check state (also available via MCP server)
state-gate get-state

See examples/exploration/README.md and CLAUDE.md for details.

License

MIT

Contributing

Issues and Pull Requests are welcome.