@lesscap/baton-cli 0.2.10 → 0.2.11
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/dist/baton.mjs +18 -4
- package/package.json +1 -1
package/dist/baton.mjs
CHANGED
|
@@ -2446,16 +2446,30 @@ import { query as query2 } from "@anthropic-ai/claude-agent-sdk";
|
|
|
2446
2446
|
// src/session/runner/title.ts
|
|
2447
2447
|
var clip = (s, max) => s.length > max ? s.slice(0, max) : s;
|
|
2448
2448
|
var isDeclined = (title) => title.replace(/[^a-z]/gi, "").toUpperCase() === "NONE";
|
|
2449
|
-
var sanitizeTitle = (raw) => raw.replace(/[\r\n]+/g, " ").replace(/[*_`~#>]/g, "").replace(/["']/g, "").replace(/^\s*(?:title|session|标题)\s*[::-]\s*/i, "").replace(/^\s*(?:[-*•]|\d+[.)、])\s+/, "").replace(/\s+/g, " ").trim().slice(0, 30).replace(/[\s。.,,、;;::!!??.]+$/, "").trim();
|
|
2449
|
+
var sanitizeTitle = (raw) => raw.replace(/[\r\n]+/g, " ").replace(/[*_`~#>]/g, "").replace(/["']/g, "").replace(/^\s*(?:title|session|标题)\s*[::-]\s*/i, "").replace(/^\s*(?:[-*•]|\d+[.)、])\s+/, "").replace(/\s+/g, " ").trim().replace(/(?:[。.!?,、;;]|[.!?;](?=\s|$)).*$/s, "").trim().slice(0, 30).replace(/[\s。.,,、;;::!!??.]+$/, "").trim();
|
|
2450
2450
|
var TITLE_TIMEOUT_MS = 9e4;
|
|
2451
2451
|
var buildPrompt2 = (userText, assistantText) => {
|
|
2452
2452
|
const exchange = [
|
|
2453
2453
|
`User: ${clip(userText, 800)}`,
|
|
2454
2454
|
assistantText ? `Assistant: ${clip(assistantText, 800)}` : ""
|
|
2455
2455
|
].filter(Boolean).join("\n");
|
|
2456
|
-
return
|
|
2457
|
-
|
|
2458
|
-
|
|
2456
|
+
return [
|
|
2457
|
+
"Name the TOPIC of this chat session \u2014 what it is ABOUT \u2014 as a short title:",
|
|
2458
|
+
"a noun phrase like a filename, at most 6 words or ~12 Chinese characters.",
|
|
2459
|
+
"Name the subject, do NOT restate the conclusion or the answer.",
|
|
2460
|
+
"No sentence, no punctuation at all (including Chinese \uFF0C\u3002\u3001\uFF1B\uFF01\uFF1F), no markdown,",
|
|
2461
|
+
`no quotes, and never an opener like "\u597D\u7684"/"\u6536\u5230"/"I'll".`,
|
|
2462
|
+
"",
|
|
2463
|
+
"Examples (exchange \u2192 title):",
|
|
2464
|
+
"User asks whether the material-ui repo needs updating; assistant says it is",
|
|
2465
|
+
"already up to date \u2192 material-ui \u4ED3\u5E93\u66F4\u65B0\u68C0\u67E5",
|
|
2466
|
+
"User: curl the health endpoint and report status \u2192 \u5065\u5EB7\u68C0\u67E5\u63A5\u53E3\u6392\u67E5",
|
|
2467
|
+
"",
|
|
2468
|
+
"Only if the exchange below has no real content at all (just a greeting or a",
|
|
2469
|
+
"test ping) reply with exactly NONE. Otherwise reply with ONLY the title.",
|
|
2470
|
+
"",
|
|
2471
|
+
exchange
|
|
2472
|
+
].join("\n");
|
|
2459
2473
|
};
|
|
2460
2474
|
var generateTitle = async (input) => {
|
|
2461
2475
|
const { worktreePath, userText, assistantText, queryFn } = input;
|