kimaki 0.4.21 → 0.4.23
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/channel-management.js +92 -0
- package/dist/cli.js +10 -2
- package/dist/database.js +130 -0
- package/dist/discord-bot.js +381 -0
- package/dist/discord-utils.js +151 -0
- package/dist/discordBot.js +60 -31
- package/dist/escape-backticks.test.js +1 -1
- package/dist/fork.js +163 -0
- package/dist/format-tables.js +93 -0
- package/dist/format-tables.test.js +418 -0
- package/dist/interaction-handler.js +750 -0
- package/dist/markdown.js +3 -3
- package/dist/message-formatting.js +188 -0
- package/dist/model-command.js +293 -0
- package/dist/opencode.js +135 -0
- package/dist/session-handler.js +467 -0
- package/dist/system-message.js +92 -0
- package/dist/tools.js +3 -5
- package/dist/utils.js +31 -0
- package/dist/voice-handler.js +528 -0
- package/dist/voice.js +257 -35
- package/package.json +3 -2
- package/src/channel-management.ts +145 -0
- package/src/cli.ts +10 -2
- package/src/database.ts +155 -0
- package/src/discord-bot.ts +506 -0
- package/src/discord-utils.ts +208 -0
- package/src/escape-backticks.test.ts +1 -1
- package/src/fork.ts +224 -0
- package/src/format-tables.test.ts +440 -0
- package/src/format-tables.ts +106 -0
- package/src/interaction-handler.ts +1000 -0
- package/src/markdown.ts +3 -3
- package/src/message-formatting.ts +227 -0
- package/src/model-command.ts +380 -0
- package/src/opencode.ts +180 -0
- package/src/session-handler.ts +601 -0
- package/src/system-message.ts +92 -0
- package/src/tools.ts +3 -5
- package/src/utils.ts +37 -0
- package/src/voice-handler.ts +745 -0
- package/src/voice.ts +354 -36
- package/src/discordBot.ts +0 -3643
package/src/tools.ts
CHANGED
|
@@ -11,14 +11,14 @@ import {
|
|
|
11
11
|
import { createLogger } from './logger.js'
|
|
12
12
|
|
|
13
13
|
const toolsLogger = createLogger('TOOLS')
|
|
14
|
-
import { formatDistanceToNow } from 'date-fns'
|
|
15
14
|
|
|
16
15
|
import { ShareMarkdown } from './markdown.js'
|
|
16
|
+
import { formatDistanceToNow } from './utils.js'
|
|
17
17
|
import pc from 'picocolors'
|
|
18
18
|
import {
|
|
19
19
|
initializeOpencodeForDirectory,
|
|
20
20
|
getOpencodeSystemMessage,
|
|
21
|
-
} from './
|
|
21
|
+
} from './discord-bot.js'
|
|
22
22
|
|
|
23
23
|
export async function getTools({
|
|
24
24
|
onMessageCompleted,
|
|
@@ -232,9 +232,7 @@ export async function getTools({
|
|
|
232
232
|
id: session.id,
|
|
233
233
|
folder: session.directory,
|
|
234
234
|
status,
|
|
235
|
-
finishedAt: formatDistanceToNow(new Date(finishedAt),
|
|
236
|
-
addSuffix: true,
|
|
237
|
-
}),
|
|
235
|
+
finishedAt: formatDistanceToNow(new Date(finishedAt)),
|
|
238
236
|
title: session.title,
|
|
239
237
|
prompt: session.title,
|
|
240
238
|
}
|
package/src/utils.ts
CHANGED
|
@@ -75,3 +75,40 @@ export function isAbortError(
|
|
|
75
75
|
(error instanceof DOMException && error.name === 'AbortError')
|
|
76
76
|
)
|
|
77
77
|
}
|
|
78
|
+
|
|
79
|
+
const rtf = new Intl.RelativeTimeFormat('en', { numeric: 'auto' })
|
|
80
|
+
|
|
81
|
+
const TIME_DIVISIONS: Array<{ amount: number; name: Intl.RelativeTimeFormatUnit }> = [
|
|
82
|
+
{ amount: 60, name: 'seconds' },
|
|
83
|
+
{ amount: 60, name: 'minutes' },
|
|
84
|
+
{ amount: 24, name: 'hours' },
|
|
85
|
+
{ amount: 7, name: 'days' },
|
|
86
|
+
{ amount: 4.34524, name: 'weeks' },
|
|
87
|
+
{ amount: 12, name: 'months' },
|
|
88
|
+
{ amount: Number.POSITIVE_INFINITY, name: 'years' },
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
export function formatDistanceToNow(date: Date): string {
|
|
92
|
+
let duration = (date.getTime() - Date.now()) / 1000
|
|
93
|
+
|
|
94
|
+
for (const division of TIME_DIVISIONS) {
|
|
95
|
+
if (Math.abs(duration) < division.amount) {
|
|
96
|
+
return rtf.format(Math.round(duration), division.name)
|
|
97
|
+
}
|
|
98
|
+
duration /= division.amount
|
|
99
|
+
}
|
|
100
|
+
return rtf.format(Math.round(duration), 'years')
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const dtf = new Intl.DateTimeFormat('en-US', {
|
|
104
|
+
month: 'short',
|
|
105
|
+
day: 'numeric',
|
|
106
|
+
year: 'numeric',
|
|
107
|
+
hour: 'numeric',
|
|
108
|
+
minute: '2-digit',
|
|
109
|
+
hour12: true,
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
export function formatDateTime(date: Date): string {
|
|
113
|
+
return dtf.format(date)
|
|
114
|
+
}
|