@rvdbreemen/adr-kit-opencode 0.52.0

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 (129) hide show
  1. package/.claude-plugin/plugin.json +29 -0
  2. package/LICENSE +21 -0
  3. package/README.md +850 -0
  4. package/bin/adr +1552 -0
  5. package/bin/adr-audit +454 -0
  6. package/bin/adr-context +584 -0
  7. package/bin/adr-discover +546 -0
  8. package/bin/adr-doctor +166 -0
  9. package/bin/adr-generate-scripts +421 -0
  10. package/bin/adr-grill-signal +131 -0
  11. package/bin/adr-guardian +1263 -0
  12. package/bin/adr-index +199 -0
  13. package/bin/adr-judge +2832 -0
  14. package/bin/adr-judge-precommit +87 -0
  15. package/bin/adr-lint +2087 -0
  16. package/bin/adr-mcp +1093 -0
  17. package/bin/adr-migrate +644 -0
  18. package/bin/adr-quality +275 -0
  19. package/bin/adr-readiness +211 -0
  20. package/bin/adr-readiness-ci +111 -0
  21. package/bin/adr-related +401 -0
  22. package/bin/adr-renumber +254 -0
  23. package/bin/adr-retire +467 -0
  24. package/bin/adr-settings +399 -0
  25. package/bin/adr-status +797 -0
  26. package/bin/adr-suggest +803 -0
  27. package/bin/adr-watch +674 -0
  28. package/bin/adr_catalog.py +536 -0
  29. package/bin/adr_config.py +280 -0
  30. package/bin/adr_doctor_checks.py +407 -0
  31. package/bin/adr_doctor_core.py +342 -0
  32. package/bin/adr_doctor_models.py +186 -0
  33. package/bin/adr_doctor_probes.py +216 -0
  34. package/bin/adr_format.py +786 -0
  35. package/bin/adr_grill_signal.py +123 -0
  36. package/bin/adr_guardian_queue.py +218 -0
  37. package/bin/adr_history_scan.py +278 -0
  38. package/bin/adr_index_core.py +443 -0
  39. package/bin/adr_llm.py +333 -0
  40. package/bin/adr_llm_judge_migration.py +314 -0
  41. package/bin/adr_quality_core.py +674 -0
  42. package/bin/adr_query.py +678 -0
  43. package/bin/adr_readiness.py +442 -0
  44. package/bin/adr_readiness_ci.py +123 -0
  45. package/bin/adr_regex.py +165 -0
  46. package/bin/adr_regex_worker.py +30 -0
  47. package/bin/adr_retrieval_health.py +385 -0
  48. package/bin/adr_schema.py +448 -0
  49. package/bin/adr_state.py +172 -0
  50. package/bin/bump-version +71 -0
  51. package/clients/workflows.json +229 -0
  52. package/hooks/__init__.py +1 -0
  53. package/hooks/adapters/__init__.py +13 -0
  54. package/hooks/adapters/claude.py +27 -0
  55. package/hooks/adapters/codex.py +26 -0
  56. package/hooks/adapters/copilot.py +11 -0
  57. package/hooks/adr-hook.py +128 -0
  58. package/hooks/adr_hook_core.py +843 -0
  59. package/hooks/adr_pr_guard.py +367 -0
  60. package/instructions/ADR-guide.md +48 -0
  61. package/instructions/adr.coding.md +82 -0
  62. package/instructions/adr.review.md +182 -0
  63. package/opencode/plugin.ts +451 -0
  64. package/package.json +41 -0
  65. package/schemas/adr-context-probes.schema.json +56 -0
  66. package/schemas/adr-enforcement.schema.json +57 -0
  67. package/schemas/adr-frontmatter.schema.json +144 -0
  68. package/schemas/adr-index.schema.json +276 -0
  69. package/schemas/adr-kit-config.schema.json +371 -0
  70. package/schemas/adr-readiness.schema.json +41 -0
  71. package/schemas/client-capabilities.schema.json +503 -0
  72. package/schemas/client-certification.schema.json +101 -0
  73. package/schemas/doctor-output.schema.json +92 -0
  74. package/schemas/marketplace.json.schema.json +70 -0
  75. package/schemas/plugin.json.schema.json +67 -0
  76. package/scripts/adr_settings.py +239 -0
  77. package/scripts/benchmark-adr-grilling.py +323 -0
  78. package/scripts/benchmark-client-generation.py +178 -0
  79. package/scripts/build-client-adapters.py +139 -0
  80. package/scripts/bump-version.py +304 -0
  81. package/scripts/check-branch-sync.py +243 -0
  82. package/scripts/check-release-version.py +81 -0
  83. package/scripts/client_certification.py +153 -0
  84. package/scripts/client_evidence.py +280 -0
  85. package/scripts/client_generation.py +288 -0
  86. package/scripts/client_generation_artifacts.py +351 -0
  87. package/scripts/client_generation_model.py +173 -0
  88. package/scripts/client_generation_state.py +260 -0
  89. package/scripts/client_support_matrix.py +360 -0
  90. package/scripts/install-agent-envs.py +300 -0
  91. package/scripts/probe-client-events.py +183 -0
  92. package/scripts/project_setup.py +379 -0
  93. package/scripts/refresh-otgw-corpus.py +219 -0
  94. package/scripts/settings.py +81 -0
  95. package/scripts/setup-project.py +205 -0
  96. package/scripts/sync-agent-plugins.py +17 -0
  97. package/scripts/version_sites.py +377 -0
  98. package/skills/adr/SKILL.md +780 -0
  99. package/skills/audit/SKILL.md +103 -0
  100. package/skills/context/SKILL.md +77 -0
  101. package/skills/grill/SKILL.md +84 -0
  102. package/skills/grill/agents/openai.yaml +4 -0
  103. package/skills/guardian/SKILL.md +316 -0
  104. package/skills/init/SKILL.md +499 -0
  105. package/skills/install-hooks/SKILL.md +154 -0
  106. package/skills/judge/SKILL.md +168 -0
  107. package/skills/lint/SKILL.md +321 -0
  108. package/skills/migrate/SKILL.md +313 -0
  109. package/skills/related/SKILL.md +62 -0
  110. package/skills/retire/SKILL.md +41 -0
  111. package/skills/review/SKILL.md +167 -0
  112. package/skills/settings/SKILL.md +73 -0
  113. package/skills/setup/SKILL.md +128 -0
  114. package/skills/supersede/SKILL.md +136 -0
  115. package/skills/upgrade/SKILL.md +273 -0
  116. package/templates/adr-kit-guide.md +354 -0
  117. package/templates/adr-template.canonical.md +115 -0
  118. package/templates/adr-template.madr.md +131 -0
  119. package/templates/adr-template.md +131 -0
  120. package/templates/adr-template.nygard.md +111 -0
  121. package/templates/cc-settings/guardian-hook-entry.json +9 -0
  122. package/templates/githooks/pre-commit +337 -0
  123. package/templates/github-workflows/adr-audit.yml +58 -0
  124. package/templates/github-workflows/adr-guardian-audit.yml +133 -0
  125. package/templates/github-workflows/adr-index-check.yml +30 -0
  126. package/templates/github-workflows/adr-judge.yml +31 -0
  127. package/templates/github-workflows/adr-readiness.yml +18 -0
  128. package/templates/validate_adr_template.py +38 -0
  129. package/templates/validate_adr_template.sh +74 -0
