@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.
- package/.claude-plugin/plugin.json +1 -1
- package/dist/hooks/post-tool-use.js +62 -43
- package/dist/hooks/post-tool-use.js.map +5 -5
- package/dist/hooks/pre-compact.js +70 -46
- package/dist/hooks/pre-compact.js.map +6 -6
- package/dist/hooks/pre-tool-honcho.js +17 -5
- package/dist/hooks/pre-tool-honcho.js.map +4 -4
- package/dist/hooks/save-user-message.js +39 -10
- package/dist/hooks/save-user-message.js.map +5 -5
- package/dist/hooks/session-end.js +18 -5
- package/dist/hooks/session-end.js.map +4 -4
- package/dist/hooks/session-start.js +65 -43
- package/dist/hooks/session-start.js.map +8 -8
- package/dist/hooks/stop.js +82 -36
- package/dist/hooks/stop.js.map +7 -6
- package/dist/hooks/user-prompt.js +122 -76
- package/dist/hooks/user-prompt.js.map +8 -8
- package/dist/mcp-server.js +119 -89
- package/dist/mcp-server.js.map +5 -5
- package/dist/skills/backfill-runner.js +24 -8
- package/dist/skills/backfill-runner.js.map +7 -6
- package/dist/skills/setup-runner.js +27 -9
- package/dist/skills/setup-runner.js.map +7 -6
- package/dist/skills/status-runner.js +14 -5
- package/dist/skills/status-runner.js.map +4 -4
- package/hooks/hooks.json +9 -9
- package/package.json +1 -1
- package/skills/status/SKILL.md +1 -1
|
@@ -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",
|
|
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
|
-
|
|
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
|
-
|
|
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 };
|
|
@@ -16863,15 +16875,24 @@ function visSessionContextMessage(hookName, lines, tokenCount, showContents = fa
|
|
|
16863
16875
|
return body ? `${head}
|
|
16864
16876
|
${body}` : head;
|
|
16865
16877
|
}
|
|
16866
|
-
function visComposedInjection(hookName, labels) {
|
|
16867
|
-
const
|
|
16868
|
-
return formatLine("in", hookName,
|
|
16878
|
+
function visComposedInjection(hookName, labels, notes = []) {
|
|
16879
|
+
const head = labels.length ? `injected ${labels.join(" + ")}` : "nothing injected";
|
|
16880
|
+
return formatLine("in", hookName, [head, ...notes].join(" · "));
|
|
16881
|
+
}
|
|
16882
|
+
function visEmptyComponent(hookName, message, unavailable = false) {
|
|
16883
|
+
return formatLine(unavailable ? "warn" : "info", hookName, message);
|
|
16884
|
+
}
|
|
16885
|
+
function visAnchorSummary(hookName, items, elapsedMs) {
|
|
16886
|
+
const what = items.length ? items.join(" · ") : "session identity only";
|
|
16887
|
+
return formatLine("in", hookName, `anchored ${what} (${(elapsedMs / 1000).toFixed(1)}s)`);
|
|
16869
16888
|
}
|
|
16870
16889
|
function visCapture(summary) {
|
|
16871
16890
|
visMessage("out", "post-tool-use", `captured: ${summary}`);
|
|
16872
16891
|
}
|
|
16873
|
-
function visSkipMessage(hookName, reason) {
|
|
16874
|
-
|
|
16892
|
+
function visSkipMessage(hookName, reason, banner) {
|
|
16893
|
+
const line = formatLine("info", hookName, `skipped (${reason})`);
|
|
16894
|
+
console.log(JSON.stringify({ systemMessage: banner ? `${banner}
|
|
16895
|
+
${line}` : line }));
|
|
16875
16896
|
}
|
|
16876
16897
|
function visStopMessage(direction, message) {
|
|
16877
16898
|
visMessage(direction, "response", message);
|
|
@@ -16919,29 +16940,23 @@ function clearVerboseLog() {
|
|
|
16919
16940
|
ensureVerboseLog();
|
|
16920
16941
|
writeFileSync5(VERBOSE_LOG, "");
|
|
16921
16942
|
}
|
|
16922
|
-
|
|
16923
|
-
|
|
16924
|
-
|
|
16925
|
-
|
|
16926
|
-
|
|
16927
|
-
|
|
16928
|
-
return
|
|
16929
|
-
[verbose] ${label}
|
|
16930
|
-
${separator}
|
|
16931
|
-
${content}
|
|
16932
|
-
${separator}`;
|
|
16943
|
+
|
|
16944
|
+
// src/hooks/pre-compact.ts
|
|
16945
|
+
var FACTS_ONLY = "Answer with facts only, as a terse bullet list written in the third person. " + "No preamble, no closing summary, no offers to help further, and no questions.";
|
|
16946
|
+
var CHAT_OFFER = /^(let me know|would you like|want me to|i can also)\b/i;
|
|
16947
|
+
var CONDITIONAL_OFFER = /^(if you('d| would)? like|if you want)\b.*\b(i can|i could|i'll|i will|let me know|just ask|happy to)\b/is;
|
|
16948
|
+
function isChatFiller(paragraph) {
|
|
16949
|
+
return CHAT_OFFER.test(paragraph) || CONDITIONAL_OFFER.test(paragraph);
|
|
16933
16950
|
}
|
|
16934
|
-
function
|
|
16935
|
-
|
|
16936
|
-
|
|
16937
|
-
|
|
16951
|
+
function stripChatFiller(answer) {
|
|
16952
|
+
const paragraphs = answer.trim().split(/\n\s*\n/);
|
|
16953
|
+
while (paragraphs.length > 1 && isChatFiller(paragraphs[paragraphs.length - 1].trim())) {
|
|
16954
|
+
paragraphs.pop();
|
|
16955
|
+
}
|
|
16956
|
+
return paragraphs.join(`
|
|
16957
|
+
|
|
16938
16958
|
`);
|
|
16939
|
-
return `
|
|
16940
|
-
[verbose] ${label} (${items.length} items)
|
|
16941
|
-
${formatted}`;
|
|
16942
16959
|
}
|
|
16943
|
-
|
|
16944
|
-
// src/hooks/pre-compact.ts
|
|
16945
16960
|
function formatMemoryCard(config, sessionName, userContext, claudeContext, summaries, userDialectic, claudeDialectic) {
|
|
16946
16961
|
const parts = [];
|
|
16947
16962
|
parts.push(`## HONCHO MEMORY ANCHOR (Pre-Compaction Injection)
|
|
@@ -17029,6 +17044,7 @@ async function handlePreCompact() {
|
|
|
17029
17044
|
logApiCall(contextLabel, "GET", observationMode === "unified" ? "self" : `target=${config.peerName}`);
|
|
17030
17045
|
logApiCall("session.summaries", "GET", sessionName);
|
|
17031
17046
|
logApiCall("peer.chat", "POST", "dialectic queries x2");
|
|
17047
|
+
const fetchStart = Date.now();
|
|
17032
17048
|
const dialecticArgs = observationMode === "unified" ? { session, reasoningLevel: config.reasoningLevel ?? "low" } : { target: config.peerName, session, reasoningLevel: config.reasoningLevel ?? "low" };
|
|
17033
17049
|
const [userContextResult, summariesResult, userChatResult, claudeChatResult] = await Promise.allSettled([
|
|
17034
17050
|
contextPeer.context({
|
|
@@ -17037,33 +17053,41 @@ async function handlePreCompact() {
|
|
|
17037
17053
|
includeMostFrequent: true
|
|
17038
17054
|
}),
|
|
17039
17055
|
session.summaries(),
|
|
17040
|
-
contextPeer.chat(`
|
|
17041
|
-
contextPeer.chat(`What are the most important things that were worked on with ${config.peerName}?
|
|
17056
|
+
contextPeer.chat(`What are the most important things to remember about ${config.peerName}? Cover their preferences, working style, current projects, and any critical context that should survive a conversation summary. ${FACTS_ONLY}`, dialecticArgs),
|
|
17057
|
+
contextPeer.chat(`What are the most important things that were worked on with ${config.peerName}? ${FACTS_ONLY}`, dialecticArgs)
|
|
17042
17058
|
]);
|
|
17059
|
+
const fetchMs = Date.now() - fetchStart;
|
|
17043
17060
|
const userContext = userContextResult.status === "fulfilled" ? userContextResult.value : null;
|
|
17044
17061
|
const summaries = summariesResult.status === "fulfilled" ? summariesResult.value : null;
|
|
17045
|
-
|
|
17046
|
-
|
|
17047
|
-
|
|
17048
|
-
const userDialectic = userChatResult
|
|
17049
|
-
const claudeDialectic = claudeChatResult
|
|
17062
|
+
verboseApiResult(`pre-compact ${contextLabel} → representation`, userContext?.representation);
|
|
17063
|
+
verboseList("pre-compact peerCard", userContext?.peerCard);
|
|
17064
|
+
const dialecticAnswer = (r) => r.status === "fulfilled" && typeof r.value === "string" && r.value.trim() ? stripChatFiller(r.value) : null;
|
|
17065
|
+
const userDialectic = dialecticAnswer(userChatResult);
|
|
17066
|
+
const claudeDialectic = dialecticAnswer(claudeChatResult);
|
|
17050
17067
|
const memoryCard = formatMemoryCard(config, sessionName, userContext, null, summaries, userDialectic, claudeDialectic);
|
|
17051
17068
|
if (trigger === "auto") {
|
|
17052
17069
|
spinner.stop("memory anchored");
|
|
17053
17070
|
}
|
|
17054
17071
|
setMemoryState("idle", undefined, hookInput.session_id);
|
|
17055
|
-
|
|
17056
|
-
|
|
17057
|
-
}
|
|
17058
|
-
if (claudeDialectic) {
|
|
17059
|
-
verboseBlocks.push(formatVerboseBlock(`pre-compact peer.chat(claude) → "${config.aiPeer}"`, claudeDialectic));
|
|
17060
|
-
}
|
|
17072
|
+
verboseApiResult(`pre-compact peer.chat(user) → "${config.peerName}"`, userDialectic);
|
|
17073
|
+
verboseApiResult(`pre-compact peer.chat(claude) → "${config.aiPeer}"`, claudeDialectic);
|
|
17061
17074
|
logHook("pre-compact", `Memory anchored (${memoryCard.length} chars)`);
|
|
17062
|
-
const
|
|
17063
|
-
|
|
17075
|
+
const ctx = userContext;
|
|
17076
|
+
const anchored = [];
|
|
17077
|
+
if (ctx?.peerCard?.length)
|
|
17078
|
+
anchored.push(`peer card (${ctx.peerCard.length} items)`);
|
|
17079
|
+
if (typeof ctx?.representation === "string" && ctx.representation.trim())
|
|
17080
|
+
anchored.push("conclusions");
|
|
17081
|
+
if (summaries?.shortSummary?.content)
|
|
17082
|
+
anchored.push("session summary");
|
|
17083
|
+
const answers = [userDialectic, claudeDialectic].filter(Boolean).length;
|
|
17084
|
+
if (answers)
|
|
17085
|
+
anchored.push(`${answers} dialectic answer${answers === 1 ? "" : "s"}`);
|
|
17064
17086
|
console.log(`[${config.aiPeer}/Honcho Memory Anchor]
|
|
17065
17087
|
|
|
17066
|
-
${memoryCard}
|
|
17088
|
+
${memoryCard}
|
|
17089
|
+
|
|
17090
|
+
${visAnchorSummary("pre-compact", anchored, fetchMs)}`);
|
|
17067
17091
|
process.exit(0);
|
|
17068
17092
|
} catch (error) {
|
|
17069
17093
|
logHook("pre-compact", `Error: ${error}`, { error: String(error) });
|
|
@@ -17083,5 +17107,5 @@ async function main() {
|
|
|
17083
17107
|
// hooks/pre-compact.ts
|
|
17084
17108
|
await main();
|
|
17085
17109
|
|
|
17086
|
-
//# debugId=
|
|
17110
|
+
//# debugId=AC5BE8938B532C6264756E2164756E21
|
|
17087
17111
|
//# sourceMappingURL=pre-compact.js.map
|