archy 0.4.1__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.
- archy-0.4.1/.github/workflows/ci.yml +38 -0
- archy-0.4.1/.github/workflows/publish.yml +49 -0
- archy-0.4.1/.gitignore +225 -0
- archy-0.4.1/.pre-commit-hooks.yaml +23 -0
- archy-0.4.1/CONTRIBUTING.md +44 -0
- archy-0.4.1/LICENSE +21 -0
- archy-0.4.1/PKG-INFO +277 -0
- archy-0.4.1/README.md +233 -0
- archy-0.4.1/action.yml +88 -0
- archy-0.4.1/archy.yaml +36 -0
- archy-0.4.1/docs/CASE_STUDIES.md +249 -0
- archy-0.4.1/docs/FUTURE.md +34 -0
- archy-0.4.1/docs/LEARNINGS.md +122 -0
- archy-0.4.1/pyproject.toml +59 -0
- archy-0.4.1/src/archy/__init__.py +1 -0
- archy-0.4.1/src/archy/cli.py +473 -0
- archy-0.4.1/src/archy/cycles.py +59 -0
- archy-0.4.1/src/archy/graph.py +335 -0
- archy-0.4.1/src/archy/history.py +197 -0
- archy-0.4.1/src/archy/layers.py +224 -0
- archy-0.4.1/src/archy/mcp.py +260 -0
- archy-0.4.1/src/archy/parser.py +140 -0
- archy-0.4.1/src/archy/score.py +123 -0
- archy-0.4.1/src/archy/trend.py +61 -0
- archy-0.4.1/tests/__init__.py +0 -0
- archy-0.4.1/tests/test_cli.py +381 -0
- archy-0.4.1/tests/test_cycles.py +207 -0
- archy-0.4.1/tests/test_graph.py +260 -0
- archy-0.4.1/tests/test_history.py +123 -0
- archy-0.4.1/tests/test_layers.py +198 -0
- archy-0.4.1/tests/test_mcp.py +236 -0
- archy-0.4.1/tests/test_parser.py +116 -0
- archy-0.4.1/tests/test_score.py +203 -0
- archy-0.4.1/tests/test_smoke.py +5 -0
- archy-0.4.1/tests/test_trend.py +98 -0
- archy-0.4.1/uv.lock +1214 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
check:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
|
|
14
|
+
- name: Install uv
|
|
15
|
+
uses: astral-sh/setup-uv@v3
|
|
16
|
+
with:
|
|
17
|
+
enable-cache: true
|
|
18
|
+
|
|
19
|
+
- name: Set up Python
|
|
20
|
+
run: uv python install 3.10
|
|
21
|
+
|
|
22
|
+
- name: Install dependencies
|
|
23
|
+
run: uv sync
|
|
24
|
+
|
|
25
|
+
- name: Ruff lint
|
|
26
|
+
run: uv run ruff check
|
|
27
|
+
|
|
28
|
+
- name: Ruff format
|
|
29
|
+
run: uv run ruff format --check
|
|
30
|
+
|
|
31
|
+
- name: Type check (ty)
|
|
32
|
+
run: uv run ty check
|
|
33
|
+
|
|
34
|
+
- name: Tests
|
|
35
|
+
run: uv run pytest
|
|
36
|
+
|
|
37
|
+
- name: Layer rules (archy check)
|
|
38
|
+
run: uv run archy check .
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
name: Build distributions
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- name: Install uv
|
|
16
|
+
uses: astral-sh/setup-uv@v3
|
|
17
|
+
with:
|
|
18
|
+
enable-cache: true
|
|
19
|
+
|
|
20
|
+
- name: Set up Python
|
|
21
|
+
run: uv python install 3.10
|
|
22
|
+
|
|
23
|
+
- name: Build sdist and wheel
|
|
24
|
+
run: uv build
|
|
25
|
+
|
|
26
|
+
- name: Upload built distributions
|
|
27
|
+
uses: actions/upload-artifact@v4
|
|
28
|
+
with:
|
|
29
|
+
name: dist
|
|
30
|
+
path: dist/
|
|
31
|
+
|
|
32
|
+
publish:
|
|
33
|
+
name: Publish to PyPI
|
|
34
|
+
needs: build
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
environment:
|
|
37
|
+
name: pypi
|
|
38
|
+
url: https://pypi.org/project/archy/
|
|
39
|
+
permissions:
|
|
40
|
+
id-token: write
|
|
41
|
+
steps:
|
|
42
|
+
- name: Download built distributions
|
|
43
|
+
uses: actions/download-artifact@v4
|
|
44
|
+
with:
|
|
45
|
+
name: dist
|
|
46
|
+
path: dist/
|
|
47
|
+
|
|
48
|
+
- name: Publish via Trusted Publishing
|
|
49
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
archy-0.4.1/.gitignore
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
# Temporary file for partial code execution
|
|
204
|
+
tempCodeRunnerFile.py
|
|
205
|
+
|
|
206
|
+
# Ruff stuff:
|
|
207
|
+
.ruff_cache/
|
|
208
|
+
|
|
209
|
+
# PyPI configuration file
|
|
210
|
+
.pypirc
|
|
211
|
+
|
|
212
|
+
# Marimo
|
|
213
|
+
marimo/_static/
|
|
214
|
+
marimo/_lsp/
|
|
215
|
+
__marimo__/
|
|
216
|
+
|
|
217
|
+
# Streamlit
|
|
218
|
+
.streamlit/secrets.toml
|
|
219
|
+
|
|
220
|
+
# DeepWork (local-only review tooling)
|
|
221
|
+
.deepwork/
|
|
222
|
+
.deepreview
|
|
223
|
+
|
|
224
|
+
# archy score history (per-checkout, not committed; one row per `archy score --record`)
|
|
225
|
+
.archy/
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
- id: archy-check
|
|
2
|
+
name: archy check
|
|
3
|
+
description: Enforce layer rules declared in archy.yaml
|
|
4
|
+
entry: archy check .
|
|
5
|
+
language: python
|
|
6
|
+
pass_filenames: false
|
|
7
|
+
always_run: true
|
|
8
|
+
|
|
9
|
+
- id: archy-score-strict
|
|
10
|
+
name: archy score --strict
|
|
11
|
+
description: Fail if the composite quality score regresses beyond tolerance
|
|
12
|
+
entry: archy score . --strict
|
|
13
|
+
language: python
|
|
14
|
+
pass_filenames: false
|
|
15
|
+
always_run: true
|
|
16
|
+
|
|
17
|
+
- id: archy-cycles
|
|
18
|
+
name: archy cycles --strict
|
|
19
|
+
description: Fail if any import cycle (size >= 2) is present
|
|
20
|
+
entry: archy cycles . --strict
|
|
21
|
+
language: python
|
|
22
|
+
pass_filenames: false
|
|
23
|
+
always_run: true
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Style
|
|
4
|
+
|
|
5
|
+
### No em dashes
|
|
6
|
+
|
|
7
|
+
Do not use the em-dash character (Unicode codepoint U+2014) anywhere in
|
|
8
|
+
the repository. Not in code, comments, docstrings, commit messages, PR
|
|
9
|
+
descriptions, or documentation. Use a regular hyphen-minus (`-`) instead,
|
|
10
|
+
or restructure the sentence, or use a colon, semicolon, or parentheses.
|
|
11
|
+
|
|
12
|
+
This rule applies uniformly to:
|
|
13
|
+
|
|
14
|
+
- Markdown files (`README.md`, `docs/*.md`, etc.)
|
|
15
|
+
- Python source and tests
|
|
16
|
+
- YAML config (`archy.yaml`, CI workflows)
|
|
17
|
+
- Commit messages and PR bodies
|
|
18
|
+
|
|
19
|
+
CI does not currently enforce this. The local DeepWork review setup flags
|
|
20
|
+
violations. To search for any em-dash in the repo without embedding the
|
|
21
|
+
forbidden character in the command itself:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Python: scans every text file under . and lists those containing U+2014.
|
|
25
|
+
python3 -c "from pathlib import Path; [print(p) for p in Path('.').rglob('*') if p.is_file() and chr(0x2014) in p.read_text(errors='ignore')]"
|
|
26
|
+
|
|
27
|
+
# zsh / bash 4.2+: $'\u2014' expands to the em-dash codepoint at runtime.
|
|
28
|
+
grep -rn $'\u2014' --include='*.md' --include='*.py' \
|
|
29
|
+
--include='*.yaml' --include='*.yml' --include='*.toml' .
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Other conventions
|
|
33
|
+
|
|
34
|
+
See `.deepwork/review/python_conventions.md` (local-only) for the broader
|
|
35
|
+
Python style notes the review tooling enforces. The short version:
|
|
36
|
+
|
|
37
|
+
- `from __future__ import annotations` at the top of every module.
|
|
38
|
+
- PEP 604 type syntax (`list[X]`, `str | None`).
|
|
39
|
+
- `pathlib.Path` over `os.path`.
|
|
40
|
+
- Frozen dataclasses for value objects; tuples (not lists) for their
|
|
41
|
+
sequence fields.
|
|
42
|
+
- ruff line length 100, target py310.
|
|
43
|
+
- Comments explain *why*, not *what*. If a comment merely narrates the
|
|
44
|
+
code, delete it.
|
archy-0.4.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alex Lee
|
|
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.
|
archy-0.4.1/PKG-INFO
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: archy
|
|
3
|
+
Version: 0.4.1
|
|
4
|
+
Summary: Architectural sensor for Python codebases
|
|
5
|
+
Project-URL: Homepage, https://github.com/hslee16/archy
|
|
6
|
+
Project-URL: Issues, https://github.com/hslee16/archy/issues
|
|
7
|
+
Author: Alex Lee
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2026 Alex Lee
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Keywords: architecture,dependency-graph,static-analysis,tree-sitter
|
|
31
|
+
Classifier: Development Status :: 1 - Planning
|
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
+
Classifier: Programming Language :: Python :: 3
|
|
34
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
35
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
36
|
+
Requires-Python: >=3.10
|
|
37
|
+
Requires-Dist: click>=8.1
|
|
38
|
+
Requires-Dist: mcp>=1.27.1
|
|
39
|
+
Requires-Dist: networkx>=3.2
|
|
40
|
+
Requires-Dist: pyyaml>=6.0
|
|
41
|
+
Requires-Dist: tree-sitter-python>=0.23
|
|
42
|
+
Requires-Dist: tree-sitter>=0.23
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
|
|
45
|
+
# archy
|
|
46
|
+
|
|
47
|
+
> Architectural sensor for Python codebases - keeps structure honest under AI-assisted development.
|
|
48
|
+
|
|
49
|
+
**Status:** v0.4.1. Usable today via:
|
|
50
|
+
|
|
51
|
+
| Mode | Command |
|
|
52
|
+
|---|---|
|
|
53
|
+
| Inspection | `archy graph`, `archy cycles` |
|
|
54
|
+
| CI governance | `archy check` (reads `archy.yaml`) |
|
|
55
|
+
| One-shot score | `archy score` |
|
|
56
|
+
| Trended score | `archy score --record` + `archy trend` |
|
|
57
|
+
| MCP server | `archy mcp` |
|
|
58
|
+
|
|
59
|
+
Benchmarks against pydantic, fastapi, flask, pytest, and archy-on-archy live in [`docs/CASE_STUDIES.md`](docs/CASE_STUDIES.md). Score design follows sentrux (modularity, acyclicity, depth, equality, geometric mean); see [`docs/LEARNINGS.md`](docs/LEARNINGS.md).
|
|
60
|
+
|
|
61
|
+
## Why
|
|
62
|
+
|
|
63
|
+
AI agents generate code at machine speed. Without a feedback loop on *structural* health (module coupling, import cycles, layer violations), codebases drift architecturally even when every individual change looks fine in review.
|
|
64
|
+
|
|
65
|
+
`archy` watches a Python codebase, builds a live module-dependency graph, and surfaces drift through a single trended score plus a handful of actionable sub-metrics. It's designed to run in CI, in pre-commit, and as an MCP server (`archy mcp`) so coding agents can read their own architectural impact before committing.
|
|
66
|
+
|
|
67
|
+
## Scope
|
|
68
|
+
|
|
69
|
+
- **Python only.** The cross-language story is deliberately someone else's problem.
|
|
70
|
+
- **Tree-sitter powered.** Robust to in-flight edits and partial files; survives syntax errors that would crash `ast`.
|
|
71
|
+
- **Score that trends over time.** A single number per commit, persisted, plotted. Trend matters more than the absolute value.
|
|
72
|
+
- **Rules as YAML.** "Layer X cannot import Y." No DSL, no plugins (yet).
|
|
73
|
+
|
|
74
|
+
## Non-goals
|
|
75
|
+
|
|
76
|
+
- Multi-language analysis
|
|
77
|
+
- Replacing linters, type checkers, or test runners
|
|
78
|
+
- Generating code or auto-fixing violations
|
|
79
|
+
|
|
80
|
+
## Quick start
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
uv sync
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Inspect the graph
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
uv run archy graph path/to/project --internal-only
|
|
90
|
+
uv run archy graph path/to/project --format json > graph.json
|
|
91
|
+
uv run archy graph path/to/project --format dot | dot -Tsvg > graph.svg
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Find import cycles
|
|
95
|
+
|
|
96
|
+
Tarjan SCCs of size >= 2. Use `--strict` in CI to fail on any cycle.
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
uv run archy cycles path/to/project
|
|
100
|
+
uv run archy cycles path/to/project --format json
|
|
101
|
+
uv run archy cycles path/to/project --strict
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Enforce layer rules
|
|
105
|
+
|
|
106
|
+
Reads `archy.yaml` from the repo root. Exits 1 on any violation. See [Layer rules](#layer-rules-archy-check) below.
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
uv run archy check path/to/project
|
|
110
|
+
uv run archy check path/to/project --format json
|
|
111
|
+
uv run archy check path/to/project --config custom.yaml
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Compute a quality score
|
|
115
|
+
|
|
116
|
+
Composite of modularity, acyclicity, depth, and equality (geometric mean).
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
uv run archy score path/to/project
|
|
120
|
+
uv run archy score path/to/project --format json
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Track score over time
|
|
124
|
+
|
|
125
|
+
Persist per-commit scores to `.archy/history.jsonl` and chart the trend.
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
uv run archy score path/to/project --record
|
|
129
|
+
uv run archy trend path/to/project
|
|
130
|
+
uv run archy trend path/to/project --last 30 --format json
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Regression gate
|
|
134
|
+
|
|
135
|
+
Fail if the current score drops more than `--strict-tolerance` (default 0.02) below the most recent recorded run.
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
uv run archy score path/to/project --strict
|
|
139
|
+
uv run archy score path/to/project --strict --record # check then record
|
|
140
|
+
uv run archy score path/to/project --strict --strict-tolerance 0.0
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Run as an MCP server
|
|
144
|
+
|
|
145
|
+
Stdio transport, so AI agents can call archy directly. See [MCP server](#mcp-server-archy-mcp) below.
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
uv run archy mcp
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## MCP server (`archy mcp`)
|
|
152
|
+
|
|
153
|
+
`archy mcp` exposes five tools to MCP-aware AI agents (Claude Code, the Anthropic API, etc.):
|
|
154
|
+
|
|
155
|
+
| Tool | Purpose |
|
|
156
|
+
|---|---|
|
|
157
|
+
| `archy_score` | Compute the four-metric score; optional `record=True` and `strict=True` for the same regression-gate behaviour the CLI offers. |
|
|
158
|
+
| `archy_cycles` | Find import cycles. |
|
|
159
|
+
| `archy_check` | Run layer rules from `archy.yaml`. |
|
|
160
|
+
| `archy_trend` | Read recent score history. |
|
|
161
|
+
| `archy_record_baseline` | Convenience wrapper for `archy_score(record=True)`; mirrors sentrux's `session_start`. |
|
|
162
|
+
|
|
163
|
+
Wire it into Claude Code with this stanza in your config:
|
|
164
|
+
|
|
165
|
+
```json
|
|
166
|
+
{
|
|
167
|
+
"mcpServers": {
|
|
168
|
+
"archy": { "command": "uv", "args": ["run", "archy", "mcp"] }
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Regression-gate semantics
|
|
174
|
+
|
|
175
|
+
`--strict` reads the last row from `.archy/history.jsonl` and compares the current score against it. Drops beyond the tolerance fail with exit code 1. The default tolerance (0.02) matches the threshold sentrux's `gate` uses. This gives archy parity with sentrux's regression-gate use case while keeping the long-term JSONL history for `archy trend`.
|
|
176
|
+
|
|
177
|
+
## CI integration
|
|
178
|
+
|
|
179
|
+
### GitHub Action
|
|
180
|
+
|
|
181
|
+
archy ships a composite action you can drop into any workflow:
|
|
182
|
+
|
|
183
|
+
```yaml
|
|
184
|
+
- uses: hslee16/archy@v0.4.1
|
|
185
|
+
with:
|
|
186
|
+
command: score # score | check | cycles
|
|
187
|
+
path: .
|
|
188
|
+
strict: "true" # fail on regression (score) or any cycle (cycles)
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Inputs (all optional unless noted):
|
|
192
|
+
|
|
193
|
+
| Input | Default | Notes |
|
|
194
|
+
|---|---|---|
|
|
195
|
+
| `command` | `score` | `score`, `check`, or `cycles` |
|
|
196
|
+
| `path` | `.` | Project root to analyze |
|
|
197
|
+
| `strict` | `true` | `score`/`cycles`: fail on regression / any cycle |
|
|
198
|
+
| `strict-tolerance` | `0.02` | `score --strict` tolerance |
|
|
199
|
+
| `record` | `false` | `score`: append result to `.archy/history.jsonl` |
|
|
200
|
+
| `config` | (auto) | `check`: path to `archy.yaml` |
|
|
201
|
+
| `python-version` | `3.10` | Python to install |
|
|
202
|
+
|
|
203
|
+
### Pre-commit hook
|
|
204
|
+
|
|
205
|
+
Add to `.pre-commit-config.yaml`:
|
|
206
|
+
|
|
207
|
+
```yaml
|
|
208
|
+
repos:
|
|
209
|
+
- repo: https://github.com/hslee16/archy
|
|
210
|
+
rev: v0.4.1
|
|
211
|
+
hooks:
|
|
212
|
+
- id: archy-check # layer rules from archy.yaml
|
|
213
|
+
- id: archy-score-strict # regression gate against last recorded score
|
|
214
|
+
- id: archy-cycles # fail on any import cycle
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
`archy-score-strict` reads `.archy/history.jsonl`; commit a baseline first with `archy score . --record`.
|
|
218
|
+
|
|
219
|
+
## Layer rules (`archy check`)
|
|
220
|
+
|
|
221
|
+
Drop an `archy.yaml` at the repo root declaring layers and forbidden directions:
|
|
222
|
+
|
|
223
|
+
```yaml
|
|
224
|
+
layers:
|
|
225
|
+
domain:
|
|
226
|
+
modules:
|
|
227
|
+
- "myapp.domain.**"
|
|
228
|
+
application:
|
|
229
|
+
modules:
|
|
230
|
+
- "myapp.application.**"
|
|
231
|
+
infra:
|
|
232
|
+
modules:
|
|
233
|
+
- "myapp.infra.**"
|
|
234
|
+
- "myapp.adapters.**"
|
|
235
|
+
|
|
236
|
+
forbid:
|
|
237
|
+
- {from: domain, to: application}
|
|
238
|
+
- {from: domain, to: infra}
|
|
239
|
+
- {from: application, to: infra}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
**Pattern syntax.** Dotted-name globs: `*` matches one segment, `**` matches zero or more. `myapp.domain.**` covers the package itself and every descendant. Modules must belong to at most one layer.
|
|
243
|
+
|
|
244
|
+
**Discovery.** `archy check` walks PATH upward to find `archy.yaml` unless `--config` is given. Exits 1 on violation.
|
|
245
|
+
|
|
246
|
+
archy enforces its own architecture this way; see [`archy.yaml`](archy.yaml) at the repo root and the `archy check .` step in `.github/workflows/ci.yml`.
|
|
247
|
+
|
|
248
|
+
## Development
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
uv sync # install runtime + dev deps from uv.lock
|
|
252
|
+
uv run ruff check # lint
|
|
253
|
+
uv run ruff format # format
|
|
254
|
+
uv run ty check # type check
|
|
255
|
+
uv run pytest # tests
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Roadmap
|
|
259
|
+
|
|
260
|
+
Next up:
|
|
261
|
+
|
|
262
|
+
- [ ] `archy_impact` MCP tool: blast-radius analysis for a set of changed files
|
|
263
|
+
- [ ] `archy graph` MCP tool: expose the dep graph itself for agent-side reasoning
|
|
264
|
+
- [ ] Score deltas (`archy_evolution`): per-component diffs vs. the last recorded run
|
|
265
|
+
- [ ] Design Structure Matrix (`archy dsm`)
|
|
266
|
+
|
|
267
|
+
Shipped: tree-sitter import graph, `__init__.py` re-export resolution, Tarjan cycle detection, YAML layer rules (`archy check`), composite score (`archy score`), JSONL history + `archy trend`, MCP server (`archy mcp`), GitHub Action + pre-commit hooks.
|
|
268
|
+
|
|
269
|
+
See [`docs/FUTURE.md`](docs/FUTURE.md) for the longer list and [`docs/LEARNINGS.md`](docs/LEARNINGS.md) for design notes.
|
|
270
|
+
|
|
271
|
+
## Contributing
|
|
272
|
+
|
|
273
|
+
See [`CONTRIBUTING.md`](CONTRIBUTING.md) for style rules. Notably: no em-dash characters (U+2014) anywhere in the repo.
|
|
274
|
+
|
|
275
|
+
## License
|
|
276
|
+
|
|
277
|
+
MIT, see [LICENSE](LICENSE).
|