@nano-step/nano-brain 2026.6.8 → 2026.6.102

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.
@@ -55,6 +55,58 @@ function download(url, dest) {
55
55
  });
56
56
  }
57
57
 
58
+ // npm normalizes leading zeros in semver numeric identifiers (e.g. tag
59
+ // v2026.6.0101 publishes as 2026.6.101). Auto-tag uses a fixed-width 4-digit
60
+ // patch {DD}{NN} for new tags, but older history has 1-3 digit patches. Try
61
+ // the canonical form first, then a zero-padded reconstruction, then API.
62
+ function candidateTagsForVersion(version) {
63
+ const parts = version.split(".");
64
+ const candidates = [`v${version}`];
65
+ if (parts.length === 3) {
66
+ const patch = parts[2];
67
+ if (/^\d+$/.test(patch) && patch.length < 4) {
68
+ const padded = patch.padStart(4, "0");
69
+ candidates.push(`v${parts[0]}.${parts[1]}.${padded}`);
70
+ }
71
+ }
72
+ return candidates;
73
+ }
74
+
75
+ function normalizeVersion(v) {
76
+ return v.replace(/^v/, "").split(".").map((p) => p.replace(/^0+/, "") || "0").join(".");
77
+ }
78
+
79
+ function httpGetJSON(url) {
80
+ return new Promise((resolve, reject) => {
81
+ https.get(url, { headers: { "User-Agent": "nano-brain-postinstall" } }, (res) => {
82
+ if (res.statusCode !== 200) {
83
+ res.resume();
84
+ return reject(new Error(`API ${url} returned HTTP ${res.statusCode}`));
85
+ }
86
+ let body = "";
87
+ res.on("data", (chunk) => { body += chunk; });
88
+ res.on("end", () => {
89
+ try { resolve(JSON.parse(body)); } catch (e) { reject(e); }
90
+ });
91
+ }).on("error", reject);
92
+ });
93
+ }
94
+
95
+ async function resolveTagFromAPI(version, assetName) {
96
+ const api = `https://api.github.com/repos/${REPO}/releases`;
97
+ const releases = await httpGetJSON(`${api}?per_page=30`);
98
+ const normalizedTarget = normalizeVersion(version);
99
+ for (const r of releases) {
100
+ if (!r.tag_name) continue;
101
+ if (normalizeVersion(r.tag_name) === normalizedTarget) {
102
+ if (r.assets && r.assets.some((a) => a.name === assetName)) {
103
+ return r.tag_name;
104
+ }
105
+ }
106
+ }
107
+ return null;
108
+ }
109
+
58
110
  async function main() {
59
111
  const platformKey = getPlatformKey();
60
112
  const binName = os.platform() === "win32" ? "nano-brain.exe" : "nano-brain";
@@ -72,18 +124,38 @@ async function main() {
72
124
  }
73
125
  }
74
126
 
75
- const url = `https://github.com/${REPO}/releases/download/v${VERSION}/nano-brain-${platformKey}`;
76
127
  console.log(`Downloading nano-brain v${VERSION} for ${platformKey}...`);
77
128
 
129
+ const assetName = `nano-brain-${platformKey}`;
130
+ let lastErr;
131
+ for (const tag of candidateTagsForVersion(VERSION)) {
132
+ const url = `https://github.com/${REPO}/releases/download/${tag}/${assetName}`;
133
+ try {
134
+ await download(url, binPath);
135
+ fs.chmodSync(binPath, 0o755);
136
+ console.log(`nano-brain v${VERSION} installed successfully from ${tag}.`);
137
+ return;
138
+ } catch (err) {
139
+ lastErr = err;
140
+ }
141
+ }
142
+
78
143
  try {
79
- await download(url, binPath);
80
- fs.chmodSync(binPath, 0o755);
81
- console.log(`nano-brain v${VERSION} installed successfully.`);
144
+ const tag = await resolveTagFromAPI(VERSION, assetName);
145
+ if (tag) {
146
+ const url = `https://github.com/${REPO}/releases/download/${tag}/${assetName}`;
147
+ await download(url, binPath);
148
+ fs.chmodSync(binPath, 0o755);
149
+ console.log(`nano-brain v${VERSION} installed successfully from ${tag} (API fallback).`);
150
+ return;
151
+ }
82
152
  } catch (err) {
83
- console.error(`Failed to download binary: ${err.message}`);
84
- console.error("Build from source: CGO_ENABLED=0 go build -o npm/nano-brain ./cmd/nano-brain");
85
- process.exit(0);
153
+ lastErr = err;
86
154
  }
155
+
156
+ console.error(`Failed to download binary: ${lastErr && lastErr.message}`);
157
+ console.error("Build from source: CGO_ENABLED=0 go build -o npm/nano-brain ./cmd/nano-brain");
158
+ process.exit(0);
87
159
  }
88
160
 
89
161
  main();
package/npm/run.js CHANGED
@@ -10,7 +10,9 @@ const binName = os.platform() === "win32" ? "nano-brain.exe" : "nano-brain";
10
10
  const binPath = path.join(__dirname, binName);
11
11
 
12
12
  if (!fs.existsSync(binPath)) {
13
- console.error("nano-brain binary not found. Run: npx nano-brain (it will download automatically)");
13
+ console.error("nano-brain binary not found at " + binPath + ".");
14
+ console.error("The postinstall script may have failed during npm install.");
15
+ console.error("Try: npm install -g @nano-step/nano-brain --foreground-scripts");
14
16
  console.error("Or build from source: CGO_ENABLED=0 go build -o npm/nano-brain ./cmd/nano-brain");
15
17
  process.exit(1);
16
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nano-step/nano-brain",
3
- "version": "2026.6.8",
3
+ "version": "2026.6.102",
4
4
  "description": "Persistent memory and code intelligence for AI coding agents",
5
5
  "bin": {
6
6
  "nano-brain": "npm/run.js"