Skip to content

Commit b3bc8ff

Browse files
mcp-tool-shopclaude
andcommitted
feat(cli): unified loadout-os CLI — wraps kernel/memories/rules + doctor/report (P3)
New @mcptoolshop/loadout-os package (bin loadout-os), the consolidation payoff. Namespaced wrapped surfaces (loadout-os memories|rules <cmd>) + flat kernel verbs (resolve/explain/usage/dead/overlaps/budget/validate) — flat-vs-namespaced resolves the validate name collision. Rituals: doctor (read-only health screen — store validates, index parse, mirror<->live drift hash, malformed layers, 0-core warning, observability-loop-null, hook wired, usage growing) and report (summarizeUsage + findDeadEntries + analyzeBudget + score distribution). hook test drives apps/hook HOME-isolated. One arg parser, structured CliError (code/message/hint), fail-loud on swallowed flag values. refresh + rules-split stubbed (refresh writes the live index -> needs a compensator, handled separately; split is interactive). Wired into root build order (cli builds last, after its 3 deps). Tests: +51 (cli). Workspace total 347 green. Live read-only checks: doctor ok:true on the real 336-entry index, report parsed 1516 events, hook test left usage.jsonl byte-identical. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 0186174 commit b3bc8ff

20 files changed

Lines changed: 3076 additions & 3 deletions

package-lock.json

