clikit-plugin 0.2.22 → 0.2.23

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AA6DlD,QAAA,MAAM,YAAY,EAAE,MAmTnB,CAAC;AAEF,eAAe,YAAY,CAAC;AAG5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACvD,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1E,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC1F,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG1D,OAAO,EACL,mBAAmB,EAAE,uBAAuB,EAC5C,cAAc,EAAE,eAAe,EAC/B,qBAAqB,EAAE,oBAAoB,EAC3C,qBAAqB,EAAE,eAAe,EAAE,qBAAqB,EAC7D,gBAAgB,EAAE,cAAc,EAAE,oBAAoB,EACtD,mBAAmB,EAAE,sBAAsB,EAAE,oBAAoB,EACjE,cAAc,EAAE,aAAa,EAAE,gBAAgB,EAC/C,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAC/C,gBAAgB,EAAE,YAAY,EAAE,sBAAsB,EACtD,gBAAgB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,qBAAqB,EACtF,cAAc,EAAE,cAAc,EAAE,mBAAmB,EACnD,wBAAwB,EAAE,oBAAoB,EAAE,mBAAmB,GACpE,MAAM,SAAS,CAAC;AAGjB,OAAO,EAEL,UAAU,EACV,YAAY,EACZ,SAAS,EACT,cAAc,EACd,YAAY,EACZ,WAAW,EACX,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EAEtB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EAEtB,KAAK,EACL,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,WAAW,EAEhB,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,cAAc,EACd,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AA6DlD,QAAA,MAAM,YAAY,EAAE,MA4TnB,CAAC;AAEF,eAAe,YAAY,CAAC;AAG5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACvD,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1E,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC1F,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG1D,OAAO,EACL,mBAAmB,EAAE,uBAAuB,EAC5C,cAAc,EAAE,eAAe,EAC/B,qBAAqB,EAAE,oBAAoB,EAC3C,qBAAqB,EAAE,eAAe,EAAE,qBAAqB,EAC7D,gBAAgB,EAAE,cAAc,EAAE,oBAAoB,EACtD,mBAAmB,EAAE,sBAAsB,EAAE,oBAAoB,EACjE,cAAc,EAAE,aAAa,EAAE,gBAAgB,EAC/C,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAC/C,gBAAgB,EAAE,YAAY,EAAE,sBAAsB,EACtD,gBAAgB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,qBAAqB,EACtF,cAAc,EAAE,cAAc,EAAE,mBAAmB,EACnD,wBAAwB,EAAE,oBAAoB,EAAE,mBAAmB,GACpE,MAAM,SAAS,CAAC;AAGjB,OAAO,EAEL,UAAU,EACV,YAAY,EACZ,SAAS,EACT,cAAc,EACd,YAAY,EACZ,WAAW,EACX,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EAEtB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EAEtB,KAAK,EACL,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,WAAW,EAEhB,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,cAAc,EACd,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -5823,245 +5823,252 @@ function buildSummary(sections, maxTokens) {
5823
5823
  }
5824
5824
  // src/index.ts
