ceulen 0.15.2 → 0.17.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +1 -1
  3. package/extensions/lib/registry.test.ts +5 -2
  4. package/extensions/lib/registry.ts +9 -3
  5. package/extensions/modules/classifier/index.ts +29 -12
  6. package/extensions/modules/classifier/lib/settings.ts +20 -3
  7. package/extensions/modules/classifier/test/classifier.test.ts +12 -4
  8. package/extensions/modules/config/defaultTools.ts +7 -3
  9. package/extensions/modules/config/test/defaultTools.test.ts +16 -0
  10. package/extensions/modules/gh/lib/ops.ts +22 -4
  11. package/extensions/modules/gh/test/gh.test.ts +64 -1
  12. package/extensions/modules/munin/index.ts +93 -6
  13. package/extensions/modules/munin/test/extension.test.ts +124 -0
  14. package/extensions/modules/plan/index.ts +116 -4
  15. package/extensions/modules/plan/lib/settings.ts +5 -7
  16. package/extensions/modules/plan/test/module.test.ts +104 -1
  17. package/extensions/modules/plan/test/settings.test.ts +7 -0
  18. package/extensions/modules/repair/configPanel.ts +3 -1
  19. package/extensions/modules/repair/index.ts +21 -16
  20. package/extensions/modules/repair/lib/read-sqlite.ts +18 -7
  21. package/extensions/modules/repair/test/freshness.test.ts +30 -0
  22. package/extensions/modules/repair/test/hardening.test.ts +46 -1
  23. package/extensions/modules/repair/test/readers.test.ts +11 -5
  24. package/extensions/modules/repair/test/settings.test.ts +7 -2
  25. package/extensions/modules/rtk/configPanel.ts +67 -0
  26. package/extensions/modules/rtk/index.ts +76 -9
  27. package/extensions/modules/rtk/lib/settings.ts +65 -0
  28. package/extensions/modules/rtk/test/configPanel.test.ts +72 -0
  29. package/extensions/modules/rtk/test/index.test.js +120 -2
  30. package/extensions/modules/rules/index.ts +4 -1
  31. package/extensions/modules/rules/lib/rules.ts +6 -3
  32. package/extensions/modules/rules/test/lib.test.ts +24 -0
  33. package/extensions/modules/rules/test/module.test.ts +29 -0
  34. package/extensions/modules/shells/lib/sessions.ts +40 -12
  35. package/extensions/modules/shells/test/sessions.test.ts +60 -2
  36. package/extensions/modules/steering/index.ts +12 -1
  37. package/extensions/modules/steering/test/anchor-plan.test.ts +73 -0
  38. package/extensions/modules/subagent/index.ts +19 -3
  39. package/extensions/modules/subagent/lib/herdr.ts +141 -1
  40. package/extensions/modules/subagent/lib/runner.ts +88 -22
  41. package/extensions/modules/subagent/test/herdr-stalled.test.ts +117 -0
  42. package/extensions/modules/subagent/test/worktree.test.ts +156 -1
  43. package/extensions/modules/todo/index.ts +4 -0
  44. package/extensions/modules/todo/test/todo.test.ts +9 -0
  45. package/extensions/modules/web/index.ts +1 -1
  46. package/extensions/modules/web/lib/a11y.ts +30 -15
  47. package/extensions/modules/web/lib/cdp.ts +11 -2
  48. package/extensions/modules/web/lib/chrome.ts +12 -3
  49. package/extensions/modules/web/lib/content.ts +32 -9
  50. package/extensions/modules/web/lib/search.ts +111 -3
  51. package/extensions/modules/web/test/a11y.test.ts +100 -2
  52. package/extensions/modules/web/test/cdp.test.ts +48 -0
  53. package/extensions/modules/web/test/chrome.test.ts +32 -0
  54. package/extensions/modules/web/test/content.test.ts +92 -0
  55. package/extensions/modules/web/test/search.test.ts +75 -0
  56. package/package.json +1 -1
  57. package/skills/munin/SKILL.md +1 -1
