feat(agent): the agent's commits and pull requests carry no Claude credit by default (#2482)

feat(agent): Claude Code commits and pull requests carry no co-author or Claude Code credit by default
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-11 14:32:29 -05:00
1 parent 2426ea793a
commit 9d99232f99
4 files changed
+49 -1

No files matched your search

@@ -27,6 +27,8 @@ interface AgentHarness {
fun turn(message: String, conversation: String?, options: Options): List<String>
/** One line of the CLI's output, or null when it carries nothing to show. */
fun parse(line: String): AgentEvent?
/** Sets the CLI's own defaults in the userland before it runs; [rootfs] is the userland's root. */
fun prepare(rootfs: File) {}
data class Model(val id: String, val label: String)
@@ -59,6 +61,28 @@ object ClaudeCode : AgentHarness {
override val signIn = listOf(binary, "auth", "login", "--claudeai")
override val plans = true
/**
* Commits and pull requests the agent makes carry no Claude Code credit or co-author line by
* default. Only keys the user has not set are written, so their own choice stays.
*/
override fun prepare(rootfs: File) {
val file = File(rootfs, "root/.claude/settings.json")
val settings = if (file.exists()) runCatching { JSONObject(file.readText()) }.getOrNull() ?: return else JSONObject()
var changed = false
if (!settings.has("includeCoAuthoredBy")) {
settings.put("includeCoAuthoredBy", false)
changed = true
}
if (!settings.has("attribution")) {
settings.put("attribution", JSONObject().put("commit", "").put("pr", ""))
changed = true
}
if (changed) runCatching {
file.parentFile?.mkdirs()
file.writeText(settings.toString(2) + "\n")
}
}
override fun models(rootfs: File) = listOf(
AgentHarness.Model("opus", "Opus"), AgentHarness.Model("sonnet", "Sonnet"), AgentHarness.Model("haiku", "Haiku"),
)
@@ -55,7 +55,8 @@ object AgentHost {
"process of its own and shows the user its progress and time left; dd-lab-build follows that build's log until it is done. " +
"Run it with run_in_background and keep checking its output, so the user can talk to you meanwhile. " +
"The restart ends this process, and this conversation continues on the new build. " +
"Files the user attaches are listed at the end of their message, under /root/.cache/droiddeck/attachments."
"Files the user attaches are listed at the end of their message, under /root/.cache/droiddeck/attachments. " +
"Commits and pull requests you make are the user's own: add no co-author line, AI credit or generated-by note."
val entries = mutableStateListOf<Entry>()
val queue = mutableStateListOf<Queued>()
@@ -250,6 +251,7 @@ object AgentHost {
val command = current.turn(prompt, conversation, AgentHarness.Options(model, plan && current.plans, BRIEF))
val workdir = workspace(app)
Thread({
runCatching { current.prepare(LinuxRuntime.rootDir(app)) }
val child = try {
guest(app, command, workdir).start()
} catch (e: Exception) {
@@ -93,6 +93,7 @@ object AgentSetup {
Thread({
val result = runCatching {
installHelpers(app)
runCatching { harness.prepare(LinuxRuntime.rootDir(app)) }
val child = AgentHost.guest(app, command).start()
child.outputStream.close()
child.inputStream.bufferedReader().forEachLine { line ->
@@ -131,6 +131,27 @@ class AgentHostTest {
assertEquals("ls", shellCommand("ls"))
}
@Test fun claudeCodeDefaultsToNoAttributionAndKeepsTheUsersChoice() {
val root = Files.createTempDirectory("rootfs").toFile()
val settings = File(root, "root/.claude/settings.json")
ClaudeCode.prepare(root)
val written = org.json.JSONObject(settings.readText())
assertEquals(false, written.getBoolean("includeCoAuthoredBy"))
assertEquals("", written.getJSONObject("attribution").getString("commit"))
assertEquals("", written.getJSONObject("attribution").getString("pr"))
settings.writeText("""{"includeCoAuthoredBy":true,"model":"opus"}""")
ClaudeCode.prepare(root)
val kept = org.json.JSONObject(settings.readText())
assertEquals(true, kept.getBoolean("includeCoAuthoredBy"))
assertEquals("opus", kept.getString("model"))
assertTrue(kept.has("attribution"))
settings.writeText("not json")
ClaudeCode.prepare(root)
assertEquals("not json", settings.readText())
}
@Test fun aTurnWithoutAnEndWasInterrupted() {
assertTrue(AgentHost.interrupted(listOf(Entry.Asked("hi"), Entry.Used("1", "Bash", "dd-lab-build"))))
assertEquals(false, AgentHost.interrupted(listOf(Entry.Asked("hi"), Entry.Finished(null))))