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

Commit ac922ea

Browse files
mcp-tool-shopclaude
andcommitted
docs: audit handbook + README, add beginner section
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 571a012 commit ac922ea

5 files changed

Lines changed: 112 additions & 22 deletions

File tree

README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,17 +226,26 @@ import type {
226226
Frontmatter,
227227
MatchResult,
228228
ValidationIssue,
229-
Priority, // "core" | "domain" | "manual"
230-
Triggers, // { task, plan, edit }
231-
LoadMode, // "eager" | "lazy" | "manual"
229+
Priority, // "core" | "domain" | "manual"
230+
Triggers, // { task, plan, edit }
231+
LoadMode, // "eager" | "lazy" | "manual"
232232
Budget,
233233
UsageEvent,
234234
MergeConflict,
235235
MergedIndex,
236-
LoadPlan,
237-
ResolvedLoadout,
238-
EntryExplanation,
239-
IssueSeverity, // "error" | "warning"
236+
LoadPlan, // returned by planLoad()
237+
ResolvedLoadout, // returned by resolveLoadout()
238+
EntryExplanation, // returned by explainEntry()
239+
IssueSeverity, // "error" | "warning"
240+
RuntimeOptions, // options for planLoad / recordLoad / manualLookup
241+
ResolveOptions, // options for resolveLoadout / discoverLayers
242+
UsageSummary, // returned by summarizeUsage()
243+
DeadEntry, // returned by findDeadEntries()
244+
KeywordOverlap, // returned by findKeywordOverlaps()
245+
BudgetBreakdown, // returned by analyzeBudget()
246+
DiscoveredLayer, // a layer found and loaded by the resolver
247+
SearchedLayer, // a layer search location and its result
248+
EntryDefinition, // one layer's version of a specific entry
240249
} from "@mcptoolshop/ai-loadout";
241250
```
242251

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ This checks for structural issues: missing fields, duplicate IDs, non-kebab-case
130130

131131
**Forgetting keywords on domain entries.** Domain entries with no keywords can never be matched by the matcher. The `validate` command catches this as an error (`EMPTY_KEYWORDS`).
132132

133-
**Using regex in patterns.** The `patterns` field contains named intents like `"ci_pipeline"` -- they are matched as plain string lookups against the underscore-split words, not as regular expressions. A pattern of `"ci_pipeline"` matches a task containing the word "ci" or "pipeline."
133+
**Using regex in patterns.** The `patterns` field contains named intents like `"ci_pipeline"` -- they are not regular expressions. The matcher splits each pattern on `_` and checks if **any** of those words appear in the task. A pattern of `"ci_pipeline"` matches a task containing the word "ci" or "pipeline." A matching pattern adds a +0.2 bonus to the entry's score.
134134

135135
**Huge payloads behind a single entry.** If one payload is 5,000 tokens and others are 200, the budget becomes misleading. Break large payloads into focused sub-topics with separate entries.
136136

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ sidebar:
99

1010
A `LoadoutIndex` is the central data structure. It contains:
1111

12+
- **version** — the schema version (currently `"1.0.0"`)
13+
- **generated** — ISO 8601 timestamp of when the index was generated
1214
- **entries** — an array of `LoadoutEntry` objects, each describing one knowledge payload
1315
- **budget** — token estimates for context planning
16+
- **lazyLoad** (optional) — when `true`, signals that payloads should not be pre-loaded by consumers
1417

1518
The index is designed to be always-loaded alongside a lean instruction file. Payloads are loaded on demand when the matcher finds a hit.
1619

@@ -42,12 +45,15 @@ The default is `{ task: true, plan: true, edit: false }`. These are advisory —
4245

4346
## Keyword Matching
4447

45-
The matcher tokenizes the task description into lowercase words, then compares against each entry's `keywords` array:
48+
The matcher tokenizes the task description into lowercase words (stripping non-alphanumeric characters and filtering single-character tokens), then compares against each entry's `keywords` array:
4649

47-
1. Calculate **overlap proportion** = matched keywords / total entry keywords
48-
2. Add **pattern bonus** (+0.2) if any entry pattern appears in the task
49-
3. Cap the score at 1.0
50-
4. Sort results by score descending, then by token cost ascending (lighter payloads first on ties)
50+
1. For each keyword, split it on spaces/hyphens and check if all words are present in the task tokens
51+
2. Calculate **overlap proportion** = matched keywords / total entry keywords
52+
3. For patterns, split each on `_` and check if **any** word appears in the task tokens
53+
4. Add **pattern bonus** (+0.2) if any entry pattern matched
54+
5. Cap the score at 1.0
55+
6. Exclude domain entries below the minimum score threshold (0.1)
56+
7. Sort results by score descending, then by token cost ascending (lighter payloads first on ties)
5157

5258
## The Budget Model
5359

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ Welcome to the AI Loadout handbook. This is the complete guide to the Knowledge
99

1010
## What's inside
1111

12+
- **[Beginners Guide](/ai-loadout/handbook/beginners/)** — New to AI Loadout? Start here
1213
- **[Getting Started](/ai-loadout/handbook/getting-started/)** — Install and first use
1314
- **[Concepts](/ai-loadout/handbook/concepts/)** — Dispatch tables, priorities, resolver, runtime, and budgets
1415
- **[API Reference](/ai-loadout/handbook/reference/)** — Every export documented
1516
- **[Security](/ai-loadout/handbook/security/)** — Attack surface and threat model
16-
- **[Beginners Guide](/ai-loadout/handbook/beginners/)** — New to AI Loadout? Start here
1717

1818
## What is AI Loadout?
1919

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

Lines changed: 83 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ const { merged, layers, searched } = resolveLoadout();
7474

7575
### discoverLayers(opts?)
7676

77-
Discover canonical layer locations and load any that exist. Lower-level than `resolveLoadout`.
77+
Discover canonical layer locations and load any that exist. Lower-level than `resolveLoadout`. Missing layers are normal -- most setups only have project-level. Malformed files are treated the same as missing.
78+
79+
**Returns:** `{ layers: DiscoveredLayer[], searched: SearchedLayer[] }`
7880

7981
---
8082

@@ -142,20 +144,69 @@ const entry = lookupEntry("github-actions", index);
142144

143145
### recordUsage(event, path) / readUsage(path) / summarizeUsage(events)
144146

145-
Append-only JSONL usage log. `recordUsage` appends, `readUsage` loads, `summarizeUsage` groups by entry.
147+
Append-only JSONL usage log. `recordUsage` appends a single event, `readUsage` loads all events (silently skipping malformed lines), `summarizeUsage` groups events by entry ID sorted by load count descending.
148+
149+
**`summarizeUsage` returns:** `UsageSummary[]`
150+
151+
```typescript
152+
interface UsageSummary {
153+
entryId: string;
154+
loadCount: number;
155+
totalTokens: number;
156+
lastLoaded: string; // ISO 8601
157+
triggers: string[]; // unique triggers that caused loads
158+
modes: Set<string>; // unique load modes used
159+
}
160+
```
146161

147162
### findDeadEntries(index, events)
148163

149-
Find entries that have never been loaded. Returns entries sorted by token cost (biggest waste first).
164+
Find entries that have never been loaded. Core entries are excluded since they always load. Returns entries sorted by token cost descending (biggest waste first).
165+
166+
**Returns:** `DeadEntry[]`
167+
168+
```typescript
169+
interface DeadEntry {
170+
entry: LoadoutEntry;
171+
reason: string;
172+
}
173+
```
150174

151175
### findKeywordOverlaps(index)
152176

153-
Find keywords shared between entries — routing ambiguities.
177+
Find keywords shared between entries — routing ambiguities. Results sorted by overlap count descending.
178+
179+
**Returns:** `KeywordOverlap[]`
180+
181+
```typescript
182+
interface KeywordOverlap {
183+
keyword: string;
184+
entries: string[]; // entry IDs sharing this keyword
185+
}
186+
```
154187

155188
### analyzeBudget(index, usage?)
156189

157190
Token budget breakdown by priority tier, with observed-vs-estimated comparison when usage data is available.
158191

192+
**Returns:** `BudgetBreakdown`
193+
194+
```typescript
195+
interface BudgetBreakdown {
196+
totalTokens: number;
197+
coreTokens: number;
198+
domainTokens: number;
199+
manualTokens: number;
200+
coreEntries: number;
201+
domainEntries: number;
202+
manualEntries: number;
203+
avgDomainSize: number;
204+
largestEntry: { id: string; tokens: number } | null;
205+
smallestEntry: { id: string; tokens: number } | null;
206+
observedAvg: number | null;
207+
}
208+
```
209+
159210
---
160211

161212
## Merge
@@ -218,22 +269,44 @@ All commands support `--json` for scripting. Resolver commands accept `--project
218269

