@rvdbreemen/adr-kit-opencode 0.52.0 → 0.52.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/.claude-plugin/plugin.json +29 -29
  2. package/README.md +861 -850
  3. package/bin/adr +0 -0
  4. package/bin/adr-audit +0 -0
  5. package/bin/adr-context +0 -0
  6. package/bin/adr-discover +0 -0
  7. package/bin/adr-doctor +0 -0
  8. package/bin/adr-generate-scripts +0 -0
  9. package/bin/adr-grill-signal +0 -0
  10. package/bin/adr-guardian +0 -0
  11. package/bin/adr-index +0 -0
  12. package/bin/adr-judge +0 -0
  13. package/bin/adr-judge-precommit +0 -0
  14. package/bin/adr-lint +0 -0
  15. package/bin/adr-mcp +0 -0
  16. package/bin/adr-migrate +0 -0
  17. package/bin/adr-quality +0 -0
  18. package/bin/adr-readiness +0 -0
  19. package/bin/adr-readiness-ci +0 -0
  20. package/bin/adr-related +0 -0
  21. package/bin/adr-renumber +254 -254
  22. package/bin/adr-retire +0 -0
  23. package/bin/adr-settings +0 -0
  24. package/bin/adr-status +0 -0
  25. package/bin/adr-suggest +0 -0
  26. package/bin/adr-watch +0 -0
  27. package/bin/bump-version +0 -0
  28. package/clients/workflows.json +229 -229
  29. package/hooks/__init__.py +1 -1
  30. package/hooks/adapters/__init__.py +13 -13
  31. package/hooks/adapters/claude.py +27 -27
  32. package/hooks/adapters/codex.py +26 -26
  33. package/hooks/adapters/copilot.py +11 -11
  34. package/hooks/adr-hook.py +128 -128
  35. package/hooks/adr_hook_core.py +843 -843
  36. package/hooks/adr_pr_guard.py +367 -367
  37. package/instructions/ADR-guide.md +48 -48
  38. package/instructions/adr.coding.md +82 -82
  39. package/instructions/adr.review.md +182 -182
  40. package/opencode/plugin.ts +1 -4
  41. package/package.json +5 -2
  42. package/schemas/adr-context-probes.schema.json +56 -56
  43. package/schemas/adr-enforcement.schema.json +57 -57
  44. package/schemas/adr-frontmatter.schema.json +144 -144
  45. package/schemas/adr-index.schema.json +276 -276
  46. package/schemas/adr-kit-config.schema.json +371 -371
  47. package/schemas/adr-readiness.schema.json +41 -41
  48. package/schemas/client-capabilities.schema.json +503 -503
  49. package/schemas/client-certification.schema.json +101 -101
  50. package/schemas/doctor-output.schema.json +92 -92
  51. package/skills/adr/SKILL.md +780 -780
  52. package/skills/audit/SKILL.md +103 -103
  53. package/skills/context/SKILL.md +77 -77
  54. package/skills/grill/SKILL.md +84 -84
  55. package/skills/grill/agents/openai.yaml +4 -4
  56. package/skills/guardian/SKILL.md +316 -316
  57. package/skills/init/SKILL.md +499 -499
  58. package/skills/install-hooks/SKILL.md +154 -154
  59. package/skills/judge/SKILL.md +168 -168
  60. package/skills/lint/SKILL.md +321 -321
  61. package/skills/migrate/SKILL.md +313 -313
  62. package/skills/related/SKILL.md +62 -62
  63. package/skills/retire/SKILL.md +41 -41
  64. package/skills/review/SKILL.md +167 -167
  65. package/skills/settings/SKILL.md +73 -73
  66. package/skills/setup/SKILL.md +128 -128
  67. package/skills/supersede/SKILL.md +136 -136
  68. package/skills/upgrade/SKILL.md +273 -273
  69. package/templates/adr-kit-guide.md +354 -354
  70. package/templates/adr-template.canonical.md +115 -115
  71. package/templates/adr-template.madr.md +131 -131
  72. package/templates/adr-template.md +131 -131
  73. package/templates/adr-template.nygard.md +111 -111
  74. package/templates/cc-settings/guardian-hook-entry.json +9 -9
  75. package/templates/githooks/pre-commit +1 -1
  76. package/templates/github-workflows/adr-audit.yml +58 -58
  77. package/templates/github-workflows/adr-guardian-audit.yml +133 -133
  78. package/templates/github-workflows/adr-index-check.yml +30 -30
  79. package/templates/github-workflows/adr-judge.yml +31 -31
  80. package/templates/github-workflows/adr-readiness.yml +18 -18
  81. package/templates/validate_adr_template.py +38 -38
  82. package/templates/validate_adr_template.sh +74 -74
