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

Commit 7de8558

Browse files
mcp-tool-shopclaude
andcommitted
v1.4.2: README overhaul — document full API surface
Add agent runtime (planLoad, recordLoad, manualLookup), resolver, observability, merge, and CLI sections. Add claude-memories to consumers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4074128 commit 7de8558

3 files changed

Lines changed: 106 additions & 36 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 1.4.2 — 2026-03-06
4+
5+
- **README overhaul**: Document full API surface — agent runtime (`planLoad`, `recordLoad`, `manualLookup`), resolver, observability, merge, CLI commands
6+
- Add claude-memories to consumers list
7+
38
## 1.4.1 — 2026-03-06
49

510
- **Fix tokenizer**: hyphens now split into separate tokens (`claude-memories``claude` + `memories`), fixing keyword matching for hyphenated task descriptions

README.md

Lines changed: 100 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616

1717
Context-aware knowledge router for AI agents.
1818

19-
`ai-loadout` is the dispatch table format and matching engine that lets AI agents load the right knowledge for the task at hand. Instead of dumping everything into context, you keep a tiny index and load payloads on demand.
19+
`ai-loadout` is the kernel of the Knowledge OS stack — dispatch table format, matching engine, hierarchical resolver, and agent runtime contract. Instead of dumping everything into context, you keep a tiny index and load 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
## Install
2424

2525
```bash
26-
npm install @mcptoolshop/ai-loadout
26+
npm install -g @mcptoolshop/ai-loadout # CLI
27+
npm install @mcptoolshop/ai-loadout # library
2728
```
2829

2930
## Core Concepts
@@ -88,76 +89,132 @@ CI minutes are finite...
8889

8990
Frontmatter is the source of truth. The index is derived from it.
9091

91-
## API
92+
## Agent Runtime (Primary API)
93+
94+
The runtime is the canonical way agents consume a loadout. It wraps the full sequence: resolve layers → match task → decide what to load → record usage.
95+
96+
### `planLoad(task, opts?)`
97+
98+
Plan what to load for a given task. This is the primary agent-facing function.
99+
100+
```typescript
101+
import { planLoad } from "@mcptoolshop/ai-loadout";
102+
103+
const plan = planLoad("fix the CI workflow");
104+
// plan.preload — core entries, load immediately
105+
// plan.onDemand — domain matches, load when needed
106+
// plan.manual — available via explicit lookup only
107+
```
108+
109+
Returns a `LoadPlan` with:
110+
- `preload` / `onDemand` / `manual` — entries separated by load mode
111+
- `provenance` — which layer each entry came from
112+
- `budget` — token budget for the resolved index
113+
- `preloadTokens` / `onDemandTokens` — token cost totals
114+
- `layerNames` / `conflicts` — layer metadata
115+
116+
### `recordLoad(entryId, trigger, mode, tokensEst, opts?)`
117+
118+
Record that an agent loaded an entry. Enables observability (dead entries, budget drift, frequency tracking). Optional — only writes when `usagePath` is set in options.
119+
120+
### `manualLookup(id, opts?)`
121+
122+
Explicitly load a manual entry by ID from the resolved index.
123+
124+
## Resolver
125+
126+
Discovers and merges loadout indexes from a canonical layer stack:
127+
128+
1. **global**`~/.ai-loadout/index.json`
129+
2. **org** — explicit path or `$AI_LOADOUT_ORG`
130+
3. **project**`<cwd>/.claude/loadout/index.json`
131+
4. **session** — explicit path or `$AI_LOADOUT_SESSION`
132+
133+
Later layers win. Missing layers are normal.
134+
135+
```typescript
136+
import { resolveLoadout, explainEntry } from "@mcptoolshop/ai-loadout";
137+
138+
const { merged, layers, searched } = resolveLoadout();
139+
// merged.entries — deduplicated entries from all layers
140+
// merged.provenance — entryId → source layer name
141+
142+
const why = explainEntry("github-actions", layers);
143+
// why.finalLayer, why.overrideChain, why.definitions
144+
```
145+
146+
## Matching
92147

93148
### `matchLoadout(task, index)`
94149

95-
Match a task description against a loadout index. Returns entries that should be loaded, ranked by match strength.
150+
Match a task description against a loadout index. Returns entries ranked by match strength.
96151

97152
```typescript
98153
import { matchLoadout } from "@mcptoolshop/ai-loadout";
99154

100155
const results = matchLoadout("fix the CI workflow", index);
101-
// [{ entry: { id: "github-actions", ... }, score: 0.67, matchedKeywords: ["ci", "workflow"] }]
156+
// [{ entry, score: 0.67, matchedKeywords: ["ci", "workflow"], reason, mode }]
102157
```
103158

104159
- Core entries always included (score 1.0)
105160
- Manual entries never auto-included
106161
- Domain entries scored by keyword overlap + pattern bonus
107-
- Results sorted by score descending
162+
- Results sorted by score descending, then by token cost ascending
108163