219270
```typescript
220271
import type {
272+
// Core data model
221273
LoadoutEntry, // Single entry in the dispatch table
222274
LoadoutIndex, // The full dispatch table (entries + budget)
223275
Frontmatter, // Parsed from payload file headers
224-
MatchResult, // Returned by matchLoadout()
225-
ValidationIssue, // Returned by validateIndex()
226276
Priority, // "core" | "domain" | "manual"
227277
Triggers, // { task, plan, edit }
228278
LoadMode, // "eager" | "lazy" | "manual"
229279
Budget, // Token budget model
280+
281+
// Matching
282+
MatchResult, // Returned by matchLoadout()
283+
284+
// Validation
285+
ValidationIssue, // Returned by validateIndex()
286+
IssueSeverity, // "error" | "warning"
287+
288+
// Usage & observability
230289
UsageEvent, // Append-only usage log entry
290+
UsageSummary, // Returned by summarizeUsage()
291+
DeadEntry, // Returned by findDeadEntries()
292+
KeywordOverlap, // Returned by findKeywordOverlaps()
293+
BudgetBreakdown, // Returned by analyzeBudget()
294+
295+
// Merge
231296
MergeConflict, // Entry defined in multiple layers
232297
MergedIndex, // LoadoutIndex + provenance + conflicts
233-
LoadPlan, // Returned by planLoad()
298+
299+
// Resolver
300+
DiscoveredLayer, // A layer found and loaded by the resolver
301+
SearchedLayer, // A layer search location and its result
234302
ResolvedLoadout, // Returned by resolveLoadout()
235303
EntryExplanation, // Returned by explainEntry()
236-
IssueSeverity, // "error" | "warning"
304+
EntryDefinition, // One layer's version of a specific entry
305+
ResolveOptions, // Options for resolveLoadout / discoverLayers
306+
307+
// Agent runtime
308+
LoadPlan, // Returned by planLoad()
309+
RuntimeOptions, // Options for planLoad / recordLoad / manualLookup
237310
} from "@mcptoolshop/ai-loadout";
238311
```
239312

@@ -243,3 +316,5 @@ import type {
243316
import { DEFAULT_TRIGGERS } from "@mcptoolshop/ai-loadout";
244317
// { task: true, plan: true, edit: false }
245318
```
319+
320+
`DEFAULT_TRIGGERS` provides the default trigger values applied when frontmatter omits the `triggers` field.

0 commit comments

Comments
 (0)