Skip to content

Conversation

@CodinCat
Copy link
Contributor

@CodinCat CodinCat commented Jul 28, 2025

let me know if you want to merge this. I'll resolve the conflicts
and feel free to just close this PR if you don't want this to be added.


fix #919

Add the include_co_authored_by option. The behavior is copied from Claude Code.

When it's true (default) the prompt remains unchanged. I copied the original prompt and verified it with a temporary test:

test("bash.txt", () => {
  const bashTxtPath = join(process.cwd(), "packages/opencode/src/tool/bash-backup.txt")
  const currentContent = readFileSync(bashTxtPath, "utf-8")
  expect(replaceCoAuthoredMessage()).toBe(currentContent)
})

And this is how the three places look when it's false. This should be the same as Claude Code:

1
commit 1

2
commit 2

3
commit 3


actual usage:

true:
true

false:
false

const cfg = await Config.get()
const description = replaceCoAuthoredMessage(cfg.include_co_authored_by ?? true)
return {
description,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no changes below. just indentation.

the actual diff:
diff

Comment on lines +11 to +30
function replaceCoAuthoredMessage(includeCoAuthoredBy = true) {
if (!includeCoAuthoredBy) {
return DESCRIPTION.replace("${commitCoAuthored1}", ".")
.replace("${commitCoAuthored2}", "")
.replace("${prCoAuthored}", "")
}

const generatedWith = "🤖 Generated with [opencode](https://opencode.ai)"
const coAuthoredBy = `${generatedWith}
Co-Authored-By: opencode <[email protected]>`

const commitCoAuthored1 = ` ending with:\n ${coAuthoredBy}`
const commitCoAuthored2 = `\n\n ${coAuthoredBy}`
const prCoAuthored = `\n\n${generatedWith}`

return DESCRIPTION.replace("${commitCoAuthored1}", commitCoAuthored1)
.replace("${commitCoAuthored2}", commitCoAuthored2)
.replace("${prCoAuthored}", prCoAuthored)
}
Copy link

@samholmes samholmes Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I'd prefer the replacing technique where you section the cases out in the .txt file using some line deliminters

3. You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance. ALWAYS run the following commands in parallel:
   - Add relevant untracked files to the staging area.
<<with-co-author>>
   - Create the commit with a message ending with:
   🤖 Generated with [opencode](https://opencode.ai)

   Co-Authored-By: opencode <[email protected]>
<</with-co-author>>
<<without-co-author>>
   - Create the commit with a message
<</without-co-author>>
   - Run git status to make sure the commit succeeded.

Then some utilities can be written and tested for to keep/select/remove these sections.

Pros:

  • All of the text remains in the .txt file (not in the codebase)
  • Code handling these sections can be clear to understand given the utilities are defined

Cons:

  • A little more complexity and abstraction, but easily managed with some utility functions.

dbirks added a commit to dbirks/opencode that referenced this pull request Aug 6, 2025
Reference the original PR sst#1369 from sst/opencode that this implementation is based on, and remove internal implementation details from user-facing documentation.
Copy link

@dbirks dbirks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm this works nicely, thanks!

@samholmes
Copy link

Can confirm this works nicely, thanks!

An alternative implementation which leverages no custom templating system and instead opts in for using mustache: #1430

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disabling co-authoring.

3 participants