agent-code-guard 0.1.0__py3-none-any.whl

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. agent_code_guard/__init__.py +1 -0
  2. agent_code_guard/analysis/__init__.py +13 -0
  3. agent_code_guard/analysis/adapters.py +608 -0
  4. agent_code_guard/analysis/errors.py +13 -0
  5. agent_code_guard/analysis/facts.py +101 -0
  6. agent_code_guard/analysis/language_specs.py +82 -0
  7. agent_code_guard/analysis/pipeline.py +37 -0
  8. agent_code_guard/analysis/provider.py +45 -0
  9. agent_code_guard/analysis/regions.py +108 -0
  10. agent_code_guard/code_guard.py +236 -0
  11. agent_code_guard/config_validation.py +90 -0
  12. agent_code_guard/file_selection.py +228 -0
  13. agent_code_guard/guards/__init__.py +1 -0
  14. agent_code_guard/guards/callable_size.py +79 -0
  15. agent_code_guard/guards/complexity.py +94 -0
  16. agent_code_guard/guards/loc.py +235 -0
  17. agent_code_guard/guards/markdown_document_size.py +66 -0
  18. agent_code_guard/guards/markdown_section_size.py +66 -0
  19. agent_code_guard/guards/nesting.py +109 -0
  20. agent_code_guard/markdown/__init__.py +6 -0
  21. agent_code_guard/markdown/facts.py +27 -0
  22. agent_code_guard/markdown/scanner.py +109 -0
  23. agent_code_guard/path_matching.py +25 -0
  24. agent_code_guard/reporting.py +11 -0
  25. agent_code_guard/result_model.py +128 -0
  26. agent_code_guard/skill_distribution.py +96 -0
  27. agent_code_guard-0.1.0.data/data/share/agent-code-guard/skill/LICENSE.txt +21 -0
  28. agent_code_guard-0.1.0.data/data/share/agent-code-guard/skill/SKILL.md +138 -0
  29. agent_code_guard-0.1.0.data/data/share/agent-code-guard/skill/agents/openai.yaml +8 -0
  30. agent_code_guard-0.1.0.data/data/share/agent-code-guard/skill/references/callable-size-policy.md +39 -0
  31. agent_code_guard-0.1.0.data/data/share/agent-code-guard/skill/references/complexity-policy.md +39 -0
  32. agent_code_guard-0.1.0.data/data/share/agent-code-guard/skill/references/loc-policy.md +40 -0
  33. agent_code_guard-0.1.0.data/data/share/agent-code-guard/skill/references/markdown-size-policy.md +16 -0
  34. agent_code_guard-0.1.0.data/data/share/agent-code-guard/skill/references/nesting-policy.md +37 -0
  35. agent_code_guard-0.1.0.dist-info/METADATA +206 -0
  36. agent_code_guard-0.1.0.dist-info/RECORD +40 -0
  37. agent_code_guard-0.1.0.dist-info/WHEEL +5 -0
  38. agent_code_guard-0.1.0.dist-info/entry_points.txt +2 -0
  39. agent_code_guard-0.1.0.dist-info/licenses/LICENSE +21 -0
  40. agent_code_guard-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,206 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-code-guard
