klaudio 0.8.3 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "klaudio",
3
- "version": "0.8.3",
3
+ "version": "0.8.5",
4
4
  "description": "Add sound effects to your coding sessions — play sounds when tasks complete, notifications arrive, and more",
5
5
  "type": "module",
6
6
  "bin": {
package/src/installer.js CHANGED
@@ -70,9 +70,9 @@ export async function install({ scope, sounds, tts = false }) {
70
70
  settings.hooks[hookEvent] = [];
71
71
  }
72
72
 
73
- // Remove any existing klaudio entries
73
+ // Remove any existing klaudio/klonk entries
74
74
  settings.hooks[hookEvent] = settings.hooks[hookEvent].filter(
75
- (entry) => !entry._klaudio
75
+ (entry) => !entry._klaudio && !entry._klonk
76
76
  );
77
77
 
78
78
  // Add our hook
@@ -170,7 +170,7 @@ export async function getExistingSounds(scope) {
170
170
  for (const [eventId, event] of Object.entries(EVENTS)) {
171
171
  const hookEntries = settings.hooks[event.hookEvent];
172
172
  if (!hookEntries) continue;
173
- const entry = hookEntries.find((e) => e._klaudio);
173
+ const entry = hookEntries.find((e) => e._klaudio || e._klonk);
174
174
  if (!entry?.hooks?.[0]?.command) continue;
175
175
 
176
176
  // Extract file path from the play command
@@ -200,7 +200,7 @@ export async function uninstall(scope) {
200
200
  if (settings.hooks) {
201
201
  for (const [event, entries] of Object.entries(settings.hooks)) {
202
202
  settings.hooks[event] = entries.filter(
203
- (entry) => !entry._klaudio
203
+ (entry) => !entry._klaudio && !entry._klonk
204
204
  );
205
205
  if (settings.hooks[event].length === 0) {
206
206
  delete settings.hooks[event];
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
- const sentences = msg.match(/[^.!?]*[.!?]/g);
410
- const summary = sentences ? sentences[0].trim() : msg.slice(0, 100);
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;