@asanabrial/estigia 0.0.0-stage → 0.1.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 +22 -2
- package/bin/estigia.js +177 -0
- package/package.json +44 -4
package/README.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @asanabrial/estigia
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The npm route to [Estigia](https://github.com/asanabrial/estigia), workflow authority for AI coding
|
|
4
|
+
agents.
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
npx -y @asanabrial/estigia setup --all
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
This package is an installer, not a copy of the program. On first run, and whenever the installed
|
|
11
|
+
version differs from this package's (or from `ESTIGIA_VERSION`), it does what the release installers do: it downloads the release
|
|
12
|
+
archive for your platform, verifies it against the `.sha256` published beside it, records the
|
|
13
|
+
candidate with `estigia __record-install`, and places the binary in `~/.local/bin` (on Windows
|
|
14
|
+
`%LOCALAPPDATA%\estigia\bin`; `ESTIGIA_INSTALL_DIR` moves it). Then it runs that binary with the
|
|
15
|
+
arguments it was given.
|
|
16
|
+
|
|
17
|
+
The binary lives at that stable path rather than in npm's cache because `estigia setup` writes its own
|
|
18
|
+
path into every agent's hooks; a path that moves with each version would leave the hooks pointing at
|
|
19
|
+
nothing after an upgrade.
|
|
20
|
+
|
|
21
|
+
`ESTIGIA_VERSION` takes a tag other than this package's, and `ESTIGIA_BASE_URL` a mirror serving the
|
|
22
|
+
same layout. Everything this script prints goes to stderr, so `npx -y @asanabrial/estigia mcp` is a
|
|
23
|
+
clean MCP server on stdout.
|
package/bin/estigia.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { createHash } = require("node:crypto");
|
|
5
|
+
const http = require("node:http");
|
|
6
|
+
const https = require("node:https");
|
|
7
|
+
const { spawnSync, execFileSync } = require("node:child_process");
|
|
8
|
+
const fs = require("node:fs");
|
|
9
|
+
const os = require("node:os");
|
|
10
|
+
const path = require("node:path");
|
|
11
|
+
|
|
12
|
+
const REPO = "asanabrial/estigia";
|
|
13
|
+
|
|
14
|
+
const TARGETS = {
|
|
15
|
+
"linux-x64": { triple: "x86_64-unknown-linux-gnu", archive: "tar.gz", exe: "estigia" },
|
|
16
|
+
"linux-arm64": { triple: "aarch64-unknown-linux-gnu", archive: "tar.gz", exe: "estigia" },
|
|
17
|
+
"darwin-x64": { triple: "x86_64-apple-darwin", archive: "tar.gz", exe: "estigia" },
|
|
18
|
+
"darwin-arm64": { triple: "aarch64-apple-darwin", archive: "tar.gz", exe: "estigia" },
|
|
19
|
+
"win32-x64": { triple: "x86_64-pc-windows-msvc", archive: "zip", exe: "estigia.exe" },
|
|
20
|
+
"win32-arm64": { triple: "aarch64-pc-windows-msvc", archive: "zip", exe: "estigia.exe" },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
class EstigiaError extends Error {}
|
|
24
|
+
|
|
25
|
+
function say(message) {
|
|
26
|
+
process.stderr.write(`estigia: ${message}\n`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function fail(message) {
|
|
30
|
+
throw new EstigiaError(message);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function resolveTarget() {
|
|
34
|
+
const key = `${process.platform}-${process.arch}`;
|
|
35
|
+
const target = TARGETS[key];
|
|
36
|
+
if (!target) {
|
|
37
|
+
fail(`no prebuilt Estigia for ${key}; build from source with 'cargo install estigia'`);
|
|
38
|
+
}
|
|
39
|
+
return target;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function installDirectory() {
|
|
43
|
+
if (process.env.ESTIGIA_INSTALL_DIR) {
|
|
44
|
+
return process.env.ESTIGIA_INSTALL_DIR;
|
|
45
|
+
}
|
|
46
|
+
if (process.platform === "win32") {
|
|
47
|
+
const local = process.env.LOCALAPPDATA || path.join(os.homedir(), "AppData", "Local");
|
|
48
|
+
return path.join(local, "estigia", "bin");
|
|
49
|
+
}
|
|
50
|
+
return path.join(os.homedir(), ".local", "bin");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function get(url, redirectsLeft = 5) {
|
|
54
|
+
const client = url.startsWith("http://") ? http : https;
|
|
55
|
+
return new Promise((resolve, reject) => {
|
|
56
|
+
const request = client.get(url, { headers: { "user-agent": "estigia-npm" } }, (response) => {
|
|
57
|
+
const status = response.statusCode || 0;
|
|
58
|
+
if (status >= 300 && status < 400 && response.headers.location) {
|
|
59
|
+
response.resume();
|
|
60
|
+
if (redirectsLeft === 0) {
|
|
61
|
+
reject(new Error(`too many redirects for ${url}`));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
resolve(get(new URL(response.headers.location, url).toString(), redirectsLeft - 1));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (status < 200 || status >= 300) {
|
|
68
|
+
response.resume();
|
|
69
|
+
reject(new Error(`${status} for ${url}`));
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const chunks = [];
|
|
73
|
+
response.on("data", (chunk) => chunks.push(chunk));
|
|
74
|
+
response.on("end", () => resolve(Buffer.concat(chunks)));
|
|
75
|
+
response.on("error", reject);
|
|
76
|
+
});
|
|
77
|
+
request.on("error", reject);
|
|
78
|
+
request.setTimeout(60_000, () => request.destroy(new Error(`timed out after 60s for ${url}`)));
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function installedVersion(binary) {
|
|
83
|
+
if (!fs.existsSync(binary)) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
const answer = spawnSync(binary, ["--version"], { encoding: "utf8" });
|
|
87
|
+
const match = /^estigia (\S+)/.exec(answer.stdout || "");
|
|
88
|
+
return match ? match[1] : null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function extract(archivePath, into) {
|
|
92
|
+
const tar =
|
|
93
|
+
process.platform === "win32"
|
|
94
|
+
? path.join(process.env.SystemRoot || "C:\\Windows", "System32", "tar.exe")
|
|
95
|
+
: "tar";
|
|
96
|
+
execFileSync(tar, ["-xf", archivePath, "-C", into], { stdio: ["ignore", "ignore", "inherit"] });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function install(tag, target, binary) {
|
|
100
|
+
const packageName = `estigia-${tag}-${target.triple}`;
|
|
101
|
+
const archiveName = `${packageName}.${target.archive}`;
|
|
102
|
+
const base = process.env.ESTIGIA_BASE_URL || `https://github.com/${REPO}/releases/download/${tag}`;
|
|
103
|
+
|
|
104
|
+
say(`installing ${tag} for ${target.triple} into ${path.dirname(binary)}`);
|
|
105
|
+
let archive;
|
|
106
|
+
try {
|
|
107
|
+
archive = await get(`${base}/${archiveName}`);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
fail(`no release archive at ${base}/${archiveName}: ${error.message}`);
|
|
110
|
+
}
|
|
111
|
+
let sum;
|
|
112
|
+
try {
|
|
113
|
+
sum = (await get(`${base}/${archiveName}.sha256`)).toString("utf8");
|
|
114
|
+
} catch (error) {
|
|
115
|
+
fail(`no checksum published for ${archiveName}; refusing to install unverified`);
|
|
116
|
+
}
|
|
117
|
+
const expected = sum.trim().split(/\s+/)[0];
|
|
118
|
+
if (!expected) {
|
|
119
|
+
fail(`${archiveName}.sha256 carries no checksum`);
|
|
120
|
+
}
|
|
121
|
+
const actual = createHash("sha256").update(archive).digest("hex");
|
|
122
|
+
if (actual !== expected) {
|
|
123
|
+
fail(`checksum mismatch for ${archiveName}: expected ${expected}, got ${actual}`);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const staging = fs.mkdtempSync(path.join(os.tmpdir(), "estigia-npm-"));
|
|
127
|
+
try {
|
|
128
|
+
const archivePath = path.join(staging, archiveName);
|
|
129
|
+
fs.writeFileSync(archivePath, archive);
|
|
130
|
+
extract(archivePath, staging);
|
|
131
|
+
const candidate = path.join(staging, packageName, target.exe);
|
|
132
|
+
if (!fs.existsSync(candidate)) {
|
|
133
|
+
fail(`${archiveName} did not contain ${packageName}/${target.exe}`);
|
|
134
|
+
}
|
|
135
|
+
fs.chmodSync(candidate, 0o755);
|
|
136
|
+
|
|
137
|
+
const recorded = spawnSync(candidate, ["__record-install"], {
|
|
138
|
+
stdio: ["ignore", process.stderr, process.stderr],
|
|
139
|
+
});
|
|
140
|
+
if (recorded.error) {
|
|
141
|
+
fail(`could not run the downloaded candidate: ${recorded.error.message}`);
|
|
142
|
+
}
|
|
143
|
+
if (recorded.status !== 0) {
|
|
144
|
+
fail("candidate lifecycle admission failed; refusing to replace the installed executable");
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
fs.mkdirSync(path.dirname(binary), { recursive: true });
|
|
148
|
+
const placed = `${binary}.${process.pid}.new`;
|
|
149
|
+
fs.copyFileSync(candidate, placed);
|
|
150
|
+
fs.chmodSync(placed, 0o755);
|
|
151
|
+
fs.renameSync(placed, binary);
|
|
152
|
+
} finally {
|
|
153
|
+
fs.rmSync(staging, { recursive: true, force: true });
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async function main() {
|
|
158
|
+
const target = resolveTarget();
|
|
159
|
+
const { version } = require("../package.json");
|
|
160
|
+
const tag = process.env.ESTIGIA_VERSION || `v${version}`;
|
|
161
|
+
const binary = path.join(installDirectory(), target.exe);
|
|
162
|
+
|
|
163
|
+
if (installedVersion(binary) !== tag.replace(/^v/, "")) {
|
|
164
|
+
await install(tag, target, binary);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
|
|
168
|
+
if (result.error) {
|
|
169
|
+
fail(`could not run ${binary}: ${result.error.message}`);
|
|
170
|
+
}
|
|
171
|
+
process.exitCode = result.signal || result.status === null ? 1 : result.status;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
main().catch((error) => {
|
|
175
|
+
say(error instanceof EstigiaError ? error.message : error.stack || error.message);
|
|
176
|
+
process.exitCode = 1;
|
|
177
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asanabrial/estigia",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"mcpName": "io.github.asanabrial/estigia",
|
|
5
|
+
"description": "Guardrails for AI coding agents (Claude Code, Codex, OpenCode, Pi): an MCP server and hooks that verify issue claims, bind reviews to exact commits and gate merges",
|
|
6
|
+
"bin": {
|
|
7
|
+
"estigia": "bin/estigia.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin/",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"mcp",
|
|
15
|
+
"model-context-protocol",
|
|
16
|
+
"claude-code",
|
|
17
|
+
"codex",
|
|
18
|
+
"opencode",
|
|
19
|
+
"ai-agents",
|
|
20
|
+
"guardrails",
|
|
21
|
+
"code-review"
|
|
22
|
+
],
|
|
23
|
+
"homepage": "https://github.com/asanabrial/estigia",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/asanabrial/estigia.git",
|
|
27
|
+
"directory": "npm"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/asanabrial/estigia/issues"
|
|
31
|
+
},
|
|
32
|
+
"author": "Alexis Sanabria Lopez",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=18"
|
|
36
|
+
},
|
|
37
|
+
"os": [
|
|
38
|
+
"linux",
|
|
39
|
+
"darwin",
|
|
40
|
+
"win32"
|
|
41
|
+
],
|
|
42
|
+
"cpu": [
|
|
43
|
+
"x64",
|
|
44
|
+
"arm64"
|
|
45
|
+
]
|
|
46
|
+
}
|