5825
5825
  var CliKitPlugin = async (ctx) => {
5826
- const pluginConfig = loadCliKitConfig(ctx.directory) ?? {};
5827
- const builtinAgents = getBuiltinAgents();
5828
- const builtinCommands = getBuiltinCommands();
5829
- const filteredAgents = filterAgents(builtinAgents, pluginConfig);
5830
- const filteredCommands = filterCommands(builtinCommands, pluginConfig);
5831
- console.log(`[CliKit] Loaded ${Object.keys(filteredAgents).length}/${Object.keys(builtinAgents).length} agents`);
5832
- console.log(`[CliKit] Loaded ${Object.keys(filteredCommands).length}/${Object.keys(builtinCommands).length} commands`);
5833
- if (pluginConfig.disabled_agents?.length) {
5834
- console.log(`[CliKit] Disabled agents: ${pluginConfig.disabled_agents.join(", ")}`);
5835
- }
5836
- if (pluginConfig.disabled_commands?.length) {
5837
- console.log(`[CliKit] Disabled commands: ${pluginConfig.disabled_commands.join(", ")}`);
5838
- }
5839
- return {
5840
- config: async (config) => {
5841
- config.agent = {
5842
- ...filteredAgents,
5843
- ...config.agent
5844
- };
5845
- config.command = {
5846
- ...filteredCommands,
5847
- ...config.command
5848
- };
5849
- if (pluginConfig.lsp && Object.keys(pluginConfig.lsp).length > 0) {
5850
- const enabledLsp = {};
5851
- for (const [name, lspConfig] of Object.entries(pluginConfig.lsp)) {
5852
- if (!lspConfig.disabled) {
5853
- enabledLsp[name] = lspConfig;
5826
+ console.log("[CliKit] Plugin initializing...");
5827
+ console.log("[CliKit] Context:", JSON.stringify({ directory: ctx?.directory, hasClient: !!ctx?.client }));
5828
+ try {
5829
+ const pluginConfig = loadCliKitConfig(ctx.directory) ?? {};
5830
+ const builtinAgents = getBuiltinAgents();
5831
+ const builtinCommands = getBuiltinCommands();
5832
+ const filteredAgents = filterAgents(builtinAgents, pluginConfig);
5833
+ const filteredCommands = filterCommands(builtinCommands, pluginConfig);
5834
+ console.log(`[CliKit] Loaded ${Object.keys(filteredAgents).length}/${Object.keys(builtinAgents).length} agents`);
5835
+ console.log(`[CliKit] Loaded ${Object.keys(filteredCommands).length}/${Object.keys(builtinCommands).length} commands`);
5836
+ if (pluginConfig.disabled_agents?.length) {
5837
+ console.log(`[CliKit] Disabled agents: ${pluginConfig.disabled_agents.join(", ")}`);
5838
+ }
5839
+ if (pluginConfig.disabled_commands?.length) {
5840
+ console.log(`[CliKit] Disabled commands: ${pluginConfig.disabled_commands.join(", ")}`);
5841
+ }
5842
+ return {
5843
+ config: async (config) => {
5844
+ config.agent = {
5845
+ ...filteredAgents,
5846
+ ...config.agent
5847
+ };
5848
+ config.command = {
5849
+ ...filteredCommands,
5850
+ ...config.command
5851
+ };
5852
+ if (pluginConfig.lsp && Object.keys(pluginConfig.lsp).length > 0) {
5853
+ const enabledLsp = {};
5854
+ for (const [name, lspConfig] of Object.entries(pluginConfig.lsp)) {
5855
+ if (!lspConfig.disabled) {
5856
+ enabledLsp[name] = lspConfig;
5857
+ }
5858
+ }
5859
+ if (Object.keys(enabledLsp).length > 0) {
5860
+ config.lsp = {
5861
+ ...enabledLsp,
5862
+ ...config.lsp || {}
5863
+ };
5864
+ console.log(`[CliKit] Injected ${Object.keys(enabledLsp).length} LSP server(s)`);
5854
5865
  }
5855
5866
  }
5856
- if (Object.keys(enabledLsp).length > 0) {
5857
- config.lsp = {
5858
- ...enabledLsp,
5859
- ...config.lsp || {}
5860
- };
5861
- console.log(`[CliKit] Injected ${Object.keys(enabledLsp).length} LSP server(s)`);
5862
- }
5863
- }
5864
- },
5865
- event: async (input) => {
5866
- const { event } = input;
5867
- const props = event.properties;
5868
- if (event.type === "session.created") {
5869
- if (pluginConfig.hooks?.session_logging) {
5870
- const info = props?.info;
5871
- console.log(`[CliKit] Session created: ${info?.id || "unknown"}`);
5872
- }
5873
- if (pluginConfig.hooks?.env_context?.enabled !== false) {
5874
- const envConfig = pluginConfig.hooks?.env_context;
5875
- const envInfo = collectEnvInfo(ctx.directory, envConfig);
5876
- const envBlock = buildEnvBlock(envInfo);
5877
- console.log(formatEnvSummary(envInfo));
5878
- input.__envBlock = envBlock;
5879
- }
5880
- }
5881
- if (event.type === "session.error") {
5882
- const error = props?.error;
5883
- if (pluginConfig.hooks?.session_logging) {
5884
- console.error(`[CliKit] Session error:`, error);
5885
- }
5886
- if (pluginConfig.hooks?.session_notification?.enabled !== false && pluginConfig.hooks?.session_notification?.on_error !== false) {
5887
- const notifConfig = pluginConfig.hooks?.session_notification;
5888
- const sessionId = props?.sessionID;
5889
- const payload = buildErrorNotification(error, sessionId, notifConfig?.title_prefix);
5890
- const sent = sendNotification(payload);
5891
- console.log(formatNotificationLog(payload, sent));
5867
+ },
5868
+ event: async (input) => {
5869
+ const { event } = input;
5870
+ const props = event.properties;
5871
+ if (event.type === "session.created") {
5872
+ if (pluginConfig.hooks?.session_logging) {
5873
+ const info = props?.info;
5874
+ console.log(`[CliKit] Session created: ${info?.id || "unknown"}`);
5875
+ }
5876
+ if (pluginConfig.hooks?.env_context?.enabled !== false) {
5877
+ const envConfig = pluginConfig.hooks?.env_context;
5878
+ const envInfo = collectEnvInfo(ctx.directory, envConfig);
5879
+ const envBlock = buildEnvBlock(envInfo);
5880
+ console.log(formatEnvSummary(envInfo));
5881
+ input.__envBlock = envBlock;
5882
+ }
5892
5883
  }
5893
- }
5894
- if (event.type === "session.idle") {
5895
- const sessionID = props?.sessionID;
5896
- if (pluginConfig.hooks?.session_logging) {
5897
- console.log(`[CliKit] Session idle: ${sessionID || "unknown"}`);
5884
+ if (event.type === "session.error") {
5885
+ const error = props?.error;
5886
+ if (pluginConfig.hooks?.session_logging) {
5887
+ console.error(`[CliKit] Session error:`, error);
5888
+ }
5889
+ if (pluginConfig.hooks?.session_notification?.enabled !== false && pluginConfig.hooks?.session_notification?.on_error !== false) {
5890
+ const notifConfig = pluginConfig.hooks?.session_notification;
5891
+ const sessionId = props?.sessionID;
5892
+ const payload = buildErrorNotification(error, sessionId, notifConfig?.title_prefix);
5893
+ const sent = sendNotification(payload);
5894
+ console.log(formatNotificationLog(payload, sent));
5895
+ }
5898
5896
  }
5899
- const todoConfig = pluginConfig.hooks?.todo_enforcer;
5900
- if (todoConfig?.enabled !== false) {
5901
- const todos = props?.todos;
5902
- if (Array.isArray(todos) && todos.length > 0) {
5903
- const result = checkTodoCompletion(todos);
5904
- if (!result.complete && todoConfig?.warn_on_incomplete !== false) {
5905
- console.warn(formatIncompleteWarning(result, sessionID));
5897
+ if (event.type === "session.idle") {
5898
+ const sessionID = props?.sessionID;
5899
+ if (pluginConfig.hooks?.session_logging) {
5900
+ console.log(`[CliKit] Session idle: ${sessionID || "unknown"}`);
5901
+ }
5902
+ const todoConfig = pluginConfig.hooks?.todo_enforcer;
5903
+ if (todoConfig?.enabled !== false) {
5904
+ const todos = props?.todos;
5905
+ if (Array.isArray(todos) && todos.length > 0) {
5906
+ const result = checkTodoCompletion(todos);
5907
+ if (!result.complete && todoConfig?.warn_on_incomplete !== false) {
5908
+ console.warn(formatIncompleteWarning(result, sessionID));
5909
+ }
5906
5910
  }
5907
5911
  }
5908
- }
5909
- if (pluginConfig.hooks?.session_notification?.enabled !== false && pluginConfig.hooks?.session_notification?.on_idle !== false) {
5910
- const notifConfig = pluginConfig.hooks?.session_notification;
5911
- const payload = buildIdleNotification(sessionID, notifConfig?.title_prefix);
5912
- const sent = sendNotification(payload);
5913
- console.log(formatNotificationLog(payload, sent));
5914
- }
5915
- if (pluginConfig.hooks?.compaction?.enabled !== false) {
5916
- const compConfig = pluginConfig.hooks?.compaction;
5917
- const compPayload = collectCompactionPayload(ctx.directory, compConfig);
5918
- if (compConfig?.include_todo_state !== false && props?.todos) {
5919
- compPayload.todos = props.todos;
5912
+ if (pluginConfig.hooks?.session_notification?.enabled !== false && pluginConfig.hooks?.session_notification?.on_idle !== false) {
5913
+ const notifConfig = pluginConfig.hooks?.session_notification;
5914
+ const payload = buildIdleNotification(sessionID, notifConfig?.title_prefix);
5915
+ const sent = sendNotification(payload);
5916
+ console.log(formatNotificationLog(payload, sent));
5917
+ }
5918
+ if (pluginConfig.hooks?.compaction?.enabled !== false) {
5919
+ const compConfig = pluginConfig.hooks?.compaction;
5920
+ const compPayload = collectCompactionPayload(ctx.directory, compConfig);
5921
+ if (compConfig?.include_todo_state !== false && props?.todos) {
5922
+ compPayload.todos = props.todos;
5923
+ }
5924
+ const block = buildCompactionBlock(compPayload, compConfig?.max_state_chars);
5925
+ console.log(formatCompactionLog(compPayload));
5926
+ input.__compactionBlock = block;
5920
5927
  }
5921
- const block = buildCompactionBlock(compPayload, compConfig?.max_state_chars);
5922
- console.log(formatCompactionLog(compPayload));
5923
- input.__compactionBlock = block;
5924
5928
  }
5925
- }
5926
- },
5927
- "tool.execute.before": async (input, _output) => {
5928
- const toolName = input.tool;
5929
- const toolInput = input.input ?? {};
5930
- if (pluginConfig.hooks?.tool_logging) {
5931
- console.log(`[CliKit] Tool executing: ${toolName}`);
5932
- }
5933
- if (pluginConfig.hooks?.git_guard?.enabled !== false) {
5934
- if (toolName === "bash" || toolName === "Bash") {
5935
- const command = toolInput.command;
5936
- if (command) {
5937
- const allowForceWithLease = pluginConfig.hooks?.git_guard?.allow_force_with_lease !== false;
5938
- const result = checkDangerousCommand(command, allowForceWithLease);
5939
- if (result.blocked) {
5940
- console.warn(formatBlockedWarning(result));
5941
- input.__blocked = true;
5942
- input.__blockReason = result.reason;
5929
+ },
5930
+ "tool.execute.before": async (input, _output) => {
5931
+ const toolName = input.tool;
5932
+ const toolInput = input.input ?? {};
5933
+ if (pluginConfig.hooks?.tool_logging) {
5934
+ console.log(`[CliKit] Tool executing: ${toolName}`);
5935
+ }
5936
+ if (pluginConfig.hooks?.git_guard?.enabled !== false) {
5937
+ if (toolName === "bash" || toolName === "Bash") {
5938
+ const command = toolInput.command;
5939
+ if (command) {
5940
+ const allowForceWithLease = pluginConfig.hooks?.git_guard?.allow_force_with_lease !== false;
5941
+ const result = checkDangerousCommand(command, allowForceWithLease);
5942
+ if (result.blocked) {
5943
+ console.warn(formatBlockedWarning(result));
5944
+ input.__blocked = true;
5945
+ input.__blockReason = result.reason;
5946
+ }
5943
5947
  }
5944
5948
  }
5945
5949
  }
5946
- }
5947
- if (pluginConfig.hooks?.security_check?.enabled !== false) {
5948
- if (toolName === "bash" || toolName === "Bash") {
5949
- const command = toolInput.command;
5950
- if (command && /git\s+(commit|add)/.test(command)) {
5951
- const secConfig = pluginConfig.hooks?.security_check;
5952
- let shouldBlock = false;
5953
- const files = toolInput.files;
5954
- if (files) {
5955
- for (const file of files) {
5956
- if (isSensitiveFile(file)) {
5957
- console.warn(`[CliKit:security] Sensitive file staged: ${file}`);
5950
+ if (pluginConfig.hooks?.security_check?.enabled !== false) {
5951
+ if (toolName === "bash" || toolName === "Bash") {
5952
+ const command = toolInput.command;
5953
+ if (command && /git\s+(commit|add)/.test(command)) {
5954
+ const secConfig = pluginConfig.hooks?.security_check;
5955
+ let shouldBlock = false;
5956
+ const files = toolInput.files;
5957
+ if (files) {
5958
+ for (const file of files) {
5959
+ if (isSensitiveFile(file)) {
5960
+ console.warn(`[CliKit:security] Sensitive file staged: ${file}`);
5961
+ shouldBlock = true;
5962
+ }
5963
+ }
5964
+ }
5965
+ const content = toolInput.content;
5966
+ if (content) {
5967
+ const scanResult = scanContentForSecrets(content);
5968
+ if (!scanResult.safe) {
5969
+ console.warn(formatSecurityWarning(scanResult));
5958
5970
  shouldBlock = true;
5959
5971
  }
5960
5972
  }
5961
- }
5962
- const content = toolInput.content;
5963
- if (content) {
5964
- const scanResult = scanContentForSecrets(content);
5965
- if (!scanResult.safe) {
5966
- console.warn(formatSecurityWarning(scanResult));
5967
- shouldBlock = true;
5973
+ if (shouldBlock && secConfig?.block_commits) {
5974
+ input.__blocked = true;
5975
+ input.__blockReason = "Sensitive data detected in commit";
5968
5976
  }
5969
5977
  }
5970
- if (shouldBlock && secConfig?.block_commits) {
5978
+ }
5979
+ }
5980
+ if (pluginConfig.hooks?.subagent_question_blocker?.enabled !== false) {
5981
+ if (isSubagentTool(toolName)) {
5982
+ const prompt = toolInput.prompt;
5983
+ if (prompt && containsQuestion(prompt)) {
5984
+ console.warn(formatBlockerWarning());
5971
5985
  input.__blocked = true;
5972
- input.__blockReason = "Sensitive data detected in commit";
5986
+ input.__blockReason = "Subagents should not ask questions";
5973
5987
  }
5974
5988
  }
5975
5989
  }
5976
- }
5977
- if (pluginConfig.hooks?.subagent_question_blocker?.enabled !== false) {
5978
- if (isSubagentTool(toolName)) {
5979
- const prompt = toolInput.prompt;
5980
- if (prompt && containsQuestion(prompt)) {
5981
- console.warn(formatBlockerWarning());
5982
- input.__blocked = true;
5983
- input.__blockReason = "Subagents should not ask questions";
5984
- }
5990
+ },
5991
+ "tool.execute.after": async (input, output) => {
5992
+ const toolName = input.tool;
5993
+ const toolInput = input.input ?? {};
5994
+ const toolOutput = output;
5995
+ if (pluginConfig.hooks?.tool_logging) {
5996
+ console.log(`[CliKit] Tool completed: ${toolName} -> ${output.title}`);
5985
5997
  }
5986
- }
5987
- },
5988
- "tool.execute.after": async (input, output) => {
5989
- const toolName = input.tool;
5990
- const toolInput = input.input ?? {};
5991
- const toolOutput = output;
5992
- if (pluginConfig.hooks?.tool_logging) {
5993
- console.log(`[CliKit] Tool completed: ${toolName} -> ${output.title}`);
5994
- }
5995
- const sanitizerConfig = pluginConfig.hooks?.empty_message_sanitizer;
5996
- if (sanitizerConfig?.enabled !== false) {
5997
- if (toolOutput.content !== undefined && isEmptyContent(toolOutput.content)) {
5998
- const placeholder = sanitizerConfig?.placeholder || "(No output)";
5999
- if (sanitizerConfig?.log_empty !== false) {
6000
- console.log(`[CliKit] Empty output detected for tool: ${toolName}`);
5998
+ const sanitizerConfig = pluginConfig.hooks?.empty_message_sanitizer;
5999
+ if (sanitizerConfig?.enabled !== false) {
6000
+ if (toolOutput.content !== undefined && isEmptyContent(toolOutput.content)) {
6001
+ const placeholder = sanitizerConfig?.placeholder || "(No output)";
6002
+ if (sanitizerConfig?.log_empty !== false) {
6003
+ console.log(`[CliKit] Empty output detected for tool: ${toolName}`);
6004
+ }
6005
+ toolOutput.content = sanitizeContent(toolOutput.content, placeholder);
6001
6006
  }
6002
- toolOutput.content = sanitizeContent(toolOutput.content, placeholder);
6003
6007
  }
6004
- }
6005
- if (pluginConfig.hooks?.comment_checker?.enabled !== false) {
6006
- if (toolName === "edit" || toolName === "Edit" || toolName === "write" || toolName === "Write") {
6007
- const content = toolOutput.content;
6008
- if (typeof content === "string" && content.length > 100) {
6009
- const threshold = pluginConfig.hooks?.comment_checker?.threshold ?? 0.3;
6010
- const densityResult = checkCommentDensity(content, threshold);
6011
- if (densityResult.excessive) {
6012
- console.warn(formatCommentWarning(densityResult));
6013
- }
6014
- if (hasExcessiveAIComments(content)) {
6015
- console.warn("[CliKit:comment-checker] Detected AI-style boilerplate comments. Remove unnecessary comments.");
6008
+ if (pluginConfig.hooks?.comment_checker?.enabled !== false) {
6009
+ if (toolName === "edit" || toolName === "Edit" || toolName === "write" || toolName === "Write") {
6010
+ const content = toolOutput.content;
6011
+ if (typeof content === "string" && content.length > 100) {
6012
+ const threshold = pluginConfig.hooks?.comment_checker?.threshold ?? 0.3;
6013
+ const densityResult = checkCommentDensity(content, threshold);
6014
+ if (densityResult.excessive) {
6015
+ console.warn(formatCommentWarning(densityResult));
6016
+ }
6017
+ if (hasExcessiveAIComments(content)) {
6018
+ console.warn("[CliKit:comment-checker] Detected AI-style boilerplate comments. Remove unnecessary comments.");
6019
+ }
6016
6020
  }
6017
6021
  }
6018
6022
  }
6019
- }
6020
- if (pluginConfig.hooks?.truncator?.enabled !== false) {
6021
- if (typeof toolOutput.content === "string" && shouldTruncate(toolOutput.content, pluginConfig.hooks?.truncator)) {
6022
- const result = truncateOutput(toolOutput.content, pluginConfig.hooks?.truncator);
6023
- if (result.truncated) {
6024
- toolOutput.content = result.content;
6025
- if (pluginConfig.hooks?.truncator?.log !== false) {
6026
- console.log(formatTruncationLog(result));
6023
+ if (pluginConfig.hooks?.truncator?.enabled !== false) {
6024
+ if (typeof toolOutput.content === "string" && shouldTruncate(toolOutput.content, pluginConfig.hooks?.truncator)) {
6025
+ const result = truncateOutput(toolOutput.content, pluginConfig.hooks?.truncator);
6026
+ if (result.truncated) {
6027
+ toolOutput.content = result.content;
6028
+ if (pluginConfig.hooks?.truncator?.log !== false) {
6029
+ console.log(formatTruncationLog(result));
6030
+ }
6027
6031
  }
6028
6032
  }
6029
6033
  }
6030
- }
6031
- if (pluginConfig.hooks?.auto_format?.enabled) {
6032
- if (toolName === "edit" || toolName === "Edit" || toolName === "write" || toolName === "Write") {
6033
- const filePath = toolInput.filePath;
6034
- if (filePath) {
6035
- const fmtConfig = pluginConfig.hooks.auto_format;
6036
- if (shouldFormat(filePath, fmtConfig?.extensions)) {
6037
- const result = runFormatter(filePath, ctx.directory, fmtConfig?.formatter);
6038
- if (fmtConfig?.log !== false) {
6039
- console.log(formatAutoFormatLog(result));
6034
+ if (pluginConfig.hooks?.auto_format?.enabled) {
6035
+ if (toolName === "edit" || toolName === "Edit" || toolName === "write" || toolName === "Write") {
6036
+ const filePath = toolInput.filePath;
6037
+ if (filePath) {
6038
+ const fmtConfig = pluginConfig.hooks.auto_format;
6039
+ if (shouldFormat(filePath, fmtConfig?.extensions)) {
6040
+ const result = runFormatter(filePath, ctx.directory, fmtConfig?.formatter);
6041
+ if (fmtConfig?.log !== false) {
6042
+ console.log(formatAutoFormatLog(result));
6043
+ }
6040
6044
  }
6041
6045
  }
6042
6046
  }
6043
6047
  }
6044
- }
6045
- if (pluginConfig.hooks?.typecheck_gate?.enabled) {
6046
- if (toolName === "edit" || toolName === "Edit" || toolName === "write" || toolName === "Write") {
6047
- const filePath = toolInput.filePath;
6048
- if (filePath && isTypeScriptFile(filePath)) {
6049
- const tcConfig = pluginConfig.hooks.typecheck_gate;
6050
- const result = runTypeCheck(filePath, ctx.directory, tcConfig);
6051
- if (!result.clean) {
6052
- console.warn(formatTypeCheckWarning(result));
6053
- if (tcConfig?.block_on_error) {
6054
- input.__blocked = true;
6055
- input.__blockReason = `Type errors in ${filePath}`;
6048
+ if (pluginConfig.hooks?.typecheck_gate?.enabled) {
6049
+ if (toolName === "edit" || toolName === "Edit" || toolName === "write" || toolName === "Write") {
6050
+ const filePath = toolInput.filePath;
6051
+ if (filePath && isTypeScriptFile(filePath)) {
6052
+ const tcConfig = pluginConfig.hooks.typecheck_gate;
6053
+ const result = runTypeCheck(filePath, ctx.directory, tcConfig);
6054
+ if (!result.clean) {
6055
+ console.warn(formatTypeCheckWarning(result));
6056
+ if (tcConfig?.block_on_error) {
6057
+ input.__blocked = true;
6058
+ input.__blockReason = `Type errors in ${filePath}`;
6059
+ }
6060
+ } else if (tcConfig?.log !== false) {
6061
+ console.log(formatTypeCheckWarning(result));
6056
6062
  }
6057
- } else if (tcConfig?.log !== false) {
6058
- console.log(formatTypeCheckWarning(result));
6059
6063
  }
6060
6064
  }
6061
6065
  }
6062
6066
  }
6063
- }
6064
- };
6067
+ };
6068
+ } catch (error) {
6069
+ console.error("[CliKit] Plugin initialization error:", error);
6070
+ throw error;
6071
+ }
6065
6072
  };
6066
6073
  var src_default = CliKitPlugin;
6067
6074
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clikit-plugin",
3
- "version": "0.2.22",
3
+ "version": "0.2.23",
4
4
  "description": "OpenCode plugin with 10 agents, 19 commands, 48 skills, 14 hooks",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",