fix: formatting issues in learn command files

This commit is contained in:
lubolin0925 2026-03-07 11:21:36 +08:00
parent 172d2f3d70
commit d000dcad94
3 changed files with 15 additions and 14 deletions

View File

@ -13,10 +13,10 @@ import {
import { logVerbose } from "../../globals.js";
import { enqueueSystemEvent } from "../../infra/system-events.js";
import { formatContextUsageShort, formatTokenCount } from "../status.js";
import { runLearnForSession } from "./commands-learn.js";
import type { CommandHandler } from "./commands-types.js";
import { stripMentions, stripStructuralPrefixes } from "./mentions.js";
import { incrementCompactionCount } from "./session-updates.js";
import { runLearnForSession } from "./commands-learn.js";
function extractCompactInstructions(params: {
rawBody?: string;
@ -102,7 +102,9 @@ export const handleCompactCommand: CommandHandler = async (params) => {
if (learnResult.ok) {
logVerbose(`Pre-compaction learning completed for session ${params.sessionKey}`);
} else {
logVerbose(`Pre-compaction learning failed for session ${params.sessionKey}: ${learnResult.message ?? "unknown error"}`);
logVerbose(
`Pre-compaction learning failed for session ${params.sessionKey}: ${learnResult.message ?? "unknown error"}`,
);
}
const customInstructions = extractCompactInstructions({

View File

@ -1,5 +1,6 @@
import fs from "node:fs/promises";
import { resetAcpSessionInPlace } from "../../acp/persistent-bindings.js";
import { resolveSessionFilePath, resolveSessionFilePathOptions } from "../../config/sessions.js";
import { logVerbose } from "../../globals.js";
import { createInternalHookEvent, triggerInternalHook } from "../../hooks/internal-hooks.js";
import { getGlobalHookRunner } from "../../plugins/hook-runner-global.js";
@ -13,7 +14,6 @@ import { handleApproveCommand } from "./commands-approve.js";
import { handleBashCommand } from "./commands-bash.js";
import { handleCompactCommand } from "./commands-compact.js";
import { handleConfigCommand, handleDebugCommand } from "./commands-config.js";
import { handleLearnCommand, runLearnForSession } from "./commands-learn.js";
import {
handleCommandsListCommand,
handleContextCommand,
@ -22,6 +22,7 @@ import {
handleStatusCommand,
handleWhoamiCommand,
} from "./commands-info.js";
import { handleLearnCommand, runLearnForSession } from "./commands-learn.js";
import { handleModelsCommand } from "./commands-models.js";
import { handlePluginCommand } from "./commands-plugin.js";
import {
@ -41,10 +42,6 @@ import type {
HandleCommandsParams,
} from "./commands-types.js";
import { routeReply } from "./route-reply.js";
import {
resolveSessionFilePath,
resolveSessionFilePathOptions,
} from "../../config/sessions.js";
let HANDLERS: CommandHandler[] | null = null;
@ -256,14 +253,17 @@ export async function handleCommands(params: HandleCommandsParams): Promise<Comm
provider: params.provider,
model: params.model,
thinkLevel: params.resolvedThinkLevel ?? (await params.resolveDefaultThinkingLevel()),
customFocus: "What insights and lessons should be remembered before starting a new session?",
customFocus:
"What insights and lessons should be remembered before starting a new session?",
senderIsOwner: params.command.senderIsOwner,
ownerNumbers: params.command.ownerList.length > 0 ? params.command.ownerList : undefined,
});
if (learnResult.ok) {
logVerbose(`Pre-reset learning completed for session ${targetSessionKey}`);
} else {
logVerbose(`Pre-reset learning failed for session ${targetSessionKey}: ${learnResult.message ?? "unknown error"}`);
logVerbose(
`Pre-reset learning failed for session ${targetSessionKey}: ${learnResult.message ?? "unknown error"}`,
);
}
}
if (boundAcpKey) {

View File

@ -1,9 +1,6 @@
import { runEmbeddedPiAgent } from "../../agents/pi-embedded.js";
import type { OpenClawConfig } from "../../config/config.js";
import {
resolveSessionFilePath,
resolveSessionFilePathOptions,
} from "../../config/sessions.js";
import { resolveSessionFilePath, resolveSessionFilePathOptions } from "../../config/sessions.js";
import { logVerbose } from "../../globals.js";
const LEARN_SYSTEM_PROMPT = [
@ -125,7 +122,9 @@ export const handleLearnCommand = async (
}
const sessionId = params.sessionEntry.sessionId;
const customFocus = extractLearnFocus(params.ctx.CommandBody ?? params.ctx.RawBody ?? params.ctx.Body);
const customFocus = extractLearnFocus(
params.ctx.CommandBody ?? params.ctx.RawBody ?? params.ctx.Body,
);
const result = await runLearnForSession({
sessionId,