agent-code-guard 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 (46) hide show
  1. agent_code_guard-0.1.0/LICENSE +21 -0
  2. agent_code_guard-0.1.0/MANIFEST.in +13 -0
  3. agent_code_guard-0.1.0/PKG-INFO +206 -0
  4. agent_code_guard-0.1.0/README.md +192 -0
  5. agent_code_guard-0.1.0/pyproject.toml +33 -0
  6. agent_code_guard-0.1.0/setup.cfg +4 -0
  7. agent_code_guard-0.1.0/skills/code-guard/LICENSE.txt +21 -0
  8. agent_code_guard-0.1.0/skills/code-guard/SKILL.md +138 -0
  9. agent_code_guard-0.1.0/skills/code-guard/agents/openai.yaml +8 -0
  10. agent_code_guard-0.1.0/skills/code-guard/references/callable-size-policy.md +39 -0
  11. agent_code_guard-0.1.0/skills/code-guard/references/complexity-policy.md +39 -0
  12. agent_code_guard-0.1.0/skills/code-guard/references/loc-policy.md +40 -0
  13. agent_code_guard-0.1.0/skills/code-guard/references/markdown-size-policy.md +16 -0
  14. agent_code_guard-0.1.0/skills/code-guard/references/nesting-policy.md +37 -0
  15. agent_code_guard-0.1.0/src/agent_code_guard/__init__.py +1 -0
  16. agent_code_guard-0.1.0/src/agent_code_guard/analysis/__init__.py +13 -0
  17. agent_code_guard-0.1.0/src/agent_code_guard/analysis/adapters.py +608 -0
  18. agent_code_guard-0.1.0/src/agent_code_guard/analysis/errors.py +13 -0
  19. agent_code_guard-0.1.0/src/agent_code_guard/analysis/facts.py +101 -0
  20. agent_code_guard-0.1.0/src/agent_code_guard/analysis/language_specs.py +82 -0
  21. agent_code_guard-0.1.0/src/agent_code_guard/analysis/pipeline.py +37 -0
  22. agent_code_guard-0.1.0/src/agent_code_guard/analysis/provider.py +45 -0
  23. agent_code_guard-0.1.0/src/agent_code_guard/analysis/regions.py +108 -0
  24. agent_code_guard-0.1.0/src/agent_code_guard/code_guard.py +236 -0
  25. agent_code_guard-0.1.0/src/agent_code_guard/config_validation.py +90 -0
  26. agent_code_guard-0.1.0/src/agent_code_guard/file_selection.py +228 -0
  27. agent_code_guard-0.1.0/src/agent_code_guard/guards/__init__.py +1 -0
  28. agent_code_guard-0.1.0/src/agent_code_guard/guards/callable_size.py +79 -0
  29. agent_code_guard-0.1.0/src/agent_code_guard/guards/complexity.py +94 -0
  30. agent_code_guard-0.1.0/src/agent_code_guard/guards/loc.py +235 -0
  31. agent_code_guard-0.1.0/src/agent_code_guard/guards/markdown_document_size.py +66 -0
  32. agent_code_guard-0.1.0/src/agent_code_guard/guards/markdown_section_size.py +66 -0
  33. agent_code_guard-0.1.0/src/agent_code_guard/guards/nesting.py +109 -0
  34. agent_code_guard-0.1.0/src/agent_code_guard/markdown/__init__.py +6 -0
  35. agent_code_guard-0.1.0/src/agent_code_guard/markdown/facts.py +27 -0
  36. agent_code_guard-0.1.0/src/agent_code_guard/markdown/scanner.py +109 -0
  37. agent_code_guard-0.1.0/src/agent_code_guard/path_matching.py +25 -0
  38. agent_code_guard-0.1.0/src/agent_code_guard/reporting.py +11 -0
  39. agent_code_guard-0.1.0/src/agent_code_guard/result_model.py +128 -0
  40. agent_code_guard-0.1.0/src/agent_code_guard/skill_distribution.py +96 -0
  41. agent_code_guard-0.1.0/src/agent_code_guard.egg-info/PKG-INFO +206 -0
  42. agent_code_guard-0.1.0/src/agent_code_guard.egg-info/SOURCES.txt +44 -0
  43. agent_code_guard-0.1.0/src/agent_code_guard.egg-info/dependency_links.txt +1 -0
  44. agent_code_guard-0.1.0/src/agent_code_guard.egg-info/entry_points.txt +2 -0
  45. agent_code_guard-0.1.0/src/agent_code_guard.egg-info/requires.txt +2 -0
  46. agent_code_guard-0.1.0/src/agent_code_guard.egg-info/top_level.txt +1 -0
