byor 0.1.0__tar.gz

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 (40) hide show
  1. byor-0.1.0/LICENSE +201 -0
  2. byor-0.1.0/PKG-INFO +189 -0
  3. byor-0.1.0/README.md +163 -0
  4. byor-0.1.0/pyproject.toml +55 -0
  5. byor-0.1.0/src/byor/__init__.py +1 -0
  6. byor-0.1.0/src/byor/agents/__init__.py +0 -0
  7. byor-0.1.0/src/byor/agents/harness.py +254 -0
  8. byor-0.1.0/src/byor/agents/hookconfig.py +270 -0
  9. byor-0.1.0/src/byor/agents/install.py +219 -0
  10. byor-0.1.0/src/byor/agents/opencode.py +55 -0
  11. byor-0.1.0/src/byor/agents/pi.py +67 -0
  12. byor-0.1.0/src/byor/cli.py +379 -0
  13. byor-0.1.0/src/byor/commands/__init__.py +0 -0
  14. byor-0.1.0/src/byor/commands/doctor.py +316 -0
  15. byor-0.1.0/src/byor/commands/init.py +183 -0
  16. byor-0.1.0/src/byor/commands/install.py +90 -0
  17. byor-0.1.0/src/byor/commands/listing.py +107 -0
  18. byor-0.1.0/src/byor/commands/prompts.py +42 -0
  19. byor-0.1.0/src/byor/config.py +362 -0
  20. byor-0.1.0/src/byor/data/skill.md +170 -0
  21. byor-0.1.0/src/byor/errors.py +31 -0
  22. byor-0.1.0/src/byor/io/__init__.py +0 -0
  23. byor-0.1.0/src/byor/io/fsio.py +78 -0
  24. byor-0.1.0/src/byor/io/gitio.py +20 -0
  25. byor-0.1.0/src/byor/io/paths.py +52 -0
  26. byor-0.1.0/src/byor/io/yamlio.py +64 -0
  27. byor-0.1.0/src/byor/rules/__init__.py +0 -0
  28. byor-0.1.0/src/byor/rules/commands.py +381 -0
  29. byor-0.1.0/src/byor/rules/rules.py +201 -0
  30. byor-0.1.0/src/byor/rules/skill.py +59 -0
  31. byor-0.1.0/src/byor/rules/sync.py +292 -0
  32. byor-0.1.0/src/byor/scaffold/__init__.py +0 -0
  33. byor-0.1.0/src/byor/scaffold/githooks.py +73 -0
  34. byor-0.1.0/src/byor/scaffold/ignore.py +115 -0
  35. byor-0.1.0/src/byor/scaffold/sgconfig.py +100 -0
  36. byor-0.1.0/src/byor/scan/__init__.py +0 -0
  37. byor-0.1.0/src/byor/scan/agent_check.py +313 -0
  38. byor-0.1.0/src/byor/scan/astgrep.py +237 -0
  39. byor-0.1.0/src/byor/scan/checks.py +131 -0
  40. byor-0.1.0/src/byor/scan/linescope.py +95 -0
