ceulen 0.5.1 → 0.8.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 +365 -12
- package/README.md +87 -91
- package/extensions/lib/advisor-marker.ts +33 -0
- package/extensions/lib/panel.ts +25 -2
- package/extensions/lib/rate.ts +24 -0
- package/extensions/lib/registry.test.ts +67 -0
- package/extensions/lib/registry.ts +104 -8
- package/extensions/lib/tools.ts +47 -0
- package/extensions/lib/usage-store.ts +33 -0
- package/extensions/modules/advisor/commands/advisor.ts +244 -0
- package/extensions/modules/advisor/configPanel.ts +194 -0
- package/extensions/modules/advisor/index.ts +235 -0
- package/extensions/modules/advisor/lib/config.ts +248 -0
- package/extensions/modules/advisor/lib/emission-guard.ts +153 -0
- package/extensions/modules/advisor/lib/isolated-model.ts +160 -0
- package/extensions/modules/advisor/lib/model-picker.ts +47 -0
- package/extensions/modules/advisor/lib/watcher.ts +288 -0
- package/extensions/modules/advisor/test/compliance.test.ts +125 -0
- package/extensions/modules/advisor/test/config.test.ts +202 -0
- package/extensions/modules/advisor/test/configPanel.test.ts +223 -0
- package/extensions/modules/advisor/test/emission-guard.test.ts +201 -0
- package/extensions/modules/advisor/test/isolated-model.test.ts +311 -0
- package/extensions/modules/advisor/test/model-picker.test.ts +32 -0
- package/extensions/modules/advisor/test/module.test.ts +649 -0
- package/extensions/modules/advisor/test/watcher.test.ts +478 -0
- package/extensions/modules/classifier/configPanel.ts +104 -0
- package/extensions/modules/classifier/index.ts +297 -0
- package/extensions/modules/classifier/lib/settings.ts +95 -0
- package/extensions/modules/classifier/test/classifier.test.ts +475 -0
- package/extensions/modules/composer/index.ts +152 -3
- package/extensions/modules/composer/lib/footer.ts +119 -0
- package/extensions/modules/composer/lib/shapes.ts +265 -26
- package/extensions/modules/composer/test/editor.test.ts +1 -1
- package/extensions/modules/composer/test/footer.test.ts +96 -0
- package/extensions/modules/composer/test/module.test.ts +113 -11
- package/extensions/modules/composer/test/screen.test.ts +29 -1
- package/extensions/modules/composer/test/shapes.test.ts +224 -8
- package/extensions/modules/config/defaultTools.ts +96 -0
- package/extensions/modules/config/index.ts +147 -7
- package/extensions/modules/config/piSettings.ts +254 -69
- package/extensions/modules/config/test/defaultTools.test.ts +122 -0
- package/extensions/modules/config/test/menu.test.ts +64 -0
- package/extensions/modules/config/test/panel.test.ts +38 -23
- package/extensions/modules/config/test/piSettings.test.ts +130 -3
- package/extensions/modules/config/test/renderTools.test.ts +71 -0
- package/extensions/modules/config/test/tools.test.ts +146 -0
- package/extensions/modules/fff/index.ts +2094 -0
- package/extensions/modules/fff/lib/query.ts +129 -0
- package/extensions/modules/fff/test/index.test.ts +607 -0
- package/extensions/modules/fff/test/query.test.ts +71 -0
- package/extensions/modules/munin/configPanel.ts +108 -0
- package/extensions/modules/munin/index.ts +641 -0
- package/extensions/modules/munin/lib/helpers.ts +471 -0
- package/extensions/modules/munin/lib/retry.ts +20 -0
- package/extensions/modules/munin/lib/sdk.ts +218 -0
- package/extensions/modules/munin/test/config.test.ts +168 -0
- package/extensions/modules/munin/test/configPanel.test.ts +186 -0
- package/extensions/modules/munin/test/extension.test.ts +224 -0
- package/extensions/modules/munin/test/helpers.test.ts +523 -0
- package/extensions/modules/munin/test/retry.test.ts +145 -0
- package/extensions/modules/munin/test/stale-protocol.test.ts +554 -0
- package/extensions/modules/plan/configPanel.ts +152 -0
- package/extensions/modules/plan/index.ts +917 -0
- package/extensions/modules/plan/lib/plan-tools.ts +72 -0
- package/extensions/modules/plan/lib/prompt.ts +65 -0
- package/extensions/modules/plan/lib/settings.ts +166 -0
- package/extensions/modules/plan/lib/shell-gate.ts +200 -0
- package/extensions/modules/plan/test/configPanel.test.ts +96 -0
- package/extensions/modules/plan/test/harness.ts +133 -0
- package/extensions/modules/plan/test/module.test.ts +305 -0
- package/extensions/modules/plan/test/settings.test.ts +114 -0
- package/extensions/modules/plan/test/shell-gate.test.ts +103 -0
- package/extensions/modules/ponytail/index.ts +23 -73
- package/extensions/modules/ponytail/lib/config.ts +1 -6
- package/extensions/modules/ponytail/test/extension.test.ts +1 -85
- package/extensions/modules/repair/configPanel.ts +96 -0
- package/extensions/modules/repair/index.ts +414 -0
- package/extensions/modules/repair/lib/auto-bg.ts +333 -0
- package/extensions/modules/repair/lib/edit-repair.ts +155 -0
- package/extensions/modules/repair/lib/editor.ts +251 -0
- package/extensions/modules/repair/lib/guards.ts +34 -0
- package/extensions/modules/repair/lib/input-repair.ts +324 -0
- package/extensions/modules/repair/lib/patch.ts +481 -0
- package/extensions/modules/repair/lib/settings.ts +114 -0
- package/extensions/modules/repair/test/auto-bg.test.ts +405 -0
- package/extensions/modules/repair/test/edit-repair.test.ts +224 -0
- package/extensions/modules/repair/test/editor.test.ts +141 -0
- package/extensions/modules/repair/test/guards.test.ts +64 -0
- package/extensions/modules/repair/test/input-repair.test.ts +231 -0
- package/extensions/modules/repair/test/patch.test.ts +563 -0
- package/extensions/modules/repair/test/settings.test.ts +167 -0
- package/extensions/modules/repair/test/wrapper.test.ts +210 -0
- package/extensions/modules/router/commands/commands.ts +4 -0
- package/extensions/modules/router/configPanel.ts +24 -10
- package/extensions/modules/router/lib/client.ts +63 -0
- package/extensions/modules/router/lib/provider.ts +34 -13
- package/extensions/modules/router/lib/systemone.ts +152 -0
- package/extensions/modules/router/test/unit.test.ts +260 -0
- package/extensions/modules/rtk/findFallback.js +68 -0
- package/extensions/modules/rtk/index.ts +248 -0
- package/extensions/modules/rtk/safe-rewrite.js +74 -0
- package/extensions/modules/rtk/test/findFallback.test.js +66 -0
- package/extensions/modules/rtk/test/index.test.js +131 -0
- package/extensions/modules/rtk/test/safe-rewrite.test.js +96 -0
- package/extensions/modules/rtk/version-gate.js +34 -0
- package/extensions/modules/rules/index.ts +120 -0
- package/extensions/modules/rules/lib/rules.ts +348 -0
- package/extensions/modules/rules/test/lib.test.ts +263 -0
- package/extensions/modules/rules/test/module.test.ts +222 -0
- package/extensions/modules/serena/index.ts +629 -0
- package/extensions/modules/serena/lib/detect.ts +73 -0
- package/extensions/modules/serena/lib/env.ts +76 -0
- package/extensions/modules/serena/lib/guidance.ts +26 -0
- package/extensions/modules/serena/lib/normalize.ts +27 -0
- package/extensions/modules/serena/lib/symbol-key.ts +20 -0
- package/extensions/modules/serena/lib/truncate.ts +20 -0
- package/extensions/modules/serena/test/env.test.ts +122 -0
- package/extensions/modules/serena/test/index.test.ts +347 -0
- package/extensions/modules/serena/test/worker.test.ts +562 -0
- package/extensions/modules/serena/worker.ts +858 -0
- package/extensions/modules/steering/configPanel.ts +122 -0
- package/extensions/modules/steering/index.ts +616 -0
- package/extensions/modules/steering/lib/anchor.ts +175 -0
- package/extensions/modules/steering/lib/errors.ts +253 -0
- package/extensions/modules/steering/lib/family.ts +33 -0
- package/extensions/modules/steering/lib/guidance.ts +172 -0
- package/extensions/modules/steering/lib/history.ts +170 -0
- package/extensions/modules/steering/lib/settings.ts +127 -0
- package/extensions/modules/steering/test/anchor-regressions.test.ts +93 -0
- package/extensions/modules/steering/test/anchor-wiring.test.ts +99 -0
- package/extensions/modules/steering/test/anchor.test.ts +160 -0
- package/extensions/modules/steering/test/cache-stats.test.ts +43 -0
- package/extensions/modules/steering/test/errors.test.ts +309 -0
- package/extensions/modules/steering/test/family.test.ts +43 -0
- package/extensions/modules/steering/test/guidance.test.ts +357 -0
- package/extensions/modules/steering/test/harness.ts +93 -0
- package/extensions/modules/steering/test/history.test.ts +118 -0
- package/extensions/modules/steering/test/settings.test.ts +182 -0
- package/extensions/modules/steering/test/status.test.ts +71 -0
- package/extensions/modules/steering/test/toolCall.test.ts +99 -0
- package/extensions/modules/subagent/agents/planner.md +14 -0
- package/extensions/modules/subagent/agents/reviewer.md +42 -0
- package/extensions/modules/subagent/agents/scout.md +47 -0
- package/extensions/modules/subagent/agents/tester.md +12 -0
- package/extensions/modules/subagent/agents/worker.md +18 -0
- package/extensions/modules/subagent/configPanel.ts +219 -0
- package/extensions/modules/subagent/index.ts +2464 -0
- package/extensions/modules/subagent/lib/agents.ts +408 -0
- package/extensions/modules/subagent/lib/background.ts +383 -0
- package/extensions/modules/subagent/lib/herdr.ts +1019 -0
- package/extensions/modules/subagent/lib/history.ts +126 -0
- package/extensions/modules/subagent/lib/model.ts +156 -0
- package/extensions/modules/subagent/lib/render.ts +335 -0
- package/extensions/modules/subagent/lib/result.ts +110 -0
- package/extensions/modules/subagent/lib/roles.ts +296 -0
- package/extensions/modules/subagent/lib/routing.ts +228 -0
- package/extensions/modules/subagent/lib/runner.ts +559 -0
- package/extensions/modules/subagent/lib/schema.ts +21 -0
- package/extensions/modules/subagent/lib/security.ts +763 -0
- package/extensions/modules/subagent/lib/settings.ts +159 -0
- package/extensions/modules/subagent/lib/thread-viewer.ts +319 -0
- package/extensions/modules/subagent/lib/threads.ts +135 -0
- package/extensions/modules/subagent/lib/types.ts +18 -0
- package/extensions/modules/subagent/lib/widget.ts +475 -0
- package/extensions/modules/subagent/test/configPanel.test.ts +132 -0
- package/extensions/modules/subagent/test/herdr-advisor.test.ts +40 -0
- package/extensions/modules/subagent/test/routing.test.ts +524 -0
- package/extensions/modules/subagent/test/widget.test.ts +208 -0
- package/extensions/modules/todo/index.ts +478 -0
- package/extensions/modules/todo/test/todo.test.ts +252 -0
- package/extensions/modules/usage/index.ts +70 -16
- package/extensions/modules/usage/test/genrate.test.ts +70 -0
- package/extensions/modules/usage/test/parsers.test.ts +13 -0
- package/extensions/modules/usage/test/session-accumulators.test.ts +85 -0
- package/extensions/modules/ux/UPSTREAM +24 -0
- package/extensions/modules/ux/index.ts +393 -0
- package/extensions/modules/ux/lib/audit.ts +562 -0
- package/extensions/modules/ux/lib/config.ts +136 -0
- package/extensions/modules/ux/lib/instructions.ts +77 -0
- package/extensions/modules/ux/test/audit.test.ts +756 -0
- package/extensions/modules/ux/test/extension.test.ts +394 -0
- package/extensions/modules/ux/test/instructions.test.ts +19 -0
- package/extensions/modules/web/configPanel.ts +218 -0
- package/extensions/modules/web/index.ts +978 -0
- package/extensions/modules/web/lib/agy.ts +209 -0
- package/extensions/modules/web/lib/brave.ts +42 -0
- package/extensions/modules/web/lib/cdp.ts +686 -0
- package/extensions/modules/web/lib/chatapi.ts +101 -0
- package/extensions/modules/web/lib/chatgpt.ts +796 -0
- package/extensions/modules/web/lib/chrome.ts +328 -0
- package/extensions/modules/web/lib/config.ts +136 -0
- package/extensions/modules/web/lib/content.ts +99 -0
- package/extensions/modules/web/lib/crawl4ai.ts +172 -0
- package/extensions/modules/web/lib/extract.ts +235 -0
- package/extensions/modules/web/lib/firecrawl.ts +56 -0
- package/extensions/modules/web/lib/format.ts +197 -0
- package/extensions/modules/web/lib/gemini-auth.ts +286 -0
- package/extensions/modules/web/lib/gemini-dr.ts +338 -0
- package/extensions/modules/web/lib/gemini.ts +551 -0
- package/extensions/modules/web/lib/imageapi.ts +559 -0
- package/extensions/modules/web/lib/retry.ts +71 -0
- package/extensions/modules/web/lib/search.ts +237 -0
- package/extensions/modules/web/lib/searxng.ts +69 -0
- package/extensions/modules/web/lib/settings.ts +157 -0
- package/extensions/modules/web/scripts/cdp-smoke.ts +77 -0
- package/extensions/modules/web/scripts/gemini-smoke.ts +107 -0
- package/extensions/modules/web/test/agy.test.ts +383 -0
- package/extensions/modules/web/test/cdp.test.ts +717 -0
- package/extensions/modules/web/test/chat.test.ts +171 -0
- package/extensions/modules/web/test/chatgpt.test.ts +633 -0
- package/extensions/modules/web/test/chrome.test.ts +282 -0
- package/extensions/modules/web/test/config.test.ts +218 -0
- package/extensions/modules/web/test/configPanel.test.ts +198 -0
- package/extensions/modules/web/test/crawl.test.ts +134 -0
- package/extensions/modules/web/test/crawl4ai.test.ts +105 -0
- package/extensions/modules/web/test/extension.test.ts +118 -0
- package/extensions/modules/web/test/extract.test.ts +436 -0
- package/extensions/modules/web/test/fixtures/dr-confirm.bin +12 -0
- package/extensions/modules/web/test/fixtures/dr-plan.bin +20 -0
- package/extensions/modules/web/test/fixtures/interaction.html +31 -0
- package/extensions/modules/web/test/format.test.ts +230 -0
- package/extensions/modules/web/test/gemini-auth.test.ts +465 -0
- package/extensions/modules/web/test/gemini-dr.test.ts +249 -0
- package/extensions/modules/web/test/gemini.test.ts +472 -0
- package/extensions/modules/web/test/hook.test.ts +101 -0
- package/extensions/modules/web/test/image.test.ts +1089 -0
- package/extensions/modules/web/test/retry.test.ts +119 -0
- package/extensions/modules/web/test/screenshot.test.ts +109 -0
- package/extensions/modules/web/test/search.test.ts +210 -0
- package/extensions/modules/web/test/settings.test.ts +165 -0
- package/extensions/modules/web/test/skill.test.ts +72 -0
- package/extensions/modules/web/types.d.ts +3 -0
- package/extensions/modules/web/vendor/package.json +1 -0
- package/extensions/modules/web/vendor/readability/LICENSE.md +13 -0
- package/extensions/modules/web/vendor/readability/Readability-readerable.js +123 -0
- package/extensions/modules/web/vendor/readability/Readability.js +2787 -0
- package/extensions/modules/web/vendor/readability/index.d.ts +64 -0
- package/extensions/modules/web/vendor/readability/index.js +9 -0
- package/extensions/modules/web/vendor/turndown/LICENSE +21 -0
- package/extensions/modules/web/vendor/turndown/turndown.cjs.js +784 -0
- package/extensions/modules/web/vendor/turndown-plugin-gfm/LICENSE +21 -0
- package/extensions/modules/web/vendor/turndown-plugin-gfm/turndown-plugin-gfm.cjs.js +163 -0
- package/extensions/modules/zai/configPanel.ts +154 -0
- package/extensions/modules/zai/index.ts +186 -0
- package/extensions/modules/zai/lib/anthropic.ts +159 -0
- package/extensions/modules/zai/lib/settings.ts +198 -0
- package/extensions/modules/zai/lib/signing.ts +721 -0
- package/extensions/modules/zai/lib/throttle.ts +198 -0
- package/extensions/modules/zai/test/anthropic.test.ts +132 -0
- package/extensions/modules/zai/test/configPanel.test.ts +230 -0
- package/extensions/modules/zai/test/extension.test.ts +249 -0
- package/extensions/modules/zai/test/settings.test.ts +183 -0
- package/extensions/modules/zai/test/signing-wiring.test.ts +108 -0
- package/extensions/modules/zai/test/signing.test.ts +364 -0
- package/extensions/modules/zai/test/throttle.test.ts +329 -0
- package/package.json +19 -4
- package/scripts/validate-themes.mjs +75 -0
- package/skills/munin/SKILL.md +117 -0
- package/skills/ux-capture/SKILL.md +202 -0
- package/skills/ux-design/SKILL.md +279 -0
- package/skills/ux-presets/SKILL.md +484 -0
- package/skills/ux-routing/SKILL.md +46 -0
- package/skills/web/SKILL.md +153 -0
- package/themes/alabaster.json +93 -0
- package/themes/amethyst.json +96 -0
- package/themes/anthracite.json +93 -0
- package/themes/basalt.json +91 -0
- package/themes/birch.json +95 -0
- package/themes/catppuccin-mocha.json +91 -0
- package/themes/dark-abyss.json +91 -0
- package/themes/dark-arctic.json +104 -0
- package/themes/dark-aurora.json +95 -0
- package/themes/dark-catppuccin.json +107 -0
- package/themes/dark-cavern.json +91 -0
- package/themes/dark-celestial.json +106 -0
- package/themes/dark-copper.json +95 -0
- package/themes/dark-cosmos.json +90 -0
- package/themes/dark-cyberpunk.json +102 -0
- package/themes/dark-dracula.json +98 -0
- package/themes/dark-eclipse.json +91 -0
- package/themes/dark-ember.json +95 -0
- package/themes/dark-equinox.json +90 -0
- package/themes/dark-forest.json +96 -0
- package/themes/dark-github.json +105 -0
- package/themes/dark-gruvbox.json +112 -0
- package/themes/dark-lavender.json +95 -0
- package/themes/dark-lunar.json +89 -0
- package/themes/dark-midnight.json +95 -0
- package/themes/dark-monochrome.json +94 -0
- package/themes/dark-monokai.json +98 -0
- package/themes/dark-nebula.json +90 -0
- package/themes/dark-neon-noir.json +100 -0
- package/themes/dark-nord.json +98 -0
- package/themes/dark-ocean.json +101 -0
- package/themes/dark-one.json +100 -0
- package/themes/dark-poimandres.json +115 -0
- package/themes/dark-rainforest.json +91 -0
- package/themes/dark-reef.json +91 -0
- package/themes/dark-retro.json +92 -0
- package/themes/dark-rose-pine.json +96 -0
- package/themes/dark-sakura.json +95 -0
- package/themes/dark-slate.json +95 -0
- package/themes/dark-solarized.json +97 -0
- package/themes/dark-solstice.json +90 -0
- package/themes/dark-starfall.json +91 -0
- package/themes/dark-sunset.json +99 -0
- package/themes/dark-swamp.json +90 -0
- package/themes/dark-synthwave.json +103 -0
- package/themes/dark-taiga.json +91 -0
- package/themes/dark-terminal.json +95 -0
- package/themes/dark-tokyo-night.json +101 -0
- package/themes/dark-tundra.json +91 -0
- package/themes/dark-twilight.json +91 -0
- package/themes/dark-volcanic.json +91 -0
- package/themes/dark.json +80 -0
- package/themes/graphite.json +92 -0
- package/themes/light-arctic.json +107 -0
- package/themes/light-aurora-day.json +91 -0
- package/themes/light-canyon.json +91 -0
- package/themes/light-catppuccin.json +106 -0
- package/themes/light-cirrus.json +90 -0
- package/themes/light-coral.json +95 -0
- package/themes/light-cyberpunk.json +96 -0
- package/themes/light-dawn.json +90 -0
- package/themes/light-dunes.json +91 -0
- package/themes/light-eucalyptus.json +95 -0
- package/themes/light-forest.json +100 -0
- package/themes/light-frost.json +95 -0
- package/themes/light-github.json +115 -0
- package/themes/light-glacier.json +91 -0
- package/themes/light-gruvbox.json +108 -0
- package/themes/light-haze.json +90 -0
- package/themes/light-honeycomb.json +95 -0
- package/themes/light-lagoon.json +91 -0
- package/themes/light-lavender.json +95 -0
- package/themes/light-meadow.json +91 -0
- package/themes/light-mint.json +95 -0
- package/themes/light-monochrome.json +101 -0
- package/themes/light-ocean.json +99 -0
- package/themes/light-one.json +99 -0
- package/themes/light-opal.json +91 -0
- package/themes/light-orchard.json +91 -0
- package/themes/light-paper.json +95 -0
- package/themes/light-poimandres.json +115 -0
- package/themes/light-prism.json +90 -0
- package/themes/light-retro.json +98 -0
- package/themes/light-sand.json +95 -0
- package/themes/light-savanna.json +91 -0
- package/themes/light-solarized.json +102 -0
- package/themes/light-soleil.json +90 -0
- package/themes/light-sunset.json +99 -0
- package/themes/light-synthwave.json +98 -0
- package/themes/light-tokyo-night.json +111 -0
- package/themes/light-wetland.json +91 -0
- package/themes/light-zenith.json +89 -0
- package/themes/light.json +80 -0
- package/themes/limestone.json +94 -0
- package/themes/mahogany.json +97 -0
- package/themes/marble.json +93 -0
- package/themes/mirage.json +79 -0
- package/themes/obsidian.json +91 -0
- package/themes/onyx.json +91 -0
- package/themes/pearl.json +93 -0
- package/themes/porcelain.json +91 -0
- package/themes/quartz.json +96 -0
- package/themes/sandstone.json +95 -0
- package/themes/titanium.json +90 -0
|
@@ -32,22 +32,35 @@ const readSettings = (): Record<string, unknown> =>
|
|
|
32
32
|
/** Untyped ctx stub — only what applyShape/save touch. */
|
|
33
33
|
function stubCtx(overrides: Record<string, unknown> = {}): never {
|
|
34
34
|
const calls: { factory: unknown }[] = [];
|
|
35
|
+
const footerCalls: { factory: unknown }[] = [];
|
|
35
36
|
const ctx: Record<string, unknown> = {
|
|
36
37
|
mode: "tui",
|
|
37
38
|
hasUI: true,
|
|
38
39
|
cwd: "/tmp/somerepo",
|
|
39
40
|
model: { name: "GLM" },
|
|
41
|
+
thinkingLevel: "high",
|
|
40
42
|
getContextUsage: () => ({ tokens: 100, contextWindow: 1000, percent: 10 }),
|
|
43
|
+
sessionManager: {
|
|
44
|
+
getSessionId: () => "s1",
|
|
45
|
+
getLeafId: () => "l1",
|
|
46
|
+
getEntries: () => [
|
|
47
|
+
{ type: "message", message: { role: "assistant", usage: { input: 100, output: 50, cacheRead: 0, cacheWrite: 0, cost: { total: 0.5 } } } },
|
|
48
|
+
],
|
|
49
|
+
},
|
|
41
50
|
ui: {
|
|
42
51
|
theme: { fg: (_t: string, s: string) => s, inverse: (s: string) => s, getBgAnsi: () => "", getFgAnsi: () => "" },
|
|
43
52
|
setEditorComponent: (factory: unknown) => {
|
|
44
53
|
calls.push({ factory });
|
|
45
54
|
},
|
|
55
|
+
setFooter: (factory: unknown) => {
|
|
56
|
+
footerCalls.push({ factory });
|
|
57
|
+
},
|
|
46
58
|
notify: () => {},
|
|
47
59
|
},
|
|
48
60
|
...overrides,
|
|
49
61
|
};
|
|
50
62
|
ctx.__calls = calls;
|
|
63
|
+
ctx.__footerCalls = footerCalls;
|
|
51
64
|
return ctx as never;
|
|
52
65
|
}
|
|
53
66
|
|
|
@@ -55,7 +68,7 @@ function stubCtx(overrides: Record<string, unknown> = {}): never {
|
|
|
55
68
|
* theme source), the same flow the real runtime runs. */
|
|
56
69
|
async function startModule(ctx: never): Promise<void> {
|
|
57
70
|
const events = new Map<string, (e: unknown, c: never) => Promise<void>>();
|
|
58
|
-
composerModule({ on: (name: string, h: never) => events.set(name, h) } as never);
|
|
71
|
+
composerModule({ on: (name: string, h: never) => events.set(name, h), getSettings: () => ({ compaction: { enabled: true } }) } as never);
|
|
59
72
|
await events.get("session_start")!({}, ctx);
|
|
60
73
|
}
|
|
61
74
|
|
|
@@ -125,6 +138,73 @@ describe("applyShape dispatch", () => {
|
|
|
125
138
|
const lines = ed.render(30);
|
|
126
139
|
assert.ok(lines.length >= 2, "editor renders chrome");
|
|
127
140
|
});
|
|
141
|
+
|
|
142
|
+
it("the live factory carries the stock status: cwd, branch, context window, Generation Rate", async () => {
|
|
143
|
+
const { setGenRate, resetGenRate } = await import("../../../lib/rate.js");
|
|
144
|
+
const { setUsageItem, resetUsageItem } = await import("../../../lib/usage-store.js");
|
|
145
|
+
const ctx = stubCtx();
|
|
146
|
+
await startModule(ctx); // liveCtx = ctx — the same data source the factory reads
|
|
147
|
+
applyShape("band", ctx);
|
|
148
|
+
const factory = (
|
|
149
|
+
ctx as unknown as {
|
|
150
|
+
__calls: { factory: (t: unknown, th: unknown, kb: unknown) => { render(w: number): string[]; setText(s: string): void } }[];
|
|
151
|
+
}
|
|
152
|
+
).__calls[0]!.factory;
|
|
153
|
+
const ed = factory({ terminal: { rows: 30 }, requestRender() {} }, { borderColor: (s: string) => s }, {});
|
|
154
|
+
ed.setText("hi");
|
|
155
|
+
setGenRate({ tps: 46 });
|
|
156
|
+
setUsageItem({ provider: "router", windows: "R:59%/2H3M" });
|
|
157
|
+
const lines = ed.render(90).map((l) => l.replace(/\x1b\[[0-9;]*m/g, ""));
|
|
158
|
+
const line = lines[0]!;
|
|
159
|
+
assert.ok(lines[0]!.includes("⚡ 46 tok/s"), `Generation Rate is line 1: ${lines[0]}`);
|
|
160
|
+
// Line 1 carries the numeric block: rate · session token stats · quota windows.
|
|
161
|
+
assert.ok(line.includes("↑100 ↓50"), `token stats on line 1: ${line}`);
|
|
162
|
+
assert.ok(line.includes("R:59%"), `quota windows on line 1: ${line}`);
|
|
163
|
+
const band = lines[1]!;
|
|
164
|
+
assert.ok(band.includes("GLM"), band);
|
|
165
|
+
assert.ok(band.includes("/tmp/somerepo"), `cwd shown: ${band}`);
|
|
166
|
+
assert.ok(band.includes("10.0%/1.0k"), `context window shown: ${band}`);
|
|
167
|
+
assert.ok(!band.includes("↑100 ↓50") && !band.includes("R:59%"), `stats/quota stay off the band: ${band}`);
|
|
168
|
+
assert.ok(band.includes("10.0%/1.0k (auto)"), `auto-compact marker from pi settings: ${band}`);
|
|
169
|
+
resetGenRate();
|
|
170
|
+
resetUsageItem();
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it("replaces pi's footer only on band-embedding shapes (no duplicated info)", () => {
|
|
174
|
+
const withFooter = (shape: string) => {
|
|
175
|
+
const ctx = stubCtx();
|
|
176
|
+
applyShape(shape, ctx);
|
|
177
|
+
return (ctx as unknown as { __footerCalls: { factory: unknown }[] }).__footerCalls;
|
|
178
|
+
};
|
|
179
|
+
for (const id of ["band", "box", "claude", "rule"]) {
|
|
180
|
+
const calls = withFooter(id);
|
|
181
|
+
assert.equal(calls.length, 1, `${id} installs a custom footer`);
|
|
182
|
+
assert.equal(typeof calls[0]!.factory, "function", `${id} factory is a function`);
|
|
183
|
+
}
|
|
184
|
+
for (const id of ["pi", "borderless", "field", "rail"]) {
|
|
185
|
+
const calls = withFooter(id);
|
|
186
|
+
assert.equal(calls.length, 1, `${id} restores the native footer`);
|
|
187
|
+
assert.equal(calls[0]!.factory, undefined, `${id} passes undefined (native footer)`);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it("the custom footer renders only the other extensions' statuses", async () => {
|
|
192
|
+
const ctx = stubCtx();
|
|
193
|
+
await startModule(ctx);
|
|
194
|
+
applyShape("band", ctx);
|
|
195
|
+
const factory = (ctx as unknown as { __footerCalls: { factory: unknown }[] }).__footerCalls[0]!.factory as (
|
|
196
|
+
t: unknown,
|
|
197
|
+
th: unknown,
|
|
198
|
+
fd: unknown,
|
|
199
|
+
) => { render(w: number): string[] };
|
|
200
|
+
const footerData = {
|
|
201
|
+
getExtensionStatuses: () => new Map([["rtk", "rtk ✓"], ["ceulen-usage", "(router) R:59%/2H3M"], ["serena", "serena ✓"]]) as ReadonlyMap<string, string>,
|
|
202
|
+
};
|
|
203
|
+
const lines = factory({}, {}, footerData).render(80).map((l) => l.replace(/\x1b\[[0-9;]*m/g, ""));
|
|
204
|
+
assert.equal(lines.length, 1, "statuses line only — stats/quota live in the band now");
|
|
205
|
+
assert.equal(lines[0], "rtk ✓ serena ✓", "usage item filtered out (the band carries it), rest key-sorted (pi parity)");
|
|
206
|
+
for (const l of lines) assert.ok(!l.includes("%/") && !l.includes("↑"), `band info stays in the band: ${l}`);
|
|
207
|
+
});
|
|
128
208
|
});
|
|
129
209
|
|
|
130
210
|
describe("composerConfig", () => {
|
|
@@ -174,10 +254,29 @@ describe("composerConfig", () => {
|
|
|
174
254
|
});
|
|
175
255
|
|
|
176
256
|
describe("module registration (core)", () => {
|
|
177
|
-
it("registers
|
|
257
|
+
it("registers session events + thinking_level_select handlers", () => {
|
|
178
258
|
const events = new Map<string, unknown>();
|
|
179
259
|
composerModule({ on: (name: string, h: unknown) => events.set(name, h) } as never);
|
|
180
|
-
assert.deepEqual([...events.keys()].sort(), ["session_shutdown", "session_start"]);
|
|
260
|
+
assert.deepEqual([...events.keys()].sort(), ["session_shutdown", "session_start", "thinking_level_select"]);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
it("thinking_level_select updates the live level without a session restart", async () => {
|
|
264
|
+
const events = new Map<string, (e: unknown, c: never) => Promise<void>>();
|
|
265
|
+
const ctx = stubCtx({ thinkingLevel: "high" });
|
|
266
|
+
composerModule({ on: (name: string, h: never) => events.set(name, h), getSettings: () => ({ compaction: { enabled: true } }) } as never);
|
|
267
|
+
await events.get("session_start")!({}, ctx);
|
|
268
|
+
applyShape("band", ctx);
|
|
269
|
+
const factoryOf = () =>
|
|
270
|
+
(ctx as unknown as { __calls: { factory: (t: unknown, th: unknown, kb: unknown) => { render(w: number): string[] } }[] }).__calls.at(-1)!.factory;
|
|
271
|
+
const render = (ed: { render(w: number): string[] }) => {
|
|
272
|
+
const lines = ed.render(120).map((l) => l.replace(/\x1b\[[0-9;]*m/g, ""));
|
|
273
|
+
return lines.find((l) => l.includes("π ·")) ?? lines[0]!;
|
|
274
|
+
};
|
|
275
|
+
const ed1 = factoryOf()({ terminal: { rows: 30 }, requestRender() {} }, { borderColor: (s: string) => s }, {});
|
|
276
|
+
assert.ok(render(ed1).includes("(high)"), "session_start ctx level");
|
|
277
|
+
await events.get("thinking_level_select")!({ type: "thinking_level_select", level: "max", previousLevel: "high" }, ctx);
|
|
278
|
+
const ed2 = factoryOf()({ terminal: { rows: 30 }, requestRender() {} }, { borderColor: (s: string) => s }, {});
|
|
279
|
+
assert.ok(render(ed2).includes("(max)"), "event updates the level live");
|
|
181
280
|
});
|
|
182
281
|
});
|
|
183
282
|
|
|
@@ -187,27 +286,30 @@ describe("core module contract", () => {
|
|
|
187
286
|
const entry = MODULES.find((m) => m.name === "composer")!;
|
|
188
287
|
assert.equal(entry.core, true, "composer is core");
|
|
189
288
|
assert.equal(isCore("composer"), true);
|
|
190
|
-
assert.equal(isCore("
|
|
289
|
+
assert.equal(isCore("munin"), false);
|
|
191
290
|
|
|
192
|
-
// A settings file that (wrongly) lists
|
|
291
|
+
// A settings file that (wrongly) lists a core module as disabled must not
|
|
193
292
|
// disable it — readDisabled filters core modules out.
|
|
194
|
-
writeFileSync(settingsFile(), JSON.stringify({ ceulen: { disabled: ["composer", "
|
|
195
|
-
assert.deepEqual(readDisabled(), ["
|
|
293
|
+
writeFileSync(settingsFile(), JSON.stringify({ ceulen: { disabled: ["composer", "munin"] } }), "utf8");
|
|
294
|
+
assert.deepEqual(readDisabled(), ["munin"], "core module filtered from the kill-switch");
|
|
196
295
|
writeFileSync(settingsFile(), "{}", "utf8");
|
|
197
296
|
});
|
|
198
297
|
|
|
199
298
|
it("writeDisabled never persists a core module", async () => {
|
|
200
299
|
const { writeDisabled } = await import("../../../lib/registry.js");
|
|
201
|
-
writeDisabled(["composer", "
|
|
202
|
-
assert.deepEqual((readSettings().ceulen as { disabled: string[] }).disabled, ["
|
|
300
|
+
writeDisabled(["composer", "munin"]);
|
|
301
|
+
assert.deepEqual((readSettings().ceulen as { disabled: string[] }).disabled, ["munin"]);
|
|
203
302
|
writeFileSync(settingsFile(), "{}", "utf8");
|
|
204
303
|
});
|
|
205
304
|
|
|
206
305
|
it("nextDisabled excludes core modules; withEnableRow adds no row for them", async () => {
|
|
207
306
|
const { nextDisabled, withEnableRow } = await import("../../config/index.js");
|
|
208
307
|
// working = enabled set; nextDisabled lists the NOT-enabled non-core modules.
|
|
209
|
-
assert.deepEqual(nextDisabled(new Set(["
|
|
210
|
-
assert.deepEqual(nextDisabled(new Set(["router", "usage", "ponytail", "config"])), [], "all-on → nothing disabled");
|
|
308
|
+
assert.deepEqual(nextDisabled(new Set(["munin"])), ["zai", "ponytail", "subagent", "plan", "todo", "repair", "serena", "fff", "web", "rules", "steering", "rtk"]);
|
|
309
|
+
assert.deepEqual(nextDisabled(new Set(["router", "classifier", "ux", "munin", "usage", "ponytail", "subagent", "plan", "todo", "repair", "serena", "fff", "web", "rules", "steering", "zai", "rtk", "config"])), [], "all-on → nothing disabled");
|
|
310
|
+
for (const core of ["composer", "advisor", "router", "classifier", "usage", "ux", "config"]) {
|
|
311
|
+
assert.ok(!nextDisabled(new Set()).includes(core), `core (${core}) is never disableable`);
|
|
312
|
+
}
|
|
211
313
|
const groups = [{ key: "composer", label: "Composer Shape", rows: [{ key: "composer.shape" }] }] as never;
|
|
212
314
|
const out = withEnableRow(groups, "composer", "Composer shape.", new Set(["composer"]));
|
|
213
315
|
assert.deepEqual(out[0]!.rows.map((r: { key: string }) => r.key), ["composer.shape"], "no Enable row for core");
|
|
@@ -64,7 +64,10 @@ function editor(id: string, txt = "hello") {
|
|
|
64
64
|
const tui = { terminal: { rows: 20 }, requestRender() {} } as never;
|
|
65
65
|
const ed = new ShapeEditor(
|
|
66
66
|
shapeById(id),
|
|
67
|
-
{
|
|
67
|
+
{
|
|
68
|
+
theme: () => IDENTITY_THEME,
|
|
69
|
+
data: () => ({ model: "GLM-5.3", cwd: "~/dev/ceulen", branch: "main", git: { staged: 1, unstaged: 3, untracked: 2 }, pct: 12, window: 1_000_000, rate: 46, stats: "↑1.9M ↓377k R69M", usage: "(router) R:59%/2H3M" }),
|
|
70
|
+
},
|
|
68
71
|
tui,
|
|
69
72
|
theme as never,
|
|
70
73
|
{} as never,
|
|
@@ -116,6 +119,30 @@ describe("composed screen through the real TUI renderer", () => {
|
|
|
116
119
|
assert.ok(compose(editor("rail")).out.includes("▎"), "rail glyph");
|
|
117
120
|
});
|
|
118
121
|
|
|
122
|
+
it("band carries the stock status on screen: icons on every segment, context right-justified", () => {
|
|
123
|
+
// At the default 60 cols the band keeps brand+model+dir and sheds the rest
|
|
124
|
+
// whole; the widest capture exercises every segment at once. Line 1 (right-
|
|
125
|
+
// justified, OMP placement) sits above the band when present: rate · stats
|
|
126
|
+
// · usage on one row.
|
|
127
|
+
const narrowBand = (l: string) => l.includes("π ·");
|
|
128
|
+
const narrow = compose(editor("band")).lines.find(narrowBand)!;
|
|
129
|
+
assert.ok(narrow.includes("π · GLM-5.3"), narrow);
|
|
130
|
+
assert.ok(narrow.includes("📁 ~/dev/ceulen"), narrow);
|
|
131
|
+
assert.ok(narrow.includes("12.0%/1.0M"), `context figure never clipped: ${narrow}`);
|
|
132
|
+
assert.ok(!narrow.includes("…"), "whole segments only, no half-cut segment");
|
|
133
|
+
|
|
134
|
+
const wide = compose(editor("band"), 120);
|
|
135
|
+
const wideBand = wide.lines.find((l) => l.includes("π ·"))!;
|
|
136
|
+
const usageLine = wide.lines.find((l) => l.includes("⚡ 46 tok/s"))!;
|
|
137
|
+
assert.ok(usageLine.includes("↑1.9M ↓377k R69M") && usageLine.includes("R:59%"), `rate · stats · usage on line 1: ${usageLine}`);
|
|
138
|
+
assert.ok(!wideBand.includes("⚡"), `line 1 sits above the band: ${wide.lines.join("\n")}`);
|
|
139
|
+
assert.ok(wideBand.includes("⑂ main *3 +1 ?2"), wideBand);
|
|
140
|
+
assert.ok(wideBand.includes("12.0%/1.0M"), wideBand); // right-justification asserted purely in shapes.test
|
|
141
|
+
|
|
142
|
+
const claude = compose(editor("claude"), 120).lines.find((l) => l.includes("GLM-5.3"))!;
|
|
143
|
+
assert.ok(claude.includes("⑂ main") && claude.includes("12.0%/1.0M"), claude);
|
|
144
|
+
});
|
|
145
|
+
|
|
119
146
|
it("composes at narrow widths without eating closing chrome", () => {
|
|
120
147
|
for (const cols of [30, 40]) {
|
|
121
148
|
const out = compose(editor("box"), cols).out;
|
|
@@ -175,6 +202,7 @@ describe("composed screen through the real TUI renderer", () => {
|
|
|
175
202
|
text: (s: string) => s,
|
|
176
203
|
dim: (s: string) => s,
|
|
177
204
|
warn: (s: string) => s,
|
|
205
|
+
error: (s: string) => s,
|
|
178
206
|
fill: (s: string) => s,
|
|
179
207
|
inverse: (s: string) => s,
|
|
180
208
|
};
|
|
@@ -7,18 +7,27 @@
|
|
|
7
7
|
import { describe, it } from "node:test";
|
|
8
8
|
import assert from "node:assert/strict";
|
|
9
9
|
import { CURSOR_MARKER, visibleWidth } from "@earendil-works/pi-tui";
|
|
10
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
11
|
+
import { tmpdir } from "node:os";
|
|
12
|
+
import { join } from "node:path";
|
|
10
13
|
import {
|
|
14
|
+
composeStatus,
|
|
11
15
|
contentWidth,
|
|
12
16
|
DEFAULT_SHAPE,
|
|
17
|
+
formatCompact,
|
|
18
|
+
ICONS,
|
|
19
|
+
parseGitStats,
|
|
13
20
|
gutterWidth,
|
|
21
|
+
rateLine,
|
|
14
22
|
IDENTITY_THEME,
|
|
15
23
|
isShapeId,
|
|
16
24
|
padRow,
|
|
17
25
|
previewShape,
|
|
26
|
+
readGitBranch,
|
|
18
27
|
SHAPE_IDS,
|
|
19
28
|
SHAPES,
|
|
20
29
|
shapeById,
|
|
21
|
-
|
|
30
|
+
statusSegments,
|
|
22
31
|
surfacePainter,
|
|
23
32
|
type ShapeTheme,
|
|
24
33
|
} from "../lib/shapes.ts";
|
|
@@ -119,7 +128,7 @@ describe("chrome rendering through the shared builders", () => {
|
|
|
119
128
|
|
|
120
129
|
it("status-bearing shapes show the live status line; band reserves a blank row when empty", () => {
|
|
121
130
|
const box = previewShape("box", 40, th, { model: "GLM-5.3", cwd: "ceulen", pct: 42 }).map(plain);
|
|
122
|
-
assert.ok(box[0]!.includes("GLM-5.3") && box[0]!.includes("ceulen") && box[0]!.includes("42%"), box[0]);
|
|
131
|
+
assert.ok(box[0]!.includes("GLM-5.3") && box[0]!.includes("ceulen") && box[0]!.includes("42.0%"), box[0]);
|
|
123
132
|
const bandEmpty = previewShape("band", 40, th).map(plain);
|
|
124
133
|
assert.equal(bandEmpty[0]!.trim(), "", "band row reserved (blank) without data");
|
|
125
134
|
const bandFull = previewShape("band", 40, th, { model: "M" }).map(plain);
|
|
@@ -136,13 +145,220 @@ describe("chrome rendering through the shared builders", () => {
|
|
|
136
145
|
});
|
|
137
146
|
});
|
|
138
147
|
|
|
148
|
+
describe("git branch read (.git/HEAD)", () => {
|
|
149
|
+
const withTmp = (fn: (dir: string) => void) => {
|
|
150
|
+
const dir = mkdtempSync(join(tmpdir(), "ceulen-branch-"));
|
|
151
|
+
try {
|
|
152
|
+
fn(dir);
|
|
153
|
+
} finally {
|
|
154
|
+
rmSync(dir, { recursive: true, force: true });
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
it("reads a normal repo's HEAD branch and walks up from a subdirectory", () => {
|
|
159
|
+
withTmp((dir) => {
|
|
160
|
+
mkdirSync(join(dir, ".git"), { recursive: true });
|
|
161
|
+
writeFileSync(join(dir, ".git", "HEAD"), "ref: refs/heads/main\n");
|
|
162
|
+
const sub = join(dir, "packages", "app");
|
|
163
|
+
mkdirSync(sub, { recursive: true });
|
|
164
|
+
assert.equal(readGitBranch(dir), "main");
|
|
165
|
+
assert.equal(readGitBranch(sub), "main", "walk-up finds the repo root");
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("resolves a linked worktree (.git is a gitdir file)", () => {
|
|
170
|
+
withTmp((dir) => {
|
|
171
|
+
const realGit = join(dir, "real-git");
|
|
172
|
+
mkdirSync(realGit, { recursive: true });
|
|
173
|
+
writeFileSync(join(realGit, "HEAD"), "ref: refs/heads/feature/x\n");
|
|
174
|
+
const wt = join(dir, "worktree");
|
|
175
|
+
mkdirSync(wt, { recursive: true });
|
|
176
|
+
writeFileSync(join(wt, ".git"), `gitdir: ${realGit}\n`);
|
|
177
|
+
assert.equal(readGitBranch(wt), "feature/x");
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("detached HEAD and non-repos degrade safely", () => {
|
|
182
|
+
withTmp((dir) => {
|
|
183
|
+
mkdirSync(join(dir, ".git"), { recursive: true });
|
|
184
|
+
writeFileSync(join(dir, ".git", "HEAD"), "0123456789abcdef0123456789abcdef01234567\n");
|
|
185
|
+
assert.equal(readGitBranch(dir), "detached");
|
|
186
|
+
});
|
|
187
|
+
withTmp((dir) => {
|
|
188
|
+
assert.equal(readGitBranch(dir), null, "no repo → null");
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
139
193
|
describe("status line + surface fill", () => {
|
|
140
|
-
it("
|
|
141
|
-
|
|
142
|
-
assert.equal(plain(
|
|
143
|
-
assert.equal(
|
|
144
|
-
|
|
145
|
-
assert.
|
|
194
|
+
it("statusSegments splits OMP's stock groups: identity left, context window right", () => {
|
|
195
|
+
const s = statusSegments({ model: "M", provider: "router", thinkingLevel: "max", cwd: "~/dev/ceulen", branch: "main", rate: 46, pct: 42.6, window: 1_000_000 }, th);
|
|
196
|
+
assert.equal(plain(s.left), "π · (router) M (max) · 📁 ~/dev/ceulen · ⑂ main");
|
|
197
|
+
assert.equal(plain(s.right), "42.6%/1.0M");
|
|
198
|
+
// Every segment carries its icon (OMP's glyph set).
|
|
199
|
+
assert.ok(plain(s.left).startsWith("π "), "brand leads the group");
|
|
200
|
+
assert.ok(plain(s.left).includes("📁 ~/dev/ceulen"), "folder icon on the dir");
|
|
201
|
+
assert.ok(plain(s.left).includes("⑂ main"), "branch icon on the git segment");
|
|
202
|
+
// Generation rate is NOT a band segment — it renders right-justified on
|
|
203
|
+
// line 1 (rateLine) together with the token stats and quota windows.
|
|
204
|
+
assert.ok(!plain(s.left).includes("tok/s"), "rate stays off the band");
|
|
205
|
+
assert.equal(plain(rateLine({ rate: 46.4 }, th, 20)), " ⚡ 46 tok/s");
|
|
206
|
+
assert.equal(rateLine(undefined, th, 20), "", "no rate → no line");
|
|
207
|
+
assert.equal(rateLine({ rate: 0 }, th, 20), "", "zero rate → no line");
|
|
208
|
+
// Line 1 splits the numeric block by the composer's left/right groups:
|
|
209
|
+
// token stats + quota windows flush LEFT, tok/s justified RIGHT.
|
|
210
|
+
const full = plain(rateLine({ rate: 46, stats: "↑1.9M ↓377k R69M", usage: "(router) R:59%/2H3M" }, th, 80));
|
|
211
|
+
assert.ok(full.startsWith("↑1.9M ↓377k R69M · (router) R:59%/2H3M"), `stats+usage flush left: ${full}`);
|
|
212
|
+
assert.ok(full.endsWith("⚡ 46 tok/s"), `rate right-justified: ${full}`);
|
|
213
|
+
// Stats and usage render without a rate too (line never blank when fed).
|
|
214
|
+
assert.ok(plain(rateLine({ stats: "↑1k ↓500" }, th, 40)).startsWith("↑1k ↓500"), "stats alone sits left");
|
|
215
|
+
assert.ok(plain(rateLine({ usage: "(router) R:59%/2H3M" }, th, 40)).startsWith("(router) R:59%/2H3M"), "usage alone sits left");
|
|
216
|
+
// Usage tone steps (error/warn) with the tightest window.
|
|
217
|
+
const toneTheme: ShapeTheme = { ...th, warn: (t) => `W(${t})`, error: (t) => `E(${t})` };
|
|
218
|
+
assert.ok(plain(rateLine({ usage: "R:9%/1M", usageTone: "error" }, toneTheme, 40)).startsWith("E(R:9%/1M)"), "error tone paints");
|
|
219
|
+
// Over-budget: the LEFT group sheds whole trailing segments (usage first,
|
|
220
|
+
// then stats); the rate yields only when the left group is gone.
|
|
221
|
+
const shed = plain(rateLine({ rate: 46, stats: "↑1.9M ↓377k", usage: "(r) R:59%/2H3M" }, th, 30));
|
|
222
|
+
assert.ok(shed.startsWith("↑1.9M ↓377k") && !shed.includes("R:59%"), `usage sheds first: ${shed}`);
|
|
223
|
+
assert.ok(shed.endsWith("⚡ 46 tok/s"), `rate stays through left shedding: ${shed}`);
|
|
224
|
+
const tighter = plain(rateLine({ rate: 46, stats: "↑1.9M ↓377k" }, th, 14));
|
|
225
|
+
assert.ok(tighter.endsWith("⚡ 46 tok/s"), `stats gone, rate right: ${tighter}`);
|
|
226
|
+
// Below the rate's own width the line yields the bare rate; ShapeEditor's
|
|
227
|
+
// final truncateToWidth pass owns the clip (same as every other row).
|
|
228
|
+
assert.equal(plain(rateLine({ rate: 46, stats: "↑1.9M ↓377k" }, th, 10)), "⚡ 46 tok/s", `rate is the last thing standing: ${plain(rateLine({ rate: 46, stats: "↑1.9M ↓377k" }, th, 10))}`);
|
|
229
|
+
// Blanks drop out — never wrong, just shorter. The brand only leads a
|
|
230
|
+
// group that exists, so an empty session keeps the band blank.
|
|
231
|
+
assert.equal(plain(statusSegments({ model: "M" }, th).left), "π · M");
|
|
232
|
+
assert.equal(statusSegments({}, th).left, "", "no data → no brand");
|
|
233
|
+
assert.equal(statusSegments(undefined, th).left, "");
|
|
234
|
+
assert.equal(statusSegments(undefined, th).right, "");
|
|
235
|
+
assert.equal(plain(statusSegments({ model: " ", cwd: "x" }, th).left), "π · 📁 x", "blank segments skipped");
|
|
236
|
+
// Branch without a cwd still renders; detached renders as-is.
|
|
237
|
+
assert.equal(plain(statusSegments({ branch: "detached" }, th).left), "π · ⑂ detached");
|
|
238
|
+
// Spinner takes the brand slot while a turn runs.
|
|
239
|
+
assert.equal(plain(statusSegments({ model: "M" }, th, "⟳").left), "⟳ · M");
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it("model segment: (provider) prefix skips when the name carries it; off/blank level dropped", () => {
|
|
243
|
+
// Direct provider whose display name already starts with provider/ — no double prefix.
|
|
244
|
+
assert.equal(plain(statusSegments({ model: "zai/glm-5.3", provider: "zai" }, th).left), "π · zai/glm-5.3");
|
|
245
|
+
// Prefix is case-insensitive on the check, verbatim on output.
|
|
246
|
+
assert.equal(plain(statusSegments({ model: "Zai/GLM", provider: "zai" }, th).left), "π · Zai/GLM");
|
|
247
|
+
assert.equal(plain(statusSegments({ model: "M", provider: "zai" }, th).left), "π · (zai) M");
|
|
248
|
+
// `off` and blank levels render nothing, not "(off)".
|
|
249
|
+
assert.equal(plain(statusSegments({ model: "M", thinkingLevel: "off" }, th).left), "π · M");
|
|
250
|
+
assert.equal(plain(statusSegments({ model: "M", thinkingLevel: " " }, th).left), "π · M");
|
|
251
|
+
// Level without a model never renders alone.
|
|
252
|
+
assert.equal(statusSegments({ thinkingLevel: "max" }, th).left, "");
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it("model cluster: model only — usage/stats live on line 1 (rateLine), not the band", () => {
|
|
256
|
+
const s = statusSegments(
|
|
257
|
+
{ model: "M", provider: "router", thinkingLevel: "high", branch: "main", git: { staged: 1, unstaged: 10, untracked: 4 }, usage: "(router) R:59%/2H3M W:99%/2D3H", stats: "↑1.9M ↓377k R69M CH99.7%", rate: 46 },
|
|
258
|
+
th,
|
|
259
|
+
);
|
|
260
|
+
const left = plain(s.left);
|
|
261
|
+
assert.equal(left, "π · (router) M (high) · ⑂ main *10 +1 ?4");
|
|
262
|
+
// Supplied-but-dropped figures never leak into the band — line 1
|
|
263
|
+
// (rateLine) owns rate · stats · usage.
|
|
264
|
+
assert.ok(!left.includes("R:59%") && !left.includes("↑1.9M") && !left.includes("tok/s"), "usage/stats/rate stay off the band");
|
|
265
|
+
// Usage-only line 1 keeps tone-stepping.
|
|
266
|
+
assert.equal(plain(rateLine({ usage: "(r) R:59%/2H3M", usageTone: "warning" }, { ...th, warn: (t) => `W(${t})` }, 40)), "W((r) R:59%/2H3M)");
|
|
267
|
+
assert.equal(plain(statusSegments({ model: "M", usage: " " }, th).left), "π · M");
|
|
268
|
+
assert.equal(plain(statusSegments({ model: "M", stats: "" }, th).left), "π · M");
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
it("context window color-steps like pi's footer (>70 warn, >90 error)", () => {
|
|
272
|
+
const seen = { warn: 0, error: 0 };
|
|
273
|
+
const stepping: ShapeTheme = {
|
|
274
|
+
...th,
|
|
275
|
+
warn: (s) => (seen.warn++, s),
|
|
276
|
+
error: (s) => (seen.error++, s),
|
|
277
|
+
};
|
|
278
|
+
assert.equal(plain(statusSegments({ pct: 42, window: 200_000 }, stepping).right), "42.0%/200k");
|
|
279
|
+
assert.equal(seen.warn, 0);
|
|
280
|
+
assert.equal(plain(statusSegments({ pct: 75, window: 200_000 }, stepping).right), "75.0%/200k");
|
|
281
|
+
assert.equal(seen.warn, 1);
|
|
282
|
+
assert.equal(plain(statusSegments({ pct: 95, window: 200_000 }, stepping).right), "95.0%/200k");
|
|
283
|
+
assert.equal(seen.error, 1);
|
|
284
|
+
// Unknown pct with a known window shows the window alone.
|
|
285
|
+
assert.equal(plain(statusSegments({ pct: null, window: 200_000 }, th).right), "200k/?");
|
|
286
|
+
assert.equal(statusSegments({}, th).right, "");
|
|
287
|
+
// pi's `(auto)` compaction marker rides the context figure (footer parity).
|
|
288
|
+
assert.equal(plain(statusSegments({ pct: 42, window: 200_000, autoCompact: true }, th).right), "42.0%/200k (auto)");
|
|
289
|
+
assert.equal(plain(statusSegments({ pct: 95, window: 200_000, autoCompact: true }, stepping).right), "95.0%/200k (auto)");
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it("composeStatus justifies the right group; the left group yields first when narrow", () => {
|
|
293
|
+
assert.equal(plain(composeStatus("L", "R", 10)), "L R");
|
|
294
|
+
assert.equal(plain(composeStatus("", "R", 10)), "R");
|
|
295
|
+
assert.equal(plain(composeStatus("L", "", 10)), "L");
|
|
296
|
+
// OMP priority: the context window survives; identity truncates into it.
|
|
297
|
+
assert.equal(plain(composeStatus("LLLLLL", "RR", 6)), "LL… RR");
|
|
298
|
+
assert.equal(plain(composeStatus("LLLLLL", "RRRR", 5)), "RRRR", "right alone when the left cannot fit");
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
it("formatCompact matches pi-footer/OMP token figures", () => {
|
|
302
|
+
assert.equal(formatCompact(0), "0");
|
|
303
|
+
assert.equal(formatCompact(999), "999");
|
|
304
|
+
assert.equal(formatCompact(2_500), "2.5k");
|
|
305
|
+
assert.equal(formatCompact(200_000), "200k");
|
|
306
|
+
assert.equal(formatCompact(1_000_000), "1.0M");
|
|
307
|
+
assert.equal(formatCompact(12_000_000), "12M");
|
|
308
|
+
assert.equal(formatCompact(Number.NaN), "0");
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
it("status chips/bands carry dir, branch and the context window", () => {
|
|
312
|
+
const data = { model: "M", cwd: "~/dev/ceulen", branch: "main", pct: 42.6, window: 1_000_000 };
|
|
313
|
+
const band = previewShape("band", 60, th, data).map(plain)[0]!;
|
|
314
|
+
assert.ok(band.includes("📁 ~/dev/ceulen") && band.includes("⑂ main"), band);
|
|
315
|
+
assert.ok(band.includes("42.6%/1.0M"), band);
|
|
316
|
+
// Right group is justified to the band's right edge (before the closing cap cells).
|
|
317
|
+
assert.ok(band.trimEnd().endsWith("42.6%/1.0M"), band);
|
|
318
|
+
const box = previewShape("box", 60, th, data).map(plain)[0]!;
|
|
319
|
+
assert.ok(box.includes("📁 ~/dev/ceulen") && box.includes("42.6%/1.0M") && box.endsWith("╮"), box);
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
it("band fills the status chip only, not the whole line (OMP's band)", () => {
|
|
323
|
+
// Sentinel fill makes the filled span explicit and implementation-agnostic.
|
|
324
|
+
const theme: ShapeTheme = { ...th, fill: (s) => `⟦${s}⟧` };
|
|
325
|
+
const c = { w: 80, hidden: 0, theme, data: { model: "M", cwd: "~/x", branch: "main", pct: 42, window: 1_000_000 } };
|
|
326
|
+
const line = shapeById("band").top!(c as never)!;
|
|
327
|
+
const filled = line.slice(line.indexOf("⟦") + 1, line.indexOf("⟧"));
|
|
328
|
+
assert.ok(filled.includes("main"), `identity is filled: ${filled}`);
|
|
329
|
+
assert.ok(!filled.includes("42.0%/1.0M"), `context figure stays on the bare surface: ${filled}`);
|
|
330
|
+
// The context figure survives OUTSIDE the chip, and the line is still full width.
|
|
331
|
+
assert.equal(visibleWidth(line), 80, "band still spans the full width");
|
|
332
|
+
assert.ok(plain(line).includes("42.0%/1.0M"), plain(line));
|
|
333
|
+
assert.ok(plain(line).indexOf("⟧") < plain(line).indexOf("42.0%/1.0M"), "fill ends before the context figure");
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it("git segment renders OMP's indicators and goes warning when dirty", () => {
|
|
337
|
+
assert.equal(plain(statusSegments({ branch: "main" }, th).left), "π · ⑂ main", "clean tree: branch only");
|
|
338
|
+
const dirty = statusSegments({ branch: "main", git: { staged: 1, unstaged: 3, untracked: 2 } }, th).left;
|
|
339
|
+
assert.ok(plain(dirty).endsWith("⑂ main *3 +1 ?2"), plain(dirty));
|
|
340
|
+
// Dirty renders through the warning hook (OMP's statusLineGitDirty).
|
|
341
|
+
let warned = 0;
|
|
342
|
+
const th2: ShapeTheme = { ...th, warn: (s) => (warned++, s) };
|
|
343
|
+
statusSegments({ branch: "main", git: { staged: 0, unstaged: 1, untracked: 0 } }, th2);
|
|
344
|
+
assert.equal(warned, 1, "dirty tree warns");
|
|
345
|
+
assert.equal(plain(statusSegments({ branch: "main", git: { staged: 0, unstaged: 0, untracked: 0 } }, th2).left), "π · ⑂ main");
|
|
346
|
+
assert.equal(warned, 1, "clean tree does not warn again");
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
it("parseGitStats counts porcelain XY states like OMP's indicators", () => {
|
|
350
|
+
const porcelain = [
|
|
351
|
+
" M src/a.ts",
|
|
352
|
+
"M src/b.ts",
|
|
353
|
+
"MM src/c.ts",
|
|
354
|
+
"A src/d.ts",
|
|
355
|
+
"?? src/e.ts",
|
|
356
|
+
"?? src/f.ts",
|
|
357
|
+
" D src/g.ts",
|
|
358
|
+
"R a.ts -> b.ts",
|
|
359
|
+
].join("\n");
|
|
360
|
+
assert.deepEqual(parseGitStats(porcelain), { staged: 4, unstaged: 3, untracked: 2 });
|
|
361
|
+
assert.deepEqual(parseGitStats(""), { staged: 0, unstaged: 0, untracked: 0 });
|
|
146
362
|
});
|
|
147
363
|
|
|
148
364
|
it("surfacePainter re-applies the fill across nested resets (cursor glyph)", () => {
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pi's built-in tools as /config toggles over the `defaultTools` setting.
|
|
3
|
+
*
|
|
4
|
+
* Rows live on the Tools tab ("Built-in tools" section): one toggle per
|
|
5
|
+
* built-in tool plus the two built-in extension tools (codemode,
|
|
6
|
+
* tool_search). The stock four (read, bash, edit, write) default on — pi
|
|
7
|
+
* enables exactly those unless `defaultTools` changes them. A plain-list
|
|
8
|
+
* write only replaces the BUILT-IN startup selection; extension tools with
|
|
9
|
+
* `defaultActive: true` still self-activate, so ceulen's tools are never
|
|
10
|
+
* touched. Save persists to the GLOBAL settings.json (pi's typed-setter
|
|
11
|
+
* convention) with the shared atomic-write pattern and applies to the live
|
|
12
|
+
* session via applyToolSwitches (see index.ts) — the ONE exception to
|
|
13
|
+
* piSettings.ts's typed-setter-only coverage rule, because SettingsManager
|
|
14
|
+
* exposes getDefaultTools() but no setter.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
18
|
+
import path from "node:path";
|
|
19
|
+
import { SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
20
|
+
import { row, type PanelRow } from "../../lib/panel.js";
|
|
21
|
+
import { agentDirs } from "../../lib/registry.js";
|
|
22
|
+
|
|
23
|
+
/** Tools enabled at startup when `defaultTools` does not change them —
|
|
24
|
+
* pi's DEFAULT_TOOL_NAMES (core/settings-manager.js), replicated locally
|
|
25
|
+
* because pi does not export it from the package root. */
|
|
26
|
+
export const STOCK_DEFAULT_TOOLS = ["read", "bash", "edit", "write"] as const;
|
|
27
|
+
|
|
28
|
+
/** Every built-in tool the panel offers, in render order. Blurbs from pi's
|
|
29
|
+
* CLI docs. codemode/tool_search are built-in EXTENSION tools, off by
|
|
30
|
+
* default; MCP activates codemode automatically when a server needs it. */
|
|
31
|
+
const BUILTIN_TOOLS: readonly { name: string; blurb: string }[] = [
|
|
32
|
+
{ name: "read", blurb: "Read text files and supported images." },
|
|
33
|
+
{ name: "bash", blurb: "Run shell commands." },
|
|
34
|
+
{ name: "powershell", blurb: "Run PowerShell commands (registered everywhere, useful on Windows)." },
|
|
35
|
+
{ name: "edit", blurb: "Apply exact text replacements to an existing file." },
|
|
36
|
+
{ name: "write", blurb: "Create or overwrite a file." },
|
|
37
|
+
{ name: "grep", blurb: "Search file contents." },
|
|
38
|
+
{ name: "find", blurb: "Find paths using glob patterns." },
|
|
39
|
+
{ name: "ls", blurb: "List directory contents." },
|
|
40
|
+
{ name: "codemode", blurb: "Run JavaScript that calls the other tools. MCP turns it on when needed." },
|
|
41
|
+
{ name: "tool_search", blurb: "Search tools not declared to the model and declare the matches." },
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
export const DEFAULT_TOOLS_PREFIX = "pi.defaultTools.";
|
|
45
|
+
|
|
46
|
+
/** The effective startup selection: the resolved `defaultTools` merged over
|
|
47
|
+
* all layers, or the stock four when no layer sets it. */
|
|
48
|
+
export function startupToolSet(m: SettingsManager): Set<string> {
|
|
49
|
+
return new Set(m.getDefaultTools() ?? STOCK_DEFAULT_TOOLS);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Toggle row per built-in tool over a live working Set of ENABLED names.
|
|
53
|
+
* Toggles mutate the set; persistence happens in the /config save path. */
|
|
54
|
+
export function builtinToolRows(working: Set<string>): PanelRow[] {
|
|
55
|
+
return BUILTIN_TOOLS.map(({ name, blurb }) =>
|
|
56
|
+
row(`${DEFAULT_TOOLS_PREFIX}${name}`, name, "toggle", working.has(name), (v) => {
|
|
57
|
+
if (v) working.add(name);
|
|
58
|
+
else working.delete(name);
|
|
59
|
+
}, {
|
|
60
|
+
defaultValue: (STOCK_DEFAULT_TOOLS as readonly string[]).includes(name),
|
|
61
|
+
description: `${blurb} Enabled at startup for new sessions; writes the global settings.json and applies to this session immediately on save.`,
|
|
62
|
+
}),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The absolute defaultTools list that results from toggling `working`
|
|
67
|
+
* (BUILTIN_TOOLS order, deterministic). Pure — exported for tests. */
|
|
68
|
+
export function nextDefaultTools(working: Set<string>): string[] {
|
|
69
|
+
return BUILTIN_TOOLS.map(({ name }) => name).filter((n) => working.has(n));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Write the startup selection into the GLOBAL agent settings.json (the same
|
|
73
|
+
* file pi's typed setters target). A list equal to the stock four DELETES
|
|
74
|
+
* the key — that is pi's reset semantics, and it keeps the selection
|
|
75
|
+
* following future stock-default changes. Atomic (tmp + rename); a corrupt
|
|
76
|
+
* file refuses to clobber. Returns the written path for disclosure. */
|
|
77
|
+
export function writeDefaultTools(list: string[], file = path.join(agentDirs()[0]!, "settings.json")): string {
|
|
78
|
+
let settings: Record<string, unknown> = {};
|
|
79
|
+
if (existsSync(file)) {
|
|
80
|
+
try {
|
|
81
|
+
settings = JSON.parse(readFileSync(file, "utf8")) as Record<string, unknown>;
|
|
82
|
+
} catch {
|
|
83
|
+
throw new Error(`${file} is not valid JSON — fix or remove it before saving.`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (list.length === STOCK_DEFAULT_TOOLS.length && STOCK_DEFAULT_TOOLS.every((n) => list.includes(n))) {
|
|
87
|
+
delete settings.defaultTools;
|
|
88
|
+
} else {
|
|
89
|
+
settings.defaultTools = list;
|
|
90
|
+
}
|
|
91
|
+
mkdirSync(path.dirname(file), { recursive: true });
|
|
92
|
+
const tmp = file + ".tmp";
|
|
93
|
+
writeFileSync(tmp, JSON.stringify(settings, null, 2) + "\n", { mode: 0o600 });
|
|
94
|
+
renameSync(tmp, file);
|
|
95
|
+
return file;
|
|
96
|
+
}
|