openpencil/commitlint.config.ts
Danila Poyarkov 2eef5610d8 ci: keep AI disclosure out of co-author credits
Welcome AI-assisted contributions while reserving co-author trailers for human credit. Reuse commitlint and Git trailer parsing to reject known assistant identities in new commits without altering existing history or legitimate credits.
2026-09-15 23:12:44 +03:00

32 lines
1.1 KiB
TypeScript

import isIgnored from '@commitlint/is-ignored'
import type { UserConfig } from '@commitlint/types'
import { hasAICoauthor, noAICoauthors } from './tools/ci/src/commit-attribution'
export default {
extends: ['@commitlint/config-conventional'],
// Apply attribution policy before allowing generated-message or release exceptions.
defaultIgnores: false,
plugins: [{ rules: { 'no-ai-coauthors': noAICoauthors } }],
rules: {
'no-ai-coauthors': [2, 'always'],
'type-enum': [
2,
'always',
['feat', 'fix', 'refactor', 'perf', 'docs', 'test', 'build', 'ci', 'chore']
],
// Product names such as MCP, DOM/CSS, and Kiwi retain their casing.
'subject-case': [0],
'scope-case': [0],
'body-max-line-length': [0],
'footer-max-line-length': [0]
},
ignores: [
(message) =>
!hasAICoauthor(message) &&
(/^Release v\d+\.\d+\.\d+$/.test(message.split('\n')[0] ?? '') ||
(process.env.COMMITLINT_PR_TITLE !== '1' && isIgnored(message)))
],
helpUrl: 'https://github.com/open-pencil/open-pencil/blob/master/CONTRIBUTING.md#commit-messages'
} satisfies UserConfig