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.
Files changed (43) hide show
  1. package/dist/channel-management.js +92 -0
  2. package/dist/cli.js +10 -2
  3. package/dist/database.js +130 -0
  4. package/dist/discord-bot.js +381 -0
  5. package/dist/discord-utils.js +151 -0
  6. package/dist/discordBot.js +60 -31
  7. package/dist/escape-backticks.test.js +1 -1
  8. package/dist/fork.js +163 -0
  9. package/dist/format-tables.js +93 -0
  10. package/dist/format-tables.test.js +418 -0
  11. package/dist/interaction-handler.js +750 -0
  12. package/dist/markdown.js +3 -3
  13. package/dist/message-formatting.js +188 -0
  14. package/dist/model-command.js +293 -0
  15. package/dist/opencode.js +135 -0
  16. package/dist/session-handler.js +467 -0
  17. package/dist/system-message.js +92 -0
  18. package/dist/tools.js +3 -5
  19. package/dist/utils.js +31 -0
  20. package/dist/voice-handler.js +528 -0
  21. package/dist/voice.js +257 -35
  22. package/package.json +3 -2
  23. package/src/channel-management.ts +145 -0
  24. package/src/cli.ts +10 -2
  25. package/src/database.ts +155 -0
  26. package/src/discord-bot.ts +506 -0
  27. package/src/discord-utils.ts +208 -0
  28. package/src/escape-backticks.test.ts +1 -1
  29. package/src/fork.ts +224 -0
  30. package/src/format-tables.test.ts +440 -0
  31. package/src/format-tables.ts +106 -0
  32. package/src/interaction-handler.ts +1000 -0
  33. package/src/markdown.ts +3 -3
  34. package/src/message-formatting.ts +227 -0
  35. package/src/model-command.ts +380 -0
  36. package/src/opencode.ts +180 -0
  37. package/src/session-handler.ts +601 -0
  38. package/src/system-message.ts +92 -0
  39. package/src/tools.ts +3 -5
  40. package/src/utils.ts +37 -0
  41. package/src/voice-handler.ts +745 -0
  42. package/src/voice.ts +354 -36
  43. 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 './discordBot.js'
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
+ }