@@ -19,6 +19,22 @@ import pkg from "./package.json" with { type: "json" };
1919const PLUGIN_VERSION : string = pkg . version ;
2020const DEFAULT_API_BASE = "https://api.kilo.ai" ;
2121
22+ // OpenClaw invokes a plugin's `register(api)` once per distinct
23+ // `loadOpenClawPlugins` cacheKey (gateway startup, provider discovery,
24+ // metadata registry, web-fetch/web-search runtimes, etc.), so in a
25+ // single process `register` typically runs ~15 times. Without this
26+ // guard the three "Registered …" info lines below fire every time,
27+ // which produced the 44-line log spam observed in KiloClaw boots.
28+ // Module scope survives across all register() calls in the same
29+ // process, so we log once and stay quiet after that.
30+ //
31+ // Scope note: this guard covers logging only. Re-invoking
32+ // `api.registerTool(...)` and `api.registerCommand(...)` on every
33+ // register() call is intentional — each `loadOpenClawPlugins` pass
34+ // builds its own registry, and the plugin must register into every
35+ // one to be visible in that context.
36+ let registrationLogged = false ;
37+
2238type ToolResult = {
2339 content : Array < { type : "text" ; text : string } > ;
2440} ;
@@ -470,8 +486,11 @@ export default definePluginEntry({
470486 handler : runSlashCommand ,
471487 } ) ;
472488
473- api . logger . info ?.( "Registered tool: kilocode_shell_security" ) ;
474- api . logger . info ?.( "Registered command: /shell-security" ) ;
475- api . logger . info ?.( "Registered command: /security-checkup (legacy alias)" ) ;
489+ if ( ! registrationLogged ) {
490+ api . logger . info ?.( "Registered tool: kilocode_shell_security" ) ;
491+ api . logger . info ?.( "Registered command: /shell-security" ) ;
492+ api . logger . info ?.( "Registered command: /security-checkup (legacy alias)" ) ;
493+ registrationLogged = true ;
494+ }
476495 } ,
477496} ) ;
0 commit comments