109164
### `lookupEntry(id, index)`
110165

111166
Look up a specific entry by ID. For manual entries or explicit access.
112167

113-
```typescript
114-
import { lookupEntry } from "@mcptoolshop/ai-loadout";
168+
## Observability
115169

116-
const entry = lookupEntry("github-actions", index);
117-
```
170+
### `recordUsage()` / `readUsage()` / `summarizeUsage()`
118171

119-
### `parseFrontmatter(content)`
172+
Append-only JSONL usage log. Never networked, never creepy.
120173

121-
Parse YAML-like frontmatter from a payload file.
174+
### `findDeadEntries(index, events)`
122175

123-
```typescript
124-
import { parseFrontmatter } from "@mcptoolshop/ai-loadout";
176+
Find entries that have never been loaded.
125177

126-
const { frontmatter, body } = parseFrontmatter(fileContent);
127-
if (frontmatter) {
128-
console.log(frontmatter.id, frontmatter.keywords);
129-
}
130-
```
178+
### `findKeywordOverlaps(index)`
131179

132-
### `serializeFrontmatter(fm)`
180+
Find keywords shared between entries (routing ambiguities).
133181

134-
Serialize a `Frontmatter` object back to a string.
182+
### `analyzeBudget(index, usage?)`
135183

136-
### `validateIndex(index)`
184+
Token budget breakdown with observed-vs-estimated comparison.
137185

138-
Validate structural integrity of a `LoadoutIndex`. Returns an array of issues.
186+
## Merge
139187

140-
```typescript
141-
import { validateIndex } from "@mcptoolshop/ai-loadout";
188+
### `mergeIndexes(layers)`
142189

143-
const issues = validateIndex(index);
144-
const errors = issues.filter(i => i.severity === "error");
145-
if (errors.length > 0) {
146-
console.error("Index has errors:", errors);
147-
}
148-
```
190+
Deterministic merge for hierarchical loadouts. Returns a `MergedIndex` with provenance tracking and conflict reporting.
191+
192+
## Utilities
193+
194+
### `parseFrontmatter(content)` / `serializeFrontmatter(fm)`
149195

150-
Checks: required fields, unique IDs, kebab-case format, summary bounds, keyword presence for domain entries, valid priorities, non-negative budgets.
196+
Parse and serialize YAML-like frontmatter from payload files.
197+
198+
### `validateIndex(index)`
199+
200+
Validate structural integrity of a `LoadoutIndex`. Checks: required fields, unique IDs, kebab-case format, summary bounds, keyword presence for domain entries, valid priorities, non-negative budgets.
151201

152202
### `estimateTokens(text)`
153203

154204
Estimate token count from text. Uses chars/4 heuristic.
155205

156-
```typescript
157-
import { estimateTokens } from "@mcptoolshop/ai-loadout";
206+
## CLI
158207

159-
const tokens = estimateTokens(fileContent); // ~250
160208
```
209+
ai-loadout resolve Resolve layered loadouts
210+
ai-loadout explain <entry-id> Explain why an entry resolved to its current state
211+
ai-loadout usage <jsonl> Usage summary from event log
212+
ai-loadout dead <index> <jsonl> Find entries never loaded
213+
ai-loadout overlaps <index> Find keyword routing ambiguities
214+
ai-loadout budget <index> [jsonl] Token budget breakdown
215+
```
216+
217+
All commands support `--json` for scripting. Resolver commands accept `--project`, `--global`, `--org`, `--session`.
161218

162219
## Types
163220

@@ -170,13 +227,21 @@ import type {
170227
ValidationIssue,
171228
Priority, // "core" | "domain" | "manual"
172229
Triggers, // { task, plan, edit }
230+
LoadMode, // "eager" | "lazy" | "manual"
173231
Budget,
232+
UsageEvent,
233+
MergeConflict,
234+
MergedIndex,
235+
LoadPlan,
236+
ResolvedLoadout,
237+
EntryExplanation,
174238
} from "@mcptoolshop/ai-loadout";
175239
```
176240

177241
## Consumers
178242

179243
- **[@mcptoolshop/claude-rules](https://github.com/mcp-tool-shop-org/claude-rules)** — CLAUDE.md optimizer for Claude Code. Uses ai-loadout for the dispatch table and matching.
244+
- **[@mcptoolshop/claude-memories](https://github.com/mcp-tool-shop-org/claude-memories)** — MEMORY.md optimizer for Claude Code. Generates dispatch tables from memory topic files.
180245

181246
## Security
182247

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mcptoolshop/ai-loadout",
3-
"version": "1.4.1",
3+
"version": "1.4.2",
44
"description": "Context-aware knowledge router for AI agents. Dispatch table, matcher, hierarchical resolver, agent runtime contract, CLI.",
55
"type": "module",
66
"bin": {

0 commit comments

Comments
 (0)