@mgantlett/nomos 0.0.0-stage → 4.27.1

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.
package/README.md CHANGED
@@ -1,3 +1,26 @@
1
- # Temporary Holding Version
1
+ # `@mgantlett/nomos`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Zero-dependency Node.js (`npx`) launcher for [**Nomos**](https://github.com/mgantlett/nomos) (`Apache-2.0`), the compiled static Go execution substrate between AI coding agents and Git.
4
+
5
+ ## Quick Usage (Zero Global Install Required)
6
+
7
+ ```bash
8
+ # Run a read-only 5-second AI Hangover Score & AST hotspot audit:
9
+ npx --yes @mgantlett/nomos xray .
10
+
11
+ # Initialize non-breaking Branch Guard & Day-0 brownfield baseline ratchet:
12
+ npx --yes @mgantlett/nomos init --local
13
+
14
+ # Launch the local read-only stdio MCP server:
15
+ npx --yes @mgantlett/nomos mcp
16
+ ```
17
+
18
+ Or connect directly to the zero-install remote Streamable HTTP MCP surface:
19
+
20
+ ```bash
21
+ claude mcp add --transport http nomos https://sophialabs.ca/mcp
22
+ ```
23
+
24
+ ## Integrity Verification
25
+
26
+ When `nomos` is not already present on `PATH`, `@mgantlett/nomos` downloads the official GitHub Release tarball (`https://github.com/mgantlett/nomos/releases`) for your OS/CPU (`linux`/`darwin`/`windows`, `x86_64`/`arm64`) and verifies its SHA-256 digest against the release `checksums.txt` manifest before execution.
@@ -0,0 +1,142 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * nomos-cli.mjs - Zero-dependency SHA-256 verified launcher for the static Go `nomos` binary.
4
+ * Resolves system PATH `nomos` first, or downloads and verifies the pinned GitHub Release archive.
5
+ */
6
+ import { execFileSync, spawnSync } from 'node:child_process';
7
+ import crypto from 'node:crypto';
8
+ import fs from 'node:fs';
9
+ import os from 'node:os';
10
+ import path from 'node:path';
11
+ import { fileURLToPath } from 'node:url';
12
+
13
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
14
+ const pkgJson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
15
+ const FALLBACK_VERSION = String(pkgJson.version || '4.27.1').replace(/^v/, '');
16
+
17
+ async function resolveEffectiveVersion() {
18
+ if (process.env.NOMOS_VERSION) {
19
+ return String(process.env.NOMOS_VERSION).replace(/^v/, '');
20
+ }
21
+ try {
22
+ const res = await fetch('https://api.github.com/repos/mgantlett/nomos/releases/latest', {
23
+ headers: {
24
+ Accept: 'application/vnd.github+json',
25
+ 'User-Agent': 'sophialabs-nomos-npx-launcher'
26
+ },
27
+ signal: AbortSignal.timeout(2500)
28
+ });
29
+ if (res.ok) {
30
+ const data = await res.json();
31
+ const tag = String(data?.tag_name || '').replace(/^v/, '');
32
+ if (/^\d+\.\d+\.\d+/.test(tag)) return tag;
33
+ }
34
+ } catch {
35
+ // Fall back to bundled manifest version when offline or rate-limited.
36
+ }
37
+ return FALLBACK_VERSION;
38
+ }
39
+
40
+ function resolveTargetPlatform(rawVersion) {
41
+ const version = String(rawVersion || FALLBACK_VERSION).replace(/^v/, '');
42
+ const platMap = { linux: 'Linux', darwin: 'Darwin', win32: 'Windows' };
43
+ const archMap = { x64: 'x86_64', arm64: 'arm64' };
44
+ const goos = platMap[process.platform];
45
+ const goarch = archMap[process.arch];
46
+ if (!goos || !goarch) {
47
+ throw new Error(`Unsupported OS/arch combination: ${process.platform}/${process.arch}`);
48
+ }
49
+ const ext = goos === 'Windows' ? 'zip' : 'tar.gz';
50
+ const binName = goos === 'Windows' ? 'nomos.exe' : 'nomos';
51
+ const archive = `nomos_${goos}_${goarch}.${ext}`;
52
+ return { version, goos, goarch, ext, binName, archive };
53
+ }
54
+
55
+ function findExistingSystemBinary(selfPath, binName) {
56
+ if (process.env.NOMOS_SKIP_SYSTEM_PATH === '1') return null;
57
+ const dirs = String(process.env.PATH || '').split(path.delimiter).filter(Boolean);
58
+ for (const d of dirs) {
59
+ const candidate = path.join(d, binName);
60
+ try {
61
+ if (fs.existsSync(candidate) && fs.realpathSync(candidate) !== selfPath) {
62
+ fs.accessSync(candidate, fs.constants.X_OK);
63
+ return candidate;
64
+ }
65
+ } catch {
66
+ // Ignore unreadable PATH entries.
67
+ }
68
+ }
69
+ return null;
70
+ }
71
+
72
+ function parseExpectedSha256(checksumsText, archiveName) {
73
+ for (const line of String(checksumsText).split(/\r?\n/)) {
74
+ const trimmed = line.trim();
75
+ if (!trimmed) continue;
76
+ const parts = trimmed.split(/\s+/);
77
+ if (parts.length >= 2 && parts[1].replace(/^\*/, '') === archiveName) {
78
+ return parts[0].toLowerCase();
79
+ }
80
+ }
81
+ throw new Error(`Archive ${archiveName} not found in release checksums.txt`);
82
+ }
83
+
84
+ async function fetchReleaseBytes(url) {
85
+ const res = await fetch(url, { headers: { 'User-Agent': 'sophialabs-nomos-npx-launcher' } });
86
+ if (!res.ok) {
87
+ throw new Error(`Download failed (${res.status}) for ${url}`);
88
+ }
89
+ return Buffer.from(await res.arrayBuffer());
90
+ }
91
+
92
+ async function ensureCachedBinary(target) {
93
+ const releaseBase = `https://github.com/mgantlett/nomos/releases/download/v${target.version}`;
94
+ const cacheRoot = process.env.NOMOS_CACHE_DIR || path.join(os.homedir(), '.cache', 'nomos-launcher');
95
+ const verDir = path.join(cacheRoot, `v${target.version}-${target.goos}-${target.goarch}`);
96
+ const binPath = path.join(verDir, target.binName);
97
+ if (fs.existsSync(binPath)) return binPath;
98
+
99
+ fs.mkdirSync(verDir, { recursive: true });
100
+ const [checksumsBuf, archiveBuf] = await Promise.all([
101
+ fetchReleaseBytes(`${releaseBase}/checksums.txt`),
102
+ fetchReleaseBytes(`${releaseBase}/${target.archive}`)
103
+ ]);
104
+ const expectedHex = parseExpectedSha256(checksumsBuf.toString('utf8'), target.archive);
105
+ const actualHex = crypto.createHash('sha256').update(archiveBuf).digest('hex').toLowerCase();
106
+ if (actualHex !== expectedHex) {
107
+ throw new Error(`SHA-256 mismatch for ${target.archive}: expected ${expectedHex}, got ${actualHex}`);
108
+ }
109
+
110
+ const archivePath = path.join(verDir, target.archive);
111
+ fs.writeFileSync(archivePath, archiveBuf);
112
+ if (target.ext === 'tar.gz') {
113
+ execFileSync('tar', ['-xzf', archivePath, '-C', verDir, target.binName]);
114
+ } else {
115
+ execFileSync('tar', ['-xf', archivePath, '-C', verDir, target.binName]);
116
+ }
117
+ fs.unlinkSync(archivePath);
118
+ if (target.goos !== 'Windows') fs.chmodSync(binPath, 0o755);
119
+ return binPath;
120
+ }
121
+
122
+ async function main() {
123
+ const args = process.argv.slice(2);
124
+ if (args[0] === '--launcher-info') {
125
+ const target = resolveTargetPlatform(process.env.NOMOS_VERSION || FALLBACK_VERSION);
126
+ process.stdout.write(`${JSON.stringify(target)}\n`);
127
+ return;
128
+ }
129
+ const effectiveArgs = args.length === 0 && !process.stdin.isTTY ? ['mcp'] : args;
130
+ const selfReal = fs.realpathSync(fileURLToPath(import.meta.url));
131
+ const quickTarget = resolveTargetPlatform(FALLBACK_VERSION);
132
+ const systemBin = findExistingSystemBinary(selfReal, quickTarget.binName);
133
+ const bin = systemBin || (await ensureCachedBinary(resolveTargetPlatform(await resolveEffectiveVersion())));
134
+ const child = spawnSync(bin, effectiveArgs, { stdio: 'inherit' });
135
+ if (child.error) throw child.error;
136
+ process.exit(child.status ?? 0);
137
+ }
138
+
139
+ main().catch((err) => {
140
+ process.stderr.write(`[nomos-npx] ${err instanceof Error ? err.message : String(err)}\n`);
141
+ process.exit(1);
142
+ });
package/package.json CHANGED
@@ -1,6 +1,38 @@
1
1
  {
2
2
  "name": "@mgantlett/nomos",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "4.27.1",
4
+ "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).",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "bin": {
8
+ "nomos": "bin/nomos-cli.mjs"
9
+ },
10
+ "files": [
11
+ "bin/nomos-cli.mjs",
12
+ "README.md"
13
+ ],
14
+ "engines": {
15
+ "node": ">=18.0.0"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/mgantlett/nomos.git",
20
+ "directory": "packaging/npm"
21
+ },
22
+ "homepage": "https://sophialabs.ca/docs/introduction",
23
+ "keywords": [
24
+ "ai-agents",
25
+ "ast",
26
+ "claude-code",
27
+ "code-quality",
28
+ "cursor",
29
+ "git-hooks",
30
+ "git-worktree",
31
+ "guardrails",
32
+ "mcp",
33
+ "mcp-server",
34
+ "model-context-protocol",
35
+ "sarif"
36
+ ],
37
+ "mcpName": "io.github.mgantlett/nomos"
38
+ }