fix: harden default co-author opt-out and correct the docs

Follow-up on the co-author default in this PR.

- Remove the existsSync/writeFileSync race in the installer settings write
  (CodeQL js/file-system-race, high). A single guarded read now covers the
  fresh-install case, and unreadable or non-object settings are left untouched.
- Respect `attribution` as an explicit user choice. It supersedes
  `includeCoAuthoredBy` in Claude Code 2.1.x, so a user who configured it would
  otherwise have had a dead key written into their settings.
- Share one opt-out rule via scripts/lib/claude-commit-attribution.js instead of
  duplicating it across the installer and plugin setup.
- Update the git-workflow rule and its nine mirrors and translations, which
  still told users ECC does not ship this setting.

We keep writing the deprecated `includeCoAuthoredBy` key rather than
`attribution`: unknown keys fail Claude Code settings validation, so writing
`attribution` would break users on older versions.
This commit is contained in:
haelyra
2026-08-10 17:48:33 -04:00
parent ea8f984be9
commit 14809cae9b
16 changed files with 210 additions and 30 deletions
+6 -10
View File
@@ -5,6 +5,10 @@ const path = require('path');
const { spawnSync } = require('child_process');
const { writeFileAtomic } = require('./atomic-write');
const {
hasExplicitCommitAttributionPreference,
withCommitAttributionDisabled,
} = require('./claude-commit-attribution');
const { normalizeGitHubGitOrigin } = require('./github-origin');
const {
CURRENT_PLUGIN_ID,
@@ -18,7 +22,6 @@ const OFFICIAL_MARKETPLACE_NAME = 'ecc';
const OFFICIAL_MARKETPLACE_REPO = 'affaan-m/ecc';
const OFFICIAL_MARKETPLACE_URL = 'https://github.com/affaan-m/ECC';
const PROVIDER_COMMAND_TIMEOUT_MS = 120 * 1000;
const CLAUDE_COAUTHOR_SETTING_KEY = 'includeCoAuthoredBy';
const VALID_SCOPES = new Set(['user', 'project', 'local']);
const VALID_HOOK_MODES = new Set(['off', 'minimal', 'standard', 'strict']);
@@ -322,18 +325,11 @@ function deriveHookMode(settings) {
}
function withClaudeCommitAttributionPreference(settings) {
if (settings?.[CLAUDE_COAUTHOR_SETTING_KEY] === true) {
return settings;
}
return {
...settings,
[CLAUDE_COAUTHOR_SETTING_KEY]: false,
};
return withCommitAttributionDisabled(settings);
}
function needsClaudeCommitAttributionPreferenceWrite(settings) {
return settings?.[CLAUDE_COAUTHOR_SETTING_KEY] !== false
&& settings?.[CLAUDE_COAUTHOR_SETTING_KEY] !== true;
return !hasExplicitCommitAttributionPreference(settings);
}
function writeClaudePluginOptions(settingsPath, hooks) {