kimaki 0.4.54 → 0.4.55

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 (110) hide show
  1. package/bin.js +1 -69
  2. package/dist/channel-management.js +17 -12
  3. package/dist/cli.js +119 -129
  4. package/dist/commands/abort.js +4 -7
  5. package/dist/commands/add-project.js +9 -12
  6. package/dist/commands/agent.js +10 -15
  7. package/dist/commands/compact.js +4 -7
  8. package/dist/commands/fork.js +11 -18
  9. package/dist/commands/gemini-apikey.js +53 -0
  10. package/dist/commands/login.js +2 -2
  11. package/dist/commands/merge-worktree.js +1 -1
  12. package/dist/commands/model.js +10 -15
  13. package/dist/commands/queue.js +6 -8
  14. package/dist/commands/remove-project.js +4 -10
  15. package/dist/commands/restart-opencode-server.js +2 -2
  16. package/dist/commands/resume.js +11 -14
  17. package/dist/commands/session.js +4 -4
  18. package/dist/commands/share.js +4 -7
  19. package/dist/commands/undo-redo.js +7 -13
  20. package/dist/commands/user-command.js +5 -7
  21. package/dist/commands/verbosity.js +2 -2
  22. package/dist/commands/worktree-settings.js +3 -3
  23. package/dist/commands/worktree.js +9 -9
  24. package/dist/database.js +480 -240
  25. package/dist/db.js +69 -0
  26. package/dist/db.test.js +23 -0
  27. package/dist/discord-bot.js +18 -20
  28. package/dist/discord-utils.js +2 -2
  29. package/dist/generated/browser.js +17 -0
  30. package/dist/generated/client.js +35 -0
  31. package/dist/generated/commonInputTypes.js +10 -0
  32. package/dist/generated/enums.js +11 -0
  33. package/dist/generated/internal/class.js +41 -0
  34. package/dist/generated/internal/prismaNamespace.js +174 -0
  35. package/dist/generated/internal/prismaNamespaceBrowser.js +144 -0
  36. package/dist/generated/models/bot_api_keys.js +1 -0
  37. package/dist/generated/models/bot_tokens.js +1 -0
  38. package/dist/generated/models/channel_agents.js +1 -0
  39. package/dist/generated/models/channel_directories.js +1 -0
  40. package/dist/generated/models/channel_models.js +1 -0
  41. package/dist/generated/models/channel_verbosity.js +1 -0
  42. package/dist/generated/models/channel_worktrees.js +1 -0
  43. package/dist/generated/models/part_messages.js +1 -0
  44. package/dist/generated/models/pending_auto_start.js +1 -0
  45. package/dist/generated/models/session_agents.js +1 -0
  46. package/dist/generated/models/session_models.js +1 -0
  47. package/dist/generated/models/thread_sessions.js +1 -0
  48. package/dist/generated/models/thread_worktrees.js +1 -0
  49. package/dist/generated/models.js +1 -0
  50. package/dist/interaction-handler.js +13 -4
  51. package/dist/logger.js +10 -12
  52. package/dist/session-handler.js +22 -28
  53. package/dist/voice-handler.js +30 -24
  54. package/dist/voice.js +64 -243
  55. package/package.json +9 -3
  56. package/src/channel-management.ts +29 -27
  57. package/src/cli.ts +134 -152
  58. package/src/commands/abort.ts +4 -8
  59. package/src/commands/add-project.ts +9 -14
  60. package/src/commands/agent.ts +11 -18
  61. package/src/commands/compact.ts +4 -8
  62. package/src/commands/fork.ts +12 -20
  63. package/src/commands/gemini-apikey.ts +76 -0
  64. package/src/commands/login.ts +2 -2
  65. package/src/commands/merge-worktree.ts +1 -1
  66. package/src/commands/model.ts +10 -17
  67. package/src/commands/queue.ts +6 -8
  68. package/src/commands/remove-project.ts +5 -15
  69. package/src/commands/restart-opencode-server.ts +2 -2
  70. package/src/commands/resume.ts +12 -23
  71. package/src/commands/session.ts +4 -4
  72. package/src/commands/share.ts +4 -8
  73. package/src/commands/undo-redo.ts +7 -15
  74. package/src/commands/user-command.ts +5 -7
  75. package/src/commands/verbosity.ts +2 -2
  76. package/src/commands/worktree-settings.ts +3 -3
  77. package/src/commands/worktree.ts +10 -10
  78. package/src/database.ts +590 -339
  79. package/src/db.test.ts +27 -0
  80. package/src/db.ts +88 -0
  81. package/src/discord-bot.ts +21 -20
  82. package/src/discord-utils.ts +3 -3
  83. package/src/generated/browser.ts +84 -0
  84. package/src/generated/client.ts +106 -0
  85. package/src/generated/commonInputTypes.ts +272 -0
  86. package/src/generated/enums.ts +15 -0
  87. package/src/generated/internal/class.ts +312 -0
  88. package/src/generated/internal/prismaNamespace.ts +1763 -0
  89. package/src/generated/internal/prismaNamespaceBrowser.ts +223 -0
  90. package/src/generated/models/bot_api_keys.ts +1256 -0
  91. package/src/generated/models/bot_tokens.ts +1355 -0
  92. package/src/generated/models/channel_agents.ts +1256 -0
  93. package/src/generated/models/channel_directories.ts +1797 -0
  94. package/src/generated/models/channel_models.ts +1256 -0
  95. package/src/generated/models/channel_verbosity.ts +1224 -0
  96. package/src/generated/models/channel_worktrees.ts +1308 -0
  97. package/src/generated/models/part_messages.ts +1302 -0
  98. package/src/generated/models/pending_auto_start.ts +1192 -0
  99. package/src/generated/models/session_agents.ts +1086 -0
  100. package/src/generated/models/session_models.ts +1086 -0
  101. package/src/generated/models/thread_sessions.ts +1456 -0
  102. package/src/generated/models/thread_worktrees.ts +1352 -0
  103. package/src/generated/models.ts +24 -0
  104. package/src/interaction-handler.ts +19 -5
  105. package/src/logger.ts +10 -12
  106. package/src/schema.sql +84 -0
  107. package/src/session-handler.ts +27 -36
  108. package/src/voice-handler.ts +41 -25
  109. package/src/voice.ts +68 -304
  110. package/src/commands/sqlitedb.ts +0 -20