@@ -0,0 +1,92 @@
1
+ // content module tests — the fetchReadableContent SSRF guard (F5): local URLs
2
+ // refused before any fetch, redirect hops re-validated, public URLs unchanged.
3
+
4
+ import { describe, it, afterEach } from "node:test";
5
+ import assert from "node:assert/strict";
6
+
7
+ import { fetchReadableContent } from "../lib/content";
8
+
9
+ const ORIGINAL_FETCH = globalThis.fetch;
10
+
11
+ /** Track every fetch call; redirect: "manual" is asserted on the request init. */
12
+ function installMockFetch(handler: (url: string, init?: RequestInit) => Response | Promise<Response>): string[] {
13
+ const calls: string[] = [];
14
+ globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {
15
+ const url = String(input);
16
+ calls.push(url);
17
+ return handler(url, init);
18
+ }) as typeof fetch;
19
+ return calls;
20
+ }
21
+
22
+ afterEach(() => {
23
+ globalThis.fetch = ORIGINAL_FETCH;
24
+ });
25
+
26
+ describe("fetchReadableContent SSRF guard", () => {
27
+ it("rejects http://169.254.169.254/ before any fetch (metadata endpoint)", async () => {
28
+ const calls = installMockFetch(() => {
29
+ throw new Error("fetch must never be called for a guarded host");
30
+ });
31
+ await assert.rejects(
32
+ () => fetchReadableContent("http://169.254.169.254/latest/meta-data/"),
33
+ /SSRF-guarded/,
34
+ );
35
+ assert.deepEqual(calls, []);
36
+ });
37
+
38
+ it("rejects http://127.0.0.1/ before any fetch (loopback)", async () => {
39
+ const calls = installMockFetch(() => {
40
+ throw new Error("fetch must never be called for a guarded host");
41
+ });
42
+ await assert.rejects(() => fetchReadableContent("http://127.0.0.1:8080/"), /SSRF-guarded/);
43
+ assert.deepEqual(calls, []);
44
+ });
45
+
46
+ it("refuses a public→169.254.169.254 redirect hop", async () => {
47
+ const calls = installMockFetch((url) => {
48
+ if (url === "https://public.example/start") {
49
+ return new Response(null, { status: 302, headers: { location: "http://169.254.169.254/latest/meta-data/" } });
50
+ }
51
+ throw new Error(`fetch must never follow to ${url}`);
52
+ });
53
+ await assert.rejects(() => fetchReadableContent("https://public.example/start"), /SSRF-guarded/);
54
+ assert.deepEqual(calls, ["https://public.example/start"], "the redirect target is never fetched");
55
+ });
56
+
57
+ it("follows a public→public redirect and extracts the landed page", async () => {
58
+ installMockFetch((url) => {
59
+ if (url === "https://public.example/a") {
60
+ return new Response(null, { status: 301, headers: { location: "https://public.example/b" } });
61
+ }
62
+ if (url === "https://public.example/b") {
63
+ return new Response(
64
+ "<html><head><title>Moved</title></head><body><main><h1>Landed</h1><p>" +
65
+ "This public page carries plenty of readable content so the static extraction path returns it. ".repeat(2) +
66
+ "</p></main></body></html>",
67
+ { status: 200, headers: { "content-type": "text/html" } },
68
+ );
69
+ }
70
+ throw new Error(`unexpected fetch ${url}`);
71
+ });
72
+ const r = await fetchReadableContent("https://public.example/a");
73
+ assert.equal(r.title, "Moved");
74
+ assert.match(r.markdown, /Landed/);
75
+ });
76
+
77
+ it("still extracts a plain public URL (existing static path unchanged)", async () => {
78
+ installMockFetch((url) => {
79
+ if (url === "https://example.com/page") {
80
+ return new Response(
81
+ "<html><head><title>Plain</title></head><body><main><p>" +
82
+ "Ordinary public content, well above the readability floor, extracted through the untouched static path. ".repeat(2) +
83
+ "</p></main></body></html>",
84
+ { status: 200, headers: { "content-type": "text/html" } },
85
+ );
86
+ }
87
+ throw new Error(`unexpected fetch ${url}`);
88
+ });
89
+ const r = await fetchReadableContent("https://example.com/page");
90
+ assert.equal(r.title, "Plain");
91
+ });
92
+ });
@@ -207,4 +207,79 @@ describe("searchWithDiagnostics", () => {
207
207
  assert.equal(lengthOf(calls), 1);
208
208
  });
209
209
 
