dsh-tg-bridge 1.40.1 → 1.41.1

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/README.md CHANGED
@@ -80,7 +80,7 @@ a decision before the first message:
80
80
 
81
81
  The first three commands are enough to be productive: `/cd <project>` binds the
82
82
  topic to a folder, `/model` picks the model with buttons, `/menu` is every
83
- command as a card, grouped. `/start` answers with the same three; `/help`
83
+ command as a card, grouped. `/start` answers with the same three and offers a five-step tour — folder, model, files, the turn and the way back, the switches — each step naming one command as a button; `/help`
84
84
  explains any command in one message; `/settings` holds the switches above.
85
85
 
86
86
  ## Requirements
@@ -18,7 +18,8 @@ import { handleModelPress, MODEL_PREFIX, modelPressRouter } from '../control/mod
18
18
  import { runCommandFromButton } from '../core/run-command.mjs';
19
19
  import { handleCardPress } from '../profile/settings-press.mjs';
20
20
  import { cardBlocks, cardKeyboard, renderCardSettings, toggleCardBlock } from '../turn/card.mjs';
21
- import { handleFilePress } from './file-press.mjs';
21
+ import { handleFilePress } from './file-press.mjs';
22
+ import { handleTourPress } from './tour-press.mjs';
22
23
  import { config, done, log, saveState, state } from '../core/state.mjs';
23
24
  import { inlineKeyboard, send, sendFile, tg, tgFast } from './telegram.mjs';
24
25
  import { sessionFile } from './thoughts.mjs';
@@ -345,6 +346,8 @@ export async function handleCallback(query) {
345
346
  if (await modelPressRouter({ chatId, threadId, messageId, key, lang, answer, log })(data)) return;
346
347
  }
347
348
 
349
+ if (await handleTourPress({ data, lang, chatId, threadId, messageId, answer })) return;
350
+
348
351
  if (await handleFilePress({ data, key, lang, chatId, threadId, messageId, answer })) return;
349
352
 
