archgate 0.41.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.
@@ -0,0 +1,54 @@
1
+ # Dependencies
2
+ node_modules/
3
+
4
+ # Build output
5
+ dist
6
+ *.tsbuildinfo
7
+
8
+ # Test coverage
9
+ coverage
10
+ *.lcov
11
+
12
+ # Logs
13
+ *.log
14
+
15
+ # Environment variables
16
+ .env
17
+ .env.local
18
+ .env.*.local
19
+
20
+ # OS files
21
+ .DS_Store
22
+
23
+ # Claude Code worktrees
24
+ .claude/worktrees
25
+
26
+ # Proto / Moon
27
+ .moon/cache
28
+ .moon/docker
29
+
30
+ # Package manager
31
+ *.tgz
32
+ .npm
33
+
34
+ # Docs site build artifacts
35
+ docs/.astro/
36
+
37
+ # Archgate generated type definitions (regenerated by archgate)
38
+ .archgate/rules.d.ts
39
+
40
+ # Shim build artifacts
41
+ shims/nuget/**/bin/
42
+ shims/nuget/**/obj/
43
+ shims/maven/target/
44
+ shims/pypi/dist/
45
+ shims/pypi/*.egg-info/
46
+ shims/go/cmd/archgate/archgate
47
+ shims/go/cmd/archgate/archgate.exe
48
+ shims/rubygem/pkg/
49
+ shims/rubygem/*.gem
50
+ shims/pypi/**/__pycache__/
51
+ shims/pypi/.pytest_cache/
52
+
53
+ # Invalid HOME/USERPROFILE (e.g. literal "undefined") can create this under cwd — never commit
54
+ /undefined/
@@ -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 2026 Archgate
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.
@@ -0,0 +1,157 @@
1
+ Metadata-Version: 2.4
2
+ Name: archgate
3
+ Version: 0.41.1
4
+ Summary: Enforce Architecture Decision Records as executable rules — for both humans and AI agents
5
+ Project-URL: Homepage, https://cli.archgate.dev
6
+ Project-URL: Documentation, https://cli.archgate.dev
7
+ Project-URL: Repository, https://github.com/archgate/cli
8
+ Project-URL: Issues, https://github.com/archgate/cli/issues
9
+ Project-URL: Changelog, https://github.com/archgate/cli/blob/main/CHANGELOG.md
10
+ License: Apache-2.0
11
+ License-File: LICENSE.md
12
+ Keywords: adr,archgate,architecture-decision-records,cli,governance,linter
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Operating System :: MacOS
18
+ Classifier: Operating System :: Microsoft :: Windows
19
+ Classifier: Operating System :: POSIX :: Linux
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.8
22
+ Classifier: Programming Language :: Python :: 3.9
23
+ Classifier: Programming Language :: Python :: 3.10
24
+ Classifier: Programming Language :: Python :: 3.11
25
+ Classifier: Programming Language :: Python :: 3.12
26
+ Classifier: Programming Language :: Python :: 3.13
27
+ Classifier: Topic :: Software Development :: Quality Assurance
28
+ Requires-Python: >=3.8
29
+ Description-Content-Type: text/markdown
30
+
31
+ # Archgate
32
+
33
+ <div align="center">
34
+
35
+ **Enforce Architecture Decision Records as executable rules — for both humans and AI agents.**
36
+
37
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE.md)
38
+ [![Release](https://github.com/archgate/cli/actions/workflows/release.yml/badge.svg)](https://github.com/archgate/cli/actions/workflows/release.yml)
39
+ [![Docs](https://img.shields.io/badge/docs-cli.archgate.dev-blue)](https://cli.archgate.dev)
40
+ [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/12659/badge)](https://www.bestpractices.dev/projects/12659)
41
+
42
+ </div>
43
+
44
+ ---
45
+
46
+ Archgate turns your Architecture Decision Records into a governance layer that runs in CI, enforces rules in pre-commit hooks, and feeds live context to AI coding agents — so architectural decisions don't stay in documents, they stay in the code.
47
+
48
+ **Write an ADR once. Enforce it everywhere.**
49
+
50
+ ## How it works
51
+
52
+ Archgate has two layers:
53
+
54
+ 1. **ADRs as documents** — markdown files with YAML frontmatter stored in `.archgate/adrs/`. Each ADR records a decision: what was decided, why, and what to do and not do.
55
+ 2. **ADRs as rules** — each ADR can have a companion `.rules.ts` file that exports automated checks. Archgate runs these checks against your codebase and reports violations.
56
+
57
+ ```
58
+ .archgate/
59
+ └── adrs/
60
+ ├── ARCH-001-command-structure.md # human-readable decision
61
+ ├── ARCH-001-command-structure.rules.ts # machine-executable checks
62
+ ├── ARCH-002-error-handling.md
63
+ └── ARCH-002-error-handling.rules.ts
64
+ ```
65
+
66
+ When a rule is violated, `archgate check` reports the file, line, and which ADR was broken. Exit code 1 means violations — wire it into CI and it blocks merges automatically.
67
+
68
+ **The CLI is free and open source.** Writing ADRs, enforcing rules, running checks in CI, and wiring up pre-commit hooks all work without an account or subscription.
69
+
70
+ ## Installation
71
+
72
+ **Standalone** (no Node.js required):
73
+
74
+ ```bash
75
+ # macOS / Linux
76
+ curl -fsSL https://cli.archgate.dev/install-unix | sh
77
+
78
+ # Windows (PowerShell)
79
+ irm https://cli.archgate.dev/install-windows | iex
80
+
81
+ # Windows (Git Bash / MSYS2)
82
+ curl -fsSL https://cli.archgate.dev/install-unix | sh
83
+ ```
84
+
85
+ **Via npm** (or any Node.js package manager):
86
+
87
+ ```bash
88
+ # npm
89
+ npm install -g archgate
90
+
91
+ # Bun
92
+ bun install -g archgate
93
+
94
+ # Yarn
95
+ yarn global add archgate
96
+
97
+ # pnpm
98
+ pnpm add -g archgate
99
+ ```
100
+
101
+ You can also install as a dev dependency:
102
+
103
+ ```bash
104
+ npm install -D archgate # or: bun add -d archgate
105
+ npx archgate check # run via package manager
106
+ ```
107
+
108
+ **Requirements:** macOS (arm64), Linux (x86_64), or Windows (x86_64). See the [installation guide](https://cli.archgate.dev/getting-started/installation/) for more options.
109
+
110
+ ## Quick start
111
+
112
+ ```bash
113
+ # 1. Install
114
+ curl -fsSL https://cli.archgate.dev/install-unix | sh # or: npm install -g archgate
115
+
116
+ # 2. Initialize governance in your project
117
+ cd my-project
118
+ archgate init
119
+
120
+ # 3. Edit the generated ADR to document a real decision
121
+ # .archgate/adrs/ARCH-001-*.md
122
+
123
+ # 4. Add a companion .rules.ts to enforce it automatically
124
+ # .archgate/adrs/ARCH-001-*.rules.ts
125
+
126
+ # 5. Run checks
127
+ archgate check
128
+ ```
129
+
130
+ ## Writing rules
131
+
132
+ Each ADR can have a companion `.rules.ts` file that exports automated checks. See the [writing rules guide](https://cli.archgate.dev/guides/writing-rules/) for examples and the full [rule API reference](https://cli.archgate.dev/reference/rule-api/).
133
+
134
+ ## Supercharge with AI plugins
135
+
136
+ > **Make your AI agent architecture-aware.** With the optional editor plugins, your AI coding agent reads ADRs before writing code, validates changes against your rules, and captures new architectural patterns back into ADRs — automatically.
137
+ >
138
+ > Plugins are available for [**Claude Code**](https://cli.archgate.dev/guides/claude-code-plugin/) and [**Cursor**](https://cli.archgate.dev/guides/cursor-integration/).
139
+ >
140
+ > ```bash
141
+ > archgate login # one-time GitHub auth
142
+ > archgate init # installs the plugin automatically
143
+ > ```
144
+ >
145
+ > **[Get started with plugins](https://cli.archgate.dev/guides/claude-code-plugin/)** — the CLI works fully without them, but plugins close the loop between decisions and code.
146
+
147
+ ## Documentation
148
+
149
+ Full documentation is available at **[cli.archgate.dev](https://cli.archgate.dev)** — including guides for writing ADRs, writing rules, CI integration, editor plugin setup, and the complete CLI reference.
150
+
151
+ ## Contributing
152
+
153
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and workflow.
154
+
155
+ ## License
156
+
157
+ [Apache-2.0](LICENSE.md)
@@ -0,0 +1,127 @@
1
+ # Archgate
2
+
3
+ <div align="center">
4
+
5
+ **Enforce Architecture Decision Records as executable rules — for both humans and AI agents.**
6
+
7
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE.md)
8
+ [![Release](https://github.com/archgate/cli/actions/workflows/release.yml/badge.svg)](https://github.com/archgate/cli/actions/workflows/release.yml)
9
+ [![Docs](https://img.shields.io/badge/docs-cli.archgate.dev-blue)](https://cli.archgate.dev)
10
+ [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/12659/badge)](https://www.bestpractices.dev/projects/12659)
11
+
12
+ </div>
13
+
14
+ ---
15
+
16
+ Archgate turns your Architecture Decision Records into a governance layer that runs in CI, enforces rules in pre-commit hooks, and feeds live context to AI coding agents — so architectural decisions don't stay in documents, they stay in the code.
17
+
18
+ **Write an ADR once. Enforce it everywhere.**
19
+
20
+ ## How it works
21
+
22
+ Archgate has two layers:
23
+
24
+ 1. **ADRs as documents** — markdown files with YAML frontmatter stored in `.archgate/adrs/`. Each ADR records a decision: what was decided, why, and what to do and not do.
25
+ 2. **ADRs as rules** — each ADR can have a companion `.rules.ts` file that exports automated checks. Archgate runs these checks against your codebase and reports violations.
26
+
27
+ ```
28
+ .archgate/
29
+ └── adrs/
30
+ ├── ARCH-001-command-structure.md # human-readable decision
31
+ ├── ARCH-001-command-structure.rules.ts # machine-executable checks
32
+ ├── ARCH-002-error-handling.md
33
+ └── ARCH-002-error-handling.rules.ts
34
+ ```
35
+
36
+ When a rule is violated, `archgate check` reports the file, line, and which ADR was broken. Exit code 1 means violations — wire it into CI and it blocks merges automatically.
37
+
38
+ **The CLI is free and open source.** Writing ADRs, enforcing rules, running checks in CI, and wiring up pre-commit hooks all work without an account or subscription.
39
+
40
+ ## Installation
41
+
42
+ **Standalone** (no Node.js required):
43
+
44
+ ```bash
45
+ # macOS / Linux
46
+ curl -fsSL https://cli.archgate.dev/install-unix | sh
47
+
48
+ # Windows (PowerShell)
49
+ irm https://cli.archgate.dev/install-windows | iex
50
+
51
+ # Windows (Git Bash / MSYS2)
52
+ curl -fsSL https://cli.archgate.dev/install-unix | sh
53
+ ```
54
+
55
+ **Via npm** (or any Node.js package manager):
56
+
57
+ ```bash
58
+ # npm
59
+ npm install -g archgate
60
+
61
+ # Bun
62
+ bun install -g archgate
63
+
64
+ # Yarn
65
+ yarn global add archgate
66
+
67
+ # pnpm
68
+ pnpm add -g archgate
69
+ ```
70
+
71
+ You can also install as a dev dependency:
72
+
73
+ ```bash
74
+ npm install -D archgate # or: bun add -d archgate
75
+ npx archgate check # run via package manager
76
+ ```
77
+
78
+ **Requirements:** macOS (arm64), Linux (x86_64), or Windows (x86_64). See the [installation guide](https://cli.archgate.dev/getting-started/installation/) for more options.
79
+
80
+ ## Quick start
81
+
82
+ ```bash
83
+ # 1. Install
84
+ curl -fsSL https://cli.archgate.dev/install-unix | sh # or: npm install -g archgate
85
+
86
+ # 2. Initialize governance in your project
87
+ cd my-project
88
+ archgate init
89
+
90
+ # 3. Edit the generated ADR to document a real decision
91
+ # .archgate/adrs/ARCH-001-*.md
92
+
93
+ # 4. Add a companion .rules.ts to enforce it automatically
94
+ # .archgate/adrs/ARCH-001-*.rules.ts
95
+
96
+ # 5. Run checks
97
+ archgate check
98
+ ```
99
+
100
+ ## Writing rules
101
+
102
+ Each ADR can have a companion `.rules.ts` file that exports automated checks. See the [writing rules guide](https://cli.archgate.dev/guides/writing-rules/) for examples and the full [rule API reference](https://cli.archgate.dev/reference/rule-api/).
103
+
104
+ ## Supercharge with AI plugins
105
+
106
+ > **Make your AI agent architecture-aware.** With the optional editor plugins, your AI coding agent reads ADRs before writing code, validates changes against your rules, and captures new architectural patterns back into ADRs — automatically.
107
+ >
108
+ > Plugins are available for [**Claude Code**](https://cli.archgate.dev/guides/claude-code-plugin/) and [**Cursor**](https://cli.archgate.dev/guides/cursor-integration/).
109
+ >
110
+ > ```bash
111
+ > archgate login # one-time GitHub auth
112
+ > archgate init # installs the plugin automatically
113
+ > ```
114
+ >
115
+ > **[Get started with plugins](https://cli.archgate.dev/guides/claude-code-plugin/)** — the CLI works fully without them, but plugins close the loop between decisions and code.
116
+
117
+ ## Documentation
118
+
119
+ Full documentation is available at **[cli.archgate.dev](https://cli.archgate.dev)** — including guides for writing ADRs, writing rules, CI integration, editor plugin setup, and the complete CLI reference.
120
+
121
+ ## Contributing
122
+
123
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and workflow.
124
+
125
+ ## License
126
+
127
+ [Apache-2.0](LICENSE.md)
@@ -0,0 +1 @@
1
+ from archgate._version import __version__
@@ -0,0 +1,3 @@
1
+ from archgate._shim import main
2
+
3
+ main()
@@ -0,0 +1,194 @@
1
+ """Thin shim that downloads the archgate binary from GitHub Releases on first
2
+ invocation and then executes it. Zero runtime dependencies — stdlib only."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import hashlib
7
+ import os
8
+ import platform
9
+ import stat
10
+ import subprocess
11
+ import sys
12
+ import tarfile
13
+ import tempfile
14
+ import zipfile
15
+ from io import BytesIO
16
+ from pathlib import Path
17
+ from urllib.error import URLError
18
+ from urllib.request import urlopen
19
+
20
+ from archgate._version import __version__
21
+
22
+ # ---------------------------------------------------------------------------
23
+ # Platform helpers
24
+ # ---------------------------------------------------------------------------
25
+
26
+ _PLATFORM_MAP = {
27
+ ("Darwin", "arm64"): "archgate-darwin-arm64",
28
+ ("Darwin", "aarch64"): "archgate-darwin-arm64",
29
+ ("Linux", "x86_64"): "archgate-linux-x64",
30
+ ("Linux", "AMD64"): "archgate-linux-x64",
31
+ ("Windows", "AMD64"): "archgate-win32-x64",
32
+ ("Windows", "x86_64"): "archgate-win32-x64",
33
+ }
34
+
35
+
36
+ def _detect_artifact(): # type: () -> str
37
+ os_name = platform.system()
38
+ arch = platform.machine()
39
+ key = (os_name, arch)
40
+ artifact = _PLATFORM_MAP.get(key)
41
+ if artifact is None:
42
+ print(
43
+ "archgate: Unsupported platform: {os}/{arch}\n"
44
+ "archgate supports darwin/arm64, linux/x64, and win32/x64.".format(
45
+ os=os_name, arch=arch
46
+ ),
47
+ file=sys.stderr,
48
+ )
49
+ sys.exit(2)
50
+ return artifact
51
+
52
+
53
+ def _binary_name(): # type: () -> str
54
+ return "archgate.exe" if platform.system() == "Windows" else "archgate"
55
+
56
+
57
+ def _archive_ext(): # type: () -> str
58
+ return "zip" if platform.system() == "Windows" else "tar.gz"
59
+
60
+
61
+ # ---------------------------------------------------------------------------
62
+ # Download / verification
63
+ # ---------------------------------------------------------------------------
64
+
65
+ _BASE_URL = "https://github.com/archgate/cli/releases/download"
66
+
67
+
68
+ def _download_url(artifact, ext): # type: (str, str) -> str
69
+ return "{base}/v{ver}/{artifact}.{ext}".format(
70
+ base=_BASE_URL, ver=__version__, artifact=artifact, ext=ext
71
+ )
72
+
73
+
74
+ def _checksum_url(artifact, ext): # type: (str, str) -> str
75
+ return _download_url(artifact, ext) + ".sha256"
76
+
77
+
78
+ def _fetch(url): # type: (str) -> bytes
79
+ resp = urlopen(url) # noqa: S310 — follows redirects automatically
80
+ return resp.read()
81
+
82
+
83
+ def _verify_checksum(archive_bytes, artifact, ext):
84
+ # type: (bytes, str, str) -> None
85
+ """Download the .sha256 companion file and verify the archive."""
86
+ try:
87
+ checksum_bytes = _fetch(_checksum_url(artifact, ext))
88
+ except (URLError, OSError):
89
+ print(
90
+ "archgate: checksum file unavailable, skipping verification.",
91
+ file=sys.stderr,
92
+ )
93
+ return
94
+
95
+ expected = checksum_bytes.decode("utf-8").strip()[:64]
96
+ actual = hashlib.sha256(archive_bytes).hexdigest()
97
+ if expected != actual:
98
+ print(
99
+ "archgate: checksum verification failed for v{ver} "
100
+ "(expected {exp}, got {act})".format(
101
+ ver=__version__, exp=expected, act=actual
102
+ ),
103
+ file=sys.stderr,
104
+ )
105
+ sys.exit(2)
106
+
107
+
108
+ # ---------------------------------------------------------------------------
109
+ # Extraction
110
+ # ---------------------------------------------------------------------------
111
+
112
+
113
+ def _extract(archive_bytes, ext, dest_dir):
114
+ # type: (bytes, str, Path) -> None
115
+ """Extract archive into *dest_dir*."""
116
+ if ext == "tar.gz":
117
+ with tarfile.open(fileobj=BytesIO(archive_bytes), mode="r:gz") as tar:
118
+ tar.extractall(path=str(dest_dir))
119
+ else:
120
+ with zipfile.ZipFile(BytesIO(archive_bytes)) as zf:
121
+ zf.extractall(path=str(dest_dir))
122
+
123
+
124
+ # ---------------------------------------------------------------------------
125
+ # Main entry-point
126
+ # ---------------------------------------------------------------------------
127
+
128
+
129
+ def main(): # type: () -> None
130
+ cache_dir = Path.home() / ".archgate" / "bin"
131
+ binary = cache_dir / _binary_name()
132
+
133
+ if not binary.exists():
134
+ artifact = _detect_artifact()
135
+ ext = _archive_ext()
136
+ url = _download_url(artifact, ext)
137
+
138
+ print(
139
+ "archgate: binary not found, downloading v{ver}...".format(
140
+ ver=__version__
141
+ ),
142
+ file=sys.stderr,
143
+ )
144
+
145
+ try:
146
+ archive_bytes = _fetch(url)
147
+ except (URLError, OSError) as exc:
148
+ print(
149
+ "archgate: failed to download binary: {detail}\n"
150
+ "Visit https://cli.archgate.dev/getting-started/installation/ "
151
+ "for alternative install methods.".format(detail=exc),
152
+ file=sys.stderr,
153
+ )
154
+ sys.exit(2)
155
+
156
+ _verify_checksum(archive_bytes, artifact, ext)
157
+
158
+ # Extract into a temporary directory, then move the binary into the
159
+ # cache so we never leave a half-written file in place.
160
+ with tempfile.TemporaryDirectory() as tmp:
161
+ tmp_path = Path(tmp)
162
+ _extract(archive_bytes, ext, tmp_path)
163
+
164
+ # The binary may sit at the root of the archive or inside a
165
+ # single top-level directory — search for it.
166
+ bin_name = _binary_name()
167
+ candidates = list(tmp_path.rglob(bin_name))
168
+ if not candidates:
169
+ print(
170
+ "archgate: failed to locate binary inside the archive.",
171
+ file=sys.stderr,
172
+ )
173
+ sys.exit(2)
174
+
175
+ cache_dir.mkdir(parents=True, exist_ok=True)
176
+
177
+ src = candidates[0]
178
+ # On Windows, rename requires the destination not to exist.
179
+ if binary.exists():
180
+ binary.unlink()
181
+
182
+ # Copy instead of rename to handle cross-device moves.
183
+ import shutil
184
+
185
+ shutil.copy2(str(src), str(binary))
186
+
187
+ # Set executable permission on Unix.
188
+ if platform.system() != "Windows":
189
+ binary.chmod(binary.stat().st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
190
+
191
+ print("archgate: binary downloaded successfully.", file=sys.stderr)
192
+
193
+ result = subprocess.run([str(binary)] + sys.argv[1:])
194
+ sys.exit(result.returncode)
@@ -0,0 +1 @@
1
+ __version__ = "0.41.1"
@@ -0,0 +1,47 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "archgate"
7
+ version = "0.41.1"
8
+ description = "Enforce Architecture Decision Records as executable rules — for both humans and AI agents"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { text = "Apache-2.0" }
12
+ keywords = [
13
+ "adr",
14
+ "archgate",
15
+ "architecture-decision-records",
16
+ "cli",
17
+ "governance",
18
+ "linter",
19
+ ]
20
+ classifiers = [
21
+ "Development Status :: 4 - Beta",
22
+ "Environment :: Console",
23
+ "Intended Audience :: Developers",
24
+ "License :: OSI Approved :: Apache Software License",
25
+ "Operating System :: MacOS",
26
+ "Operating System :: Microsoft :: Windows",
27
+ "Operating System :: POSIX :: Linux",
28
+ "Programming Language :: Python :: 3",
29
+ "Programming Language :: Python :: 3.8",
30
+ "Programming Language :: Python :: 3.9",
31
+ "Programming Language :: Python :: 3.10",
32
+ "Programming Language :: Python :: 3.11",
33
+ "Programming Language :: Python :: 3.12",
34
+ "Programming Language :: Python :: 3.13",
35
+ "Topic :: Software Development :: Quality Assurance",
36
+ ]
37
+ dependencies = []
38
+
39
+ [project.scripts]
40
+ archgate = "archgate._shim:main"
41
+
42
+ [project.urls]
43
+ Homepage = "https://cli.archgate.dev"
44
+ Documentation = "https://cli.archgate.dev"
45
+ Repository = "https://github.com/archgate/cli"
46
+ Issues = "https://github.com/archgate/cli/issues"
47
+ Changelog = "https://github.com/archgate/cli/blob/main/CHANGELOG.md"
@@ -0,0 +1,144 @@
1
+ """Unit tests for the archgate PyPI shim. Uses only the stdlib unittest module."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import hashlib
6
+ import sys
7
+ import unittest
8
+ from unittest import mock
9
+
10
+ # ---------------------------------------------------------------------------
11
+ # Ensure the package is importable regardless of working directory.
12
+ # ---------------------------------------------------------------------------
13
+ from pathlib import Path
14
+
15
+ _PKG_ROOT = str(Path(__file__).resolve().parent.parent)
16
+ if _PKG_ROOT not in sys.path:
17
+ sys.path.insert(0, _PKG_ROOT)
18
+
19
+ from archgate._shim import ( # noqa: E402
20
+ _PLATFORM_MAP,
21
+ _archive_ext,
22
+ _binary_name,
23
+ _detect_artifact,
24
+ _verify_checksum,
25
+ )
26
+
27
+
28
+ class TestPlatformDetection(unittest.TestCase):
29
+ """Verify the platform → artifact mapping."""
30
+
31
+ def test_darwin_arm64(self):
32
+ with mock.patch("archgate._shim.platform") as mp:
33
+ mp.system.return_value = "Darwin"
34
+ mp.machine.return_value = "arm64"
35
+ self.assertEqual(_detect_artifact(), "archgate-darwin-arm64")
36
+
37
+ def test_darwin_aarch64(self):
38
+ with mock.patch("archgate._shim.platform") as mp:
39
+ mp.system.return_value = "Darwin"
40
+ mp.machine.return_value = "aarch64"
41
+ self.assertEqual(_detect_artifact(), "archgate-darwin-arm64")
42
+
43
+ def test_linux_x86_64(self):
44
+ with mock.patch("archgate._shim.platform") as mp:
45
+ mp.system.return_value = "Linux"
46
+ mp.machine.return_value = "x86_64"
47
+ self.assertEqual(_detect_artifact(), "archgate-linux-x64")
48
+
49
+ def test_linux_amd64(self):
50
+ with mock.patch("archgate._shim.platform") as mp:
51
+ mp.system.return_value = "Linux"
52
+ mp.machine.return_value = "AMD64"
53
+ self.assertEqual(_detect_artifact(), "archgate-linux-x64")
54
+
55
+ def test_windows_amd64(self):
56
+ with mock.patch("archgate._shim.platform") as mp:
57
+ mp.system.return_value = "Windows"
58
+ mp.machine.return_value = "AMD64"
59
+ self.assertEqual(_detect_artifact(), "archgate-win32-x64")
60
+
61
+ def test_windows_x86_64(self):
62
+ with mock.patch("archgate._shim.platform") as mp:
63
+ mp.system.return_value = "Windows"
64
+ mp.machine.return_value = "x86_64"
65
+ self.assertEqual(_detect_artifact(), "archgate-win32-x64")
66
+
67
+ def test_unsupported_platform_exits(self):
68
+ with mock.patch("archgate._shim.platform") as mp:
69
+ mp.system.return_value = "FreeBSD"
70
+ mp.machine.return_value = "i386"
71
+ with self.assertRaises(SystemExit) as ctx:
72
+ _detect_artifact()
73
+ self.assertEqual(ctx.exception.code, 2)
74
+
75
+
76
+ class TestArtifactNaming(unittest.TestCase):
77
+ """Verify artifact name, binary name, and archive extension."""
78
+
79
+ def test_artifact_names_in_platform_map(self):
80
+ expected_artifacts = {
81
+ "archgate-darwin-arm64",
82
+ "archgate-linux-x64",
83
+ "archgate-win32-x64",
84
+ }
85
+ self.assertEqual(set(_PLATFORM_MAP.values()), expected_artifacts)
86
+
87
+ def test_binary_name_windows(self):
88
+ with mock.patch("archgate._shim.platform") as mp:
89
+ mp.system.return_value = "Windows"
90
+ self.assertEqual(_binary_name(), "archgate.exe")
91
+
92
+ def test_binary_name_unix(self):
93
+ for os_name in ("Darwin", "Linux"):
94
+ with mock.patch("archgate._shim.platform") as mp:
95
+ mp.system.return_value = os_name
96
+ self.assertEqual(_binary_name(), "archgate")
97
+
98
+ def test_archive_ext_windows(self):
99
+ with mock.patch("archgate._shim.platform") as mp:
100
+ mp.system.return_value = "Windows"
101
+ self.assertEqual(_archive_ext(), "zip")
102
+
103
+ def test_archive_ext_unix(self):
104
+ for os_name in ("Darwin", "Linux"):
105
+ with mock.patch("archgate._shim.platform") as mp:
106
+ mp.system.return_value = os_name
107
+ self.assertEqual(_archive_ext(), "tar.gz")
108
+
109
+
110
+ class TestChecksumVerification(unittest.TestCase):
111
+ """Verify SHA256 checksum logic."""
112
+
113
+ def test_checksum_pass(self):
114
+ data = b"hello archgate"
115
+ expected_hash = hashlib.sha256(data).hexdigest()
116
+ checksum_content = (expected_hash + " archgate-linux-x64.tar.gz\n").encode()
117
+
118
+ with mock.patch("archgate._shim._fetch", return_value=checksum_content):
119
+ # Should not raise or exit.
120
+ _verify_checksum(data, "archgate-linux-x64", "tar.gz")
121
+
122
+ def test_checksum_mismatch_exits(self):
123
+ data = b"hello archgate"
124
+ wrong_hash = hashlib.sha256(b"wrong data").hexdigest()
125
+ checksum_content = (wrong_hash + " archgate-linux-x64.tar.gz\n").encode()
126
+
127
+ with mock.patch("archgate._shim._fetch", return_value=checksum_content):
128
+ with self.assertRaises(SystemExit) as ctx:
129
+ _verify_checksum(data, "archgate-linux-x64", "tar.gz")
130
+ self.assertEqual(ctx.exception.code, 2)
131
+
132
+ def test_checksum_unavailable_warns(self):
133
+ """When the checksum file can't be fetched, warn but don't exit."""
134
+ from urllib.error import URLError
135
+
136
+ data = b"hello archgate"
137
+
138
+ with mock.patch("archgate._shim._fetch", side_effect=URLError("404")):
139
+ # Should not raise or exit.
140
+ _verify_checksum(data, "archgate-linux-x64", "tar.gz")
141
+
142
+
143
+ if __name__ == "__main__":
144
+ unittest.main()