210
+ it("auto + >=2 backends routes through the classifier when a model resolves", async () => {
211
+ // A fake registry whose classify() always answers brave_first with high
212
+ // confidence — the order flips to precision regardless of the heuristic.
213
+ const registry = {
214
+ findOfType: () => ({ id: "combo/jev", provider: "router" }),
215
+ getModelsOfType: () => [{ id: "combo/jev", provider: "router" }],
216
+ getAvailableOfType: async () => [{ id: "combo/jev", provider: "router" }],
217
+ refresh: async () => {},
218
+ classify: async () => ({
219
+ stopReason: "stop",
220
+ answers: {
221
+ backend_preference: { choice: "brave_first", probabilities: { brave_first: 0.9, searxng_first: 0.1 }, confidence: 0.9 },
222
+ },
223
+ }),
224
+ };
225
+ const calls = installMockFetch((url) => {
226
+ if (url.startsWith("https://api.search.brave.com/")) {
227
+ return jsonResponse({ web: { results: [{ title: "Brave", url: "https://example.com", description: "S" }] } });
228
+ }
229
+ throw new Error(`unexpected fetch ${url}`);
230
+ });
231
+ // A broad query the heuristic would send to searxng first (unique string:
232
+ // the verdict LRU is keyed by query fingerprint and earlier tests run
233
+ // the same broad query without a ctx, which caches the heuristic order).
234
+ const result = await searchWithDiagnostics({ query: "homelab ansible ideas 2026", _ctx: { modelRegistry: registry } });
235
+ assert.equal(result.router, "classifier:jev");
236
+ assert.equal(result.backendOrder[0], "brave");
237
+ assert.equal(result.selectedBackend, "brave");
238
+ assert.ok(lengthOf(calls) >= 1);
239
+ });
240
+
241
+ it("classifier low confidence falls back to the heuristic", async () => {
242
+ const registry = {
243
+ findOfType: () => ({ id: "combo/jev", provider: "router" }),
244
+ getModelsOfType: () => [{ id: "combo/jev", provider: "router" }],
245
+ getAvailableOfType: async () => [{ id: "combo/jev", provider: "router" }],
246
+ refresh: async () => {},
247
+ classify: async () => ({
248
+ stopReason: "stop",
249
+ answers: { backend_preference: { choice: "searxng_first", probabilities: { searxng_first: 0.3, brave_first: 0.2 }, confidence: 0.3 } },
250
+ }),
251
+ };
252
+ const calls = installMockFetch((url) => {
253
+ if (url.startsWith("http://searxng.test/search")) {
254
+ return jsonResponse({ results: [{ title: "SearXNG", url: "https://example.com", content: "Snippet" }] });
255
+ }
256
+ throw new Error(`unexpected fetch ${url}`);
257
+ });
258
+ const result = await searchWithDiagnostics({ query: "homelab ansible ideas", _ctx: { modelRegistry: registry } });
259
+ assert.equal(result.router, "heuristic", "0.3 confidence < 0.6 → heuristic");
260
+ assert.equal(result.backendOrder[0], "searxng");
261
+ assert.ok(includes(calls[0], "searxng.test"));
262
+ });
263
+
264
+ it("explicit backend/engines params report router: explicit and never ask Jev", async () => {
265
+ let classifyCalls = 0;
266
+ const registry = {
267
+ findOfType: () => ({ id: "combo/jev", provider: "router" }),
268
+ getAvailableOfType: async () => [{ id: "combo/jev", provider: "router" }],
269
+ refresh: async () => {},
270
+ classify: async () => { classifyCalls++; throw new Error("must not be called"); },
271
+ };
272
+ installMockFetch((url) => {
273
+ if (url.startsWith("http://searxng.test/search")) {
274
+ return jsonResponse({ results: [{ title: "SearXNG", url: "https://example.com", content: "Snippet" }] });
275
+ }
276
+ throw new Error(`unexpected fetch ${url}`);
277
+ });
278
+ const explicit = await searchWithDiagnostics({ query: "homelab ansible", backend: "searxng", _ctx: { modelRegistry: registry } });
279
+ assert.equal(explicit.router, "explicit");
280
+ const engines = await searchWithDiagnostics({ query: "homelab ansible", engines: "google,github", _ctx: { modelRegistry: registry } });
281
+ assert.equal(engines.router, "explicit");
282
+ assert.equal(classifyCalls, 0);
283
+ });
284
+
210
285
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ceulen",
3
- "version": "0.15.2",
3
+ "version": "0.17.0",
4
4
  "description": "Ceulen — the Pi coding agent, fully dressed: one bundle extension carrying the full toolkit with a single /ceulen config command.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -11,7 +11,7 @@ Use the Munin Pi extension tools to recover and preserve verified project knowle
11
11
 
12
12
  ## How It Works
13
13
 
14
- 1. The ceulen `munin` module provides native tools: `munin_search`, `munin_get`, `munin_store`, `munin_list`, `munin_recent`, `munin_delete`, `munin_capabilities`, `munin_share`.
14
+ 1. The ceulen `munin` module provides native tools: `munin_search`, `munin_get`, `munin_store` (all three always declared), plus `munin_list`, `munin_recent`, `munin_delete`, `munin_capabilities`, `munin_share` (loaded on demand via `tool_search`).
15
15
  2. Config lives at PROJECT level: `/config` → Memory → Munin (saved to `<repo>/.pi/settings.json` under a `munin` section). `MUNIN_API_KEY` / `MUNIN_PROJECT` / `MUNIN_BASE_URL` env vars (incl. trusted `.env.local` / `.env`) override it; a per-call `api_key`/`project`/`base_url` param overrides everything.
16
16
  3. Print readable output by default, or raw JSON via tool details.
17
17
  4. Store only durable knowledge that is verified and useful in a future session.