nomos-cli 4.28.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.
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.4
2
+ Name: nomos-cli
3
+ Version: 4.28.0
4
+ Summary: Zero-dependency launcher for Nomos: Apache-2.0 static Go AST & Git execution substrate for AI coding agents (nomos xray, nomos init, nomos verify, nomos mcp).
5
+ Author: Mark Gantlett
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://sophialabs.ca
8
+ Project-URL: Documentation, https://sophialabs.ca/docs/introduction
9
+ Project-URL: Repository, https://github.com/mgantlett/nomos
10
+ Project-URL: Issues, https://github.com/mgantlett/nomos/issues
11
+ Keywords: ai-agents,agent-skills,ast,claude-code,code-quality,coding-agents,cursor,git-hooks,git-worktree,guardrails,mcp,mcp-server,model-context-protocol,sarif
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Software Development :: Quality Assurance
17
+ Classifier: Topic :: Software Development :: Version Control :: Git
18
+ Requires-Python: >=3.9
19
+ Description-Content-Type: text/markdown
20
+
21
+ # `nomos-cli`
22
+
23
+ Zero-dependency Python (`uvx` / `pipx` / `pip`) launcher for [**Nomos**](https://github.com/mgantlett/nomos) (`Apache-2.0`), the compiled static Go AST and Git governance substrate between AI coding agents and production repositories.
24
+
25
+ ## Quick Usage (`uvx` - Zero Install Required)
26
+
27
+ ```bash
28
+ # Run a read-only sub-5s AI Hangover Score & AST hotspot audit:
29
+ uvx nomos-cli xray .
30
+
31
+ # Initialize non-breaking Branch Guard & Day-0 brownfield baseline ratchet:
32
+ uvx nomos-cli init --local
33
+
34
+ # Launch the local read-only stdio MCP server:
35
+ uvx nomos-cli mcp
36
+ ```
37
+
38
+ Or install `nomos` onto your Python environment `PATH`:
39
+
40
+ ```bash
41
+ uv tool install nomos-cli
42
+ # or: pip install nomos-cli
43
+ ```
44
+
45
+ Or attach directly to the zero-install remote Streamable HTTP MCP endpoint:
46
+
47
+ ```bash
48
+ claude mcp add --transport http nomos https://sophialabs.ca/mcp
49
+ ```
50
+
51
+ ## SHA-256 Integrity Verification
52
+
53
+ When `nomos` is not already present on `PATH`, `nomos-cli` downloads the official GitHub Release archive (`https://github.com/mgantlett/nomos/releases`) for your OS/CPU (`Linux`/`Darwin`/`Windows`, `x86_64`/`arm64`) using Python's standard library and verifies its SHA-256 digest against the release `checksums.txt` manifest before extracting or executing the binary.
54
+
55
+ <!-- mcp-name: io.github.mgantlett/nomos -->
@@ -0,0 +1,35 @@
1
+ # `nomos-cli`
2
+
3
+ Zero-dependency Python (`uvx` / `pipx` / `pip`) launcher for [**Nomos**](https://github.com/mgantlett/nomos) (`Apache-2.0`), the compiled static Go AST and Git governance substrate between AI coding agents and production repositories.
4
+
5
+ ## Quick Usage (`uvx` - Zero Install Required)
6
+
7
+ ```bash
8
+ # Run a read-only sub-5s AI Hangover Score & AST hotspot audit:
9
+ uvx nomos-cli xray .
10
+
11
+ # Initialize non-breaking Branch Guard & Day-0 brownfield baseline ratchet:
12
+ uvx nomos-cli init --local
13
+
14
+ # Launch the local read-only stdio MCP server:
15
+ uvx nomos-cli mcp
16
+ ```
17
+
18
+ Or install `nomos` onto your Python environment `PATH`:
19
+
20
+ ```bash
21
+ uv tool install nomos-cli
22
+ # or: pip install nomos-cli
23
+ ```
24
+
25
+ Or attach directly to the zero-install remote Streamable HTTP MCP endpoint:
26
+
27
+ ```bash
28
+ claude mcp add --transport http nomos https://sophialabs.ca/mcp
29
+ ```
30
+
31
+ ## SHA-256 Integrity Verification
32
+
33
+ When `nomos` is not already present on `PATH`, `nomos-cli` downloads the official GitHub Release archive (`https://github.com/mgantlett/nomos/releases`) for your OS/CPU (`Linux`/`Darwin`/`Windows`, `x86_64`/`arm64`) using Python's standard library and verifies its SHA-256 digest against the release `checksums.txt` manifest before extracting or executing the binary.
34
+
35
+ <!-- mcp-name: io.github.mgantlett/nomos -->
@@ -0,0 +1,50 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "nomos-cli"
7
+ version = "4.28.0"
8
+ description = "Zero-dependency launcher for Nomos: Apache-2.0 static Go AST & Git execution substrate for AI coding agents (nomos xray, nomos init, nomos verify, nomos mcp)."
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ requires-python = ">=3.9"
12
+ dependencies = []
13
+ authors = [{ name = "Mark Gantlett" }]
14
+ keywords = [
15
+ "ai-agents",
16
+ "agent-skills",
17
+ "ast",
18
+ "claude-code",
19
+ "code-quality",
20
+ "coding-agents",
21
+ "cursor",
22
+ "git-hooks",
23
+ "git-worktree",
24
+ "guardrails",
25
+ "mcp",
26
+ "mcp-server",
27
+ "model-context-protocol",
28
+ "sarif",
29
+ ]
30
+ classifiers = [
31
+ "Development Status :: 5 - Production/Stable",
32
+ "Environment :: Console",
33
+ "Intended Audience :: Developers",
34
+ "Programming Language :: Python :: 3",
35
+ "Topic :: Software Development :: Quality Assurance",
36
+ "Topic :: Software Development :: Version Control :: Git",
37
+ ]
38
+
39
+ [project.urls]
40
+ Homepage = "https://sophialabs.ca"
41
+ Documentation = "https://sophialabs.ca/docs/introduction"
42
+ Repository = "https://github.com/mgantlett/nomos"
43
+ Issues = "https://github.com/mgantlett/nomos/issues"
44
+
45
+ [project.scripts]
46
+ nomos-cli = "nomos_cli:main"
47
+ nomos = "nomos_cli:main"
48
+
49
+ [tool.setuptools.packages.find]
50
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,213 @@
1
+ """Zero-dependency SHA-256 verified Python launcher for the static Go nomos binary."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import hashlib
6
+ import io
7
+ import json
8
+ import os
9
+ import platform
10
+ import stat
11
+ import subprocess
12
+ import sys
13
+ import tarfile
14
+ import urllib.request
15
+ import zipfile
16
+ from dataclasses import asdict, dataclass
17
+ from pathlib import Path
18
+ from typing import List, Optional
19
+
20
+ FALLBACK_VERSION = "4.28.0"
21
+ USER_AGENT = "mgantlett-nomos-pypi-launcher"
22
+
23
+
24
+ @dataclass(frozen=True)
25
+ class TargetPlatform:
26
+ """Resolved OS, CPU architecture, and release archive metadata."""
27
+
28
+ version: str
29
+ goos: str
30
+ goarch: str
31
+ ext: str
32
+ bin_name: str
33
+ archive: str
34
+
35
+
36
+ def resolve_effective_version(env_version: Optional[str] = None) -> str:
37
+ """Resolves NOMOS_VERSION or queries GitHub's latest release tag with offline fallback."""
38
+ explicit = (env_version if env_version is not None else os.environ.get("NOMOS_VERSION", "")).strip()
39
+ if explicit:
40
+ return explicit.lstrip("v")
41
+ req = urllib.request.Request(
42
+ "https://api.github.com/repos/mgantlett/nomos/releases/latest",
43
+ headers={"Accept": "application/vnd.github+json", "User-Agent": USER_AGENT},
44
+ )
45
+ try:
46
+ with urllib.request.urlopen(req, timeout=2.5) as resp:
47
+ payload = json.loads(resp.read().decode("utf-8"))
48
+ tag = str(payload.get("tag_name", "")).strip().lstrip("v")
49
+ parts = tag.split(".")
50
+ if len(parts) >= 3 and parts[0].isdigit() and parts[1].isdigit():
51
+ return tag
52
+ except Exception:
53
+ return FALLBACK_VERSION
54
+ return FALLBACK_VERSION
55
+
56
+
57
+ def resolve_target_platform(
58
+ raw_version: str = FALLBACK_VERSION,
59
+ sys_name: Optional[str] = None,
60
+ machine_name: Optional[str] = None,
61
+ ) -> TargetPlatform:
62
+ """Maps Python OS and CPU identifiers onto GoReleaser archive coordinates."""
63
+ version = (raw_version or FALLBACK_VERSION).strip().lstrip("v")
64
+ raw_os = (sys_name or platform.system()).lower()
65
+ raw_arch = (machine_name or platform.machine()).lower()
66
+ os_map = {"linux": "Linux", "darwin": "Darwin", "windows": "Windows"}
67
+ arch_map = {
68
+ "x86_64": "x86_64",
69
+ "amd64": "x86_64",
70
+ "aarch64": "arm64",
71
+ "arm64": "arm64",
72
+ }
73
+ goos = os_map.get(raw_os)
74
+ goarch = arch_map.get(raw_arch)
75
+ if not goos or not goarch:
76
+ raise RuntimeError(f"Unsupported OS/arch combination: {raw_os}/{raw_arch}")
77
+ ext = "zip" if goos == "Windows" else "tar.gz"
78
+ bin_name = "nomos.exe" if goos == "Windows" else "nomos"
79
+ archive = f"nomos_{goos}_{goarch}.{ext}"
80
+ return TargetPlatform(version=version, goos=goos, goarch=goarch, ext=ext, bin_name=bin_name, archive=archive)
81
+
82
+
83
+ def parse_expected_sha256(checksums_text: str, archive_name: str) -> str:
84
+ """Extracts the expected lowercase SHA-256 hex digest for archive_name from checksums.txt."""
85
+ for line in checksums_text.splitlines():
86
+ parts = line.strip().split()
87
+ if len(parts) >= 2 and parts[1].lstrip("*") == archive_name:
88
+ return parts[0].lower()
89
+ raise ValueError(f"Archive {archive_name} not found in release checksums.txt")
90
+
91
+
92
+ def _is_usable_system_candidate(
93
+ cand: Path,
94
+ script_dir: Optional[Path],
95
+ exe_real: Optional[Path],
96
+ ) -> bool:
97
+ """Returns True when cand is an executable native binary distinct from Python wrapper shims."""
98
+ if not cand.is_file() or not os.access(cand, os.X_OK):
99
+ return False
100
+ resolved = cand.resolve()
101
+ if exe_real and resolved == exe_real:
102
+ return False
103
+ if script_dir and cand.parent.resolve() == script_dir and cand.read_bytes()[:2] == b"#!":
104
+ return False
105
+ return True
106
+
107
+
108
+ def find_existing_system_binary(bin_name: str, self_exe: Optional[Path] = None) -> Optional[str]:
109
+ """Finds an already-installed native nomos binary on PATH while skipping Python wrapper shims."""
110
+ if os.environ.get("NOMOS_SKIP_SYSTEM_PATH") == "1":
111
+ return None
112
+ script_dir = Path(sys.argv[0]).resolve().parent if sys.argv else None
113
+ exe_real = self_exe.resolve() if self_exe else None
114
+ entries = [e for e in os.environ.get("PATH", "").split(os.pathsep) if e]
115
+ for entry in entries:
116
+ cand = Path(entry) / bin_name
117
+ try:
118
+ if _is_usable_system_candidate(cand, script_dir, exe_real):
119
+ return str(cand)
120
+ except OSError:
121
+ continue
122
+ return None
123
+
124
+
125
+ def _fetch_bytes(url: str) -> bytes:
126
+ """Downloads raw bytes from a release URL using stdlib urllib."""
127
+ req = urllib.request.Request(url, headers={"User-Agent": USER_AGENT})
128
+ with urllib.request.urlopen(req, timeout=30) as resp:
129
+ return resp.read()
130
+
131
+
132
+ def _read_tar_member_bytes(archive_bytes: bytes, target: TargetPlatform) -> bytes:
133
+ """Reads the target executable payload from a verified tar.gz archive."""
134
+ with tarfile.open(fileobj=io.BytesIO(archive_bytes), mode="r:gz") as tf:
135
+ for member in tf.getmembers():
136
+ if member.isfile() and Path(member.name).name == target.bin_name:
137
+ extracted = tf.extractfile(member)
138
+ if extracted is not None:
139
+ return extracted.read()
140
+ raise RuntimeError(f"Binary {target.bin_name} missing inside {target.archive}")
141
+
142
+
143
+ def _read_zip_member_bytes(archive_bytes: bytes, target: TargetPlatform) -> bytes:
144
+ """Reads the target executable payload from a verified zip archive."""
145
+ with zipfile.ZipFile(io.BytesIO(archive_bytes)) as zf:
146
+ for name in zf.namelist():
147
+ if Path(name).name == target.bin_name:
148
+ return zf.read(name)
149
+ raise RuntimeError(f"Binary {target.bin_name} missing inside {target.archive}")
150
+
151
+
152
+ def _extract_verified_binary(archive_bytes: bytes, target: TargetPlatform, dest_bin: Path) -> None:
153
+ """Extracts exclusively the target nomos binary from a verified tar.gz or zip payload."""
154
+ payload = (
155
+ _read_tar_member_bytes(archive_bytes, target)
156
+ if target.ext == "tar.gz"
157
+ else _read_zip_member_bytes(archive_bytes, target)
158
+ )
159
+ dest_bin.write_bytes(payload)
160
+ if target.goos != "Windows":
161
+ dest_bin.chmod(dest_bin.stat().st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
162
+
163
+
164
+ def ensure_cached_binary(target: TargetPlatform) -> str:
165
+ """Returns a cached SHA-256 verified nomos binary path, downloading on cache miss."""
166
+ release_base = os.environ.get(
167
+ "NOMOS_RELEASE_BASE_URL",
168
+ f"https://github.com/mgantlett/nomos/releases/download/v{target.version}",
169
+ ).rstrip("/")
170
+ default_cache = Path.home() / ".cache" / "nomos-launcher"
171
+ cache_root = Path(os.environ.get("NOMOS_CACHE_DIR", str(default_cache)))
172
+ ver_dir = cache_root / f"v{target.version}-{target.goos}-{target.goarch}"
173
+ bin_path = ver_dir / target.bin_name
174
+ if bin_path.is_file():
175
+ return str(bin_path)
176
+
177
+ ver_dir.mkdir(parents=True, exist_ok=True)
178
+ checksums_text = _fetch_bytes(f"{release_base}/checksums.txt").decode("utf-8")
179
+ archive_bytes = _fetch_bytes(f"{release_base}/{target.archive}")
180
+ expected_hex = parse_expected_sha256(checksums_text, target.archive)
181
+ actual_hex = hashlib.sha256(archive_bytes).hexdigest().lower()
182
+ if actual_hex != expected_hex:
183
+ raise ValueError(f"SHA-256 mismatch for {target.archive}: expected {expected_hex}, got {actual_hex}")
184
+
185
+ tmp_bin = ver_dir / f".{target.bin_name}.tmp.{os.getpid()}"
186
+ _extract_verified_binary(archive_bytes, target, tmp_bin)
187
+ tmp_bin.replace(bin_path)
188
+ return str(bin_path)
189
+
190
+
191
+ def run_cli(argv: Optional[List[str]] = None) -> int:
192
+ """Executes the resolved nomos binary with CLI arguments or stdio mcp fallback."""
193
+ args = list(sys.argv[1:] if argv is None else argv)
194
+ if args[:1] == ["--launcher-info"]:
195
+ target = resolve_target_platform(os.environ.get("NOMOS_VERSION", FALLBACK_VERSION))
196
+ sys.stdout.write(json.dumps(asdict(target)) + "\n")
197
+ return 0
198
+ effective_args = ["mcp"] if (not args and not sys.stdin.isatty()) else args
199
+ quick_target = resolve_target_platform(FALLBACK_VERSION)
200
+ bin_path = find_existing_system_binary(quick_target.bin_name)
201
+ if not bin_path:
202
+ bin_path = ensure_cached_binary(resolve_target_platform(resolve_effective_version()))
203
+ completed = subprocess.run([bin_path, *effective_args], check=False)
204
+ return int(completed.returncode)
205
+
206
+
207
+ def main() -> None:
208
+ """Console script entrypoint for uvx nomos-cli and nomos."""
209
+ try:
210
+ raise SystemExit(run_cli())
211
+ except Exception as exc:
212
+ sys.stderr.write(f"[nomos-pypi] {exc}\n")
213
+ raise SystemExit(1) from exc
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.4
2
+ Name: nomos-cli
3
+ Version: 4.28.0
4
+ Summary: Zero-dependency launcher for Nomos: Apache-2.0 static Go AST & Git execution substrate for AI coding agents (nomos xray, nomos init, nomos verify, nomos mcp).
5
+ Author: Mark Gantlett
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://sophialabs.ca
8
+ Project-URL: Documentation, https://sophialabs.ca/docs/introduction
9
+ Project-URL: Repository, https://github.com/mgantlett/nomos
10
+ Project-URL: Issues, https://github.com/mgantlett/nomos/issues
11
+ Keywords: ai-agents,agent-skills,ast,claude-code,code-quality,coding-agents,cursor,git-hooks,git-worktree,guardrails,mcp,mcp-server,model-context-protocol,sarif
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Software Development :: Quality Assurance
17
+ Classifier: Topic :: Software Development :: Version Control :: Git
18
+ Requires-Python: >=3.9
19
+ Description-Content-Type: text/markdown
20
+
21
+ # `nomos-cli`
22
+
23
+ Zero-dependency Python (`uvx` / `pipx` / `pip`) launcher for [**Nomos**](https://github.com/mgantlett/nomos) (`Apache-2.0`), the compiled static Go AST and Git governance substrate between AI coding agents and production repositories.
24
+
25
+ ## Quick Usage (`uvx` - Zero Install Required)
26
+
27
+ ```bash
28
+ # Run a read-only sub-5s AI Hangover Score & AST hotspot audit:
29
+ uvx nomos-cli xray .
30
+
31
+ # Initialize non-breaking Branch Guard & Day-0 brownfield baseline ratchet:
32
+ uvx nomos-cli init --local
33
+
34
+ # Launch the local read-only stdio MCP server:
35
+ uvx nomos-cli mcp
36
+ ```
37
+
38
+ Or install `nomos` onto your Python environment `PATH`:
39
+
40
+ ```bash
41
+ uv tool install nomos-cli
42
+ # or: pip install nomos-cli
43
+ ```
44
+
45
+ Or attach directly to the zero-install remote Streamable HTTP MCP endpoint:
46
+
47
+ ```bash
48
+ claude mcp add --transport http nomos https://sophialabs.ca/mcp
49
+ ```
50
+
51
+ ## SHA-256 Integrity Verification
52
+
53
+ When `nomos` is not already present on `PATH`, `nomos-cli` downloads the official GitHub Release archive (`https://github.com/mgantlett/nomos/releases`) for your OS/CPU (`Linux`/`Darwin`/`Windows`, `x86_64`/`arm64`) using Python's standard library and verifies its SHA-256 digest against the release `checksums.txt` manifest before extracting or executing the binary.
54
+
55
+ <!-- mcp-name: io.github.mgantlett/nomos -->
@@ -0,0 +1,8 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/nomos_cli/__init__.py
4
+ src/nomos_cli.egg-info/PKG-INFO
5
+ src/nomos_cli.egg-info/SOURCES.txt
6
+ src/nomos_cli.egg-info/dependency_links.txt
7
+ src/nomos_cli.egg-info/entry_points.txt
8
+ src/nomos_cli.egg-info/top_level.txt
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ nomos = nomos_cli:main
3
+ nomos-cli = nomos_cli:main
@@ -0,0 +1 @@
1
+ nomos_cli