From d0ee2ca784f55bfef3a826d536e22570dadaf36a Mon Sep 17 00:00:00 2001 From: "melodic-automation-lanes[bot]" <337595936+melodic-automation-lanes[bot]@users.noreply.github.com> Date: Sun, 22 Nov 2026 04:33:12 +0000 Subject: [PATCH 1/4] Resolve issue #18000 Lane-Activity: work-resolve-issue/resolve-issue --- ...ssue-issue-18000-44983079501-1-2c221d7b.md | 5 + ...ssue-issue-18000-44983079501-1-3e41146d.md | 12 + lib/resolve-convention-pattern.sh | 12 +- .../hooks/resolve-convention-pattern.sh | 12 +- plugins/source-control/README.md | 8 +- .../prompt.md | 4 +- .../samples/ignore-rule-fail.json | 6 +- .../samples/no-shell-gitignore-write.json | 6 +- .../scaffold.sh | 3 - .../graders/no-personal-override-written.md | 2 +- .../prompt.md | 4 +- .../samples/no-personal-override-written.json | 4 +- .../samples/team-file-written.json | 2 +- .../scaffold.sh | 5 +- plugins/source-control/lib/convention-key.sh | 26 ++- .../reference/config-resolution.md | 87 ++++--- .../skills/babysit-loop/SKILL.md | 2 +- .../skills/babysit-loop/evals/evals.json | 2 +- plugins/source-control/skills/commit/SKILL.md | 32 ++- .../conventions/source-control.local.yaml | 2 + .../skills/commit/evals/evals.json | 6 +- .../skills/commit/reference/config-probes.md | 14 +- .../skills/pull-request/evals/evals.json | 10 +- .../skills/pull-request/reference/create.md | 2 +- .../scripts/parse-branch-issue.sh | 44 ++-- .../scripts/parse-branch-issue.test.sh | 102 +++++++- plugins/source-control/skills/setup/SKILL.md | 80 ++++--- .../conventions/source-control.local.yaml | 1 + .../skills/setup/evals/evals.json | 53 ++--- .../setup/reference/apply-convention.md | 218 ++++++++---------- 30 files changed, 459 insertions(+), 307 deletions(-) create mode 100644 .changes/guardrails/work-resolve-issue-issue-18000-44983079501-1-2c221d7b.md create mode 100644 .changes/source-control/work-resolve-issue-issue-18000-44983079501-1-3e41146d.md create mode 100644 plugins/source-control/skills/commit/evals/docs/conventions/source-control.local.yaml create mode 100644 plugins/source-control/skills/setup/evals/docs/conventions/source-control.local.yaml diff --git a/.changes/guardrails/work-resolve-issue-issue-18000-44983079501-1-2c221d7b.md b/.changes/guardrails/work-resolve-issue-issue-18000-44983079501-1-2c221d7b.md new file mode 100644 index 00000000000..d5ec927cf76 --- /dev/null +++ b/.changes/guardrails/work-resolve-issue-issue-18000-44983079501-1-2c221d7b.md @@ -0,0 +1,5 @@ +--- +bump: none +--- + +Only a comment in the synced copy of `lib/resolve-convention-pattern.sh` changed, naming source-control's drafting layers after their move ([#18000](https://github.com/melodic-software/claude-code-plugins/issues/18000)); enforcement behavior is unchanged. diff --git a/.changes/source-control/work-resolve-issue-issue-18000-44983079501-1-3e41146d.md b/.changes/source-control/work-resolve-issue-issue-18000-44983079501-1-3e41146d.md new file mode 100644 index 00000000000..857d1cbea86 --- /dev/null +++ b/.changes/source-control/work-resolve-issue-issue-18000-44983079501-1-3e41146d.md @@ -0,0 +1,12 @@ +--- +bump: minor +--- + +### Changed + +- **Convention config lives at the config-cascade layers.** The personal override is now `docs/conventions/source-control.local.yaml`, the same YAML keys as the team file `docs/conventions/source-control.yaml`, and wins over it key by key. `parse-branch-issue.sh`, `/source-control:commit`, `/source-control:pull-request create` and `/source-control:setup` read it, and `lib/convention-key.sh` gains `local-value`, `local-list` and `old-files`. There is no user-global file layer and no new `userConfig` option: `setup apply layer=user` is refused, `layer=local` writes the YAML, and the ignore line setup appends at team bind is `docs/conventions/**/*.local.*` ([#18000](https://github.com/melodic-software/claude-code-plugins/issues/18000)). +- **Old paths are still read, with a warning.** While `~/.claude/source-control.md` exists it is read below the team layer, and `.claude/source-control.local.md` is read as the personal override while the personal YAML is absent; beside it, the old file is not read. Each run of `parse-branch-issue.sh` prints one `old location` note per old file, naming it, its new location and `/source-control:setup apply`. + +### Added + +- **`/source-control:setup` moves old-location config.** `check` names each old file with the keys it still supplies; `apply` previews where each key goes and, after a yes, copies the keys into the new file, checks the new file resolves the same values, then deletes the old file. diff --git a/lib/resolve-convention-pattern.sh b/lib/resolve-convention-pattern.sh index 5c5940ba8f0..bdac8500276 100755 --- a/lib/resolve-convention-pattern.sh +++ b/lib/resolve-convention-pattern.sh @@ -27,12 +27,12 @@ # launcher. It runs the same under bash. # # ENFORCEMENT ≠ DRAFTING — the policy-floor contract: -# Enforcement reads the TEAM-TRACKED layer: the files above. The user-global -# (`~/.claude/source-control.md`) and gitignored local -# (`.claude/source-control.local.md`) personal overrides are DRAFTING inputs the model -# merges per `reference/config-resolution.md`; a blocking gate never reads -# them. "Is regex A stricter than B" is undecidable, so no merge of a personal -# pattern with a team one could honor "tighten only". +# Enforcement reads the TEAM-TRACKED layer: the files above. The drafting +# layers the model merges per `reference/config-resolution.md` (the personal +# override, plus the two old locations still read during the dual-read +# window) are never merged here. "Is regex A stricter than B" is undecidable, +# so no merge of a personal pattern with a team one could honor "tighten only" +# (https://github.com/melodic-software/claude-code-plugins/blob/main/docs/contracts/commit-convention/README.md). # # THE PERSONAL LAYER IS FALLBACK-ONLY: `subject_pattern` in # `docs/conventions/source-control.local.yaml` (ADR 0075's diff --git a/plugins/guardrails/hooks/resolve-convention-pattern.sh b/plugins/guardrails/hooks/resolve-convention-pattern.sh index a99b97e048e..4e51dc870cf 100755 --- a/plugins/guardrails/hooks/resolve-convention-pattern.sh +++ b/plugins/guardrails/hooks/resolve-convention-pattern.sh @@ -29,12 +29,12 @@ # launcher. It runs the same under bash. # # ENFORCEMENT ≠ DRAFTING — the policy-floor contract: -# Enforcement reads the TEAM-TRACKED layer: the files above. The user-global -# (`~/.claude/source-control.md`) and gitignored local -# (`.claude/source-control.local.md`) personal overrides are DRAFTING inputs the model -# merges per `reference/config-resolution.md`; a blocking gate never reads -# them. "Is regex A stricter than B" is undecidable, so no merge of a personal -# pattern with a team one could honor "tighten only". +# Enforcement reads the TEAM-TRACKED layer: the files above. The drafting +# layers the model merges per `reference/config-resolution.md` (the personal +# override, plus the two old locations still read during the dual-read +# window) are never merged here. "Is regex A stricter than B" is undecidable, +# so no merge of a personal pattern with a team one could honor "tighten only" +# (https://github.com/melodic-software/claude-code-plugins/blob/main/docs/contracts/commit-convention/README.md). # # THE PERSONAL LAYER IS FALLBACK-ONLY: `subject_pattern` in # `docs/conventions/source-control.local.yaml` (ADR 0075's diff --git a/plugins/source-control/README.md b/plugins/source-control/README.md index 00a2b970814..fed9f6db573 100644 --- a/plugins/source-control/README.md +++ b/plugins/source-control/README.md @@ -368,9 +368,11 @@ see [hooks: WorktreeRemove](https://code.claude.com/docs/en/hooks#worktreeremove on a missing tool. - **Reads your conventions, assumes none.** Commit-subject / PR-title convention resolves from the layered source-control config (written by - `/source-control:setup`) first, a `~/.claude` user-global file, the tracked - team file `docs/conventions/source-control.yaml`, and a gitignored `.claude/source-control.local.md` personal - override, merged per key, then the consuming project's own + `/source-control:setup`) first, the tracked team file + `docs/conventions/source-control.yaml` and a gitignored + `docs/conventions/source-control.local.yaml` personal override, merged per key + (`~/.claude/source-control.md` and `.claude/source-control.local.md` are still + read, with a warning, until `/source-control:setup apply` moves them), then the consuming project's own `CLAUDE.md`, rules, and hooks; branch naming, PR template, merge style, and bot-identity wrappers also come from the project's own `CLAUDE.md` and rules. Defaults (Conventional Commits, squash merge) apply only when the diff --git a/plugins/source-control/evals/setup-check-reports-team-layer-and-ignore-gap/prompt.md b/plugins/source-control/evals/setup-check-reports-team-layer-and-ignore-gap/prompt.md index 3da7049bce3..09c370600be 100644 --- a/plugins/source-control/evals/setup-check-reports-team-layer-and-ignore-gap/prompt.md +++ b/plugins/source-control/evals/setup-check-reports-team-layer-and-ignore-gap/prompt.md @@ -1,10 +1,10 @@ --- -description: "Explicit check in a git repository whose tracked docs/conventions/source-control.yaml sets subject_pattern '^[A-Z]+-\\d+: .+', with no .gitignore. setup SKILL.md check (Convention config): read all three layers and report one effective-configuration table naming the layer that won each key, so subject_pattern resolves to the team value won by team; probe the recursive .claude/**/*.local.* ignore rule whether or not a personal override exists, and report it missing as FAIL; per key, run the bundled lib/convention-key.sh, and confirm branch_issue_pattern through the bundled parse-branch-issue.sh; modify nothing (the .gitignore line is apply's write, never check's). ran-bundled-probe is a with-only indicator: those scripts ship only with the plugin. No grader reads the babysit probes, whose forge, auto-mode and GraphQL answers depend on the host. The setup skill is disable-model-invocation and the prompt invokes it by slash command, so no Skill tool call is graded. Needs --scaffold --allow-tools Bash Write Edit (Write and Edit are granted so the must-not graders can fail)." +description: "Explicit check in a git repository whose tracked docs/conventions/source-control.yaml sets subject_pattern '^[A-Z]+-\\d+: .+', with no .gitignore. setup SKILL.md check (Convention config): read both layers and any old location and report one effective-configuration table naming the layer that won each key, so subject_pattern resolves to the team value won by team; probe the recursive docs/conventions/**/*.local.* ignore rule (nested sentinel docs/conventions/nested/personal-override.local.yaml) whether or not a personal override exists, and report it missing as FAIL; per key, run the bundled lib/convention-key.sh, and confirm branch_issue_pattern through the bundled parse-branch-issue.sh; modify nothing (the .gitignore line is apply's write, never check's). ran-bundled-probe is a with-only indicator: those scripts ship only with the plugin. No grader reads the babysit probes, whose forge, auto-mode and GraphQL answers depend on the host. The setup skill is disable-model-invocation and the prompt invokes it by slash command, so no Skill tool call is graded. Needs --scaffold --allow-tools Bash Write Edit (Write and Edit are granted so the must-not graders can fail)." tags: ['source-control', 'setup', 'check', 'read-only'] max_turns: 30 timeout_seconds: 600 allowed_tools: [Read, Glob, Grep, Skill, Bash, Write, Edit] -expected_outcome: 'Reports subject_pattern ^[A-Z]+-\d+: .+ won by team and the missing .claude/**/*.local.* ignore rule as FAIL, running the bundled convention-key.sh or parse-branch-issue.sh; never writes .gitignore or any other file and edits nothing.' +expected_outcome: 'Reports subject_pattern ^[A-Z]+-\d+: .+ won by team and the missing docs/conventions/**/*.local.* ignore rule as FAIL, running the bundled convention-key.sh or parse-branch-issue.sh; never writes .gitignore or any other file and edits nothing.' --- /source-control:setup check diff --git a/plugins/source-control/evals/setup-check-reports-team-layer-and-ignore-gap/samples/ignore-rule-fail.json b/plugins/source-control/evals/setup-check-reports-team-layer-and-ignore-gap/samples/ignore-rule-fail.json index a6c699000b7..a9d3ecc6197 100644 --- a/plugins/source-control/evals/setup-check-reports-team-layer-and-ignore-gap/samples/ignore-rule-fail.json +++ b/plugins/source-control/evals/setup-check-reports-team-layer-and-ignore-gap/samples/ignore-rule-fail.json @@ -1,16 +1,16 @@ { "pass": [ { - "answer": "| Personal override ignore rule | FAIL | no repository .gitignore covers `.claude/**/*.local.*`; run `apply` |" + "answer": "| Personal override ignore rule | FAIL | no repository .gitignore covers `docs/conventions/**/*.local.*`; run `apply` |" }, { - "answer": "FAIL: the recursive `.claude/**/*.local.*` rule is missing.", + "answer": "FAIL: the recursive `docs/conventions/**/*.local.*` rule is missing.", "why": "FAIL first" } ], "fail": [ { - "answer": "| Personal override ignore rule | PASS | `.gitignore:1:.claude/**/*.local.*` |", + "answer": "| Personal override ignore rule | PASS | `.gitignore:1:docs/conventions/**/*.local.*` |", "why": "wrong: reports the rule present" }, { diff --git a/plugins/source-control/evals/setup-check-reports-team-layer-and-ignore-gap/samples/no-shell-gitignore-write.json b/plugins/source-control/evals/setup-check-reports-team-layer-and-ignore-gap/samples/no-shell-gitignore-write.json index 878fca345e5..4824fa87472 100644 --- a/plugins/source-control/evals/setup-check-reports-team-layer-and-ignore-gap/samples/no-shell-gitignore-write.json +++ b/plugins/source-control/evals/setup-check-reports-team-layer-and-ignore-gap/samples/no-shell-gitignore-write.json @@ -5,7 +5,7 @@ { "tool": "Bash", "input": { - "command": "git check-ignore -v .claude/multi-agent.local.yaml" + "command": "git check-ignore --no-index -v -- docs/conventions/nested/personal-override.local.yaml" } } ], @@ -29,7 +29,7 @@ { "tool": "Bash", "input": { - "command": "printf '.claude/**/*.local.*\\n' >> .gitignore" + "command": "printf 'docs/conventions/**/*.local.*\\n' >> .gitignore" } } ], @@ -40,7 +40,7 @@ { "tool": "Bash", "input": { - "command": "echo '.claude/**/*.local.*' | tee -a .gitignore" + "command": "echo 'docs/conventions/**/*.local.*' | tee -a .gitignore" } } ], diff --git a/plugins/source-control/evals/setup-check-reports-team-layer-and-ignore-gap/scaffold.sh b/plugins/source-control/evals/setup-check-reports-team-layer-and-ignore-gap/scaffold.sh index b1c593a28c6..7bd1d2c3281 100755 --- a/plugins/source-control/evals/setup-check-reports-team-layer-and-ignore-gap/scaffold.sh +++ b/plugins/source-control/evals/setup-check-reports-team-layer-and-ignore-gap/scaffold.sh @@ -1,7 +1,4 @@ #!/usr/bin/env bash -# A git repository whose tracked team file declares a ticket-prefixed subject_pattern, with no -# .gitignore, so check resolves the pattern from the team layer and the recursive -# .claude/**/*.local.* ignore rule is missing. set -euo pipefail git init -q -b main git config core.excludesFile /dev/null diff --git a/plugins/source-control/evals/setup-writes-only-confirmed-change/graders/no-personal-override-written.md b/plugins/source-control/evals/setup-writes-only-confirmed-change/graders/no-personal-override-written.md index 458e678a7e3..bd9fb41690b 100644 --- a/plugins/source-control/evals/setup-writes-only-confirmed-change/graders/no-personal-override-written.md +++ b/plugins/source-control/evals/setup-writes-only-confirmed-change/graders/no-personal-override-written.md @@ -1,6 +1,6 @@ --- type: file_exists -path: .claude/source-control.local.md +path: docs/conventions/source-control.local.yaml exists: false arm: both --- diff --git a/plugins/source-control/evals/setup-writes-only-confirmed-change/prompt.md b/plugins/source-control/evals/setup-writes-only-confirmed-change/prompt.md index b0ffb1d7b9d..5618b47be17 100644 --- a/plugins/source-control/evals/setup-writes-only-confirmed-change/prompt.md +++ b/plugins/source-control/evals/setup-writes-only-confirmed-change/prompt.md @@ -4,9 +4,9 @@ tags: [setup, source-control] runs: 3 max_turns: 30 allowed_tools: [Read, Glob, Grep, Skill, Bash, Write, Edit] -expected_outcome: "docs/conventions/source-control.yaml exists with the ticket-prefixed convention; .claude/source-control.local.md and docs/conventions/source-control/commit-convention.yml were never written" +expected_outcome: "docs/conventions/source-control.yaml exists with the ticket-prefixed convention; docs/conventions/source-control.local.yaml and docs/conventions/source-control/commit-convention.yml were never written" --- /source-control:setup apply layer=team -I am answering the interview up front, so do not ask me anything. Our team convention is ticket-prefixed subjects, `^[A-Z]+-\d+: .+`, and I confirm you write that to the team file `docs/conventions/source-control.yaml`. I decline two other changes: do not create a personal override at `.claude/source-control.local.md`, and do not create the neutral convention file `docs/conventions/source-control/commit-convention.yml`. Write nothing else apart from the team file. +I am answering the interview up front, so do not ask me anything. Our team convention is ticket-prefixed subjects, `^[A-Z]+-\d+: .+`, and I confirm you write that to the team file `docs/conventions/source-control.yaml`. I decline two other changes: do not create a personal override at `docs/conventions/source-control.local.yaml`, and do not create the neutral convention file `docs/conventions/source-control/commit-convention.yml`. Write nothing else apart from the team file. diff --git a/plugins/source-control/evals/setup-writes-only-confirmed-change/samples/no-personal-override-written.json b/plugins/source-control/evals/setup-writes-only-confirmed-change/samples/no-personal-override-written.json index c086b92ec7a..6d87a1b4090 100644 --- a/plugins/source-control/evals/setup-writes-only-confirmed-change/samples/no-personal-override-written.json +++ b/plugins/source-control/evals/setup-writes-only-confirmed-change/samples/no-personal-override-written.json @@ -5,7 +5,7 @@ {"answer": [".claude/source-control.md"], "why": "a different, non-local path"} ], "fail": [ - {"answer": [".claude/source-control.local.md"], "why": "the declined personal override"}, - {"answer": ["docs/conventions/source-control.yaml", ".claude/source-control.local.md"], "why": "the team file plus the declined personal override"} + {"answer": ["docs/conventions/source-control.local.yaml"], "why": "the declined personal override"}, + {"answer": ["docs/conventions/source-control.yaml", "docs/conventions/source-control.local.yaml"], "why": "the team file plus the declined personal override"} ] } diff --git a/plugins/source-control/evals/setup-writes-only-confirmed-change/samples/team-file-written.json b/plugins/source-control/evals/setup-writes-only-confirmed-change/samples/team-file-written.json index 5be4d98432a..74c5cb10033 100644 --- a/plugins/source-control/evals/setup-writes-only-confirmed-change/samples/team-file-written.json +++ b/plugins/source-control/evals/setup-writes-only-confirmed-change/samples/team-file-written.json @@ -6,7 +6,7 @@ "fail": [ {"answer": []}, {"answer": ["docs/conventions/source-control.yml"], "why": "near miss: .yml, not the confirmed .yaml"}, - {"answer": [".claude/source-control.local.md"], "why": "the declined personal override instead of the team file"}, + {"answer": ["docs/conventions/source-control.local.yaml"], "why": "the declined personal override instead of the team file"}, {"answer": ["docs/conventions/source-control/commit-convention.yml"], "why": "the declined neutral file instead of the team file"} ] } diff --git a/plugins/source-control/evals/setup-writes-only-confirmed-change/scaffold.sh b/plugins/source-control/evals/setup-writes-only-confirmed-change/scaffold.sh index 8124a67d1b5..dba79da6b07 100755 --- a/plugins/source-control/evals/setup-writes-only-confirmed-change/scaffold.sh +++ b/plugins/source-control/evals/setup-writes-only-confirmed-change/scaffold.sh @@ -1,13 +1,10 @@ #!/usr/bin/env bash -# Seeds the eval workspace with a git repo that has no source-control config at any layer: one commit -# on main, and the recursive .claude/**/*.local.* ignore rule already in place so apply has no -# .gitignore edit of its own to make. set -euo pipefail git init -q -b main git config user.name eval git config user.email eval@example.invalid -printf '.claude/**/*.local.*\n' > .gitignore +printf 'docs/conventions/**/*.local.*\n' > .gitignore printf '# demo\n' > README.md git add .gitignore README.md git commit -q -m "WEB-101: seed" diff --git a/plugins/source-control/lib/convention-key.sh b/plugins/source-control/lib/convention-key.sh index de551025060..c11a34693a6 100755 --- a/plugins/source-control/lib/convention-key.sh +++ b/plugins/source-control/lib/convention-key.sh @@ -27,6 +27,8 @@ # lower layer past a broken team file. CONVENTION_KEY_YAML_REL="docs/conventions/source-control.yaml" +CONVENTION_KEY_LOCAL_REL="docs/conventions/source-control.local.yaml" +CONVENTION_KEY_OLD_LOCAL_REL=".claude/source-control.local.md" CONVENTION_KEY_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # True when git tracks the repo-relative file REL under ROOT. An untracked or @@ -39,7 +41,7 @@ convention_key_tracked() { # when the file is absent. Returns 3 when the parser rejects the file; a key # repeated in one mapping is a rejection too. convention_key_records() { - local file="$1/$CONVENTION_KEY_YAML_REL" text + local file="$1/${2:-$CONVENTION_KEY_YAML_REL}" text [[ -f "$file" ]] || return 0 text="$(<"$file")" LC_ALL=C awk -v STRICT=1 -f "$CONVENTION_KEY_DIR/yaml-subset.awk" <<<"$text" 2>/dev/null || return 3 @@ -47,18 +49,29 @@ convention_key_records() { # Print the value of KEY from the team YAML under ROOT, or nothing. convention_key_yaml_value() { - local records - records="$(convention_key_records "$1")" || return 3 + local records other_yaml_rel="${3:-}" + records="$(convention_key_records "$1" "$other_yaml_rel")" || return 3 PCV_KEY="$2" LC_ALL=C awk -F '\t' '$1 == ENVIRON["PCV_KEY"] && !seen++ { print substr($0, length($1) + 2) }' <<<"$records" } # Print the scalar items of the sequence KEY in the team YAML, one per line. convention_key_yaml_list() { local records - records="$(convention_key_records "$1")" || return 3 + records="$(convention_key_records "$1" "${3:-}")" || return 3 PCV_KEY="$2" LC_ALL=C awk -F '\t' 'index($1, ENVIRON["PCV_KEY"] ".") == 1 && substr($1, length(ENVIRON["PCV_KEY"]) + 2) ~ /^[0-9]+$/ { print substr($0, length($1) + 2) }' <<<"$records" } +convention_key_old_files() { + local repo_root_or_empty="$1" user="${HOME:-}/.claude/source-control.md" + local root="$repo_root_or_empty" + if [[ -n "$root" && -f "$root/$CONVENTION_KEY_OLD_LOCAL_REL" ]]; then + printf '%s\t%s\n' "$root/$CONVENTION_KEY_OLD_LOCAL_REL" "$CONVENTION_KEY_LOCAL_REL" + fi + if [[ -n "${HOME:-}" && -f "$user" ]]; then + printf '%s\t%s\n' "$user" "$CONVENTION_KEY_YAML_REL (team) or $CONVENTION_KEY_LOCAL_REL (personal), in each repository that needs it" + fi +} + # True when the team YAML carries KEY, as a scalar or as a non-empty list. convention_key_yaml_has() { local root="$1" key="$2" scalar items @@ -83,8 +96,11 @@ if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then layer) convention_key_layer "${2:?root}" "${3:?key}" ;; value) convention_key_yaml_value "${2:?root}" "${3:?key}" ;; list) convention_key_yaml_list "${2:?root}" "${3:?key}" ;; + local-value) convention_key_yaml_value "${2:?root}" "${3:?key}" "$CONVENTION_KEY_LOCAL_REL" ;; + local-list) convention_key_yaml_list "${2:?root}" "${3:?key}" "$CONVENTION_KEY_LOCAL_REL" ;; + old-files) convention_key_old_files "${2-}" ;; *) - echo "usage: bash convention-key.sh layer|value|list ROOT KEY" >&2 + echo "usage: bash convention-key.sh layer|value|list|local-value|local-list ROOT KEY | old-files ROOT" >&2 exit 2 ;; esac diff --git a/plugins/source-control/reference/config-resolution.md b/plugins/source-control/reference/config-resolution.md index fe10e683c94..8bc0d829278 100644 --- a/plugins/source-control/reference/config-resolution.md +++ b/plugins/source-control/reference/config-resolution.md @@ -35,12 +35,14 @@ Implements the tracked-rich-config extensibility contract in ([ADR 0064](https://raw.githubusercontent.com/melodic-software/claude-code-plugins/main/docs/adr/0064-home-plugin-customization-in-docs-conventions-yaml.md)). The retired team file `.claude/source-control.md` is not read; `/source-control:setup check` names it when it is still tracked. A YAML the shared reader rejects stops the lookup for that key instead -of falling back to a lower layer. The personal override and the user-global file stay -markdown and keep their place in +of falling back to a lower layer. The personal override is +`docs/conventions/source-control.local.yaml`, the same keys in the same YAML shape; the two old +markdown locations are still read during the dual-read window in [The three layers](#the-three-layers). Every resolver reports the layer that supplied a value: -`docs/conventions/source-control.yaml`, the personal override, the -user-global file, `userConfig`, or the default. `lib/convention-key.sh` is the reader -(`layer ROOT KEY` prints `yaml` or `none`; `value` and `list` print the YAML value), and +`docs/conventions/source-control.yaml`, the personal override, an old location, `userConfig`, or +the default. `lib/convention-key.sh` is the reader (`layer ROOT KEY` prints `yaml` or `none`; +`value` and `list` print the team YAML value, `local-value` and `local-list` the personal YAML +value, and `old-files ROOT` lists each old-location file present with where it moves), and `parse-branch-issue.sh --explain` prints the layer for `branch_issue_pattern`. **Team-layer home of the loop-lane and babysit-prs keys.** Every `babysit_loop_*` key and the seven @@ -58,12 +60,12 @@ pr_body_required_sections: branch_issue_pattern: '^[^/]+/([0-9]+)-' ``` -The sections below describe each key's value grammar; read "H2" there as "the key in the YAML, or -its `## ` H2 in the personal override or user-global file". A list value is a YAML sequence in the YAML -and a bullet list in the H2. +The sections below describe each key's value grammar; read "H2" there as "the key in a YAML +layer, or its `## ` H2 in an old markdown location". A list value is a YAML sequence in a YAML +layer and a bullet list in the H2. -The personal override and the user-global file are Markdown: one `## ` H2 per key, -the value as the section body. Seven babysit-prs +The two old locations are Markdown: one `## ` H2 per key, the value as the section body. +Seven babysit-prs repository-policy keys (`babysit_merge_method`, `babysit_merge_block_labels`, `babysit_extra_dependency_manager_logins`, `babysit_approval_downgrade_logins`, `babysit_skip_downgrade_logins`, `babysit_review_gate_context`, @@ -441,8 +443,8 @@ lane with a per-domain `--settings` file. Which keys stay in [0039-keep-babysit-identity-keys-in-userconfig-and-move-repository-keys-to-the-cascade.md](https://raw.githubusercontent.com/melodic-software/claude-code-plugins/main/docs/adr/0039-keep-babysit-identity-keys-in-userconfig-and-move-repository-keys-to-the-cascade.md). Loop keys carry the `babysit_loop_` prefix so the two key families sharing one file stay distinguishable. -In the personal override and the user-global file, one `## ` H2 per key, exactly -like the convention keys above. Every value is a scalar except +In the personal YAML a loop key is a YAML key, and in an old markdown location one `## ` H2 +per key, exactly like the convention keys above. Every value is a scalar except `babysit_loop_trusted_internal_bot_logins`, a closed list like `pr_body_required_sections` (a YAML sequence in the team YAML, a bullet list in an H2), so the per-key override semantics below apply unchanged (a closed list is taken whole from its one binding layer, never unioned). @@ -721,12 +723,12 @@ Resolve every read from the repo root: `${CLAUDE_PROJECT_DIR}` when set, otherwi When that root is `$HOME` or an ancestor of `$HOME`, or is not inside a git working tree, team and personal override are **not applicable** (config-cascade #4672): report both with -that reason and resolve user-global only. `parse-branch-issue.sh` +that reason and resolve only the old user-global file, while it exists. `parse-branch-issue.sh` skips both layers and prints `team and personal override not applicable: project root is the home directory (or an ancestor of it)` or `... project root is not inside a git -repository` on stderr. A team or personal override path that physically equals the user-global file -is skipped even when the root is not home. `/source-control:setup apply layer=team` -and `layer=local` refuse in that state; `layer=user` still writes. +repository` on stderr. An old personal override path that physically equals the user-global file +is skipped even when the root is not home. `/source-control:setup apply` refuses to write in that +state. `lib/config-root.sh` is the resolver for the scripts and skills that call it: `resolve`, `classify` (`repo`, `non-repo`, or `home`), and `same` (physical path equality). `parse-branch-issue.sh` @@ -734,20 +736,33 @@ sources it, and `commit` and `pull-request` (`create.md`) run `classify` before or personal override layer. `setup` does not call it: its `check` and `apply` steps apply the same rule inline (`skills/setup/reference/apply-convention.md`). -Layers, in resolution order, where a later layer refines an earlier one: +Layers, in resolution order, where a later layer refines an earlier one (the +[config-cascade layers](https://github.com/melodic-software/claude-code-plugins/blob/main/docs/contracts/config-cascade/README.md#the-layers)): -1. **`~/.claude/source-control.md`**: user-global. The operator's own preference, following them - across repos and machines. Their home directory, not consumer repository data. -2. **`${REPO_ROOT}/docs/conventions/source-control.yaml`**: team, tracked. The shared convention +1. **`${REPO_ROOT}/docs/conventions/source-control.yaml`**: team, tracked. The shared convention for the seven convention keys, the layer `/source-control:setup apply` writes by default, and for the `babysit_loop_*` keys. The retired `${REPO_ROOT}/.claude/source-control.md` is not read. -3. **`${REPO_ROOT}/.claude/source-control.local.md`**: personal override, gitignored. A per-machine - or per-operator deviation from team policy, never committed. +2. **`${REPO_ROOT}/docs/conventions/source-control.local.yaml`**: personal override, gitignored. A + per-machine or per-operator deviation from team policy in one repository, never committed. - This plugin still reads, or reports as retired, the `.claude/` paths named here; until the plugin migrates, keep config where this page says it is read, then move it where [config locations](config-locations.md) says. +There is no user-global file layer, and no `userConfig` option takes its place: the convention keys +are per-repository conventions. + +**Dual-read window.** Two old locations are still read while they exist, each named on every run +with where to move it: + +| Old location | Read as | Moves to | +|---|---|---| +| `~/.claude/source-control.md` | the lowest layer, below team | `docs/conventions/source-control.yaml` (team), or `docs/conventions/source-control.local.yaml` for one person in one repo | +| `${REPO_ROOT}/.claude/source-control.local.md` | the personal override, only while `docs/conventions/source-control.local.yaml` is absent; beside it the old file is not read | `docs/conventions/source-control.local.yaml` | + +`parse-branch-issue.sh` prints one `old location` note per old file on stderr, naming the file, its +new location and `/source-control:setup apply`, whose migration moves the keys, checks the new +location resolves the same values and deletes the old file. Removing the old-location reads is a +later change, made once no old file is reported. Each layer is optional, and **fall-through is per key, not per file**. A key absent from every layer -is unresolved even when some layer exists: a user-global file contributing only `trailer_policy` +is unresolved even when some layer exists: a personal override contributing only `trailer_policy` leaves `subject_pattern` as unresolved as no file at all. Each unresolved key falls through independently to the repo's own `CLAUDE.md`/rules/commit-msg hook, then the bundled Conventional Commits default. Never gate that fall-through on file presence. @@ -763,15 +778,15 @@ Every key here is a scalar or a closed list: two `subject_pattern` regexes canno third valid regex, and a concatenated `trailer_policy` would emit two trailers. This is the layering convention's sanctioned per-key case. -Worked example: user-global sets `trailer_policy: none`, team sets `subject_pattern` to a -ticket-prefix regex and leaves `trailer_policy` unset, personal override sets nothing. The effective -config is the team `subject_pattern` with the user-global `trailer_policy: none`. +Worked example: team sets `subject_pattern` to a ticket-prefix regex and leaves `trailer_policy` +unset, and the personal override sets only `trailer_policy: none`. The effective config is the team +`subject_pattern` with the personal `trailer_policy: none`. **`type_list` is bound to the effective `subject_pattern`, not merged independently.** It belongs to a Conventional-Commits-shaped pattern, so after the layers merge, an inherited `type_list` is dropped whenever the *effective* `subject_pattern` is a custom regex, even when the layer supplying that -pattern said nothing about `type_list`. A user-global `Conventional Commits` plus its type list, -overridden by a team ticket-prefix regex, resolves to the team pattern with **no** `type_list`; +pattern said nothing about `type_list`. A team `Conventional Commits` plus its type list, +overridden by a personal ticket-prefix regex, resolves to the personal pattern with **no** `type_list`; keeping it would leave `/source-control:commit` pre-checking against a vocabulary the effective pattern does not use. Conversely, an effective Conventional-Commits pattern with no `type_list` in any layer resolves to the bundled 11-type list. @@ -787,11 +802,11 @@ concern owns **enforcement**: how a zero-dependency guardrails hook decides whet *already-formed* subject/title is allowed. Both read the team values in `docs/conventions/source-control.yaml` (enforcement also reads the git-tracked `docs/conventions/source-control/commit-convention.yml` for a key that file lacks) but differ on -purpose: enforcement reads the **team-tracked layer** (a gitignored `*.local.md` must never weaken +purpose: enforcement reads the **team-tracked layer** (a gitignored personal file must never weaken a blocking gate), and only where it sets no `subject_pattern` falls back to the operator's git-ignored `docs/conventions/source-control.local.yaml`, never merged with a team pattern. -Drafting does not read that file; an operator who wants drafts to match it sets the same -`## subject_pattern` in `.claude/source-control.local.md`. Enforcement resolves to **POSIX ERE +Drafting reads that file as the personal override, which wins over team per key; the old +`.claude/source-control.local.md` is a drafting input only. Enforcement resolves to **POSIX ERE only**, and treats an unresolved key as **no enforcement**, never the bundled Conventional Commits default. That contract, the regex-dialect normalization, and the resolver (`lib/resolve-convention-pattern.sh`) live in the @@ -799,15 +814,17 @@ normalization, and the resolver (`lib/resolve-convention-pattern.sh`) live in th ## Consumer `.gitignore` -The personal override convention needs one line in the consuming repo: +The personal override convention needs one line in the consuming repo, the config-cascade line for +the convention home: ```gitignore -.claude/**/*.local.* +docs/conventions/**/*.local.* ``` `/source-control:setup apply layer=team` appends the line when it is missing and announces the edit; it is the only write this plugin makes to the consumer's root `.gitignore`. `layer=local` -never edits it and fails with a recommendation when the personal override is exposed. +never edits it and fails with a recommendation when the personal override is exposed. An existing +`.claude/**/*.local.*` line, which covered the old personal override, is left as it is. ## Failure modes diff --git a/plugins/source-control/skills/babysit-loop/SKILL.md b/plugins/source-control/skills/babysit-loop/SKILL.md index 709f16fe095..e9b9954493b 100644 --- a/plugins/source-control/skills/babysit-loop/SKILL.md +++ b/plugins/source-control/skills/babysit-loop/SKILL.md @@ -66,7 +66,7 @@ Everything else resolves in order: 1. **Invocation arguments**, the tier keyword (babysit-prs vocabulary) and any per-dimension or loop-knob override mirroring the seam keys (e.g. `--drain`, `--grace-window-minutes 45`, `--merge human-only`). 2. **The layered config seam**, the `babysit_loop_*` keys in the source-control config - cascade (user-global → team-tracked → personal override, merged per key; `babysit_loop_trusted_internal_bot_logins` binds only from the target repo's tracked default branch, never an argument or another layer). The team-tracked value of every `babysit_loop_*` key comes from `docs/conventions/source-control.yaml` only. Key table, defaults, and layering semantics: + cascade (team-tracked → personal override `docs/conventions/source-control.local.yaml`, merged per key, plus the old locations still read during the dual-read window; `babysit_loop_trusted_internal_bot_logins` binds only from the target repo's tracked default branch, never an argument or another layer). The team-tracked value of every `babysit_loop_*` key comes from `docs/conventions/source-control.yaml` only. Key table, defaults, and layering semantics: [`${CLAUDE_PLUGIN_ROOT}/reference/config-resolution.md`](../../reference/config-resolution.md). 3. **Tier defaults**, the resolved tier's own dimension values (`safe` when nothing resolves a tier). diff --git a/plugins/source-control/skills/babysit-loop/evals/evals.json b/plugins/source-control/skills/babysit-loop/evals/evals.json index e1d8558f14e..e6c92ce41b7 100644 --- a/plugins/source-control/skills/babysit-loop/evals/evals.json +++ b/plugins/source-control/skills/babysit-loop/evals/evals.json @@ -121,7 +121,7 @@ { "id": 8, "name": "babysit-loop-trusted-internal-bot-trust-signal", - "prompt": "/source-control:babysit-loop melodic-software/example-repo worker\n\nThe target repository's team-tracked docs/conventions/source-control.yaml (its default branch) carries babysit_loop_merge set to c2-mechanical and babysit_loop_trusted_internal_bot_logins listing two entries: melodic-lane-bot[bot] and dependabot[bot]. The trusted promotion-evidence seam qualifies this cycle: C2-auto-merge resolves effective-promoted. The operator's personal override .claude/source-control.local.md lists rogue-helper[bot] under the same key, the invocation line carries --trusted-internal-bot-logins rogue-helper[bot], and the lane's own checkout of the target repository currently sits on a bot-authored PR branch whose tree's docs/conventions/source-control.yaml adds rogue-helper[bot] to the tracked key. This cycle's snapshot, all PRs quiet and green with close-linked items classified C2 mechanical on their work-class: labels: PR #21 authored by melodic-lane-bot[bot] (authorAssociation NONE, same-repository head); PR #22 authored by melodic-lane-bot[bot] from a cross-repository head; PR #23 authored by other-tool[bot] (authorAssociation CONTRIBUTOR, same-repository head, not listed); PR #24 authored by dependabot[bot] (authorAssociation CONTRIBUTOR, same-repository head); PR #25 authored by rogue-helper[bot] (same-repository head).", + "prompt": "/source-control:babysit-loop melodic-software/example-repo worker\n\nThe target repository's team-tracked docs/conventions/source-control.yaml (its default branch) carries babysit_loop_merge set to c2-mechanical and babysit_loop_trusted_internal_bot_logins listing two entries: melodic-lane-bot[bot] and dependabot[bot]. The trusted promotion-evidence seam qualifies this cycle: C2-auto-merge resolves effective-promoted. The operator's personal override docs/conventions/source-control.local.yaml lists rogue-helper[bot] under the same key, the invocation line carries --trusted-internal-bot-logins rogue-helper[bot], and the lane's own checkout of the target repository currently sits on a bot-authored PR branch whose tree's docs/conventions/source-control.yaml adds rogue-helper[bot] to the tracked key. This cycle's snapshot, all PRs quiet and green with close-linked items classified C2 mechanical on their work-class: labels: PR #21 authored by melodic-lane-bot[bot] (authorAssociation NONE, same-repository head); PR #22 authored by melodic-lane-bot[bot] from a cross-repository head; PR #23 authored by other-tool[bot] (authorAssociation CONTRIBUTOR, same-repository head, not listed); PR #24 authored by dependabot[bot] (authorAssociation CONTRIBUTOR, same-repository head); PR #25 authored by rogue-helper[bot] (same-repository head).", "expected_output": "The lane resolves babysit_loop_trusted_internal_bot_logins from the TARGET repository's team-tracked layer only, read from its DEFAULT BRANCH via the provider API on every resolution — never from any working tree, so the checkout's bot-authored PR branch (which added rogue-helper[bot] to its own copy of the tracked file) supplies nothing: a PR branch can never self-grant. The effective trusted set is exactly melodic-lane-bot[bot] and dependabot[bot]; the personal override's rogue-helper[bot] entry AND the --trusted-internal-bot-logins invocation argument are both ignored and reported — this key is a policy-floor exception to the invocation-arguments-win precedence, binding from the target repo's tracked default-branch file and nowhere else, because a trust grant must be a recorded, reviewable change. PR #21 passes the trust test on the listed-bot arm (structurally a bot, login exactly matching a tracked entry, same-repository head) despite authorAssociation NONE, so it is not C5 and — its item classifying C2 mechanical within the tracked c2-mechanical rung — it is the merge-eligible set's member, invoked at the worker tier with its partitioned head as the expected-head pin. PR #22 is C5 regardless of the listing: the fork test is independent of the trust test, and a listed bot authoring from a cross-repository head is still untrusted provenance — trust-listing never bypasses the fork test. PR #23 is C5: neither arm positively passes (CONTRIBUTOR association, login unlisted), fail closed. PR #24 is not C5 — dependabot[bot] is listed — but it is still never merged autonomously: the dependency-manager hold-merge invariant is independent of classification and wins on intersection, so the PR partitions on its work class and lands on the merge-ready report for a human, the merge gate refusing absent --allow-dependency, which only an explicit per-PR human order supplies. PR #25 is C5: the personal override grant never bound, so rogue-helper[bot] is unlisted, and the C5 verdict routes it to the safe per-PR pass like every other non-eligible PR. Had the tracked key been absent entirely, the trusted set would be empty and the trust test exactly the OWNER/MEMBER test — every one of these bot-authored PRs C5, fail closed. A trust match never establishes C2 by itself: eligibility still required each PR's close-linked item's recorded classification, and the diff-class check and every other withholding still applied.", "files": [], "expectations": [ diff --git a/plugins/source-control/skills/commit/SKILL.md b/plugins/source-control/skills/commit/SKILL.md index 1f6909aeaac..1b3bf0bd9fd 100644 --- a/plugins/source-control/skills/commit/SKILL.md +++ b/plugins/source-control/skills/commit/SKILL.md @@ -12,9 +12,7 @@ metadata: ## Pre-computed context Exec-bit backstop: !`bash "${CLAUDE_PLUGIN_ROOT}/skills/commit/scripts/exec-bit-check.sh" --probe 2>/dev/null || echo "unavailable — run the check manually"` -Config layer (user-global): !`test -f "$HOME/.claude/source-control.md" && echo present || echo absent` - -This plugin still reads, or reports as retired, the `.claude/` paths named here; until the plugin migrates, keep config where this page says it is read, then move it where [config locations](../../reference/config-locations.md) says. +Old config location (user-global, still read below team): !`test -f "$HOME/.claude/source-control.md" && echo present || echo absent` ## Repository context. Gather first @@ -29,13 +27,21 @@ invocation: Keep the `head` and `tail` pipes in the commands: they are the bound ([reference/config-probes.md](reference/config-probes.md) says why). -Before the layer probes, classify the config root with `bash "${CLAUDE_PLUGIN_ROOT}/lib/config-root.sh" classify`. For `home` or `non-repo`, report team and personal override as not applicable, skip the three probes, and read user-global only ([../../reference/config-resolution.md](../../reference/config-resolution.md), "The three layers"). +Before the layer probes, classify the config root with `bash "${CLAUDE_PLUGIN_ROOT}/lib/config-root.sh" classify`. For `home` or `non-repo`, report team and personal override as not applicable, skip the repo probes, and read only the old user-global file, when present ([../../reference/config-resolution.md](../../reference/config-resolution.md), "The three layers"). The team value of the convention keys (`subject_pattern`, `type_list`, `trailer_policy`) comes from `docs/conventions/source-control.yaml`, read when probe 1 below reports it tracked, through `bash "${CLAUDE_PLUGIN_ROOT}/lib/convention-key.sh" layer "$ROOT" `, which prints `yaml` or -`none` for a key; `value` and `list` print the YAML's value. The retired `.claude/source-control.md` -is not read. Report which layer supplied each value. +`none` for a key; `value` and `list` print the YAML's value. The personal override, +`docs/conventions/source-control.local.yaml`, wins per key; `local-value` and `local-list` print +its value. The retired `.claude/source-control.md` is not read. Report which layer supplied each +value. + +**Old locations.** Until `/source-control:setup apply` moves them, `~/.claude/source-control.md` +is still read below team, and `.claude/source-control.local.md` as the personal override while +probe 3 finds no personal YAML (beside it the old file is not read). Read the `## ` sections +of each old file that applies, and for each one present tell the user once that it is an old +location and `/source-control:setup apply` moves it. Run the repo-scoped probes as separate calls. Each uses git's repo-root-relative magic pathspec `:/`, which resolves against the top of the working tree, so these are correct from @@ -47,9 +53,11 @@ the leading `:` is pathspec magic, and quoting keeps the shell from reinterpreti 2. Team layer, existence. `git ls-files --cached --others -- ":/docs/conventions/source-control.yaml"` 3. Personal override, existence. + `git ls-files --cached --others -- ":/docs/conventions/source-control.local.yaml"` +4. Old personal override, existence. `git ls-files --cached --others -- ":/.claude/source-control.local.md"` -Probes 2 and 3 deliberately omit `--exclude-standard`, so a gitignored file is still listed. +Probes 2 to 4 deliberately omit `--exclude-standard`, so a gitignored file is still listed. **Combine probes 1 and 2 in that order**. Trackedness first, existence consulted only when trackedness comes back nonzero. They are not independent readings: @@ -81,7 +89,7 @@ for each probe's shape are in [reference/config-probes.md](reference/config-prob Run this list **for every commit**, including the second and tenth commit of a session. These are commands, not remembered facts. Steps 3–5 are the ones a long session silently stops performing. -1. **Resolve** the convention + `trailer_policy` across all three config layers (once per session +1. **Resolve** the convention + `trailer_policy` across the config layers (once per session is enough; re-resolve if a layer changed). 2. **Stage** surgically by explicit path, after checking the four pre-existing conditions below. 3. **Format**, run the discoverable formatter scoped to this commit's paths, re-stage its fixes. @@ -109,10 +117,12 @@ these failure modes: The subject convention (what shape a subject must take) resolves via a ladder, checked in order: -1. **The layered source-control convention config**. User-global, tracked team - (`docs/conventions/source-control.yaml`), and gitignored personal override, merged per key by +1. **The layered source-control convention config**. Tracked team + (`docs/conventions/source-control.yaml`) and gitignored personal override + (`docs/conventions/source-control.local.yaml`), plus the old locations still read, merged per + key by [`${CLAUDE_PLUGIN_ROOT}/reference/config-resolution.md`](../../reference/config-resolution.md). - Resolve all three layers before using any value; a value from one layer alone is not the effective + Resolve every layer before using any value; a value from one layer alone is not the effective config. When any layer declares one, the effective `subject_pattern` (and `type_list`, when Conventional-Commits-shaped) is authoritative. Before pre-checking, expand `subject_pattern`: the literal keyword `Conventional Commits` expands to the anchored pattern in step 3 below; anything diff --git a/plugins/source-control/skills/commit/evals/docs/conventions/source-control.local.yaml b/plugins/source-control/skills/commit/evals/docs/conventions/source-control.local.yaml new file mode 100644 index 00000000000..d5481fe4ff1 --- /dev/null +++ b/plugins/source-control/skills/commit/evals/docs/conventions/source-control.local.yaml @@ -0,0 +1,2 @@ +subject_pattern: '^[A-Z]+-\d+: .+' +pr_title_pattern: Same as `subject_pattern`. diff --git a/plugins/source-control/skills/commit/evals/evals.json b/plugins/source-control/skills/commit/evals/evals.json index 65e3569a8f3..d727832df3e 100644 --- a/plugins/source-control/skills/commit/evals/evals.json +++ b/plugins/source-control/skills/commit/evals/evals.json @@ -93,8 +93,8 @@ "id": 8, "name": "personal-override-overrides-team-convention-per-key", "prompt": "Commit the null-user fix in src/api/me.js.", - "expected_output": "Resolves the convention across all three layers before drafting. The personal override .claude/source-control.local.md declares only subject_pattern (a ticket-prefix regex), so the drafted subject matches the ticket-prefix shape rather than the team file's Conventional Commits value; the team file's trailer_policy: none still applies, because the personal override does not declare that key and per-key override never drops the base layer wholesale. The personal override is not treated as the whole config.", - "files": ["docs/conventions/source-control.yaml", ".claude/source-control.local.md"], + "expected_output": "Resolves the convention across both layers before drafting. The personal override docs/conventions/source-control.local.yaml declares only subject_pattern (a ticket-prefix regex), so the drafted subject matches the ticket-prefix shape rather than the team file's Conventional Commits value; the team file's trailer_policy: none still applies, because the personal override does not declare that key and per-key override never drops the base layer wholesale. The personal override is not treated as the whole config.", + "files": ["docs/conventions/source-control.yaml", "docs/conventions/source-control.local.yaml"], "expectations": [ "Reads the personal override and the team file, not the team file alone", "Drafts a subject matching the personal override's ticket-prefix subject_pattern, not the team file's Conventional Commits pattern", @@ -107,7 +107,7 @@ "name": "inherited-type-list-drops-for-an-effective-custom-pattern", "prompt": "Commit the null-user fix in src/api/me.js.", "expected_output": "The team file declares Conventional Commits plus the bundled 11-type type_list; the personal override overrides subject_pattern with a ticket-prefix regex and says nothing about type_list. type_list is bound to the effective subject_pattern rather than merged per key on its own, so it is dropped: the drafted subject matches the ticket-prefix pattern and is not pre-checked against a Conventional-Commits type vocabulary the effective pattern does not use.", - "files": ["docs/conventions/source-control.yaml", ".claude/source-control.local.md"], + "files": ["docs/conventions/source-control.yaml", "docs/conventions/source-control.local.yaml"], "expectations": [ "Drafts a subject matching the personal override's ticket-prefix subject_pattern", "Drops the team layer's type_list because the effective subject_pattern is not Conventional-Commits-shaped", diff --git a/plugins/source-control/skills/commit/reference/config-probes.md b/plugins/source-control/skills/commit/reference/config-probes.md index 55d83a0116c..d06cb5784b2 100644 --- a/plugins/source-control/skills/commit/reference/config-probes.md +++ b/plugins/source-control/skills/commit/reference/config-probes.md @@ -12,11 +12,11 @@ instead, is [Tools reference § Output limits](https://code.claude.com/docs/en/t These are ordinary body Bash calls, not pre-compute, so the one-invocation composition that applies to the `## Pre-computed context` block does not apply here. -## Why probes 2 and 3 omit `--exclude-standard` +## Why probes 2 to 4 omit `--exclude-standard` -Probes 2 and 3 deliberately omit `--exclude-standard`, so a gitignored file is still listed: the -personal override is expected to be gitignored, and an untracked team file has to be *seen* before it -can be reported as untracked. +Probes 2 to 4 deliberately omit `--exclude-standard`, so a gitignored file is still listed: the +personal override and its old location are expected to be gitignored, and an untracked team file +has to be *seen* before it can be reported as untracked. ## Why probe 2 exists, and what a nonzero exit means @@ -43,8 +43,8 @@ invocable from inside a worktree. The composition record is the **Every repo-scoped probe anchors at the repository root**, via the `:/` magic pathspec, never at the session's current directory. A session started in a subdirectory would otherwise look for -`/docs/conventions/source-control.yaml` and `/.claude/source-control.local.md` and report -both repo-scoped layers absent, silently dropping the team convention +`/docs/conventions/source-control.yaml` and `/docs/conventions/source-control.local.yaml` +and report both repo-scoped layers absent, silently dropping the team convention and `trailer_policy`, and producing a commit with the wrong subject shape or attribution. Never substitute a resolved root path into a probe instead: a repository root containing `$(…)`, a backtick, or a double quote is *not* made safe by wrapping the substituted text in double quotes @@ -53,5 +53,3 @@ substitutes the root at all. This matches the root-resolution requirement [`config-resolution.md`](../../../reference/config-resolution.md) already states for resolution itself; the probes must not disagree with it. `exec-bit-check.sh` anchors itself the same way. - -This plugin still reads, or reports as retired, the `.claude/` paths named here; until the plugin migrates, keep config where this page says it is read, then move it where [config locations](../../../reference/config-locations.md) says. diff --git a/plugins/source-control/skills/pull-request/evals/evals.json b/plugins/source-control/skills/pull-request/evals/evals.json index 8faf6ea9d25..008d4d85175 100644 --- a/plugins/source-control/skills/pull-request/evals/evals.json +++ b/plugins/source-control/skills/pull-request/evals/evals.json @@ -245,14 +245,14 @@ { "id": 20, "name": "pr-body-required-sections-none-overrides-lower-layer", - "prompt": "/pull-request create from branch feat/512-add-widget. The user-global ~/.claude/source-control.md declares pr_body_required_sections as the bullet list Summary, Test plan, Related. The repo's team-tracked docs/conventions/source-control.yaml declares pr_body_required_sections as the literal keyword none. The gitignored personal override .claude/source-control.local.md exists but does not set pr_body_required_sections. Resolve the effective section scaffold.", - "expected_output": "Per config-resolution.md's per-key override across the three layers, the team layer's `none` REPLACES the user-global list wholesale — the effective value is zero required sections, and the personal override's silence on the key changes nothing (an absent key in a later layer keeps the earlier winner; it never resets or re-imports a lower layer's list). The skill distinguishes `none` (a resolved value that wins the per-key override like any list would) from absence (which would have fallen through to the user-global list here). A personal override declaring `none` over a team list would win the same way — the semantics are per-key precedence, identical to trailer_policy / pr_body_attribution.", + "prompt": "/pull-request create from branch feat/512-add-widget. The old user-global ~/.claude/source-control.md (still read below team during the dual-read window) declares pr_body_required_sections as the bullet list Summary, Test plan, Related. The repo's team-tracked docs/conventions/source-control.yaml declares pr_body_required_sections as the literal keyword none. The gitignored personal override docs/conventions/source-control.local.yaml exists but does not set pr_body_required_sections. Resolve the effective section scaffold.", + "expected_output": "Per config-resolution.md's per-key override, with the old user-global file read lowest, then team, then the personal override, the team layer's `none` REPLACES the old user-global list wholesale — the effective value is zero required sections, and the personal override's silence on the key changes nothing (an absent key in a later layer keeps the earlier winner; it never resets or re-imports a lower layer's list). The skill distinguishes `none` (a resolved value that wins the per-key override like any list would) from absence (which would have fallen through to the old user-global list here). A personal override declaring `none` over a team list would win the same way — the semantics are per-key precedence, identical to trailer_policy / pr_body_attribution.", "files": [], "expectations": [ - "The team layer's `none` overrides the user-global layer's Summary/Test plan/Related list — the effective resolution is zero required sections", + "The team layer's `none` overrides the old user-global file's Summary/Test plan/Related list — the effective resolution is zero required sections", "The personal override omitting the key does not disturb the team layer's `none` — per-key fallthrough keeps the later layer's resolved value", "`none` wins the per-key override as a resolved value exactly like a list would, with the same precedence semantics as trailer_policy and pr_body_attribution", - "Absence and `none` are distinguished: had the team layer omitted the key, the user-global list would have won instead" + "Absence and `none` are distinguished: had the team layer omitted the key, the old user-global list would have won instead" ] }, { @@ -386,7 +386,7 @@ { "id": 30, "name": "pr-body-briefing-keyword-overrides-lower-list", - "prompt": "/pull-request create from branch feat/733-retry-uploads. The repo's team-tracked docs/conventions/source-control.yaml declares pr_body_required_sections as the bullet list Summary, Test plan. The gitignored personal override .claude/source-control.local.md declares pr_body_required_sections as the keyword briefing. Resolve the effective section scaffold.", + "prompt": "/pull-request create from branch feat/733-retry-uploads. The repo's team-tracked docs/conventions/source-control.yaml declares pr_body_required_sections as the bullet list Summary, Test plan. The gitignored personal override docs/conventions/source-control.local.yaml declares pr_body_required_sections as the keyword briefing. Resolve the effective section scaffold.", "expected_output": "The personal override wins the per-key override, and its keyword briefing replaces the team layer's list whole. The effective required sections are Why, What changed, Scope and Verification; Summary and Test plan are not required and are not merged in. The reported source is the personal override with the briefing keyword.", "files": [], "narration": true, diff --git a/plugins/source-control/skills/pull-request/reference/create.md b/plugins/source-control/skills/pull-request/reference/create.md index 296c5fc10f6..e4c6c5bfb9f 100644 --- a/plugins/source-control/skills/pull-request/reference/create.md +++ b/plugins/source-control/skills/pull-request/reference/create.md @@ -276,7 +276,7 @@ here. Derive the PR title from the commit subject, shaped to the resolved subject/title convention (the ladder in [SKILL.md](../SKILL.md): layered source-control config → project convention → Conventional Commits default). Build the body with `${CLOSES_LINE}` at top, then the resolved section scaffold and a config-gated attribution line. -**Resolve the required section scaffold first.** Run `bash "/lib/config-root.sh" classify` before reading any layer: for `home` or `non-repo`, team and personal override are not applicable and only the user-global layer is read ([../../../reference/config-resolution.md](../../../reference/config-resolution.md), "The three layers"). Read `pr_body_required_sections` across the applicable layers per [../../../reference/config-resolution.md](../../../reference/config-resolution.md) (per-key override: a winning layer's value is taken whole, never merged with an earlier layer's). The team layer is `docs/conventions/source-control.yaml`: `bash "/lib/convention-key.sh" layer "" pr_body_required_sections` prints `yaml` or `none`, and `list` or `value` prints the YAML's heading list or keyword; the retired `.claude/source-control.md` is not read. The YAML is a layer only when git tracks it, as in `parse-branch-issue.sh` and `/source-control:commit`; `convention-key.sh` does not check trackedness, so check `git ls-files --error-unmatch -- ":/docs/conventions/source-control.yaml"` before trusting `layer`, `list` or `value`. Skip an untracked or gitignored team file with a note. The value is a heading list or one of three keywords, each overriding a lower layer as a list would (never an absence; parallel to `trailer_policy`/`pr_body_attribution`): +**Resolve the required section scaffold first.** Run `bash "/lib/config-root.sh" classify` before reading any layer: for `home` or `non-repo`, team and personal override are not applicable and only the old user-global file is read, when present ([../../../reference/config-resolution.md](../../../reference/config-resolution.md), "The three layers"). Read `pr_body_required_sections` across the applicable layers per [../../../reference/config-resolution.md](../../../reference/config-resolution.md) (per-key override: a winning layer's value is taken whole, never merged with an earlier layer's). The team layer is `docs/conventions/source-control.yaml`: `bash "/lib/convention-key.sh" layer "" pr_body_required_sections` prints `yaml` or `none`, and `list` or `value` prints the YAML's heading list or keyword; the retired `.claude/source-control.md` is not read. The personal override `docs/conventions/source-control.local.yaml` wins over it: `local-list` or `local-value` prints its value. The old locations still read during the dual-read window are in that section. The team YAML is a layer only when git tracks it, as in `parse-branch-issue.sh` and `/source-control:commit`; `convention-key.sh` does not check trackedness, so check `git ls-files --error-unmatch -- ":/docs/conventions/source-control.yaml"` before trusting `layer`, `list` or `value`. Skip an untracked or gitignored team file with a note. The value is a heading list or one of three keywords, each overriding a lower layer as a list would (never an absence; parallel to `trailer_policy`/`pr_body_attribution`): - **Absent everywhere, or `briefing`**: the short-briefing preset below. No `Related` is required (see [`docs/contracts/pr-body-convention/README.md`](https://raw.githubusercontent.com/melodic-software/claude-code-plugins/main/docs/contracts/pr-body-convention/README.md) for why the default excludes it). - **`summary-test-plan`**: `Summary` and `Test plan`, both required. diff --git a/plugins/source-control/skills/pull-request/scripts/parse-branch-issue.sh b/plugins/source-control/skills/pull-request/scripts/parse-branch-issue.sh index 4424d7a9b2a..33c2a8207ff 100755 --- a/plugins/source-control/skills/pull-request/scripts/parse-branch-issue.sh +++ b/plugins/source-control/skills/pull-request/scripts/parse-branch-issue.sh @@ -20,13 +20,6 @@ # into link text. A pattern with no capture group, or a capture of any other # shape, yields no output and exit 1. It resolves, first hit wins: # 1. The layered `branch_issue_pattern` key (reference/config-resolution.md): -# `/.claude/source-control.local.md` over the team layer over -# `$HOME/.claude/source-control.md`. The team layer is the -# `branch_issue_pattern` key of `/docs/conventions/source-control.yaml`, -# read only when git tracks it; an untracked one is skipped with a note. -# The retired `/.claude/source-control.md` is not read. A team YAML -# the shared reader rejects stops resolution. `--explain` prints the layer -# that supplied the pattern on stderr. # In a markdown layer the value is the `## branch_issue_pattern` section's # first non-blank line, surrounding backticks # stripped, or, when that line opens a code fence, the first non-blank line @@ -260,6 +253,9 @@ usable_pattern() { REPO_ROOT="$(config_root_resolve)" +SETUP_HINT="run /source-control:setup apply to move it, which deletes the old file" +old_location() { note "old location ${1}: $2; move its keys to ${3}; ${SETUP_HINT}"; } + LAYERS=() USER_LAYER="${HOME:-}/.claude/source-control.md" if [[ -n "$REPO_ROOT" ]]; then @@ -267,9 +263,18 @@ if [[ -n "$REPO_ROOT" ]]; then home) note "team and personal override not applicable: project root is the home directory (or an ancestor of it)" ;; non-repo) note "team and personal override not applicable: project root is not inside a git repository" ;; *) - personal_override="${REPO_ROOT}/.claude/source-control.local.md" + PERSONAL_YAML="${REPO_ROOT}/${CONVENTION_KEY_LOCAL_REL}" + personal_override="${REPO_ROOT}/${CONVENTION_KEY_OLD_LOCAL_REL}" TEAM_YAML="${REPO_ROOT}/${CONVENTION_KEY_YAML_REL}" - config_root_paths_same "$personal_override" "$USER_LAYER" || LAYERS+=("$personal_override") + [[ -f "$PERSONAL_YAML" ]] && LAYERS+=("$PERSONAL_YAML") + if [[ -f "$personal_override" ]] && ! config_root_paths_same "$personal_override" "$USER_LAYER"; then + if [[ -f "$PERSONAL_YAML" ]]; then + old_location "$personal_override" "not read, since ${CONVENTION_KEY_LOCAL_REL} supplies the personal override" "$PERSONAL_YAML" + else + LAYERS+=("$personal_override") + old_location "$personal_override" "still read as the personal override" "$PERSONAL_YAML" + fi + fi # The team layer is the YAML, a layer only when git tracks it, as in the # commit skill. The retired .claude/source-control.md is not read. if convention_key_tracked "$REPO_ROOT" "$CONVENTION_KEY_YAML_REL"; then @@ -280,25 +285,32 @@ if [[ -n "$REPO_ROOT" ]]; then ;; esac fi -LAYERS+=("$USER_LAYER") +if [[ -n "${HOME:-}" && -f "$USER_LAYER" ]]; then + LAYERS+=("$USER_LAYER") + old_location "$USER_LAYER" "still read as the lowest layer" \ + "${CONVENTION_KEY_YAML_REL} (team) or ${CONVENTION_KEY_LOCAL_REL} (personal) in each repository that needs it" +fi # The layer a resolved pattern came from, as reported by --explain. layer_label() { case "$1" in "${TEAM_YAML:-}") echo "$CONVENTION_KEY_YAML_REL" ;; - "${personal_override:-}") echo ".claude/source-control.local.md" ;; - "$USER_LAYER") echo "user-global .claude/source-control.md in the home directory" ;; + "${PERSONAL_YAML:-}") echo "$CONVENTION_KEY_LOCAL_REL" ;; + "${personal_override:-}") echo "old personal override ${CONVENTION_KEY_OLD_LOCAL_REL}" ;; + "$USER_LAYER") echo "old user-global .claude/source-control.md in the home directory" ;; *) echo "$1" ;; esac } PATTERN="" SOURCE="" LABEL="" -for layer in "${LAYERS[@]}"; do - if [[ -n "${TEAM_YAML:-}" && "$layer" == "$TEAM_YAML" ]]; then - value="$(convention_key_yaml_value "$REPO_ROOT" "$KEY")" +for layer in ${LAYERS[@]+"${LAYERS[@]}"}; do + if [[ "$layer" == "${TEAM_YAML:-}" || "$layer" == "${PERSONAL_YAML:-}" ]]; then + rel="$CONVENTION_KEY_YAML_REL" + [[ "$layer" == "${PERSONAL_YAML:-}" ]] && rel="$CONVENTION_KEY_LOCAL_REL" + value="$(convention_key_yaml_value "$REPO_ROOT" "$KEY" "$rel")" rc=$? if [[ "$rc" -ne 0 ]]; then - note "${CONVENTION_KEY_YAML_REL} could not be parsed; ${STOP}" + note "${rel} could not be parsed; ${STOP}" exit 1 fi else diff --git a/plugins/source-control/skills/pull-request/scripts/parse-branch-issue.test.sh b/plugins/source-control/skills/pull-request/scripts/parse-branch-issue.test.sh index ca466ab83a1..429f6df027e 100755 --- a/plugins/source-control/skills/pull-request/scripts/parse-branch-issue.test.sh +++ b/plugins/source-control/skills/pull-request/scripts/parse-branch-issue.test.sh @@ -98,6 +98,8 @@ yaml_layer() { } TEAM_YAML_REL="docs/conventions/source-control.yaml" +PERSONAL_YAML_REL="docs/conventions/source-control.local.yaml" +OLD_LOCATION_NOTE='^parse-branch-issue: old location ' # `track ` stages a file the case wrote inside its repo, since the team # YAML is a config layer only when git tracks it. Outside a git repo it does nothing. @@ -132,7 +134,7 @@ run_cfg() { bash "$PARSER" "$branch" "$pattern" 2>"$errfile") fi rc=$? - err=$(<"$errfile") + err=$(grep -v -- "$OLD_LOCATION_NOTE" "$errfile") local err_ok=1 if [[ "$err_check" == "empty" ]]; then [[ -z "$err" ]] || err_ok=0 @@ -538,7 +540,7 @@ new_case yaml_layer "${CASE_REPO}/docs/conventions/source-control.yaml" '-([0-9]+)$' layer "${CASE_REPO}/.claude/source-control.local.md" '^[^/]+/([0-9]+)-' run_explain "the personal override still beats the team YAML" "feat/12-add-widget-1234" "12" \ - '\.claude/source-control\.local\.md$' + 'old personal override \.claude/source-control\.local\.md$' new_case yaml_layer "${CASE_REPO}/docs/conventions/source-control.yaml" '([' @@ -566,6 +568,102 @@ run_cfg "an untracked team YAML is ignored, and a tracked retired file is not re new_case run_explain "the default is the named layer when nothing is configured" "feat/42-x" "42" 'default$' +SETUP_NOTE='/source-control:setup apply' + +write_personal_yaml() { + mkdir -p "$(dirname "$1")" + printf '%s\n' "branch_issue_pattern: '$2'" >"$1" +} + +old_note_count_is() { + local desc="$1" want="$2" got + got=$(grep -c -- "$OLD_LOCATION_NOTE" "${FIXTURES}/stderr") + if [[ "$got" -eq "$want" ]]; then + echo "PASS: $desc" + PASS=$((PASS + 1)) + else + echo "FAIL: $desc (got $got old-location notes, wanted $want)" + FAIL=$((FAIL + 1)) + fi +} + +old_note_matches() { + local desc="$1" ere="$2" + if grep -Eq -- "${OLD_LOCATION_NOTE}.*${ere}" "${FIXTURES}/stderr"; then + echo "PASS: $desc" + PASS=$((PASS + 1)) + else + echo "FAIL: $desc (no old-location note matches '${ere}': $(<"${FIXTURES}/stderr"))" + FAIL=$((FAIL + 1)) + fi +} + +new_case +yaml_layer "${CASE_REPO}/$TEAM_YAML_REL" '-([0-9]+)$' +write_personal_yaml "${CASE_REPO}/$PERSONAL_YAML_REL" '^[^/]+/([0-9]+)-' +run_cfg "new layers only: the personal YAML beats the team YAML" \ + "feat/12-add-widget-1234" "" - "12" 0 empty +old_note_count_is "new layers only: no old-location note" 0 +run_explain "the personal YAML is the named layer" "feat/12-add-widget-1234" "12" \ + 'docs/conventions/source-control\.local\.yaml$' + +new_case +yaml_layer "${CASE_REPO}/$TEAM_YAML_REL" '-([0-9]+)$' +mkdir -p "${CASE_REPO}/docs/conventions" +printf '%s\n' 'trailer_policy: none' >"${CASE_REPO}/$PERSONAL_YAML_REL" +run_cfg "a personal YAML without the key falls through to the team YAML" \ + "feat/12-add-widget-1234" "" - "1234" 0 empty + +new_case +write_personal_yaml "${CASE_REPO}/$PERSONAL_YAML_REL" '([' +run_cfg "an invalid personal YAML pattern stops resolution" \ + "feat/12-add-widget-1234" "" - "" 1 "invalid ERE.*${STOPPED}" + +new_case +write_personal_yaml "${CASE_REPO}/$PERSONAL_YAML_REL" '^[^/]+/([0-9]+)-' +printf '%s\n' 'branch_issue_pattern: a' >>"${CASE_REPO}/$PERSONAL_YAML_REL" +run_cfg "a personal YAML the shared reader rejects stops resolution" \ + "feat/12-add-widget-1234" "" - "" 1 "source-control\.local\.yaml could not be parsed.*${STOPPED}" + +new_case +yaml_layer "${CASE_REPO}/$TEAM_YAML_REL" '-([0-9]+)$' +layer "${CASE_REPO}/.claude/source-control.local.md" '^[^/]+/([0-9]+)-' +run_cfg "old personal override only: its value applies" "feat/12-add-widget-1234" "" - "12" 0 empty +old_note_count_is "old personal override only: one note per run" 1 +old_note_matches "old personal override only: the note names the file, its new location and setup" \ + "\.claude/source-control\.local\.md: still read.*source-control\.local\.yaml.*${SETUP_NOTE}" + +new_case +yaml_layer "${CASE_REPO}/$TEAM_YAML_REL" '-([0-9]+)$' +write_personal_yaml "${CASE_REPO}/$PERSONAL_YAML_REL" '^[a-z]+/([0-9]+)-add' +layer "${CASE_REPO}/.claude/source-control.local.md" '^[a-z]+/[0-9]+-add-widget-([0-9]+)$' +run_cfg "both personal files: the YAML wins" "feat/7-add-widget-1234" "" - "7" 0 empty +old_note_count_is "both personal files: one note per run" 1 +old_note_matches "both personal files: the note names both files and setup" \ + "\.claude/source-control\.local\.md: not read, since docs/conventions/source-control\.local\.yaml.*${SETUP_NOTE}" + +new_case +layer "${CASE_HOME}/.claude/source-control.md" '-([0-9]+)$' +run_cfg "old user-global only: its value applies" "feat/12-add-widget-1234" "" - "1234" 0 empty +old_note_count_is "old user-global only: one note per run" 1 +old_note_matches "old user-global only: the note names the file, both new locations and setup" \ + "home\.[^ ]*/\.claude/source-control\.md: still read.*source-control\.yaml \(team\) or .*source-control\.local\.yaml \(personal\).*${SETUP_NOTE}" +run_explain "the old user-global file is the named layer" "feat/12-add-widget-1234" "1234" \ + 'old user-global' + +new_case +layer "${CASE_HOME}/.claude/source-control.md" '-([0-9]+)$' +yaml_layer "${CASE_REPO}/$TEAM_YAML_REL" '^[^/]+/([0-9]+)-' +run_cfg "old user-global beside the team YAML: the team wins" "feat/12-add-widget-1234" "" - "12" 0 empty +old_note_count_is "old user-global beside the team YAML: the note still prints once" 1 + +new_case +layer "${CASE_HOME}/.claude/source-control.md" '-([0-9]+)$' +layer "${CASE_REPO}/.claude/source-control.local.md" '^[^/]+/([0-9]+)-' +run_cfg "both old files: the old personal override wins over the old user-global" \ + "feat/12-add-widget-1234" "" - "12" 0 empty +old_note_count_is "both old files: one note for each" 2 + echo echo "Results: ${PASS} passed, ${FAIL} failed" [[ $FAIL -eq 0 ]] diff --git a/plugins/source-control/skills/setup/SKILL.md b/plugins/source-control/skills/setup/SKILL.md index 5745108e9e4..2ccefa1e37a 100644 --- a/plugins/source-control/skills/setup/SKILL.md +++ b/plugins/source-control/skills/setup/SKILL.md @@ -1,11 +1,11 @@ --- -description: "Configure the source-control plugin. check (read-only, default) reports the effective commit-subject / PR-title convention merged across the user-global, team, and personal-override layers plus the babysit-prs userConfig surface; apply interviews the repo, writes the convention config to a chosen layer, and walks the sanctioned babysit reconfigure paths. Use when setting up or inspecting this plugin's configuration, choosing or overriding a commit convention at any layer, configuring or checking babysit, or when /commit, /pull-request, or /babysit-prs report missing configuration. Re-runnable and safe." -argument-hint: "[check|apply] [layer=user|team|local] [subject_pattern=] [branch_issue_pattern=]" +description: "Configure the source-control plugin. check (read-only, default) reports the effective commit-subject / PR-title convention merged across the team and personal-override layers, plus old-location files and the babysit-prs userConfig surface; apply interviews the repo, writes the convention config to a chosen layer, moves old-location config, and walks the sanctioned babysit reconfigure paths. Use when setting up or inspecting this plugin's configuration, choosing or overriding a commit convention at any layer, configuring or checking babysit, when a run names an old config location, or when /commit, /pull-request, or /babysit-prs report missing configuration. Re-runnable and safe." +argument-hint: "[check|apply] [layer=team|local] [subject_pattern=] [branch_issue_pattern=]" user-invocable: true disable-model-invocation: true --- -**Arguments.** `[check|apply] [layer=user|team|local] [subject_pattern=] [branch_issue_pattern=]`. Full form: [check|apply] [layer=user|team|local] [subject_pattern=] [branch_issue_pattern=] +**Arguments.** `[check|apply] [layer=team|local] [subject_pattern=] [branch_issue_pattern=]`. Full form: [check|apply] [layer=team|local] [subject_pattern=] [branch_issue_pattern=] ## Purpose @@ -13,8 +13,10 @@ Inspect and configure the source-control plugin per the uniform setup contract (`docs/plugin-philosophy.md` "Setup is explicit and repeatable" in the marketplace repository): `check` reports the effective configuration, `apply` writes it. Two kinds of configuration: -1. The commit-subject / PR-title convention config, layered across a user-global file, the tracked - team file (`docs/conventions/source-control.yaml`), and a gitignored personal override and merged per key by +1. The commit-subject / PR-title convention config, layered across the tracked team file + (`docs/conventions/source-control.yaml`) and the gitignored personal override + (`docs/conventions/source-control.local.yaml`), plus the two old locations still read during + the dual-read window, and merged per key by [../../reference/config-resolution.md](../../reference/config-resolution.md). Resolved first by `/source-control:commit` and `/source-control:pull-request` before they fall back to inference or the bundled Conventional Commits default. Conventional Commits is genuinely optional, some orgs @@ -45,7 +47,7 @@ below, never a cwd-relative path (invoked from a nested directory, a cwd-relativ the wrong file). Re-resolve `REPO_ROOT` at the top of every self-contained Bash call, a fresh shell does not carry a prior call's variables. -Read all three layers, then report **one effective-configuration table**, a row per key, its +Read both layers and any old location, then report **one effective-configuration table**, a row per key, its resolved value, and which layer supplied it, followed by a per-layer presence line. Never present a single layer's value as the effective convention; a reader who cannot see which layer won cannot tell why `/source-control:commit` behaves as it does. @@ -55,10 +57,10 @@ personal override are **not applicable** ([../../reference/config-resolution.md](../../reference/config-resolution.md)): do not read `${REPO_ROOT}/docs/conventions/source-control.yaml` or the personal override, report both as N/A with the reason (`project root is the home directory (or an ancestor of it)` -or `project root is not inside a git repository`), and resolve user-global only. -`parse-branch-issue.sh` prints the same note on stderr. Git +or `project root is not inside a git repository`), and resolve only the old user-global file, +while it exists. `parse-branch-issue.sh` prints the same note on stderr. Git tracked/ignored probes do not apply: there is no consumer repository to answer against. -`apply layer=team` and `layer=local` refuse; offer `layer=user`. +`apply` refuses to write; say to run it from the repository that should hold the config. ```text key value won by @@ -96,8 +98,15 @@ that keyword with its layer in `won by`. Per-layer verdicts: -- **User-global** (`~/.claude/source-control.md`): present → report which keys it contributes; - absent → INFO. It is outside the repo, so no git check applies to it. +- **Old locations** (dual-read window): list them with + `bash "${CLAUDE_PLUGIN_ROOT}/lib/convention-key.sh" old-files "$REPO_ROOT"` (pass an empty root + when team and personal override are not applicable), which prints one + `` line per file present. Each line → WARN naming the old file, the + keys it still supplies, its new location, and `apply` as the remediation, which moves it + ([reference/apply-convention.md](reference/apply-convention.md) "Move config off the old + locations"). `~/.claude/source-control.md` is still read below team; the old personal override + `.claude/source-control.local.md` is read only while the personal YAML is absent, so beside it + say its keys are not read. No output → nothing to move. - **Team** (`REPO_ROOT/docs/conventions/source-control.yaml`): present → PASS. **FAIL** when excluded by `.gitignore`. Teammates would never receive the shared convention; report the matching rule. Absent → INFO, remediable by `apply`. Per key, `bash "${CLAUDE_PLUGIN_ROOT}/lib/convention-key.sh" layer "$REPO_ROOT" ` @@ -110,32 +119,32 @@ Per-layer verdicts: by source-control; name the `## ` sections it still carries. `apply` copies every key the schema declares into `docs/conventions/source-control.yaml` and removes its section; delete the file once it carries none. -- **Personal override ignore rule** (the recursive `.claude/**/*.local.*`, covering - `REPO_ROOT/.claude/source-control.local.md`): probe the ignore rule whether or +- **Personal override ignore rule** (the recursive `docs/conventions/**/*.local.*`, covering + `REPO_ROOT/docs/conventions/source-control.local.yaml`): probe the ignore rule whether or not the personal override file exists. The rule's job is to be in place **before** the first personal override is written; conditioning the probe on the file already existing is the window that produces the exposure. Missing rule → FAIL, remediable by `apply` (which writes the line at team-layer bind, not only at `layer=local`). - Probe with `git check-ignore --no-index -v -- .claude/nested/personal-override.local.md` + Probe with `git check-ignore --no-index -v -- docs/conventions/nested/personal-override.local.yaml` (the path does not need to exist). The sentinel is nested so a leftover - `.claude/*.local.*` rule, which still matches the flat personal override path, is not + `docs/conventions/*.local.*` rule, which still matches the flat personal override path, is not mistaken for the recursive rule. A match counts only when `-v` names a repository `.gitignore` as the source. `$GIT_DIR/info/exclude` and `core.excludesFile` are operator-local and do not protect a teammate. -- **Personal override file** (`REPO_ROOT/.claude/source-control.local.md`): when +- **Personal override file** (`REPO_ROOT/docs/conventions/source-control.local.yaml`): when present, PASS only when an ignore rule matches it **and** it is not in the index. Two distinct failures hide behind one symptom and need different remediations, so probe them separately. See the two-probe form under - `apply`. Absent file is OK once the ignore rule itself is present. - - This plugin still reads, or reports as retired, the `.claude/` paths named here; until the plugin migrates, keep config where this page says it is read, then move it where [config locations](../../reference/config-locations.md) says. + `apply`. Absent file is OK once the ignore rule itself is present. Per key, + `bash "${CLAUDE_PLUGIN_ROOT}/lib/convention-key.sh" local-value "$REPO_ROOT" ` (or + `local-list` for a list key) prints its value. **FAIL** when the *effective* `subject_pattern` is not machine-checkable. It must be either the literal keyword `Conventional Commits` or an anchored regex (`^…`-style); a plain-language description cannot be evaluated by `/source-control:commit` or `/source-control:pull-request`. Name the layer that supplied the offending value. -With **all three layers absent**: INFO, no declared convention; `/source-control:commit` and `/source-control:pull-request` infer +With **every layer and old location absent**: INFO, no declared convention; `/source-control:commit` and `/source-control:pull-request` infer from the repo's own `CLAUDE.md`/rules/commit-msg hook, then fall back to the bundled Conventional Commits default. The remediation is `apply` to persist a convention. @@ -291,29 +300,34 @@ The full write path is normative in [reference/apply-convention.md](reference/apply-convention.md). Read it before writing any layer. In brief: -- **Target layer.** `layer=` picks `user` / `team` (default) / `local`; infer the layer from the +- **Target layer.** `layer=` picks `team` (default) / `local`; infer the layer from the request's wording and state the pick before writing, the wrong layer either misses teammates or - commits a personal preference to shared history. When `REPO_ROOT` is `$HOME` or an ancestor of - it, or is not inside a git working tree, refuse `layer=team` and `layer=local` (at home they - would write the operator's personal files under a team label; outside a - repository there is no team to share with) and offer `layer=user`. + commits a personal preference to shared history. There is no user-global layer: `layer=user` + is refused, naming `team` or `local` in each repository that needs the value. When `REPO_ROOT` + is `$HOME` or an ancestor of it, or is not inside a git working tree, refuse to write (at home + the files would land in the operator's home directory under a team label; outside a repository + there is no team to share with). +- **Move config off the old locations.** For each file `check` named at an old location, show a + preview of the keys it carries and where each goes, and after a yes copy them into the new + location, check the new location resolves the same values, then delete the old file. Never + without the yes; a decline leaves the file, still read and still warned about. The spoke's + "Move config off the old locations" owns the steps. - **Non-interactive** (`subject_pattern=`): an in-place *update*, never a fresh file. Carry every independent key, recompute derived keys (`type_list`, `pr_title_pattern`), reject a - non-machine-checkable value, and for a `user` or `local` write omit requested keys the layers below already - resolve identically. + non-machine-checkable value, and for a `local` write omit requested keys the team layer already + resolves identically. - **`branch_issue_pattern=`**: alone, it writes or replaces only the `branch_issue_pattern` key of - the chosen layer (a quoted scalar in the team YAML; the `## branch_issue_pattern` section, value in - backticks, in a markdown layer), leaving every other key untouched; with + the chosen layer (a quoted scalar in the YAML), leaving every other key untouched; with `subject_pattern=`, both are written in one pass. Reject a value that is not a valid ERE, holds a backreference, or has no capture group, then confirm `parse-branch-issue.sh ` prints the expected number. -- **Interactive:** the interview. Anchor at `REPO_ROOT`, read all three layers first, infer before +- **Interactive:** the interview. Anchor at `REPO_ROOT`, read every layer first, infer before asking (declared prose, commit-msg hooks, commit-history consensus over the configurable `setup_inference_*` window), interview one decision at a time with a recommendation first, settle the optional keys (`trailer_policy`, `pr_body_attribution`, `pr_body_required_sections`, including the `none` value and the omission-never-resets trap), write the template, verify per - layer (team = tracked and staged; local = ignored and untracked, two independent probes; user = - no git command at all), and report the new **effective merge**, not just what was written. + layer (team = tracked and staged; local = ignored and untracked, two independent probes), and + report the new **effective merge**, not just what was written. - **Neutral SSOT:** a `team` write may materialize a tool-agnostic flat-scalar YAML file other tools consume too, always at the well-known path `docs/conventions/source-control/commit-convention.yml` @@ -428,7 +442,7 @@ later. Where each plugin variable resolves: the plugins reference, - Enforce the convention at commit time, a project's own `commit-msg` hook (when one exists) remains the authoritative gate; this config only tells the plugin's skills what shape to draft and pre-check against. -- Write the consumer's `.gitignore`, except the one recursive `.claude/**/*.local.*` line at +- Write the consumer's `.gitignore`, except the one recursive `docs/conventions/**/*.local.*` line at team-layer bind / `apply`. That line must exist before any personal override is written, so `apply` appends it when missing and announces the edit. Everything else in `.gitignore` stays the consumer's. diff --git a/plugins/source-control/skills/setup/evals/docs/conventions/source-control.local.yaml b/plugins/source-control/skills/setup/evals/docs/conventions/source-control.local.yaml new file mode 100644 index 00000000000..da30f1c20c2 --- /dev/null +++ b/plugins/source-control/skills/setup/evals/docs/conventions/source-control.local.yaml @@ -0,0 +1 @@ +trailer_policy: none diff --git a/plugins/source-control/skills/setup/evals/evals.json b/plugins/source-control/skills/setup/evals/evals.json index e112804ad3a..5ad13794bdf 100644 --- a/plugins/source-control/skills/setup/evals/evals.json +++ b/plugins/source-control/skills/setup/evals/evals.json @@ -80,8 +80,8 @@ "id": 7, "name": "check-renders-effective-merge-with-winning-layer", "prompt": "/source-control:setup check", - "expected_output": "Reports one effective-configuration table across all three layers — a row per key with its resolved value and which layer supplied it — rather than the tracked team file's values alone. The personal override's trailer_policy: none wins that key; the team file supplies the rest. Also reports a per-layer presence line, and reports the personal override's gitignore status as a PASS when it is ignored rather than as the team file's hard-STOP condition.", - "files": ["docs/conventions/source-control.yaml", ".claude/source-control.local.md"], + "expected_output": "Reports one effective-configuration table across both layers (team docs/conventions/source-control.yaml and personal override docs/conventions/source-control.local.yaml) — a row per key with its resolved value and which layer supplied it — rather than the tracked team file's values alone. The personal override's trailer_policy: none wins that key; the team file supplies the rest. Also reports a per-layer presence line, and reports the personal override's gitignore status as a PASS when it is ignored rather than as the team file's hard-STOP condition.", + "files": ["docs/conventions/source-control.yaml", "docs/conventions/source-control.local.yaml"], "expectations": [ "Reports the effective merged configuration, not one layer's values presented as the whole convention", "Names which layer supplied each resolved key (the personal override wins trailer_policy; the team file supplies subject_pattern)", @@ -93,14 +93,14 @@ "id": 8, "name": "routes-personal-request-to-personal-override-not-team-file", "prompt": "/source-control:setup apply\n\nI personally want ticket-prefixed subjects like WEB-123: fix the thing on this repo, but don't change what the team uses.", - "expected_output": "Writes .claude/source-control.local.md, not the tracked team docs/conventions/source-control.yaml, and says which layer it picked before writing. Carries only the keys that differ from the layers below rather than restating the whole config. Verifies the personal override is gitignored — an ignore match is the success condition here, the inverse of the team file's check — never runs git add on it, and if it is not ignored, surfaces the recursive .claude/**/*.local.* line for the consumer to add rather than editing their .gitignore. Closes by reporting the resulting effective merge, not only the keys written.", + "expected_output": "Writes YAML to docs/conventions/source-control.local.yaml (never .claude/source-control.local.md), not the tracked team docs/conventions/source-control.yaml, and says which layer it picked before writing. Carries only the keys that differ from the layers below rather than restating the whole config. Verifies the personal override is gitignored — an ignore match is the success condition here, the inverse of the team file's check — never runs git add on it, and if it is not ignored, surfaces the recursive docs/conventions/**/*.local.* line for the consumer to add rather than editing their .gitignore. Closes by reporting the resulting effective merge, not only the keys written.", "files": ["docs/conventions/source-control.yaml"], "expectations": [ - "Writes the personal override path, leaving the tracked team file unmodified", + "Writes the personal override path docs/conventions/source-control.local.yaml in YAML shape, leaving the tracked team file unmodified", "States which layer it selected before writing", "Writes only the differing keys instead of restating every key from the team layer", "Treats a git check-ignore match on the personal override as success, and never stages the personal override with git add", - "When the personal override is not ignored, recommends the recursive .claude/**/*.local.* gitignore line instead of editing the consumer's .gitignore", + "When the personal override is not ignored, recommends the recursive docs/conventions/**/*.local.* gitignore line instead of editing the consumer's .gitignore", "Reports the resulting effective merge across layers rather than only the keys just written" ] }, @@ -108,13 +108,13 @@ "id": 9, "name": "user-global-write-runs-no-repo-git-checks", "prompt": "/source-control:setup apply layer=user subject_pattern=Conventional Commits", - "expected_output": "Writes ~/.claude/source-control.md and runs no git command against it — git check-ignore, git status, and git add all target the repository worktree and would produce a meaningless or confidently wrong verdict on a path outside it (including when the home directory is itself a git repository). Confirms the file exists with the intended content, reports the path, and does not claim the value is staged or committed.", + "expected_output": "Refuses layer=user before writing anything: there is no user-global layer, so ~/.claude/source-control.md is neither created nor modified, and no git command runs against it. The refusal says a value meant for every repository goes in each repository's team file (layer=team, docs/conventions/source-control.yaml) or, for one person, its personal override (layer=local, docs/conventions/source-control.local.yaml). It does not silently write the team or local layer in place of the refused one, and does not claim any value was written, staged, or committed.", "files": [], "expectations": [ - "Writes the user-global path rather than a repo path", - "Runs no git check-ignore, git status, or git add against the user-global file", - "Does not report the user-global write as staged or awaiting a commit", - "Reports the resulting effective merge, noting that an existing team file or personal override still overrides these values per key" + "Refuses layer=user and writes no file, leaving ~/.claude/source-control.md uncreated and unmodified", + "Points to layer=team or layer=local in each repository that needs the value", + "Runs no git check-ignore, git status, or git add against ~/.claude/source-control.md", + "Does not substitute a team or local write for the refused layer, and does not report any write as staged or awaiting a commit" ] }, { @@ -135,7 +135,7 @@ "name": "non-interactive-update-preserves-unrequested-personal-override-keys", "prompt": "/source-control:setup apply layer=local subject_pattern=^[A-Z]+-\\d+: .+", "expected_output": "The personal override already declares trailer_policy: none, which this invocation says nothing about. The skill reads the target layer before rewriting it and carries that key through unchanged, replacing only subject_pattern (and the pr_title_pattern derived from it). It does not treat a rewrite as a fresh file, which would silently drop the active personal trailer override and change commit behavior the user never asked to change.", - "files": ["docs/conventions/source-control.yaml", ".claude/source-control.local.md"], + "files": ["docs/conventions/source-control.yaml", "docs/conventions/source-control.local.yaml"], "expectations": [ "Reads the existing personal override before rewriting it rather than composing the file from the invocation alone", "Preserves the personal override's existing trailer_policy: none, which the invocation did not mention", @@ -236,27 +236,27 @@ { "id": 19, "name": "check-reports-missing-personal-override-ignore-without-personal-override-file", - "prompt": "/source-control:setup check\n\nThe repo has a tracked team docs/conventions/source-control.yaml and no .claude/source-control.local.md. .gitignore does not mention .claude/**/*.local.*.", - "expected_output": "Reports FAIL on the personal-override ignore rule even though no personal override file exists: the rule must be in place before the first personal override is written. Does not classify the missing rule as INFO/pass. Names apply as the remediation, which writes the recursive .claude/**/*.local.* line at team-layer bind. The presence probe is git check-ignore --no-index -v -- .claude/nested/personal-override.local.md, not the flat personal override path.", + "prompt": "/source-control:setup check\n\nThe repo has a tracked team docs/conventions/source-control.yaml and no docs/conventions/source-control.local.yaml. .gitignore does not mention docs/conventions/**/*.local.*.", + "expected_output": "Reports FAIL on the personal-override ignore rule even though no personal override file exists: the rule must be in place before the first personal override is written. Does not classify the missing rule as INFO/pass. Names apply as the remediation, which writes the recursive docs/conventions/**/*.local.* line at team-layer bind. The presence probe is git check-ignore --no-index -v -- docs/conventions/nested/personal-override.local.yaml, not the flat personal override path.", "files": [], "expectations": [ "Probes the ignore rule without requiring the personal override file to exist", - "Probes a nested sentinel (.claude/nested/personal-override.local.md) rather than the flat personal override path", + "Probes a nested sentinel (docs/conventions/nested/personal-override.local.yaml) rather than the flat personal override path", "Counts only a repository .gitignore match, not info/exclude or core.excludesFile", - "Missing .claude/**/*.local.* rule is FAIL, not INFO", + "Missing docs/conventions/**/*.local.* rule is FAIL, not INFO", "Remediation is apply writing the ignore line at team-layer bind" ] }, { "id": 20, "name": "check-does-not-accept-leftover-nonrecursive-ignore-as-the-recursive-rule", - "prompt": "/source-control:setup check\n\nThe repo has a tracked team docs/conventions/source-control.yaml and no .claude/source-control.local.md. .gitignore contains .claude/*.local.* and does not contain .claude/**/*.local.*.", - "expected_output": "Reports FAIL on the personal-override ignore rule. The leftover .claude/*.local.* line matches the flat personal override path, so probing .claude/source-control.local.md would have passed; the nested sentinel .claude/nested/personal-override.local.md does not match that line, so check still FAILs and names apply as the remediation (append .claude/**/*.local.* at team-layer bind).", + "prompt": "/source-control:setup check\n\nThe repo has a tracked team docs/conventions/source-control.yaml and no docs/conventions/source-control.local.yaml. .gitignore contains docs/conventions/*.local.* and does not contain docs/conventions/**/*.local.*.", + "expected_output": "Reports FAIL on the personal-override ignore rule. The leftover docs/conventions/*.local.* line matches the flat personal override path, so probing docs/conventions/source-control.local.yaml would have passed; the nested sentinel docs/conventions/nested/personal-override.local.yaml does not match that line, so check still FAILs and names apply as the remediation (append docs/conventions/**/*.local.* at team-layer bind).", "files": [], "expectations": [ - "A leftover .claude/*.local.* rule is not treated as the recursive personal override ignore rule", - "The presence probe uses .claude/nested/personal-override.local.md", - "Missing .claude/**/*.local.* is FAIL even when .claude/*.local.* is present", + "A leftover docs/conventions/*.local.* rule is not treated as the recursive personal override ignore rule", + "The presence probe uses docs/conventions/nested/personal-override.local.yaml", + "Missing docs/conventions/**/*.local.* is FAIL even when docs/conventions/*.local.* is present", "Remediation is apply appending the recursive line at team-layer bind" ] }, @@ -278,12 +278,13 @@ "id": 22, "name": "check-at-home-root-reports-team-and-personal-override-not-applicable", "prompt": "/source-control:setup check\n\nThe session's project root is the operator's home directory, which contains ~/.claude/source-control.md and no repository of its own.", - "expected_output": "Resolves the config root, classifies it as home, and reports the team layer and the personal override as not applicable with the reason `project root is the home directory (or an ancestor of it)`. Resolves user-global only and never presents ~/.claude/source-control.md as the team layer. The effective-configuration table shows user-global as the only winning layer, and the git tracked/ignored probes are not run.", + "expected_output": "Resolves the config root, classifies it as home, and reports the team layer and the personal override as not applicable with the reason `project root is the home directory (or an ancestor of it)`. Resolves only the old user-global file ~/.claude/source-control.md and never presents it as the team layer. The effective-configuration table shows that old file as the only winning source, and a WARN names it as an old location with its new location (a repository's docs/conventions/source-control.yaml, or docs/conventions/source-control.local.yaml for one person) and apply, run from the repository that should hold the config, as the move. The git tracked/ignored probes are not run.", "files": [], "expectations": [ "Reports team and personal override as not applicable and names the reason: project root is the home directory (or an ancestor of it)", - "Resolves user-global only and does not read ~/.claude/source-control.md a second time as the team layer", - "Shows user-global as the only layer that can win in the effective-configuration table", + "Resolves only the old user-global file and does not read ~/.claude/source-control.md a second time as the team layer", + "Shows the old user-global file as the only source that can win in the effective-configuration table", + "WARNs that ~/.claude/source-control.md is an old location, naming its new location in a repository and apply from that repository as the remediation", "Runs no git ls-files, git check-ignore, or trackedness probe against the home directory" ] }, @@ -291,13 +292,13 @@ "id": 23, "name": "apply-at-home-root-refuses-team-and-local-but-writes-user", "prompt": "/source-control:setup apply layer=team subject_pattern=Conventional Commits\n\nThe session's project root is the operator's home directory. Afterwards the operator re-runs with layer=user.", - "expected_output": "layer=team refuses before writing anything: at home the team path sits in the operator's home directory, so a team write would edit the operator's personal config under a team label. The refusal names the reason (`project root is the home directory (or an ancestor of it)`) and offers layer=user. layer=local refuses for the same reason. The re-run with layer=user writes ~/.claude/source-control.md, runs no git command against it, and reports the resulting effective merge.", + "expected_output": "layer=team refuses before writing anything: at home the team path sits in the operator's home directory, so a team write would edit the operator's personal config under a team label. The refusal names the reason (`project root is the home directory (or an ancestor of it)`) and says to run apply from the repository that should hold the config; it does not offer layer=user. layer=local refuses for the same reason. The re-run with layer=user is refused too: there is no user-global layer, so it points to layer=team or layer=local in each repository, writes nothing (~/.claude/source-control.md is neither created nor modified), and runs no git command against it.", "files": [], "expectations": [ "Refuses layer=team at a home project root without writing any file", - "Names the reason (project root is the home directory or an ancestor of it) and offers layer=user", + "Names the reason (project root is the home directory or an ancestor of it), says to run apply from the repository that should hold the config, and does not offer layer=user", "layer=local is refused for the same reason", - "layer=user writes ~/.claude/source-control.md and runs no git check-ignore, git status, or git add against it" + "layer=user is refused, pointing to layer=team or layer=local in each repository; ~/.claude/source-control.md is not written and no git check-ignore, git status, or git add runs against it" ] } ] diff --git a/plugins/source-control/skills/setup/reference/apply-convention.md b/plugins/source-control/skills/setup/reference/apply-convention.md index de8bb19ea94..6b33b271529 100644 --- a/plugins/source-control/skills/setup/reference/apply-convention.md +++ b/plugins/source-control/skills/setup/reference/apply-convention.md @@ -20,6 +20,7 @@ post-write verification, and the effective-merge report. Loaded from [SKILL.md]( - Step 5, write the config - Step 6, verify the write, per layer - Step 7, report the new effective merge +- [Move config off the old locations](#move-config-off-the-old-locations) - [Neutral convention SSOT (`convention_source`)](#neutral-convention-ssot-convention_source) Find a step directly with: @@ -35,30 +36,30 @@ absent, since a convention is a team artifact until someone says otherwise. | `layer=` | Target path | For | |---|---|---| -| `user` | `~/.claude/source-control.md` | the operator's own preference across every repo | | `team` (default) | `REPO_ROOT/docs/conventions/source-control.yaml` | the shared, tracked convention | -| `local` | `REPO_ROOT/.claude/source-control.local.md` | a personal deviation from team policy here | +| `local` | `REPO_ROOT/docs/conventions/source-control.local.yaml` | a personal deviation from team policy here | -This plugin still reads, or reports as retired, the `.claude/` paths named here; until the plugin migrates, keep config where this page says it is read, then move it where [config locations](../../../reference/config-locations.md) says. - -The team layer is YAML, validated by `plugins/source-control/schemas/source-control.schema.json` -([config-resolution.md](../../../reference/config-resolution.md), "The config files"). The user -and local layers stay markdown, one `## ` section per key. The retired team file -`REPO_ROOT/.claude/source-control.md` is not read by this plugin; `apply layer=team` never writes -there, and its migration step (below) copies the keys it carries into the YAML. +Both layers are YAML with the same keys, validated by +`plugins/source-control/schemas/source-control.schema.json` +([config-resolution.md](../../../reference/config-resolution.md), "The config files"). There is no +user-global layer and no `userConfig` option for these keys: refuse `layer=user`, and say a value +for every repository goes in each repository's team file, or its personal override for one person. +`apply` never writes an old location (`~/.claude/source-control.md`, +`REPO_ROOT/.claude/source-control.local.md`) or the retired team file +`REPO_ROOT/.claude/source-control.md`; the migration steps below move the keys they carry. Infer the layer rather than asking when the request names one: "my personal convention" / "on this -machine" is `local`, "for all my repos" is `user`, "our convention" is `team`. State which layer -you picked before writing, since writing to the wrong one either fails to reach teammates or -commits a personal preference to shared history. +machine" is `local`, "our convention" is `team`, and "for all my repos" is `local` in each repo +the operator names. State which layer you picked before writing, since writing to the wrong one +either fails to reach teammates or commits a personal preference to shared history. When `REPO_ROOT` is `$HOME` or an ancestor of it, or is not inside a git working tree, **refuse -`layer=team` and `layer=local`**. At home the team and personal override paths sit in the operator's home directory, beside the user-global -`~/.claude/source-control.md`, so a team write would edit the operator's personal config under a -team label; outside a repository the tracked/ignored probes -have no repository to answer against. Name the reason, the same note `parse-branch-issue.sh` -prints (`project root is the home directory (or an ancestor of it)` or `project root is not -inside a git repository`), and offer `layer=user`. Compare paths physically (slash-fold, case-fold, resolve symlinks when the +to write**. At home the team and personal override paths sit in the operator's home directory, so +a team write would edit the operator's personal files under a team label; outside a repository +the tracked/ignored probes have no repository to answer against. Name the reason, the same note +`parse-branch-issue.sh` prints (`project root is the home directory (or an ancestor of it)` or +`project root is not inside a git repository`), and say to run `apply` from the repository that +should hold the config. Compare paths physically (slash-fold, case-fold, resolve symlinks when the directory exists) so a native Windows home spelling and its MSYS alias still match. When the invocation carries a `subject_pattern=` argument, write non-interactively: use it as @@ -83,8 +84,8 @@ vocabulary the pattern does not use. Moving the other way re-adds the bundled 11 `pr_title_pattern` follows the same rule unless the user set it to a value independent of `subject_pattern`, which is carried through like any other independent key. -**Writing the `user` or `local` layer, resolve the layers below first and omit any -*requested* key already equal to that merge.** A non-interactive argument is not evidence of a genuine +**Writing the `local` layer, resolve the team layer first and omit any +*requested* key already equal to it.** A non-interactive argument is not evidence of a genuine deviation: `apply layer=local subject_pattern=X` against a team file that already declares `X` would otherwise pin `X` locally, so a later team change would be silently ignored on this machine, the exact failure per-key override exists to prevent. This applies to the requested keys only; it never @@ -104,22 +105,16 @@ file. resolution with a stderr note, printing no number rather than falling through to a lower source; a pattern with no capture group can never yield a number either, so the script prints nothing and exits 1. It reads the issue number from the **last** capture group and prints it - only when it is all digits. Write the heading exactly as `## branch_issue_pattern`, with the - value on its first non-blank line: a near-miss heading, a section with no value, or a heading or - HTML comment as that line also stops resolution - ([config-resolution.md](../../../reference/config-resolution.md)). + only when it is all digits ([config-resolution.md](../../../reference/config-resolution.md)). - **Alone** (no `subject_pattern=`): write or replace only the `branch_issue_pattern` key of the - chosen layer. For `layer=team` that is a single-quoted scalar line in the YAML + chosen layer, a single-quoted scalar line in the YAML (`branch_issue_pattern: '^[^/]+/([0-9]+)-'`), every other key and comment left byte-for-byte as it - is. For `user` and `local` it is the `## branch_issue_pattern` section, value in backticks on the - first line under the heading (a value that itself contains a backtick goes in a fenced code block - instead), every other section and the preamble untouched. When the target file does not exist yet, write the step 5 template's - preamble plus this one section, never placeholder sections for the other keys. The layered-write rule - above applies: writing `user` or `local`, when the layers below already resolve the same value, - write nothing and say so. + is. When the target file does not exist yet, write the step 5 header plus this one key, never + placeholder keys. The layered-write rule above applies: writing `local`, when the team layer + already resolves the same value, write nothing and say so. - **Combined** with `subject_pattern=`: one pass writes both. The `subject_pattern=` rules above govern its own keys (carry independent keys, recompute derived ones), this route governs the - `## branch_issue_pattern` section, and the target layer is rewritten once. + `branch_issue_pattern` key, and the target layer is rewritten once. - **Confirm the result.** After the write, run `bash "/skills/pull-request/scripts/parse-branch-issue.sh" ` from `REPO_ROOT` with a branch name that follows the new grammar, and check it prints the expected @@ -136,10 +131,10 @@ With no argument in an interactive session, run the interview: 0. **Anchor at the repo root** exactly as `check` does: resolve `REPO_ROOT` once and reuse the literal resolved path for every read, write, and git command below; re-resolve it at the top of every self-contained Bash call. -1. **Read the current config first**, all three layers, not just the target. Present the effective - merge and which layer supplies each key; the interview proposes changes against that baseline and - overwrites nothing without confirmation. Writing the `user` or `local` layer, carry only the keys that - genuinely differ from the merge below it: a layer that restates every key silently pins values +1. **Read the current config first**, every layer and old location, not just the target. Present + the effective merge and which layer supplies each key; the interview proposes changes against + that baseline and overwrites nothing without confirmation. Writing the `local` layer, carry only + the keys that genuinely differ from the team layer below it: a layer that restates every key silently pins values the base layer should still own, which is the failure mode per-key override exists to avoid. 2. **Infer before asking.** Gate this on the resolved value, not on file presence: infer whenever the **effective merged `subject_pattern` is unresolved**, which includes the case where layers exist @@ -242,7 +237,7 @@ With no argument in an interactive session, run the interview: *below* the one being written already resolve to the portable default (or the key is unset everywhere), since writing the explicit default there would just add redundant noise. When the intent is genuinely to reset back to the portable default *over* a lower layer that sets something else - (a team config requiring `Related`, and this write is a `user` or `local` layer or a team rewrite meant + (a team config requiring `Related`, and this write is the `local` layer or a team rewrite meant to drop it), the portable default must be written out explicitly as the keyword `briefing`. An omitted section would silently keep inheriting the lower layer's list instead. State the one-line reason when this applies ("written explicitly to override the team layer's @@ -270,84 +265,20 @@ With no argument in an interactive session, run the interview: where the repository has it, and confirm the layer with `bash "/lib/convention-key.sh" layer "$REPO_ROOT" `, which must print `yaml`. - For `layer=user` and `layer=local`, materialize the target layer's path with these sections: - - ```markdown - # source-control configuration - - Read by the source-control Claude Code plugin (and, where installed, the guardrails - commit-convention gate). Without those plugins this file is inert and safe to ignore. - It is a drafting aid for plugin users, not team-wide enforcement: tool-agnostic - enforcement for every committer (plugin or not) is a commit-msg hook or CI check. - - Commit-subject / PR-title convention for the source-control plugin, resolved by - `/source-control:commit` and `/source-control:pull-request` before they infer from the repo's own - CLAUDE.md/rules/commit-msg hook or fall back to the bundled Conventional Commits default. - Re-run `/source-control:setup` to change these values. - - ## subject_pattern - - - - ## type_list - - - - ## pr_title_pattern - - - - ## trailer_policy - - - - ## pr_body_attribution - - - - ## pr_body_required_sections - - ` per line, e.g.: - - Summary - - Test plan - - Related - or one literal keyword: `summary-test-plan` (Summary and Test plan only), `none` for a repo whose - convention requires no PR-body sections, or `briefing` to restate the default over a lower layer> - - ## branch_issue_pattern - - /-` convention> - ``` - - Drop any section with no content rather than leaving it empty. Writing a non-`team` layer, add one - line under the heading naming which layer this file is and that it overrides per key. The file - sits next to (or looks identical to) the team file, and the next reader has no other signal. - - The self-describing preamble above the first `##` heading exists for the reader who does NOT run - these plugins. The team file lands in shared history, and a teammate opening it deserves to know - it binds nothing on its own. It is part of the template, not an append: a reconfiguration run - rewrites the whole header block in place, never stacks a second copy. Prose above the first H2 is - inert to every consumer by construction: the enforcement resolver reads only the first non-empty - body line under a `## ` heading (`lib/resolve-convention-pattern.sh` parse contract), and the - drafting read is per-H2-key, so the preamble can never change a resolved value. + For `layer=local`, write the same YAML shape to + `REPO_ROOT/docs/conventions/source-control.local.yaml`, with the same schema header line and a + second comment line saying it is this operator's gitignored personal override, which wins over + the team file key by key. Carry only the keys that differ from the team layer. Confirm each with + `bash "/lib/convention-key.sh" local-value "$REPO_ROOT" ` (`local-list` for a + list key), which must print the written value. Where the team file sets no `subject_pattern`, the + guardrails commit-convention gate enforces this file's `subject_pattern` too + (`lib/resolve-convention-pattern.sh`); say so when writing that key. 6. **Verify the write, per layer.** The post-write check inverts between layers and there is no - shared shortcut: the team file must be tracked, the personal override must be ignored, and the - user-global file is not in a repository at all. Run the wrong one and the skill reports success - over exactly the failure it exists to catch. - - - **`layer=user`**: `~/.claude/source-control.md` is outside `REPO_ROOT`. Run no git command - against it: `git check-ignore` and `git status` on a path outside the worktree are meaningless - here, and a home directory that happens to be its own repository would produce a confidently - wrong verdict. Confirm the file exists with the intended content and report the path. It takes - effect immediately in the next session; nothing is staged or committed. - - **`layer=local`**: `REPO_ROOT/.claude/source-control.local.md` **must** be both ignore-matched + shared shortcut: the team file must be tracked and the personal override must be ignored. Run + the wrong one and the skill reports success over exactly the failure it exists to catch. + + - **`layer=local`**: `REPO_ROOT/docs/conventions/source-control.local.yaml` **must** be both ignore-matched and untracked, and those are two independent probes. Bare `git check-ignore` consults the index and reports nothing for a file that is already tracked, because gitignore rules do not apply to tracked files, so "no rule exists" and "a rule exists but the file was committed anyway" are @@ -365,12 +296,13 @@ With no argument in an interactive session, run the interview: For `layer=team`, also ensure the personal-override ignore rule exists **whether or not a personal override file has been written**. The rule belongs to bind time, not to `layer=local`. Probe a nested sentinel - (`.claude/nested/personal-override.local.md`), not the flat personal override path: a leftover - `.claude/*.local.*` rule still matches `.claude/source-control.local.md` and - would otherwise look like the recursive rule is present. If - `git check-ignore --no-index -v -- .claude/nested/personal-override.local.md` reports + (`docs/conventions/nested/personal-override.local.yaml`), not the flat personal override path: a + leftover `docs/conventions/*.local.*` rule still matches + `docs/conventions/source-control.local.yaml` and would otherwise look like the recursive rule is + present. If + `git check-ignore --no-index -v -- docs/conventions/nested/personal-override.local.yaml` reports no match **from a repository `.gitignore`** (ignore `$GIT_DIR/info/exclude` - and `core.excludesFile`), append the recursive `.claude/**/*.local.*` line + and `core.excludesFile`), append the recursive `docs/conventions/**/*.local.*` line to the consumer `.gitignore`, announce the edit, and stage that line with the team file. @@ -411,7 +343,7 @@ With no argument in an interactive session, run the interview: ```bash REPO_ROOT="" - PERSONAL_OVERRIDE=".claude/source-control.local.md" + PERSONAL_OVERRIDE="docs/conventions/source-control.local.yaml" # --no-index answers "does a matching ignore rule exist?" on its own terms. Without it, git # consults the index first and reports nothing for an already-tracked file, conflating a missing # rule with a rule that exists but was overridden by a past commit. @@ -437,7 +369,7 @@ With no argument in an interactive session, run the interview: echo "FAIL: $PERSONAL_OVERRIDE is tracked; untrack it with: git rm --cached $PERSONAL_OVERRIDE" >&2 exit 1 else - echo "FAIL: no ignore rule matches $PERSONAL_OVERRIDE; add .claude/**/*.local.* to .gitignore" >&2 + echo "FAIL: no ignore rule matches $PERSONAL_OVERRIDE; add docs/conventions/**/*.local.* to .gitignore" >&2 exit 1 fi ``` @@ -449,7 +381,7 @@ With no argument in an interactive session, run the interview: proceed to step 7. For the team guard (`IGNORE_MATCH` reported), tell the user the matching `.gitignore` pattern and ask them to either fix `.gitignore` so the team YAML is no longer excluded, or persist the convention to a different layer. For the `layer=local` guard, - surface the failure's own remediation, the recursive `.claude/**/*.local.*` ignore line for a missing + surface the failure's own remediation, the recursive `docs/conventions/**/*.local.*` ignore line for a missing rule or `git rm --cached` for an already-tracked personal override, so the personal override does not linger in a shareable state. Re-run this step once the state is fixed. @@ -460,9 +392,9 @@ With no argument in an interactive session, run the interview: take effect. Only report success once both checks pass: not ignored, and no unstaged changes remain. -7. **Report the new effective merge**, not just what was written. A `layer=user` write can be - overridden by an existing team file, and a `layer=team` write can be overridden by an existing - personal override. A user who is told only "wrote `subject_pattern`" and then sees `/source-control:commit` use a +7. **Report the new effective merge**, not just what was written. A `layer=team` write can be + overridden by an existing personal override, or by an old personal override still read while + the personal YAML is absent. A user who is told only "wrote `subject_pattern`" and then sees `/source-control:commit` use a different pattern has been misled by the success message. For a `team` write, the report also states plainly what the file is and is not: a drafting aid @@ -471,6 +403,44 @@ With no argument in an interactive session, run the interview: check; when the team wants that, point at the guardrails plugin's opt-in commit-msg hook or the repo's own hook manager rather than implying this file enforces anything by itself. +## Move config off the old locations + +Two old locations are still read during the dual-read window, and `parse-branch-issue.sh` names +each on every run, pointing here +([config-resolution.md](../../../reference/config-resolution.md), "The three layers"). The move +ends with one home per value, never two. Run it in `apply` after `check`, once per file +`bash "/lib/convention-key.sh" old-files "$REPO_ROOT"` prints: + +1. **Preview.** Read the old file's `## ` sections and show, in one preview, each key, its + value, and where it goes: + - `REPO_ROOT/.claude/source-control.local.md` → `docs/conventions/source-control.local.yaml`. + - `~/.claude/source-control.md` → `docs/conventions/source-control.local.yaml` by default, since + the file held one person's values; the operator may name this repository's + `docs/conventions/source-control.yaml` instead in the same answer. Its keys apply in every + repository the operator works in, so the preview also says the old file is kept until the + operator says it may go (in that answer, or once the other repositories have moved). + - A key the new file already sets: show both values; the new file's value stays unless the + operator picks the old one in the same answer. Name any key the schema does not declare; it + is not carried. +2. **Ask once, then write.** One confirmation covers the whole preview. Without a yes, write + nothing; the file stays, still read and still warned about. Before writing the personal YAML, + the `docs/conventions/**/*.local.*` ignore rule must match the nested sentinel from step 6; a + missing rule stops the move with step 6's remediation. With a yes, write each key in the YAML + shape of step 5 (a bullet list becomes a YAML sequence, a regex is single-quoted), carrying + every key the new file already holds, and run step 6's verification for the layer written; a + failed verification stops the move and keeps the old file. +3. **Check the values match.** For each moved key, read it back from the new file + (`convention-key.sh value`, or `local-value`, `list` and `local-list`) and compare it with the + old value, and for `branch_issue_pattern` run `parse-branch-issue.sh --explain` + from `REPO_ROOT` and confirm the number, and that the layer named is the new file or a higher + layer that already set the key. A mismatch stops the move: report it and keep the old file. +4. **Delete the old file** only after every key matched, and, for `~/.claude/source-control.md`, + only when the operator said it may go; report its path. Re-run + `old-files` last; a moved file no longer appears. + +Removing the old-location reads from this plugin is a later change, made once no old file is +reported. + ## Neutral convention SSOT (`convention_source`) For a `team` write, offer (never require) the neutral-file shape: one tool-agnostic flat-scalar From 8fb540c8e3a5c78162a947e95b49bfe97cb91b8a Mon Sep 17 00:00:00 2001 From: "melodic-automation-lanes[bot]" <337595936+melodic-automation-lanes[bot]@users.noreply.github.com> Date: Sun, 22 Nov 2026 04:54:20 +0000 Subject: [PATCH 2/4] Fix failing CI checks on work-resolve-issue/issue-18000-44983079501-1 Lane-Activity: pr-unblock/fix-ci --- ...work-resolve-issue-issue-18000-44983079501-1-2c221d7b.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.changes/guardrails/work-resolve-issue-issue-18000-44983079501-1-2c221d7b.md b/.changes/guardrails/work-resolve-issue-issue-18000-44983079501-1-2c221d7b.md index d5ec927cf76..c1d5cfd7524 100644 --- a/.changes/guardrails/work-resolve-issue-issue-18000-44983079501-1-2c221d7b.md +++ b/.changes/guardrails/work-resolve-issue-issue-18000-44983079501-1-2c221d7b.md @@ -1,5 +1,7 @@ --- -bump: none +bump: patch --- -Only a comment in the synced copy of `lib/resolve-convention-pattern.sh` changed, naming source-control's drafting layers after their move ([#18000](https://github.com/melodic-software/claude-code-plugins/issues/18000)); enforcement behavior is unchanged. +### Changed + +- Shared `resolve-convention-pattern.sh` synced where this plugin carries it: only a comment changed, naming source-control's drafting layers after their move ([#18000](https://github.com/melodic-software/claude-code-plugins/issues/18000)); enforcement behavior is unchanged. From 1235e2206b62bd90cdbbd5cba318a0842c8c8e86 Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Sun, 22 Nov 2026 01:07:30 -0500 Subject: [PATCH 3/4] fix(source-control): keep resolved config fixed through the old-file move - setup apply moves ~/.claude/source-control.md to the team YAML by default, as #18000's mapping table says; the personal YAML is the operator's alternative. A key a layer above the old file already sets is shown and not carried, and step 3 compares each key's resolved value before and after the move, not only the per-file value. - parse-branch-issue.test.sh strips old-location notes only in cases that set up an old file; every other case keeps the strict empty-stderr check. Test count unchanged (107). - Rename two setup eval cases whose names contradicted their expected output: user-layer-refused-writes-nothing and apply-at-home-root-refuses-every-layer. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RAoAtUnz4WHB5auUnwQYq7 --- .../scripts/parse-branch-issue.test.sh | 5 +++- .../skills/setup/evals/evals.json | 4 +-- .../setup/reference/apply-convention.md | 30 +++++++++++-------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/plugins/source-control/skills/pull-request/scripts/parse-branch-issue.test.sh b/plugins/source-control/skills/pull-request/scripts/parse-branch-issue.test.sh index 429f6df027e..73c2465993c 100755 --- a/plugins/source-control/skills/pull-request/scripts/parse-branch-issue.test.sh +++ b/plugins/source-control/skills/pull-request/scripts/parse-branch-issue.test.sh @@ -134,7 +134,10 @@ run_cfg() { bash "$PARSER" "$branch" "$pattern" 2>"$errfile") fi rc=$? - err=$(grep -v -- "$OLD_LOCATION_NOTE" "$errfile") + err=$(<"$errfile") + if [[ -f "${CASE_HOME}/.claude/source-control.md" || -f "${CASE_REPO}/.claude/source-control.local.md" ]]; then + err=$(grep -v -- "$OLD_LOCATION_NOTE" "$errfile") + fi local err_ok=1 if [[ "$err_check" == "empty" ]]; then [[ -z "$err" ]] || err_ok=0 diff --git a/plugins/source-control/skills/setup/evals/evals.json b/plugins/source-control/skills/setup/evals/evals.json index 5ad13794bdf..b12f8cbde5d 100644 --- a/plugins/source-control/skills/setup/evals/evals.json +++ b/plugins/source-control/skills/setup/evals/evals.json @@ -106,7 +106,7 @@ }, { "id": 9, - "name": "user-global-write-runs-no-repo-git-checks", + "name": "user-layer-refused-writes-nothing", "prompt": "/source-control:setup apply layer=user subject_pattern=Conventional Commits", "expected_output": "Refuses layer=user before writing anything: there is no user-global layer, so ~/.claude/source-control.md is neither created nor modified, and no git command runs against it. The refusal says a value meant for every repository goes in each repository's team file (layer=team, docs/conventions/source-control.yaml) or, for one person, its personal override (layer=local, docs/conventions/source-control.local.yaml). It does not silently write the team or local layer in place of the refused one, and does not claim any value was written, staged, or committed.", "files": [], @@ -290,7 +290,7 @@ }, { "id": 23, - "name": "apply-at-home-root-refuses-team-and-local-but-writes-user", + "name": "apply-at-home-root-refuses-every-layer", "prompt": "/source-control:setup apply layer=team subject_pattern=Conventional Commits\n\nThe session's project root is the operator's home directory. Afterwards the operator re-runs with layer=user.", "expected_output": "layer=team refuses before writing anything: at home the team path sits in the operator's home directory, so a team write would edit the operator's personal config under a team label. The refusal names the reason (`project root is the home directory (or an ancestor of it)`) and says to run apply from the repository that should hold the config; it does not offer layer=user. layer=local refuses for the same reason. The re-run with layer=user is refused too: there is no user-global layer, so it points to layer=team or layer=local in each repository, writes nothing (~/.claude/source-control.md is neither created nor modified), and runs no git command against it.", "files": [], diff --git a/plugins/source-control/skills/setup/reference/apply-convention.md b/plugins/source-control/skills/setup/reference/apply-convention.md index 6b33b271529..6f0f2a88d50 100644 --- a/plugins/source-control/skills/setup/reference/apply-convention.md +++ b/plugins/source-control/skills/setup/reference/apply-convention.md @@ -414,14 +414,16 @@ ends with one home per value, never two. Run it in `apply` after `check`, once p 1. **Preview.** Read the old file's `## ` sections and show, in one preview, each key, its value, and where it goes: - `REPO_ROOT/.claude/source-control.local.md` → `docs/conventions/source-control.local.yaml`. - - `~/.claude/source-control.md` → `docs/conventions/source-control.local.yaml` by default, since - the file held one person's values; the operator may name this repository's - `docs/conventions/source-control.yaml` instead in the same answer. Its keys apply in every - repository the operator works in, so the preview also says the old file is kept until the - operator says it may go (in that answer, or once the other repositories have moved). - - A key the new file already sets: show both values; the new file's value stays unless the - operator picks the old one in the same answer. Name any key the schema does not declare; it - is not carried. + - `~/.claude/source-control.md` → this repository's `docs/conventions/source-control.yaml` (the + team layer) by default; the operator may name `docs/conventions/source-control.local.yaml` + instead in the same answer. Its keys apply in every repository the operator works in, so the + preview also says the old file is kept until the operator says it may go (in that answer, or + once the other repositories have moved). + - The move never changes a resolved value. The old user-global file is the lowest layer, and + the personal YAML wins over team, so a key any layer above the old file already sets + (the target, or for a personal target the tracked team YAML) is shown with both values and + not carried; the resolved value stays unless the operator picks the old one in the same + answer. Name any key the schema does not declare; it is not carried. 2. **Ask once, then write.** One confirmation covers the whole preview. Without a yes, write nothing; the file stays, still read and still warned about. Before writing the personal YAML, the `docs/conventions/**/*.local.*` ignore rule must match the nested sentinel from step 6; a @@ -429,11 +431,13 @@ ends with one home per value, never two. Run it in `apply` after `check`, once p shape of step 5 (a bullet list becomes a YAML sequence, a regex is single-quoted), carrying every key the new file already holds, and run step 6's verification for the layer written; a failed verification stops the move and keeps the old file. -3. **Check the values match.** For each moved key, read it back from the new file - (`convention-key.sh value`, or `local-value`, `list` and `local-list`) and compare it with the - old value, and for `branch_issue_pattern` run `parse-branch-issue.sh --explain` - from `REPO_ROOT` and confirm the number, and that the layer named is the new file or a higher - layer that already set the key. A mismatch stops the move: report it and keep the old file. +3. **Check the values match.** Before writing, record each key's resolved value across all layers + (config-resolution.md), and for `branch_issue_pattern` the number + `parse-branch-issue.sh --explain` prints from `REPO_ROOT`. After writing, read + each moved key back from the new file (`convention-key.sh value`, or `local-value`, `list` and + `local-list`) and compare it with the old value, then resolve every key again, with the old file + set aside, and compare with the recorded value, except a key the operator chose to change. A + mismatch stops the move: report it and keep the old file. 4. **Delete the old file** only after every key matched, and, for `~/.claude/source-control.md`, only when the operator said it may go; report its path. Re-run `old-files` last; a moved file no longer appears. From e3a271012a735d6fb0671edb77b45ad2290046a2 Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Sun, 22 Nov 2026 02:13:54 -0500 Subject: [PATCH 4/4] fix(source-control): decide what the old-file move carries before writing setup apply now resolves each key across the layers read today before the preview, and carries a key only when the old file is the layer that supplies its resolved value. An old .claude/source-control.local.md that is not read, because the personal YAML exists, has every key shown and none carried. A step 3 mismatch restores the target to its pre-write content before stopping. Docs only; tests unchanged (107). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RAoAtUnz4WHB5auUnwQYq7 --- .../setup/reference/apply-convention.md | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/plugins/source-control/skills/setup/reference/apply-convention.md b/plugins/source-control/skills/setup/reference/apply-convention.md index 6f0f2a88d50..59f920aa9b0 100644 --- a/plugins/source-control/skills/setup/reference/apply-convention.md +++ b/plugins/source-control/skills/setup/reference/apply-convention.md @@ -419,11 +419,15 @@ ends with one home per value, never two. Run it in `apply` after `check`, once p instead in the same answer. Its keys apply in every repository the operator works in, so the preview also says the old file is kept until the operator says it may go (in that answer, or once the other repositories have moved). - - The move never changes a resolved value. The old user-global file is the lowest layer, and - the personal YAML wins over team, so a key any layer above the old file already sets - (the target, or for a personal target the tracked team YAML) is shown with both values and - not carried; the resolved value stays unless the operator picks the old one in the same - answer. Name any key the schema does not declare; it is not carried. + - The move never changes a resolved value. Before the preview, resolve each key across the + layers read today ([config-resolution.md](../../../reference/config-resolution.md); for + `branch_issue_pattern`, `parse-branch-issue.sh --explain` from `REPO_ROOT`) + and record the value and the layer that supplies it. Carry a key only when the old file is + that layer; nothing above it sets the key, so the target supplies the same value. Every other + key is shown with both values and not carried: one a higher layer supplies, and every key of + an old personal override that is not read because the personal YAML exists. The operator may + pick the old value in the same answer. + Name any key the schema does not declare; it is not carried. 2. **Ask once, then write.** One confirmation covers the whole preview. Without a yes, write nothing; the file stays, still read and still warned about. Before writing the personal YAML, the `docs/conventions/**/*.local.*` ignore rule must match the nested sentinel from step 6; a @@ -431,13 +435,11 @@ ends with one home per value, never two. Run it in `apply` after `check`, once p shape of step 5 (a bullet list becomes a YAML sequence, a regex is single-quoted), carrying every key the new file already holds, and run step 6's verification for the layer written; a failed verification stops the move and keeps the old file. -3. **Check the values match.** Before writing, record each key's resolved value across all layers - (config-resolution.md), and for `branch_issue_pattern` the number - `parse-branch-issue.sh --explain` prints from `REPO_ROOT`. After writing, read - each moved key back from the new file (`convention-key.sh value`, or `local-value`, `list` and - `local-list`) and compare it with the old value, then resolve every key again, with the old file - set aside, and compare with the recorded value, except a key the operator chose to change. A - mismatch stops the move: report it and keep the old file. +3. **Check the values match.** Read each moved key back from the new file (`convention-key.sh + value`, or `local-value`, `list` and `local-list`) and compare it with the old value, then + resolve every key again and compare with the value recorded in step 1, except a key the + operator chose to change. A mismatch restores the target to its content before the write + (removing it if the move created it), reports the mismatch, and keeps the old file. 4. **Delete the old file** only after every key matched, and, for `~/.claude/source-control.md`, only when the operator said it may go; report its path. Re-run `old-files` last; a moved file no longer appears.