Add shell commands without context contribution (!! prefix)

Use !!command to execute bash commands that are shown in the TUI and
saved to session history but excluded from LLM context, compaction
summaries, and branch summaries.

- Add excludeFromContext field to BashExecutionMessage
- Filter excluded messages in convertToLlm()
- Parse !! prefix in interactive mode
- Use dim border color for excluded commands

fixes #414
This commit is contained in:
Mario Zechner 2026-01-03 04:14:35 +01:00
parent bc52509a42
commit 746ec9eb01
5 changed files with 40 additions and 17 deletions

View file

@ -1395,8 +1395,13 @@ export class AgentSession {
* Adds result to agent context and session.
* @param command The bash command to execute
* @param onChunk Optional streaming callback for output
* @param options.excludeFromContext If true, command output won't be sent to LLM (!! prefix)
*/
async executeBash(command: string, onChunk?: (chunk: string) => void): Promise<BashResult> {
async executeBash(
command: string,
onChunk?: (chunk: string) => void,
options?: { excludeFromContext?: boolean },
): Promise<BashResult> {
this._bashAbortController = new AbortController();
try {
@ -1415,6 +1420,7 @@ export class AgentSession {
truncated: result.truncated,
fullOutputPath: result.fullOutputPath,
timestamp: Date.now(),
excludeFromContext: options?.excludeFromContext,
};
// If agent is streaming, defer adding to avoid breaking tool_use/tool_result ordering