package/bin.js CHANGED
@@ -1,70 +1,2 @@
1
1
  #!/usr/bin/env node
2
-
3
- // CLI entrypoint with automatic restart capability.
4
- // Spawns the main CLI and restarts it on non-zero exit codes with throttling.
5
- // Exit codes 0, 130 (SIGINT), 143 (SIGTERM), or 64 (EXIT_NO_RESTART) terminate cleanly.
6
-
7
- import { spawn } from 'node:child_process'
8
- import { fileURLToPath } from 'node:url'
9
- import { dirname, join } from 'node:path'
10
-
11
- const __filename = fileURLToPath(import.meta.url)
12
- const __dirname = dirname(__filename)
13
-
14
- const NODE_PATH = process.execPath
15
- const CLI_PATH = join(__dirname, 'dist', 'cli.js')
16
-
17
- let lastStart = 0
18
-
19
- async function sleep(ms) {
20
- return new Promise(resolve => setTimeout(resolve, ms))
21
- }
22
-
23
- async function run() {
24
- while (true) {
25
- const now = Date.now()
26
- const elapsed = now - lastStart
27
- if (elapsed < 5000) {
28
- await sleep(5000 - elapsed)
29
- }
30
- lastStart = Date.now()
31
-
32
- try {
33
- const code = await new Promise((resolve) => {
34
- const child = spawn(NODE_PATH, [CLI_PATH, ...process.argv.slice(2)], {
35
- stdio: 'inherit'
36
- })
37
-
38
- child.on('exit', (code, signal) => {
39
- if (signal) {
40
- // Map signals to exit codes similar to bash
41
- if (signal === 'SIGINT') resolve(130)
42
- else if (signal === 'SIGTERM') resolve(143)
43
- else resolve(1)
44
- } else {
45
- resolve(code || 0)
46
- }
47
- })
48
-
49
- child.on('error', (err) => {
50
- console.error('Failed to start process:', err)
51
- resolve(1)
52
- })
53
- })
54
-
55
- // Exit cleanly if the app ended OK or via SIGINT/SIGTERM
56
- if (code === 0 || code === 130 || code === 143 || code === 64) {
57
- process.exit(code)
58
- }
59
- // otherwise loop; the 5s throttle above will apply
60
- } catch (err) {
61
- console.error('Unexpected error:', err)
62
- // Continue looping after error
63
- }
64
- }
65
- }
66
-
67
- run().catch(err => {
68
- console.error('Fatal error:', err)
69
- process.exit(1)
70
- })
2
+ import './dist/cli.js'
@@ -3,7 +3,7 @@
3
3
  // extracts channel metadata from topic tags, and ensures category structure.
