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

@pga-ai/core

v0.4.0

Published

PGA Core - Genomic Self-Evolving Prompts with Gene Bank, THK, Layered Memory, RAG, and Advanced Reasoning

Readme

@pga-ai/core

🧬 Genomic Self-Evolving Prompts — Core Engine

npm version License: MIT

Created by Luis Alfredo Velasquez Duran | Germany, 2025


What is @pga-ai/core?

The core engine for PGA (Genomic Self-Evolving Prompts) — the world's first system that makes AI prompts evolve automatically like biological organisms.

Instead of manually tweaking prompts, PGA:

  • ✅ Learns from every interaction
  • ✅ Adapts to each user uniquely
  • ✅ Improves continuously (autonomous)
  • ✅ Never degrades (immune system)
  • ✅ Tests changes before deployment (sandbox)

Installation

npm install @pga-ai/core

You'll also need adapters for your LLM and database:

npm install @pga-ai/adapters-llm @pga-ai/adapters-storage

Quick Start

import { PGA } from '@pga-ai/core';
import { ClaudeAdapter } from '@pga-ai/adapters-llm/anthropic';
import { PostgresAdapter } from '@pga-ai/adapters-storage/postgres';

// 1. Initialize PGA
const pga = new PGA({
  llm: new ClaudeAdapter({
    apiKey: process.env.ANTHROPIC_KEY,
  }),
  storage: new PostgresAdapter({
    connectionString: process.env.DATABASE_URL,
  }),
});

await pga.initialize();

// 2. Create genome
const genome = await pga.createGenome({
  name: 'my-assistant',
});

// 3. Use in your agent loop
async function chat(userId: string, message: string) {
  const response = await genome.chat(message, { userId });
  return response;
}

// 4. PGA learns automatically from interactions
await genome.recordInteraction({
  userId: 'user123',
  userMessage: 'Hello!',
  assistantResponse: 'Hi there!',
  toolCalls: [],
  score: 0.9,
  timestamp: new Date(),
});

That's it! Your agent now evolves automatically.

Core Concepts

Three-Layer Architecture

┌─────────────────────────────────────────┐
│  Layer 0: Immutable DNA                 │
│  Security, Ethics, Core Identity        │
│  🚫 NEVER mutates                       │
├─────────────────────────────────────────┤
│  Layer 1: Operative Genes               │
│  Tool Usage, Coding Patterns            │
│  🐢 SLOW mutation (high validation)    │
├─────────────────────────────────────────┤
│  Layer 2: Epigenomes                    │
│  User Preferences, Communication Style  │
│  ⚡ FAST mutation (daily adaptation)    │
└─────────────────────────────────────────┘

User DNA Profiling

Each user gets a unique cognitive profile:

const dna = await genome.getDNA('user123');

console.log(dna.traits);
// {
//   communicationStyle: 'technical',
//   verbosity: 'terse',
//   preferredTools: ['browser', 'code'],
//   domainExpertise: { 'coding': 0.9 }
// }

Automatic Evolution

PGA evolves through a 4-phase cycle:

  1. Transcription: Log every interaction
  2. Variation: Generate mutations
  3. Simulation: Test in sandbox
  4. Selection: Deploy only improvements

API Reference

PGA Class

new PGA(config)

Create PGA instance.

const pga = new PGA({
  llm: new ClaudeAdapter({ apiKey: '...' }),
  storage: new PostgresAdapter({ connectionString: '...' }),
  config: {
    enableSandbox: true,      // Test mutations before deploy
    mutationRate: 'balanced',  // 'slow' | 'balanced' | 'aggressive'
  },
});

pga.initialize()

Initialize storage (create tables, etc.).

await pga.initialize();

pga.createGenome(options)

Create new genome.

const genome = await pga.createGenome({
  name: 'my-assistant',
  config: {
    enableSandbox: true,
    mutationRate: 'balanced',
  },
});

GenomeInstance Class

genome.assemblePrompt(context)

Get optimized prompt for current context.

const prompt = await genome.assemblePrompt({
  userId: 'user123',
  taskType: 'coding',
});

genome.chat(message, context)

Chat with PGA optimization.

const response = await genome.chat('Hello!', {
  userId: 'user123',
});

genome.recordInteraction(interaction)

Record interaction (enables learning).

await genome.recordInteraction({
  userId: 'user123',
  userMessage: 'Fix this bug',
  assistantResponse: 'Bug fixed!',
  toolCalls: [],
  score: 0.95,
  timestamp: new Date(),
});

genome.getDNA(userId)

Get user's DNA profile.

const dna = await genome.getDNA('user123');

genome.recordFeedback(userId, gene, sentiment)

Record user feedback.

await genome.recordFeedback('user123', 'communication-style', 'positive');

Adapters

LLM Adapters

Implement LLMAdapter interface:

import type { LLMAdapter } from '@pga-ai/core';

export class MyLLMAdapter implements LLMAdapter {
  readonly name = 'my-llm';
  readonly model = 'my-model-v1';

  async chat(messages, options) {
    // Your implementation
  }
}

Available adapters:

  • @pga-ai/adapters-llm/anthropic - Claude
  • @pga-ai/adapters-llm/openai - GPT
  • @pga-ai/adapters-llm/google - Gemini
  • @pga-ai/adapters-llm/local - Ollama

Storage Adapters

Implement StorageAdapter interface:

import type { StorageAdapter } from '@pga-ai/core';

export class MyStorageAdapter implements StorageAdapter {
  async initialize() { /* ... */ }
  async saveGenome(genome) { /* ... */ }
  async loadGenome(id) { /* ... */ }
  // ... other methods
}

Available adapters:

  • @pga-ai/adapters-storage/postgres
  • @pga-ai/adapters-storage/mongodb
  • @pga-ai/adapters-storage/redis
  • @pga-ai/adapters-storage/sqlite

Examples

See /examples directory for:

  • Basic usage
  • LangChain integration
  • Custom agents
  • Next.js app

License

MIT © Luis Alfredo Velasquez Duran


Created with 🧬 by Luis Alfredo Velasquez Duran