kimaki 0.3.1 → 0.4.0
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/discordBot.js +27 -7
- package/dist/utils.js +3 -2
- package/package.json +1 -1
- package/src/discordBot.ts +27 -10
- package/src/utils.ts +8 -7
package/dist/discordBot.js
CHANGED
|
@@ -718,7 +718,6 @@ function formatPart(part) {
|
|
|
718
718
|
return `▪︎ thinking: ${escapeDiscordFormatting(part.text || '')}`;
|
|
719
719
|
case 'tool':
|
|
720
720
|
if (part.state.status === 'completed' || part.state.status === 'error') {
|
|
721
|
-
let language = '';
|
|
722
721
|
let outputToDisplay = '';
|
|
723
722
|
let summaryText = '';
|
|
724
723
|
if (part.tool === 'bash') {
|
|
@@ -740,6 +739,23 @@ function formatPart(part) {
|
|
|
740
739
|
const lines = content.split('\n').length;
|
|
741
740
|
summaryText = `(${lines} line${lines === 1 ? '' : 's'})`;
|
|
742
741
|
}
|
|
742
|
+
else if (part.tool === 'read') {
|
|
743
|
+
}
|
|
744
|
+
else if (part.tool === 'write') {
|
|
745
|
+
}
|
|
746
|
+
else if (part.tool === 'edit') {
|
|
747
|
+
}
|
|
748
|
+
else if (part.tool === 'list') {
|
|
749
|
+
}
|
|
750
|
+
else if (part.tool === 'glob') {
|
|
751
|
+
}
|
|
752
|
+
else if (part.tool === 'grep') {
|
|
753
|
+
}
|
|
754
|
+
else if (part.tool === 'task') {
|
|
755
|
+
}
|
|
756
|
+
else if (part.tool === 'todoread') {
|
|
757
|
+
// Special handling for read - don't show arguments
|
|
758
|
+
}
|
|
743
759
|
else if (part.tool === 'todowrite') {
|
|
744
760
|
const todos = part.state.input?.todos || [];
|
|
745
761
|
outputToDisplay = todos
|
|
@@ -775,12 +791,14 @@ function formatPart(part) {
|
|
|
775
791
|
if (value === null || value === undefined)
|
|
776
792
|
return null;
|
|
777
793
|
const stringValue = typeof value === 'string' ? value : JSON.stringify(value);
|
|
778
|
-
const truncatedValue = stringValue.length > 100
|
|
794
|
+
const truncatedValue = stringValue.length > 100
|
|
795
|
+
? stringValue.slice(0, 100) + '…'
|
|
796
|
+
: stringValue;
|
|
779
797
|
return `${key}: ${truncatedValue}`;
|
|
780
798
|
})
|
|
781
799
|
.filter(Boolean);
|
|
782
800
|
if (inputFields.length > 0) {
|
|
783
|
-
outputToDisplay = inputFields.join('
|
|
801
|
+
outputToDisplay = inputFields.join(', ');
|
|
784
802
|
}
|
|
785
803
|
}
|
|
786
804
|
let toolTitle = part.state.status === 'completed' ? part.state.title || '' : 'error';
|
|
@@ -1174,12 +1192,14 @@ async function handleOpencodeSession(prompt, thread, projectDirectory, originalM
|
|
|
1174
1192
|
}
|
|
1175
1193
|
}
|
|
1176
1194
|
// Always log the error's constructor name (if any) and make error reporting more readable
|
|
1177
|
-
const errorName = error &&
|
|
1195
|
+
const errorName = error &&
|
|
1196
|
+
typeof error === 'object' &&
|
|
1197
|
+
'constructor' in error &&
|
|
1198
|
+
error.constructor &&
|
|
1199
|
+
typeof error.constructor.name === 'string'
|
|
1178
1200
|
? error.constructor.name
|
|
1179
1201
|
: typeof error;
|
|
1180
|
-
const errorMsg = error instanceof Error
|
|
1181
|
-
? (error.stack || error.message)
|
|
1182
|
-
: String(error);
|
|
1202
|
+
const errorMsg = error instanceof Error ? error.stack || error.message : String(error);
|
|
1183
1203
|
await sendThreadMessage(thread, `✗ Unexpected bot Error: [${errorName}]\n${errorMsg}`);
|
|
1184
1204
|
}
|
|
1185
1205
|
}
|
package/dist/utils.js
CHANGED
|
@@ -40,11 +40,12 @@ export function deduplicateByKey(arr, keyFn) {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
export function isAbortError(error, signal) {
|
|
43
|
-
return (error instanceof Error &&
|
|
43
|
+
return ((error instanceof Error &&
|
|
44
44
|
(error.name === 'AbortError' ||
|
|
45
45
|
error.name === 'Aborterror' ||
|
|
46
46
|
error.name === 'aborterror' ||
|
|
47
47
|
error.name.toLowerCase() === 'aborterror' ||
|
|
48
48
|
error.message?.includes('aborted') ||
|
|
49
|
-
(signal?.aborted ?? false)))
|
|
49
|
+
(signal?.aborted ?? false))) ||
|
|
50
|
+
(error instanceof DOMException && error.name === 'AbortError'));
|
|
50
51
|
}
|
package/package.json
CHANGED
package/src/discordBot.ts
CHANGED
|
@@ -945,6 +945,7 @@ export async function initializeOpencodeForDirectory(directory: string) {
|
|
|
945
945
|
}
|
|
946
946
|
}
|
|
947
947
|
|
|
948
|
+
|
|
948
949
|
function formatPart(part: Part): string {
|
|
949
950
|
switch (part.type) {
|
|
950
951
|
case 'text':
|
|
@@ -954,7 +955,6 @@ function formatPart(part: Part): string {
|
|
|
954
955
|
return `▪︎ thinking: ${escapeDiscordFormatting(part.text || '')}`
|
|
955
956
|
case 'tool':
|
|
956
957
|
if (part.state.status === 'completed' || part.state.status === 'error') {
|
|
957
|
-
let language = ''
|
|
958
958
|
let outputToDisplay = ''
|
|
959
959
|
let summaryText = ''
|
|
960
960
|
|
|
@@ -975,6 +975,15 @@ function formatPart(part: Part): string {
|
|
|
975
975
|
const content = (part.state.input?.content as string) || ''
|
|
976
976
|
const lines = content.split('\n').length
|
|
977
977
|
summaryText = `(${lines} line${lines === 1 ? '' : 's'})`
|
|
978
|
+
} else if (part.tool === 'read') {
|
|
979
|
+
} else if (part.tool === 'write') {
|
|
980
|
+
} else if (part.tool === 'edit') {
|
|
981
|
+
} else if (part.tool === 'list') {
|
|
982
|
+
} else if (part.tool === 'glob') {
|
|
983
|
+
} else if (part.tool === 'grep') {
|
|
984
|
+
} else if (part.tool === 'task') {
|
|
985
|
+
} else if (part.tool === 'todoread') {
|
|
986
|
+
// Special handling for read - don't show arguments
|
|
978
987
|
} else if (part.tool === 'todowrite') {
|
|
979
988
|
const todos =
|
|
980
989
|
(part.state.input?.todos as {
|
|
@@ -1010,13 +1019,17 @@ function formatPart(part: Part): string {
|
|
|
1010
1019
|
const inputFields = Object.entries(part.state.input)
|
|
1011
1020
|
.map(([key, value]) => {
|
|
1012
1021
|
if (value === null || value === undefined) return null
|
|
1013
|
-
const stringValue =
|
|
1014
|
-
|
|
1022
|
+
const stringValue =
|
|
1023
|
+
typeof value === 'string' ? value : JSON.stringify(value)
|
|
1024
|
+
const truncatedValue =
|
|
1025
|
+
stringValue.length > 100
|
|
1026
|
+
? stringValue.slice(0, 100) + '…'
|
|
1027
|
+
: stringValue
|
|
1015
1028
|
return `${key}: ${truncatedValue}`
|
|
1016
1029
|
})
|
|
1017
1030
|
.filter(Boolean)
|
|
1018
1031
|
if (inputFields.length > 0) {
|
|
1019
|
-
outputToDisplay = inputFields.join('
|
|
1032
|
+
outputToDisplay = inputFields.join(', ')
|
|
1020
1033
|
}
|
|
1021
1034
|
}
|
|
1022
1035
|
|
|
@@ -1515,12 +1528,16 @@ async function handleOpencodeSession(
|
|
|
1515
1528
|
}
|
|
1516
1529
|
}
|
|
1517
1530
|
// Always log the error's constructor name (if any) and make error reporting more readable
|
|
1518
|
-
const errorName =
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1531
|
+
const errorName =
|
|
1532
|
+
error &&
|
|
1533
|
+
typeof error === 'object' &&
|
|
1534
|
+
'constructor' in error &&
|
|
1535
|
+
error.constructor &&
|
|
1536
|
+
typeof error.constructor.name === 'string'
|
|
1537
|
+
? error.constructor.name
|
|
1538
|
+
: typeof error
|
|
1539
|
+
const errorMsg =
|
|
1540
|
+
error instanceof Error ? error.stack || error.message : String(error)
|
|
1524
1541
|
await sendThreadMessage(
|
|
1525
1542
|
thread,
|
|
1526
1543
|
`✗ Unexpected bot Error: [${errorName}]\n${errorMsg}`,
|
package/src/utils.ts
CHANGED
|
@@ -65,12 +65,13 @@ export function isAbortError(
|
|
|
65
65
|
signal?: AbortSignal,
|
|
66
66
|
): error is Error {
|
|
67
67
|
return (
|
|
68
|
-
error instanceof Error &&
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
(error instanceof Error &&
|
|
69
|
+
(error.name === 'AbortError' ||
|
|
70
|
+
error.name === 'Aborterror' ||
|
|
71
|
+
error.name === 'aborterror' ||
|
|
72
|
+
error.name.toLowerCase() === 'aborterror' ||
|
|
73
|
+
error.message?.includes('aborted') ||
|
|
74
|
+
(signal?.aborted ?? false))) ||
|
|
75
|
+
(error instanceof DOMException && error.name === 'AbortError')
|
|
75
76
|
)
|
|
76
77
|
}
|