Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
bump: patch
---

### 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.
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 6 additions & 6 deletions lib/resolve-convention-pattern.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions plugins/guardrails/hooks/resolve-convention-pattern.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions plugins/source-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
],
Expand All @@ -29,7 +29,7 @@
{
"tool": "Bash",
"input": {
"command": "printf '.claude/**/*.local.*\\n' >> .gitignore"
"command": "printf 'docs/conventions/**/*.local.*\\n' >> .gitignore"
}
}
],
Expand All @@ -40,7 +40,7 @@
{
"tool": "Bash",
"input": {
"command": "echo '.claude/**/*.local.*' | tee -a .gitignore"
"command": "echo 'docs/conventions/**/*.local.*' | tee -a .gitignore"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
type: file_exists
path: .claude/source-control.local.md
path: docs/conventions/source-control.local.yaml
exists: false
arm: both
---
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
]
}
Original file line number Diff line number Diff line change
@@ -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"
26 changes: 21 additions & 5 deletions plugins/source-control/lib/convention-key.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -39,26 +41,37 @@ 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
}

# 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
Expand All @@ -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
Expand Down
Loading
Loading