@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.
@@ -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 };
@@ -16355,7 +16367,7 @@ function getObservationMode(config) {
16355
16367
  }
16356
16368
 
16357
16369
  // src/hooks/stop.ts
16358
- import { existsSync as existsSync6, readFileSync as readFileSync4 } from "fs";
16370
+ import { existsSync as existsSync7, readFileSync as readFileSync4 } from "fs";
16359
16371
 
16360
16372
  // src/log.ts
16361
16373
  import { homedir as homedir3 } from "os";
@@ -16586,15 +16598,24 @@ function visSessionContextMessage(hookName, lines, tokenCount, showContents = fa
16586
16598
  return body ? `${head}
16587
16599
  ${body}` : head;
16588
16600
  }
16589
- function visComposedInjection(hookName, labels) {
16590
- const summary = labels.length ? `injected ${labels.join(" + ")}` : "nothing to inject";
16591
- return formatLine("in", hookName, summary);
16601
+ function visComposedInjection(hookName, labels, notes = []) {
16602
+ const head = labels.length ? `injected ${labels.join(" + ")}` : "nothing injected";
16603
+ return formatLine("in", hookName, [head, ...notes].join(" · "));
16604
+ }
16605
+ function visEmptyComponent(hookName, message, unavailable = false) {
16606
+ return formatLine(unavailable ? "warn" : "info", hookName, message);
16607
+ }
16608
+ function visAnchorSummary(hookName, items, elapsedMs) {
16609
+ const what = items.length ? items.join(" · ") : "session identity only";
16610
+ return formatLine("in", hookName, `anchored ${what} (${(elapsedMs / 1000).toFixed(1)}s)`);
16592
16611
  }
16593
16612
  function visCapture(summary) {
16594
16613
  visMessage("out", "post-tool-use", `captured: ${summary}`);
16595
16614
  }
16596
- function visSkipMessage(hookName, reason) {
16597
- visMessage("info", hookName, `skipped (${reason})`);
16615
+ function visSkipMessage(hookName, reason, banner) {
16616
+ const line = formatLine("info", hookName, `skipped (${reason})`);
16617
+ console.log(JSON.stringify({ systemMessage: banner ? `${banner}
16618
+ ${line}` : line }));
16598
16619
  }
16599
16620
  function visStopMessage(direction, message) {
16600
16621
  visMessage(direction, "response", message);
@@ -16642,40 +16663,64 @@ function clearVerboseLog() {
16642
16663
  ensureVerboseLog();
16643
16664
  writeFileSync4(VERBOSE_LOG, "");
16644
16665
  }
16645
- function formatVerboseBlock(label, data) {
16646
- if (!data)
16647
- return "";
16648
- const separator = "─".repeat(60);
16649
- const content = data.length > 3000 ? data.slice(0, 3000) + `
16650
- ... (${data.length - 3000} more chars)` : data;
16651
- return `
16652
- [verbose] ${label}
16653
- ${separator}
16654
- ${content}
16655
- ${separator}`;
16666
+
16667
+ // src/prompt-filters.ts
16668
+ import { existsSync as existsSync6 } from "fs";
16669
+ var TRIVIAL_REPLY_PATTERN = /^(yes|no|ok|sure|thanks|y|n|yep|nope|yeah|nah|continue|go ahead|do it|proceed)$/i;
16670
+ function isTerseReply(prompt) {
16671
+ return TRIVIAL_REPLY_PATTERN.test(prompt.trim());
16656
16672
  }
16657
- function formatVerboseList(label, items) {
16658
- if (!items || items.length === 0)
16659
- return "";
16660
- const formatted = items.map((item) => ` • ${item}`).join(`
16661
- `);
16662
- return `
16663
- [verbose] ${label} (${items.length} items)
16664
- ${formatted}`;
16673
+ var HARNESS_INJECTED_PATTERNS = [
16674
+ /^<task-notification>/,
16675
+ /^<cross-session-message\b/,
16676
+ /^<local-command-stdout>/,
16677
+ /^<command-name>/,
16678
+ /^<command-message>/,
16679
+ /^<system-reminder>/,
16680
+ /^<bash-(stdout|stderr|input)>/,
16681
+ /^<<[\w-]+>>$/
16682
+ ];
16683
+ var LEADING_REMINDERS = /^(?:\s*<system-reminder>[\s\S]*?<\/system-reminder>)+\s*/;
16684
+ function stripLeadingReminders(prompt) {
16685
+ return prompt.replace(LEADING_REMINDERS, "");
16686
+ }
16687
+ var SLASH_COMMAND_ENVELOPE = /^<command-(name|message)>/;
16688
+ function isHarnessInjected(prompt) {
16689
+ const trimmed = stripLeadingReminders(prompt).trim();
16690
+ return !trimmed || HARNESS_INJECTED_PATTERNS.some((p) => p.test(trimmed));
16691
+ }
16692
+ var SLASH_COMMAND = /^\/([\w:-]+)(?:\s|$)/;
16693
+ function isSlashCommand(prompt) {
16694
+ const trimmed = stripLeadingReminders(prompt).trim();
16695
+ if (SLASH_COMMAND_ENVELOPE.test(trimmed))
16696
+ return true;
16697
+ const name = SLASH_COMMAND.exec(trimmed)?.[1];
16698
+ if (!name)
16699
+ return false;
16700
+ return name.includes(":") || !existsSync6(`/${name}`);
16665
16701
  }
16666
16702
 
16667
16703
  // src/hooks/stop.ts
16668
16704
  function isWakeupBoundary(entry) {
16669
16705
  return entry.promptSource === "system" || entry.origin?.kind === "task-notification";
16670
16706
  }
16707
+ function userText(entry) {
16708
+ const mc = entry.message?.content ?? entry.content;
16709
+ if (typeof mc === "string")
16710
+ return mc;
16711
+ if (Array.isArray(mc))
16712
+ return mc.filter((b) => b.type === "text" && b.text).map((b) => b.text).join("");
16713
+ return "";
16714
+ }
16671
16715
  function isRealUserPrompt(entry) {
16672
16716
  if (entry.isMeta)
16673
16717
  return false;
16674
- const mc = entry.message?.content ?? entry.content;
16675
- const text = typeof mc === "string" ? mc : Array.isArray(mc) ? mc.filter((b) => b.type === "text" && b.text).map((b) => b.text).join("") : "";
16676
- const trimmed = text.trim();
16718
+ const trimmed = stripLeadingReminders(userText(entry)).trim();
16677
16719
  return trimmed.length > 0 && !trimmed.startsWith("<");
16678
16720
  }
16721
+ function isSlashCommandBoundary(entry) {
16722
+ return !entry.isMeta && isSlashCommand(userText(entry));
16723
+ }
16679
16724
  function assistantText(entry) {
16680
16725
  const mc = entry.message?.content ?? entry.content;
16681
16726
  if (typeof mc === "string")
@@ -16695,7 +16740,7 @@ function getCurrentTurnAssistantMessages(transcriptPath, lastAssistantMessage) {
16695
16740
  return blocks;
16696
16741
  }
16697
16742
  function readTranscriptTurnBlocks(transcriptPath) {
16698
- if (!transcriptPath || !existsSync6(transcriptPath))
16743
+ if (!transcriptPath || !existsSync7(transcriptPath))
16699
16744
  return [];
16700
16745
  let lines;
16701
16746
  try {
@@ -16708,7 +16753,7 @@ function readTranscriptTurnBlocks(transcriptPath) {
16708
16753
  for (let i = lines.length - 1;i >= 0; i--) {
16709
16754
  try {
16710
16755
  const entry = JSON.parse(lines[i]);
16711
- if ((entry.type || entry.role) === "user" && (isRealUserPrompt(entry) || isWakeupBoundary(entry))) {
16756
+ if ((entry.type || entry.role) === "user" && (isRealUserPrompt(entry) || isSlashCommandBoundary(entry) || isWakeupBoundary(entry))) {
16712
16757
  lastPromptIdx = i;
16713
16758
  break;
16714
16759
  }
@@ -16788,9 +16833,10 @@ async function handleStop() {
16788
16833
  return honcho.session(sessionName);
16789
16834
  });
16790
16835
  logHook("stop", `Saved ${turnMessages.length} assistant message(s)`);
16791
- visStopMessage("out", `saved ${turnMessages.length} assistant msg(s)`);
16792
16836
  } catch (error) {
16793
16837
  logHook("stop", `Upload failed: ${error}`, { error: String(error) });
16838
+ const seeLog = isLoggingEnabled() ? " (see ~/.honcho/activity.log)" : "";
16839
+ visStopMessage("warn", `upload failed, ${turnMessages.length} assistant msg(s) not saved${seeLog}`);
16794
16840
  }
16795
16841
  process.exit(0);
16796
16842
  }
@@ -16802,5 +16848,5 @@ async function main() {
16802
16848
  // hooks/stop.ts
16803
16849
  await main();
16804
16850
 
16805
- //# debugId=7658033751C6544364756E2164756E21
16851
+ //# debugId=A42F0E7E0AC317DB64756E2164756E21
16806
16852
  //# sourceMappingURL=stop.js.map