bashbros 0.1.1 → 0.1.3

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.
@@ -10,7 +10,7 @@ import {
10
10
  } from "./chunk-A535VV7N.js";
11
11
  import {
12
12
  PolicyEngine
13
- } from "./chunk-GD5VNHIN.js";
13
+ } from "./chunk-QWZGB4V3.js";
14
14
  import {
15
15
  __require
16
16
  } from "./chunk-7OCVIDC7.js";
@@ -421,6 +421,7 @@ import { homedir as homedir2 } from "os";
421
421
  var CLAUDE_SETTINGS_PATH = join2(homedir2(), ".claude", "settings.json");
422
422
  var CLAUDE_DIR = join2(homedir2(), ".claude");
423
423
  var BASHBROS_HOOK_MARKER = "# bashbros-managed";
424
+ var BASHBROS_ALL_TOOLS_MARKER = "--marker=bashbros-all-tools";
424
425
  var ClaudeCodeHooks = class {
425
426
  /**
426
427
  * Check if Claude Code is installed
@@ -570,19 +571,106 @@ var ClaudeCodeHooks = class {
570
571
  const claudeInstalled = this.isClaudeInstalled();
571
572
  const settings = claudeInstalled ? this.loadSettings() : {};
572
573
  const hooksInstalled = this.isInstalled(settings);
574
+ const allToolsInstalled = this.isAllToolsInstalled(settings);
573
575
  const hooks = [];
574
576
  if (settings.hooks?.PreToolUse) hooks.push("PreToolUse (gate)");
575
577
  if (settings.hooks?.PostToolUse) hooks.push("PostToolUse (record)");
576
578
  if (settings.hooks?.SessionEnd) hooks.push("SessionEnd (report)");
579
+ if (allToolsInstalled) hooks.push("PostToolUse (all-tools)");
577
580
  return {
578
581
  claudeInstalled,
579
582
  hooksInstalled,
583
+ allToolsInstalled,
580
584
  hooks
581
585
  };
582
586
  }
587
+ /**
588
+ * Check if all-tools recording is installed
589
+ */
590
+ static isAllToolsInstalled(settings) {
591
+ const s = settings || this.loadSettings();
592
+ if (!s.hooks?.PostToolUse) return false;
593
+ return s.hooks.PostToolUse.some(
594
+ (h) => h.hooks.some(
595
+ (hook) => hook.command.includes(BASHBROS_ALL_TOOLS_MARKER) || hook.command.includes("bashbros-all-tools")
596
+ )
597
+ );
598
+ }
599
+ /**
600
+ * Install all-tools recording hook (records ALL Claude Code tools, not just Bash)
601
+ */
602
+ static installAllTools() {
603
+ if (!this.isClaudeInstalled()) {
604
+ return {
605
+ success: false,
606
+ message: "Claude Code not found. Install Claude Code first."
607
+ };
608
+ }
609
+ const settings = this.loadSettings();
610
+ if (!settings.hooks) {
611
+ settings.hooks = {};
612
+ }
613
+ if (this.isAllToolsInstalled(settings)) {
614
+ return {
615
+ success: true,
616
+ message: "BashBros all-tools recording already installed."
617
+ };
618
+ }
619
+ const allToolsHook = {
620
+ matcher: "",
621
+ // Empty matcher matches ALL tools
622
+ hooks: [{
623
+ type: "command",
624
+ command: `bashbros record-tool ${BASHBROS_ALL_TOOLS_MARKER}`
625
+ }]
626
+ };
627
+ settings.hooks.PostToolUse = [
628
+ allToolsHook,
629
+ ...settings.hooks.PostToolUse || []
630
+ ];
631
+ this.saveSettings(settings);
632
+ return {
633
+ success: true,
634
+ message: "BashBros all-tools recording installed. All Claude Code tools will now be recorded."
635
+ };
636
+ }
637
+ /**
638
+ * Uninstall all-tools recording hook
639
+ */
640
+ static uninstallAllTools() {
641
+ if (!this.isClaudeInstalled()) {
642
+ return {
643
+ success: false,
644
+ message: "Claude Code not found."
645
+ };
646
+ }
647
+ const settings = this.loadSettings();
648
+ if (!settings.hooks?.PostToolUse) {
649
+ return {
650
+ success: true,
651
+ message: "No all-tools hook to uninstall."
652
+ };
653
+ }
654
+ settings.hooks.PostToolUse = settings.hooks.PostToolUse.filter(
655
+ (h) => !h.hooks.some(
656
+ (hook) => hook.command.includes(BASHBROS_ALL_TOOLS_MARKER) || hook.command.includes("bashbros-all-tools")
657
+ )
658
+ );
659
+ if (settings.hooks.PostToolUse.length === 0) {
660
+ delete settings.hooks.PostToolUse;
661
+ }
662
+ if (Object.keys(settings.hooks).length === 0) {
663
+ delete settings.hooks;
664
+ }
665
+ this.saveSettings(settings);
666
+ return {
667
+ success: true,
668
+ message: "BashBros all-tools recording uninstalled."
669
+ };
670
+ }
583
671
  };
