Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LDFLAGS := -X github.com/agentsdance/agentx/internal/version.Version=$(VERSION)

PREFIX ?= /usr/local

.PHONY: build install clean
.PHONY: build install clean release

build:
go build -ldflags "$(LDFLAGS)" -o agentx
Expand All @@ -19,3 +19,6 @@ install: build

clean:
rm -f agentx

release:
npm publish --access public
29 changes: 29 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@agentsdance/agentx",
"version": "0.0.8",
"version": "0.0.9",
"description": "AgentX CLI installer (downloads the native AgentX binary on install)",
"license": "MIT",
"bin": {
Expand All @@ -9,14 +9,12 @@
"files": [
"bin/",
"scripts/",
"vendor/",
"README.md",
"LICENSE"
],
"scripts": {
"postinstall": "node scripts/install.js"
},
"dependencies": {},
"engines": {
"node": ">=18"
},
Expand Down
15 changes: 14 additions & 1 deletion scripts/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const PKG_ROOT = path.resolve(__dirname, "..");
const BIN_DIR = path.join(PKG_ROOT, "vendor");
const BIN_NAME = os.platform() === "win32" ? "agentx.exe" : "agentx";
const BIN_PATH = path.join(BIN_DIR, BIN_NAME);
const VERSION_MARKER = path.join(BIN_DIR, ".agentx-version");

const VERSION = require(path.join(PKG_ROOT, "package.json")).version;
const REPO = "agentsdance/agentx";
Expand Down Expand Up @@ -148,7 +149,7 @@ async function main() {
const { filename, ext, osName, arch } = getAssetInfo();
await ensureDir(BIN_DIR);

if (fs.existsSync(BIN_PATH)) {
if (await isCurrentVersionInstalled()) {
return;
}

Expand All @@ -166,6 +167,7 @@ async function main() {
}
await promoteBinary(found);
await makeExecutable(BIN_PATH);
await fs.promises.writeFile(VERSION_MARKER, VERSION, "utf8");
}

async function resolveRelease(expectedFilename, osName, arch, ext) {
Expand Down Expand Up @@ -248,6 +250,17 @@ async function fetchJson(url, redirects = 0) {
});
}

async function isCurrentVersionInstalled() {
try {
const marker = await fs.promises.readFile(VERSION_MARKER, "utf8");
if (marker.trim() !== VERSION) return false;
await fs.promises.access(BIN_PATH, fs.constants.X_OK);
return true;
} catch (_) {
return false;
}
}

main().catch((err) => {
console.error(`AgentX install failed: ${err.message}`);
process.exit(1);
Expand Down