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
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { existsSync, mkdtempSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { after, beforeEach, describe, it } from "node:test";
|
|
6
|
+
import { advisorConfig, buildAdvisorGroups, setAdvisorBridge, setAdvisorRegistry, type AdvisorPanelCfg } from "../configPanel.js";
|
|
7
|
+
import type { AdvisorConfig } from "../lib/config.js";
|
|
8
|
+
|
|
9
|
+
const realAgentDir = process.env.PI_CODING_AGENT_DIR;
|
|
10
|
+
let home: string;
|
|
11
|
+
let cwd: string;
|
|
12
|
+
let notes: { message: string; level: string }[];
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
home = mkdtempSync(join(tmpdir(), "ceulen-advisor-cfg-"));
|
|
16
|
+
cwd = mkdtempSync(join(tmpdir(), "ceulen-advisor-cfg-repo-"));
|
|
17
|
+
process.env.PI_CODING_AGENT_DIR = home;
|
|
18
|
+
notes = [];
|
|
19
|
+
setAdvisorRegistry(undefined);
|
|
20
|
+
setAdvisorBridge(undefined);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
after(() => {
|
|
24
|
+
setAdvisorRegistry(undefined);
|
|
25
|
+
setAdvisorBridge(undefined);
|
|
26
|
+
if (realAgentDir === undefined) delete process.env.PI_CODING_AGENT_DIR;
|
|
27
|
+
else process.env.PI_CODING_AGENT_DIR = realAgentDir;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const cfg = (over: Partial<AdvisorPanelCfg> = {}): AdvisorPanelCfg => ({
|
|
31
|
+
model: "router/zai/glm-5.3-flash",
|
|
32
|
+
thinking: "",
|
|
33
|
+
fallbacks: "",
|
|
34
|
+
enabled: true,
|
|
35
|
+
minToolCalls: 3,
|
|
36
|
+
immuneTurns: 3,
|
|
37
|
+
...over,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const catalog = [
|
|
41
|
+
{ provider: "router", id: "zai/glm-5.3-flash", name: "glm-5.3-flash" },
|
|
42
|
+
{ provider: "opencode-go", id: "deepseek-v4-pro" },
|
|
43
|
+
];
|
|
44
|
+
const useCatalog = (list: typeof catalog = catalog) => setAdvisorRegistry({ getAvailable: () => list } as never);
|
|
45
|
+
|
|
46
|
+
function ctx(): any {
|
|
47
|
+
return {
|
|
48
|
+
cwd,
|
|
49
|
+
isProjectTrusted: () => false,
|
|
50
|
+
ui: { notify: (message: string, level?: string) => notes.push({ message, level: level ?? "info" }) },
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const writeGlobal = (body: unknown): void => writeFileSync(join(home, "settings.json"), JSON.stringify(body, null, 2));
|
|
55
|
+
const readGlobal = (): any => JSON.parse(readFileSync(join(home, "settings.json"), "utf8"));
|
|
56
|
+
|
|
57
|
+
describe("buildAdvisorGroups", () => {
|
|
58
|
+
it("renders one Model-tab section with the six advisor rows", () => {
|
|
59
|
+
const groups = buildAdvisorGroups(cfg());
|
|
60
|
+
assert.equal(groups.length, 1);
|
|
61
|
+
const [group] = groups;
|
|
62
|
+
assert.equal(group!.key, "advisor");
|
|
63
|
+
assert.equal(group!.label, "Advisor");
|
|
64
|
+
assert.equal(group!.tab, "Model");
|
|
65
|
+
assert.equal(group!.icon, "🧭");
|
|
66
|
+
assert.deepEqual(group!.rows.map((r) => r.key), [
|
|
67
|
+
"advisor.enabled",
|
|
68
|
+
"advisor.model",
|
|
69
|
+
"advisor.thinking",
|
|
70
|
+
"advisor.fallbacks",
|
|
71
|
+
"advisor.watch.minToolCalls",
|
|
72
|
+
"advisor.watch.immuneTurns",
|
|
73
|
+
]);
|
|
74
|
+
const byKey = new Map(group!.rows.map((r) => [r.key, r]));
|
|
75
|
+
assert.equal(byKey.get("advisor.enabled")!.kind, "toggle");
|
|
76
|
+
assert.equal(byKey.get("advisor.enabled")!.label, "Review settled turns", "the row names the behavior, not 'advisor enabled'");
|
|
77
|
+
assert.match(String(byKey.get("advisor.enabled")!.description), /consult tool still works/, "off must disclose that the tool is unaffected");
|
|
78
|
+
assert.equal(byKey.get("advisor.enabled")!.defaultValue, true);
|
|
79
|
+
assert.equal(byKey.get("advisor.watch.minToolCalls")!.kind, "number");
|
|
80
|
+
assert.equal(byKey.get("advisor.watch.minToolCalls")!.defaultValue, 3);
|
|
81
|
+
assert.equal(byKey.get("advisor.watch.immuneTurns")!.defaultValue, 3);
|
|
82
|
+
assert.ok(byKey.get("advisor.model")!.menu, "primary model row opens a picker");
|
|
83
|
+
assert.ok(byKey.get("advisor.thinking")!.menu, "thinking row is a closed set");
|
|
84
|
+
assert.ok(byKey.get("advisor.fallbacks")!.completions, "fallback row offers inline model completions");
|
|
85
|
+
assert.equal(byKey.get("advisor.model")!.warning, undefined);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("warns on the primary row when no model is set", () => {
|
|
89
|
+
const [group] = buildAdvisorGroups(cfg({ model: "" }));
|
|
90
|
+
assert.match(String(group!.rows[1]!.warning), /No model set/);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("model menu lists (none) then the catalogue, sorted, with display names", () => {
|
|
94
|
+
useCatalog();
|
|
95
|
+
const [group] = buildAdvisorGroups(cfg());
|
|
96
|
+
const options = group!.rows[1]!.menu!();
|
|
97
|
+
assert.equal(options[0]!.value, "");
|
|
98
|
+
assert.deepEqual(options.slice(1).map((o) => o.value), ["opencode-go/deepseek-v4-pro", "router/zai/glm-5.3-flash"]);
|
|
99
|
+
assert.equal(options[2]!.description, "glm-5.3-flash");
|
|
100
|
+
assert.equal(options[1]!.description, undefined, "no name → no description noise");
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("model menu degrades to (none) without a registry", () => {
|
|
104
|
+
const [group] = buildAdvisorGroups(cfg());
|
|
105
|
+
assert.deepEqual(group!.rows[1]!.menu!().map((o) => o.value), [""]);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("thinking menu offers the model default plus every real level, never :off", () => {
|
|
109
|
+
const [group] = buildAdvisorGroups(cfg());
|
|
110
|
+
const values = group!.rows[2]!.menu!().map((o) => o.value);
|
|
111
|
+
assert.deepEqual(values, ["", "minimal", "low", "medium", "high", "xhigh", "max"]);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("fallback completions mirror the catalogue", () => {
|
|
115
|
+
useCatalog();
|
|
116
|
+
const [group] = buildAdvisorGroups(cfg());
|
|
117
|
+
const items = group!.rows[3]!.completions!();
|
|
118
|
+
assert.deepEqual(items.map((i) => i.value), ["opencode-go/deepseek-v4-pro", "router/zai/glm-5.3-flash"]);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("row setters mutate the working copy", () => {
|
|
122
|
+
const working = cfg({ model: "" });
|
|
123
|
+
const [group] = buildAdvisorGroups(working);
|
|
124
|
+
group!.rows[0]!.set(false);
|
|
125
|
+
group!.rows[1]!.set("prov/model");
|
|
126
|
+
group!.rows[2]!.set("high");
|
|
127
|
+
group!.rows[3]!.set("prov/backup, prov/two");
|
|
128
|
+
group!.rows[4]!.set("0");
|
|
129
|
+
group!.rows[5]!.set("6");
|
|
130
|
+
assert.deepEqual(working, { model: "prov/model", thinking: "high", fallbacks: "prov/backup, prov/two", enabled: false, minToolCalls: 0, immuneTurns: 6 });
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("number rows clamp garbage and negatives to the current value / zero", () => {
|
|
134
|
+
const working = cfg();
|
|
135
|
+
const [group] = buildAdvisorGroups(working);
|
|
136
|
+
group!.rows[4]!.set("nonsense");
|
|
137
|
+
group!.rows[5]!.set("-3");
|
|
138
|
+
assert.equal(working.minToolCalls, 3, "garbage keeps the previous value");
|
|
139
|
+
assert.equal(working.immuneTurns, 0, "negatives clamp to 0");
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe("advisorConfig save", () => {
|
|
144
|
+
it("no-ops unless an advisor. key was edited", async () => {
|
|
145
|
+
const m = advisorConfig();
|
|
146
|
+
await m.save(new Set(["ceulen.disabledTools.advisor"]), ctx());
|
|
147
|
+
assert.deepEqual(notes, []);
|
|
148
|
+
assert.equal(existsSync(join(home, "settings.json")), false);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("notifies and does not rewrite when nothing changed", async () => {
|
|
152
|
+
writeGlobal({ advisor: { models: ["prov/a"], watch: { minToolCalls: 3, immuneTurns: 3 } } });
|
|
153
|
+
const m = advisorConfig();
|
|
154
|
+
await m.save(new Set(["advisor.model"]), ctx());
|
|
155
|
+
assert.equal(notes[0]!.message, "Advisor: no changes.");
|
|
156
|
+
assert.equal(readGlobal().advisor.watch.minToolCalls, 3);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("writes the section, applies it live, and reports the chain", async () => {
|
|
160
|
+
const applied: AdvisorConfig[] = [];
|
|
161
|
+
setAdvisorBridge({ read: () => ({ enabled: true, models: [], watch: { minToolCalls: 3, immuneTurns: 3 } }), apply: (next) => { applied.push(next); } });
|
|
162
|
+
const m = advisorConfig();
|
|
163
|
+
m.groups()[0]!.rows[1]!.set("router/zai/glm-5.3-flash");
|
|
164
|
+
m.groups()[0]!.rows[2]!.set("high");
|
|
165
|
+
m.groups()[0]!.rows[3]!.set("opencode-go/deepseek-v4-pro");
|
|
166
|
+
m.groups()[0]!.rows[0]!.set(false);
|
|
167
|
+
await m.save(new Set(["advisor.model", "advisor.thinking", "advisor.fallbacks", "advisor.enabled"]), ctx());
|
|
168
|
+
assert.deepEqual(readGlobal().advisor, {
|
|
169
|
+
enabled: false,
|
|
170
|
+
models: ["router/zai/glm-5.3-flash:high", "opencode-go/deepseek-v4-pro"],
|
|
171
|
+
watch: { minToolCalls: 3, immuneTurns: 3 },
|
|
172
|
+
});
|
|
173
|
+
assert.deepEqual(applied, [{ enabled: false, models: ["router/zai/glm-5.3-flash:high", "opencode-go/deepseek-v4-pro"], watch: { minToolCalls: 3, immuneTurns: 3 } }]);
|
|
174
|
+
assert.match(notes[0]!.message, /Advisor saved to .*settings\.json: router\/zai\/glm-5\.3-flash:high → opencode-go\/deepseek-v4-pro/);
|
|
175
|
+
assert.match(notes[0]!.message, /auto-review off/);
|
|
176
|
+
assert.match(notes[0]!.message, /Applied to this session/);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it("clearing the primary drops the chain and says so", async () => {
|
|
180
|
+
writeGlobal({ advisor: { models: ["prov/a"], watch: { minToolCalls: 3, immuneTurns: 3 } } });
|
|
181
|
+
const m = advisorConfig();
|
|
182
|
+
m.groups()[0]!.rows[1]!.set("");
|
|
183
|
+
await m.save(new Set(["advisor.model"]), ctx());
|
|
184
|
+
assert.equal(readGlobal().advisor.models, undefined);
|
|
185
|
+
assert.match(notes[0]!.message, /chain cleared/);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it("warns when a trusted project file shadows the global save", async () => {
|
|
189
|
+
mkdirSync(join(cwd, ".pi"), { recursive: true });
|
|
190
|
+
writeFileSync(join(cwd, ".pi", "settings.json"), JSON.stringify({ "pi-advisor": { models: ["prov/project"] } }));
|
|
191
|
+
const m = advisorConfig();
|
|
192
|
+
m.groups()[0]!.rows[1]!.set("prov/a");
|
|
193
|
+
const projectCtx = ctx();
|
|
194
|
+
projectCtx.isProjectTrusted = () => true;
|
|
195
|
+
await m.save(new Set(["advisor.model"]), projectCtx);
|
|
196
|
+
assert.equal(notes[0]!.level, "warning");
|
|
197
|
+
assert.match(notes[0]!.message, /pi-advisor.*overrides this save/s);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it("reports a live-apply failure without hiding the successful write", async () => {
|
|
201
|
+
setAdvisorBridge({
|
|
202
|
+
read: () => ({ enabled: true, models: [], watch: { minToolCalls: 3, immuneTurns: 3 } }),
|
|
203
|
+
apply: () => { throw new Error("stale ctx"); },
|
|
204
|
+
});
|
|
205
|
+
const m = advisorConfig();
|
|
206
|
+
m.groups()[0]!.rows[1]!.set("prov/a");
|
|
207
|
+
await m.save(new Set(["advisor.model"]), ctx());
|
|
208
|
+
assert.equal(readGlobal().advisor.models.join(), "prov/a");
|
|
209
|
+
assert.match(notes[0]!.message, /live session update failed: stale ctx/);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it("reports a write failure and skips the live apply", async () => {
|
|
213
|
+
writeFileSync(join(home, "settings.json"), "{broken");
|
|
214
|
+
let applied = 0;
|
|
215
|
+
setAdvisorBridge({ read: () => ({ enabled: true, models: [], watch: { minToolCalls: 3, immuneTurns: 3 } }), apply: () => { applied++; } });
|
|
216
|
+
const m = advisorConfig();
|
|
217
|
+
m.groups()[0]!.rows[1]!.set("prov/a");
|
|
218
|
+
await m.save(new Set(["advisor.model"]), ctx());
|
|
219
|
+
assert.equal(applied, 0);
|
|
220
|
+
assert.equal(notes[0]!.level, "error");
|
|
221
|
+
assert.match(notes[0]!.message, /Advisor save failed: .*not valid JSON/);
|
|
222
|
+
});
|
|
223
|
+
});
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { describe, it } from "node:test";
|
|
3
|
+
import { CONTENT_FREE_SAFE, createGuard, guardCheck, isSeverity, nextCycle, normalizeNote, parseReviewOutput, sanitizeNote } from "../lib/emission-guard.js";
|
|
4
|
+
|
|
5
|
+
describe("sanitizeNote", () => {
|
|
6
|
+
it("strips control chars, zero-width, and bidi overrides", () => {
|
|
7
|
+
assert.equal(sanitizeNote("clean note"), "clean note");
|
|
8
|
+
assert.equal(sanitizeNote("invis\u200Bible\u2069"), "invisible");
|
|
9
|
+
assert.equal(sanitizeNote("bad\u0000\u001Fcontrol"), "badcontrol");
|
|
10
|
+
assert.equal(sanitizeNote("rtl\u202Eoverride"), "rtloverride");
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("guard-accepted notes are sanitized on accept", () => {
|
|
14
|
+
const g = createGuard();
|
|
15
|
+
const verdict = guardCheck(g, "nit", "note\u200Bwith\u202Ehidden");
|
|
16
|
+
assert.equal(verdict.accepted, true);
|
|
17
|
+
if (verdict.accepted) assert.equal(verdict.note, "notewithhidden");
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe("normalizeNote", () => {
|
|
22
|
+
it("lowercases, NFKC-normalizes, collapses non-alphanumerics, trims", () => {
|
|
23
|
+
assert.equal(normalizeNote(" *Stop.* "), "stop");
|
|
24
|
+
assert.equal(normalizeNote("LGTM!!"), "lgtm");
|
|
25
|
+
assert.equal(normalizeNote("No-issue CONTINUE"), "no issue continue");
|
|
26
|
+
assert.equal(normalizeNote(""), "");
|
|
27
|
+
assert.equal(normalizeNote(" --- "), "");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("keeps accented and CJK letters inside words (unicode classes, omp parity)", () => {
|
|
31
|
+
assert.equal(normalizeNote("Stöp."), "stöp");
|
|
32
|
+
assert.equal(normalizeNote("停在这里"), "停在这里");
|
|
33
|
+
assert.notEqual(normalizeNote("stöp"), "st p", "accented letters must not split into separate tokens");
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe("guardCheck", () => {
|
|
38
|
+
it("rejects empty notes", () => {
|
|
39
|
+
const g = createGuard();
|
|
40
|
+
assert.deepEqual(guardCheck(g, "nit", " "), { accepted: false, reason: "empty" });
|
|
41
|
+
assert.equal(g.counts.suppressed, 1);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("rejects content-free phrases", () => {
|
|
45
|
+
const g = createGuard();
|
|
46
|
+
for (const phrase of ["stop", "LGTM", "*Done*", "no issue continue", "nothing to add", "looks good"]) {
|
|
47
|
+
assert.deepEqual(guardCheck(g, "nit", phrase), { accepted: false, reason: "content-free" }, `phrase: ${phrase}`);
|
|
48
|
+
}
|
|
49
|
+
assert.ok(CONTENT_FREE_SAFE.has("lgtm"));
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("suppresses omp-parity filler phrases (halt, stop here, task done, carry on, no further input)", () => {
|
|
53
|
+
const g = createGuard();
|
|
54
|
+
for (const phrase of ["Halt!", "Stop here.", "Task complete!", "Carry on.", "No further input needed.", "Ok done.", "No notes."]) {
|
|
55
|
+
assert.deepEqual(guardCheck(g, "nit", phrase), { accepted: false, reason: "content-free" }, `phrase: ${phrase}`);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("suppresses bare prompt-injection imperatives with no technical content (observed live)", () => {
|
|
60
|
+
const g = createGuard();
|
|
61
|
+
for (const phrase of ["ignore previous instruction", "Ignore all previous instructions!", "disregard prior instructions."]) {
|
|
62
|
+
assert.deepEqual(guardCheck(g, "nit", phrase), { accepted: false, reason: "content-free" }, `phrase: ${phrase}`);
|
|
63
|
+
}
|
|
64
|
+
// A substantive note that merely CONTAINS the phrase must still pass:
|
|
65
|
+
assert.equal(guardCheck(g, "nit", "The README says 'ignore previous instruction' as a test — but the test fixture is committed").accepted, true);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("unicode folding: full-width filler normalizes to its ASCII key; accented letters stay distinct", () => {
|
|
69
|
+
const g = createGuard();
|
|
70
|
+
// NFKC folds compatibility forms — full-width STOP is the same noise.
|
|
71
|
+
assert.equal(normalizeNote("STOP!"), "stop");
|
|
72
|
+
assert.deepEqual(guardCheck(g, "nit", "STOP!"), { accepted: false, reason: "content-free" });
|
|
73
|
+
// Accented/CJK letters are NOT stripped: "stöp" stays one word, is not in
|
|
74
|
+
// the filler set, and passes the guard (a real note if substantive).
|
|
75
|
+
assert.equal(normalizeNote("Stöp."), "stöp");
|
|
76
|
+
assert.equal(guardCheck(g, "nit", "Stöp. Fix the import.").accepted, true);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("rejects notes that end with a no-op verdict even when wrapped in prose (padv-c9 regression)", () => {
|
|
80
|
+
const g = createGuard();
|
|
81
|
+
const cases = [
|
|
82
|
+
"Change made as requested (x>0 → x<0 in src/check.ts only). No verification step was run, but the edit is a trivial one-line inversion matching the request exactly. No note warranted.",
|
|
83
|
+
"Everything looks correct and matches the request. Nothing to flag.",
|
|
84
|
+
"The edit is fine as instructed. No action needed.",
|
|
85
|
+
"No issues found — the change is correct.",
|
|
86
|
+
];
|
|
87
|
+
for (const note of cases) {
|
|
88
|
+
assert.deepEqual(guardCheck(g, "nit", note), { accepted: false, reason: "content-free" }, `note: ${note.slice(0, 60)}…`);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("still accepts a substantive note that merely mentions the words no note", () => {
|
|
93
|
+
const g = createGuard();
|
|
94
|
+
// ends with an actionable clause, not a no-op verdict
|
|
95
|
+
const note = "No note was added to the changelog for this API change — add one before release";
|
|
96
|
+
assert.equal(guardCheck(g, "nit", note).accepted, true);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("accepts a substantive note once per cycle", () => {
|
|
100
|
+
const g = createGuard();
|
|
101
|
+
const verdict = guardCheck(g, "nit", "The edit targets src/old.ts but the caller imports lib/new.ts — verify the path");
|
|
102
|
+
assert.equal(verdict.accepted, true);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("rate-limits to one note per cycle", () => {
|
|
106
|
+
const g = createGuard();
|
|
107
|
+
assert.equal(guardCheck(g, "nit", "First substantive note about the build").accepted, true);
|
|
108
|
+
assert.deepEqual(guardCheck(g, "nit", "Second different note about tests"), { accepted: false, reason: "rate-limit" });
|
|
109
|
+
nextCycle(g);
|
|
110
|
+
assert.equal(guardCheck(g, "nit", "Second different note about tests").accepted, true);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("suppresses equal-or-lower severity duplicates, allows escalation", () => {
|
|
114
|
+
const g = createGuard();
|
|
115
|
+
assert.equal(guardCheck(g, "nit", "Wrong file path in the edit").accepted, true);
|
|
116
|
+
nextCycle(g);
|
|
117
|
+
// same text, same severity → duplicate (permanent by default window = Infinity)
|
|
118
|
+
assert.deepEqual(guardCheck(g, "nit", "Wrong file path in the edit!"), { accepted: false, reason: "duplicate" });
|
|
119
|
+
// same text, higher severity → escalation passes
|
|
120
|
+
nextCycle(g);
|
|
121
|
+
const escalated = guardCheck(g, "blocker", "Wrong file path in the edit");
|
|
122
|
+
assert.equal(escalated.accepted, true);
|
|
123
|
+
// after escalation, lower severity is again a duplicate
|
|
124
|
+
nextCycle(g);
|
|
125
|
+
assert.deepEqual(guardCheck(g, "concern", "Wrong file path in the edit"), { accepted: false, reason: "duplicate" });
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("same note re-delivers after the immuneTurns window, not before", () => {
|
|
129
|
+
const g = createGuard();
|
|
130
|
+
const window = 3;
|
|
131
|
+
const text = "Consider error handling for empty input";
|
|
132
|
+
// first review: accepted at n
|
|
133
|
+
assert.equal(guardCheck(g, "nit", text, window).accepted, true);
|
|
134
|
+
g.reviewIndex++;
|
|
135
|
+
nextCycle(g);
|
|
136
|
+
assert.deepEqual(guardCheck(g, "nit", text, window), { accepted: false, reason: "duplicate" }, "n+1 within window → still deduped");
|
|
137
|
+
nextCycle(g);
|
|
138
|
+
g.reviewIndex++;
|
|
139
|
+
assert.deepEqual(guardCheck(g, "nit", text, window), { accepted: false, reason: "duplicate" }, "n+2 still within window");
|
|
140
|
+
nextCycle(g);
|
|
141
|
+
g.reviewIndex++;
|
|
142
|
+
assert.deepEqual(guardCheck(g, "nit", text, window), { accepted: false, reason: "duplicate" }, "n+3 boundary still within");
|
|
143
|
+
nextCycle(g);
|
|
144
|
+
g.reviewIndex++;
|
|
145
|
+
assert.equal(guardCheck(g, "nit", text, window).accepted, true, "n+window+1 outside window → re-delivered");
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("content-free phrase embedded in longer note is NOT suppressed", () => {
|
|
149
|
+
const g = createGuard();
|
|
150
|
+
assert.equal(guardCheck(g, "nit", "Stop the rename: package.json still imports the old name").accepted, true);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("FIFO caps delivered history", () => {
|
|
154
|
+
const g = createGuard();
|
|
155
|
+
for (let i = 0; i < 1100; i++) {
|
|
156
|
+
guardCheck(g, "nit", `unique note number ${i} with substance`);
|
|
157
|
+
nextCycle(g);
|
|
158
|
+
}
|
|
159
|
+
assert.ok(g.delivered.size <= 1024, `delivered map size ${g.delivered.size}`);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe("parseReviewOutput", () => {
|
|
164
|
+
it("parses a strict JSON note line", () => {
|
|
165
|
+
const note = parseReviewOutput('{"severity":"concern","note":"Verify the auth guard covers /api/v2"}');
|
|
166
|
+
assert.deepEqual(note, { severity: "concern", note: "Verify the auth guard covers /api/v2" });
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("empty/blank output means no note", () => {
|
|
170
|
+
assert.equal(parseReviewOutput(""), undefined);
|
|
171
|
+
assert.equal(parseReviewOutput(" \n "), undefined);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("unparseable output is no note (conservative)", () => {
|
|
175
|
+
assert.equal(parseReviewOutput("looks fine to me, keep going"), undefined);
|
|
176
|
+
assert.equal(parseReviewOutput("{broken json"), undefined);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it("rejects invalid severity or missing note", () => {
|
|
180
|
+
assert.equal(parseReviewOutput('{"severity":"urgent","note":"x"}'), undefined);
|
|
181
|
+
assert.equal(parseReviewOutput('{"severity":"nit"}'), undefined);
|
|
182
|
+
assert.equal(parseReviewOutput('{"severity":"nit","note":" "}'), undefined);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it("clamps long notes to 280 chars", () => {
|
|
186
|
+
const note = parseReviewOutput(`{"severity":"nit","note":"${"x".repeat(500)}"}`);
|
|
187
|
+
assert.equal(note?.note.length, 280);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it("extracts JSON from surrounding prose", () => {
|
|
191
|
+
const note = parseReviewOutput('Here is my review:\n{"severity":"blocker","note":"the deploy will fail"}\nthanks');
|
|
192
|
+
assert.deepEqual(note, { severity: "blocker", note: "the deploy will fail" });
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it("isSeverity narrows correctly", () => {
|
|
196
|
+
assert.equal(isSeverity("nit"), true);
|
|
197
|
+
assert.equal(isSeverity("blocker"), true);
|
|
198
|
+
assert.equal(isSeverity("urgent"), false);
|
|
199
|
+
assert.equal(isSeverity(undefined), false);
|
|
200
|
+
});
|
|
201
|
+
});
|