ceulen 0.14.0 → 0.15.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/CHANGELOG.md +24 -0
- package/README.md +5 -3
- package/extensions/index.ts +33 -1
- package/extensions/lib/registry.ts +31 -52
- package/extensions/modules/a2a/index.ts +0 -9
- package/extensions/modules/a2a/test/extension.test.ts +1 -19
- package/extensions/modules/advisor/commands/advisor.ts +3 -9
- package/extensions/modules/advisor/test/configPanel.test.ts +1 -1
- package/extensions/modules/advisor/test/module.test.ts +0 -11
- package/extensions/modules/classifier/index.ts +0 -3
- package/extensions/modules/composer/test/module.test.ts +0 -22
- package/extensions/modules/config/defaultTools.ts +5 -3
- package/extensions/modules/config/index.ts +18 -204
- package/extensions/modules/config/test/defaultTools.test.ts +3 -4
- package/extensions/modules/config/test/panel.test.ts +9 -72
- package/extensions/modules/fff/index.ts +0 -8
- package/extensions/modules/gh/index.ts +0 -3
- package/extensions/modules/jfind/index.ts +0 -3
- package/extensions/modules/munin/index.ts +5 -7
- package/extensions/modules/notify/index.ts +0 -3
- package/extensions/modules/plan/index.ts +1 -7
- package/extensions/modules/repair/index.ts +0 -8
- package/extensions/modules/rules/index.ts +0 -4
- package/extensions/modules/rules/lib/rules.ts +1 -1
- package/extensions/modules/rules/test/module.test.ts +2 -29
- package/extensions/modules/serena/index.ts +1 -6
- package/extensions/modules/serena/lib/guidance.ts +9 -5
- package/extensions/modules/sg/index.ts +0 -5
- package/extensions/modules/shells/index.ts +0 -2
- package/extensions/modules/steering/lib/think.ts +0 -2
- package/extensions/modules/steering/test/think.test.ts +1 -5
- package/extensions/modules/todo/index.ts +0 -2
- package/extensions/modules/usage/index.ts +19 -9
- package/extensions/modules/usage/test/context.test.ts +18 -7
- package/extensions/modules/ux/index.ts +1 -5
- package/extensions/modules/ux/test/extension.test.ts +0 -5
- package/extensions/modules/web/index.ts +0 -9
- package/extensions/modules/web/test/extension.test.ts +8 -18
- package/package.json +1 -1
- package/extensions/lib/tools.ts +0 -47
- package/extensions/modules/config/test/renderTools.test.ts +0 -71
- package/extensions/modules/config/test/tools.test.ts +0 -146
|
@@ -6,13 +6,14 @@
|
|
|
6
6
|
* and the pi-package (plugins) groups — all categorized under OMP's settings
|
|
7
7
|
* taxonomy (Appearance, Model, Interaction, Context, Tasks, Providers, …).
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* →
|
|
15
|
-
* own try/catch, so
|
|
9
|
+
* Modules are always loaded; the `ceulen.disabled` settings key is a
|
|
10
|
+
* settings.json-only escape hatch read by the bundle entry, never edited here.
|
|
11
|
+
* Cold tools register `exposure: "deferred"` (registry `deferredTools`), so
|
|
12
|
+
* there is no per-module Enable row and no per-tool toggle — /config carries
|
|
13
|
+
* only functional settings. Save routes edited row keys to their owner:
|
|
14
|
+
* `pi.*` → SettingsManager.flush(), `ceulen.plugins.*` → the packages file,
|
|
15
|
+
* `<module>.<key>` → the module's `save()` — each in its own try/catch, so
|
|
16
|
+
* one failure never blocks the others.
|
|
16
17
|
*
|
|
17
18
|
* Naming note: `/settings` is a Pi builtin — an extension command with that
|
|
18
19
|
* name is skipped in autocomplete and renamed (`/settings:1`), never an
|
|
@@ -22,105 +23,10 @@
|
|
|
22
23
|
import { SettingsManager, type ExtensionAPI, type ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
23
24
|
import { builtinToolRows, DEFAULT_TOOLS_PREFIX, nextDefaultTools, startupToolSet, writeDefaultTools } from "./defaultTools.js";
|
|
24
25
|
import { openConfigPanel, row, type PanelGroup } from "../../lib/panel.js";
|
|
25
|
-
import { agentDirs,
|
|
26
|
-
import { readDisabledTools, writeDisabledTools } from "../../lib/tools.js";
|
|
26
|
+
import { agentDirs, MODULES, type ModuleConfig, type ModuleLoadDeps } from "../../lib/registry.js";
|
|
27
27
|
import { buildPiSettingsGroups, isPiKey, PI_TAB_ORDER, type PiMenuLookup } from "./piSettings.js";
|
|
28
28
|
import { buildPluginsGroups, isPluginsKey, openPluginsWorking, savePlugins } from "./plugins.js";
|
|
29
29
|
|
|
30
|
-
export const KILL_SWITCH_PREFIX = "ceulen.disabled.";
|
|
31
|
-
export const TOOL_SWITCH_PREFIX = "ceulen.disabledTools.";
|
|
32
|
-
|
|
33
|
-
/** Display overrides for tool rows whose bare name would not explain itself
|
|
34
|
-
* (the row IS the tool's kill-switch, so it must say what on/off means).
|
|
35
|
-
* Tools without an entry keep the bare tool name — the identity the model
|
|
36
|
-
* sees — with the generic registration description. */
|
|
37
|
-
const TOOL_PRETTY: Record<string, { label: string; description: string }> = {
|
|
38
|
-
advisor: {
|
|
39
|
-
label: "Consult tool",
|
|
40
|
-
description: "Registers the advisor tool so the agent can ask for a second opinion on demand. Off = not registered; the background review is unaffected.",
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/** Read the current kill-switch state as a Set of ENABLED module names. */
|
|
45
|
-
function enabledModules(): Set<string> {
|
|
46
|
-
const disabled = new Set(readDisabled());
|
|
47
|
-
// Core modules are always enabled, whatever a stale settings file says.
|
|
48
|
-
return new Set(MODULES.map((m) => m.name).filter((n) => !disabled.has(n)));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** The module's Enable kill-switch row over a live working Set (toggles
|
|
52
|
-
* mutate it; save diffs it against the persisted state). Lives at the top of
|
|
53
|
-
* the module's own section — the feature is turned on where it is
|
|
54
|
-
* configured. When the effective settings file is the project's, the
|
|
55
|
-
* description discloses where writes land. */
|
|
56
|
-
export function moduleEnableRow(name: string, describe: string, working: Set<string>): ReturnType<typeof row> {
|
|
57
|
-
const where = disabledSource().isProject ? "this project's .pi/settings.json" : "the global settings.json";
|
|
58
|
-
return row(`${KILL_SWITCH_PREFIX}${name}`, "Enabled", "toggle", working.has(name), (v) => {
|
|
59
|
-
if (v) working.add(name);
|
|
60
|
-
else working.delete(name);
|
|
61
|
-
}, {
|
|
62
|
-
description: `${describe} Writes ${where}.`,
|
|
63
|
-
// Sole warning rows: the kill-switch does NOT apply on save — the ⚠
|
|
64
|
-
// marks "needs /reload" against the instant-apply rest.
|
|
65
|
-
warning: "Takes effect after /reload (or restart).",
|
|
66
|
-
defaultValue: true,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** Prepend a module's Enable row to the FIRST group of its contribution. */
|
|
71
|
-
export function withEnableRow(groups: PanelGroup[], name: string, describe: string, working: Set<string>): PanelGroup[] {
|
|
72
|
-
// Core modules are always on — no kill-switch row (nothing to toggle).
|
|
73
|
-
if (isCore(name)) return groups;
|
|
74
|
-
const [first, ...rest] = groups;
|
|
75
|
-
if (!first) return groups;
|
|
76
|
-
return [{ ...first, rows: [moduleEnableRow(name, describe, working), ...first.rows] }, ...rest];
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/** The kill-switch list that results from toggling `working` (enabled set).
|
|
80
|
-
* Pure — exported for tests. Core modules are excluded (never disableable). */
|
|
81
|
-
export function nextDisabled(working: Set<string>): string[] {
|
|
82
|
-
return MODULES.filter((m) => !m.core).map((m) => m.name).filter((n) => !working.has(n));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** One per-tool toggle row (key `ceulen.disabledTools.<tool>` over the given
|
|
86
|
-
* working set of ENABLED tool names). Applied live on save — no /reload. */
|
|
87
|
-
export function moduleToolRow(tool: string, working: Set<string>): ReturnType<typeof row> {
|
|
88
|
-
const pretty = TOOL_PRETTY[tool];
|
|
89
|
-
return row(`${TOOL_SWITCH_PREFIX}${tool}`, pretty?.label ?? tool, "toggle", working.has(tool), (v) => {
|
|
90
|
-
if (v) working.add(tool);
|
|
91
|
-
else working.delete(tool);
|
|
92
|
-
}, {
|
|
93
|
-
description: pretty?.description ?? "Registers the tool inactive when off — applied to this session immediately on save.",
|
|
94
|
-
defaultValue: true,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/** Toggle rows for every tool a module declares. Exported for tests. */
|
|
99
|
-
export function moduleToolRows(tools: string[] | undefined, working: Set<string>): ReturnType<typeof row>[] {
|
|
100
|
-
return (tools ?? []).map((t) => moduleToolRow(t, working));
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/** Append the module's tool rows after its (first-section) rows. A no-op for
|
|
104
|
-
* modules without a `tools` list. Exported for tests. */
|
|
105
|
-
export function withToolRows(groups: PanelGroup[], tools: string[] | undefined, working: Set<string>): PanelGroup[] {
|
|
106
|
-
const rows = moduleToolRows(tools, working);
|
|
107
|
-
if (rows.length === 0) return groups;
|
|
108
|
-
const [first, ...rest] = groups;
|
|
109
|
-
if (!first) return groups;
|
|
110
|
-
return [{ ...first, rows: [...first.rows, ...rows] }, ...rest];
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/** The disabled-tools list that results from toggling `working` (enabled set)
|
|
114
|
-
* across every ceulen-declared tool. Pure — exported for tests. */
|
|
115
|
-
export function nextDisabledTools(working: Set<string>): string[] {
|
|
116
|
-
return MODULES.flatMap((m) => m.tools ?? []).filter((n) => !working.has(n));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/** Every tool name ceulen modules declare. */
|
|
120
|
-
export function allDeclaredTools(): string[] {
|
|
121
|
-
return MODULES.flatMap((m) => m.tools ?? []);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
30
|
/** Apply the disabled-tools list to the LIVE session: drop newly disabled
|
|
125
31
|
* tools, re-activate newly enabled ones (registered tools only — unknown
|
|
126
32
|
* names are ignored by setActiveTools). Exported for tests. */
|
|
@@ -190,12 +96,7 @@ export async function saveContributions(
|
|
|
190
96
|
}
|
|
191
97
|
|
|
192
98
|
function summaryLines(groups: PanelGroup[]): string[] {
|
|
193
|
-
const
|
|
194
|
-
const lines = [
|
|
195
|
-
"── Ceulen config ──",
|
|
196
|
-
`Modules: ${MODULES.map((m) => `${m.name}${enabled.has(m.name) ? "" : " (off)"}`).join(", ")}`,
|
|
197
|
-
"",
|
|
198
|
-
];
|
|
99
|
+
const lines = ["── Ceulen config ──"];
|
|
199
100
|
// Generic row dump per tab/section (label: value) — stays in lockstep with
|
|
200
101
|
// the panel's assembly, pi settings and plugins included.
|
|
201
102
|
let lastTab = "";
|
|
@@ -224,7 +125,7 @@ function summaryLines(groups: PanelGroup[]): string[] {
|
|
|
224
125
|
" /ceulen Module status",
|
|
225
126
|
" /ponytail status Ponytail mode + default",
|
|
226
127
|
"",
|
|
227
|
-
"
|
|
128
|
+
"Escape hatch: `ceulen.disabled` in settings.json (no UI); /reload applies.",
|
|
228
129
|
);
|
|
229
130
|
return lines;
|
|
230
131
|
}
|
|
@@ -235,47 +136,11 @@ export default function configModule(pi: ExtensionAPI, deps?: ModuleLoadDeps): v
|
|
|
235
136
|
// so a save that re-registers a provider stays the owner's claim.
|
|
236
137
|
const factories = deps?.configContribs ?? new Map<string, () => ModuleConfig>();
|
|
237
138
|
|
|
238
|
-
// Where each module's section lives in OMP's taxonomy — pretty section
|
|
239
|
-
// names + icons only; the TAB comes from the registry's `category` (one
|
|
240
|
-
// source: adding a module = one registry entry, no second map to touch).
|
|
241
|
-
// A module WITHOUT a contribution factory (usage, config) renders an
|
|
242
|
-
// Enable-only section here; unknown modules fall back to their own tab so
|
|
243
|
-
// a new module still renders.
|
|
244
|
-
const PRETTY_OF: Record<string, { section: string; icon?: string }> = {
|
|
245
|
-
router: { section: "Router", icon: "🌐" },
|
|
246
|
-
classifier: { section: "Classifier (Jev)", icon: "⚖" },
|
|
247
|
-
advisor: { section: "Advisor", icon: "🧭" },
|
|
248
|
-
steering: { section: "Steering", icon: "🎯" },
|
|
249
|
-
zai: { section: "Z.AI (Anthropic)", icon: "⚡" },
|
|
250
|
-
usage: { section: "Usage footer", icon: "📊" },
|
|
251
|
-
munin: { section: "Munin", icon: "🪶" },
|
|
252
|
-
composer: { section: "Composer", icon: "🎨" },
|
|
253
|
-
ux: { section: "UX discipline", icon: "📐" },
|
|
254
|
-
ponytail: { section: "Ponytail", icon: "🦥" },
|
|
255
|
-
plan: { section: "Plan mode", icon: "🗺️" },
|
|
256
|
-
todo: { section: "Todo", icon: "☑" },
|
|
257
|
-
cron: { section: "Cron", icon: "⏰" },
|
|
258
|
-
attachments: { section: "Attachments", icon: "📎" },
|
|
259
|
-
permission: { section: "Permissions", icon: "🛡" },
|
|
260
|
-
serena: { section: "Serena" },
|
|
261
|
-
repair: { section: "Repair", icon: "🔧" },
|
|
262
|
-
fff: { section: "FFF search" },
|
|
263
|
-
web: { section: "Web", icon: "🌍" },
|
|
264
|
-
gh: { section: "GitHub", icon: "🐙" },
|
|
265
|
-
a2a: { section: "A2A", icon: "📡" },
|
|
266
|
-
rtk: { section: "RTK" },
|
|
267
|
-
config: { section: "Ceulen config", icon: "🧩" },
|
|
268
|
-
};
|
|
269
|
-
const SECTION_OF: Record<string, { tab: string; section: string; icon: string | undefined }> = Object.fromEntries(
|
|
270
|
-
MODULES.map((m) => [m.name, { tab: m.category, section: PRETTY_OF[m.name]?.section ?? m.name, icon: PRETTY_OF[m.name]?.icon }]),
|
|
271
|
-
);
|
|
272
139
|
|
|
273
140
|
pi.registerCommand("config", {
|
|
274
141
|
description: "Central settings panel for all ceulen modules.",
|
|
275
142
|
handler: async (args, ctx) => {
|
|
276
143
|
const sub = String(args ?? "").trim().toLowerCase();
|
|
277
|
-
const workingEnabled = new Set(enabledModules());
|
|
278
|
-
const workingTools = new Set(allDeclaredTools().filter((t) => !readDisabledTools().has(t)));
|
|
279
144
|
const pluginsWorking = openPluginsWorking();
|
|
280
145
|
// Pi core settings: an OWN SettingsManager instance over the same files
|
|
281
146
|
// (typed setters persist to global settings.json with pi's own locking;
|
|
@@ -289,39 +154,16 @@ export default function configModule(pi: ExtensionAPI, deps?: ModuleLoadDeps): v
|
|
|
289
154
|
const initialStartup = startupToolSet(piSettings);
|
|
290
155
|
const workingStartup = new Set(initialStartup);
|
|
291
156
|
|
|
292
|
-
//
|
|
293
|
-
//
|
|
294
|
-
//
|
|
157
|
+
// The loader skips a module named in the `ceulen.disabled` settings
|
|
158
|
+
// escape hatch, so its factory (and section) never renders here — the
|
|
159
|
+
// settings.json key is the only way back, by design (no UI toggles).
|
|
295
160
|
const contributions = [...factories.entries()].map(([name, factory]) => ({ name, cfg: factory() }));
|
|
296
161
|
|
|
297
162
|
// Assemble in OMP taxonomy order: pi settings first (they own the
|
|
298
163
|
// Appearance/Model/Interaction/Context/Shell spine), then ceulen module
|
|
299
|
-
// sections
|
|
164
|
+
// sections (functional rows only — no Enable/tool toggles), then plugins.
|
|
300
165
|
const assemble = (): PanelGroup[] => {
|
|
301
|
-
const
|
|
302
|
-
const modGroups = contributions.flatMap((c) => {
|
|
303
|
-
const section = SECTION_OF[c.name];
|
|
304
|
-
const groups = c.cfg.groups();
|
|
305
|
-
if (!section) return groups;
|
|
306
|
-
const module = MODULES.find((m) => m.name === c.name);
|
|
307
|
-
return withToolRows(withEnableRow(groups, c.name, module?.describe ?? "", workingEnabled), module?.tools, workingTools);
|
|
308
|
-
});
|
|
309
|
-
// Modules with no contribution factory still need their Enable row
|
|
310
|
-
// reachable (usage, config itself) — and a disabled module needs the
|
|
311
|
-
// same synthesized section to be switchable back on. Core modules are
|
|
312
|
-
// always on: no synthesized Enable-only section (their contribution,
|
|
313
|
-
// if any, renders without one).
|
|
314
|
-
for (const m of MODULES) {
|
|
315
|
-
const section = SECTION_OF[m.name];
|
|
316
|
-
if (!section || seen.has(m.name) || m.core) continue;
|
|
317
|
-
modGroups.push({
|
|
318
|
-
key: `ceulen-${m.name}`,
|
|
319
|
-
label: section.section,
|
|
320
|
-
tab: section.tab,
|
|
321
|
-
icon: section.icon,
|
|
322
|
-
rows: [moduleEnableRow(m.name, m.describe ?? "", workingEnabled), ...moduleToolRows(m.tools, workingTools)],
|
|
323
|
-
});
|
|
324
|
-
}
|
|
166
|
+
const modGroups = contributions.flatMap((c) => c.cfg.groups());
|
|
325
167
|
// Plugins' package sections precede the config module's own switch.
|
|
326
168
|
const piGroups = buildPiSettingsGroups(piSettings, piMenuLookup(ctx));
|
|
327
169
|
// Built-in tools lead the Tools tab (before the extension-dirs rows).
|
|
@@ -356,34 +198,6 @@ export default function configModule(pi: ExtensionAPI, deps?: ModuleLoadDeps): v
|
|
|
356
198
|
onSave: async (_saved, edited) => {
|
|
357
199
|
const keys = edited ?? new Set<string>();
|
|
358
200
|
|
|
359
|
-
// Kill-switch first: compare the working Set against what's persisted.
|
|
360
|
-
if ([...keys].some((k) => k.startsWith(KILL_SWITCH_PREFIX))) {
|
|
361
|
-
try {
|
|
362
|
-
const file = writeDisabled(nextDisabled(workingEnabled));
|
|
363
|
-
ctx.ui.notify(`Module kill-switch saved to ${file} — /reload (or restart) to apply.`, "info");
|
|
364
|
-
} catch (e) {
|
|
365
|
-
ctx.ui.notify(`Kill-switch save failed: ${e instanceof Error ? e.message : e}`, "error");
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
if ([...keys].some((k) => k.startsWith(TOOL_SWITCH_PREFIX))) {
|
|
370
|
-
try {
|
|
371
|
-
const before = new Set(allDeclaredTools().filter((t) => !readDisabledTools().has(t)));
|
|
372
|
-
const after = workingTools;
|
|
373
|
-
const file = writeDisabledTools(nextDisabledTools(after));
|
|
374
|
-
applyToolSwitches(pi, before, after);
|
|
375
|
-
const changed = allDeclaredTools().filter((t) => before.has(t) !== after.has(t));
|
|
376
|
-
ctx.ui.notify(
|
|
377
|
-
changed.length > 0
|
|
378
|
-
? `Tools ${changed.map((t) => (after.has(t) ? `+${t}` : `-${t}`)).join(" ")} — saved to ${file}, applied live.`
|
|
379
|
-
: `Tool toggles saved to ${file}.`,
|
|
380
|
-
"info",
|
|
381
|
-
);
|
|
382
|
-
} catch (e) {
|
|
383
|
-
ctx.ui.notify(`Tool toggle save failed: ${e instanceof Error ? e.message : e}`, "error");
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
|
|
387
201
|
// Pi packages (plugins): writes land in the file each entry came from.
|
|
388
202
|
if ([...keys].some(isPluginsKey)) {
|
|
389
203
|
try {
|
|
@@ -396,8 +210,8 @@ export default function configModule(pi: ExtensionAPI, deps?: ModuleLoadDeps): v
|
|
|
396
210
|
}
|
|
397
211
|
}
|
|
398
212
|
|
|
399
|
-
// Module contributions: each isolated — one module's failure must
|
|
400
|
-
// block the others
|
|
213
|
+
// Module contributions: each isolated — one module's failure must
|
|
214
|
+
// never block the others.
|
|
401
215
|
await saveContributions(contributions, keys, ctx);
|
|
402
216
|
|
|
403
217
|
// Pi's built-in tools: persist the selection (stock-equal deletes
|
|
@@ -46,7 +46,7 @@ describe("startupToolSet", () => {
|
|
|
46
46
|
describe("builtinToolRows", () => {
|
|
47
47
|
it("renders one toggle per built-in tool, stock four default-on", () => {
|
|
48
48
|
const rows = builtinToolRows(new Set(startupToolSet(SettingsManager.inMemory())));
|
|
49
|
-
assert.equal(rows.length,
|
|
49
|
+
assert.equal(rows.length, 9, "tool_search has no row — ceulen owns its activation");
|
|
50
50
|
const byKey = new Map(rows.map((r) => [r.key, r]));
|
|
51
51
|
for (const name of STOCK) {
|
|
52
52
|
const r = byKey.get(`${DEFAULT_TOOLS_PREFIX}${name}`)!;
|
|
@@ -77,9 +77,8 @@ describe("nextDefaultTools", () => {
|
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
it("round-trips through the panel state", () => {
|
|
80
|
-
const working = startupToolSet(SettingsManager.inMemory({ defaultTools: ["+codemode"] }));
|
|
81
|
-
|
|
82
|
-
assert.deepEqual(nextDefaultTools(working), [...STOCK, "codemode", "tool_search"]);
|
|
80
|
+
const working = startupToolSet(SettingsManager.inMemory({ defaultTools: ["+codemode", "+grep"] }));
|
|
81
|
+
assert.deepEqual(nextDefaultTools(working), [...STOCK, "grep", "codemode"]);
|
|
83
82
|
});
|
|
84
83
|
});
|
|
85
84
|
|
|
@@ -19,7 +19,7 @@ after(() => {
|
|
|
19
19
|
|
|
20
20
|
const settingsPath = () => join(TMP_HOME, "settings.json");
|
|
21
21
|
|
|
22
|
-
// ── registry: kill-switch read
|
|
22
|
+
// ── registry: kill-switch read + layer precedence (write side deleted with the /config rows) ──
|
|
23
23
|
|
|
24
24
|
describe("registry kill-switch", () => {
|
|
25
25
|
it("readDisabled returns [] when no settings file exists", async () => {
|
|
@@ -28,34 +28,10 @@ describe("registry kill-switch", () => {
|
|
|
28
28
|
assert.deepEqual(readDisabled(), []);
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
it("
|
|
32
|
-
|
|
33
|
-
const { readDisabled
|
|
34
|
-
const written = writeDisabled(["ponytail"]);
|
|
35
|
-
assert.equal(written, settingsPath());
|
|
31
|
+
it("readDisabled honors a hand-written settings escape hatch and maps the deprecated sub alias", async () => {
|
|
32
|
+
writeFileSync(settingsPath(), JSON.stringify({ ceulen: { disabled: ["sub", "ponytail"] } }));
|
|
33
|
+
const { readDisabled } = await import("../../../lib/registry.js");
|
|
36
34
|
assert.deepEqual(readDisabled(), ["ponytail"]);
|
|
37
|
-
assert.equal(disabledSource().isProject, false);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("writeDisabled merges — unrelated keys survive, tmp residue cleaned", async () => {
|
|
41
|
-
writeFileSync(settingsPath(), JSON.stringify({ theme: "dark", ceulen: { disabled: ["usage"] } }));
|
|
42
|
-
const inoBefore = statSync(settingsPath()).ino;
|
|
43
|
-
const { writeDisabled } = await import("../../../lib/registry.js");
|
|
44
|
-
writeDisabled(["ponytail"]);
|
|
45
|
-
const json = JSON.parse(readFileSync(settingsPath(), "utf8"));
|
|
46
|
-
assert.equal(json.theme, "dark");
|
|
47
|
-
assert.deepEqual(json.ceulen.disabled, ["ponytail"]);
|
|
48
|
-
assert.notEqual(inoBefore, statSync(settingsPath()).ino); // tmp+rename atomic
|
|
49
|
-
assert.ok(!existsSync(settingsPath() + ".tmp"));
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("writeDisabled refuses to clobber a corrupt settings.json", async () => {
|
|
53
|
-
writeFileSync(settingsPath(), '{ "ceulen": { "disabled": ["usage"] }\nOOPS');
|
|
54
|
-
const before = readFileSync(settingsPath(), "utf8");
|
|
55
|
-
const { writeDisabled } = await import("../../../lib/registry.js");
|
|
56
|
-
assert.throws(() => writeDisabled(["ponytail"]), /not valid JSON/);
|
|
57
|
-
assert.equal(readFileSync(settingsPath(), "utf8"), before);
|
|
58
|
-
assert.ok(!existsSync(settingsPath() + ".tmp"));
|
|
59
35
|
});
|
|
60
36
|
|
|
61
37
|
it("deprecated \"sub\" alias still maps (to the now-core usage module, so it disables nothing)", async () => {
|
|
@@ -78,29 +54,22 @@ describe("registry kill-switch", () => {
|
|
|
78
54
|
writeFileSync(join(TMP_HOME, "trust.json"), JSON.stringify({ [projectCwd]: true }));
|
|
79
55
|
});
|
|
80
56
|
|
|
81
|
-
it("project ceulen section wins the read
|
|
57
|
+
it("project ceulen section wins the read", async () => {
|
|
82
58
|
writeFileSync(settingsPath(), JSON.stringify({ ceulen: { disabled: ["usage"] } }));
|
|
83
59
|
writeFileSync(projectSettings, JSON.stringify({ ceulen: { disabled: ["ponytail"] } }));
|
|
84
|
-
const { readDisabled,
|
|
60
|
+
const { readDisabled, disabledSource } = await import("../../../lib/registry.js");
|
|
85
61
|
|
|
86
62
|
assert.deepEqual(readDisabled(projectCwd), ["ponytail"]); // project wins
|
|
87
63
|
const source = disabledSource(projectCwd);
|
|
88
64
|
assert.equal(source.path, projectSettings);
|
|
89
65
|
assert.equal(source.isProject, true);
|
|
90
|
-
|
|
91
|
-
const written = writeDisabled(["munin"], projectCwd);
|
|
92
|
-
assert.equal(written, projectSettings, "write lands where the read resolves — never shadowed");
|
|
93
|
-
assert.deepEqual(readDisabled(projectCwd), ["munin"]);
|
|
94
|
-
// Global file untouched by the project-scoped write.
|
|
95
|
-
assert.deepEqual(JSON.parse(readFileSync(settingsPath(), "utf8")).ceulen.disabled, ["usage"]);
|
|
96
66
|
});
|
|
97
67
|
|
|
98
|
-
it("project file WITHOUT a ceulen section does not
|
|
68
|
+
it("project file WITHOUT a ceulen section does not claim the key", async () => {
|
|
99
69
|
writeFileSync(projectSettings, JSON.stringify({ router: { baseUrl: "http://x" } }));
|
|
100
70
|
try { unlinkSync(settingsPath()); } catch { /* ignore */ }
|
|
101
|
-
const {
|
|
71
|
+
const { disabledSource } = await import("../../../lib/registry.js");
|
|
102
72
|
assert.equal(disabledSource(projectCwd).isProject, false);
|
|
103
|
-
assert.equal(writeDisabled(["usage"], projectCwd), settingsPath());
|
|
104
73
|
});
|
|
105
74
|
});
|
|
106
75
|
});
|
|
@@ -128,37 +97,6 @@ describe("config module", () => {
|
|
|
128
97
|
};
|
|
129
98
|
};
|
|
130
99
|
|
|
131
|
-
it("moduleEnableRow toggles mutate the working set; nextDisabled inverts it", async () => {
|
|
132
|
-
const { moduleEnableRow, nextDisabled } = await import("../index.js");
|
|
133
|
-
const { MODULES } = await import("../../../lib/registry.js");
|
|
134
|
-
const working = new Set(MODULES.map((m) => m.name));
|
|
135
|
-
const enable = moduleEnableRow("ponytail", "Lazy mode.", working);
|
|
136
|
-
assert.equal(enable.key, "ceulen.disabled.ponytail");
|
|
137
|
-
assert.equal(enable.defaultValue, true);
|
|
138
|
-
|
|
139
|
-
// Toggle "ponytail" off via its row setter.
|
|
140
|
-
assert.equal(enable.value, true);
|
|
141
|
-
enable.set(false);
|
|
142
|
-
assert.equal(working.has("ponytail"), false);
|
|
143
|
-
assert.deepEqual(nextDisabled(working), ["ponytail"]);
|
|
144
|
-
|
|
145
|
-
enable.set(true);
|
|
146
|
-
assert.deepEqual(nextDisabled(working), []);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it("withEnableRow prepends the Enable row to the module's FIRST section only", async () => {
|
|
150
|
-
const { withEnableRow } = await import("../index.js");
|
|
151
|
-
const { MODULES } = await import("../../../lib/registry.js");
|
|
152
|
-
const working = new Set(MODULES.map((m) => m.name));
|
|
153
|
-
const groups = [
|
|
154
|
-
{ key: "a", label: "Ponytail", tab: "Tasks", rows: [{ key: "ponytail.defaultMode" }] },
|
|
155
|
-
{ key: "b", label: "Models", tab: "Tasks", rows: [{ key: "ponytail.quietStartup" }] },
|
|
156
|
-
] as never;
|
|
157
|
-
const out = withEnableRow(groups, "ponytail", "Lazy mode.", working);
|
|
158
|
-
assert.deepEqual(out[0]!.rows.map((r) => r.key), ["ceulen.disabled.ponytail", "ponytail.defaultMode"]);
|
|
159
|
-
assert.deepEqual(out[1]!.rows.map((r) => r.key), ["ponytail.quietStartup"], "second section untouched");
|
|
160
|
-
});
|
|
161
|
-
|
|
162
100
|
it("saveContributions: only edited-key owners are invoked, and a thrower doesn't block siblings", async () => {
|
|
163
101
|
const { saveContributions } = await import("../index.js");
|
|
164
102
|
const calls: string[] = [];
|
|
@@ -249,9 +187,8 @@ describe("config module", () => {
|
|
|
249
187
|
registerCommand: (_name: string, opts: { handler: typeof handler }) => { handler = opts.handler; },
|
|
250
188
|
} as never;
|
|
251
189
|
const factories = new Map<string, () => never>([
|
|
252
|
-
// Router is core, so its Providers section comes from its OWN
|
|
253
|
-
// contribution (there is no synthesized Enable-only section).
|
|
254
190
|
[
|
|
191
|
+
|
|
255
192
|
"router",
|
|
256
193
|
() => ({
|
|
257
194
|
groups: () => [
|
|
@@ -32,7 +32,6 @@ import { closeSync, fstatSync, openSync, readSync, statSync } from "node:fs";
|
|
|
32
32
|
import path from "node:path";
|
|
33
33
|
import { StringDecoder } from "node:string_decoder";
|
|
34
34
|
import { buildQuery, normalizeExcludes, normalizePathConstraint } from "./lib/query";
|
|
35
|
-
import { readDisabledTools } from "../../lib/tools";
|
|
36
35
|
|
|
37
36
|
// ---------------------------------------------------------------------------
|
|
38
37
|
// Constants
|
|
@@ -426,7 +425,6 @@ export default function fffExtension(pi: ExtensionAPI) {
|
|
|
426
425
|
let enableFsRootScanning = false;
|
|
427
426
|
let toolsRegistered = false;
|
|
428
427
|
let autocompleteRegistered = false;
|
|
429
|
-
let disabledTools: Set<string> = new Set();
|
|
430
428
|
// Names registerBoundedTool could not claim this session (another
|
|
431
429
|
// extension's guarded() owns them). One dim note after the loop instead of
|
|
432
430
|
// a first-throw unwind — a single collision must not cost the whole toolset.
|
|
@@ -1009,7 +1007,6 @@ export default function fffExtension(pi: ExtensionAPI) {
|
|
|
1009
1007
|
function registerTools() {
|
|
1010
1008
|
if (toolsRegistered) return;
|
|
1011
1009
|
toolsRegistered = true;
|
|
1012
|
-
disabledTools = readDisabledTools();
|
|
1013
1010
|
skippedTools = [];
|
|
1014
1011
|
|
|
1015
1012
|
// --- Shared render helpers ---
|
|
@@ -1054,13 +1051,8 @@ export default function fffExtension(pi: ExtensionAPI) {
|
|
|
1054
1051
|
|
|
1055
1052
|
const registerOneBoundedTool = (tool: any) => {
|
|
1056
1053
|
const execute = tool.execute;
|
|
1057
|
-
// Per-tool kill-switch (ceulen.disabledTools): rows use canonical names
|
|
1058
|
-
// (ffgrep/fffind); override mode registers grep/find, so map before the
|
|
1059
|
-
// defaultActive check. /config re-activates disabled tools live.
|
|
1060
|
-
const canonical = tool.name === "grep" ? "ffgrep" : tool.name === "find" ? "fffind" : tool.name;
|
|
1061
1054
|
pi.registerTool({
|
|
1062
1055
|
...tool,
|
|
1063
|
-
defaultActive: !disabledTools.has(canonical),
|
|
1064
1056
|
async execute(...args: any[]) {
|
|
1065
1057
|
const result = await execute(...args);
|
|
1066
1058
|
let truncation: TruncationResult | undefined;
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
|
|
13
13
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
14
14
|
import { Type } from "typebox";
|
|
15
|
-
import { readDisabledTools } from "../../lib/tools.js";
|
|
16
15
|
import { ghAvailable, realGh } from "./lib/gh-cli.js";
|
|
17
16
|
import { executeOp } from "./lib/ops.js";
|
|
18
17
|
|
|
@@ -40,7 +39,6 @@ export default function ghModule(pi: ExtensionAPI): void {
|
|
|
40
39
|
// stays registered in the loader) so installing gh + /reload activates it.
|
|
41
40
|
if (!ghAvailable()) return;
|
|
42
41
|
|
|
43
|
-
const disabled = readDisabledTools();
|
|
44
42
|
pi.registerTool({
|
|
45
43
|
name: "github",
|
|
46
44
|
label: "GitHub",
|
|
@@ -81,6 +79,5 @@ export default function ghModule(pi: ExtensionAPI): void {
|
|
|
81
79
|
return { content: [{ type: "text", text: err instanceof Error ? err.message : String(err) }], isError: true, details: undefined };
|
|
82
80
|
}
|
|
83
81
|
},
|
|
84
|
-
defaultActive: !disabled.has("github"),
|
|
85
82
|
});
|
|
86
83
|
}
|
|
@@ -6,7 +6,6 @@ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
|
6
6
|
import { existsSync, statSync } from "node:fs";
|
|
7
7
|
import { resolve as resolvePath } from "node:path";
|
|
8
8
|
import { Type } from "typebox";
|
|
9
|
-
import { readDisabledTools } from "../../lib/tools.js";
|
|
10
9
|
import { formatBytes } from "./lib/format.js";
|
|
11
10
|
import { runCascade, FIND_TIMEOUT_MS, type CascadeResult } from "./lib/cascade.js";
|
|
12
11
|
import { createJudge } from "./lib/judge.js";
|
|
@@ -20,11 +19,9 @@ function formatBytesCeulen(bytes: number): string {
|
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
export default function jfindModule(pi: ExtensionAPI): void {
|
|
23
|
-
const disabled = readDisabledTools();
|
|
24
22
|
pi.registerTool({
|
|
25
23
|
name: "jfind",
|
|
26
24
|
label: "Semantic Find",
|
|
27
|
-
defaultActive: !disabled.has("jfind"),
|
|
28
25
|
description:
|
|
29
26
|
"Semantic code find: describe a BEHAVIOR (\"where do we parse CLI flags\", \"retry with backoff around provider calls\") and get the files and line ranges that implement it, strongest first. " +
|
|
30
27
|
"A lexical keyword scan ranks candidates, then a System One judge (the router's classifier models) ranks filenames, passage sketches, and full passages in three waves. " +
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//
|
|
3
3
|
// Ported from @bacnh85/pi-munin 0.5.12 extensions/index.ts (SDK vendored to
|
|
4
4
|
// lib/sdk.ts; dotenv dropped — ceulen's bundle env.ts ingests trusted .env).
|
|
5
|
-
// Registers the 8 munin_* tools (
|
|
5
|
+
// Registers the 8 munin_* tools (all deferred — tool_search loads them),
|
|
6
6
|
// /munin-status, the Munin Memory Protocol injection (only when configured),
|
|
7
7
|
// the tool_result error sanitizer, and the munin skill (resources_discover).
|
|
8
8
|
// Config lives at PROJECT level (.pi/settings.json `munin` section) — see
|
|
@@ -35,7 +35,6 @@ import {
|
|
|
35
35
|
type Remediation,
|
|
36
36
|
} from "./lib/helpers.js";
|
|
37
37
|
import { withRetry } from "./lib/retry.js";
|
|
38
|
-
import { readDisabledTools } from "../../lib/tools.js";
|
|
39
38
|
import { skillsRoot } from "../../lib/skill-path.js";
|
|
40
39
|
|
|
41
40
|
// Shared schemas — per-call overrides (params win over env/settings).
|
|
@@ -69,7 +68,9 @@ const MUNIN_PROTOCOL_HEADER = `## Munin Memory Protocol
|
|
|
69
68
|
|
|
70
69
|
Use Munin to recover and preserve verified project knowledge, not as a task log.
|
|
71
70
|
If Munin is unavailable, state that briefly when it matters and continue from
|
|
72
|
-
repository evidence.
|
|
71
|
+
repository evidence. The munin_* tools are deferred: if none are declared yet,
|
|
72
|
+
load them with one tool_search call for "munin" (they stay declared for the
|
|
73
|
+
rest of the session).
|
|
73
74
|
|
|
74
75
|
### Before acting
|
|
75
76
|
|
|
@@ -576,11 +577,8 @@ export default function muninExtension(pi: ExtensionAPI) {
|
|
|
576
577
|
skillPaths: [path.join(skillsRoot(), "munin")],
|
|
577
578
|
}));
|
|
578
579
|
|
|
579
|
-
// Per-tool kill-switch (ceulen.disabledTools): listed tools register
|
|
580
|
-
// inactive — /config re-activates them live via setActiveTools.
|
|
581
|
-
const disabled = readDisabledTools();
|
|
582
580
|
for (const tool of makeTools()) {
|
|
583
|
-
pi.registerTool(
|
|
581
|
+
pi.registerTool(tool as AnyTool);
|
|
584
582
|
}
|
|
585
583
|
|
|
586
584
|
pi.registerCommand("munin-status", {
|
|
@@ -5,11 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
7
7
|
import { Type } from "typebox";
|
|
8
|
-
import { readDisabledTools } from "../../lib/tools.js";
|
|
9
8
|
import { notify } from "./lib/notify.js";
|
|
10
9
|
|
|
11
10
|
export default function notifyModule(pi: ExtensionAPI): void {
|
|
12
|
-
const disabled = readDisabledTools();
|
|
13
11
|
pi.registerTool({
|
|
14
12
|
name: "notify",
|
|
15
13
|
label: "Notify",
|
|
@@ -28,6 +26,5 @@ export default function notifyModule(pi: ExtensionAPI): void {
|
|
|
28
26
|
if (r.note) text += `\n${r.note}`;
|
|
29
27
|
return { content: [{ type: "text", text }], details: { via: r.via } };
|
|
30
28
|
},
|
|
31
|
-
defaultActive: !disabled.has("notify"),
|
|
32
29
|
});
|
|
33
30
|
}
|
|
@@ -52,7 +52,6 @@ import {
|
|
|
52
52
|
type ThinkingLevel,
|
|
53
53
|
} from "./lib/settings.js";
|
|
54
54
|
import { getPlanRegistry, planConfig, setPlanBridge, setPlanRegistry, type PlanBridge } from "./configPanel.js";
|
|
55
|
-
import { readDisabledTools } from "../../lib/tools.js";
|
|
56
55
|
// Sandbox semantics live in ONE place: the subagent module resolves agent
|
|
57
56
|
// frontmatter (user + project + bundled). discoverAgents is a pure fs loader,
|
|
58
57
|
// independent of whether the subagent module itself is enabled.
|
|
@@ -165,10 +164,7 @@ export default function planModule(pi: ExtensionAPI): void {
|
|
|
165
164
|
let planReadyForReview = false;
|
|
166
165
|
let applyingStoredModel = false;
|
|
167
166
|
let writePlanInProgress = false;
|
|
168
|
-
|
|
169
|
-
* be silently undone by entering plan mode. */
|
|
170
|
-
const planToolsAvailable = (): string[] =>
|
|
171
|
-
[PLAN_TOOL, ASK_USER_QUESTION_TOOL].filter((t) => !readDisabledTools().has(t));
|
|
167
|
+
const planToolsAvailable = (): string[] => [PLAN_TOOL, ASK_USER_QUESTION_TOOL];
|
|
172
168
|
|
|
173
169
|
// ── State / settings ────────────────────────────────────────
|
|
174
170
|
|
|
@@ -594,7 +590,6 @@ export default function planModule(pi: ExtensionAPI): void {
|
|
|
594
590
|
`Use ${PLAN_TOOL} in plan mode after exploration. No edit/write until the plan is approved.`,
|
|
595
591
|
`Don't call ${PLAN_TOOL} while blocking questions remain; use ${ASK_USER_QUESTION_TOOL} first.`,
|
|
596
592
|
],
|
|
597
|
-
defaultActive: !readDisabledTools().has(PLAN_TOOL),
|
|
598
593
|
parameters: Type.Object({
|
|
599
594
|
title: Type.Optional(Type.String({ description: "Short plan title. Optional: derived from the first '# Heading' in content when omitted." })),
|
|
600
595
|
content: Type.String({ description: "Markdown plan content" }),
|
|
@@ -617,7 +612,6 @@ export default function planModule(pi: ExtensionAPI): void {
|
|
|
617
612
|
"Provide a recommended option when one choice is clearly preferable.",
|
|
618
613
|
`Never issue multiple ${ASK_USER_QUESTION_TOOL} calls in the same turn — ask one question, await the answer, then decide.`,
|
|
619
614
|
],
|
|
620
|
-
defaultActive: !readDisabledTools().has(ASK_USER_QUESTION_TOOL),
|
|
621
615
|
parameters: Type.Object({
|
|
622
616
|
question: Type.String({ description: "Question to ask the user" }),
|
|
623
617
|
options: Type.Array(
|