4
4
  import { ChannelType } from 'discord.js';
5
5
  import path from 'node:path';
6
- import { getDatabase, getChannelDirectory } from './database.js';
6
+ import { getChannelDirectory, setChannelDirectory } from './database.js';
7
7
  export async function ensureKimakiCategory(guild, botName) {
8
8
  // Skip appending bot name if it's already "kimaki" to avoid "Kimaki kimaki"
9
9
  const isKimakiBot = botName?.toLowerCase() === 'kimaki';
@@ -53,9 +53,12 @@ export async function createProjectChannels({ guild, projectDirectory, appId, bo
53
53
  parent: kimakiCategory,
54
54
  // Channel configuration is stored in SQLite, not in the topic
55
55
  });
56
- getDatabase()
57
- .prepare('INSERT OR REPLACE INTO channel_directories (channel_id, directory, channel_type, app_id) VALUES (?, ?, ?, ?)')
58
- .run(textChannel.id, projectDirectory, 'text', appId);
56
+ await setChannelDirectory({
57
+ channelId: textChannel.id,
58
+ directory: projectDirectory,
59
+ channelType: 'text',
60
+ appId,
61
+ });
59
62
  let voiceChannelId = null;
60
63
  if (enableVoiceChannels) {
61
64
  const kimakiAudioCategory = await ensureKimakiAudioCategory(guild, botName);
@@ -64,9 +67,12 @@ export async function createProjectChannels({ guild, projectDirectory, appId, bo
64
67
  type: ChannelType.GuildVoice,
65
68
  parent: kimakiAudioCategory,
66
69
  });
67
- getDatabase()
68
- .prepare('INSERT OR REPLACE INTO channel_directories (channel_id, directory, channel_type, app_id) VALUES (?, ?, ?, ?)')
69
- .run(voiceChannel.id, projectDirectory, 'voice', appId);
70
+ await setChannelDirectory({
71
+ channelId: voiceChannel.id,
72
+ directory: projectDirectory,
73
+ channelType: 'voice',
74
+ appId,
75
+ });
70
76
  voiceChannelId = voiceChannel.id;
71
77
  }
72
78
  return {
@@ -77,13 +83,12 @@ export async function createProjectChannels({ guild, projectDirectory, appId, bo
77
83
  }
78
84
  export async function getChannelsWithDescriptions(guild) {
79
85
  const channels = [];
80
- guild.channels.cache
81
- .filter((channel) => channel.isTextBased())
82
- .forEach((channel) => {
86
+ const textChannels = guild.channels.cache.filter((channel) => channel.isTextBased());
87
+ for (const channel of textChannels.values()) {
83
88
  const textChannel = channel;
84
89
  const description = textChannel.topic || null;
85
90
  // Get channel config from database instead of parsing XML from topic
86
- const channelConfig = getChannelDirectory(textChannel.id);
91
+ const channelConfig = await getChannelDirectory(textChannel.id);
87
92
  channels.push({
88
93
  id: textChannel.id,
89
94
  name: textChannel.name,
@@ -91,6 +96,6 @@ export async function getChannelsWithDescriptions(guild) {
91
96
  kimakiDirectory: channelConfig?.directory,
92
97
  kimakiApp: channelConfig?.appId || undefined,
93
98
  });
94
- });
99
+ }
95
100
  return channels;
96
101
  }