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

opencode-ai-os-v4-semantic

v1.0.12

Published

Adaptive semantic AI execution engine for OpenCode — learns from past tasks and dynamically generates execution policy without hardcoded modes.

Downloads

1,455

Readme

opencode-ai-os-v4-semantic

An adaptive semantic AI execution engine for OpenCode that learns from past tasks and dynamically generates execution policy — no hardcoded modes.

Audience: OpenCode users who want context-aware AI assistance that improves over time. Prerequisites: OpenCode CLI installed, basic TypeScript knowledge for programmatic API use.

How It Works

  ┌────────┬───────┬─────────────────┬───────────────────┬──────────┬───────┐
  │ Input  │ Embed │ Memory Retrieval│ Policy Synthesis  │ Planner  │ Coder │
  └────────┴───────┴────────┬────────┴────────┬──────────┴──────────┴───┬───┘
                             │                 │                        │
                             │ past vectors    │ policy object           │ plan
                             │                 │                        │
                        ┌────┘            ┌────┘             ┌──────────┘
                        ▼                 ▼                  ▼
               Semantic Memory    (similarity +        depth >= 3 ?
                  (LRU 1000)       complexity)          ╱        ╲
                        ▲                            Yes          No
                        │                             ▼            ▼
                        │                         Reviewer      Output
                        │                             │            │
                        │                             ▼            │
                        └────────── store ──────── (result) ──────┘
                                     (next
                                    request)

Every request is embedded into a 128-dimension vector, compared against past task memories via cosine similarity, and used to synthesize a dynamic execution policy that controls pipeline depth, tool usage, and reasoning intensity.

The engine uses deterministic FNV-1a hashing for embeddings and in-memory cosine similarity retrieval with an LRU cap at 1,000 entries — no external APIs or services required.

Core Design

  • NO Redis — fully in-process
  • NO queue system — synchronous pipeline
  • NO external APIs — deterministic embedding via character distribution
  • NO FAST/DEEP/MCP modes — policy is synthesized per-request

With zero external runtime dependencies, the plugin operates entirely within your machine.

Install

npm install opencode-ai-os-v4-semantic

Once installed, configure OpenCode to load the plugin.

Usage (as an OpenCode plugin)

Add the plugin to your opencode.json:

{
  "plugin": ["opencode-ai-os-v4-semantic"]
}

OpenCode will auto-load the plugin at startup. It hooks into message.updated events, runs the adaptive semantic engine on every user message, and injects the resulting policy + memory context into the session.

Results are also logged via OpenCode's structured logging system (visible with debug-level logging).

Additionally, the core engine is available for direct import in TypeScript/JavaScript projects.

Programmatic API

import {
  adaptiveEngine,
  embed,
  cosine,
  memoryStore,
} from "opencode-ai-os-v4-semantic";

// Run the full adaptive engine
const result = adaptiveEngine("Build a REST API for user profiles");
console.log(result.policy); // { steps: 3, toolUsage: "full", ... }
console.log(result.similarity); // 0.92 (if similar to past task)

// Check memory state
console.log(memoryStore.size); // number of stored memories

The engine returns a synthesized policy object that controls execution behavior.

Policy Object

interface ExecutionPolicy {
  steps: number;          // 1-5 execution steps
  toolUsage: "none" | "light" | "full";
  reasoningDepth: number; // 1-10
  asyncLevel: number;     // 1-5
}

File Structure

src/
  index.ts      — Plugin entry, hooks into OpenCode events
  engine.ts     — Adaptive engine orchestrator
  embed.ts      — Deterministic embedding (128-dim)
  similarity.ts — Cosine similarity computation
  memory.ts     — In-memory semantic vector store
  policy.ts     — Policy synthesizer (replaces hardcoded modes)
  exec.ts       — Planner, coder, reviewer pipeline

Contributing

Issues and contributions are welcome.

License

MIT