telecoder 1.2.0 → 1.3.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/.env.example +142 -130
- package/CHANGELOG.md +683 -2
- package/README.md +36 -32
- package/dist/audio/transcribe.js +0 -9
- package/dist/bin/mcp-server.js +46 -61
- package/dist/bot/bot.js +162 -181
- package/dist/bot/command-catalog.js +263 -0
- package/dist/bot/deleted-threads.js +103 -0
- package/dist/bot/file-access.js +35 -26
- package/dist/bot/handlers/album.handler.js +128 -0
- package/dist/bot/handlers/{fork.handler.js → branch.handler.js} +267 -280
- package/dist/bot/handlers/command/access.js +1 -1
- package/dist/bot/handlers/command/admin.js +86 -110
- package/dist/bot/handlers/command/all-view.js +33 -0
- package/dist/bot/handlers/command/auto-approve.js +3 -3
- package/dist/bot/handlers/command/background.js +37 -0
- package/dist/bot/handlers/command/botname.js +76 -0
- package/dist/bot/handlers/command/btw.js +20 -69
- package/dist/bot/handlers/command/cleanup.js +329 -0
- package/dist/bot/handlers/command/model.js +40 -119
- package/dist/bot/handlers/command/prefs-scope.js +255 -90
- package/dist/bot/handlers/command/project.js +31 -109
- package/dist/bot/handlers/command/resume.js +8 -4
- package/dist/bot/handlers/command/session.js +74 -213
- package/dist/bot/handlers/command/settings.js +92 -447
- package/dist/bot/handlers/command/shared.js +32 -35
- package/dist/bot/handlers/command/tasks.js +263 -95
- package/dist/bot/handlers/command/thread.js +128 -0
- package/dist/bot/handlers/command/topic-store.js +14 -53
- package/dist/bot/handlers/command/topic.js +8 -61
- package/dist/bot/handlers/command/{cost.js → usage.js} +32 -59
- package/dist/bot/handlers/command-fallback.js +179 -0
- package/dist/bot/handlers/command.handler.js +96 -422
- package/dist/bot/handlers/{schedule.handler.js → loop.handler.js} +159 -73
- package/dist/bot/handlers/media-fallback.js +12 -7
- package/dist/bot/handlers/message/replies.js +10 -87
- package/dist/bot/handlers/message/shared.js +9 -31
- package/dist/bot/handlers/message/turn-notify.js +15 -49
- package/dist/bot/handlers/message/turn-runner.js +18 -103
- package/dist/bot/handlers/message.handler.js +59 -52
- package/dist/bot/handlers/newbot.handler.js +13 -4
- package/dist/bot/handlers/photo.handler.js +88 -129
- package/dist/bot/handlers/prompts.handler.js +11 -11
- package/dist/bot/handlers/running-note.js +2 -2
- package/dist/bot/handlers/session-guard.js +4 -4
- package/dist/bot/handlers/suggestion.handler.js +2 -2
- package/dist/bot/handlers/tree.handler.js +20 -20
- package/dist/bot/handlers/voice.handler.js +23 -85
- package/dist/bot/kept-threads.js +51 -0
- package/dist/bot/middleware/album-collector.js +69 -0
- package/dist/bot/middleware/auth.middleware.js +1 -1
- package/dist/bot/middleware/group-mention.middleware.js +11 -5
- package/dist/bot/middleware/queued-messages.js +143 -32
- package/dist/bot/middleware/stale-filter.js +0 -22
- package/dist/build-info.json +5 -5
- package/dist/claude/ask-user-form.js +517 -0
- package/dist/claude/ask-user.js +94 -26
- package/dist/claude/auto-topic-haiku.js +17 -0
- package/dist/claude/available-commands.js +22 -19
- package/dist/claude/background-hint.js +91 -0
- package/dist/claude/{fork-tree.js → branch-tree.js} +9 -9
- package/dist/claude/carry-over.js +0 -2
- package/dist/claude/ccr-shim.js +12 -10
- package/dist/claude/claude-auth.js +6 -10
- package/dist/claude/command-parser.js +49 -43
- package/dist/claude/cost-overlay-scraper.js +7 -2
- package/dist/claude/effort-level.js +5 -0
- package/dist/claude/enabled-plugins.js +12 -16
- package/dist/claude/in-flight-tracker.js +21 -0
- package/dist/claude/mcp-bridge.js +86 -58
- package/dist/claude/memory-guard.js +400 -0
- package/dist/claude/message-offsets.js +5 -5
- package/dist/claude/modal-relay.js +401 -34
- package/dist/claude/model-catalog.js +20 -3
- package/dist/claude/monitor-relay.js +130 -15
- package/dist/claude/native-commands.js +40 -0
- package/dist/claude/{pending-forks.js → pending-branches.js} +26 -26
- package/dist/claude/permission-gate.js +11 -10
- package/dist/claude/permission-mode.js +19 -45
- package/dist/claude/prewarm.js +70 -0
- package/dist/claude/pty-idle-reaper.js +96 -0
- package/dist/claude/pty-provider.js +473 -188
- package/dist/claude/pty-spawn-config.js +79 -32
- package/dist/claude/pty-watch.js +201 -0
- package/dist/claude/request-queue.js +7 -35
- package/dist/claude/rewind.js +111 -0
- package/dist/claude/scheduled-runner.js +1 -3
- package/dist/claude/scheduler.js +6 -2
- package/dist/claude/scope-guard.js +8 -3
- package/dist/claude/screen-marks.js +83 -0
- package/dist/claude/screen-render.js +96 -0
- package/dist/claude/session-history.js +4 -2
- package/dist/claude/session-jsonl.js +162 -15
- package/dist/claude/session-manager.js +29 -8
- package/dist/claude/session-move.js +70 -0
- package/dist/claude/shell-mode-gate.js +60 -0
- package/dist/claude/side-question.js +20 -17
- package/dist/claude/stage-images.js +5 -5
- package/dist/claude/tasks-overlay-scraper.js +143 -20
- package/dist/claude/thread-judge-haiku.js +88 -0
- package/dist/claude/tip-scraper.js +3 -4
- package/dist/claude/tui-modal.js +272 -27
- package/dist/claude/tui-state.js +74 -2
- package/dist/claude/turn-end.js +15 -1
- package/dist/claude/turn-prose.js +1 -1
- package/dist/claude/typed-answer.js +104 -0
- package/dist/claude/update-banner-relay.js +1 -1
- package/dist/cli/commands/doctor.js +48 -15
- package/dist/cli/commands/help.js +11 -2
- package/dist/cli/commands/init.js +16 -13
- package/dist/cli/commands/service.js +40 -8
- package/dist/cli/commands/start.js +10 -0
- package/dist/cli/commands/watch.js +322 -0
- package/dist/cli/dispatch.js +5 -0
- package/dist/cli/init/env-file.js +1 -1
- package/dist/cli/init/flow.js +114 -47
- package/dist/cli/init/prompter.js +8 -0
- package/dist/cli/init/telegram.js +35 -9
- package/dist/cli/service/render.js +3 -3
- package/dist/config.js +156 -131
- package/dist/index.js +107 -31
- package/dist/launcher.js +34 -7
- package/dist/providers/ccr-introspect.js +1 -8
- package/dist/providers/ccr-provider.js +19 -20
- package/dist/providers/claude-provider.js +4 -57
- package/dist/providers/prefs-sync.js +16 -59
- package/dist/providers/provider-router.js +24 -23
- package/dist/providers/spawn-settings.js +45 -0
- package/dist/providers/user-preferences.js +127 -19
- package/dist/restart-when-idle.js +27 -7
- package/dist/startup/auto-continue.js +2 -2
- package/dist/startup/auto-resume.js +3 -15
- package/dist/startup/notices.js +1 -1
- package/dist/startup/verify-token.js +4 -4
- package/dist/telegram/action-logger.js +3 -165
- package/dist/telegram/background-activity-card.js +1 -1
- package/dist/telegram/botname-settings.js +71 -125
- package/dist/telegram/client-options.js +6 -7
- package/dist/telegram/force-reply-tracker.js +55 -16
- package/dist/telegram/message-sender.js +92 -360
- package/dist/telegram/prompt-label.js +11 -5
- package/dist/telegram/streaming-turn.js +5 -7
- package/dist/telegram/table-lists.js +56 -0
- package/dist/telegram/task-list.js +4 -4
- package/dist/telegram/task-tracker.js +45 -126
- package/dist/telegram/terminal-renderer.js +1 -5
- package/dist/telegram/thread-titles.js +74 -2
- package/dist/telegram/threads-setup.js +1 -1
- package/dist/utils/admins.js +2 -2
- package/dist/utils/bot-icon.js +248 -0
- package/dist/utils/bot-token.js +8 -5
- package/dist/utils/build-info.js +3 -3
- package/dist/utils/caffeinate.js +6 -3
- package/dist/utils/claude-env.js +0 -1
- package/dist/utils/claude-version.js +2 -2
- package/dist/utils/config-home.js +3 -3
- package/dist/utils/download.js +41 -15
- package/dist/utils/exit-codes.js +11 -0
- package/dist/utils/format.js +3 -6
- package/dist/utils/home-project.js +1 -1
- package/dist/utils/idle-restart.js +1 -1
- package/dist/utils/install-mode.js +1 -1
- package/dist/utils/instance-config.js +1 -1
- package/dist/utils/instances.js +1 -1
- package/dist/utils/keyed-settings.js +2 -2
- package/dist/utils/memory-pressure.js +60 -0
- package/dist/utils/npm-version.js +2 -2
- package/dist/utils/resolve-claude-bin.js +13 -24
- package/dist/utils/respawn-backoff.js +9 -0
- package/dist/utils/stale-launcher.js +1 -1
- package/dist/utils/systemd.js +8 -8
- package/dist/utils/telegram-proxy.js +72 -0
- package/dist/utils/uploads-dir.js +27 -0
- package/dist/utils/verbosity.js +8 -8
- package/dist/utils/version-check.js +5 -5
- package/package.json +3 -4
- package/dist/bot/handlers/command/media.js +0 -197
- package/dist/bot/handlers/command/streaming-mode.js +0 -16
- package/dist/bot/handlers/message/throttle.js +0 -49
- package/dist/claude/agent-watchdog.js +0 -162
- package/dist/claude/agent.js +0 -1458
- package/dist/claude/held-query.js +0 -190
- package/dist/claude/mcp-tools.js +0 -354
- package/dist/claude/sdk-permission-gate.js +0 -77
- package/dist/claude/session-cost.js +0 -41
- package/dist/claude/system-prompt.js +0 -162
- package/dist/providers/sdk-provider.js +0 -37
- package/dist/telegram/telegraph-settings.js +0 -31
- package/dist/telegram/telegraph.js +0 -453
- package/dist/telegram/terminal-settings.js +0 -25
- package/dist/tts/tts-settings.js +0 -62
- package/dist/tts/tts.js +0 -245
- package/dist/tts/voice-reply.js +0 -78
- package/dist/utils/debug-agent.js +0 -117
- package/dist/utils/debug-watchdog.js +0 -121
- package/dist/utils/project-data-dir.js +0 -33
- package/dist/utils/reasoning-summary.js +0 -12
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* /
|
|
2
|
+
* /dir and the inline project browser.
|
|
3
3
|
*
|
|
4
4
|
* Owns the paginated directory-browser state, the favorites screen, and the
|
|
5
5
|
* switching logic that rewires a session to a new working directory.
|
|
6
6
|
*/
|
|
7
7
|
import * as fs from 'fs';
|
|
8
8
|
import * as path from 'path';
|
|
9
|
-
import { config } from '../../../config.js';
|
|
10
9
|
import { sessionManager } from '../../../claude/session-manager.js';
|
|
11
10
|
import { clearConversation } from '../../../providers/provider-router.js';
|
|
11
|
+
import { prewarmClaude } from '../../../claude/prewarm.js';
|
|
12
12
|
import { projectFavorites } from '../../../providers/project-favorites.js';
|
|
13
13
|
import { EntityText } from '../../../telegram/entities.js';
|
|
14
14
|
import { replyFormatted, editCallbackMessage } from '../../../telegram/send.js';
|
|
15
15
|
import { getWorkspaceRoot, isPathWithinRoot } from '../../../utils/workspace-guard.js';
|
|
16
16
|
import { getSessionKeyFromCtx } from '../../../utils/session-key.js';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
17
|
+
import { sendForceReplyPrompt } from '../../../telegram/force-reply-tracker.js';
|
|
18
|
+
import { parseCallback, projectStatusSuffix, resumeCommandMessage, withBackToPrevious, } from './shared.js';
|
|
19
|
+
import { clearTopic } from './topic.js';
|
|
19
20
|
const PROJECT_BROWSER_PAGE_SIZE = 8;
|
|
20
21
|
const projectBrowserState = new Map();
|
|
21
22
|
const PROJECT_BROWSER_TTL_MS = 30 * 60 * 1000; // 30 minutes
|
|
@@ -36,7 +37,7 @@ projectBrowserCleanup.unref();
|
|
|
36
37
|
async function selectProjectFromCallback(ctx, sessionKey, projectPath) {
|
|
37
38
|
sessionManager.setWorkingDirectory(sessionKey, projectPath);
|
|
38
39
|
clearConversation(sessionKey);
|
|
39
|
-
|
|
40
|
+
clearTopic(sessionKey);
|
|
40
41
|
const state = getProjectState(sessionKey);
|
|
41
42
|
state.current = projectPath;
|
|
42
43
|
state.page = 0;
|
|
@@ -47,6 +48,7 @@ async function selectProjectFromCallback(ctx, sessionKey, projectPath) {
|
|
|
47
48
|
if (s?.claudeSessionId) {
|
|
48
49
|
await replyFormatted(ctx, resumeCommandMessage(s.claudeSessionId));
|
|
49
50
|
}
|
|
51
|
+
void prewarmClaude(ctx, sessionKey);
|
|
50
52
|
}
|
|
51
53
|
/** "<lead><name>", the chat-now line and the project status block. */
|
|
52
54
|
function projectOpenedMessage(lead, name, sessionKey) {
|
|
@@ -56,8 +58,8 @@ function projectOpenedMessage(lead, name, sessionKey) {
|
|
|
56
58
|
.append(projectStatusSuffix(sessionKey))
|
|
57
59
|
.build();
|
|
58
60
|
}
|
|
59
|
-
export async function
|
|
60
|
-
const cb = parseCallback(ctx, '
|
|
61
|
+
export async function handleDirCallback(ctx) {
|
|
62
|
+
const cb = parseCallback(ctx, 'dir:');
|
|
61
63
|
if (!cb)
|
|
62
64
|
return;
|
|
63
65
|
const { sessionKey, data } = cb;
|
|
@@ -249,42 +251,42 @@ function buildProjectBrowserKeyboard(state, entries, totalPages, sessionKey) {
|
|
|
249
251
|
const second = entries[i + 1];
|
|
250
252
|
if (first) {
|
|
251
253
|
const index = pageOffset + i;
|
|
252
|
-
row.push({ text: `📁 ${shortenName(first)}`, callback_data: `
|
|
254
|
+
row.push({ text: `📁 ${shortenName(first)}`, callback_data: `dir:open:${index}` });
|
|
253
255
|
}
|
|
254
256
|
if (second) {
|
|
255
257
|
const index = pageOffset + i + 1;
|
|
256
|
-
row.push({ text: `📁 ${shortenName(second)}`, callback_data: `
|
|
258
|
+
row.push({ text: `📁 ${shortenName(second)}`, callback_data: `dir:open:${index}` });
|
|
257
259
|
}
|
|
258
260
|
if (row.length > 0)
|
|
259
261
|
rows.push(row);
|
|
260
262
|
}
|
|
261
263
|
const navRow = [];
|
|
262
264
|
if (state.current !== state.root) {
|
|
263
|
-
navRow.push({ text: '⬆️ Up', callback_data: '
|
|
265
|
+
navRow.push({ text: '⬆️ Up', callback_data: 'dir:up' });
|
|
264
266
|
}
|
|
265
|
-
navRow.push({ text: '✅ Use this folder', callback_data: '
|
|
267
|
+
navRow.push({ text: '✅ Use this folder', callback_data: 'dir:use' });
|
|
266
268
|
const isFav = projectFavorites.has(sessionKey, state.current);
|
|
267
269
|
navRow.push({
|
|
268
270
|
text: isFav ? '★ Unfavorite' : '⭐ Favorite',
|
|
269
|
-
callback_data: isFav ? '
|
|
271
|
+
callback_data: isFav ? 'dir:fav-del-here' : 'dir:fav-add-here',
|
|
270
272
|
});
|
|
271
273
|
rows.push(navRow);
|
|
272
274
|
const utilRow = [
|
|
273
|
-
{ text: '⭐ Favorites', callback_data: '
|
|
274
|
-
{ text: '✍️ Enter path', callback_data: '
|
|
275
|
+
{ text: '⭐ Favorites', callback_data: 'dir:favorites' },
|
|
276
|
+
{ text: '✍️ Enter path', callback_data: 'dir:manual' },
|
|
275
277
|
];
|
|
276
278
|
rows.push(utilRow);
|
|
277
279
|
const pageRow = [];
|
|
278
280
|
if (state.page > 0) {
|
|
279
|
-
pageRow.push({ text: '◀️ Prev', callback_data: '
|
|
281
|
+
pageRow.push({ text: '◀️ Prev', callback_data: 'dir:page:prev' });
|
|
280
282
|
}
|
|
281
283
|
if (state.page < totalPages - 1) {
|
|
282
|
-
pageRow.push({ text: 'Next ▶️', callback_data: '
|
|
284
|
+
pageRow.push({ text: 'Next ▶️', callback_data: 'dir:page:next' });
|
|
283
285
|
}
|
|
284
286
|
if (pageRow.length > 0) {
|
|
285
287
|
rows.push(pageRow);
|
|
286
288
|
}
|
|
287
|
-
rows.push([{ text: '🔄 Refresh', callback_data: '
|
|
289
|
+
rows.push([{ text: '🔄 Refresh', callback_data: 'dir:refresh' }]);
|
|
288
290
|
return { inline_keyboard: rows };
|
|
289
291
|
}
|
|
290
292
|
async function sendProjectBrowser(ctx, sessionKey, state, edit) {
|
|
@@ -324,16 +326,16 @@ function buildFavoritesScreen(sessionKey) {
|
|
|
324
326
|
const fav = favorites[i];
|
|
325
327
|
const name = path.basename(fav.path) || fav.path;
|
|
326
328
|
rows.push([
|
|
327
|
-
{ text: `📁 ${shortenName(name, 28)}`, callback_data: `
|
|
328
|
-
{ text: '🗑️', callback_data: `
|
|
329
|
+
{ text: `📁 ${shortenName(name, 28)}`, callback_data: `dir:fav-use:${i}` },
|
|
330
|
+
{ text: '🗑️', callback_data: `dir:fav-del:${i}` },
|
|
329
331
|
]);
|
|
330
332
|
}
|
|
331
333
|
const actionRow = [];
|
|
332
334
|
if (currentPath && !currentIsFav) {
|
|
333
|
-
actionRow.push({ text: '⭐ Add current', callback_data: '
|
|
335
|
+
actionRow.push({ text: '⭐ Add current', callback_data: 'dir:fav-add-current' });
|
|
334
336
|
}
|
|
335
|
-
actionRow.push({ text: '🗂️ Browse', callback_data: '
|
|
336
|
-
actionRow.push({ text: '✍️ Enter path', callback_data: '
|
|
337
|
+
actionRow.push({ text: '🗂️ Browse', callback_data: 'dir:browse' });
|
|
338
|
+
actionRow.push({ text: '✍️ Enter path', callback_data: 'dir:manual' });
|
|
337
339
|
rows.push(actionRow);
|
|
338
340
|
return { text: text.build(), reply_markup: { inline_keyboard: rows } };
|
|
339
341
|
}
|
|
@@ -361,13 +363,7 @@ async function sendProjectManualPrompt(ctx) {
|
|
|
361
363
|
prompt.add('\n\n').italic(`Current: ${path.basename(session.workingDirectory)}`);
|
|
362
364
|
}
|
|
363
365
|
prompt.add('\n\n👇 ').italic('Enter the path below:');
|
|
364
|
-
await
|
|
365
|
-
reply_markup: {
|
|
366
|
-
force_reply: true,
|
|
367
|
-
input_field_placeholder: '/home/user/projects/myapp',
|
|
368
|
-
selective: true,
|
|
369
|
-
},
|
|
370
|
-
});
|
|
366
|
+
await sendForceReplyPrompt(ctx, 'dir', prompt.build(), '/home/user/projects/myapp');
|
|
371
367
|
}
|
|
372
368
|
function getProjectState(sessionKey) {
|
|
373
369
|
const root = getProjectRoot();
|
|
@@ -409,7 +405,7 @@ function syncProjectStateToSession(sessionKey) {
|
|
|
409
405
|
state.page = 0;
|
|
410
406
|
}
|
|
411
407
|
}
|
|
412
|
-
export async function
|
|
408
|
+
export async function handleDir(ctx) {
|
|
413
409
|
const keyInfo = getSessionKeyFromCtx(ctx);
|
|
414
410
|
if (!keyInfo)
|
|
415
411
|
return;
|
|
@@ -437,8 +433,9 @@ export async function handleProject(ctx) {
|
|
|
437
433
|
}
|
|
438
434
|
if (!fs.existsSync(projectPath)) {
|
|
439
435
|
await replyFormatted(ctx, new EntityText()
|
|
440
|
-
.add(`📁
|
|
441
|
-
.code(
|
|
436
|
+
.add(`📁 There's no project at `).code(projectPath).add('.\n\nAsk Claude to create it from the project you\'re in, or run ')
|
|
437
|
+
.code(`mkdir ${projectPath}`)
|
|
438
|
+
.add(' and open it with ').code(`/dir ${args}`).add('.')
|
|
442
439
|
.build());
|
|
443
440
|
return;
|
|
444
441
|
}
|
|
@@ -448,7 +445,7 @@ export async function handleProject(ctx) {
|
|
|
448
445
|
}
|
|
449
446
|
sessionManager.setWorkingDirectory(sessionKey, projectPath);
|
|
450
447
|
clearConversation(sessionKey);
|
|
451
|
-
|
|
448
|
+
clearTopic(sessionKey);
|
|
452
449
|
const newConv = sessionManager.getSession(sessionKey)?.conversationId;
|
|
453
450
|
const back = withBackToPrevious(projectOpenedMessage('✅ Project: ', args, sessionKey), sessionKey, newConv);
|
|
454
451
|
await replyFormatted(ctx, back.text, back.options);
|
|
@@ -456,81 +453,6 @@ export async function handleProject(ctx) {
|
|
|
456
453
|
if (s?.claudeSessionId) {
|
|
457
454
|
await replyFormatted(ctx, resumeCommandMessage(s.claudeSessionId));
|
|
458
455
|
}
|
|
459
|
-
|
|
460
|
-
export async function handleNewProject(ctx) {
|
|
461
|
-
const keyInfo = getSessionKeyFromCtx(ctx);
|
|
462
|
-
if (!keyInfo)
|
|
463
|
-
return;
|
|
464
|
-
const { sessionKey } = keyInfo;
|
|
465
|
-
const text = ctx.message?.text || '';
|
|
466
|
-
const args = text.split(' ').slice(1).join(' ').trim();
|
|
467
|
-
if (!args) {
|
|
468
|
-
await replyMd(ctx, 'Usage: `/newproject <name>`');
|
|
469
|
-
return;
|
|
470
|
-
}
|
|
471
|
-
if (!/^[a-zA-Z0-9_-]+$/.test(args)) {
|
|
472
|
-
await replyMd(ctx, '❌ Project name can only contain letters, numbers, dashes and underscores.');
|
|
473
|
-
return;
|
|
474
|
-
}
|
|
475
|
-
const projectPath = path.join(config.WORKSPACE_DIR, args);
|
|
476
|
-
if (fs.existsSync(projectPath)) {
|
|
477
|
-
await replyFormatted(ctx, new EntityText()
|
|
478
|
-
.add(`❌ Project "${args}" already exists. Use `)
|
|
479
|
-
.code(`/project ${args}`)
|
|
480
|
-
.add(' to open it.')
|
|
481
|
-
.build());
|
|
482
|
-
return;
|
|
483
|
-
}
|
|
484
|
-
fs.mkdirSync(projectPath, { recursive: true, mode: 0o700 });
|
|
485
|
-
sessionManager.setWorkingDirectory(sessionKey, projectPath);
|
|
486
|
-
clearConversation(sessionKey);
|
|
487
|
-
await clearTopicAndRefreshBotName(ctx, sessionKey);
|
|
488
|
-
const newConv = sessionManager.getSession(sessionKey)?.conversationId;
|
|
489
|
-
const back = withBackToPrevious(projectOpenedMessage('✅ Created and opened: ', args, sessionKey), sessionKey, newConv);
|
|
490
|
-
await replyFormatted(ctx, back.text, back.options);
|
|
491
|
-
const s = sessionManager.getSession(sessionKey);
|
|
492
|
-
if (s?.claudeSessionId) {
|
|
493
|
-
await replyFormatted(ctx, resumeCommandMessage(s.claudeSessionId));
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
export function listProjectFiles(projectPath, maxDepth = 2) {
|
|
497
|
-
const files = [];
|
|
498
|
-
function walk(dir, depth, prefix = '') {
|
|
499
|
-
if (depth > maxDepth)
|
|
500
|
-
return;
|
|
501
|
-
try {
|
|
502
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
503
|
-
for (const entry of entries) {
|
|
504
|
-
if (entry.name.startsWith('.') || entry.name === 'node_modules')
|
|
505
|
-
continue;
|
|
506
|
-
const relativePath = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
507
|
-
if (entry.isFile()) {
|
|
508
|
-
files.push(relativePath);
|
|
509
|
-
}
|
|
510
|
-
else if (entry.isDirectory() && depth < maxDepth) {
|
|
511
|
-
walk(path.join(dir, entry.name), depth + 1, relativePath);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
catch {
|
|
516
|
-
// Ignore permission errors
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
walk(projectPath, 0);
|
|
520
|
-
// Sort by common file types first (README, package.json, src files)
|
|
521
|
-
return files.sort((a, b) => {
|
|
522
|
-
const priority = (f) => {
|
|
523
|
-
if (f === 'README.md')
|
|
524
|
-
return 0;
|
|
525
|
-
if (f === 'package.json')
|
|
526
|
-
return 1;
|
|
527
|
-
if (f.startsWith('src/'))
|
|
528
|
-
return 2;
|
|
529
|
-
if (f.endsWith('.md'))
|
|
530
|
-
return 3;
|
|
531
|
-
return 4;
|
|
532
|
-
};
|
|
533
|
-
return priority(a) - priority(b);
|
|
534
|
-
});
|
|
456
|
+
void prewarmClaude(ctx, sessionKey);
|
|
535
457
|
}
|
|
536
458
|
//# sourceMappingURL=project.js.map
|
|
@@ -24,6 +24,7 @@ import { findSession, isSessionId, isSessionOpenElsewhere, listSessions, matches
|
|
|
24
24
|
import { setPendingCarryOver } from '../../../claude/carry-over.js';
|
|
25
25
|
import { isProcessing } from '../../../claude/request-queue.js';
|
|
26
26
|
import { clearConversation, getActiveProviderName } from '../../../providers/provider-router.js';
|
|
27
|
+
import { prewarmClaude } from '../../../claude/prewarm.js';
|
|
27
28
|
import { buildCarryOverPreamble } from '../../../providers/provider-switch.js';
|
|
28
29
|
import { EntityText } from '../../../telegram/entities.js';
|
|
29
30
|
import { buildLetteredKeyboard, letteredOptionLines } from '../../../telegram/lettered-options.js';
|
|
@@ -32,7 +33,7 @@ import { editCallbackMessage, replyFormatted } from '../../../telegram/send.js';
|
|
|
32
33
|
import { taskListDisplay } from '../../../telegram/task-list.js';
|
|
33
34
|
import { getSessionKeyFromCtx } from '../../../utils/session-key.js';
|
|
34
35
|
import { formatTimeAgo, parseCallback, projectStatusSuffix, replyMd, resumeCommandMessage } from './shared.js';
|
|
35
|
-
import {
|
|
36
|
+
import { restoreTopic } from './topic.js';
|
|
36
37
|
import { sendView } from '../view.js';
|
|
37
38
|
import { resumeHistoryEntry, sendRecapHint } from './session.js';
|
|
38
39
|
/** Sessions per page: letters A–H, short enough to read on a phone. */
|
|
@@ -130,7 +131,7 @@ export async function handleResume(ctx) {
|
|
|
130
131
|
if (!arg) {
|
|
131
132
|
const view = listView(sessionKey, session ? 'p' : 'a', 0) ?? (session ? listView(sessionKey, 'a', 0) : undefined);
|
|
132
133
|
if (!view) {
|
|
133
|
-
await replyMd(ctx, 'ℹ️ No conversations to resume yet.\n\nUse `/
|
|
134
|
+
await replyMd(ctx, 'ℹ️ No conversations to resume yet.\n\nUse `/dir <name>` to start one.');
|
|
134
135
|
return;
|
|
135
136
|
}
|
|
136
137
|
await sendView(ctx, view, 'reply');
|
|
@@ -295,9 +296,9 @@ async function resumeScanned(ctx, sessionKey, s) {
|
|
|
295
296
|
carriedOver = true;
|
|
296
297
|
notes.push(`This conversation ran on ${BACKEND_NAMES[owner] ?? owner} and this chat is on ${BACKEND_NAMES[provider] ?? provider}, ` +
|
|
297
298
|
`which can't replay its thinking. It goes on as a new session that starts with a recap of the last exchanges. ` +
|
|
298
|
-
`To continue it as it is, switch with /
|
|
299
|
+
`To continue it as it is, switch backends with /ccr and resume it again.`);
|
|
299
300
|
}
|
|
300
|
-
|
|
301
|
+
restoreTopic(sessionKey, topic);
|
|
301
302
|
const message = new EntityText()
|
|
302
303
|
.add('✅ Resumed ').bold(topic ?? sessionId)
|
|
303
304
|
.add('\n\nWorking directory: ').code(s.projectPath)
|
|
@@ -312,6 +313,9 @@ async function resumeScanned(ctx, sessionKey, s) {
|
|
|
312
313
|
else {
|
|
313
314
|
await replyFormatted(ctx, text);
|
|
314
315
|
}
|
|
316
|
+
// Last of the state changes above is long done; the claude this starts is
|
|
317
|
+
// the one the first message would have.
|
|
318
|
+
void prewarmClaude(ctx, sessionKey);
|
|
315
319
|
if (carriedOver)
|
|
316
320
|
return;
|
|
317
321
|
await replyFormatted(ctx, resumeCommandMessage(sessionId));
|