584
672
  async function gateCommand(command) {
585
- const { PolicyEngine: PolicyEngine2 } = await import("./engine-PKLXW6OF.js");
673
+ const { PolicyEngine: PolicyEngine2 } = await import("./engine-EGPAS2EX.js");
586
674
  const { RiskScorer } = await import("./risk-scorer-Y6KF2XCZ.js");
587
675
  const { loadConfig: loadConfig2 } = await import("./config-43SK6SFI.js");
588
676
  const config = loadConfig2();
@@ -1767,7 +1855,29 @@ var BashBro = class extends EventEmitter4 {
1767
1855
  if (!this.ollama || !this.ollamaAvailable) {
1768
1856
  return null;
1769
1857
  }
1770
- return this.ollama.suggestCommand(context);
1858
+ const startTime = Date.now();
1859
+ try {
1860
+ const result = await this.ollama.suggestCommand(context);
1861
+ const latency = Date.now() - startTime;
1862
+ this.emit("bro:suggestion", {
1863
+ input: context,
1864
+ output: result ?? "",
1865
+ model: this.ollama.getModel(),
1866
+ latencyMs: latency,
1867
+ success: result !== null
1868
+ });
1869
+ return result;
1870
+ } catch (error) {
1871
+ const latency = Date.now() - startTime;
1872
+ this.emit("bro:suggestion", {
1873
+ input: context,
1874
+ output: "",
1875
+ model: this.ollama?.getModel() ?? "unknown",
1876
+ latencyMs: latency,
1877
+ success: false
1878
+ });
1879
+ return null;
1880
+ }
1771
1881
  }
1772
1882
  /**
1773
1883
  * Ask Bash Bro to explain a command
@@ -1776,7 +1886,29 @@ var BashBro = class extends EventEmitter4 {
1776
1886
  if (!this.ollama || !this.ollamaAvailable) {
1777
1887
  return "Ollama not available for explanations.";
1778
1888
  }
1779
- return this.ollama.explainCommand(command);
1889
+ const startTime = Date.now();
1890
+ try {
1891
+ const result = await this.ollama.explainCommand(command);
1892
+ const latency = Date.now() - startTime;
1893
+ this.emit("bro:explanation", {
1894
+ input: command,
1895
+ output: result,
1896
+ model: this.ollama.getModel(),
1897
+ latencyMs: latency,
1898
+ success: true
1899
+ });
1900
+ return result;
1901
+ } catch (error) {
1902
+ const latency = Date.now() - startTime;
1903
+ this.emit("bro:explanation", {
1904
+ input: command,
1905
+ output: "Could not explain command.",
1906
+ model: this.ollama?.getModel() ?? "unknown",
1907
+ latencyMs: latency,
1908
+ success: false
1909
+ });
1910
+ return "Could not explain command.";
1911
+ }
1780
1912
  }
1781
1913
  /**
1782
1914
  * Ask Bash Bro to fix a failed command
@@ -1785,7 +1917,29 @@ var BashBro = class extends EventEmitter4 {
1785
1917
  if (!this.ollama || !this.ollamaAvailable) {
1786
1918
  return null;
1787
1919
  }
1788
- return this.ollama.fixCommand(command, error);
1920
+ const startTime = Date.now();
1921
+ try {
1922
+ const result = await this.ollama.fixCommand(command, error);
1923
+ const latency = Date.now() - startTime;
1924
+ this.emit("bro:fix", {
1925
+ input: `${command} | Error: ${error}`,
1926
+ output: result ?? "",
1927
+ model: this.ollama.getModel(),
1928
+ latencyMs: latency,
1929
+ success: result !== null
1930
+ });
1931
+ return result;
1932
+ } catch (err) {
1933
+ const latency = Date.now() - startTime;
1934
+ this.emit("bro:fix", {
1935
+ input: `${command} | Error: ${error}`,
1936
+ output: "",
1937
+ model: this.ollama?.getModel() ?? "unknown",
1938
+ latencyMs: latency,
1939
+ success: false
1940
+ });
1941
+ return null;
1942
+ }
1789
1943
  }
1790
1944
  /**
1791
1945
  * Set the Ollama model to use
@@ -1803,7 +1957,29 @@ var BashBro = class extends EventEmitter4 {
1803
1957
  return null;
1804
1958
  }
1805
1959
  const shell = this.profile?.shell || "bash";
1806
- return this.ollama.generateScript(description, shell);
1960
+ const startTime = Date.now();
1961
+ try {
1962
+ const result = await this.ollama.generateScript(description, shell);
1963
+ const latency = Date.now() - startTime;
1964
+ this.emit("bro:script", {
1965
+ input: description,
1966
+ output: result ?? "",
1967
+ model: this.ollama.getModel(),
1968
+ latencyMs: latency,
1969
+ success: result !== null
1970
+ });
1971
+ return result;
1972
+ } catch (error) {
1973
+ const latency = Date.now() - startTime;
1974
+ this.emit("bro:script", {
1975
+ input: description,
1976
+ output: "",
1977
+ model: this.ollama?.getModel() ?? "unknown",
1978
+ latencyMs: latency,
1979
+ success: false
1980
+ });
1981
+ return null;
1982
+ }
1807
1983
  }
1808
1984
  /**
1809
1985
  * Analyze command for security risks using AI
@@ -1817,7 +1993,34 @@ var BashBro = class extends EventEmitter4 {
1817
1993
  suggestions: []
1818
1994
  };
1819
1995
  }
1820
- return this.ollama.analyzeCommandSafety(command);
1996
+ const startTime = Date.now();
1997
+ try {
1998
+ const result = await this.ollama.analyzeCommandSafety(command);
1999
+ const latency = Date.now() - startTime;
2000
+ this.emit("bro:safety", {
2001
+ input: command,
2002
+ output: `Risk: ${result.risk} - ${result.explanation}`,
2003
+ model: this.ollama.getModel(),
2004
+ latencyMs: latency,
2005
+ success: true
2006
+ });
2007
+ return result;
2008
+ } catch (error) {
2009
+ const latency = Date.now() - startTime;
2010
+ this.emit("bro:safety", {
2011
+ input: command,
2012
+ output: "Analysis failed",
2013
+ model: this.ollama?.getModel() ?? "unknown",
2014
+ latencyMs: latency,
2015
+ success: false
2016
+ });
2017
+ return {
2018
+ safe: true,
2019
+ risk: "low",
2020
+ explanation: "Analysis unavailable.",
2021
+ suggestions: []
2022
+ };
2023
+ }
1821
2024
  }
1822
2025
  /**
1823
2026
  * Summarize a terminal session
@@ -2907,4 +3110,4 @@ export {
2907
3110
  UndoStack,
2908
3111
  LoopDetector
2909
3112
  };
2910
- //# sourceMappingURL=chunk-VVSCAH2B.js.map
3113
+ //# sourceMappingURL=chunk-2RPTM6EQ.js.map