takt/src/features/interactive/passthroughMode.ts
nrs f7d540b069
github-issue-154-moodoni4tsuno (#165)
* caffeinate に -d フラグを追加し、ディスプレイスリープ中の App Nap によるプロセス凍結を防止

* takt 対話モードの save_task を takt add と同じ worktree 設定フローに統一

takt 対話モードで Save Task を選択した際に worktree/branch/auto_pr の
設定プロンプトがスキップされ、takt run で clone なしに実行されて成果物が
消失するバグを修正。promptWorktreeSettings() を共通関数として抽出し、
saveTaskFromInteractive() と addTask() の両方から使用するようにした。

* Release v0.9.0

* takt: github-issue-154-moodoni4tsuno
2026-02-09 00:18:29 +09:00

51 lines
1.4 KiB
TypeScript

/**
* Passthrough interactive mode.
*
* Passes user input directly as the task string without any
* AI-assisted instruction generation or system prompt injection.
*/
import chalk from 'chalk';
import { info, blankLine } from '../../shared/ui/index.js';
import { getLabel } from '../../shared/i18n/index.js';
import { readMultilineInput } from './lineEditor.js';
import type { InteractiveModeResult } from './interactive.js';
/**
* Run passthrough mode: collect user input and return it as-is.
*
* If initialInput is provided, it is used directly as the task.
* Otherwise, prompts the user for input.
*
* @param lang - Display language
* @param initialInput - Pre-filled input (e.g., from issue reference)
* @returns Result with the raw user input as task
*/
export async function passthroughMode(
lang: 'en' | 'ja',
initialInput?: string,
): Promise<InteractiveModeResult> {
if (initialInput) {
return { action: 'execute', task: initialInput };
}
info(getLabel('interactive.ui.intro', lang));
blankLine();
const input = await readMultilineInput(chalk.green('> '));
if (input === null) {
blankLine();
info(getLabel('interactive.ui.cancelled', lang));
return { action: 'cancel', task: '' };
}
const trimmed = input.trim();
if (!trimmed) {
info(getLabel('interactive.ui.cancelled', lang));
return { action: 'cancel', task: '' };
}
return { action: 'execute', task: trimmed };
}