@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 };
@@ -16368,6 +16380,8 @@ ${recall}
16368
16380
  function renderSessionStart(components, data) {
16369
16381
  const parts = [];
16370
16382
  const labels = [];
16383
+ const notes = [];
16384
+ const missing = (data, name, empty) => notes.push(data == null ? `${name} unavailable` : `${name} ${empty}`);
16371
16385
  for (const component of components) {
16372
16386
  switch (component) {
16373
16387
  case "directives": {
@@ -16381,6 +16395,8 @@ ${honchoDirectives(data.remember === true)}`);
16381
16395
  if (summary) {
16382
16396
  parts.push(`Session summary: ${summary}`);
16383
16397
  labels.push("summary");
16398
+ } else {
16399
+ missing(data.summary, "summary", "none yet");
16384
16400
  }
16385
16401
  break;
16386
16402
  }
@@ -16390,6 +16406,8 @@ ${honchoDirectives(data.remember === true)}`);
16390
16406
  parts.push(`Honcho stored representation of the user:
16391
16407
  ${rep}`);
16392
16408
  labels.push("representation");
16409
+ } else {
16410
+ missing(data.representation, "representation", "empty");
16393
16411
  }
16394
16412
  break;
16395
16413
  }
@@ -16403,6 +16421,8 @@ ${rep}`);
16403
16421
  if (card.length) {
16404
16422
  parts.push(`Profile: ${card.join("; ")}`);
16405
16423
  labels.push(`peer card (${card.length} items)`);
16424
+ } else {
16425
+ missing(data.peerCard, "peer card", "empty");
16406
16426
  }
16407
16427
  break;
16408
16428
  }
@@ -16410,7 +16430,7 @@ ${rep}`);
16410
16430
  }
16411
16431
  return { content: parts.join(`
16412
16432
 
16413
- `), labels };
16433
+ `), labels, notes };
16414
16434
  }
16415
16435
 
16416
16436
  // src/spinner.ts
@@ -16805,8 +16825,10 @@ var symbols2 = {
16805
16825
  pipe: String.fromCodePoint(9474),
16806
16826
  sparkle: String.fromCodePoint(10022)
16807
16827
  };
16808
- function honchoSessionUrl(workspace, sessionName) {
16809
- return `https://app.honcho.dev/explore?workspace=${encodeURIComponent(workspace)}&view=sessions&session=${encodeURIComponent(sessionName)}`;
16828
+ function honchoSessionUrl(config, sessionName) {
16829
+ if (!isProductionEndpoint(config))
16830
+ return null;
16831
+ return `https://app.honcho.dev/explore?workspace=${encodeURIComponent(config.workspace)}&view=sessions&session=${encodeURIComponent(sessionName)}`;
16810
16832
  }
16811
16833
 
16812
16834
  // src/log.ts
@@ -16938,15 +16960,24 @@ function visSessionContextMessage(hookName, lines, tokenCount, showContents = fa
16938
16960
  return body ? `${head}
16939
16961
  ${body}` : head;
16940
16962
  }