@@ -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,13 @@
1
+ include LICENSE
2
+ include README.md
3
+ include pyproject.toml
4
+ graft src
5
+
6
+ prune .github
7
+ prune docs
8
+ prune examples
9
+ prune research
10
+ graft skills/code-guard
11
+ prune skills/code-guard/scripts
12
+ prune tests
13
+ global-exclude *.py[cod]
@@ -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,192 @@
1
+ # Agent Code Guard
2
+
3
+ <p align="center">
4
+ <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">
5
+ </p>
6
+
7
+ Deterministic guardrails for agent-assisted software development.
8
+
9
+ [![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)
10
+ [![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)
11
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/stef-k/agent-code-guard/blob/main/LICENSE)
12
+
13
+ Code Guard gives coding agents objective measurements and **PASS / REVIEW /
14
+ FAIL** signals while leaving design decisions to agent and user judgment.
15
+
16
+ ```text
17
+ deterministic measurement
18
+
19
+ PASS / REVIEW / FAIL
20
+
21
+ agent judgment
22
+ ```
23
+
24
+ ## Installation
25
+
26
+ [pipx](https://pipx.pypa.io/) keeps the command isolated from project
27
+ environments:
28
+
29
+ ```bash
30
+ pipx install agent-code-guard
31
+ ```
32
+
33
+ See the [usage guide](https://github.com/stef-k/agent-code-guard/blob/main/docs/usage.md)
34
+ for a virtual-environment alternative and developer installation.
35
+
36
+ ## Quick start
37
+
38
+ Run all enabled, applicable guards over your current Git work:
39
+
40
+ ```bash
41
+ code-guard . --changed-only
42
+ ```
43
+
44
+ Git determines the edited-file candidates, Code Guard applies every enabled
45
+ and applicable guard, and project or user exclusions remain authoritative. No
46
+ configuration file is required.
47
+
48
+ ## Result model
49
+
50
+ - **PASS** — no special action.
51
+ - **REVIEW** — inspect the finding and decide whether meaningful improvement is
52
+ warranted. REVIEW is not automatic refactoring.
53
+ - **FAIL** — blocks normal completion until fixed or an explicitly authorized
54
+ exception applies.
55
+
56
+ **Never game the metric.** Preserve clarity and useful structure; do not create
57
+ artificial helpers, files, abstractions, formatting, or exclusions merely to
58
+ lower a measurement.
59
+
60
+ ## Default guards
61
+
62
+ | Guard | Default |
63
+ | --- | --- |
64
+ | File LOC | REVIEW >400, FAIL >600 |
65
+ | Callable size | REVIEW >80 physical LOC |
66
+ | Structural nesting | REVIEW >4 |
67
+ | Cyclomatic complexity | REVIEW >15 |
68
+ | Markdown document size | REVIEW >800 physical lines |
69
+ | Markdown direct-section size | REVIEW >200 physical lines |
70
+
71
+ Comparisons are strictly greater-than, so equality passes. All guards except
72
+ file LOC are REVIEW-only; only file LOC can FAIL.
73
+
74
+ Agent Code Guard intentionally remains small. A new guard must provide distinct,
75
+ deterministic agent-guardrail value rather than merely duplicate mature
76
+ conventional tooling. See [Guard admission](https://github.com/stef-k/agent-code-guard/blob/main/docs/guard-admission.md).
77
+
78
+ ## Common workflows
79
+
80
+ Normal Git work:
81
+
82
+ ```bash
83
+ code-guard . --changed-only
84
+ ```
85
+
86
+ Explicit agent-owned scope without Git:
87
+
88
+ ```bash
89
+ code-guard src/Foo.py src/Bar.ts docs/guide.md
90
+ ```
91
+
92
+ Pull request or branch comparison:
93
+
94
+ ```bash
95
+ code-guard . --base-ref origin/main --ci
96
+ ```
97
+
98
+ The actual base ref must exist or be fetched correctly in the chosen CI
99
+ environment.
100
+
101
+ Deliberate full audit:
102
+
103
+ ```bash
104
+ code-guard .
105
+ ```
106
+
107
+ Changed work is not a full audit. Use Git selection during normal development;
108
+ do not repeatedly scan unrelated repository history after every edit.
109
+
110
+ ## Supported languages and formats
111
+
112
+ Syntax guards support Python, Go, Kotlin, C#, Java, JavaScript, TypeScript, JSX,
113
+ TSX, Vue JavaScript/TypeScript script regions, C++, Rust, PHP, Swift, and Dart.
114
+ Markdown guards apply to `.md` files.
115
+
116
+ Important boundaries:
117
+
118
+ - Generic `.h` files are not syntax-dispatched because their language context
119
+ is ambiguous.
120
+ - `.markdown` is not currently enabled for Markdown guards.
121
+ - Vue template and style regions are not executable syntax input.
122
+ - Unsupported artifacts are simply inapplicable.
123
+ - Malformed applicable syntax or a required provider failure is a fail-closed
124
+ tool error, never heuristic partial analysis.
125
+
126
+ See [Language support](https://github.com/stef-k/agent-code-guard/blob/main/docs/language-support.md)
127
+ for extension and mixed-content details.
128
+
129
+ ## Agent integration
130
+
131
+ CLI-only use requires no skill export. Each installed distribution also carries
132
+ a version-matched Code Guard skill payload for agent workflows:
133
+
134
+ ```bash
135
+ code-guard --skill-path
136
+ code-guard --export-skill <target-directory>
137
+ ```
138
+
139
+ See [Skill distribution](https://github.com/stef-k/agent-code-guard/blob/main/docs/skill-distribution.md)
140
+ for discovery, export, and integration guarantees. The checkout compatibility
141
+ runner is for repository and skill compatibility, not primary end-user
142
+ installation.
143
+
144
+ ## Configuration
145
+
146
+ Built-in defaults require no config. A minimal project configuration is:
147
+
148
+ ```json
149
+ {
150
+ "version": 1
151
+ }
152
+ ```
153
+
154
+ Use configuration only when a project has a concrete policy reason to change a
155
+ guard or scope. See the [Configuration guide](https://github.com/stef-k/agent-code-guard/blob/main/docs/configuration.md).
156
+
157
+ ## Documentation
158
+
159
+ - [Documentation index](https://github.com/stef-k/agent-code-guard/blob/main/docs/README.md)
160
+ - [Usage](https://github.com/stef-k/agent-code-guard/blob/main/docs/usage.md)
161
+ - [Configuration](https://github.com/stef-k/agent-code-guard/blob/main/docs/configuration.md)
162
+ - [Language support](https://github.com/stef-k/agent-code-guard/blob/main/docs/language-support.md)
163
+ - [Platform support](https://github.com/stef-k/agent-code-guard/blob/main/docs/platform-support.md)
164
+ - [Skill distribution](https://github.com/stef-k/agent-code-guard/blob/main/docs/skill-distribution.md)
165
+
166
+ ## Platform support
167
+
168
+ The maintained interpreter range is **CPython 3.10–3.14**. The normal binary
169
+ installation envelope is:
170
+
171
+ - Windows x86-64 and ARM64;
172
+ - macOS x86-64 and ARM64;
173
+ - Linux glibc 2.34 or newer on x86-64 and ARM64.
174
+
175
+ Source builds outside that binary envelope are best effort and are not
176
+ release-supported. See [Platform support](https://github.com/stef-k/agent-code-guard/blob/main/docs/platform-support.md)
177
+ for exact wheel and deployment boundaries.
178
+
179
+ ## Feedback and security
180
+
181
+ Report normal defects through the [bug report form](https://github.com/stef-k/agent-code-guard/issues/new?template=bug-report.md)
182
+ and propose new measurements through the [Candidate guard form](https://github.com/stef-k/agent-code-guard/issues/new?template=candidate-guard.md).
183
+ For vulnerability reporting, follow the repository [Security policy](https://github.com/stef-k/agent-code-guard/blob/main/SECURITY.md).
184
+
185
+ ## Background and license
186
+
187
+ Agent Code Guard grew from the Agent LOC Guard prototype and is now the
188
+ canonical implementation. It remains focused on deterministic measurements
189
+ that complement—not replace—tests, compilers, formatters, linters, security
190
+ tools, or design judgment.
191
+
192
+ Licensed under the [MIT License](https://github.com/stef-k/agent-code-guard/blob/main/LICENSE).
@@ -0,0 +1,33 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "agent-code-guard"
7
+ version = "0.1.0"
8
+ description = "Deterministic cross-language guardrails for agent-assisted development"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ dependencies = [
13
+ "tree-sitter==0.26.0",
14
+ "tree-sitter-language-pack==1.14.3",
15
+ ]
16
+
17
+ [project.urls]
18
+ Source = "https://github.com/stef-k/agent-code-guard"
19
+ Issues = "https://github.com/stef-k/agent-code-guard/issues"
20
+
21
+ [project.scripts]
22
+ code-guard = "agent_code_guard.code_guard:main"
23
+
24
+ [tool.setuptools.packages.find]
25
+ where = ["src"]
26
+
27
+ [tool.setuptools.data-files]
28
+ "share/agent-code-guard/skill" = [
29
+ "skills/code-guard/SKILL.md",
30
+ "skills/code-guard/LICENSE.txt",
31
+ ]
32
+ "share/agent-code-guard/skill/agents" = ["skills/code-guard/agents/openai.yaml"]
33
+ "share/agent-code-guard/skill/references" = ["skills/code-guard/references/*.md"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -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,138 @@
1
+ ---
2
+ name: code-guard
3
+ description: Use when creating, editing, reviewing, or refactoring supported code or Markdown documentation to run deterministic guardrails and load only the policy guidance required by triggered findings.
4
+ license: Complete terms in LICENSE.txt
5
+ ---
6
+
7
+ # Code Guard
8
+
9
+ Use this skill whenever supported code or Markdown documentation artifacts are created, edited, reviewed, or refactored.
10
+
11
+ Code Guard provides deterministic measurements that act as anchors for agent judgment. The measurement is objective; the response to a `REVIEW` finding still requires design judgment.
12
+
13
+ ## Result states
14
+
15
+ - `PASS` — no special action is required.
16
+ - `REVIEW` — inspect the finding and either accept it with a meaningful justification or improve the code when doing so improves real clarity, cohesion, or boundaries.
17
+ - `FAIL` — do not declare normal completion until the condition is fixed or an explicitly permitted/user-approved exception applies.
18
+
19
+ ## Universal rules
20
+
21
+ 1. Never game a metric.
22
+ 2. Preserve readability and the repository's normal formatting/style conventions.
23
+ 3. Do not compress independent statements, remove useful structure/comments, obscure control flow, or minify handwritten source to lower a measurement.
24
+ 4. Do not create meaningless helpers, artificial files, unnecessary abstractions, or indirection mainly to reduce a metric.
25
+ 5. `REVIEW` is not an automatic refactor instruction.
26
+ 6. Refactor only when the change improves the code rather than merely improving the score.
27
+ 7. Do not create, broaden, or alter policy exceptions/configuration solely to make Code Guard pass without explicit user approval.
28
+ 8. Do not expand the current task to unrelated pre-existing debt. Normal development checks changed/current-work files; full-repository audit is separate.
29
+
30
+ ## Workflow
31
+
32
+ With Git, run the installed Code Guard command after supported code or Markdown documentation edits:
33
+
34
+ ```bash
35
+ code-guard . --changed-only
36
+ ```
37
+
38
+ An installed Agent Code Guard distribution provides both the command and this
39
+ version-matched skill payload. The skill's normal execution route is always the
40
+ installed `code-guard` command.
41
+
42
+ For repository development only, the compatibility runner remains available
43
+ directly from a checkout. It is not part of the externally installed skill
44
+ payload or the normal end-user execution route:
45
+
46
+ ```bash
47
+ python3 skills/code-guard/scripts/code_guard.py . --changed-only
48
+ ```
49
+
50
+ `pyproject.toml` canonically owns the production pins. Tree-sitter remains
51
+ dormant during LOC-only execution; failure to load a required provider or
52
+ grammar is a deterministic tool error during normal zero-config syntax analysis.
53
+ Disabling every syntax guard preserves the lazy no-Tree-sitter path. A strictly
54
+ LOC-only result also requires both Markdown guards to be explicitly disabled.
55
+
56
+ Without Git or another VCS that can provide changed scope, pass exactly the files you created or modified. You are responsible for supplying the complete edited-file set:
57
+
58
+ ```bash
59
+ code-guard src/Foo.py src/Bar.ts docs/guide.md
60
+ ```
61
+
62
+ Do not create a manifest or temporary scope file. Specific positional files mean “inspect these artifacts.” A directory or `.` means a deliberate recursive audit when no Git selector is used. Positional files/directories bound the candidates selected by `--changed-only`, `--staged`, or `--base-ref`; Git selection fails outside a Git repository and never falls back to an audit.
63
+
64
+ Recursive directory discovery does not follow symlinks. An explicitly supplied
65
+ file symlink is treated as caller intent; an explicit directory symlink is
66
+ rejected rather than recursively traversed.
67
+
68
+ Prefer normal zero-config scope and respect project `scope.exclude`; do not
69
+ remove or alter exclusions merely to silence findings. Repeated
70
+ `--scope-exclude` is caller-supplied all-guard scope policy and composes with
71
+ project exclusions. LOC `--exclude` remains LOC-specific. Explicit files may
72
+ intentionally inspect Git-ignored or built-in-pruned artifacts, unless Code
73
+ Guard `scope.exclude` or `--scope-exclude` removes them.
74
+
75
+ When all guards return `PASS`, no detailed policy file needs to be loaded.
76
+
77
+ When a guard returns `REVIEW` or `FAIL`, read only the policy file named by that finding. The runner returns required policy identifiers/files in both human-readable and JSON output.
78
+
79
+ Policy references:
80
+
81
+ - file LOC: `references/loc-policy.md`
82
+ - callable size: `references/callable-size-policy.md`
83
+ - nesting depth: `references/nesting-policy.md`
84
+ - cyclomatic complexity: `references/complexity-policy.md`
85
+ - Markdown document/section size: `references/markdown-size-policy.md`
86
+
87
+ Do not load unrelated guard policies merely because they exist.
88
+
89
+ ## Scope
90
+
91
+ Code Guard is intentionally limited to deterministic concerns that are broadly applicable across conventional programming languages.
92
+
93
+ Guards:
94
+
95
+ - file LOC (implemented and enabled by default);
96
+ - source/container and syntax facts (production infrastructure, not a guard);
97
+ - callable LOC (implemented and enabled by default; REVIEW greater than 80);
98
+ - structural nesting (implemented and enabled by default; REVIEW greater than 4);
99
+ - cyclomatic complexity (implemented and enabled by default; REVIEW greater than 15).
100
+ - Markdown document physical size (implemented for `.md` and enabled by default; REVIEW greater than 800);
101
+ - Markdown direct-section physical size (implemented for `.md` and enabled by default; REVIEW greater than 200).
102
+
103
+ Callable LOC needs no invented configuration to activate it. Omission or
104
+ `enabled: true` uses 80; an authorized positive-integer `reviewAt` overrides it,
105
+ and `enabled: false` disables it. Exactly the effective threshold passes;
106
+ larger callables review and never fail. Load
107
+ `references/callable-size-policy.md` only when `callableSize` appears in
108
+ `requiredPolicies`.
109
+
110
+ Structural nesting is executable control-flow depth, not visual, markup, brace,
111
+ or indentation depth. Omission or `enabled: true` uses 4; an authorized
112
+ positive-integer `reviewAt` overrides it, and `enabled: false` disables it.
113
+ Exactly the effective depth passes; greater depth reviews and never fails. Load `references/nesting-policy.md` only when `nesting`
114
+ appears in `requiredPolicies`.
115
+
116
+ Cyclomatic complexity is baseline 1 plus normalized decisions owned by the
117
+ callable. Omission or `enabled: true` uses 15; an authorized positive-integer
118
+ `reviewAt` overrides it, and `enabled: false` disables it. Short-circuit
119
+ booleans and fallback/null-aware constructs contribute zero. Lambda boundaries
120
+ are independent. Exactly the effective threshold passes; greater complexity
121
+ reviews and never fails. Load `references/complexity-policy.md` only when
122
+ `complexity` appears in `requiredPolicies`.
123
+
124
+ Markdown document and direct-section size count all physical lines. Sections
125
+ run from a supported heading through the line before the next heading of any
126
+ level, or EOF. Exact effective thresholds pass; greater measurements review and
127
+ never fail. Load `references/markdown-size-policy.md` when either
128
+ `markdownDocumentSize` or `markdownSectionSize` appears in `requiredPolicies`.
129
+ Review navigation and responsibility without mechanically splitting coherent
130
+ specifications or gaming headings/formatting.
131
+
132
+ Do not invent configuration, disable a guard, or raise its threshold
133
+ merely to silence a finding. Respect built-ins and only project/user-authorized overrides.
134
+ REVIEW requires inspection and justification, not mandatory refactoring.
135
+
136
+ Agent Code Guard is the canonical LOC implementation. Agent LOC Guard is the completed prototype/reference whose mature behavior was migrated from commit `75ab39d261dbc65f78815836fac90add16d265d1`.
137
+
138
+ Project-specific architecture rules, framework-specific checks, arbitrary style preferences, security scanners, and dependency auditing are outside the universal core.
@@ -0,0 +1,8 @@
1
+ interface:
2
+ display_name: "Code Guard"
3
+ short_description: "Deterministic code guardrails for agents"
4
+ brand_color: "#2563EB"
5
+ default_prompt: "Use $code-guard to check changed supported code and Markdown documentation, then load only the policies required by triggered findings."
6
+
7
+ policy:
8
+ allow_implicit_invocation: true