3
+ Version: 0.1.0
4
+ Summary: Deterministic cross-language guardrails for agent-assisted development
5
+ License-Expression: MIT
6
+ Project-URL: Source, https://github.com/stef-k/agent-code-guard
7
+ Project-URL: Issues, https://github.com/stef-k/agent-code-guard/issues
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: tree-sitter==0.26.0
12
+ Requires-Dist: tree-sitter-language-pack==1.14.3
13
+ Dynamic: license-file
14
+
15
+ # Agent Code Guard
16
+
17
+ <p align="center">
18
+ <img src="https://raw.githubusercontent.com/stef-k/agent-code-guard/main/assets/agent-code-guard-mark.svg" width="180" alt="Agent Code Guard project mark">
19
+ </p>
20
+
21
+ Deterministic guardrails for agent-assisted software development.
22
+
23
+ [![Production Analysis](https://github.com/stef-k/agent-code-guard/actions/workflows/analysis.yml/badge.svg)](https://github.com/stef-k/agent-code-guard/actions/workflows/analysis.yml)
24
+ [![Python 3.10–3.14](https://img.shields.io/badge/Python-3.10%E2%80%933.14-3776AB?logo=python&logoColor=white)](https://github.com/stef-k/agent-code-guard/blob/main/docs/platform-support.md)
25
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/stef-k/agent-code-guard/blob/main/LICENSE)
26
+
27
+ Code Guard gives coding agents objective measurements and **PASS / REVIEW /
28
+ FAIL** signals while leaving design decisions to agent and user judgment.
29
+
30
+ ```text
31
+ deterministic measurement
32
+
33
+ PASS / REVIEW / FAIL
34
+
35
+ agent judgment
36
+ ```
37
+
38
+ ## Installation
39
+
40
+ [pipx](https://pipx.pypa.io/) keeps the command isolated from project
41
+ environments:
42
+
43
+ ```bash
44
+ pipx install agent-code-guard
45
+ ```
46
+
47
+ See the [usage guide](https://github.com/stef-k/agent-code-guard/blob/main/docs/usage.md)
48
+ for a virtual-environment alternative and developer installation.
49
+
50
+ ## Quick start
51
+
52
+ Run all enabled, applicable guards over your current Git work:
53
+
54
+ ```bash
55
+ code-guard . --changed-only
56
+ ```
57
+
58
+ Git determines the edited-file candidates, Code Guard applies every enabled
59
+ and applicable guard, and project or user exclusions remain authoritative. No
60
+ configuration file is required.
61
+
62
+ ## Result model
63
+
64
+ - **PASS** — no special action.
65
+ - **REVIEW** — inspect the finding and decide whether meaningful improvement is
66
+ warranted. REVIEW is not automatic refactoring.
67
+ - **FAIL** — blocks normal completion until fixed or an explicitly authorized
68
+ exception applies.
69
+
70
+ **Never game the metric.** Preserve clarity and useful structure; do not create
71
+ artificial helpers, files, abstractions, formatting, or exclusions merely to
72
+ lower a measurement.
73
+
74
+ ## Default guards
75
+
76
+ | Guard | Default |
77
+ | --- | --- |
78
+ | File LOC | REVIEW >400, FAIL >600 |
79
+ | Callable size | REVIEW >80 physical LOC |
80
+ | Structural nesting | REVIEW >4 |
81
+ | Cyclomatic complexity | REVIEW >15 |
82
+ | Markdown document size | REVIEW >800 physical lines |
83
+ | Markdown direct-section size | REVIEW >200 physical lines |
84
+
85
+ Comparisons are strictly greater-than, so equality passes. All guards except
86
+ file LOC are REVIEW-only; only file LOC can FAIL.
87
+
88
+ Agent Code Guard intentionally remains small. A new guard must provide distinct,
89
+ deterministic agent-guardrail value rather than merely duplicate mature
90
+ conventional tooling. See [Guard admission](https://github.com/stef-k/agent-code-guard/blob/main/docs/guard-admission.md).
91
+
92
+ ## Common workflows
93
+
94
+ Normal Git work:
95
+
96
+ ```bash
97
+ code-guard . --changed-only
98
+ ```
99
+
100
+ Explicit agent-owned scope without Git:
101
+
102
+ ```bash
103
+ code-guard src/Foo.py src/Bar.ts docs/guide.md
104
+ ```
105
+
106
+ Pull request or branch comparison:
107
+
108
+ ```bash
109
+ code-guard . --base-ref origin/main --ci
110
+ ```
111
+
112
+ The actual base ref must exist or be fetched correctly in the chosen CI
113
+ environment.
114
+
115
+ Deliberate full audit:
116
+
117
+ ```bash
118
+ code-guard .
119
+ ```
120
+
121
+ Changed work is not a full audit. Use Git selection during normal development;
122
+ do not repeatedly scan unrelated repository history after every edit.
123
+
124
+ ## Supported languages and formats
125
+
126
+ Syntax guards support Python, Go, Kotlin, C#, Java, JavaScript, TypeScript, JSX,
127
+ TSX, Vue JavaScript/TypeScript script regions, C++, Rust, PHP, Swift, and Dart.
128
+ Markdown guards apply to `.md` files.
129
+
130
+ Important boundaries:
131
+
132
+ - Generic `.h` files are not syntax-dispatched because their language context
133
+ is ambiguous.
134
+ - `.markdown` is not currently enabled for Markdown guards.
135
+ - Vue template and style regions are not executable syntax input.
136
+ - Unsupported artifacts are simply inapplicable.
137
+ - Malformed applicable syntax or a required provider failure is a fail-closed
138
+ tool error, never heuristic partial analysis.
139
+
140
+ See [Language support](https://github.com/stef-k/agent-code-guard/blob/main/docs/language-support.md)
141
+ for extension and mixed-content details.
142
+
143
+ ## Agent integration
144
+
145
+ CLI-only use requires no skill export. Each installed distribution also carries
146
+ a version-matched Code Guard skill payload for agent workflows:
147
+
148
+ ```bash
149
+ code-guard --skill-path
150
+ code-guard --export-skill <target-directory>
151
+ ```
152
+
153
+ See [Skill distribution](https://github.com/stef-k/agent-code-guard/blob/main/docs/skill-distribution.md)
154
+ for discovery, export, and integration guarantees. The checkout compatibility
155
+ runner is for repository and skill compatibility, not primary end-user
156
+ installation.
157
+
158
+ ## Configuration
159
+
160
+ Built-in defaults require no config. A minimal project configuration is:
161
+
162
+ ```json
163
+ {
164
+ "version": 1
165
+ }
166
+ ```
167
+
168
+ Use configuration only when a project has a concrete policy reason to change a
169
+ guard or scope. See the [Configuration guide](https://github.com/stef-k/agent-code-guard/blob/main/docs/configuration.md).
170
+
171
+ ## Documentation
172
+
173
+ - [Documentation index](https://github.com/stef-k/agent-code-guard/blob/main/docs/README.md)
174
+ - [Usage](https://github.com/stef-k/agent-code-guard/blob/main/docs/usage.md)
175
+ - [Configuration](https://github.com/stef-k/agent-code-guard/blob/main/docs/configuration.md)
176
+ - [Language support](https://github.com/stef-k/agent-code-guard/blob/main/docs/language-support.md)
177
+ - [Platform support](https://github.com/stef-k/agent-code-guard/blob/main/docs/platform-support.md)
178
+ - [Skill distribution](https://github.com/stef-k/agent-code-guard/blob/main/docs/skill-distribution.md)
179
+
180
+ ## Platform support
181
+
182
+ The maintained interpreter range is **CPython 3.10–3.14**. The normal binary
183
+ installation envelope is:
184
+
185
+ - Windows x86-64 and ARM64;
186
+ - macOS x86-64 and ARM64;
187
+ - Linux glibc 2.34 or newer on x86-64 and ARM64.
188
+
189
+ Source builds outside that binary envelope are best effort and are not
190
+ release-supported. See [Platform support](https://github.com/stef-k/agent-code-guard/blob/main/docs/platform-support.md)
191
+ for exact wheel and deployment boundaries.
192
+
193
+ ## Feedback and security
194
+
195
+ Report normal defects through the [bug report form](https://github.com/stef-k/agent-code-guard/issues/new?template=bug-report.md)
196
+ and propose new measurements through the [Candidate guard form](https://github.com/stef-k/agent-code-guard/issues/new?template=candidate-guard.md).
197
+ For vulnerability reporting, follow the repository [Security policy](https://github.com/stef-k/agent-code-guard/blob/main/SECURITY.md).
198
+
199
+ ## Background and license
200
+
201
+ Agent Code Guard grew from the Agent LOC Guard prototype and is now the
202
+ canonical implementation. It remains focused on deterministic measurements
203
+ that complement—not replace—tests, compilers, formatters, linters, security
204
+ tools, or design judgment.
205
+
206
+ Licensed under the [MIT License](https://github.com/stef-k/agent-code-guard/blob/main/LICENSE).
@@ -0,0 +1,40 @@
1
+ agent_code_guard/__init__.py,sha256=9l0D2gP5QVcrPSEifzWEOhCTMvrT9SDYkHWr9Y9F4kk,43
2
+ agent_code_guard/code_guard.py,sha256=KL7942CHWta2nwUQVq04uuu-tuYNv_D43dmEmFfenqs,10664
3
+ agent_code_guard/config_validation.py,sha256=_NOc147aZfoXjP7qPP-jqjxaXPz_4Vh6n4KTFnp6y_E,2891
4
+ agent_code_guard/file_selection.py,sha256=oZ0Umn3LGQ5zpO46qeS-XW26qi_XRIA4OXVHh8ZKWOc,9283
5
+ agent_code_guard/path_matching.py,sha256=xqX_JsWH-7N5k5_df3OHm9OOY7sxaVVtlzjFSVY7yBs,890
6
+ agent_code_guard/reporting.py,sha256=SpYBXS9QlCuPO4f3dsnc-0dcOh0lq--1Af0YQDWa96g,295
7
+ agent_code_guard/result_model.py,sha256=jYnp9XkBGuSmWmbAqlXgmtl-3ZsiHrbB0lU-DGHOvV8,3486
8
+ agent_code_guard/skill_distribution.py,sha256=WKACCBrm4SW3ygy8JF8W4cDYyCiK6pdVuD7qIbClmnk,3417
9
+ agent_code_guard/analysis/__init__.py,sha256=kd47xQlTvcPM0V896tGn9QBQhb0IYi0wPzItV4jWfng,697
10
+ agent_code_guard/analysis/adapters.py,sha256=ADGO6K8IJu87aY-dOzD6plGhqkKR9xMyI8AOY9mDPvQ,29271
11
+ agent_code_guard/analysis/errors.py,sha256=V6whxtgYL9j3oEmxZsI-mo6ePwopfwB-J_gcchy93AM,428
12
+ agent_code_guard/analysis/facts.py,sha256=Hl2NWsqc8RgSQdWGvDMOsW6Rncu7Y7sh8glM4o88n2Q,2413
13
+ agent_code_guard/analysis/language_specs.py,sha256=mJRY5S-OjiR1UdbuJqPzgUKzpAYlDM6ZU2Sv4kEoBxA,7402
14
+ agent_code_guard/analysis/pipeline.py,sha256=_is6JXzqq1174jTVKAPiMjs42h_m2GhWnDZjReybJZo,1595
15
+ agent_code_guard/analysis/provider.py,sha256=Oc704YdOgu1nHkOwSB9OuYn6S6Y0ImLA-keAJ2r1gM0,1632
16
+ agent_code_guard/analysis/regions.py,sha256=PveqPCWZ1WBnWNgUcGEaSkDbC4YzHljeei5xRUlH6io,4421
17
+ agent_code_guard/guards/__init__.py,sha256=_hECdxBB2F-FcoQtxz_18zWcJ_Ws8u2yEFvZdLEhbl8,59
18
+ agent_code_guard/guards/callable_size.py,sha256=yGj7iQrbkD3rJLyD9aTXiOMeH1yB0Phejx7HKAqdPUY,2985
19
+ agent_code_guard/guards/complexity.py,sha256=VKZu4XN2WHnOgKaYCo6bFhqJRe2Go44H1hYcASrxoqI,3707
20
+ agent_code_guard/guards/loc.py,sha256=KNONau4usW5gG66drogLg_-5JYfLm94SKpnWak3lfVQ,10316
21
+ agent_code_guard/guards/markdown_document_size.py,sha256=NcHzIxKoBZm-Nhc2X7ci87_a3KADzlCHU7HIu4XETiQ,2457
22
+ agent_code_guard/guards/markdown_section_size.py,sha256=95oiJF21JzHPHS8S5D8Gd3lZGYudgnM2pQjH297GQF0,2648
23
+ agent_code_guard/guards/nesting.py,sha256=98rJ25Rv7f4Z1GNekbs2iPs6MUMEyzy9-flG7WpdJaI,4194
24
+ agent_code_guard/markdown/__init__.py,sha256=-xqZCo2iS8OHStkug_l_BqgxQX1rJC7iJbgszjQA0ps,308
25
+ agent_code_guard/markdown/facts.py,sha256=INv_4JnYSraILdoP89PrbuuYqvnIb8XV3bev-y979PU,534
26
+ agent_code_guard/markdown/scanner.py,sha256=XgP1hVEGCNPSlbzVfyE3p4sEjmbUxqrn9hd557LySrM,3514
27
+ agent_code_guard-0.1.0.data/data/share/agent-code-guard/skill/LICENSE.txt,sha256=qfi3ybIq-hBcRO1D2PjtcvI1AJNhUxtKYxqPhmECJ5A,1072
28
+ agent_code_guard-0.1.0.data/data/share/agent-code-guard/skill/SKILL.md,sha256=rb-1sxzAEgPqUvrP5vF35SI1n1iTQDMegNfkxeaqcPQ,7778
29
+ agent_code_guard-0.1.0.data/data/share/agent-code-guard/skill/agents/openai.yaml,sha256=YDfA-KXAIO6uAPt_DALnq6WPN08u0zsFGJQ_QXr_Z74,328
30
+ agent_code_guard-0.1.0.data/data/share/agent-code-guard/skill/references/callable-size-policy.md,sha256=mBvUFpEIS6dvLBmCDtpPEJizarh_NasbYCAb9pAqBdw,1953
31
+ agent_code_guard-0.1.0.data/data/share/agent-code-guard/skill/references/complexity-policy.md,sha256=ogGo3FCBcHM5rizPs1ISNoJg9_vO4OvOSjV-am4J1V0,1876
32
+ agent_code_guard-0.1.0.data/data/share/agent-code-guard/skill/references/loc-policy.md,sha256=czcK7IOPdJzPcFEZMhQ22GEjcXdDNoYHbp3rJIHlxqc,2918
33
+ agent_code_guard-0.1.0.data/data/share/agent-code-guard/skill/references/markdown-size-policy.md,sha256=Q_5DDUm8QgI_xS7aZxZwRszvSVMgvYop0TIq14aU8L8,836
34
+ agent_code_guard-0.1.0.data/data/share/agent-code-guard/skill/references/nesting-policy.md,sha256=gxoQy5wUjH44to0R9Q5Ur0O2x0go0Lajc9yZTedwNkw,1729
35
+ agent_code_guard-0.1.0.dist-info/licenses/LICENSE,sha256=qfi3ybIq-hBcRO1D2PjtcvI1AJNhUxtKYxqPhmECJ5A,1072
36
+ agent_code_guard-0.1.0.dist-info/METADATA,sha256=qTUl8EoER2BiMlUIFdREAuiDndOVL-TlqPvSSqUfFJc,7407
37
+ agent_code_guard-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
38
+ agent_code_guard-0.1.0.dist-info/entry_points.txt,sha256=AlQT1EJar6o7zmVRCQ4h4vT9HEawcosfUp2aWdg7IuE,64
39
+ agent_code_guard-0.1.0.dist-info/top_level.txt,sha256=VAvxYk-u5udTTDswvepW4c6M-wdH4nsOmUZVCOaAcdw,17
40
+ agent_code_guard-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ code-guard = agent_code_guard.code_guard:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Stef Karyotidis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ agent_code_guard