From 9580d249743a780268574750e50e9db70829dc6a Mon Sep 17 00:00:00 2001 From: Chris Lettieri Date: Wed, 25 Feb 2026 07:54:44 -0500 Subject: [PATCH] context pipe from file, shell script launch --- src/services/task-dispatch-service.ts | 35 ++++++++++++++++++--------- src/types/settings.ts | 2 +- src/ui/settings-tab.ts | 2 +- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/services/task-dispatch-service.ts b/src/services/task-dispatch-service.ts index 2e102d0..09043ed 100644 --- a/src/services/task-dispatch-service.ts +++ b/src/services/task-dispatch-service.ts @@ -298,16 +298,19 @@ export class TaskDispatchService { } private cleanupContextFile(taskId: string): void { - const filePath = path.join( - this.settings.taskDispatch.contextTempDir, - `task-${taskId}-context.md` - ); - try { - if (fs.existsSync(filePath)) { - fs.unlinkSync(filePath); + const dir = this.settings.taskDispatch.contextTempDir; + const files = [ + path.join(dir, `task-${taskId}-context.md`), + path.join(dir, `task-${taskId}-launch.sh`), + ]; + for (const filePath of files) { + try { + if (fs.existsSync(filePath)) { + fs.unlinkSync(filePath); + } + } catch { + // Non-critical, ignore cleanup failures } - } catch { - // Non-critical, ignore cleanup failures } } @@ -329,9 +332,19 @@ export class TaskDispatchService { ): Promise { await execAsync(`${tmux} new-session -d -s ${this.shellEscape(sessionName)} -c ${this.shellEscape(workingDir)}`); - const agentCommand = `${agentConfig.command} ${agentConfig.contextFlag} ${this.shellEscape(contextFilePath)}`; + // Write a launcher script that reads context from the temp file and passes + // it to the agent via --append-system-prompt (which works in interactive mode, + // unlike --append-system-prompt-file which is print-mode only). + // This avoids piping potentially 200k+ chars through tmux send-keys. + const launcherPath = contextFilePath.replace('-context.md', '-launch.sh'); + const launcherScript = [ + '#!/bin/bash', + `${agentConfig.command} ${agentConfig.contextFlag} "$(cat "${contextFilePath}")" "Read the task above and begin. Summarize what you understand, then start working."`, + ].join('\n'); + fs.writeFileSync(launcherPath, launcherScript, { mode: 0o755 }); + await execAsync( - `${tmux} send-keys -t ${this.shellEscape(sessionName)} ${this.shellEscape(agentCommand)} Enter` + `${tmux} send-keys -t ${this.shellEscape(sessionName)} ${this.shellEscape(launcherPath)} Enter` ); } diff --git a/src/types/settings.ts b/src/types/settings.ts index 4a10b43..4d8b56a 100644 --- a/src/types/settings.ts +++ b/src/types/settings.ts @@ -65,7 +65,7 @@ export const DEFAULT_SETTINGS: OpenAugiSettings = { id: 'claude-code', name: 'Claude Code', command: 'claude', - contextFlag: '--append-system-prompt-file' + contextFlag: '--append-system-prompt' } ], defaultAgent: 'claude-code', diff --git a/src/ui/settings-tab.ts b/src/ui/settings-tab.ts index cd60dc1..a8d8b1c 100644 --- a/src/ui/settings-tab.ts +++ b/src/ui/settings-tab.ts @@ -401,7 +401,7 @@ export class OpenAugiSettingTab extends PluginSettingTab { new Setting(containerEl) .setName('Default working directory') - .setDesc('Directory the agent launches in. Override per-task with `repo` in frontmatter.') + .setDesc('Directory the agent launches in. Vault-relative or absolute. Override per-task with `working_dir` in frontmatter.') .addText(text => { text .setPlaceholder('~/projects')