@honcho-ai/claude-honcho 0.3.3 → 0.3.4

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,6 +1,6 @@
1
1
  {
2
2
  "name": "honcho",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "Persistent memory for Claude Code sessions using Honcho by Plastic Labs",
5
5
  "author": {
6
6
  "name": "Plastic Labs",
@@ -15566,7 +15566,7 @@ var import_sdk = __toESM(require_dist(), 1);
15566
15566
  import { homedir as homedir2 } from "os";
15567
15567
  import { join as join3, basename, dirname, resolve, sep } from "path";
15568
15568
  import { fileURLToPath } from "url";
15569
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync2, statSync, writeFileSync as writeFileSync2 } from "fs";
15569
+ import { chmodSync, existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync2, statSync, writeFileSync as writeFileSync2 } from "fs";
15570
15570
 
15571
15571
  // src/git.ts
15572
15572
  import { execSync } from "child_process";
@@ -16107,6 +16107,9 @@ function mergeWithEnvVars(config) {
16107
16107
  if (process.env.HONCHO_LOGGING === "false") {
16108
16108
  config.logging = false;
16109
16109
  }
16110
+ if (process.env.HONCHO_SAVE_MESSAGES === "false") {
16111
+ config.saveMessages = false;
16112
+ }
16110
16113
  if (process.env.HONCHO_SAVE_TOOL_USE !== undefined) {
16111
16114
  config.saveToolUse = process.env.HONCHO_SAVE_TOOL_USE === "true";
16112
16115
  }
@@ -16115,6 +16118,11 @@ function mergeWithEnvVars(config) {
16115
16118
  }
16116
16119
  return config;
16117
16120
  }
16121
+ function writeConfigFile(data) {
16122
+ if (existsSync3(CONFIG_FILE))
16123
+ chmodSync(CONFIG_FILE, 384);
16124
+ writeFileSync2(CONFIG_FILE, JSON.stringify(data, null, 2), { mode: 384 });
16125
+ }
16118
16126
  function saveConfig(config) {
16119
16127
  if (!existsSync3(CONFIG_DIR)) {
16120
16128
  mkdirSync2(CONFIG_DIR, { recursive: true });
@@ -16145,9 +16153,10 @@ function saveConfig(config) {
16145
16153
  setHostIfExplicit("aiPeer", config.aiPeer, existing.aiPeer ?? DEFAULT_AI_PEER[host]);
16146
16154
  const enabledForSave = process.env.HONCHO_ENABLED === "false" && config.enabled === false ? existingHost.enabled : config.enabled;
16147
16155
  const loggingForSave = process.env.HONCHO_LOGGING === "false" && config.logging === false ? existingHost.logging : config.logging;
16156
+ const saveMessagesForSave = process.env.HONCHO_SAVE_MESSAGES === "false" && config.saveMessages === false ? existingHost.saveMessages : config.saveMessages;
16148
16157
  setHostIfExplicit("enabled", enabledForSave, existing.enabled);
16149
16158
  setHostIfExplicit("logging", loggingForSave, existing.logging);
16150
- setHostIfExplicit("saveMessages", config.saveMessages, existing.saveMessages);
16159
+ setHostIfExplicit("saveMessages", saveMessagesForSave, existing.saveMessages);
16151
16160
  setHostIfExplicit("sessionStrategy", config.sessionStrategy, existing.sessionStrategy);
16152
16161
  setHostIfExplicit("sessionPeerPrefix", config.sessionPeerPrefix, existing.sessionPeerPrefix);
16153
16162
  setHostIfExplicit("reasoningLevel", config.reasoningLevel, existing.reasoningLevel);
@@ -16162,7 +16171,7 @@ function saveConfig(config) {
16162
16171
  hostEntry.apiKey = existingHost.apiKey;
16163
16172
  }
16164
16173
  existing.hosts[host] = hostEntry;
16165
- writeFileSync2(CONFIG_FILE, JSON.stringify(existing, null, 2));
16174
+ writeConfigFile(existing);
16166
16175
  }
16167
16176
  function saveRootField(field, value) {
16168
16177
  if (!existsSync3(CONFIG_DIR)) {
@@ -16175,7 +16184,7 @@ function saveRootField(field, value) {
16175
16184
  } catch {}
16176
16185
  }
16177
16186
  existing[field] = value;
16178
- writeFileSync2(CONFIG_FILE, JSON.stringify(existing, null, 2));
16187
+ writeConfigFile(existing);
16179
16188
  }
16180
16189
  function resolveWorktreeMainRoot(dir) {
16181
16190
  try {
@@ -16340,6 +16349,9 @@ function getHonchoClientOptions(config) {
16340
16349
  defaultHeaders: getTelemetryHeaders()
16341
16350
  };
16342
16351
  }
16352
+ function isProductionEndpoint(config) {
16353
+ return getHonchoBaseUrl(config) === HONCHO_BASE_URLS.production;
16354
+ }
16343
16355
  function getEndpointInfo(config) {
16344
16356
  if (config.endpoint?.baseUrl) {
16345
16357
  return { type: "custom", url: config.endpoint.baseUrl };
@@ -16629,15 +16641,24 @@ function visSessionContextMessage(hookName, lines, tokenCount, showContents = fa
16629
16641
  return body ? `${head}
16630
16642
  ${body}` : head;
16631
16643
  }
16632
- function visComposedInjection(hookName, labels) {
16633
- const summary = labels.length ? `injected ${labels.join(" + ")}` : "nothing to inject";
16634
- return formatLine("in", hookName, summary);
16644
+ function visComposedInjection(hookName, labels, notes = []) {
16645
+ const head = labels.length ? `injected ${labels.join(" + ")}` : "nothing injected";
16646
+ return formatLine("in", hookName, [head, ...notes].join(" · "));
16647
+ }
16648
+ function visEmptyComponent(hookName, message, unavailable = false) {
16649
+ return formatLine(unavailable ? "warn" : "info", hookName, message);
16650
+ }
16651
+ function visAnchorSummary(hookName, items, elapsedMs) {
16652
+ const what = items.length ? items.join(" · ") : "session identity only";
16653
+ return formatLine("in", hookName, `anchored ${what} (${(elapsedMs / 1000).toFixed(1)}s)`);
16635
16654
  }
16636
16655
  function visCapture(summary) {
16637
16656
  visMessage("out", "post-tool-use", `captured: ${summary}`);
16638
16657
  }
16639
- function visSkipMessage(hookName, reason) {
16640
- visMessage("info", hookName, `skipped (${reason})`);
16658
+ function visSkipMessage(hookName, reason, banner) {
16659
+ const line = formatLine("info", hookName, `skipped (${reason})`);
16660
+ console.log(JSON.stringify({ systemMessage: banner ? `${banner}
16661
+ ${line}` : line }));
16641
16662
  }
16642
16663
  function visStopMessage(direction, message) {
16643
16664
  visMessage(direction, "response", message);
@@ -16685,40 +16706,37 @@ function clearVerboseLog() {
16685
16706
  ensureVerboseLog();
16686
16707
  writeFileSync4(VERBOSE_LOG, "");
16687
16708
  }
16688
- function formatVerboseBlock(label, data) {
16689
- if (!data)
16690
- return "";
16691
- const separator = "─".repeat(60);
16692
- const content = data.length > 3000 ? data.slice(0, 3000) + `
16693
- ... (${data.length - 3000} more chars)` : data;
16694
- return `
16695
- [verbose] ${label}
16696
- ${separator}
16697
- ${content}
16698
- ${separator}`;
16699
- }
16700
- function formatVerboseList(label, items) {
16701
- if (!items || items.length === 0)
16702
- return "";
16703
- const formatted = items.map((item) => ` • ${item}`).join(`
16704
- `);
16705
- return `
16706
- [verbose] ${label} (${items.length} items)
16707
- ${formatted}`;
16708
- }
16709
16709
 
16710
16710
  // src/hooks/post-tool-use.ts
16711
+ var TRIVIAL_COMMANDS = new Set([
16712
+ "cd",
16713
+ "ls",
16714
+ "pwd",
16715
+ "echo",
16716
+ "cat",
16717
+ "head",
16718
+ "tail",
16719
+ "which",
16720
+ "type",
16721
+ "git status",
16722
+ "git log",
16723
+ "git diff"
16724
+ ]);
16725
+ var COMMAND_WRAPPERS = new Set(["rtk", "sudo", "doas", "env", "time", "command", "nice"]);
16726
+ function isTrivialCommand(command) {
16727
+ const tokens = command.trim().split(/\s+/);
16728
+ while (tokens.length > 1 && COMMAND_WRAPPERS.has(tokens[0])) {
16729
+ tokens.shift();
16730
+ }
16731
+ return TRIVIAL_COMMANDS.has(tokens[0]) || TRIVIAL_COMMANDS.has(tokens.slice(0, 2).join(" "));
16732
+ }
16711
16733
  function shouldLogTool(toolName, toolInput) {
16712
16734
  const significantTools = new Set(["Write", "Edit", "Bash", "Task", "NotebookEdit"]);
16713
16735
  if (!significantTools.has(toolName)) {
16714
16736
  return false;
16715
16737
  }
16716
- if (toolName === "Bash") {
16717
- const command = toolInput.command || "";
16718
- const trivialCommands = ["cd", "ls", "pwd", "echo", "cat", "head", "tail", "which", "type", "git status", "git log", "git diff"];
16719
- if (trivialCommands.some((cmd) => command.trim().startsWith(cmd))) {
16720
- return false;
16721
- }
16738
+ if (toolName === "Bash" && isTrivialCommand(toolInput.command || "")) {
16739
+ return false;
16722
16740
  }
16723
16741
  return true;
16724
16742
  }
@@ -16848,7 +16866,7 @@ async function handlePostToolUse() {
16848
16866
  if (!config) {
16849
16867
  process.exit(0);
16850
16868
  }
16851
- if (!isPluginEnabled()) {
16869
+ if (!isPluginEnabled() || config.saveMessages === false || config.saveToolUse !== true) {
16852
16870
  process.exit(0);
16853
16871
  }
16854
16872
  let hookInput = {};
@@ -16870,14 +16888,15 @@ async function handlePostToolUse() {
16870
16888
  }
16871
16889
  const summary = redactSecrets(formatToolSummary(toolName, toolInput, toolResponse), config.redactPatterns);
16872
16890
  logHook("post-tool-use", summary, { tool: toolName });
16873
- visCapture(summary);
16874
- await logToHonchoAsync(config, cwd, summary).catch((e) => logHook("post-tool-use", `Upload failed: ${e}`, { error: String(e) }));
16891
+ try {
16892
+ await logToHonchoAsync(config, cwd, summary);
16893
+ visCapture(summary);
16894
+ } catch (e) {
16895
+ logHook("post-tool-use", `Upload failed: ${e}`, { error: String(e) });
16896
+ }
16875
16897
  process.exit(0);
16876
16898
  }
16877
16899
  async function logToHonchoAsync(config, cwd, summary) {
16878
- if (config.saveMessages === false || config.saveToolUse !== true) {
16879
- return;
16880
- }
16881
16900
  const honcho = new import_sdk.Honcho(getHonchoClientOptions(config));
16882
16901
  const sessionName = getSessionName(cwd);
16883
16902
  const session = await honcho.session(sessionName);
@@ -16901,5 +16920,5 @@ async function main() {
16901
16920
  // hooks/post-tool-use.ts
16902
16921
  await main();
16903
16922
 
16904
- //# debugId=7328DC2BB66229D164756E2164756E21
16923
+ //# debugId=297CD8A1E82BEAC464756E2164756E21
16905
16924
  //# sourceMappingURL=post-tool-use.js.map