attention-matters 0.0.1 → 0.1.2

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/bin/am ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+
3
+ "use strict";
4
+
5
+ const { execFileSync } = require("child_process");
6
+ const path = require("path");
7
+ const fs = require("fs");
8
+
9
+ const binPath = path.join(__dirname, "am");
10
+ const nativeBin = binPath + (process.platform === "win32" ? ".exe" : "");
11
+
12
+ // Check for the downloaded native binary next to this script
13
+ // The install.js postinstall script extracts it here
14
+ const candidates = [
15
+ nativeBin,
16
+ // Fallback: maybe it's on PATH (cargo install, brew, etc.)
17
+ "am",
18
+ ];
19
+
20
+ for (const candidate of candidates) {
21
+ try {
22
+ if (candidate === "am" || fs.existsSync(candidate)) {
23
+ execFileSync(candidate, process.argv.slice(2), { stdio: "inherit" });
24
+ process.exit(0);
25
+ }
26
+ } catch (err) {
27
+ if (err.status !== undefined) {
28
+ process.exit(err.status);
29
+ }
30
+ // Try next candidate
31
+ }
32
+ }
33
+
34
+ console.error(
35
+ "attention-matters: native binary not found.\n\n" +
36
+ "The postinstall script may have failed. Install manually:\n" +
37
+ " cargo install am-cli\n" +
38
+ " brew install srobinson/tap/am\n"
39
+ );
40
+ process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attention-matters",
3
- "version": "0.0.1",
3
+ "version": "0.1.2",
4
4
  "description": "Geometric memory for AI coding agents. No embeddings, no vectors, no cloud — just math.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -15,7 +15,8 @@
15
15
  "claude",
16
16
  "agent",
17
17
  "geometric-memory",
18
- "quaternion"
18
+ "quaternion",
19
+ "mcp-server"
19
20
  ],
20
21
  "bin": {
21
22
  "am": "bin/am"
@@ -24,7 +25,7 @@
24
25
  "postinstall": "node scripts/install.js"
25
26
  },
26
27
  "files": [
27
- "bin",
28
- "scripts"
28
+ "bin/am",
29
+ "scripts/install.js"
29
30
  ]
30
31
  }
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env node
2
+
3
+ "use strict";
4
+
5
+ const { execSync } = require("child_process");
6
+ const fs = require("fs");
7
+ const path = require("path");
8
+ const https = require("https");
9
+ const http = require("http");
10
+
11
+ const REPO = "srobinson/attention-matters";
12
+ const BIN_NAME = "am";
13
+
14
+ const PLATFORM_MAP = {
15
+ "darwin-arm64": "aarch64-apple-darwin",
16
+ "darwin-x64": "x86_64-apple-darwin",
17
+ "linux-arm64": "aarch64-unknown-linux-gnu",
18
+ "linux-x64": "x86_64-unknown-linux-gnu",
19
+ };
20
+
21
+ function getPlatformKey() {
22
+ const platform = process.platform;
23
+ const arch = process.arch;
24
+ return `${platform}-${arch}`;
25
+ }
26
+
27
+ function getTarget() {
28
+ const key = getPlatformKey();
29
+ const target = PLATFORM_MAP[key];
30
+ if (!target) {
31
+ console.error(
32
+ `Unsupported platform: ${key}\n` +
33
+ `Supported: ${Object.keys(PLATFORM_MAP).join(", ")}`
34
+ );
35
+ process.exit(1);
36
+ }
37
+ return target;
38
+ }
39
+
40
+ function getVersion() {
41
+ const pkg = JSON.parse(
42
+ fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf8")
43
+ );
44
+ return pkg.version;
45
+ }
46
+
47
+ function fetch(url) {
48
+ return new Promise((resolve, reject) => {
49
+ const mod = url.startsWith("https") ? https : http;
50
+ mod
51
+ .get(url, { headers: { "User-Agent": "attention-matters-installer" } }, (res) => {
52
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
53
+ return fetch(res.headers.location).then(resolve, reject);
54
+ }
55
+ if (res.statusCode !== 200) {
56
+ return reject(new Error(`HTTP ${res.statusCode} for ${url}`));
57
+ }
58
+ const chunks = [];
59
+ res.on("data", (chunk) => chunks.push(chunk));
60
+ res.on("end", () => resolve(Buffer.concat(chunks)));
61
+ res.on("error", reject);
62
+ })
63
+ .on("error", reject);
64
+ });
65
+ }
66
+
67
+ async function install() {
68
+ const target = getTarget();
69
+ const version = getVersion();
70
+ const artifact = `am-${target}.tar.gz`;
71
+ const url = `https://github.com/${REPO}/releases/download/v${version}/${artifact}`;
72
+
73
+ const binDir = path.join(__dirname, "..", "bin");
74
+ fs.mkdirSync(binDir, { recursive: true });
75
+
76
+ const binPath = path.join(binDir, BIN_NAME);
77
+
78
+ // Skip download if binary already exists (e.g. CI caching)
79
+ if (fs.existsSync(binPath)) {
80
+ return;
81
+ }
82
+
83
+ console.log(`Downloading ${BIN_NAME} v${version} for ${target}...`);
84
+
85
+ try {
86
+ const tarball = await fetch(url);
87
+
88
+ // Write tarball to temp file, extract with tar
89
+ const tmpTar = path.join(binDir, `${BIN_NAME}.tar.gz`);
90
+ fs.writeFileSync(tmpTar, tarball);
91
+ execSync(`tar xzf "${tmpTar}" -C "${binDir}"`, { stdio: "pipe" });
92
+ fs.unlinkSync(tmpTar);
93
+
94
+ // Ensure the binary is executable
95
+ fs.chmodSync(binPath, 0o755);
96
+
97
+ console.log(`Installed ${BIN_NAME} v${version} to ${binPath}`);
98
+ } catch (err) {
99
+ console.error(
100
+ `Failed to download ${BIN_NAME} v${version} for ${target}:\n` +
101
+ ` ${err.message}\n\n` +
102
+ `You can install manually:\n` +
103
+ ` cargo install am-cli\n` +
104
+ ` brew install srobinson/tap/am`
105
+ );
106
+ // Don't fail the install — the bin wrapper will show a helpful error
107
+ }
108
+ }
109
+
110
+ install();