byor-0.1.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
byor-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,189 @@
1
+ Metadata-Version: 2.4
2
+ Name: byor
3
+ Version: 0.1.0
4
+ Summary: Make custom ast-grep diagnostics easy to set up, share, and expose to AI agents
5
+ Keywords: ast-grep,linter,ai,coding-agent,diagnostics,static-analysis
6
+ Author: Ryan Saxe
7
+ Author-email: Ryan Saxe <ryancsaxe+1@gmail.com>
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Topic :: Software Development :: Quality Assurance
19
+ Requires-Dist: ast-grep-cli>=0.42.3
20
+ Requires-Dist: ruamel-yaml>=0.18
21
+ Requires-Python: >=3.11
22
+ Project-URL: Homepage, https://github.com/RyanSaxe/byor
23
+ Project-URL: Repository, https://github.com/RyanSaxe/byor
24
+ Project-URL: Issues, https://github.com/RyanSaxe/byor/issues
25
+ Description-Content-Type: text/markdown
26
+
27
+ <p align="center">
28
+ <img src="https://raw.githubusercontent.com/RyanSaxe/byor/main/assets/banner.png" alt="byor: Build Your Own Rules" width="600">
29
+ </p>
30
+
31
+ Write a custom lint rule once and it becomes a live diagnostic in your terminal,
32
+ your editor, and your AI agent's feedback loop.
33
+
34
+ byor is a small CLI around [ast-grep](https://ast-grep.github.io), a fast
35
+ structural search-and-lint tool. `ast-grep scan` lints from the terminal and
36
+ `ast-grep lsp` shows diagnostics in your editor; byor arranges plain rule files
37
+ and configuration so both work without setup, then adds the two things ast-grep
38
+ leaves out: sharing rules across your repositories, and feeding their
39
+ diagnostics back into AI coding agents.
40
+
41
+ ```yaml
42
+ # .byor/rules/project/no-print.yml
43
+ id: no-print
44
+ language: python
45
+ severity: warning
46
+ message: Use the logging module, not print, in library code.
47
+ rule:
48
+ pattern: print($$$ARGS)
49
+ metadata:
50
+ byor:
51
+ agent_prompt: >
52
+ Replace this print with a module-level logger,
53
+ logging.getLogger(__name__), at the appropriate level.
54
+ ```
55
+
56
+ `message` is what you read in the terminal and editor; `agent_prompt` is the
57
+ directive byor hands your AI agent when it trips the rule.
58
+
59
+ ## Install
60
+
61
+ ```bash
62
+ uv tool install byor # or `uvx byor` to try without installing
63
+ byor install # set up the skill + your agents' hooks (once)
64
+ byor init # add byor to a repo
65
+ ```
66
+
67
+ byor bundles ast-grep, so Python 3.11+ is the only requirement. `byor install`
68
+ registers your editor and agent integrations machine-wide; `byor init` adds a
69
+ repository's rule directories and `sgconfig.yml`.
70
+ [docs/ai-agents.md](docs/ai-agents.md) covers what each step writes.
71
+
72
+ You can also let your AI coding agent handle it: open it in the repo and ask it
73
+ to set up byor.
74
+
75
+ ## Terminal and editor
76
+
77
+ A rule under `.byor/rules/` is an ordinary ast-grep rule, so the ordinary tools
78
+ read it:
79
+
80
+ ```bash
81
+ ast-grep scan # lint the repo
82
+ ast-grep scan src/ # ...or a path
83
+ ```
84
+
85
+ For live in-editor diagnostics, point your editor's ast-grep integration at
86
+ `ast-grep lsp`: rules light up as you type and reload when you edit them.
87
+ ([editor setup](https://ast-grep.github.io/guide/tools/editors.html).)
88
+
89
+ ## Rule scopes
90
+
91
+ The same rule format lives at three scopes:
92
+
93
+ | Scope | Lives in | Shared with |
94
+ | --- | --- | --- |
95
+ | `project` | `.byor/rules/project/` | Your team (committed) |
96
+ | `local` | `.byor/rules/personal/local/` | You, this repo only |
97
+ | `global` | `~/.config/byor/rules/` | You, in every repo |
98
+
99
+ Global rules are your personal standards; byor makes them apply in every repo.
100
+ Project and local rules override a global rule with the same ID, so a team
101
+ policy or a local experiment takes precedence. See [docs/rules.md](docs/rules.md)
102
+ for the rule workflow and [docs/sync-model.md](docs/sync-model.md) for how byor
103
+ copies global rules into each repo.
104
+
105
+ ## With AI coding agents
106
+
107
+ Agents can both obey your rules and write new ones:
108
+
109
+ - **Feedback.** A post-edit hook runs `byor agent-check` after the agent edits a
110
+ file and feeds the diagnostics back into its context, scoped to the lines it
111
+ changed, so it fixes violations before moving on.
112
+ - **Capture.** A bundled skill turns durable feedback ("never do this", "always
113
+ do that") into an ast-grep rule: the agent drafts it, confirms once, and runs
114
+ `byor add`. When a linter or type checker fits better, the skill offers that
115
+ instead.
116
+
117
+ `byor install` wires up the agents you pick (once, machine-wide); `byor hook`
118
+ adds or drops one later.
119
+
120
+ ```bash
121
+ byor install --agents claude-code,codex
122
+ byor hook install --agent cursor
123
+ ```
124
+
125
+ byor supports six harnesses:
126
+
127
+ | Harness | Skill | Real hook | Diagnostic precision |
128
+ | --- | --- | --- | --- |
129
+ | Claude Code | yes | `PostToolUse` | the edited lines |
130
+ | Codex | yes | `PostToolUse` | the patched lines |
131
+ | Copilot CLI | yes | `postToolUse` | best-effort path |
132
+ | Cursor | yes | `postToolUse` | the edited lines |
133
+ | OpenCode | yes | `tool.execute.after` plugin | the changed file |
134
+ | Pi | yes | `tool_result` extension | the changed file |
135
+
136
+ A `checks:` section in `.byor/config.yml` (or your global config) runs extra
137
+ command-line tools (a linter, a type checker, anything) on the changed files and
138
+ folds their output into the same feedback. See
139
+ [docs/ai-agents.md](docs/ai-agents.md).
140
+
141
+ ## Continuous integration
142
+
143
+ Project rules are committed files that work with `ast-grep`, so CI doesn't need
144
+ `byor`: a fresh clone already has everything `ast-grep scan` reads. Scan with
145
+ `--error` so warnings fail the build (a plain scan exits 0 on warnings):
146
+
147
+ ```yaml
148
+ - run: npm install -g @ast-grep/cli
149
+ - run: ast-grep scan --error
150
+ ```
151
+
152
+ ## Commands
153
+
154
+ **Setup.** You run these once to get going.
155
+
156
+ ```text
157
+ byor install Register byor's AI integrations (machine-wide)
158
+ byor init Initialize byor in a repository
159
+ byor hook Add or remove an agent integration
160
+ byor doctor Check that everything is wired up
161
+ ```
162
+
163
+ **Rules.** Your agent runs these as it captures and manages rules for you.
164
+
165
+ ```text
166
+ byor add Create a rule in a scope
167
+ byor list Show rules and where they come from
168
+ byor edit Open a rule in $EDITOR
169
+ byor remove Delete a rule
170
+ byor promote Move a personal rule into shared project rules
171
+ byor exclude Disable a global rule in this repository
172
+ byor include Re-enable an excluded global rule
173
+ ```
174
+
175
+ **Automatic.** byor runs these itself: the post-edit hook and self-heal.
176
+
177
+ ```text
178
+ byor agent-check Render diagnostics for your agent
179
+ byor sync Mirror global rules into the repo
180
+ ```
181
+
182
+ Every command takes `--help`, and repo-operating commands take `--repo PATH`
183
+ (default: search upward from the current directory).
184
+
185
+ ## Documentation
186
+
187
+ - [docs/rules.md](docs/rules.md) — rule format, scopes, and the rule workflow
188
+ - [docs/ai-agents.md](docs/ai-agents.md) — AI agent integration and `agent-check`
189
+ - [docs/sync-model.md](docs/sync-model.md) — copies, self-healing, and git hooks
byor-0.1.0/README.md ADDED
@@ -0,0 +1,163 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/RyanSaxe/byor/main/assets/banner.png" alt="byor: Build Your Own Rules" width="600">
3
+ </p>
4
+
5
+ Write a custom lint rule once and it becomes a live diagnostic in your terminal,
6
+ your editor, and your AI agent's feedback loop.
7
+
8
+ byor is a small CLI around [ast-grep](https://ast-grep.github.io), a fast
9
+ structural search-and-lint tool. `ast-grep scan` lints from the terminal and
10
+ `ast-grep lsp` shows diagnostics in your editor; byor arranges plain rule files
11
+ and configuration so both work without setup, then adds the two things ast-grep
12
+ leaves out: sharing rules across your repositories, and feeding their
13
+ diagnostics back into AI coding agents.
14
+
15
+ ```yaml
16
+ # .byor/rules/project/no-print.yml
17
+ id: no-print
18
+ language: python
19
+ severity: warning
20
+ message: Use the logging module, not print, in library code.
21
+ rule:
22
+ pattern: print($$$ARGS)
23
+ metadata:
24
+ byor:
25
+ agent_prompt: >
26
+ Replace this print with a module-level logger,
27
+ logging.getLogger(__name__), at the appropriate level.
28
+ ```
29
+
30
+ `message` is what you read in the terminal and editor; `agent_prompt` is the
31
+ directive byor hands your AI agent when it trips the rule.
32
+
33
+ ## Install
34
+
35
+ ```bash
36
+ uv tool install byor # or `uvx byor` to try without installing
37
+ byor install # set up the skill + your agents' hooks (once)
38
+ byor init # add byor to a repo
39
+ ```
40
+
41
+ byor bundles ast-grep, so Python 3.11+ is the only requirement. `byor install`
42
+ registers your editor and agent integrations machine-wide; `byor init` adds a
43
+ repository's rule directories and `sgconfig.yml`.
44
+ [docs/ai-agents.md](docs/ai-agents.md) covers what each step writes.
45
+
46
+ You can also let your AI coding agent handle it: open it in the repo and ask it
47
+ to set up byor.
48
+
49
+ ## Terminal and editor
50
+
51
+ A rule under `.byor/rules/` is an ordinary ast-grep rule, so the ordinary tools
52
+ read it:
53
+
54
+ ```bash
55
+ ast-grep scan # lint the repo
56
+ ast-grep scan src/ # ...or a path
57
+ ```
58
+
59
+ For live in-editor diagnostics, point your editor's ast-grep integration at
60
+ `ast-grep lsp`: rules light up as you type and reload when you edit them.
61
+ ([editor setup](https://ast-grep.github.io/guide/tools/editors.html).)
62
+
63
+ ## Rule scopes
64
+
65
+ The same rule format lives at three scopes:
66
+
67
+ | Scope | Lives in | Shared with |
68
+ | --- | --- | --- |
69
+ | `project` | `.byor/rules/project/` | Your team (committed) |
70
+ | `local` | `.byor/rules/personal/local/` | You, this repo only |
71
+ | `global` | `~/.config/byor/rules/` | You, in every repo |
72
+
73
+ Global rules are your personal standards; byor makes them apply in every repo.
74
+ Project and local rules override a global rule with the same ID, so a team
75
+ policy or a local experiment takes precedence. See [docs/rules.md](docs/rules.md)
76
+ for the rule workflow and [docs/sync-model.md](docs/sync-model.md) for how byor
77
+ copies global rules into each repo.
78
+
79
+ ## With AI coding agents
80
+
81
+ Agents can both obey your rules and write new ones:
82
+
83
+ - **Feedback.** A post-edit hook runs `byor agent-check` after the agent edits a
84
+ file and feeds the diagnostics back into its context, scoped to the lines it
85
+ changed, so it fixes violations before moving on.
86
+ - **Capture.** A bundled skill turns durable feedback ("never do this", "always
87
+ do that") into an ast-grep rule: the agent drafts it, confirms once, and runs
88
+ `byor add`. When a linter or type checker fits better, the skill offers that
89
+ instead.
90
+
91
+ `byor install` wires up the agents you pick (once, machine-wide); `byor hook`
92
+ adds or drops one later.
93
+
94
+ ```bash
95
+ byor install --agents claude-code,codex
96
+ byor hook install --agent cursor
97
+ ```
98
+
99
+ byor supports six harnesses:
100
+
101
+ | Harness | Skill | Real hook | Diagnostic precision |
102
+ | --- | --- | --- | --- |
103
+ | Claude Code | yes | `PostToolUse` | the edited lines |
104
+ | Codex | yes | `PostToolUse` | the patched lines |
105
+ | Copilot CLI | yes | `postToolUse` | best-effort path |
106
+ | Cursor | yes | `postToolUse` | the edited lines |
107
+ | OpenCode | yes | `tool.execute.after` plugin | the changed file |
108
+ | Pi | yes | `tool_result` extension | the changed file |
109
+
110
+ A `checks:` section in `.byor/config.yml` (or your global config) runs extra
111
+ command-line tools (a linter, a type checker, anything) on the changed files and
112
+ folds their output into the same feedback. See
113
+ [docs/ai-agents.md](docs/ai-agents.md).
114
+
115
+ ## Continuous integration
116
+
117
+ Project rules are committed files that work with `ast-grep`, so CI doesn't need
118
+ `byor`: a fresh clone already has everything `ast-grep scan` reads. Scan with
119
+ `--error` so warnings fail the build (a plain scan exits 0 on warnings):
120
+
121
+ ```yaml
122
+ - run: npm install -g @ast-grep/cli
123
+ - run: ast-grep scan --error
124
+ ```
125
+
126
+ ## Commands
127
+
128
+ **Setup.** You run these once to get going.
129
+
130
+ ```text
131
+ byor install Register byor's AI integrations (machine-wide)
132
+ byor init Initialize byor in a repository
133
+ byor hook Add or remove an agent integration
134
+ byor doctor Check that everything is wired up
135
+ ```
136
+
137
+ **Rules.** Your agent runs these as it captures and manages rules for you.
138
+
139
+ ```text
140
+ byor add Create a rule in a scope
141
+ byor list Show rules and where they come from
142
+ byor edit Open a rule in $EDITOR
143
+ byor remove Delete a rule
144
+ byor promote Move a personal rule into shared project rules
145
+ byor exclude Disable a global rule in this repository
146
+ byor include Re-enable an excluded global rule
147
+ ```
148
+
149
+ **Automatic.** byor runs these itself: the post-edit hook and self-heal.
150
+
151
+ ```text
152
+ byor agent-check Render diagnostics for your agent
153
+ byor sync Mirror global rules into the repo
154
+ ```
155
+
156
+ Every command takes `--help`, and repo-operating commands take `--repo PATH`
157
+ (default: search upward from the current directory).
158
+
159
+ ## Documentation
160
+
161
+ - [docs/rules.md](docs/rules.md) — rule format, scopes, and the rule workflow
162
+ - [docs/ai-agents.md](docs/ai-agents.md) — AI agent integration and `agent-check`
163
+ - [docs/sync-model.md](docs/sync-model.md) — copies, self-healing, and git hooks
@@ -0,0 +1,55 @@
1
+ [project]
2
+ name = "byor"
3
+ version = "0.1.0"
4
+ description = "Make custom ast-grep diagnostics easy to set up, share, and expose to AI agents"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Ryan Saxe", email = "ryancsaxe+1@gmail.com" }
8
+ ]
9
+ requires-python = ">=3.11"
10
+ license = "Apache-2.0"
11
+ license-files = ["LICENSE"]
12
+ keywords = ["ast-grep", "linter", "ai", "coding-agent", "diagnostics", "static-analysis"]
13
+ classifiers = [
14
+ "Development Status :: 4 - Beta",
15
+ "Environment :: Console",
16
+ "Intended Audience :: Developers",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Programming Language :: Python :: 3.14",
22
+ "Topic :: Software Development :: Quality Assurance",
23
+ ]
24
+ dependencies = [
25
+ "ast-grep-cli>=0.42.3",
26
+ "ruamel-yaml>=0.18",
27
+ ]
28
+
29
+ [project.urls]
30
+ Homepage = "https://github.com/RyanSaxe/byor"
31
+ Repository = "https://github.com/RyanSaxe/byor"
32
+ Issues = "https://github.com/RyanSaxe/byor/issues"
33
+
34
+ [project.scripts]
35
+ byor = "byor.cli:main"
36
+
37
+ [build-system]
38
+ requires = ["uv_build>=0.11.16,<0.12.0"]
39
+ build-backend = "uv_build"
40
+
41
+ [dependency-groups]
42
+ dev = [
43
+ "pre-commit>=4.6.0",
44
+ "pytest>=9.0.3",
45
+ "pytest-cov>=7.1.0",
46
+ "ruff>=0.15.17",
47
+ "ty>=0.0.49",
48
+ ]
49
+
50
+ [tool.ruff.lint]
51
+ extend-select = ["I", "UP", "B", "SIM"]
52
+
53
+ [tool.pytest.ini_options]
54
+ testpaths = ["tests"]
55
+ pythonpath = ["tests"]
@@ -0,0 +1 @@
1
+ """BYOR: custom ast-grep diagnostics, easy to set up, share, and expose to AI agents."""
File without changes