From 4c1d1fa49c59934b93a1d6271770caaf48e4d5ef Mon Sep 17 00:00:00 2001 From: alpha nerd Date: Wed, 13 May 2026 18:06:32 +0200 Subject: [PATCH] fix: added workflow instructions to the opencode prompt to not let opencode use git --- index.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/index.ts b/index.ts index 1997cd7..29b19f1 100644 --- a/index.ts +++ b/index.ts @@ -117,6 +117,13 @@ type IssueQueryResponse = { const HOST = "127.0.0.1" const PORT = 4096 +const WORKFLOW_INSTRUCTIONS = [ + "", + "You are running inside a Forgejo Actions workflow. The surrounding action handles all git write operations for you: staging changed files, creating the commit, pushing the branch, and opening the pull request.", + "Do NOT run git commit, git push, git tag, git reset, or any other git command that writes to history or the remote. You do not have credentials for the remote and any push will fail with 403, after which the branch only exists on the runner and is lost when the job ends.", + "Your job is only to read and edit files in the working tree. Leave changes uncommitted — the workflow will detect them via `git status` and commit/push them itself.", + "", +].join("\n") const SERVER_URL = `http://${HOST}:${PORT}` let proc: ReturnType | undefined let accessToken: string @@ -246,7 +253,7 @@ try { if (prData.head.repo?.full_name === prData.base.repo?.full_name) { await checkoutLocalBranch(prData) const dataPrompt = buildPromptDataForPR(prData) - const response = await chat(`${userPrompt}\n\n${dataPrompt}`, promptFiles) + const response = await chat(`${WORKFLOW_INSTRUCTIONS}\n\n${userPrompt}\n\n${dataPrompt}`, promptFiles) if (await branchIsDirty()) { const summary = await summarize(response) await pushToLocalBranch(summary) @@ -258,7 +265,7 @@ try { else { await checkoutForkBranch(prData) const dataPrompt = buildPromptDataForPR(prData) - const response = await chat(`${userPrompt}\n\n${dataPrompt}`, promptFiles) + const response = await chat(`${WORKFLOW_INSTRUCTIONS}\n\n${userPrompt}\n\n${dataPrompt}`, promptFiles) if (await branchIsDirty()) { const summary = await summarize(response) await pushToForkBranch(summary, prData) @@ -272,7 +279,7 @@ try { const branch = await checkoutNewBranch() const issueData = await fetchIssue() const dataPrompt = buildPromptDataForIssue(issueData) - const response = await chat(`${userPrompt}\n\n${dataPrompt}`, promptFiles) + const response = await chat(`${WORKFLOW_INSTRUCTIONS}\n\n${userPrompt}\n\n${dataPrompt}`, promptFiles) if (await branchIsDirty()) { const summary = await summarize(response) await pushToNewBranch(summary, branch)