16941
- function visComposedInjection(hookName, labels) {
16942
- const summary = labels.length ? `injected ${labels.join(" + ")}` : "nothing to inject";
16943
- return formatLine("in", hookName, summary);
16963
+ function visComposedInjection(hookName, labels, notes = []) {
16964
+ const head = labels.length ? `injected ${labels.join(" + ")}` : "nothing injected";
16965
+ return formatLine("in", hookName, [head, ...notes].join(" · "));
16966
+ }
16967
+ function visEmptyComponent(hookName, message, unavailable = false) {
16968
+ return formatLine(unavailable ? "warn" : "info", hookName, message);
16969
+ }
16970
+ function visAnchorSummary(hookName, items, elapsedMs) {
16971
+ const what = items.length ? items.join(" · ") : "session identity only";
16972
+ return formatLine("in", hookName, `anchored ${what} (${(elapsedMs / 1000).toFixed(1)}s)`);
16944
16973
  }
16945
16974
  function visCapture(summary) {
16946
16975
  visMessage("out", "post-tool-use", `captured: ${summary}`);
16947
16976
  }
16948
- function visSkipMessage(hookName, reason) {
16949
- visMessage("info", hookName, `skipped (${reason})`);
16977
+ function visSkipMessage(hookName, reason, banner) {
16978
+ const line = formatLine("info", hookName, `skipped (${reason})`);
16979
+ console.log(JSON.stringify({ systemMessage: banner ? `${banner}
16980
+ ${line}` : line }));
16950
16981
  }
16951
16982
  function visStopMessage(direction, message) {
16952
16983
  visMessage(direction, "response", message);
@@ -16994,27 +17025,6 @@ function clearVerboseLog() {
16994
17025
  ensureVerboseLog();
16995
17026
  writeFileSync5(VERBOSE_LOG, "");
16996
17027
  }
16997
- function formatVerboseBlock(label, data) {
16998
- if (!data)
16999
- return "";
17000
- const separator = "─".repeat(60);
17001
- const content = data.length > 3000 ? data.slice(0, 3000) + `
17002
- ... (${data.length - 3000} more chars)` : data;
17003
- return `
17004
- [verbose] ${label}
17005
- ${separator}
17006
- ${content}
17007
- ${separator}`;
17008
- }
17009
- function formatVerboseList(label, items) {
17010
- if (!items || items.length === 0)
17011
- return "";
17012
- const formatted = items.map((item) => ` • ${item}`).join(`
17013
- `);
17014
- return `
17015
- [verbose] ${label} (${items.length} items)
17016
- ${formatted}`;
17017
- }
17018
17028
 
17019
17029
  // src/hooks/session-start.ts
17020
17030
  var CONTEXT_FETCH_TIMEOUT_MS = 1e4;
@@ -17027,8 +17037,8 @@ function raceTimeout(p, ms) {
17027
17037
  async function handleSessionStart() {
17028
17038
  const config = loadConfig2();
17029
17039
  if (!config) {
17030
- console.error("[honcho] Not configured. Run: honcho init");
17031
- process.exit(1);
17040
+ console.log(JSON.stringify({ systemMessage: "[honcho] Not configured. Run /honcho:setup to connect Honcho memory." }));
17041
+ process.exit(0);
17032
17042
  }
17033
17043
  if (!isPluginEnabled()) {
17034
17044
  process.exit(0);
@@ -17047,8 +17057,17 @@ async function handleSessionStart() {
17047
17057
  }
17048
17058
  const sessionName = getSessionName(cwd, claudeInstanceId);
17049
17059
  setLogContext(cwd, sessionName);
17050
- clearVerboseLog();
17051
- resetMessageCount();
17060
+ const source = hookInput.source ?? "startup";
17061
+ if (source === "resume") {
17062
+ setCachedSessionId(cwd, sessionName, sessionName, claudeInstanceId);
17063
+ setSessionLink(honchoSessionUrl(config, sessionName), sessionName, claudeInstanceId);
17064
+ logHook("session-start", "Resumed conversation; skipping injection");
17065
+ process.exit(0);
17066
+ }
17067
+ if (source !== "compact") {
17068
+ clearVerboseLog();
17069
+ resetMessageCount();
17070
+ }
17052
17071
  const previousGitState = getCachedGitState(cwd);
17053
17072
  const currentGitState = captureGitState(cwd);
17054
17073
  const gitChanges = currentGitState ? detectGitChanges(previousGitState, currentGitState) : [];
@@ -17058,7 +17077,7 @@ async function handleSessionStart() {
17058
17077
  const spinner = new Spinner({ style: "neural" });
17059
17078
  spinner.start(`${sessionName} · loading memory`);
17060
17079
  setMemoryState("loading", sessionName, claudeInstanceId);
17061
- setSessionLink(honchoSessionUrl(config.workspace, sessionName), sessionName, claudeInstanceId);
17080
+ setSessionLink(honchoSessionUrl(config, sessionName), sessionName, claudeInstanceId);
17062
17081
  try {
17063
17082
  logHook("session-start", `Starting session in ${cwd}`, { branch: currentGitState?.branch });
17064
17083
  logFlow("init", `workspace: ${config.workspace}, peers: ${config.peerName}/${config.aiPeer}`);
@@ -17119,21 +17138,24 @@ async function handleSessionStart() {
17119
17138
  const contextValue = userContextResult.status === "fulfilled" ? userContextResult.value : null;
17120
17139
  const summaryValue = summaryResult.status === "fulfilled" ? summaryResult.value : null;
17121
17140
  const rendered = renderSessionStart(startComponents, {
17122
- summary: summaryValue?.longSummary?.content ?? null,
17123
- peerCard: contextValue?.peerCard ?? null,
17124
- representation: contextValue?.representation ?? null,
17141
+ summary: summaryValue ? summaryValue.longSummary?.content ?? "" : null,
17142
+ peerCard: contextValue ? contextValue.peerCard ?? [] : null,
17143
+ representation: contextValue ? contextValue.representation ?? "" : null,
17125
17144
  remember: config.rememberTool === true
17126
17145
  });
17127
17146
  spinner.stop();
17128
17147
  setMemoryState("idle", undefined, claudeInstanceId);
17148
+ const systemMessage = visComposedInjection("session-start", rendered.labels, rendered.notes);
17129
17149
  if (rendered.content) {
17130
17150
  console.log(JSON.stringify({
17131
17151
  hookSpecificOutput: {
17132
17152
  hookEventName: "SessionStart",
17133
17153
  additionalContext: `[Honcho Memory for ${config.peerName}]: ${rendered.content}`
17134
17154
  },
17135
- systemMessage: visComposedInjection("session-start", rendered.labels)
17155
+ systemMessage
17136
17156
  }));
17157
+ } else if (rendered.notes.length) {
17158
+ console.log(JSON.stringify({ systemMessage }));
17137
17159
  }
17138
17160
  logFlow("complete", `Cache warmed: ${successCount}/1 context · injected: ${rendered.labels.join(", ") || "none"}`);
17139
17161
  process.exit(0);
@@ -17152,5 +17174,5 @@ async function main() {
17152
17174
  // hooks/session-start.ts
17153
17175
  await main();
17154
17176
 
17155
- //# debugId=878392F3DBB2CC2464756E2164756E21
17177
+ //# debugId=444AFFFC074F959B64756E2164756E21
17156
17178
  //# sourceMappingURL=session-start.js.map