Repository navigation
feat(tui): /loop で同じ依頼をセッション内で一定間隔に繰り返す - #71
Open
yukihamada wants to merge 2 commits into
Open
yukihamada wants to merge 2 commits into
yukihamada wants to merge 2 commits into
Conversation
- `/loop <間隔> [--max N] [--for 期間] <依頼 or サーバーコマンド>`、`/loop` で一覧(選ぶと停止)、`/loop stop [id|all]`、`/loop resume [id|all]` - 間隔は最短60秒に切り上げ。既定24時間・50回で終了、--for は最長7日、同時10件まで - 前回(や本人・/goal の依頼)が生成中ならその回は飛ばす。生成終了から5秒・入力欄を触ってから10秒は送らない(/goal の自動継続と二重送信しない) - 費用上限の承認待ち(request_cost)が出たらループを一時停止して知らせる。送信3連続失敗でも一時停止 - 入力欄の下に「ループ中 n件・次回 mm:ss」。TUI を閉じると止まる(/help に明記、常時実行は /tasks) - 日英表示。偽の時計で単体テスト15件 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
独立評価(67点)の指摘への対応。 - 同じ会話の複数ループ: 他ループの回で塞がっているだけなら飛ばさず期日を保って待ち、期日の古い順に送る(2本で 50/50 回) - 費用確認(request_cost)で一時停止したループは承認されたら自動再開。承認待ち中の resume は「承認待ちです」を返す。通知は同じ会話で5分に1回 - --budget(既定 $1/ループ)で、送信前後の会話費用の差を累計して上限で終了。request_cost: allow / cost_limit_usd: none でも効く。一覧・フッター・終了通知に累計 - 開始通知にモデル固定(例 teai/auto)と「約5秒後に1回目」を表示。自分の入力欄クリアで10秒待っていたのを修正(書きかけがある時だけ待つ) - 「5分」「5分ごとに」「every 5m」、本文後ろの --max/--for/--budget、上限丸めの通知 - /loop stop・resume の対象省略は開いている会話の全件。一覧は毎秒更新・選ぶと止める/再開/戻る - 「/」で始まる依頼は手元の画面コマンド(/mode 等)でなければ送る(/usr を確認 等) - LoopProvider を DialogProvider の外側へ(/loop 一覧が context エラーで落ちていた) - 入力欄・TUI 状態読み取りの描画テスト4件を追加 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
対話画面に
/loopを追加します。手元の TUI セッション内で、同じ依頼(またはサーバー側のスラッシュコマンド)を一定間隔で今の会話へ送ります。TUI を閉じると止まります。常時実行には、サーバー側の/tasks(そのまま残します)を案内します。使い方
/loop 5分 依頼//loop 5分ごとに依頼//loop 5m 依頼//loop every 5m 依頼--max N(回数・既定50・最大1000)、--for 2h(期間・既定24時間・最長7日)、--budget 0.5(1ループの費用上限・既定 $1・最大 $100)/loopで一覧を開きます(毎秒更新)。選ぶと「止める / 再開する / 戻る」を選べます。/loop stop [id|all]・/loop resume [id|all]: 対象を省くと、開いている会話のループ全件が対象です。/modeなど)は断ります。それ以外は、サーバーのコマンドならコマンドとして、そうでなければ依頼文として送ります(例:/usr を確認)。送り方の規則
費用
--budget): 各回の送信前後の会話費用(子セッション込み)の差を足していき、上限に達したら終了します。サーバーの費用確認とは独立して動くので、request_cost: allowやcost_limit_usd: noneの設定でも止まります。request_costの承認待ち)が出たら、その会話のループを一時停止して通知します(「先に承認すると自動で再開」)。/loop resumeで再開します。/goal との関係
/goal(ターン終了時の自動継続)はまだ別の PR で、このブランチには入っていません。/loop は、生成が終わってから5秒静かになるまで送らないので、/goal が直後に継続を送ればループ側はその回を飛ばします。両方を入れた状態での動作は未確認です。
実装
packages/tui/src/util/loop.ts: 解析、スケジューラ、TUI 状態の読み取り(sessionState/sessionSpend)、入力の受け付け判定(prepareStart)。時計・送信は外から渡します。packages/tui/src/context/loop.tsx: 1秒ごとの tick、費用確認イベント(permission.asked/replied)の受け取り、通知。LoopProviderはDialogProviderの外側に置きました(一覧のダイアログからも参照するため)。component/dialog-loop.tsx、util/loop-text.ts(日英)、prompt の submit とフッター、/loopの app コマンド、/help の説明テスト
bun test test/util/loop.test.ts: 25件成功(偽の時計。偽送信は応答中は「生成中」を再現)bun test test/cli/tui/prompt-loop.test.tsx: 4件成功(本物の Prompt と LoopProvider)/usr を確認は受け付ける・上限丸めの通知・対象なし stop/loop listのダイアログ表示 → 操作メニューで再開starve.test.ts: a=50 / b=50、承認待ち中の resume は paused のままpackages/tui:bun run typecheck成功、bun test --timeout 30000488件成功 / 失敗0実機確認(tmux・新しい会話・teai/auto)
/loop 1m 今の時刻を一言で: 1回目は Enter から5.1秒後に届きました。その後も1分ごとに送られています。/loop stop(対象なし)でフッターが消えました。一覧の残り時間は毎秒更新され、操作メニューの「止める」で停止しました。--budget 0.00001: 1回送ったあと「上限に達したため終了しました(累計 $0.000041)」と出ました。request_cost: allowだったため、起動時の設定でaskに上書きし、/cost を $0.0001 に設定):LoopProviderの位置を直し、描画テストを追加しました。CI(base
headless-model-fallback= fc902f4 の test run 45288524310 と照合)@sente-ai/core#testとsente#testで、tui は成功しています。DatabaseMigration > declared schema has no ungenerated migrations、loop sets status to busy then idle、assertNotBusy fails with BusyError when loop running、sente CLI help-text snapshots > every documented command emits stable help text、audit: bash deny blocks shell syntax: …Playwright does not support chromium on ubuntu26.04-x64です。@sente-ai/core#testとsente#testで、tui は成功しています。base 側の windows の結果はこの時点では出ておらず、名前の照合はまだです。🤖 Generated with Claude Code