v9: new-topic helper — spawn fresh lane synchronously, queue heartbeat

MA
7mo ago
+181-2

Stacked on #216 (v8). One small new helper that fixes a doctrine awkwardness you called out.

Why

tg-schedule "+1 minute" --fresh "..." was being recommended as the way for the agent to spawn a fresh topic for a new project. But that's misusing the schedule API:

  • The 1-minute delay is wrong UX (topic appears late).
  • It's a one-shot — the spawned topic got an initial prompt and then nothing. No check-in 3 hours later. No heartbeat.
  • "Schedule" reads wrong for a synchronous spawn.

What

agent/new-topic — a small Python helper (~140 LOC):

new-topic "<title>" "<initial prompt>"                       # default +1h heartbeat
new-topic "<title>" --heartbeat "+3 hours" "<prompt>"        # custom cadence
new-topic "<title>" --heartbeat none "<prompt>"              # one-shot, no follow-up

What it actually does:

  1. createForumTopic synchronously — topic appears in Telegram immediately, no at-job delay.
  2. bot.run_task to dispatch the initial prompt as the topic's first turn.
  3. tg-schedule --repeat to queue the recurring heartbeat (skipped on --heartbeat none).
  4. Prints {ok, chat_id, thread_id, title, heartbeat} as JSON so the caller can include a link in whatever it's posting back to the user.

/goal stays the user-driven autopilot trigger (no approvals). new-topic is the agent-driven copilot equivalent (default mode, draft + ask).

Changes

  • agent/new-topic (new, +178 LOC)
  • install.sh + agent/bootstrap.sh — install + symlink
  • agent/system-prompt.md — "Spawning new topics" rewritten around new-topic

Tests

  • 29 pass
  • Syntax check
  • On a box: new-topic "Test topic" "draft hello" — verify topic appears, first turn dispatches, atq shows a queued heartbeat
  • new-topic "X" --heartbeat none "Y" — verify no heartbeat queued

🤖 Generated with Claude Code


Summary by cubic

Add new-topic to start a fresh Telegram topic instantly, send the first agent turn, and schedule a recurring heartbeat. Replaces the misuse of tg-schedule --fresh so new lanes appear now and keep getting follow‑ups.

  • New Features
    • agent/new-topic CLI:
      • Creates the forum topic immediately and dispatches the first turn via bot.run_task.
      • Queues a recurring heartbeat with tg-schedule --repeat (default +1h; supports --heartbeat "+3 hours" or --heartbeat none).
      • Prints JSON {ok, chat_id, thread_id, title, heartbeat} for easy linking.
      • New lanes run in copilot mode; /goal stays the user-driven autopilot.
    • Added install/symlink in install.sh and agent/bootstrap.sh. Updated agent/system-prompt.md to use new-topic.