clef-mcp 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -4
- package/dist/cli.js +536 -156
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +32 -10
- package/dist/index.js +109 -60
- package/dist/index.js.map +1 -1
- package/examples/claude-code/README.md +21 -0
- package/examples/claude-code/mcp.json +8 -0
- package/examples/codex/config.toml +21 -0
- package/examples/cursor/README.md +12 -0
- package/examples/cursor/mcp.json +8 -0
- package/examples/hooks/README.md +12 -0
- package/examples/hooks/ci-triage/README.md +68 -0
- package/examples/hooks/pretooluse-guard/README.md +54 -0
- package/examples/hooks/pretooluse-guard/guard.sh +61 -0
- package/package.json +3 -2
- package/skills/clef-decisions/SKILL.md +15 -5
package/README.md
CHANGED
|
@@ -81,19 +81,22 @@ Sweet spot: **decision points inside agent loops** — next action, routing, cla
|
|
|
81
81
|
| `score` | ordered list (index = score) | probability per level |
|
|
82
82
|
| `noul` | optional `{"true": "...", "false": "..."}` | `{"true": p, "false": 1-p}` |
|
|
83
83
|
|
|
84
|
-
Response — strictly structured, never prose:
|
|
84
|
+
Response — strictly structured, never prose. Each decision carries the model-reported `confidence` (when the runtime sends it), plus token `usage` for the call:
|
|
85
85
|
|
|
86
86
|
```json
|
|
87
87
|
{
|
|
88
88
|
"model": "clef-flash",
|
|
89
89
|
"decisions": {
|
|
90
|
-
"next_action": { "answer": { "inspect": 0.72, "modify": 0.12, "test": 0.14, "ask_user": 0.02 } },
|
|
91
|
-
"confidence": { "answer": { "very_low": 0.01, "low": 0.04, "medium": 0.18, "high": 0.61, "very_high": 0.16 } },
|
|
90
|
+
"next_action": { "answer": { "inspect": 0.72, "modify": 0.12, "test": 0.14, "ask_user": 0.02 }, "confidence": 0.83 },
|
|
91
|
+
"confidence": { "answer": { "very_low": 0.01, "low": 0.04, "medium": 0.18, "high": 0.61, "very_high": 0.16 }, "confidence": 0.61 },
|
|
92
92
|
"is_outage": { "answer": { "true": 0.9, "false": 0.1 } }
|
|
93
|
-
}
|
|
93
|
+
},
|
|
94
|
+
"usage": { "input_tokens": 228, "output_tokens": 0, "latency_ms": 512 }
|
|
94
95
|
}
|
|
95
96
|
```
|
|
96
97
|
|
|
98
|
+
Act on the argmax only when the distribution is decisive — top p ≥ 0.8 and high `confidence` for destructive or security-adjacent calls.
|
|
99
|
+
|
|
97
100
|
Batch up to **64 questions per call** — they are scored in one forward pass. `state` is treated strictly as **data**: never executed, never interpreted as instructions for the server.
|
|
98
101
|
|
|
99
102
|
## Prompts & resources
|
|
@@ -178,6 +181,23 @@ args = []
|
|
|
178
181
|
|
|
179
182
|
Ready-made snippets: [`examples/`](examples/).
|
|
180
183
|
|
|
184
|
+
## Scripting & hooks
|
|
185
|
+
|
|
186
|
+
No MCP client required — hooks, CI jobs and shell scripts call the same model one-shot:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# Full document on stdin
|
|
190
|
+
echo '{"state": "checkout 500s after deploy", "questions": {"is_outage": {"type": "noul", "instructions": "Is a service down?"}}}' \
|
|
191
|
+
| clef-mcp decide
|
|
192
|
+
|
|
193
|
+
# Or split across files
|
|
194
|
+
clef-mcp decide --questions questions.json --state state.json
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
stdout carries the strict JSON result (same shape as the MCP tool, including `confidence` and `usage`); errors go to stderr as structured JSON with exit codes: `2` invalid input, `3` model not installed, `4` runtime missing. `decide` never downloads anything.
|
|
198
|
+
|
|
199
|
+
Each plain `decide` invocation is a cold start (model load included, a few seconds) — fine for gates and triage. For repeated calls, start `clef-mcp daemon` once: it keeps the model warm on a permission-scoped unix socket in `CLEF_HOME` (no TCP port, unloads after `CLEF_DAEMON_IDLE` seconds, default 600), and `clef-mcp decide --daemon` answers in well under a second, falling back to a cold run when no daemon is running. See [`examples/hooks/`](examples/hooks/) for a PreToolUse guard and a GitHub Action recipe.
|
|
200
|
+
|
|
181
201
|
## Teach your agent (skill)
|
|
182
202
|
|
|
183
203
|
The schema tells the client *what* `clef_decide` accepts; agents also need to know *when* to reach for it and *how* to frame decisions. The bundled [`clef-decisions`](skills/clef-decisions/SKILL.md) skill covers decision patterns, batching, criteria writing, distribution interpretation and error recovery:
|
|
@@ -210,6 +230,8 @@ The `ClefRuntime` interface (`load / decide / unload / health`) isolates the eng
|
|
|
210
230
|
|
|
211
231
|
```bash
|
|
212
232
|
clef-mcp # run the MCP server on stdio (default command)
|
|
233
|
+
clef-mcp decide # one-shot decision (no MCP session): JSON in, JSON out — for hooks, CI, scripts
|
|
234
|
+
clef-mcp daemon # keep the model warm on a local unix socket; `decide --daemon` uses it
|
|
213
235
|
clef-mcp install # detect hardware → download model + runtime → verify checksum → verify inference
|
|
214
236
|
clef-mcp setup # register the MCP server + agent skill in zcode / claude-code / codex / cursor
|
|
215
237
|
clef-mcp models # list models/quantizations and install status
|
|
@@ -246,6 +268,7 @@ Switch at runtime with `CLEF_RUNTIME=mlx` (must be set for the MCP server proces
|
|
|
246
268
|
| `CLEF_LLAMA_RELEASE_TAG` | latest nightly | Pin the managed llama.cpp build |
|
|
247
269
|
| `CLEF_LLAMA_BATCH` | `8192` | llama.cpp physical batch (multi-question requests) |
|
|
248
270
|
| `CLEF_MLX_UV` | `uv` on PATH | Explicit uv binary (MLX runtime) |
|
|
271
|
+
| `CLEF_DAEMON_IDLE` | `600` | Seconds of idle before the daemon unloads the model (0 = never) |
|
|
249
272
|
| `CLEF_MAX_QUESTIONS` | `64` | Max questions per call |
|
|
250
273
|
| `CLEF_MAX_STATE_BYTES` | `1048576` | Max serialized `state` size |
|
|
251
274
|
| `CLEF_MAX_INSTRUCTION_CHARS` | `10000` | Max chars per question instructions |
|