klaudio 0.8.4 → 0.8.5
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/package.json +1 -1
- package/src/player.js +29 -2
package/package.json
CHANGED
package/src/player.js
CHANGED
|
@@ -406,8 +406,35 @@ export async function handlePlayCommand(args) {
|
|
|
406
406
|
.replace(/^\s*\d+\.\s+/gm, "") // numbered lists
|
|
407
407
|
.replace(/\n+/g, " ") // newlines -> spaces
|
|
408
408
|
.trim();
|
|
409
|
-
|
|
410
|
-
|
|
409
|
+
// Build summary: include sentences up to ~25 words max.
|
|
410
|
+
// Short next sentences (<4 chars, e.g. version numbers) are always included.
|
|
411
|
+
const MAX_WORDS = 25;
|
|
412
|
+
// Split on sentence-ending punctuation, but not periods between digits (0.8.4)
|
|
413
|
+
// or inside filenames (auth.js). A period is "sentence-ending" only if followed
|
|
414
|
+
// by a space+letter, end-of-string, or another sentence-end mark.
|
|
415
|
+
const sentences = msg.match(/(?:[^.!?]|\.(?=\d|\w{1,5}\b))*[.!?]+/g);
|
|
416
|
+
let summary;
|
|
417
|
+
if (!sentences) {
|
|
418
|
+
summary = msg.split(/\s+/).slice(0, MAX_WORDS).join(" ");
|
|
419
|
+
} else {
|
|
420
|
+
summary = sentences[0].trim();
|
|
421
|
+
for (let i = 1; i < sentences.length; i++) {
|
|
422
|
+
const next = sentences[i].trim();
|
|
423
|
+
const wordsSoFar = summary.split(/\s+/).length;
|
|
424
|
+
const nextWords = next.split(/\s+/).length;
|
|
425
|
+
// Always include tiny fragments (version numbers, short confirmations)
|
|
426
|
+
if (next.length < 4) {
|
|
427
|
+
summary += " " + next;
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
// Include next sentence if we're still under the word limit
|
|
431
|
+
if (wordsSoFar + nextWords <= MAX_WORDS) {
|
|
432
|
+
summary += " " + next;
|
|
433
|
+
} else {
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
411
438
|
// Prefix with project folder name if available
|
|
412
439
|
const project = hookData.cwd ? hookData.cwd.replace(/\\/g, "/").split("/").pop() : null;
|
|
413
440
|
const spoken = project ? `${project}: ${summary}` : summary;
|