Skip to content
This repository was archived by the owner on Jun 16, 2026. It is now read-only.

Commit 8622573

Browse files
mcp-tool-shopclaude
andcommitted
Update handbook: document resolver, runtime, CLI, observability
Index, getting-started, concepts, and reference pages now reflect the full v1.4 API surface including planLoad, resolver, merge, observability, and CLI commands. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7de8558 commit 8622573

4 files changed

Lines changed: 224 additions & 73 deletions

File tree

site/src/content/docs/handbook/concepts.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Concepts
3-
description: Dispatch tables, priority tiers, trigger phases, and the budget model.
3+
description: Dispatch tables, priorities, resolver, runtime, load modes, and the budget model.
44
sidebar:
55
order: 2
66
---
@@ -85,3 +85,44 @@ Content here...
8585
**Frontmatter is the source of truth.** The index is derived from it, not the other way around. If they drift, validation catches it.
8686

8787
The frontmatter parser is hand-rolled — no YAML library, no `eval`, no prototype pollution vectors. It handles strings, inline arrays `[a, b]`, booleans, and one-level nested objects.
88+
89+
## Load Modes
90+
91+
Each matched entry gets a load mode that controls how it enters context:
92+
93+
| Mode | Maps from | Behavior |
94+
|------|-----------|----------|
95+
| `eager` | `core` priority | Preloaded immediately — always in context |
96+
| `lazy` | `domain` priority | Available on demand — loaded when the task matches |
97+
| `manual` | `manual` priority | Never auto-loaded — requires explicit lookup |
98+
99+
## The Resolver
100+
101+
The resolver discovers and merges loadout indexes from a canonical layer stack:
102+
103+
1. **global**`~/.ai-loadout/index.json` (user-wide preferences)
104+
2. **org** — explicit path or `$AI_LOADOUT_ORG` (team conventions)
105+
3. **project**`<cwd>/.claude/loadout/index.json` (repo contracts)
106+
4. **session** — explicit path or `$AI_LOADOUT_SESSION` (ephemeral overrides)
107+
108+
Later layers win. Missing layers are normal — most setups only have project-level. The resolver never guesses; it looks in fixed places in a fixed order.
109+
110+
## Merge Semantics
111+
112+
When two layers define the same entry ID, the later layer overrides the earlier one. The merged index tracks **provenance** (which layer each entry came from) and **conflicts** (entries defined in multiple layers).
113+
114+
## Agent Runtime
115+
116+
The runtime wraps the full sequence: resolve layers → match task → separate by load mode. Agents integrate against one function:
117+
118+
- **`planLoad(task)`** returns a `LoadPlan` with `preload` (eager), `onDemand` (lazy), and `manual` entries, plus provenance, budget, and token costs.
119+
120+
This is the canonical agent-facing API. Everything else (resolve, merge, match, explain) is machinery that the runtime abstracts over.
121+
122+
## Observability
123+
124+
Usage events are recorded to an append-only JSONL log. This enables:
125+
126+
- **Dead entry detection** — entries that have never been loaded
127+
- **Keyword overlap analysis** — routing ambiguities where multiple entries share keywords
128+
- **Budget drift** — comparing estimated vs. observed token costs

site/src/content/docs/handbook/getting-started.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ sidebar:
1313
## Install
1414

1515
```bash
16-
npm install @mcptoolshop/ai-loadout
16+
npm install -g @mcptoolshop/ai-loadout # CLI
17+
npm install @mcptoolshop/ai-loadout # library
1718
```
1819

1920
## Your first dispatch table
@@ -59,20 +60,29 @@ for (const { entry, score, matchedKeywords } of results) {
5960
// github-actions: 0.67 (matched: ci, workflow)
6061
```
6162

62-
## Validate your index
63+
## Plan a load (agent runtime)
64+
65+
The primary agent-facing API — resolve layers, match task, decide what to load:
6366

6467
```typescript
65-
import { validateIndex } from "@mcptoolshop/ai-loadout";
68+
import { planLoad } from "@mcptoolshop/ai-loadout";
6669

67-
const issues = validateIndex(index);
68-
if (issues.length > 0) {
69-
for (const issue of issues) {
70-
console.error(`[${issue.severity}] ${issue.code}: ${issue.message}`);
71-
if (issue.hint) console.error(` hint: ${issue.hint}`);
72-
}
73-
}
70+
const plan = planLoad("fix the CI workflow");
71+
// plan.preload — core entries, load immediately
72+
// plan.onDemand — domain matches, load when needed
73+
// plan.manual — available via explicit lookup only
74+
```
75+
76+
## Use the CLI
77+
78+
Resolve your layered loadouts and inspect entries:
79+
80+
```bash
81+
ai-loadout resolve # show all layers and entries
82+
ai-loadout explain github-actions # trace an entry's decision path
83+
ai-loadout budget .claude/rules/index.json # token budget breakdown
7484
```
7585

7686
## Next steps
7787

78-
Read [Concepts](/ai-loadout/handbook/concepts/) to understand priority tiers, trigger phases, and the budget model.
88+
Read [Concepts](/ai-loadout/handbook/concepts/) to understand priority tiers, the resolver, and the agent runtime.

site/src/content/docs/handbook/index.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,29 @@ sidebar:
55
order: 0
66
---
77

8-
Welcome to the AI Loadout handbook. This is the complete guide to using the dispatch table format, matching engine, and frontmatter spec.
8+
Welcome to the AI Loadout handbook. This is the complete guide to the Knowledge OS kernel — dispatch table, matching engine, hierarchical resolver, agent runtime contract, and CLI.
99

1010
## What's inside
1111

1212
- **[Getting Started](/ai-loadout/handbook/getting-started/)** — Install and first use
13-
- **[Concepts](/ai-loadout/handbook/concepts/)** — Dispatch tables, priorities, triggers, and budgets
13+
- **[Concepts](/ai-loadout/handbook/concepts/)** — Dispatch tables, priorities, resolver, runtime, and budgets
1414
- **[API Reference](/ai-loadout/handbook/reference/)** — Every export documented
1515
- **[Security](/ai-loadout/handbook/security/)** — Attack surface and threat model
1616

1717
## What is AI Loadout?
1818

19-
AI Loadout is a context-aware knowledge router for AI agents. Instead of dumping entire instruction files into context every session, you keep a tiny dispatch table (always loaded) and route to topic-specific payloads on demand.
19+
AI Loadout is the kernel of the Knowledge OS stack — a context-aware knowledge router for AI agents. Instead of dumping entire instruction files into context every session, you keep a tiny dispatch table (always loaded) and route to topic-specific payloads on demand.
2020

2121
Think of it like a game loadout — you equip the agent with exactly the knowledge it needs before each mission.
2222

2323
The library provides:
2424
- A **dispatch table format** (`LoadoutIndex`) for structuring knowledge
2525
- A **keyword + pattern matcher** for routing tasks to payloads
26+
- A **hierarchical resolver** for merging indexes across layers (global → org → project → session)
27+
- An **agent runtime contract** (`planLoad`) — the canonical way agents consume loadouts
28+
- An **observability layer** — usage tracking, dead entry detection, budget analysis
29+
- A **CLI** for resolving, explaining, and analyzing loadouts
2630
- A **frontmatter spec** for embedding routing metadata in payload files
27-
- A **structural validator** for catching broken indexes early
28-
- A **token estimator** for budget dashboards
2931

3032
Zero dependencies. Pure TypeScript. Works anywhere Node 20+ runs.
3133

0 commit comments

Comments
 (0)