ceulen 0.10.1 โ†’ 0.12.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 (69) hide show
  1. package/CHANGELOG.md +107 -1
  2. package/README.md +56 -1
  3. package/extensions/index.ts +5 -1
  4. package/extensions/lib/env.test.ts +147 -0
  5. package/extensions/lib/env.ts +180 -0
  6. package/extensions/lib/order.test.ts +74 -0
  7. package/extensions/lib/plan-bridge.ts +18 -0
  8. package/extensions/lib/registry.test.ts +8 -5
  9. package/extensions/lib/registry.ts +22 -3
  10. package/extensions/modules/a2a/configPanel.ts +42 -1
  11. package/extensions/modules/a2a/index.ts +4 -2
  12. package/extensions/modules/a2a/lib/config.ts +8 -3
  13. package/extensions/modules/a2a/test/configPanel.test.ts +7 -4
  14. package/extensions/modules/advisor/index.ts +6 -3
  15. package/extensions/modules/advisor/test/module.test.ts +31 -0
  16. package/extensions/modules/attachments/configPanel.ts +91 -0
  17. package/extensions/modules/attachments/index.ts +274 -0
  18. package/extensions/modules/attachments/lib/clipboard-files.ts +80 -0
  19. package/extensions/modules/attachments/lib/pastes.ts +45 -0
  20. package/extensions/modules/attachments/lib/paths.ts +74 -0
  21. package/extensions/modules/attachments/lib/registry.ts +70 -0
  22. package/extensions/modules/attachments/lib/settings.ts +99 -0
  23. package/extensions/modules/attachments/lib/tray.ts +74 -0
  24. package/extensions/modules/attachments/test/configPanel.test.ts +122 -0
  25. package/extensions/modules/attachments/test/index.test.ts +870 -0
  26. package/extensions/modules/attachments/test/module.test.ts +53 -0
  27. package/extensions/modules/classifier/index.ts +55 -1
  28. package/extensions/modules/classifier/test/classifier.test.ts +62 -0
  29. package/extensions/modules/composer/test/module.test.ts +2 -2
  30. package/extensions/modules/config/index.ts +3 -0
  31. package/extensions/modules/config/test/renderTools.test.ts +1 -1
  32. package/extensions/modules/cron/configPanel.ts +103 -0
  33. package/extensions/modules/cron/index.ts +638 -0
  34. package/extensions/modules/cron/lib/jobs.ts +201 -0
  35. package/extensions/modules/cron/lib/schedule.ts +161 -0
  36. package/extensions/modules/cron/test/cwd-repro.test.ts +98 -0
  37. package/extensions/modules/cron/test/index.test.ts +859 -0
  38. package/extensions/modules/cron/test/schedule.test.ts +93 -0
  39. package/extensions/modules/munin/index.ts +3 -1
  40. package/extensions/modules/permission/index.ts +567 -0
  41. package/extensions/modules/permission/test/permission.test.ts +789 -0
  42. package/extensions/modules/plan/index.ts +5 -0
  43. package/extensions/modules/repair/index.ts +160 -5
  44. package/extensions/modules/repair/test/freshness.test.ts +209 -0
  45. package/extensions/modules/repair/test/guard-selector.test.ts +67 -0
  46. package/extensions/modules/router/configPanel.ts +4 -4
  47. package/extensions/modules/router/index.ts +1 -1
  48. package/extensions/modules/router/lib/config.ts +9 -4
  49. package/extensions/modules/router/lib/systemone.ts +17 -4
  50. package/extensions/modules/router/test/unit.test.ts +46 -1
  51. package/extensions/modules/rules/index.ts +13 -3
  52. package/extensions/modules/rules/lib/rules.ts +24 -12
  53. package/extensions/modules/rules/test/lib.test.ts +20 -0
  54. package/extensions/modules/rules/test/module.test.ts +21 -0
  55. package/extensions/modules/subagent/index.ts +49 -10
  56. package/extensions/modules/subagent/lib/herdr.ts +5 -0
  57. package/extensions/modules/subagent/lib/routing.ts +31 -8
  58. package/extensions/modules/subagent/lib/runner.ts +356 -14
  59. package/extensions/modules/subagent/test/routing.test.ts +45 -0
  60. package/extensions/modules/subagent/test/worktree.test.ts +230 -0
  61. package/extensions/modules/usage/index.ts +193 -71
  62. package/extensions/modules/usage/test/context.test.ts +160 -120
  63. package/extensions/modules/web/configPanel.ts +67 -8
  64. package/extensions/modules/web/index.ts +3 -1
  65. package/extensions/modules/web/test/a11y.test.ts +1 -1
  66. package/extensions/modules/web/test/configPanel.test.ts +7 -3
  67. package/extensions/modules/web/test/settings.test.ts +6 -0
  68. package/package.json +2 -2
  69. package/skills/cron/SKILL.md +58 -0
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Pending-attachment tray: holds files queued by drag-drop paste / clipboard
3
+ * paste until submit. The tray renders as a single chip line above the editor;
4
+ * on submit the input hook swaps the [[attach:name]] tokens for real content.
5
+ */
6
+
7
+ import { basename } from "node:path";
8
+
9
+ export interface PendingAttachment {
10
+ /** [[attach:name]] token inserted into the editor text (filename-based). */
11
+ token: string;
12
+ path: string;
13
+ /** Display name used inside the token (unique across the tray). */
14
+ name: string;
15
+ /** Optional detail appended to the ๐Ÿ“Ž chip at submit (e.g. paste line count). */
16
+ hint?: string;
17
+ }
18
+
19
+ export class AttachmentTray {
20
+ private items: PendingAttachment[] = [];
21
+
22
+ add(path: string, hint?: string): PendingAttachment {
23
+ const name = this.uniqueName(basename(path));
24
+ const item: PendingAttachment = { token: `[[attach:${name}]]`, path, name };
25
+ if (hint) item.hint = hint;
26
+ this.items.push(item);
27
+ return item;
28
+ }
29
+
30
+ /** Resolve tokens still present in submitted text; returns kept items in order. */
31
+ resolve(text: string): PendingAttachment[] {
32
+ return this.items.filter((i) => text.includes(i.token));
33
+ }
34
+
35
+ /** Replace every live [[attach:name]] token in text with the real path (for the input hook). */
36
+ expand(text: string): string {
37
+ let out = text;
38
+ for (const i of this.items) {
39
+ if (out.includes(i.token)) out = out.split(i.token).join(i.path);
40
+ }
41
+ return out;
42
+ }
43
+
44
+ /** Drop items whose tokens are gone from the editor (user deleted them). */
45
+ prune(editorText: string): void {
46
+ this.items = this.items.filter((i) => editorText.includes(i.token));
47
+ }
48
+
49
+ clear(): void {
50
+ this.items = [];
51
+ }
52
+
53
+ get size(): number {
54
+ return this.items.length;
55
+ }
56
+
57
+ /** Single chip line: ๐Ÿ“Ž demo.jpeg ยท C601079.pdf */
58
+ render(): string[] {
59
+ if (this.items.length === 0) return [];
60
+ return [`๐Ÿ“Ž ${this.items.map((i) => i.name).join(" ยท ")}`];
61
+ }
62
+
63
+ /** First basename is used as-is; duplicates get -2, -3โ€ฆ before the extension. */
64
+ private uniqueName(base: string): string {
65
+ if (!this.items.some((i) => i.name === base)) return base;
66
+ const dot = base.lastIndexOf(".");
67
+ const stem = dot > 0 ? base.slice(0, dot) : base;
68
+ const ext = dot > 0 ? base.slice(dot) : "";
69
+ for (let n = 2; ; n++) {
70
+ const candidate = `${stem}-${n}${ext}`;
71
+ if (!this.items.some((i) => i.name === candidate)) return candidate;
72
+ }
73
+ }
74
+ }
@@ -0,0 +1,122 @@
1
+ // attachments' /config contribution: row keys + Files tab, save routing
2
+ // (only attachments.* edits persist, working copy driven via row.set()),
3
+ // and the corrupt-file guard.
4
+ import assert from "node:assert/strict";
5
+ import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
6
+ import { tmpdir } from "node:os";
7
+ import { join } from "node:path";
8
+ import { after, beforeEach, describe, it } from "node:test";
9
+ import { applyRows } from "../../../lib/panel.js";
10
+ import { attachmentsConfig, buildAttachmentsGroups } from "../configPanel.js";
11
+ import { DEFAULTS, loadSettings } from "../lib/settings.js";
12
+
13
+ const realAgentDir = process.env.PI_CODING_AGENT_DIR;
14
+ let AGENT: string;
15
+
16
+ beforeEach(() => {
17
+ AGENT = mkdtempSync(join(tmpdir(), "ceulen-att-cfg-"));
18
+ process.env.PI_CODING_AGENT_DIR = AGENT;
19
+ });
20
+
21
+ after(() => {
22
+ if (realAgentDir === undefined) delete process.env.PI_CODING_AGENT_DIR;
23
+ else process.env.PI_CODING_AGENT_DIR = realAgentDir;
24
+ });
25
+
26
+ const fakeCtx = (notified: string[] = []): any => ({
27
+ cwd: AGENT,
28
+ ui: { notify: (message: string) => { notified.push(message); } },
29
+ });
30
+
31
+ describe("attachments config panel", () => {
32
+ it("rows: the five attachments keys on the Files tab", () => {
33
+ const groups = buildAttachmentsGroups({ ...DEFAULTS });
34
+ assert.equal(groups.length, 1);
35
+ const group = groups[0];
36
+ assert.equal(group.tab, "Files");
37
+ assert.equal(group.label, "Attachments");
38
+ assert.deepEqual(
39
+ group.rows.map((r) => r.key),
40
+ [
41
+ "attachments.inlineTextFiles",
42
+ "attachments.maxInlineBytes",
43
+ "attachments.pasteFileShortcut",
44
+ "attachments.pasteCollapseLines",
45
+ "attachments.pasteCollapseChars",
46
+ ],
47
+ );
48
+ assert.equal(group.rows[0].kind, "toggle");
49
+ // The shortcut row carries the load-bound restart warning.
50
+ assert.match(group.rows[2].warning ?? "", /restart/i);
51
+ });
52
+
53
+ it("applyRows round-trips a working copy", () => {
54
+ const cfg = { ...DEFAULTS };
55
+ const groups = buildAttachmentsGroups(cfg);
56
+ const byKey = new Map(groups[0].rows.map((r) => [r.key, r]));
57
+ byKey.get("attachments.inlineTextFiles")!.set(true);
58
+ byKey.get("attachments.maxInlineBytes")!.set(5_000);
59
+ byKey.get("attachments.pasteCollapseLines")!.set(0);
60
+ applyRows(cfg, groups);
61
+ assert.equal(cfg.inlineTextFiles, true);
62
+ assert.equal(cfg.maxInlineBytes, 5_000);
63
+ assert.equal(cfg.pasteCollapseLines, 0);
64
+ assert.equal(cfg.pasteCollapseChars, DEFAULTS.pasteCollapseChars, "untouched field stays default");
65
+ });
66
+
67
+ it("save persists edited keys to the GLOBAL attachments section (rows driven first)", async () => {
68
+ mkdirSync(AGENT, { recursive: true });
69
+ writeFileSync(join(AGENT, "settings.json"), JSON.stringify({ attachments: { pasteCollapseChars: 999 } }));
70
+ const config = attachmentsConfig();
71
+ // Drive the factory's OWN working copy through the row setters โ€” a save
72
+ // without set() would persist the fresh-from-disk defaults, not the edit.
73
+ const byKey = new Map(config.groups()[0].rows.map((r) => [r.key, r]));
74
+ byKey.get("attachments.inlineTextFiles")!.set(true);
75
+ byKey.get("attachments.maxInlineBytes")!.set(5_000);
76
+ await config.save(new Set(["attachments.inlineTextFiles", "attachments.maxInlineBytes"]), fakeCtx());
77
+ const raw = JSON.parse(readFileSync(join(AGENT, "settings.json"), "utf8"));
78
+ assert.equal(raw.attachments.inlineTextFiles, true);
79
+ assert.equal(raw.attachments.maxInlineBytes, 5_000);
80
+ assert.equal(raw.attachments.pasteCollapseChars, 999, "unrelated sibling key untouched");
81
+ });
82
+
83
+ it("save no-ops when no owned key was edited", async () => {
84
+ const config = attachmentsConfig();
85
+ const before = readSettingsIfExists();
86
+ await config.save(new Set(["plan.savePlans"]), fakeCtx());
87
+ assert.equal(readSettingsIfExists(), before, "file untouched");
88
+ });
89
+
90
+ it("loadSettings round-trips a written section", () => {
91
+ mkdirSync(AGENT, { recursive: true });
92
+ writeFileSync(
93
+ join(AGENT, "settings.json"),
94
+ JSON.stringify({ attachments: { inlineTextFiles: true, pasteCollapseLines: 42 } }),
95
+ );
96
+ const s = loadSettings();
97
+ assert.equal(s.inlineTextFiles, true);
98
+ assert.equal(s.pasteCollapseLines, 42);
99
+ assert.equal(s.pasteFileShortcut, DEFAULTS.pasteFileShortcut, "unset field falls back");
100
+ });
101
+
102
+ it("corrupt settings.json refuses to clobber on save", async () => {
103
+ mkdirSync(AGENT, { recursive: true });
104
+ writeFileSync(join(AGENT, "settings.json"), "{not json");
105
+ const config = attachmentsConfig();
106
+ const byKey = new Map(config.groups()[0].rows.map((r) => [r.key, r]));
107
+ byKey.get("attachments.inlineTextFiles")!.set(true);
108
+ const notified: string[] = [];
109
+ await config.save(new Set(["attachments.inlineTextFiles"]), fakeCtx(notified));
110
+ assert.equal(notified.length, 1);
111
+ assert.match(notified[0], /failed|not valid JSON/i);
112
+ assert.equal(readFileSync(join(AGENT, "settings.json"), "utf8"), "{not json", "corrupt file untouched");
113
+ });
114
+ });
115
+
116
+ function readSettingsIfExists(): string | undefined {
117
+ try {
118
+ return readFileSync(join(AGENT, "settings.json"), "utf8");
119
+ } catch {
120
+ return undefined;
121
+ }
122
+ }