@@ -1,133 +1,133 @@
1
- # ADR guardian audit: weekly CI-cron sweep of the cheap tier only.
2
- #
3
- # COPY-PASTE TEMPLATE for downstream projects that use adr-kit.
4
- # Copy this file to .github/workflows/adr-guardian-audit.yml in your repo.
5
- # Unlike the adr-kit self-dogfood workflow, this variant checks out the
6
- # adr-kit tools into .adr-kit/ first, because your repo does not carry
7
- # the bin/ scripts itself. Pin ADR_KIT_REF to a release tag for stability.
8
- #
9
- # What it does (team mode, see skills/guardian/SKILL.md):
10
- # - Runs the free cheap tier: adr-lint + adr-retire + adr-status.
11
- # - Aggregates one markdown report.
12
- # - Maintains a single tracking issue ("ADR guardian audit"): created on
13
- # first findings, body updated on later runs, closed when clean.
14
- #
15
- # Invariants:
16
- # - NEVER runs an LLM (ADR-001 posture: LLM gates are opt-in and local).
17
- # - Report-only: the job always succeeds; findings go to the issue.
18
- # - No secrets beyond the default GITHUB_TOKEN.
19
-
20
- name: ADR guardian audit
21
-
22
- on:
23
- schedule:
24
- - cron: "0 6 * * 1"
25
- workflow_dispatch:
26
-
27
- permissions:
28
- contents: read
29
- issues: write
30
-
31
- env:
32
- ADR_KIT_REF: main # pin to a release tag, e.g. v0.20.1
33
-
34
- jobs:
35
- audit:
36
- runs-on: ubuntu-latest
37
- steps:
38
- - uses: actions/checkout@v4
39
- with:
40
- fetch-depth: 0
41
-
42
- - uses: actions/checkout@v4
43
- with:
44
- repository: rvdbreemen/adr-kit
45
- ref: ${{ env.ADR_KIT_REF }}
46
- path: .adr-kit
47
-
48
- - uses: actions/setup-python@v5
49
- with:
50
- python-version: "3.11"
51
-
52
- - name: Run cheap-tier sweep (lint + retire + status)
53
- id: sweep
54
- shell: bash
55
- run: |
56
- REPORT="$RUNNER_TEMP/adr-guardian-report.md"
57
- if [ ! -d docs/adr ]; then
58
- echo "No docs/adr directory; nothing to audit."
59
- echo "findings=false" >> "$GITHUB_OUTPUT"
60
- exit 0
61
- fi
62
-
63
- lint_rc=0
64
- python .adr-kit/bin/adr-lint docs/adr > "$RUNNER_TEMP/lint.txt" 2>&1 || lint_rc=$?
65
- python .adr-kit/bin/adr-retire docs/adr --repo-root . --format markdown \
66
- > "$RUNNER_TEMP/retire.md" 2>&1 || true
67
- python .adr-kit/bin/adr-status --adr-dir docs/adr --format markdown \
68
- > "$RUNNER_TEMP/status.md" 2>&1 || true
69
-
70
- {
71
- echo "# ADR guardian audit (cheap tier)"
72
- echo
73
- echo "_Last sweep: $(date -u +%Y-%m-%dT%H:%M:%SZ) · commit ${GITHUB_SHA} · report-only, no LLM._"
74
- echo
75
- echo "## Lint (adr-lint, default gates)"
76
- echo
77
- echo '```'
78
- cat "$RUNNER_TEMP/lint.txt"
79
- echo '```'
80
- echo
81
- echo "## Retirement candidates (adr-retire)"
82
- echo
83
- cat "$RUNNER_TEMP/retire.md"
84
- echo
85
- echo "## Status (adr-status)"
86
- echo
87
- cat "$RUNNER_TEMP/status.md"
88
- } > "$REPORT"
89
- cat "$REPORT"
90
-
91
- findings=false
92
- if [ "$lint_rc" -ne 0 ]; then
93
- findings=true
94
- fi
95
- if grep -q '^## ADR-' "$RUNNER_TEMP/retire.md"; then
96
- findings=true
97
- fi
98
- echo "findings=$findings" >> "$GITHUB_OUTPUT"
99
-
100
- - name: Create or update tracking issue
101
- if: steps.sweep.outputs.findings == 'true'
102
- env:
103
- GH_TOKEN: ${{ github.token }}
104
- shell: bash
105
- run: |
106
- TITLE="ADR guardian audit"
107
- existing=$(gh issue list --state open --search "\"$TITLE\" in:title" \
108
- --json number,title \
109
- --jq "[.[] | select(.title == \"$TITLE\")][0].number // empty")
110
- if [ -n "$existing" ]; then
111
- gh issue edit "$existing" --body-file "$RUNNER_TEMP/adr-guardian-report.md"
112
- echo "Updated tracking issue #$existing"
113
- else
114
- gh issue create --title "$TITLE" \
115
- --body-file "$RUNNER_TEMP/adr-guardian-report.md"
116
- fi
117
-
118
- - name: Close tracking issue when clean
119
- if: steps.sweep.outputs.findings == 'false'
120
- env:
121
- GH_TOKEN: ${{ github.token }}
122
- shell: bash
123
- run: |
124
- TITLE="ADR guardian audit"
125
- existing=$(gh issue list --state open --search "\"$TITLE\" in:title" \
126
- --json number,title \
127
- --jq "[.[] | select(.title == \"$TITLE\")][0].number // empty")
128
- if [ -n "$existing" ]; then
129
- gh issue close "$existing" \
130
- --comment "Latest guardian sweep came back clean. Closing."
131
- else
132
- echo "No open tracking issue and no findings. Nothing to do."
133
- fi
1
+ # ADR guardian audit: weekly CI-cron sweep of the cheap tier only.
2
+ #
3
+ # COPY-PASTE TEMPLATE for downstream projects that use adr-kit.
4
+ # Copy this file to .github/workflows/adr-guardian-audit.yml in your repo.
5
+ # Unlike the adr-kit self-dogfood workflow, this variant checks out the
6
+ # adr-kit tools into .adr-kit/ first, because your repo does not carry
7
+ # the bin/ scripts itself. Pin ADR_KIT_REF to a release tag for stability.
8
+ #
9
+ # What it does (team mode, see skills/guardian/SKILL.md):
10
+ # - Runs the free cheap tier: adr-lint + adr-retire + adr-status.
11
+ # - Aggregates one markdown report.
12
+ # - Maintains a single tracking issue ("ADR guardian audit"): created on
13
+ # first findings, body updated on later runs, closed when clean.
14
+ #
15
+ # Invariants:
16
+ # - NEVER runs an LLM (ADR-001 posture: LLM gates are opt-in and local).
17
+ # - Report-only: the job always succeeds; findings go to the issue.
18
+ # - No secrets beyond the default GITHUB_TOKEN.
19
+
20
+ name: ADR guardian audit
21
+
22
+ on:
23
+ schedule:
24
+ - cron: "0 6 * * 1"
25
+ workflow_dispatch:
26
+
27
+ permissions:
28
+ contents: read
29
+ issues: write
30
+
31
+ env:
32
+ ADR_KIT_REF: main # pin to a release tag, e.g. v0.20.1
33
+
34
+ jobs:
35
+ audit:
36
+ runs-on: ubuntu-latest
37
+ steps:
38
+ - uses: actions/checkout@v4
39
+ with:
40
+ fetch-depth: 0
41
+
42
+ - uses: actions/checkout@v4
43
+ with:
44
+ repository: rvdbreemen/adr-kit
45
+ ref: ${{ env.ADR_KIT_REF }}
46
+ path: .adr-kit
47
+
48
+ - uses: actions/setup-python@v5
49
+ with:
50
+ python-version: "3.11"
51
+
52
+ - name: Run cheap-tier sweep (lint + retire + status)
53
+ id: sweep
54
+ shell: bash
55
+ run: |
56
+ REPORT="$RUNNER_TEMP/adr-guardian-report.md"
57
+ if [ ! -d docs/adr ]; then
58
+ echo "No docs/adr directory; nothing to audit."
59
+ echo "findings=false" >> "$GITHUB_OUTPUT"
60
+ exit 0
61
+ fi
62
+
63
+ lint_rc=0
64
+ python .adr-kit/bin/adr-lint docs/adr > "$RUNNER_TEMP/lint.txt" 2>&1 || lint_rc=$?
65
+ python .adr-kit/bin/adr-retire docs/adr --repo-root . --format markdown \
66
+ > "$RUNNER_TEMP/retire.md" 2>&1 || true
67
+ python .adr-kit/bin/adr-status --adr-dir docs/adr --format markdown \
68
+ > "$RUNNER_TEMP/status.md" 2>&1 || true
69
+
70
+ {
71
+ echo "# ADR guardian audit (cheap tier)"
72
+ echo
73
+ echo "_Last sweep: $(date -u +%Y-%m-%dT%H:%M:%SZ) · commit ${GITHUB_SHA} · report-only, no LLM._"
74
+ echo
75
+ echo "## Lint (adr-lint, default gates)"
76
+ echo
77
+ echo '```'
78
+ cat "$RUNNER_TEMP/lint.txt"
79
+ echo '```'
80
+ echo
81
+ echo "## Retirement candidates (adr-retire)"
82
+ echo
83
+ cat "$RUNNER_TEMP/retire.md"
84
+ echo
85
+ echo "## Status (adr-status)"
86
+ echo
87
+ cat "$RUNNER_TEMP/status.md"
88
+ } > "$REPORT"
89
+ cat "$REPORT"
90
+
91
+ findings=false
92
+ if [ "$lint_rc" -ne 0 ]; then
93
+ findings=true
94
+ fi
95
+ if grep -q '^## ADR-' "$RUNNER_TEMP/retire.md"; then
96
+ findings=true
97
+ fi
98
+ echo "findings=$findings" >> "$GITHUB_OUTPUT"
99
+
100
+ - name: Create or update tracking issue
101
+ if: steps.sweep.outputs.findings == 'true'
102
+ env:
103
+ GH_TOKEN: ${{ github.token }}
104
+ shell: bash
105
+ run: |
106
+ TITLE="ADR guardian audit"
107
+ existing=$(gh issue list --state open --search "\"$TITLE\" in:title" \
108
+ --json number,title \
109
+ --jq "[.[] | select(.title == \"$TITLE\")][0].number // empty")
110
+ if [ -n "$existing" ]; then
111
+ gh issue edit "$existing" --body-file "$RUNNER_TEMP/adr-guardian-report.md"
112
+ echo "Updated tracking issue #$existing"
113
+ else
114
+ gh issue create --title "$TITLE" \
115
+ --body-file "$RUNNER_TEMP/adr-guardian-report.md"
116
+ fi
117
+
118
+ - name: Close tracking issue when clean
119
+ if: steps.sweep.outputs.findings == 'false'
120
+ env:
121
+ GH_TOKEN: ${{ github.token }}
122
+ shell: bash
123
+ run: |
124
+ TITLE="ADR guardian audit"
125
+ existing=$(gh issue list --state open --search "\"$TITLE\" in:title" \
126
+ --json number,title \
127
+ --jq "[.[] | select(.title == \"$TITLE\")][0].number // empty")
128
+ if [ -n "$existing" ]; then
129
+ gh issue close "$existing" \
130
+ --comment "Latest guardian sweep came back clean. Closing."
131
+ else
132
+ echo "No open tracking issue and no findings. Nothing to do."
133
+ fi
@@ -1,30 +1,30 @@
1
- # Generated-index freshness on every pull request.
2
- #
3
- # The lifecycle CLI regenerates README.md, ADR-INDEX.md and ADR-INDEX.json
4
- # inside its own transaction, so anything written through `bin/adr` keeps them
5
- # true. An ADR edited by hand -- or written straight to disk by a coding agent,
6
- # which is the common case in a harness -- does not. The index is what every
7
- # other tool and every agent reads first, so a stale one quietly misinforms
8
- # everything downstream.
9
- #
10
- # The commit hook warns about this; it cannot block, because it reads the
11
- # worktree while the commit is the staged snapshot. Here the checkout is the
12
- # commit, so blocking is honest.
13
- #
14
- # Copy into .github/workflows/ of your project.
15
- name: ADR index freshness
16
-
17
- on:
18
- pull_request:
19
-
20
- permissions:
21
- contents: read
22
-
23
- jobs:
24
- adr-index-check:
25
- runs-on: ubuntu-latest
26
- steps:
27
- - uses: actions/checkout@v4
28
- - uses: rvdbreemen/adr-kit/.github/actions/adr-index-check@main
29
- with:
30
- adr-dir: docs/adr
1
+ # Generated-index freshness on every pull request.
2
+ #
3
+ # The lifecycle CLI regenerates README.md, ADR-INDEX.md and ADR-INDEX.json
4
+ # inside its own transaction, so anything written through `bin/adr` keeps them
5
+ # true. An ADR edited by hand -- or written straight to disk by a coding agent,
6
+ # which is the common case in a harness -- does not. The index is what every
7
+ # other tool and every agent reads first, so a stale one quietly misinforms
8
+ # everything downstream.
9
+ #
10
+ # The commit hook warns about this; it cannot block, because it reads the
11
+ # worktree while the commit is the staged snapshot. Here the checkout is the
12
+ # commit, so blocking is honest.
13
+ #
14
+ # Copy into .github/workflows/ of your project.
15
+ name: ADR index freshness
16
+
17
+ on:
18
+ pull_request:
19
+
20
+ permissions:
21
+ contents: read
22
+
23
+ jobs:
24
+ adr-index-check:
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - uses: actions/checkout@v4
28
+ - uses: rvdbreemen/adr-kit/.github/actions/adr-index-check@main
29
+ with:
30
+ adr-dir: docs/adr
@@ -1,31 +1,31 @@
1
- # ADR enforcement on every pull request.
2
- #
3
- # The pre-commit hook judges one commit; this judges the whole branch, which is
4
- # what the reviewer is actually being asked to accept. Declarative-only by
5
- # default: no LLM, no secrets, no API key.
6
- #
7
- # Copy into .github/workflows/ of your project. The checkout MUST use
8
- # fetch-depth: 0 so both sides of the diff exist.
9
- name: ADR enforcement
10
-
11
- on:
12
- pull_request:
13
- branches: [main]
14
-
15
- permissions:
16
- contents: read
17
-
18
- jobs:
19
- adr-judge:
20
- runs-on: ubuntu-latest
21
- steps:
22
- - uses: actions/checkout@v4
23
- with:
24
- fetch-depth: 0
25
- - uses: rvdbreemen/adr-kit/.github/actions/adr-judge@main
26
- with:
27
- adr-dir: docs/adr/
28
- # A release-sized branch diff needs more room than a single commit.
29
- # This budget is deliberately separate from judge.max_diff_bytes, so
30
- # raising it here does not weaken the commit-time gate.
31
- max-diff-bytes: "33554432"
1
+ # ADR enforcement on every pull request.
2
+ #
3
+ # The pre-commit hook judges one commit; this judges the whole branch, which is
4
+ # what the reviewer is actually being asked to accept. Declarative-only by
5
+ # default: no LLM, no secrets, no API key.
6
+ #
7
+ # Copy into .github/workflows/ of your project. The checkout MUST use
8
+ # fetch-depth: 0 so both sides of the diff exist.
9
+ name: ADR enforcement
10
+
11
+ on:
12
+ pull_request:
13
+ branches: [main]
14
+
15
+ permissions:
16
+ contents: read
17
+
18
+ jobs:
19
+ adr-judge:
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - uses: actions/checkout@v4
23
+ with:
24
+ fetch-depth: 0
25
+ - uses: rvdbreemen/adr-kit/.github/actions/adr-judge@main
26
+ with:
27
+ adr-dir: docs/adr/
28
+ # A release-sized branch diff needs more room than a single commit.
29
+ # This budget is deliberately separate from judge.max_diff_bytes, so
30
+ # raising it here does not weaken the commit-time gate.
31
+ max-diff-bytes: "33554432"
@@ -1,18 +1,18 @@
1
- name: ADR readiness
2
-
3
- on:
4
- pull_request:
5
-
6
- permissions:
7
- contents: read
8
-
9
- jobs:
10
- adr-readiness:
11
- runs-on: ubuntu-latest
12
- steps:
13
- - uses: actions/checkout@v4
14
- with:
15
- fetch-depth: 0
16
- - uses: rvdbreemen/adr-kit/.github/actions/adr-readiness@v0.37.0
17
- with:
18
- adr-dir: docs/adr
1
+ name: ADR readiness
2
+
3
+ on:
4
+ pull_request:
5
+
6
+ permissions:
7
+ contents: read
8
+
9
+ jobs:
10
+ adr-readiness:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ with:
15
+ fetch-depth: 0
16
+ - uses: rvdbreemen/adr-kit/.github/actions/adr-readiness@v0.37.0
17
+ with:
18
+ adr-dir: docs/adr
@@ -1,38 +1,38 @@
1
- #!/usr/bin/env python3
2
- # Reference sample of adr-generate-scripts output; the generator does not read
3
- # this file. It exists so a human can see the expected shape of a generated
4
- # validator. Keep it in step with bin/adr-generate-scripts.
5
- #
6
- # Generated by adr-kit for ADR-NNN. Do not edit manually.
7
- # Validates stdin against ADR-NNN enforcement rules.
8
- # Usage: cat file.py | python validate.py
9
- # echo "suspicious line" | python validate.py
10
- # Exit 0 = clean, exit 1 = violations found.
11
- #
12
- # This script is fully standalone — no adr-kit dependency required.
13
- # Only the Python standard library (re, sys) is used.
14
-
15
- import re
16
- import sys
17
-
18
- # Patterns are injected by adr-generate-scripts from the ADR's ## Enforcement block.
19
- # Each entry is a compiled regex pattern and an error message.
20
- FORBID_RULES = [
21
- (re.compile('\\bFoo\\b'), 'Do not use Foo.'), # example — replaced at generation time
22
- ]
23
-
24
-
25
- def main():
26
- lines = sys.stdin.readlines()
27
- violations = 0
28
- for i, line in enumerate(lines, 1):
29
- for pattern, message in FORBID_RULES:
30
- if pattern.search(line):
31
- print(f"VIOLATION line {i}: {message}", file=sys.stderr)
32
- print(f" {line.rstrip()}", file=sys.stderr)
33
- violations += 1
34
- sys.exit(1 if violations > 0 else 0)
35
-
36
-
37
- if __name__ == "__main__":
38
- main()
1
+ #!/usr/bin/env python3
2
+ # Reference sample of adr-generate-scripts output; the generator does not read
3
+ # this file. It exists so a human can see the expected shape of a generated
4
+ # validator. Keep it in step with bin/adr-generate-scripts.
5
+ #
6
+ # Generated by adr-kit for ADR-NNN. Do not edit manually.
7
+ # Validates stdin against ADR-NNN enforcement rules.
8
+ # Usage: cat file.py | python validate.py
9
+ # echo "suspicious line" | python validate.py
10
+ # Exit 0 = clean, exit 1 = violations found.
11
+ #
12
+ # This script is fully standalone — no adr-kit dependency required.
13
+ # Only the Python standard library (re, sys) is used.
14
+
15
+ import re
16
+ import sys
17
+
18
+ # Patterns are injected by adr-generate-scripts from the ADR's ## Enforcement block.
19
+ # Each entry is a compiled regex pattern and an error message.
20
+ FORBID_RULES = [
21
+ (re.compile('\\bFoo\\b'), 'Do not use Foo.'), # example — replaced at generation time
22
+ ]
23
+
24
+
25
+ def main():
26
+ lines = sys.stdin.readlines()
27
+ violations = 0
28
+ for i, line in enumerate(lines, 1):
29
+ for pattern, message in FORBID_RULES:
30
+ if pattern.search(line):
31
+ print(f"VIOLATION line {i}: {message}", file=sys.stderr)
32
+ print(f" {line.rstrip()}", file=sys.stderr)
33
+ violations += 1
34
+ sys.exit(1 if violations > 0 else 0)
35
+
36
+
37
+ if __name__ == "__main__":
38
+ main()
@@ -1,74 +1,74 @@
1
- #!/bin/bash
2
- # validate_adr_template.sh — reference sample of adr-generate-scripts output.
3
- #
4
- # The generator does not read this file; it emits its scripts from built-in
5
- # templates. This file exists so a human can see the expected shape without
6
- # running the generator, so keep it in step with bin/adr-generate-scripts.
7
- #
8
- # This file documents the shape of generated shell validation scripts.
9
- # It is NOT runnable as-is; {PLACEHOLDERS} are replaced by the generator.
10
- # The generator in bin/adr-generate-scripts produces the actual shell script.
11
- #
12
- # Generated script behaviour:
13
- # - Reads stdin completely into memory (supports piping).
14
- # - Validates each pattern as POSIX ERE at startup and warns about
15
- # any pattern grep -E rejects (Python-only regex features won't compile
16
- # under ERE — use adr-judge for authoritative validation).
17
- # - Runs ONE grep -nE pass per rule across the full input
18
- # (O(rules) subprocess spawns, not O(lines × rules)).
19
- # - Reports VIOLATION to stderr with line number, message, and snippet.
20
- # - Exit 0 = clean, exit 1 = at least one violation.
21
- #
22
- # Example of a generated file for ADR-001 with one forbid rule:
23
- #
24
- # #!/bin/bash
25
- # # Generated by adr-kit for ADR-001. Do not edit manually.
26
- # # Validates stdin against ADR-001 enforcement rules.
27
- # # Usage: cat file.py | bash validate.sh
28
- #
29
- # set -euo pipefail
30
- #
31
- # # --- Pattern validation at startup --------------------------------
32
- # _INVALID=0
33
- # for _pat in \
34
- # '\bFoo\b'
35
- # do
36
- # if ! printf '' | grep -qE -- "$_pat" 2>/dev/null; then
37
- # printf '[adr-validate] WARN: invalid ERE pattern: %s\n' "$_pat" >&2
38
- # _INVALID=1
39
- # fi
40
- # done
41
- # if [ "$_INVALID" -eq 1 ]; then
42
- # printf '%s\n' '[adr-validate] WARN: some patterns invalid for ERE (grep). Results may be incomplete. Use adr-judge for authoritative validation.' >&2
43
- # fi
44
- #
45
- # # --- Main validation ---------------------------------------------
46
- # VIOLATIONS=0
47
- # INPUT=$(cat)
48
- #
49
- # check_rule() {
50
- # local pattern="$1"
51
- # local message="$2"
52
- # local matches
53
- # matches=$(printf '%s\n' "$INPUT" | grep -nE -- "$pattern" || true)
54
- # if [ -n "$matches" ]; then
55
- # while IFS= read -r hit; do
56
- # [ -z "$hit" ] && continue
57
- # local lineno="${hit%%:*}"
58
- # local content="${hit#*:}"
59
- # printf 'VIOLATION line %s: %s\n' "$lineno" "$message" >&2
60
- # printf ' %s\n' "$content" >&2
61
- # VIOLATIONS=$((VIOLATIONS + 1))
62
- # done <<< "$matches"
63
- # fi
64
- # }
65
- #
66
- # check_rule '\bFoo\b' 'Do not use Foo.'
67
- #
68
- # [ "$VIOLATIONS" -gt 0 ] && exit 1
69
- # exit 0
70
- #
71
- # Template placeholders (replaced by generate_shell_script in bin/adr-generate-scripts):
72
- # {adr_id} — e.g. "ADR-001"
73
- # {patterns_block} — one quoted pattern per line, for the startup validity loop
74
- # {checks_block} — one line per rule: check_rule 'PATTERN' 'MESSAGE'
1
+ #!/bin/bash
2
+ # validate_adr_template.sh — reference sample of adr-generate-scripts output.
3
+ #
4
+ # The generator does not read this file; it emits its scripts from built-in
5
+ # templates. This file exists so a human can see the expected shape without
6
+ # running the generator, so keep it in step with bin/adr-generate-scripts.
7
+ #
8
+ # This file documents the shape of generated shell validation scripts.
9
+ # It is NOT runnable as-is; {PLACEHOLDERS} are replaced by the generator.
10
+ # The generator in bin/adr-generate-scripts produces the actual shell script.
11
+ #
12
+ # Generated script behaviour:
13
+ # - Reads stdin completely into memory (supports piping).
14
+ # - Validates each pattern as POSIX ERE at startup and warns about
15
+ # any pattern grep -E rejects (Python-only regex features won't compile
16
+ # under ERE — use adr-judge for authoritative validation).
17
+ # - Runs ONE grep -nE pass per rule across the full input
18
+ # (O(rules) subprocess spawns, not O(lines × rules)).
19
+ # - Reports VIOLATION to stderr with line number, message, and snippet.
20
+ # - Exit 0 = clean, exit 1 = at least one violation.
21
+ #
22
+ # Example of a generated file for ADR-001 with one forbid rule:
23
+ #
24
+ # #!/bin/bash
25
+ # # Generated by adr-kit for ADR-001. Do not edit manually.
26
+ # # Validates stdin against ADR-001 enforcement rules.
27
+ # # Usage: cat file.py | bash validate.sh
28
+ #
29
+ # set -euo pipefail
30
+ #
31
+ # # --- Pattern validation at startup --------------------------------
32
+ # _INVALID=0
33
+ # for _pat in \
34
+ # '\bFoo\b'
35
+ # do
36
+ # if ! printf '' | grep -qE -- "$_pat" 2>/dev/null; then
37
+ # printf '[adr-validate] WARN: invalid ERE pattern: %s\n' "$_pat" >&2
38
+ # _INVALID=1
39
+ # fi
40
+ # done
41
+ # if [ "$_INVALID" -eq 1 ]; then
42
+ # printf '%s\n' '[adr-validate] WARN: some patterns invalid for ERE (grep). Results may be incomplete. Use adr-judge for authoritative validation.' >&2
43
+ # fi
44
+ #
45
+ # # --- Main validation ---------------------------------------------
46
+ # VIOLATIONS=0
47
+ # INPUT=$(cat)
48
+ #
49
+ # check_rule() {
50
+ # local pattern="$1"
51
+ # local message="$2"
52
+ # local matches
53
+ # matches=$(printf '%s\n' "$INPUT" | grep -nE -- "$pattern" || true)
54
+ # if [ -n "$matches" ]; then
55
+ # while IFS= read -r hit; do
56
+ # [ -z "$hit" ] && continue
57
+ # local lineno="${hit%%:*}"
58
+ # local content="${hit#*:}"
59
+ # printf 'VIOLATION line %s: %s\n' "$lineno" "$message" >&2
60
+ # printf ' %s\n' "$content" >&2
61
+ # VIOLATIONS=$((VIOLATIONS + 1))
62
+ # done <<< "$matches"
63
+ # fi
64
+ # }
65
+ #
66
+ # check_rule '\bFoo\b' 'Do not use Foo.'
67
+ #
68
+ # [ "$VIOLATIONS" -gt 0 ] && exit 1
69
+ # exit 0
70
+ #
71
+ # Template placeholders (replaced by generate_shell_script in bin/adr-generate-scripts):
72
+ # {adr_id} — e.g. "ADR-001"
73
+ # {patterns_block} — one quoted pattern per line, for the startup validity loop
74
+ # {checks_block} — one line per rule: check_rule 'PATTERN' 'MESSAGE'