350
353
  if (data.startsWith('tc:')) {
@@ -0,0 +1,41 @@
1
+ // One press inside the tour: next, back, or the command a card names.
2
+ //
3
+ // `tr:page:<n>` edits the card in place; `tr:run:<cmd>` hands the press to the
4
+ // ordinary command path, so a tour button is not a second implementation of the
5
+ // command it advertises.
6
+ import { runCommandFromButton } from '../core/run-command.mjs';
7
+ import { t } from '../core/i18n.mjs';
8
+ import { tg } from './telegram.mjs';
9
+ import { TRY, tourCard } from './tour.mjs';
10
+
11
+ export async function handleTourPress({ data, lang, chatId, threadId, messageId, answer }) {
12
+ if (!String(data || '').startsWith('tr:')) return false;
13
+ const body = String(data).slice(3);
14
+
15
+ if (body === 'done') {
16
+ await answer(t(lang, 'tour.done'));
17
+ return true;
18
+ }
19
+
20
+ if (body.startsWith('run:')) {
21
+ const cmd = body.slice(4);
22
+ if (!TRY.includes(cmd)) {
23
+ await answer(t(lang, 'tour.done'));
24
+ return true;
25
+ }
26
+ await runCommandFromButton(`/${cmd}`, { chatId, threadId, lang });
27
+ return true;
28
+ }
29
+
30
+ const step = Number(body.replace('page:', '')) || 1;
31
+ const card = tourCard(step, lang);
32
+ await tg('editMessageText', {
33
+ chat_id: chatId,
34
+ message_id: messageId,
35
+ text: card.text,
36
+ parse_mode: 'Markdown',
37
+ reply_markup: { inline_keyboard: card.keyboard },
38
+ }).catch(() => {});
39
+ await answer(t(lang, 'tour.page', { n: Math.min(Math.max(step, 1), TRY.length), total: TRY.length }));
40
+ return true;
41
+ }
package/chat/tour.mjs ADDED
@@ -0,0 +1,35 @@
1
+ // The tour: what the bot can do, five cards, buttons only.
2
+ //
3
+ // The command list answers "what is the syntax"; it never answers "what is this
4
+ // for". A beginner reading twenty commands learns nothing about which one they
5
+ // need today, so the tour walks the five jobs a person actually has — a folder,
6
+ // a model, files, the turn and the way back, the switches — and each card names
7
+ // one command that starts that job, as a button.
8
+ //
9
+ // The page lives in the callback data, not in state: a card survives a restart,
10
+ // and there is nothing to keep in sync.
11
+ import { t } from '../core/i18n.mjs';
12
+ import { inlineKeyboard } from './telegram.mjs';
13
+
14
+ /** One command per card — the one a person would reach for first in that job. */
15
+ export const TRY = ['cd', 'model', 'find', 'rewind', 'menu'];
16
+
17
+ export const PAGES = TRY.length;
18
+
19
+ /**
20
+ * The card for one step.
21
+ *
22
+ * @param {number} step 1-based; clamped, because a stale button must not crash.
23
+ */
24
+ export function tourCard(step, lang) {
25
+ const n = Math.min(Math.max(Math.trunc(step) || 1, 1), PAGES);
26
+ const title = t(lang, `tour.${n}.title`);
27
+ const body = t(lang, `tour.${n}.body`);
28
+ const text = `*${title}*\n_${t(lang, 'tour.page', { n, total: PAGES })}_\n\n${body}`;
29
+ const row = [];
30
+ if (n > 1) row.push({ text: t(lang, 'tour.back'), data: `tr:page:${n - 1}` });
31
+ if (n < PAGES) row.push({ text: t(lang, 'tour.next'), data: `tr:page:${n + 1}` });
32
+ else row.push({ text: t(lang, 'tour.done'), data: 'tr:done' });
33
+ const keyboard = [row, [{ text: t(lang, 'tour.try', { cmd: TRY[n - 1] }), data: `tr:run:${TRY[n - 1]}` }]];
34
+ return { text, keyboard: inlineKeyboard(keyboard) };
35
+ }
@@ -5,10 +5,14 @@
5
5
  // first sentence, since the person had done nothing wrong. This is the answer
6
6
  // instead: what the bot is, and the three commands that make it usable.
7
7
  import { t } from '../core/i18n.mjs';
8
+ import { inlineKeyboard } from '../chat/telegram.mjs';
9
+ import { tourCard } from '../chat/tour.mjs';
8
10
 
9
11
  export async function handleStartCommands(ctx) {
10
12
  const { effective, lang, reply } = ctx;
11
13
  if (effective !== '/start') return false;
12
- await reply(t(lang, 'start.body'));
14
+ await reply(t(lang, 'start.body'), {
15
+ reply_markup: { inline_keyboard: inlineKeyboard([[{ text: t(lang, 'tour.start'), data: 'tr:page:1' }]]) },
16
+ });
13
17
  return true;
14
18
  }
package/docs/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # CHANGELOG — DSH Telegram bridge
2
2
 
3
+ ## 1.41.1
4
+
5
+ - **A note cannot land in General while its turn is elsewhere.** `say.mjs
6
+ --chat <id>` without `--thread` meant thread 0, and thread 0 is a group's
7
+ General topic: a session that knew only the chat wrote its working notes there
8
+ while its card named another topic, and nothing said so. The live marker for
9
+ the folder completes the half a flag carries and prints `--thread missing:
10
+ using topic N of the turn running in this folder`; a caller that passes both
11
+ keeps its own topic, and no target at all is still a refusal.
12
+ - Reported from a real group. The markers and files on disk were consistent when
13
+ checked, so this closes the hole the symptom needs rather than claiming the
14
+ exact line that produced it.
15
+
16
+ ## 1.41.0
17
+
18
+ - **`/start` opens a five-step tour.** The command list answers "what is the
19
+ syntax"; it never answered "which of these do I need today". Five cards —
20
+ the topic is a session, the model and its price, files, the turn and the way
21
+ back, the switches and the rhythm — each naming one command and carrying it as
22
+ a button, so the tour hands the person to the real command instead of
23
+ describing it. The step lives in the callback data, so a card survives a
24
+ restart, a stale button is clamped to a real step, and the last card ends at
25
+ `/menu` and `/help`.
26
+
3
27
  ## 1.40.1
4
28
 
5
29
  - **`/start` answers.** Telegram sends it when somebody opens the bot — the
package/i18n/en/core.mjs CHANGED
@@ -323,4 +323,20 @@ export default {
323
323
 
324
324
  'ctrl.help.about.start': "/start — the welcome card: what this bot is and the three commands to begin with. Telegram sends it when somebody opens the bot.",
325
325
 
326
+ 'tour.start': "What it can do",
327
+ 'tour.page': "Step {n} of {total}",
328
+ 'tour.back': "< Back",
329
+ 'tour.next': "Next >",
330
+ 'tour.done': "Done",
331
+ 'tour.try': "Try /{cmd}",
332
+ 'tour.1.title': "Topics are sessions",
333
+ 'tour.1.body': "Every topic in Telegram is its own session: its own folder, its own model, its own history.\n\n/cd <project> binds this topic to a folder; /new starts a fresh conversation in the same folder.",
334
+ 'tour.2.title': "Model and price",
335
+ 'tour.2.body': "/model picks the endpoint first, then the model — all buttons.\n\n/prices says what the current model costs and whose price that is. /model auto lets the fallback chain take over when a provider refuses.",
336
+ 'tour.3.title': "Files",
337
+ 'tour.3.body': "/send hands over a file from this topic folder.\n\n/find <text> searches for a string and opens the file at the matched line. /diff shows what a turn changed and can revert a single hunk.",
338
+ 'tour.4.title': "The turn and the way back",
339
+ 'tour.4.body': "Anything you type without a command is a turn: the agent works in this folder and answers here.\n\n/stop stops it, /rewind steps the conversation back, /sessions lists the past ones.",
340
+ 'tour.5.title': "Settings and rhythm",
341
+ 'tour.5.body': "/settings is the switches, as buttons.\n\n/every 9:00 <text> runs a turn on a schedule in this topic, /remind is a nudge, /menu draws every command, /help <command> explains one.",
326
342
  };
package/i18n/ru/core.mjs CHANGED
@@ -323,4 +323,20 @@ export default {
323
323
 
324
324
  'ctrl.help.about.start': "/start — приветствие: что это за бот и три команды, с которых начать. Telegram присылает её, когда человек открывает бота.",
325
325
 
326
+ 'tour.start': "Что умею",
327
+ 'tour.page': "Шаг {n} из {total}",
328
+ 'tour.back': "< Назад",
329
+ 'tour.next': "Далее >",
330
+ 'tour.done': "Готово",
331
+ 'tour.try': "Попробовать /{cmd}",
332
+ 'tour.1.title': "Темы — это сессии",
333
+ 'tour.1.body': "Каждая тема в Telegram — отдельная сессия: своя папка, своя модель, своя история.\n\n/cd <проект> привязывает тему к папке; /new начинает новый разговор в той же папке.",
334
+ 'tour.2.title': "Модель и цена",
335
+ 'tour.2.body': "/model сначала спрашивает эндпоинт, потом модель — всё кнопками.\n\n/prices говорит, сколько стоит текущая модель и чья это цена. /model auto включает цепочку подмены, когда провайдер отказывает.",
336
+ 'tour.3.title': "Файлы",
337
+ 'tour.3.body': "/send отдаёт файл из папки темы.\n\n/find <текст> ищет строку и открывает файл на найденной строке. /diff показывает, что изменил ход, и умеет откатить один кусок.",
338
+ 'tour.4.title': "Ход и дорога назад",
339
+ 'tour.4.body': "Всё, что вы написали без команды, — ход: агент работает в этой папке и отвечает здесь.\n\n/stop останавливает его, /rewind откатывает разговор на шаг, /sessions показывает прошлые.",
340
+ 'tour.5.title': "Настройки и ритм",
341
+ 'tour.5.body': "/settings — переключатели кнопками.\n\n/every 9:00 <текст> запускает ход по расписанию в этой теме, /remind напоминает, /menu рисует все команды, /help <команда> объясняет одну.",
326
342
  };
package/i18n/zh/core.mjs CHANGED
@@ -323,4 +323,20 @@ export default {
323
323
 
324
324
  'ctrl.help.about.start': "/start —— 欢迎卡片:这个机器人是什么,以及开始用的三条命令。有人打开机器人时 Telegram 会发送它。",
325
325
 
326
+ 'tour.start': "能做什么",
327
+ 'tour.page': "第 {n} 步,共 {total} 步",
328
+ 'tour.back': "< 上一步",
329
+ 'tour.next': "下一步 >",
330
+ 'tour.done': "完成",
331
+ 'tour.try': "试试 /{cmd}",
332
+ 'tour.1.title': "话题就是会话",
333
+ 'tour.1.body': "Telegram 里每个话题都是独立会话:自己的目录、模型和历史。\n\n/cd <项目> 把话题绑定到目录;/new 在同一目录里开新对话。",
334
+ 'tour.2.title': "模型与价格",
335
+ 'tour.2.body': "/model 先选端点,再选模型,全部用按钮。\n\n/prices 说明当前模型的费用以及是谁的价格。/model auto 让提供商拒绝时自动切换。",
336
+ 'tour.3.title': "文件",
337
+ 'tour.3.body': "/send 发送话题目录里的文件。\n\n/find <文字> 查找字符串并在该行打开文件。/diff 显示一次回合改了什么,还能只回退一段。",
338
+ 'tour.4.title': "回合与退路",
339
+ 'tour.4.body': "不带命令的任何消息都是一次回合:代理在这个目录里工作并在这里回答。\n\n/stop 停止,/rewind 往回退一步,/sessions 列出过去的会话。",
340
+ 'tour.5.title': "设置与节奏",
341
+ 'tour.5.body': "/settings 是开关,全部按钮化。\n\n/every 9:00 <文字> 在这个话题里定时跑一次回合,/remind 提醒,/menu 画出所有命令,/help <命令> 解释一条。",
326
342
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-tg-bridge",
3
- "version": "1.40.1",
3
+ "version": "1.41.1",
4
4
  "description": "Drive DeepSeek Harness from Telegram: one project, model and session per forum topic",
5
5
  "type": "module",
6
6
  "main": "plugin-bridge.mjs",
package/say.mjs CHANGED
@@ -183,6 +183,15 @@ async function main() {
183
183
  threadId = active.threadId;
184
184
  }
185
185
  }
186
+ // `--chat` without `--thread` used to mean thread 0, and thread 0 is the
187
+ // group's General topic: a note written from a session that only knew the
188
+ // chat landed in "General" while it was talking about another topic's work.
189
+ // The live marker for this folder knows both halves, so it wins over half a
190
+ // flag — and says so, because a silent correction is its own mystery later.
191
+ if (chatId && !threadId && !args.steer && marker && marker.chatId === chatId && marker.threadId) {
192
+ threadId = marker.threadId;
193
+ console.error(`--thread missing: using topic ${threadId} of the turn running in this folder`);
194
+ }
186
195
  if (args.steer) {
187
196
  const found = jobOf(args.steer);
188
197
  if (!found) {