Chore: format + lint fixes

main
Peter Steinberger 2025-12-03 09:09:34 +00:00
parent 85917d4769
commit 53c1674382
4 changed files with 216 additions and 200 deletions

View File

@ -76,7 +76,11 @@ function parsePiJson(raw: string): AgentParseResult {
}
: undefined;
return { texts, toolResults: toolResults.length ? toolResults : undefined, meta };
return {
texts,
toolResults: toolResults.length ? toolResults : undefined,
meta,
};
}
export const piSpec: AgentSpec = {

View File

@ -45,7 +45,17 @@ function normalizeThinkLevel(raw?: string | null): ThinkLevel | undefined {
return "low";
if (["med", "medium", "thinkharder", "think-harder", "harder"].includes(key))
return "medium";
if (["high", "ultra", "ultrathink", "think-hard", "thinkhardest", "highest", "max"].includes(key))
if (
[
"high",
"ultra",
"ultrathink",
"think-hard",
"thinkhardest",
"highest",
"max",
].includes(key)
)
return "high";
if (["think"].includes(key)) return "minimal";
return undefined;
@ -67,9 +77,7 @@ function extractThinkDirective(body?: string): {
} {
if (!body) return { cleaned: "", hasDirective: false };
// Match the longest keyword first to avoid partial captures (e.g. "/think:high")
const match = body.match(
/\/(?:thinking|think|t)\s*:?\s*([a-zA-Z-]+)\b/i,
);
const match = body.match(/\/(?:thinking|think|t)\s*:?\s*([a-zA-Z-]+)\b/i);
const thinkLevel = normalizeThinkLevel(match?.[1]);
const cleaned = match
? body.replace(match[0], "").replace(/\s+/g, " ").trim()
@ -262,7 +270,7 @@ export async function getReplyFromConfig(
(sessionEntry?.thinkingLevel as ThinkLevel | undefined) ??
(reply?.thinkingDefault as ThinkLevel | undefined);
let resolvedVerboseLevel =
const resolvedVerboseLevel =
inlineVerbose ??
(sessionEntry?.verboseLevel as VerboseLevel | undefined) ??
(reply?.verboseDefault as VerboseLevel | undefined);
@ -559,10 +567,10 @@ export async function getReplyFromConfig(
// If verbose is enabled and this is a new session, prepend a session hint.
const sessionIdHint =
resolvedVerboseLevel === "on" && isNewSession
? sessionId ??
? (sessionId ??
meta.agentMeta?.sessionId ??
templatingCtx.SessionId ??
"unknown"
"unknown")
: undefined;
if (sessionIdHint) {
finalPayloads = [

View File

@ -810,7 +810,11 @@ describe("config and templating", () => {
};
const ack = await index.getReplyFromConfig(
{ Body: "[Dec 1 00:00] [🦞 same-phone] /think:high", From: "+1", To: "+2" },
{
Body: "[Dec 1 00:00] [🦞 same-phone] /think:high",
From: "+1",
To: "+2",
},
undefined,
cfg,
runSpy,
@ -863,7 +867,7 @@ describe("config and templating", () => {
);
expect(runSpy).not.toHaveBeenCalled();
expect(ack?.text).toContain("Unrecognized thinking level \"big\"");
expect(ack?.text).toContain('Unrecognized thinking level "big"');
// Send another message; state should not carry any level.
const second = await index.getReplyFromConfig(