claude-remote-approver 0.6.1 → 0.6.2
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/ntfy.mjs +23 -27
package/package.json
CHANGED
package/src/ntfy.mjs
CHANGED
|
@@ -127,6 +127,7 @@ export function stripMarkdown(text) {
|
|
|
127
127
|
// ---------------------------------------------------------------------------
|
|
128
128
|
|
|
129
129
|
const MAX_INPUT = 10000;
|
|
130
|
+
const MESSAGE_MAX_LENGTH = 1000;
|
|
130
131
|
|
|
131
132
|
/**
|
|
132
133
|
* Count consecutive runs of character ch starting at pos.
|
|
@@ -442,37 +443,32 @@ function stripInline(text) {
|
|
|
442
443
|
* @returns {{ title: string, message: string }}
|
|
443
444
|
*/
|
|
444
445
|
export function formatToolInfo({ hook_event_name, tool_name, tool_input }) {
|
|
445
|
-
|
|
446
|
+
let title;
|
|
447
|
+
let message;
|
|
448
|
+
|
|
446
449
|
if (tool_name === 'ExitPlanMode' && typeof tool_input?.plan === 'string') {
|
|
447
|
-
|
|
448
|
-
const
|
|
449
|
-
|
|
450
|
-
|
|
450
|
+
title = 'Claude Code: Plan Review';
|
|
451
|
+
const plain = tool_input.plan.trim() ? stripMarkdown(tool_input.plan) : '';
|
|
452
|
+
message = plain || '(empty plan)';
|
|
453
|
+
} else {
|
|
454
|
+
title = `Claude Code: ${tool_name}`;
|
|
455
|
+
switch (tool_name) {
|
|
456
|
+
case 'Bash':
|
|
457
|
+
message = tool_input?.command ?? JSON.stringify(tool_input);
|
|
458
|
+
break;
|
|
459
|
+
case 'Read':
|
|
460
|
+
case 'Write':
|
|
461
|
+
case 'Edit':
|
|
462
|
+
message = tool_input?.file_path ?? JSON.stringify(tool_input);
|
|
463
|
+
break;
|
|
464
|
+
default:
|
|
465
|
+
message = JSON.stringify(tool_input);
|
|
466
|
+
break;
|
|
451
467
|
}
|
|
452
|
-
const raw = tool_input.plan;
|
|
453
|
-
const plain = stripMarkdown(raw);
|
|
454
|
-
const message = plain
|
|
455
|
-
? (plain.length > PLAN_MESSAGE_MAX_LENGTH ? plain.slice(0, PLAN_MESSAGE_MAX_LENGTH) + '...' : plain)
|
|
456
|
-
: '(empty plan)';
|
|
457
|
-
return { title, message };
|
|
458
468
|
}
|
|
459
469
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
switch (tool_name) {
|
|
464
|
-
case 'Bash':
|
|
465
|
-
message = tool_input?.command ?? JSON.stringify(tool_input);
|
|
466
|
-
break;
|
|
467
|
-
case 'Read':
|
|
468
|
-
case 'Write':
|
|
469
|
-
case 'Edit':
|
|
470
|
-
message = tool_input?.file_path ?? JSON.stringify(tool_input);
|
|
471
|
-
break;
|
|
472
|
-
default:
|
|
473
|
-
message = JSON.stringify(tool_input);
|
|
474
|
-
break;
|
|
470
|
+
if (message.length > MESSAGE_MAX_LENGTH) {
|
|
471
|
+
message = message.slice(0, MESSAGE_MAX_LENGTH) + '...';
|
|
475
472
|
}
|
|
476
|
-
|
|
477
473
|
return { title, message };
|
|
478
474
|
}
|