@grinev/opencode-telegram-bot 0.21.1 → 0.22.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 +10 -15
- package/README.md +33 -13
- package/dist/app/{start-bot-app.js → bootstrap/start-bot-app.js} +16 -15
- package/dist/{bot/utils/assistant-run-footer.js → app/formatters/assistant-run-footer-formatter.js} +1 -1
- package/dist/{summary → app/formatters}/subagent-formatter.js +8 -3
- package/dist/{summary/formatter.js → app/formatters/summary-formatter.js} +20 -132
- package/dist/{summary → app/formatters}/tool-message-batcher.js +1 -1
- package/dist/{bot/assistant-run-state.js → app/managers/assistant-run-state-manager.js} +1 -1
- package/dist/{attach/manager.js → app/managers/attach-manager.js} +1 -1
- package/dist/{background-session/tracker.js → app/managers/background-session-manager.js} +2 -2
- package/dist/{scheduled-task/foreground-state.js → app/managers/foreground-session-state-manager.js} +1 -1
- package/dist/{interaction/manager.js → app/managers/interaction-manager.js} +31 -1
- package/dist/{permission/manager.js → app/managers/permission-manager.js} +1 -1
- package/dist/{question/manager.js → app/managers/question-manager.js} +1 -1
- package/dist/{rename/manager.js → app/managers/rename-manager.js} +1 -1
- package/dist/{scheduled-task/creation-manager.js → app/managers/scheduled-task-creation-manager.js} +2 -2
- package/dist/{summary/aggregator.js → app/managers/summary-aggregation-manager.js} +177 -13
- package/dist/{agent/manager.js → app/services/agent-selection-service.js} +4 -5
- package/dist/{attach/service.js → app/services/attach-service.js} +23 -44
- package/dist/{bot/utils/busy-reconciliation.js → app/services/busy-reconciliation-service.js} +12 -7
- package/dist/app/services/command-catalog-service.js +21 -0
- package/dist/{bot/utils/external-user-input.js → app/services/external-user-input-service.js} +4 -19
- package/dist/app/services/file-browser-service.js +265 -0
- package/dist/{bot/utils/file-download.js → app/services/file-download-service.js} +14 -28
- package/dist/app/services/mcp-catalog-service.js +79 -0
- package/dist/app/services/message-history-service.js +81 -0
- package/dist/{model/capabilities.js → app/services/model-capabilities-service.js} +2 -2
- package/dist/{model/context-limit.js → app/services/model-context-limit-service.js} +4 -4
- package/dist/{model/manager.js → app/services/model-selection-service.js} +4 -4
- package/dist/{project/manager.js → app/services/project-service.js} +3 -3
- package/dist/app/services/project-switch-service.js +39 -0
- package/dist/{bot/utils/busy-guard.js → app/services/run-control-service.js} +3 -14
- package/dist/{scheduled-task/executor.js → app/services/scheduled-task-executor-service.js} +27 -12
- package/dist/{scheduled-task/runtime.js → app/services/scheduled-task-runtime-service.js} +17 -56
- package/dist/{scheduled-task/schedule-parser.js → app/services/scheduled-task-schedule-parser-service.js} +3 -3
- package/dist/{scheduled-task/session-ignore.js → app/services/scheduled-task-session-ignore-service.js} +1 -1
- package/dist/{session/cache-manager.js → app/services/session-cache-service.js} +3 -3
- package/dist/{session/manager.js → app/services/session-service.js} +1 -1
- package/dist/app/services/skills-catalog-service.js +21 -0
- package/dist/{stt/client.js → app/services/stt-service.js} +2 -2
- package/dist/{tts/client.js → app/services/tts-service.js} +68 -5
- package/dist/{variant/manager.js → app/services/variant-selection-service.js} +3 -3
- package/dist/{scheduled-task/store.js → app/stores/scheduled-task-store.js} +3 -3
- package/dist/{settings/manager.js → app/stores/settings-store.js} +49 -7
- package/dist/app/types/worktree.js +1 -0
- package/dist/bot/{handlers/agent.js → callbacks/agent-selection-callback-handler.js} +8 -57
- package/dist/bot/callbacks/callback-router.js +113 -0
- package/dist/bot/{commands/commands.js → callbacks/command-catalog-callback-handler.js} +17 -197
- package/dist/bot/{handlers/context.js → callbacks/context-control-callback-handler.js} +3 -32
- package/dist/bot/callbacks/file-browser-callback-handler.js +219 -0
- package/dist/bot/callbacks/inline-menu-cancel-callback-handler.js +32 -0
- package/dist/bot/{commands/mcps.js → callbacks/mcp-catalog-callback-handler.js} +7 -172
- package/dist/bot/{commands/messages.js → callbacks/message-history-callback-handler.js} +17 -248
- package/dist/bot/{handlers/model.js → callbacks/model-selection-callback-handler.js} +10 -71
- package/dist/bot/callbacks/permission-callback-handler.js +114 -0
- package/dist/bot/callbacks/project-callback-handler.js +79 -0
- package/dist/bot/callbacks/question-callback-handler.js +159 -0
- package/dist/bot/{commands/rename.js → callbacks/rename-callback-handler.js} +6 -34
- package/dist/bot/{commands/tasklist.js → callbacks/scheduled-task-callback-handler.js} +83 -68
- package/dist/bot/{commands/sessions.js → callbacks/session-callback-handler.js} +19 -158
- package/dist/bot/callbacks/settings-callback-handler.js +105 -0
- package/dist/bot/{commands/skills.js → callbacks/skills-catalog-callback-handler.js} +8 -188
- package/dist/bot/{handlers/variant.js → callbacks/variant-selection-callback-handler.js} +7 -69
- package/dist/bot/callbacks/worktree-callback-handler.js +97 -0
- package/dist/bot/commands/{abort.js → abort-command.js} +6 -6
- package/dist/bot/commands/command-catalog-command.js +42 -0
- package/dist/bot/commands/definitions.js +1 -1
- package/dist/bot/commands/{detach.js → detach-command.js} +8 -8
- package/dist/bot/commands/ls-command.js +48 -0
- package/dist/bot/commands/mcp-catalog-command.js +39 -0
- package/dist/bot/commands/messages-command.js +59 -0
- package/dist/bot/commands/{new.js → new-command.js} +12 -11
- package/dist/bot/commands/open-command.js +45 -0
- package/dist/bot/commands/{opencode-start.js → opencode-start-command.js} +1 -1
- package/dist/bot/commands/{opencode-stop.js → opencode-stop-command.js} +1 -1
- package/dist/bot/commands/projects-command.js +32 -0
- package/dist/bot/commands/rename-command.js +33 -0
- package/dist/bot/commands/sessions-command.js +42 -0
- package/dist/bot/commands/settings-command.js +10 -0
- package/dist/bot/commands/skills-catalog-command.js +42 -0
- package/dist/bot/commands/{start.js → start-command.js} +12 -12
- package/dist/bot/commands/{status.js → status-command.js} +15 -10
- package/dist/bot/commands/{task.js → task-command.js} +9 -81
- package/dist/bot/commands/tasklist-command.js +40 -0
- package/dist/bot/commands/worktree-command.js +47 -0
- package/dist/bot/handlers/{document.js → document-handler.js} +3 -3
- package/dist/bot/handlers/{media-group.js → media-group-handler.js} +3 -3
- package/dist/bot/handlers/photo-handler.js +44 -0
- package/dist/bot/handlers/prompt.js +17 -17
- package/dist/bot/handlers/text-message-handler.js +61 -0
- package/dist/bot/handlers/tts-response-handler.js +29 -0
- package/dist/bot/handlers/{voice.js → voice-handler.js} +6 -3
- package/dist/bot/index.js +27 -1179
- package/dist/{keyboard/manager.js → bot/keyboards/keyboard-manager.js} +6 -6
- package/dist/bot/keyboards/keyboard-types.js +1 -0
- package/dist/bot/{utils/keyboard.js → keyboards/main-reply-keyboard.js} +2 -2
- package/dist/bot/menus/agent-selection-menu.js +54 -0
- package/dist/bot/menus/command-catalog-menu.js +101 -0
- package/dist/bot/menus/context-control-menu.js +33 -0
- package/dist/bot/menus/file-browser-menu.js +265 -0
- package/dist/bot/{handlers → menus}/inline-menu.js +7 -34
- package/dist/bot/menus/mcp-catalog-menu.js +97 -0
- package/dist/bot/menus/message-history-menu.js +107 -0
- package/dist/bot/menus/model-selection-menu.js +66 -0
- package/dist/bot/menus/permission-menu.js +116 -0
- package/dist/bot/{commands/projects.js → menus/project-selection-menu.js} +5 -105
- package/dist/bot/{handlers/question.js → menus/question-menu.js} +10 -166
- package/dist/bot/menus/rename-menu.js +6 -0
- package/dist/bot/menus/scheduled-task-menu.js +42 -0
- package/dist/bot/menus/session-selection-menu.js +115 -0
- package/dist/bot/menus/settings-menu.js +52 -0
- package/dist/bot/menus/skills-catalog-menu.js +99 -0
- package/dist/bot/menus/variant-selection-menu.js +67 -0
- package/dist/bot/menus/worktree-selection-menu.js +76 -0
- package/dist/bot/{utils → messages}/assistant-rendering.js +2 -2
- package/dist/bot/messages/busy-blocked-renderer.js +11 -0
- package/dist/bot/messages/external-user-input-notification.js +22 -0
- package/dist/bot/messages/scheduled-task-delivery.js +63 -0
- package/dist/bot/{utils → messages}/send-downloaded-file.js +1 -1
- package/dist/bot/messages/summary-message-formatter.js +130 -0
- package/dist/bot/{utils → messages}/thinking-message.js +1 -4
- package/dist/bot/messages/thinking-rendering.js +66 -0
- package/dist/{interaction/guard.js → bot/middleware/interaction-guard-decision.js} +11 -4
- package/dist/bot/middleware/interaction-guard.js +2 -2
- package/dist/bot/middleware/unknown-command.js +1 -1
- package/dist/{pinned/format.js → bot/pinned/pinned-message-format.js} +1 -2
- package/dist/{pinned/manager.js → bot/pinned/pinned-message-manager.js} +10 -10
- package/dist/bot/pinned/pinned-message-types.js +1 -0
- package/dist/{summary → bot/render}/markdown-to-telegram-v2.js +2 -2
- package/dist/bot/render/types.js +1 -0
- package/dist/bot/routers/command-router.js +73 -0
- package/dist/bot/routers/message-router.js +150 -0
- package/dist/bot/services/attach-presentation.js +40 -0
- package/dist/bot/services/event-subscription-service.js +1116 -0
- package/dist/bot/services/project-switch-presentation.js +26 -0
- package/dist/bot/streaming/compact-progress-streamer.js +162 -0
- package/dist/bot/{utils → streaming}/finalize-assistant-response.js +9 -3
- package/dist/bot/streaming/response-streamer.js +16 -1
- package/dist/cli.js +4 -4
- package/dist/config.js +9 -18
- package/dist/i18n/ar.js +31 -6
- package/dist/i18n/de.js +32 -7
- package/dist/i18n/en.js +32 -7
- package/dist/i18n/es.js +32 -7
- package/dist/i18n/fr.js +32 -7
- package/dist/i18n/ru.js +32 -7
- package/dist/i18n/zh.js +32 -7
- package/dist/index.js +1 -1
- package/dist/opencode/ready-refresh.js +2 -2
- package/dist/{service → runtime/service}/manager.js +2 -2
- package/dist/runtime/service/types.js +1 -0
- package/package.json +1 -1
- package/dist/bot/commands/ls.js +0 -445
- package/dist/bot/commands/open.js +0 -319
- package/dist/bot/commands/tts.js +0 -13
- package/dist/bot/commands/worktree.js +0 -201
- package/dist/bot/handlers/permission.js +0 -235
- package/dist/bot/utils/browser-roots.js +0 -140
- package/dist/bot/utils/file-tree.js +0 -92
- package/dist/bot/utils/send-tts-response.js +0 -37
- package/dist/bot/utils/switch-project.js +0 -45
- package/dist/bot/utils/telegram-file-url.js +0 -11
- package/dist/interaction/busy.js +0 -8
- package/dist/interaction/cleanup.js +0 -32
- /package/dist/{scheduled-task/display.js → app/formatters/scheduled-task-display-formatter.js} +0 -0
- /package/dist/{bot/utils/abort-error-suppression.js → app/managers/abort-suppression-manager.js} +0 -0
- /package/dist/{external-input/suppression.js → app/managers/external-input-suppression-manager.js} +0 -0
- /package/dist/{scheduled-task/next-run.js → app/services/scheduled-task-next-run-service.js} +0 -0
- /package/dist/{git/worktree.js → app/services/worktree-service.js} +0 -0
- /package/dist/{agent/types.js → app/types/agent.js} +0 -0
- /package/dist/{interaction/types.js → app/types/interaction.js} +0 -0
- /package/dist/{model/types.js → app/types/model.js} +0 -0
- /package/dist/{keyboard/types.js → app/types/permission.js} +0 -0
- /package/dist/{permission/types.js → app/types/project.js} +0 -0
- /package/dist/{pinned/types.js → app/types/question.js} +0 -0
- /package/dist/{scheduled-task/types.js → app/types/scheduled-task.js} +0 -0
- /package/dist/{question/types.js → app/types/session.js} +0 -0
- /package/dist/{service/types.js → app/types/settings.js} +0 -0
- /package/dist/{telegram/render/types.js → app/types/summary.js} +0 -0
- /package/dist/{variant/types.js → app/types/variant.js} +0 -0
- /package/dist/bot/commands/{help.js → help-command.js} +0 -0
- /package/dist/bot/{utils → messages}/send-with-markdown-fallback.js +0 -0
- /package/dist/bot/{utils → messages}/telegram-text.js +0 -0
- /package/dist/{telegram → bot}/render/block-fallback.js +0 -0
- /package/dist/{telegram → bot}/render/block-parser.js +0 -0
- /package/dist/{telegram → bot}/render/block-renderer.js +0 -0
- /package/dist/{telegram → bot}/render/chunker.js +0 -0
- /package/dist/{telegram → bot}/render/inline-renderer.js +0 -0
- /package/dist/{telegram → bot}/render/markdown-normalizer.js +0 -0
- /package/dist/{telegram → bot}/render/pipeline.js +0 -0
- /package/dist/{telegram → bot}/render/validator.js +0 -0
- /package/dist/bot/{utils/commands.js → routers/command-utils.js} +0 -0
- /package/dist/{service/runtime.js → runtime/service/env.js} +0 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { clearAllInteractionState } from "../../app/managers/interaction-manager.js";
|
|
2
|
+
import { getProjectByWorktree } from "../../app/services/project-service.js";
|
|
3
|
+
import { isForegroundBusy } from "../../app/services/run-control-service.js";
|
|
4
|
+
import { switchToProject } from "../../app/services/project-switch-service.js";
|
|
5
|
+
import { getGitWorktreeContext } from "../../app/services/worktree-service.js";
|
|
6
|
+
import { upsertSessionDirectory } from "../../app/services/session-cache-service.js";
|
|
7
|
+
import { getCurrentProject } from "../../app/stores/settings-store.js";
|
|
8
|
+
import { t } from "../../i18n/index.js";
|
|
9
|
+
import { logger } from "../../utils/logger.js";
|
|
10
|
+
import { appendInlineMenuCancelButton, ensureActiveInlineMenu } from "../menus/inline-menu.js";
|
|
11
|
+
import { buildWorktreeMenuView, parseWorktreeIndexCallback, parseWorktreePageCallback, WORKTREE_CALLBACK_PREFIX, } from "../menus/worktree-selection-menu.js";
|
|
12
|
+
import { replyBusyBlocked } from "../messages/busy-blocked-renderer.js";
|
|
13
|
+
import { createProjectSwitchPresentation } from "../services/project-switch-presentation.js";
|
|
14
|
+
async function loadCurrentWorktreeContext() {
|
|
15
|
+
const currentProject = getCurrentProject();
|
|
16
|
+
if (!currentProject) {
|
|
17
|
+
return { currentProject: null, context: null };
|
|
18
|
+
}
|
|
19
|
+
const context = await getGitWorktreeContext(currentProject.worktree);
|
|
20
|
+
return { currentProject, context };
|
|
21
|
+
}
|
|
22
|
+
export async function handleWorktreeCallback(ctx, deps = {}) {
|
|
23
|
+
const callbackQuery = ctx.callbackQuery;
|
|
24
|
+
if (!callbackQuery?.data || !callbackQuery.data.startsWith(WORKTREE_CALLBACK_PREFIX)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
if (isForegroundBusy()) {
|
|
28
|
+
await replyBusyBlocked(ctx);
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
const page = parseWorktreePageCallback(callbackQuery.data);
|
|
32
|
+
const index = parseWorktreeIndexCallback(callbackQuery.data);
|
|
33
|
+
const isActiveMenu = await ensureActiveInlineMenu(ctx, "worktree");
|
|
34
|
+
if (!isActiveMenu) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
const { currentProject, context } = await loadCurrentWorktreeContext();
|
|
39
|
+
if (!currentProject) {
|
|
40
|
+
clearAllInteractionState("worktree_project_missing");
|
|
41
|
+
await ctx.answerCallbackQuery();
|
|
42
|
+
await ctx.reply(t("worktree.project_not_selected"));
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
if (!context) {
|
|
46
|
+
clearAllInteractionState("worktree_git_context_missing");
|
|
47
|
+
await ctx.answerCallbackQuery({ text: t("worktree.not_git_repo_callback") });
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
if (page !== null) {
|
|
51
|
+
if (context.worktrees.length === 0) {
|
|
52
|
+
await ctx.answerCallbackQuery({ text: t("worktree.page_empty_callback") });
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
const { text, keyboard } = buildWorktreeMenuView(context.worktrees, page);
|
|
56
|
+
await ctx.answerCallbackQuery();
|
|
57
|
+
await ctx.editMessageText(text, {
|
|
58
|
+
reply_markup: appendInlineMenuCancelButton(keyboard, "worktree"),
|
|
59
|
+
});
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
if (index === null) {
|
|
63
|
+
await ctx.answerCallbackQuery({ text: t("callback.processing_error") });
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
const selectedWorktree = context.worktrees[index];
|
|
67
|
+
if (!selectedWorktree) {
|
|
68
|
+
await ctx.answerCallbackQuery({ text: t("worktree.selection_missing_callback") });
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
if (selectedWorktree.isCurrent) {
|
|
72
|
+
await ctx.answerCallbackQuery({ text: t("worktree.already_selected_callback") });
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
logger.info(`[Bot] Worktree selected: ${selectedWorktree.path}`);
|
|
76
|
+
await upsertSessionDirectory(selectedWorktree.path, Date.now());
|
|
77
|
+
const projectInfo = await getProjectByWorktree(selectedWorktree.path);
|
|
78
|
+
const selectedProjectInfo = { ...projectInfo, name: selectedWorktree.path };
|
|
79
|
+
const replyKeyboard = await switchToProject(ctx, selectedProjectInfo, "worktree_switched", {
|
|
80
|
+
ensureEventSubscription: deps.ensureEventSubscription,
|
|
81
|
+
presentation: createProjectSwitchPresentation(),
|
|
82
|
+
});
|
|
83
|
+
await ctx.answerCallbackQuery();
|
|
84
|
+
await ctx.reply(t("worktree.selected", { worktree: selectedWorktree.path }), {
|
|
85
|
+
reply_markup: replyKeyboard,
|
|
86
|
+
});
|
|
87
|
+
await ctx.deleteMessage();
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
logger.error("[Bot] Error handling worktree callback:", error);
|
|
92
|
+
clearAllInteractionState("worktree_select_error");
|
|
93
|
+
await ctx.answerCallbackQuery({ text: t("callback.processing_error") });
|
|
94
|
+
await ctx.reply(t("worktree.select_error"));
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { opencodeClient } from "../../opencode/client.js";
|
|
2
|
-
import { getCurrentSession } from "../../session
|
|
3
|
-
import { clearAllInteractionState } from "../../interaction
|
|
2
|
+
import { getCurrentSession } from "../../app/services/session-service.js";
|
|
3
|
+
import { clearAllInteractionState } from "../../app/managers/interaction-manager.js";
|
|
4
4
|
import { logger } from "../../utils/logger.js";
|
|
5
5
|
import { t } from "../../i18n/index.js";
|
|
6
|
-
import { foregroundSessionState } from "../../
|
|
7
|
-
import { assistantRunState } from "
|
|
8
|
-
import { markAttachedSessionIdle } from "../../attach
|
|
6
|
+
import { foregroundSessionState } from "../../app/managers/foreground-session-state-manager.js";
|
|
7
|
+
import { assistantRunState } from "../../app/managers/assistant-run-state-manager.js";
|
|
8
|
+
import { markAttachedSessionIdle } from "../../app/services/attach-service.js";
|
|
9
9
|
import { clearPromptResponseMode } from "../handlers/prompt.js";
|
|
10
|
-
import { markUserAbortRequested } from "
|
|
10
|
+
import { markUserAbortRequested } from "../../app/managers/abort-suppression-manager.js";
|
|
11
11
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
12
12
|
function abortLocalStreaming() {
|
|
13
13
|
clearAllInteractionState("abort_command");
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { config } from "../../config.js";
|
|
2
|
+
import { interactionManager } from "../../app/managers/interaction-manager.js";
|
|
3
|
+
import { loadCommandCatalog } from "../../app/services/command-catalog-service.js";
|
|
4
|
+
import { getCurrentProject } from "../../app/stores/settings-store.js";
|
|
5
|
+
import { t } from "../../i18n/index.js";
|
|
6
|
+
import { logger } from "../../utils/logger.js";
|
|
7
|
+
import { buildCommandsListKeyboard, formatCommandsSelectText } from "../menus/command-catalog-menu.js";
|
|
8
|
+
export async function commandsCommand(ctx) {
|
|
9
|
+
try {
|
|
10
|
+
const currentProject = getCurrentProject();
|
|
11
|
+
if (!currentProject) {
|
|
12
|
+
await ctx.reply(t("bot.project_not_selected"));
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const commands = await loadCommandCatalog(currentProject.worktree);
|
|
16
|
+
if (commands.length === 0) {
|
|
17
|
+
await ctx.reply(t("commands.empty"));
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const pageSize = config.bot.commandsListLimit;
|
|
21
|
+
const keyboard = buildCommandsListKeyboard(commands, 0, pageSize);
|
|
22
|
+
const message = await ctx.reply(formatCommandsSelectText(0), {
|
|
23
|
+
reply_markup: keyboard,
|
|
24
|
+
});
|
|
25
|
+
interactionManager.start({
|
|
26
|
+
kind: "custom",
|
|
27
|
+
expectedInput: "callback",
|
|
28
|
+
metadata: {
|
|
29
|
+
flow: "commands",
|
|
30
|
+
stage: "list",
|
|
31
|
+
messageId: message.message_id,
|
|
32
|
+
projectDirectory: currentProject.worktree,
|
|
33
|
+
commands,
|
|
34
|
+
page: 0,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
logger.error("[Commands] Error fetching commands list:", error);
|
|
40
|
+
await ctx.reply(t("commands.fetch_error"));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -10,7 +10,7 @@ const COMMAND_DEFINITIONS = [
|
|
|
10
10
|
{ command: "detach", descriptionKey: "cmd.description.detach" },
|
|
11
11
|
{ command: "sessions", descriptionKey: "cmd.description.sessions" },
|
|
12
12
|
{ command: "messages", descriptionKey: "cmd.description.messages" },
|
|
13
|
-
{ command: "
|
|
13
|
+
{ command: "settings", descriptionKey: "cmd.description.settings" },
|
|
14
14
|
{ command: "projects", descriptionKey: "cmd.description.projects" },
|
|
15
15
|
{ command: "worktree", descriptionKey: "cmd.description.worktree" },
|
|
16
16
|
{ command: "task", descriptionKey: "cmd.description.task" },
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { getCurrentProject } from "../../settings
|
|
2
|
-
import { clearSession, getCurrentSession } from "../../session
|
|
3
|
-
import { detachAttachedSession } from "../../attach
|
|
4
|
-
import { clearAllInteractionState } from "../../interaction
|
|
5
|
-
import { pinnedMessageManager } from "
|
|
6
|
-
import { keyboardManager } from "
|
|
7
|
-
import { foregroundSessionState } from "../../
|
|
8
|
-
import { assistantRunState } from "
|
|
1
|
+
import { getCurrentProject } from "../../app/stores/settings-store.js";
|
|
2
|
+
import { clearSession, getCurrentSession } from "../../app/services/session-service.js";
|
|
3
|
+
import { detachAttachedSession } from "../../app/services/attach-service.js";
|
|
4
|
+
import { clearAllInteractionState } from "../../app/managers/interaction-manager.js";
|
|
5
|
+
import { pinnedMessageManager } from "../pinned/pinned-message-manager.js";
|
|
6
|
+
import { keyboardManager } from "../keyboards/keyboard-manager.js";
|
|
7
|
+
import { foregroundSessionState } from "../../app/managers/foreground-session-state-manager.js";
|
|
8
|
+
import { assistantRunState } from "../../app/managers/assistant-run-state-manager.js";
|
|
9
9
|
import { clearPromptResponseMode } from "../handlers/prompt.js";
|
|
10
10
|
import { logger } from "../../utils/logger.js";
|
|
11
11
|
import { t } from "../../i18n/index.js";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { getProjectRoot, isWithinProjectRoot } from "../../app/services/file-browser-service.js";
|
|
2
|
+
import { interactionManager } from "../../app/managers/interaction-manager.js";
|
|
3
|
+
import { isForegroundBusy } from "../../app/services/run-control-service.js";
|
|
4
|
+
import { t } from "../../i18n/index.js";
|
|
5
|
+
import { clearLsPathIndex, renderLsBrowseView } from "../menus/file-browser-menu.js";
|
|
6
|
+
import { replyBusyBlocked } from "../messages/busy-blocked-renderer.js";
|
|
7
|
+
import { rememberLsDirectory, resolveInitialLsDirectory } from "../callbacks/file-browser-callback-handler.js";
|
|
8
|
+
export async function lsCommand(ctx) {
|
|
9
|
+
if (isForegroundBusy()) {
|
|
10
|
+
await replyBusyBlocked(ctx);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
clearLsPathIndex();
|
|
14
|
+
const projectRoot = getProjectRoot();
|
|
15
|
+
if (!projectRoot) {
|
|
16
|
+
await ctx.reply(t("bot.project_not_selected"));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const args = typeof ctx.match === "string" ? ctx.match.trim() : undefined;
|
|
20
|
+
const targetDir = args || resolveInitialLsDirectory(ctx.from?.id);
|
|
21
|
+
if (!targetDir) {
|
|
22
|
+
await ctx.reply(t("bot.project_not_selected"));
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!isWithinProjectRoot(targetDir)) {
|
|
26
|
+
await ctx.reply(`❌ ${t("ls.access_denied")}`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const view = await renderLsBrowseView(targetDir);
|
|
30
|
+
if ("error" in view) {
|
|
31
|
+
await ctx.reply(`❌ ${view.error}`);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
rememberLsDirectory(ctx.from?.id, targetDir);
|
|
35
|
+
if (!view.hasActions) {
|
|
36
|
+
await ctx.reply(view.text, { parse_mode: "HTML" });
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const message = await ctx.reply(view.text, { parse_mode: "HTML", reply_markup: view.keyboard });
|
|
40
|
+
interactionManager.start({
|
|
41
|
+
kind: "inline",
|
|
42
|
+
expectedInput: "callback",
|
|
43
|
+
metadata: {
|
|
44
|
+
menuKind: "ls",
|
|
45
|
+
messageId: message.message_id,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { interactionManager } from "../../app/managers/interaction-manager.js";
|
|
2
|
+
import { loadMcpCatalog } from "../../app/services/mcp-catalog-service.js";
|
|
3
|
+
import { getCurrentProject } from "../../app/stores/settings-store.js";
|
|
4
|
+
import { t } from "../../i18n/index.js";
|
|
5
|
+
import { logger } from "../../utils/logger.js";
|
|
6
|
+
import { buildMcpsListKeyboard } from "../menus/mcp-catalog-menu.js";
|
|
7
|
+
export async function mcpsCommand(ctx) {
|
|
8
|
+
try {
|
|
9
|
+
const currentProject = getCurrentProject();
|
|
10
|
+
if (!currentProject) {
|
|
11
|
+
await ctx.reply(t("bot.project_not_selected"));
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const servers = await loadMcpCatalog(currentProject.worktree);
|
|
15
|
+
if (servers.length === 0) {
|
|
16
|
+
await ctx.reply(t("mcps.empty"));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const keyboard = buildMcpsListKeyboard(servers);
|
|
20
|
+
const message = await ctx.reply(t("mcps.select"), {
|
|
21
|
+
reply_markup: keyboard,
|
|
22
|
+
});
|
|
23
|
+
interactionManager.start({
|
|
24
|
+
kind: "custom",
|
|
25
|
+
expectedInput: "callback",
|
|
26
|
+
metadata: {
|
|
27
|
+
flow: "mcps",
|
|
28
|
+
stage: "list",
|
|
29
|
+
messageId: message.message_id,
|
|
30
|
+
projectDirectory: currentProject.worktree,
|
|
31
|
+
servers,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
logger.error("[Mcps] Error fetching MCP servers list:", error);
|
|
37
|
+
await ctx.reply(t("mcps.fetch_error"));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { config } from "../../config.js";
|
|
2
|
+
import { interactionManager } from "../../app/managers/interaction-manager.js";
|
|
3
|
+
import { getCurrentSession } from "../../app/services/session-service.js";
|
|
4
|
+
import { loadUserMessages } from "../../app/services/message-history-service.js";
|
|
5
|
+
import { isForegroundBusy } from "../../app/services/run-control-service.js";
|
|
6
|
+
import { getCurrentProject } from "../../app/stores/settings-store.js";
|
|
7
|
+
import { t } from "../../i18n/index.js";
|
|
8
|
+
import { logger } from "../../utils/logger.js";
|
|
9
|
+
import { replyBusyBlocked } from "../messages/busy-blocked-renderer.js";
|
|
10
|
+
import { buildMessagesListKeyboard, formatMessagesSelectText } from "../menus/message-history-menu.js";
|
|
11
|
+
export async function messagesCommand(ctx) {
|
|
12
|
+
try {
|
|
13
|
+
if (isForegroundBusy()) {
|
|
14
|
+
await replyBusyBlocked(ctx);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const currentProject = getCurrentProject();
|
|
18
|
+
if (!currentProject) {
|
|
19
|
+
await ctx.reply(t("messages.project_not_selected"));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const currentSession = getCurrentSession();
|
|
23
|
+
if (!currentSession) {
|
|
24
|
+
await ctx.reply(t("messages.session_not_selected"));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (currentSession.directory !== currentProject.worktree) {
|
|
28
|
+
await ctx.reply(t("messages.session_project_mismatch"));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const messages = await loadUserMessages(currentSession.id, currentSession.directory);
|
|
32
|
+
if (messages.length === 0) {
|
|
33
|
+
await ctx.reply(t("messages.empty"));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const pageSize = config.bot.messagesListLimit;
|
|
37
|
+
const keyboard = buildMessagesListKeyboard(messages, 0, pageSize);
|
|
38
|
+
const message = await ctx.reply(formatMessagesSelectText(0), {
|
|
39
|
+
reply_markup: keyboard,
|
|
40
|
+
});
|
|
41
|
+
interactionManager.start({
|
|
42
|
+
kind: "custom",
|
|
43
|
+
expectedInput: "callback",
|
|
44
|
+
metadata: {
|
|
45
|
+
flow: "messages",
|
|
46
|
+
stage: "list",
|
|
47
|
+
messageId: message.message_id,
|
|
48
|
+
projectDirectory: currentProject.worktree,
|
|
49
|
+
sessionId: currentSession.id,
|
|
50
|
+
messages,
|
|
51
|
+
page: 0,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
logger.error("[Messages] Error fetching messages list:", error);
|
|
57
|
+
await ctx.reply(t("messages.fetch_error"));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { opencodeClient } from "../../opencode/client.js";
|
|
2
|
-
import { setCurrentSession } from "../../session
|
|
3
|
-
import { ingestSessionInfoForCache } from "../../session
|
|
4
|
-
import { getCurrentProject } from "../../settings
|
|
5
|
-
import { clearAllInteractionState } from "../../interaction
|
|
6
|
-
import { keyboardManager } from "
|
|
7
|
-
import { getStoredAgent, resolveProjectAgent } from "../../agent
|
|
8
|
-
import { getStoredModel } from "../../model
|
|
9
|
-
import { formatVariantForButton } from "../../variant
|
|
10
|
-
import { createMainKeyboard } from "../
|
|
11
|
-
import { isForegroundBusy
|
|
2
|
+
import { setCurrentSession } from "../../app/services/session-service.js";
|
|
3
|
+
import { ingestSessionInfoForCache } from "../../app/services/session-cache-service.js";
|
|
4
|
+
import { getCurrentProject } from "../../app/stores/settings-store.js";
|
|
5
|
+
import { clearAllInteractionState } from "../../app/managers/interaction-manager.js";
|
|
6
|
+
import { keyboardManager } from "../keyboards/keyboard-manager.js";
|
|
7
|
+
import { getStoredAgent, resolveProjectAgent } from "../../app/services/agent-selection-service.js";
|
|
8
|
+
import { getStoredModel } from "../../app/services/model-selection-service.js";
|
|
9
|
+
import { formatVariantForButton } from "../../app/services/variant-selection-service.js";
|
|
10
|
+
import { createMainKeyboard } from "../keyboards/main-reply-keyboard.js";
|
|
11
|
+
import { isForegroundBusy } from "../../app/services/run-control-service.js";
|
|
12
|
+
import { replyBusyBlocked } from "../messages/busy-blocked-renderer.js";
|
|
12
13
|
import { logger } from "../../utils/logger.js";
|
|
13
14
|
import { t } from "../../i18n/index.js";
|
|
14
|
-
import { attachToSession } from "../../attach
|
|
15
|
+
import { attachToSession } from "../../app/services/attach-service.js";
|
|
15
16
|
export async function newCommand(ctx, deps) {
|
|
16
17
|
try {
|
|
17
18
|
if (isForegroundBusy()) {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { getBrowserRoots } from "../../app/services/file-browser-service.js";
|
|
2
|
+
import { interactionManager } from "../../app/managers/interaction-manager.js";
|
|
3
|
+
import { isForegroundBusy } from "../../app/services/run-control-service.js";
|
|
4
|
+
import { t } from "../../i18n/index.js";
|
|
5
|
+
import { logger } from "../../utils/logger.js";
|
|
6
|
+
import { buildOpenRootsKeyboard, clearOpenPathIndex, renderOpenBrowseView } from "../menus/file-browser-menu.js";
|
|
7
|
+
import { replyBusyBlocked } from "../messages/busy-blocked-renderer.js";
|
|
8
|
+
export async function openCommand(ctx) {
|
|
9
|
+
try {
|
|
10
|
+
if (isForegroundBusy()) {
|
|
11
|
+
await replyBusyBlocked(ctx);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
clearOpenPathIndex();
|
|
15
|
+
const roots = getBrowserRoots();
|
|
16
|
+
let text;
|
|
17
|
+
let keyboard;
|
|
18
|
+
if (roots.length === 1) {
|
|
19
|
+
const view = await renderOpenBrowseView(roots[0]);
|
|
20
|
+
if ("error" in view) {
|
|
21
|
+
await ctx.reply(t("open.scan_error", { error: view.error }));
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
text = view.text;
|
|
25
|
+
keyboard = view.keyboard;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
text = t("open.select_root");
|
|
29
|
+
keyboard = buildOpenRootsKeyboard();
|
|
30
|
+
}
|
|
31
|
+
const message = await ctx.reply(text, { reply_markup: keyboard });
|
|
32
|
+
interactionManager.start({
|
|
33
|
+
kind: "inline",
|
|
34
|
+
expectedInput: "callback",
|
|
35
|
+
metadata: {
|
|
36
|
+
menuKind: "open",
|
|
37
|
+
messageId: message.message_id,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
logger.error("[Bot] Error opening directory browser:", error);
|
|
43
|
+
await ctx.reply(t("open.open_error"));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -4,7 +4,7 @@ import { resolveLocalOpencodeTarget, startLocalOpencodeServer } from "../../open
|
|
|
4
4
|
import { opencodeReadyLifecycle } from "../../opencode/ready-lifecycle.js";
|
|
5
5
|
import { logger } from "../../utils/logger.js";
|
|
6
6
|
import { t } from "../../i18n/index.js";
|
|
7
|
-
import { editBotText } from "../
|
|
7
|
+
import { editBotText } from "../messages/telegram-text.js";
|
|
8
8
|
const SERVER_READY_TIMEOUT_MS = 10_000;
|
|
9
9
|
const SERVER_READY_POLL_INTERVAL_MS = 500;
|
|
10
10
|
const HEALTH_CHECK_TIMEOUT_MS = 3_000;
|
|
@@ -3,7 +3,7 @@ import { opencodeClient } from "../../opencode/client.js";
|
|
|
3
3
|
import { findServerPid, killServerProcess, resolveLocalOpencodeTarget, } from "../../opencode/process.js";
|
|
4
4
|
import { logger } from "../../utils/logger.js";
|
|
5
5
|
import { t } from "../../i18n/index.js";
|
|
6
|
-
import { editBotText } from "../
|
|
6
|
+
import { editBotText } from "../messages/telegram-text.js";
|
|
7
7
|
/**
|
|
8
8
|
* Command handler for /opencode-stop
|
|
9
9
|
* Stops the OpenCode server process
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { getProjects } from "../../app/services/project-service.js";
|
|
2
|
+
import { isForegroundBusy } from "../../app/services/run-control-service.js";
|
|
3
|
+
import { syncSessionDirectoryCache } from "../../app/services/session-cache-service.js";
|
|
4
|
+
import { t } from "../../i18n/index.js";
|
|
5
|
+
import { logger } from "../../utils/logger.js";
|
|
6
|
+
import { buildProjectsMenuView } from "../menus/project-selection-menu.js";
|
|
7
|
+
import { replyWithInlineMenu } from "../menus/inline-menu.js";
|
|
8
|
+
import { replyBusyBlocked } from "../messages/busy-blocked-renderer.js";
|
|
9
|
+
export async function projectsCommand(ctx) {
|
|
10
|
+
try {
|
|
11
|
+
if (isForegroundBusy()) {
|
|
12
|
+
await replyBusyBlocked(ctx);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
await syncSessionDirectoryCache();
|
|
16
|
+
const projects = await getProjects();
|
|
17
|
+
if (projects.length === 0) {
|
|
18
|
+
await ctx.reply(t("projects.empty"));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const { text, keyboard } = await buildProjectsMenuView(projects, 0);
|
|
22
|
+
await replyWithInlineMenu(ctx, {
|
|
23
|
+
menuKind: "project",
|
|
24
|
+
text,
|
|
25
|
+
keyboard,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
logger.error("[Bot] Error fetching projects:", error);
|
|
30
|
+
await ctx.reply(t("projects.fetch_error"));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getCurrentSession } from "../../app/services/session-service.js";
|
|
2
|
+
import { renameManager } from "../../app/managers/rename-manager.js";
|
|
3
|
+
import { interactionManager } from "../../app/managers/interaction-manager.js";
|
|
4
|
+
import { logger } from "../../utils/logger.js";
|
|
5
|
+
import { t } from "../../i18n/index.js";
|
|
6
|
+
import { buildRenameCancelKeyboard } from "../menus/rename-menu.js";
|
|
7
|
+
export async function renameCommand(ctx) {
|
|
8
|
+
try {
|
|
9
|
+
const currentSession = getCurrentSession();
|
|
10
|
+
if (!currentSession) {
|
|
11
|
+
await ctx.reply(t("rename.no_session"));
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const message = await ctx.reply(t("rename.prompt", { title: currentSession.title }), {
|
|
15
|
+
reply_markup: buildRenameCancelKeyboard(),
|
|
16
|
+
});
|
|
17
|
+
renameManager.startWaiting(currentSession.id, currentSession.directory, currentSession.title);
|
|
18
|
+
renameManager.setMessageId(message.message_id);
|
|
19
|
+
interactionManager.start({
|
|
20
|
+
kind: "rename",
|
|
21
|
+
expectedInput: "text",
|
|
22
|
+
metadata: {
|
|
23
|
+
sessionId: currentSession.id,
|
|
24
|
+
messageId: message.message_id,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
logger.info(`[RenameCommand] Waiting for new title for session: ${currentSession.id}`);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
logger.error("[RenameCommand] Error starting rename flow:", error);
|
|
31
|
+
await ctx.reply(t("rename.error"));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getCurrentProject } from "../../app/stores/settings-store.js";
|
|
2
|
+
import { replyWithInlineMenu } from "../menus/inline-menu.js";
|
|
3
|
+
import { isForegroundBusy } from "../../app/services/run-control-service.js";
|
|
4
|
+
import { replyBusyBlocked } from "../messages/busy-blocked-renderer.js";
|
|
5
|
+
import { logger } from "../../utils/logger.js";
|
|
6
|
+
import { config } from "../../config.js";
|
|
7
|
+
import { t } from "../../i18n/index.js";
|
|
8
|
+
import { buildSessionSelectionMenuView, loadSessionPage } from "../menus/session-selection-menu.js";
|
|
9
|
+
export async function sessionsCommand(ctx) {
|
|
10
|
+
try {
|
|
11
|
+
if (isForegroundBusy()) {
|
|
12
|
+
await replyBusyBlocked(ctx);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const pageSize = config.bot.sessionsListLimit;
|
|
16
|
+
const currentProject = getCurrentProject();
|
|
17
|
+
if (!currentProject) {
|
|
18
|
+
await ctx.reply(t("sessions.project_not_selected"));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
logger.debug(`[Sessions] Fetching sessions for directory: ${currentProject.worktree}`);
|
|
22
|
+
const firstPage = await loadSessionPage(currentProject.worktree, 0, pageSize);
|
|
23
|
+
logger.debug(`[Sessions] Found ${firstPage.sessions.length} sessions on page 1`);
|
|
24
|
+
firstPage.sessions.forEach((session) => {
|
|
25
|
+
logger.debug(`[Sessions] Session: ${session.title} | ${session.directory}`);
|
|
26
|
+
});
|
|
27
|
+
if (firstPage.sessions.length === 0) {
|
|
28
|
+
await ctx.reply(t("sessions.empty"));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const { text, keyboard } = buildSessionSelectionMenuView(firstPage, pageSize);
|
|
32
|
+
await replyWithInlineMenu(ctx, {
|
|
33
|
+
menuKind: "session",
|
|
34
|
+
text,
|
|
35
|
+
keyboard,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
logger.error("[Sessions] Error fetching sessions:", error);
|
|
40
|
+
await ctx.reply(t("sessions.fetch_error"));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { buildSettingsMenuView } from "../menus/settings-menu.js";
|
|
2
|
+
import { replyWithInlineMenu } from "../menus/inline-menu.js";
|
|
3
|
+
export async function settingsCommand(ctx) {
|
|
4
|
+
const { text, keyboard } = buildSettingsMenuView();
|
|
5
|
+
await replyWithInlineMenu(ctx, {
|
|
6
|
+
menuKind: "settings",
|
|
7
|
+
text,
|
|
8
|
+
keyboard,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { config } from "../../config.js";
|
|
2
|
+
import { interactionManager } from "../../app/managers/interaction-manager.js";
|
|
3
|
+
import { loadSkillsCatalog } from "../../app/services/skills-catalog-service.js";
|
|
4
|
+
import { getCurrentProject } from "../../app/stores/settings-store.js";
|
|
5
|
+
import { t } from "../../i18n/index.js";
|
|
6
|
+
import { logger } from "../../utils/logger.js";
|
|
7
|
+
import { buildSkillsListKeyboard, formatSkillsSelectText } from "../menus/skills-catalog-menu.js";
|
|
8
|
+
export async function skillsCommand(ctx) {
|
|
9
|
+
try {
|
|
10
|
+
const currentProject = getCurrentProject();
|
|
11
|
+
if (!currentProject) {
|
|
12
|
+
await ctx.reply(t("bot.project_not_selected"));
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const skills = await loadSkillsCatalog(currentProject.worktree);
|
|
16
|
+
if (skills.length === 0) {
|
|
17
|
+
await ctx.reply(t("skills.empty"));
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const pageSize = config.bot.commandsListLimit;
|
|
21
|
+
const keyboard = buildSkillsListKeyboard(skills, 0, pageSize);
|
|
22
|
+
const message = await ctx.reply(formatSkillsSelectText(0), {
|
|
23
|
+
reply_markup: keyboard,
|
|
24
|
+
});
|
|
25
|
+
interactionManager.start({
|
|
26
|
+
kind: "custom",
|
|
27
|
+
expectedInput: "callback",
|
|
28
|
+
metadata: {
|
|
29
|
+
flow: "skills",
|
|
30
|
+
stage: "list",
|
|
31
|
+
messageId: message.message_id,
|
|
32
|
+
projectDirectory: currentProject.worktree,
|
|
33
|
+
skills,
|
|
34
|
+
page: 0,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
logger.error("[Skills] Error fetching skills list:", error);
|
|
40
|
+
await ctx.reply(t("skills.fetch_error"));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { createMainKeyboard } from "../
|
|
2
|
-
import { getStoredAgent } from "../../agent
|
|
3
|
-
import { getStoredModel } from "../../model
|
|
4
|
-
import { formatVariantForButton } from "../../variant
|
|
5
|
-
import { pinnedMessageManager } from "
|
|
6
|
-
import { keyboardManager } from "
|
|
7
|
-
import { clearSession } from "../../session
|
|
8
|
-
import { clearProject } from "../../settings
|
|
9
|
-
import { foregroundSessionState } from "../../
|
|
10
|
-
import { abortCurrentOperation } from "./abort.js";
|
|
1
|
+
import { createMainKeyboard } from "../keyboards/main-reply-keyboard.js";
|
|
2
|
+
import { getStoredAgent } from "../../app/services/agent-selection-service.js";
|
|
3
|
+
import { getStoredModel } from "../../app/services/model-selection-service.js";
|
|
4
|
+
import { formatVariantForButton } from "../../app/services/variant-selection-service.js";
|
|
5
|
+
import { pinnedMessageManager } from "../pinned/pinned-message-manager.js";
|
|
6
|
+
import { keyboardManager } from "../keyboards/keyboard-manager.js";
|
|
7
|
+
import { clearSession } from "../../app/services/session-service.js";
|
|
8
|
+
import { clearProject } from "../../app/stores/settings-store.js";
|
|
9
|
+
import { foregroundSessionState } from "../../app/managers/foreground-session-state-manager.js";
|
|
10
|
+
import { abortCurrentOperation } from "./abort-command.js";
|
|
11
11
|
import { t } from "../../i18n/index.js";
|
|
12
|
-
import { assistantRunState } from "
|
|
13
|
-
import { detachAttachedSession } from "../../attach
|
|
12
|
+
import { assistantRunState } from "../../app/managers/assistant-run-state-manager.js";
|
|
13
|
+
import { detachAttachedSession } from "../../app/services/attach-service.js";
|
|
14
14
|
export async function startCommand(ctx) {
|
|
15
15
|
if (ctx.chat) {
|
|
16
16
|
if (!pinnedMessageManager.isInitialized()) {
|