From 9cce68d82090e972ac773f047fa807bc0ffaea60 Mon Sep 17 00:00:00 2001 From: Gab Date: Wed, 25 Mar 2026 21:14:19 +1100 Subject: [PATCH] feat: opencode --- .../tfcode/src/session/prompt/anthropic.txt | 2 +- packages/tfcode/src/session/prompt/codex.txt | 2 +- .../tfcode/src/session/prompt/default.txt | 2 +- packages/tfcode/src/session/prompt/gemini.txt | 2 +- .../tfcode/src/session/prompt/trinity.txt | 2 +- packages/tfcode/src/tool/read.ts | 24 +++++++++++++++++++ 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/packages/tfcode/src/session/prompt/anthropic.txt b/packages/tfcode/src/session/prompt/anthropic.txt index 21d9c0e9f..94e2a3fba 100644 --- a/packages/tfcode/src/session/prompt/anthropic.txt +++ b/packages/tfcode/src/session/prompt/anthropic.txt @@ -1,4 +1,4 @@ -You are OpenCode, the best coding agent on the planet. +You are TF Code, the best coding agent on the planet, created by ToothFairyAI. You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user. diff --git a/packages/tfcode/src/session/prompt/codex.txt b/packages/tfcode/src/session/prompt/codex.txt index d595cadb0..198c39330 100644 --- a/packages/tfcode/src/session/prompt/codex.txt +++ b/packages/tfcode/src/session/prompt/codex.txt @@ -1,4 +1,4 @@ -You are OpenCode, the best coding agent on the planet. +You are TF Code, the best coding agent on the planet, created by ToothFairyAI. You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user. diff --git a/packages/tfcode/src/session/prompt/default.txt b/packages/tfcode/src/session/prompt/default.txt index 3d65ac405..31afea0a2 100644 --- a/packages/tfcode/src/session/prompt/default.txt +++ b/packages/tfcode/src/session/prompt/default.txt @@ -1,4 +1,4 @@ -You are TF Code (also referred to as tfcode), an interactive CLI tool that helps users with software engineering tasks. Users may refer to you as "TF Code", "tfcode", or both interchangeably. Use the instructions below and the tools available to you to assist the user. +You are TF Code (also referred to as tfcode), an interactive CLI tool from ToothFairyAI that helps users with software engineering tasks. Users may refer to you as "TF Code", "tfcode", or both interchangeably. Use the instructions below and the tools available to you to assist the user. IMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files. diff --git a/packages/tfcode/src/session/prompt/gemini.txt b/packages/tfcode/src/session/prompt/gemini.txt index 87fe422bc..ffdb389ed 100644 --- a/packages/tfcode/src/session/prompt/gemini.txt +++ b/packages/tfcode/src/session/prompt/gemini.txt @@ -1,4 +1,4 @@ -You are opencode, an interactive CLI agent specializing in software engineering tasks. Your primary goal is to help users safely and efficiently, adhering strictly to the following instructions and utilizing your available tools. +You are TF Code, an interactive CLI agent from ToothFairyAI specializing in software engineering tasks. Your primary goal is to help users safely and efficiently, adhering strictly to the following instructions and utilizing your available tools. # Core Mandates diff --git a/packages/tfcode/src/session/prompt/trinity.txt b/packages/tfcode/src/session/prompt/trinity.txt index 28ee4c4f2..7f3a5ebb9 100644 --- a/packages/tfcode/src/session/prompt/trinity.txt +++ b/packages/tfcode/src/session/prompt/trinity.txt @@ -1,4 +1,4 @@ -You are opencode, an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user. +You are TF Code, an interactive CLI tool from ToothFairyAI that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user. # Tone and style You should be concise, direct, and to the point. When you run a non-trivial bash command, you should explain what the command does and why you are running it, to make sure the user understands what you are doing (this is especially important when you are running a command that will make changes to the user's system). diff --git a/packages/tfcode/src/tool/read.ts b/packages/tfcode/src/tool/read.ts index 85be8f9d3..f9ddedbb1 100644 --- a/packages/tfcode/src/tool/read.ts +++ b/packages/tfcode/src/tool/read.ts @@ -18,6 +18,8 @@ const MAX_LINE_SUFFIX = `... (line truncated to ${MAX_LINE_LENGTH} chars)` const MAX_BYTES = 50 * 1024 const MAX_BYTES_LABEL = `${MAX_BYTES / 1024} KB` +const readCount = Instance.state(() => new Map()) + export const ReadTool = Tool.define("read", { description: DESCRIPTION, parameters: z.object({ @@ -216,6 +218,28 @@ export const ReadTool = Tool.define("read", { LSP.touchFile(filepath, false) await FileTime.read(ctx.sessionID, filepath) + // Track read count and warn about verification loops + const counts = readCount() + const key = filepath + const count = (counts.get(key) ?? 0) + 1 + counts.set(key, count) + + if (count >= 3) { + const warning = + count === 3 + ? `\n\n +⚠️ WARNING: You have read this file ${count} times in this session. This indicates a verification loop. +Your previous edits to this file have been applied successfully. Do NOT read this file again to "verify" - +this wastes tokens and creates unnecessary loops. Trust your changes and proceed with the task. +` + : `\n\n +🛑 STOP: You have read this file ${count} times. This is a verification loop. +Reading the same file repeatedly wastes tokens. Your edits ARE applied. +PROCEED with the task or ask the user for guidance. Do NOT read this file again. +` + output += warning + } + if (instructions.length > 0) { output += `\n\n\n${instructions.map((i) => i.content).join("\n\n")}\n` }