AL AI Loadout
Knowledge routing library

Equip the Right Knowledge. On Demand.

Stop dumping everything into context. AI Loadout is a dispatch table format and matching engine that loads the right knowledge for each task — like a game loadout for your agent.

Install

npm install @mcptoolshop/ai-loadout

Match

import { matchLoadout } from '@mcptoolshop/ai-loadout'; const results = matchLoadout('fix the CI workflow', index); // [{ entry: { id: 'github-actions' }, score: 0.67 }]

Validate

import { validateIndex } from '@mcptoolshop/ai-loadout'; const issues = validateIndex(index); // [] — clean!

Features

Everything that makes context routing work.

Dispatch Table Format

A structured index of knowledge payloads. Entries carry keywords, patterns, priority tiers, and trigger phases. The index is the brain; payloads are the muscles.

Keyword + Pattern Matching

Deterministic routing based on keyword overlap proportion plus a pattern bonus. Core entries always load. Manual entries never auto-load. Domain entries score and rank.

Frontmatter Spec

Each payload file carries its own routing metadata as YAML-like frontmatter. Hand-rolled parser — no YAML library, no eval, no prototype pollution. Frontmatter is the source of truth.

Three Priority Tiers

Core (always loaded), Domain (keyword-triggered), Manual (explicit lookup only). Clear semantics, no ambiguity about what loads and when.

Structural Validator

Catches broken indexes before they break your agent: missing IDs, duplicate entries, empty keywords on domain entries, invalid priorities, budget sanity checks.

Zero Dependencies

Pure TypeScript, ESM-only, zero production dependencies. Works anywhere Node 20+ runs. Token estimator included (chars/4 heuristic).

Quick Start

Install

npm install @mcptoolshop/ai-loadout

Match a task

import { matchLoadout } from '@mcptoolshop/ai-loadout';

const results = matchLoadout(
  'fix the CI workflow',
  index
);

for (const { entry, score } of results) {
  console.log(entry.id, score);
}

Parse frontmatter

import { parseFrontmatter } from '@mcptoolshop/ai-loadout';

const { frontmatter, body } = parseFrontmatter(fileContent);
if (frontmatter) {
  console.log(frontmatter.id, frontmatter.keywords);
}

Priority Tiers

Three tiers with clear semantics. No ambiguity about what loads and when.

Tier
Behavior
Example
core
Always loaded (score 1.0)
"never skip tests to make CI green"
domain
Loaded when task keywords match
CI rules when editing workflows
manual
Never auto-loaded, explicit lookup only
Obscure platform gotchas

API Reference

Clean exports for matching, resolving, and observability.