package/bin/adr-index ADDED
@@ -0,0 +1,199 @@
1
+ #!/usr/bin/env python3
2
+ """adr-index: generate ADR indexes for context injection and local README navigation.
3
+
4
+ Two modes intentionally share one command:
5
+
6
+ Context mode, used by ADR-004 and CI:
7
+ adr-index
8
+ adr-index --adr-dir docs/adr -o docs/adr/ADR-INDEX.md
9
+ adr-index --adr-dir docs/adr --format json
10
+ adr-index --adr-dir docs/adr --format graph
11
+
12
+ README mode, used by lifecycle and doctor tooling:
13
+ adr-index docs/adr/
14
+ adr-index --check docs/adr/
15
+ adr-index --check --format json docs/adr/
16
+
17
+ The context index is a compact one-row-per-ADR map imported by CLAUDE.md. The
18
+ README index owns only the sentinel-delimited block in docs/adr/README.md and
19
+ preserves all human prose outside it.
20
+ """
21
+
22
+ from __future__ import annotations
23
+
24
+ import argparse
25
+ import importlib.machinery
26
+ import importlib.util
27
+ import io
28
+ import json
29
+ import re
30
+ import sys
31
+ from pathlib import Path
32
+ from typing import Dict, List, Optional
33
+
34
+ _BIN_DIR = Path(__file__).resolve().parent
35
+
36
+
37
+ def _load_sibling(name: str):
38
+ """Import bin/<name>.py by explicit path, WITHOUT touching sys.path.
39
+
40
+ SEC-HIGH (TASK-62): `sys.path.insert(0, _BIN_DIR)` put this directory ahead
41
+ of the standard library for every import, so a module committed next to
42
+ this script executed as code -- and it re-added the very directory
43
+ CPython's -P / PYTHONSAFEPATH removes. Siblings are registered in
44
+ sys.modules under their bare name, so the plain `from adr_* import ...`
45
+ statements below (and the lazy ones inside functions) resolve from the
46
+ cache instead of the path. bin/adr-judge carries the full rationale.
47
+ """
48
+ cached = sys.modules.get(name)
49
+ if cached is not None:
50
+ return cached
51
+ loader = importlib.machinery.SourceFileLoader(name, str(_BIN_DIR / f"{name}.py"))
52
+ spec = importlib.util.spec_from_loader(name, loader)
53
+ module = importlib.util.module_from_spec(spec)
54
+ sys.modules[name] = module
55
+ loader.exec_module(module)
56
+ return module
57
+
58
+
59
+ # Dependency order: adr_catalog imports adr_format and adr_schema.
60
+ _load_sibling("adr_format")
61
+ _load_sibling("adr_schema")
62
+ _load_sibling("adr_catalog")
63
+
64
+ _load_sibling("adr_index_core")
65
+
66
+ from adr_index_core import (
67
+ BEGIN,
68
+ END,
69
+ INDEX_ARTIFACTS,
70
+ _ensure_utf8_streams,
71
+ build_readme_payload,
72
+ default_readme,
73
+ discover_files,
74
+ enforcement_globs,
75
+ index_probably_fresh,
76
+ load_index,
77
+ render_context_json,
78
+ render_generated_readme_block,
79
+ render_graph_json,
80
+ render_markdown,
81
+ render_readme_text,
82
+ stale_index_artifacts,
83
+ update_readme,
84
+ _find_adr_dir,
85
+ )
86
+
87
+
88
+ def _should_use_context_mode(args: argparse.Namespace) -> bool:
89
+ if args.output or args.adr_dir_opt:
90
+ return True
91
+ if args.check or args.readme:
92
+ return False
93
+ return args.adr_dir_arg is None
94
+
95
+
96
+ def _run_context_mode(args: argparse.Namespace) -> int:
97
+ fmt = args.format or "md"
98
+ if fmt not in {"md", "json", "graph"}:
99
+ sys.stderr.write("adr-index: context mode supports --format md|json|graph\n")
100
+ return 2
101
+ adr_dir = _find_adr_dir(args.adr_dir_opt or args.adr_dir_arg)
102
+ rows = load_index(adr_dir) if adr_dir is not None else []
103
+ if fmt == "graph":
104
+ text = render_graph_json(rows)
105
+ elif fmt == "json":
106
+ text = render_context_json(rows)
107
+ else:
108
+ text = render_markdown(rows)
109
+
110
+ if args.output:
111
+ try:
112
+ Path(args.output).write_text(text, encoding="utf-8")
113
+ except OSError as exc:
114
+ sys.stderr.write(f"adr-index: cannot write {args.output}: {exc}\n")
115
+ return 0
116
+ else:
117
+ sys.stdout.write(text)
118
+ return 0
119
+
120
+
121
+ def _run_readme_mode(args: argparse.Namespace) -> int:
122
+ fmt = args.format or "text"
123
+ if fmt not in {"text", "json"}:
124
+ sys.stderr.write("adr-index: README mode supports --format text|json\n")
125
+ return 2
126
+
127
+ adr_dir = Path(args.adr_dir_arg or args.adr_dir_opt or "docs/adr")
128
+ readme = Path(args.readme) if args.readme else adr_dir / "README.md"
129
+ payload = build_readme_payload(adr_dir, readme)
130
+ desired_readme = payload.pop("_desired_readme")
131
+ desired_markdown = payload.pop("_desired_markdown")
132
+ desired_json = payload.pop("_desired_json")
133
+
134
+ if fmt == "json":
135
+ print(json.dumps(payload, indent=2))
136
+ else:
137
+ print(render_readme_text(payload, args.check))
138
+
139
+ if payload["issues"]:
140
+ return 1
141
+ if args.check:
142
+ return 1 if payload["summary"]["changed"] else 0
143
+
144
+ adr_dir.mkdir(parents=True, exist_ok=True)
145
+ readme.parent.mkdir(parents=True, exist_ok=True)
146
+ readme.write_text(desired_readme, encoding="utf-8")
147
+ (adr_dir / "ADR-INDEX.md").write_text(desired_markdown, encoding="utf-8")
148
+ (adr_dir / "ADR-INDEX.json").write_text(desired_json, encoding="utf-8")
149
+ return 0
150
+
151
+
152
+ def main(argv: Optional[List[str]] = None) -> int:
153
+ _ensure_utf8_streams()
154
+ parser = argparse.ArgumentParser(
155
+ prog="adr-index",
156
+ description="Generate compact ADR context indexes and docs/adr README indexes.",
157
+ )
158
+ parser.add_argument(
159
+ "adr_dir_arg",
160
+ nargs="?",
161
+ help="ADR directory. Positional form selects README mode unless -o/--adr-dir is used.",
162
+ )
163
+ parser.add_argument(
164
+ "--adr-dir",
165
+ dest="adr_dir_opt",
166
+ default=None,
167
+ help="Directory holding ADR-*.md for context mode.",
168
+ )
169
+ parser.add_argument(
170
+ "--format",
171
+ choices=("md", "text", "json", "graph"),
172
+ default=None,
173
+ help="Output format. Context: md/json (legacy list)/graph. README: text/json.",
174
+ )
175
+ parser.add_argument(
176
+ "-o",
177
+ "--output",
178
+ default=None,
179
+ help="Context mode output path, usually docs/adr/ADR-INDEX.md.",
180
+ )
181
+ parser.add_argument(
182
+ "--readme",
183
+ default=None,
184
+ help="README path for README mode (default: <adr_dir>/README.md).",
185
+ )
186
+ parser.add_argument(
187
+ "--check",
188
+ action="store_true",
189
+ help="README mode: exit 1 if README is stale or duplicate ADR ids exist.",
190
+ )
191
+ args = parser.parse_args(argv)
192
+
193
+ if _should_use_context_mode(args):
194
+ return _run_context_mode(args)
195
+ return _run_readme_mode(args)
196
+
197
+
198
+ if __name__ == "__main__":
199
+ sys.exit(main())