Lines changed: 59 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
],
1313
"//buildOrder": "INTENTIONAL: kernel must build before memories and rules — they import the kernel's built dist. Do NOT 'simplify' build/test/verify to `--workspaces` (npm does not guarantee topo order) or the order breaks. The PowerShell hook smoke-test (apps/hook/smoke-test.ps1) is deliberately NOT in verify: it is Windows/rig-specific and would break Linux CI.",
1414
"scripts": {
15-
"build": "npm run build -w packages/kernel && npm run build -w packages/memories && npm run build -w packages/rules",
16-
"test": "npm run test -w packages/kernel && npm run test -w packages/memories && npm run test -w packages/rules",
17-
"verify": "npm run build && npm run verify -w packages/kernel && npm run verify -w packages/memories && npm run verify -w packages/rules"
15+
"build": "npm run build -w packages/kernel && npm run build -w packages/memories && npm run build -w packages/rules && npm run build -w packages/cli",
16+
"test": "npm run test -w packages/kernel && npm run test -w packages/memories && npm run test -w packages/rules && npm run test -w packages/cli",
17+
"verify": "npm run build && npm run verify -w packages/kernel && npm run verify -w packages/memories && npm run verify -w packages/rules && npm run verify -w packages/cli"
1818
},
1919
"engines": {
2020
"node": ">=20"

packages/cli/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 mcp-tool-shop
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/cli/README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# @mcptoolshop/loadout-os
2+
3+
The unified **Knowledge OS** CLI. One `loadout-os` binary that wraps the three
4+
library packages of this workspace and absorbs the operational rituals that used
5+
to be a multi-step manual sequence.
6+
7+
It wraps:
8+
9+
- **kernel**[`@mcptoolshop/ai-loadout`](../kernel) — the knowledge router (resolve / match / budget / usage analysis)
10+
- **memories**[`@mcptoolshop/claude-memories`](../memories) — MEMORY.md → dispatch index
11+
- **rules**[`@mcptoolshop/claude-rules`](../rules) — CLAUDE.md section analysis + rule-file linting
12+
- the **runtime hook**[`apps/hook/loadout-hook.mjs`](../../apps/hook) — the `UserPromptSubmit` pointer-injector
13+
14+
Every wrapped surface calls the library export directly (one process, one arg
15+
parser, one structured-error shape) — `loadout-os` does not shell out to the
16+
legacy `ai-loadout` / `claude-memories` / `claude-rules` bins.
17+
18+
## Command tree
19+
20+
### Namespaces (wrapped library surfaces)
21+
22+
```
23+
loadout-os memories index <MEMORY.md> [--lazy] [--json]
24+
loadout-os memories validate <MEMORY.md> [--json]
25+
loadout-os memories stats <MEMORY.md> [--json]
26+
loadout-os memories health [path] [--json]
27+
28+
loadout-os rules analyze <CLAUDE.md> [--rules-dir <dir>] [--json]
29+
loadout-os rules validate [--rules-dir <dir>] [--lazy] [--repo-root <dir>] [--json]
30+
loadout-os rules stats <CLAUDE.md> [--rules-dir <dir>] [--json]
31+
loadout-os rules split # interactive — not wrapped; use the claude-rules bin
32+
```
33+
34+
### Flat verbs (knowledge router / kernel)
35+
36+
```
37+
loadout-os resolve # resolve layered loadouts (global → org → project → session)
38+
loadout-os explain <entry-id> # how an entry resolved across layers
39+
loadout-os usage <jsonl> # usage summary from the event log
40+
loadout-os dead <index> <jsonl> # entries never loaded
41+
loadout-os overlaps <index> # keyword routing ambiguities
42+
loadout-os budget <index> [jsonl] # token budget breakdown
43+
loadout-os validate <index> # validate index STRUCTURE (kernel)
44+
```
45+
46+
> **Name collision, resolved by namespacing.** The flat `validate <index>` is the
47+
> kernel's index-structure validator. The store/rules linters are namespaced —
48+
> `memories validate <MEMORY.md>` and `rules validate` — so all three coexist.
49+
50+
### Rituals
51+
52+
```
53+
loadout-os doctor [--json] # read-only health screen
54+
loadout-os report [--index <p>] [--jsonl <p>] # observability over usage.jsonl
55+
loadout-os hook test [--prompt "<text>"] # drive the runtime hook on a sample prompt
56+
loadout-os refresh # not yet implemented (see below)
57+
```
58+
59+
- **`doctor`** — one read-only screen: store `MEMORY.md` validates, the global
60+
index parses + validates, the runtime hook mirror matches the repo source (drift
61+
check), no malformed resolver layers, at least one core entry, observability
62+
loop wired, hook wired in `settings.json`, and `usage.jsonl` growing. `--json`
63+
emits `{ checks: [{ id, status, message, hint }], ok }`. Exit 0 when all checks
64+
pass or warn; exit 1 on any fail. **Never writes.**
65+
- **`report`** — composes usage summary + dead-entry detection + token budget,
66+
plus a score distribution when usage events carry a `score`. `--json` for the
67+
machine-readable shape. Exit 2 when an input is missing. **Read-only.**
68+
- **`hook test`** — runs the real `loadout-hook.mjs` against a sample prompt in an
69+
isolated HOME so the live `usage.jsonl` is never written.
70+
- **`refresh`***stubbed this wave.* It writes the live global index and needs a
71+
named compensator, so it is handled separately; for now run the Index Freshness
72+
Ritual (memories index → validate → copy to `~/.ai-loadout/index.json`).
73+
74+
## Build & test
75+
76+
```
77+
npm run build # tsc
78+
npm test # node --test dist/tests/*.test.js
79+
npm run verify # tsc --noEmit && node --test dist/tests/*.test.js
80+
```
81+
82+
## SDK use
83+
84+
Importing the package is side-effect-free — the dispatcher only runs when the
85+
file is the process entrypoint. Composable exports: `dispatch`, `runDoctor` /
86+
`buildReport` / `runHookTest` (and their `print*` renderers + `default*Paths`
87+
helpers).

packages/cli/package.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "@mcptoolshop/loadout-os",
3+
"version": "0.0.0",
4+
"description": "Unified Knowledge OS CLI — wraps ai-loadout (kernel) + claude-memories + claude-rules and absorbs the operational rituals (doctor, report, refresh) into one loadout-os binary.",
5+
"license": "MIT",
6+
"author": "mcp-tool-shop",
7+
"type": "module",
8+
"bin": {
9+
"loadout-os": "./dist/cli.js"
10+
},
11+
"main": "./dist/index.js",
12+
"types": "./dist/index.d.ts",
13+
"exports": {
14+
".": {
15+
"types": "./dist/index.d.ts",
16+
"import": "./dist/index.js"
17+
}
18+
},
19+
"files": [
20+
"dist",
21+
"README.md",
22+
"LICENSE"
23+
],
24+
"scripts": {
25+
"build": "tsc",
26+
"test": "node --test dist/tests/*.test.js",
27+
"verify": "tsc --noEmit && node --test dist/tests/*.test.js"
28+
},
29+
"dependencies": {
30+
"@mcptoolshop/ai-loadout": "^1.4.3",
31+
"@mcptoolshop/claude-memories": "^1.0.3",
32+
"@mcptoolshop/claude-rules": "^1.2.2"
33+
},
34+
"devDependencies": {
35+
"@types/node": "^22",
36+
"typescript": "^5.7",
37+
"c8": "^11"
38+
},
39+
"engines": {
40+
"node": ">=20"
41+
}
42+
}

0 commit comments

Comments
 (0)