@brianli/kimaki 0.4.72-brianli.1 → 0.4.72-brianli.3

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/bin.js CHANGED
File without changes
package/dist/cli.js CHANGED
@@ -761,20 +761,34 @@ async function run({ restart, addChannels, useWorktrees, enableVoiceChannels, })
761
761
  // 1. KIMAKI_BOT_TOKEN env var (headless/CI deployments)
762
762
  // 2. Saved credentials in the database
763
763
  // 3. Interactive setup wizard (first-time users)
764
- // App ID is always derived from the token (base64 first segment).
764
+ // App ID comes from auth mode env or is derived from token (base64 first segment).
765
765
  const { appId, token, isQuickStart } = await (async () => {
766
766
  const envBot = getBotToken({ allowDatabase: false });
767
767
  const existingBot = getBotToken({ preferEnv: false });
768
- // 1. Env var takes precedence (headless deployments)
769
- if (envBot && !forceSetup) {
770
- const derivedAppId = appIdFromToken(envBot.token);
771
- if (!derivedAppId) {
772
- cliLogger.error('Could not derive Application ID from KIMAKI_BOT_TOKEN. The token appears malformed.');
768
+ // 1. Env var/auth mode takes precedence (headless deployments)
769
+ if (envBot && (!forceSetup || envBot.source === 'auth')) {
770
+ if (forceSetup && envBot.source === 'auth') {
771
+ cliLogger.log('Auth mode enabled; skipping interactive setup (--restart ignored)');
772
+ }
773
+ const resolvedAppId = envBot.appId || appIdFromToken(envBot.token);
774
+ if (!resolvedAppId) {
775
+ cliLogger.error(envBot.source === 'auth'
776
+ ? 'Auth mode requires KIMAKI_APP_ID when using KIMAKI_GUILD_ID/KIMAKI_PRIVATE_KEY.'
777
+ : 'Could not derive Application ID from KIMAKI_BOT_TOKEN. The token appears malformed.');
773
778
  process.exit(EXIT_NO_RESTART);
774
779
  }
775
- await setBotToken(derivedAppId, envBot.token);
776
- cliLogger.log(`Using KIMAKI_BOT_TOKEN env var (App ID: ${derivedAppId})`);
777
- return { appId: derivedAppId, token: envBot.token, isQuickStart: !addChannels };
780
+ await setBotToken(resolvedAppId, envBot.token);
781
+ if (envBot.source === 'auth') {
782
+ cliLogger.log(`Using auth mode credentials (App ID: ${resolvedAppId})`);
783
+ }
784
+ else {
785
+ cliLogger.log(`Using KIMAKI_BOT_TOKEN env var (App ID: ${resolvedAppId})`);
786
+ }
787
+ return {
788
+ appId: resolvedAppId,
789
+ token: envBot.token,
790
+ isQuickStart: !addChannels,
791
+ };
778
792
  }
779
793
  // 2. Saved credentials in the database
780
794
  if (existingBot && !forceSetup) {
package/package.json CHANGED
@@ -2,21 +2,7 @@
2
2
  "name": "@brianli/kimaki",
3
3
  "module": "index.ts",
4
4
  "type": "module",
5
- "version": "0.4.72-brianli.1",
6
- "scripts": {
7
- "dev": "tsx --env-file .env src/cli.ts",
8
- "prepublishOnly": "pnpm generate && pnpm tsc",
9
- "dev:bun": "DEBUG=1 bun --env-file .env src/cli.ts",
10
- "watch": "tsx scripts/watch-session.ts",
11
- "generate": "prisma generate && pnpm generate:sql",
12
- "generate:sql": "rm -f dev.db && prisma db push --url 'file:dev.db' --accept-data-loss && echo '-- This file is generated by pnpm generate:sql. Do not edit manually.' > src/schema.sql && sqlite3 dev.db '.schema' >> src/schema.sql",
13
- "pcm-to-mp3": "bun scripts/pcm-to-mp3",
14
- "test": "vitest",
15
- "test:send": "tsx send-test-message.ts",
16
- "register-commands": "tsx scripts/register-commands.ts",
17
- "format": "oxfmt src",
18
- "sync-skills": "tsx scripts/sync-skills.ts"
19
- },
5
+ "version": "0.4.72-brianli.3",
20
6
  "repository": "https://github.com/remorses/kimaki",
21
7
  "bin": "bin.js",
22
8
  "files": [
@@ -33,11 +19,11 @@
33
19
  "@types/json-schema": "^7.0.15",
34
20
  "@types/ms": "^2.1.0",
35
21
  "@types/node": "^24.3.0",
36
- "discord-digital-twin": "workspace:^",
37
- "opencode-cached-provider": "workspace:^",
38
- "opencode-deterministic-provider": "workspace:^",
39
22
  "prisma": "7.3.0",
40
- "tsx": "^4.20.5"
23
+ "tsx": "^4.20.5",
24
+ "opencode-deterministic-provider": "^0.0.1",
25
+ "discord-digital-twin": "^0.0.1",
26
+ "opencode-cached-provider": "^0.0.1"
41
27
  },
42
28
  "dependencies": {
43
29
  "@ai-sdk/google": "^3.0.30",
@@ -57,7 +43,6 @@
57
43
  "cron-parser": "^5.5.0",
58
44
  "discord.js": "^14.25.1",
59
45
  "domhandler": "^5.0.3",
60
- "errore": "workspace:^",
61
46
  "goke": "^6.1.2",
62
47
  "htmlparser2": "^10.0.0",
63
48
  "js-yaml": "^4.1.0",
@@ -67,16 +52,30 @@
67
52
  "picocolors": "^1.1.1",
68
53
  "pretty-ms": "^9.3.0",
69
54
  "string-dedent": "^3.0.2",
70
- "traforo": "workspace:^",
71
55
  "undici": "^7.16.0",
72
56
  "xdg-basedir": "^5.1.0",
73
57
  "zod": "^4.3.6",
74
- "zustand": "^5.0.11"
58
+ "zustand": "^5.0.11",
59
+ "errore": "^0.14.0",
60
+ "traforo": "^0.0.9"
75
61
  },
76
62
  "optionalDependencies": {
77
63
  "@discordjs/opus": "^0.10.0",
78
64
  "heic-convert": "^2.1.0",
79
65
  "prism-media": "^1.3.5",
80
66
  "sharp": "^0.34.5"
67
+ },
68
+ "scripts": {
69
+ "dev": "tsx --env-file .env src/cli.ts",
70
+ "dev:bun": "DEBUG=1 bun --env-file .env src/cli.ts",
71
+ "watch": "tsx scripts/watch-session.ts",
72
+ "generate": "prisma generate && pnpm generate:sql",
73
+ "generate:sql": "rm -f dev.db && prisma db push --url 'file:dev.db' --accept-data-loss && echo '-- This file is generated by pnpm generate:sql. Do not edit manually.' > src/schema.sql && sqlite3 dev.db '.schema' >> src/schema.sql",
74
+ "pcm-to-mp3": "bun scripts/pcm-to-mp3",
75
+ "test": "vitest",
76
+ "test:send": "tsx send-test-message.ts",
77
+ "register-commands": "tsx scripts/register-commands.ts",
78
+ "format": "oxfmt src",
79
+ "sync-skills": "tsx scripts/sync-skills.ts"
81
80
  }
82
- }
81
+ }
package/src/cli.ts CHANGED
@@ -1121,7 +1121,7 @@ async function run({
1121
1121
  // 1. KIMAKI_BOT_TOKEN env var (headless/CI deployments)
1122
1122
  // 2. Saved credentials in the database
1123
1123
  // 3. Interactive setup wizard (first-time users)
1124
- // App ID is always derived from the token (base64 first segment).
1124
+ // App ID comes from auth mode env or is derived from token (base64 first segment).
1125
1125
  const { appId, token, isQuickStart } = await (async (): Promise<{
1126
1126
  appId: string
1127
1127
  token: string
@@ -1130,18 +1130,33 @@ async function run({
1130
1130
  const envBot = getBotToken({ allowDatabase: false })
1131
1131
  const existingBot = getBotToken({ preferEnv: false })
1132
1132
 
1133
- // 1. Env var takes precedence (headless deployments)
1134
- if (envBot && !forceSetup) {
1135
- const derivedAppId = appIdFromToken(envBot.token)
1136
- if (!derivedAppId) {
1133
+ // 1. Env var/auth mode takes precedence (headless deployments)
1134
+ if (envBot && (!forceSetup || envBot.source === 'auth')) {
1135
+ if (forceSetup && envBot.source === 'auth') {
1136
+ cliLogger.log('Auth mode enabled; skipping interactive setup (--restart ignored)')
1137
+ }
1138
+ const resolvedAppId = envBot.appId || appIdFromToken(envBot.token)
1139
+ if (!resolvedAppId) {
1137
1140
  cliLogger.error(
1138
- 'Could not derive Application ID from KIMAKI_BOT_TOKEN. The token appears malformed.',
1141
+ envBot.source === 'auth'
1142
+ ? 'Auth mode requires KIMAKI_APP_ID when using KIMAKI_GUILD_ID/KIMAKI_PRIVATE_KEY.'
1143
+ : 'Could not derive Application ID from KIMAKI_BOT_TOKEN. The token appears malformed.',
1139
1144
  )
1140
1145
  process.exit(EXIT_NO_RESTART)
1141
1146
  }
1142
- await setBotToken(derivedAppId, envBot.token)
1143
- cliLogger.log(`Using KIMAKI_BOT_TOKEN env var (App ID: ${derivedAppId})`)
1144
- return { appId: derivedAppId, token: envBot.token, isQuickStart: !addChannels }
1147
+ await setBotToken(resolvedAppId, envBot.token)
1148
+ if (envBot.source === 'auth') {
1149
+ cliLogger.log(`Using auth mode credentials (App ID: ${resolvedAppId})`)
1150
+ } else {
1151
+ cliLogger.log(
1152
+ `Using KIMAKI_BOT_TOKEN env var (App ID: ${resolvedAppId})`,
1153
+ )
1154
+ }
1155
+ return {
1156
+ appId: resolvedAppId,
1157
+ token: envBot.token,
1158
+ isQuickStart: !addChannels,
1159
+ }
1145
1160
  }
1146
1161
 
1147
1162
  // 2. Saved credentials in the database