@nanocollective/roster 0.1.0-beta.29 → 0.1.0-beta.30

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/dist/cli.js CHANGED
@@ -8641,7 +8641,6 @@ var Snapshots = class {
8641
8641
  });
8642
8642
  addDirs(snap.dirs, path);
8643
8643
  if (commit2) snap.sha = commit2;
8644
- void this.kv.put(`blob:${sha}`, text2);
8645
8644
  }
8646
8645
  async load(gh, repo, pathsOnly, say) {
8647
8646
  say("checking for changes");
@@ -8697,16 +8696,20 @@ var Snapshots = class {
8697
8696
  }
8698
8697
  if (pathsOnly) return { ok: true, snap };
8699
8698
  const known = /* @__PURE__ */ new Map();
8700
- for (const [_path, e] of before?.files ?? []) known.set(e.sha, e);
8699
+ for (const [, e] of before?.files ?? []) if (e.text !== void 0) known.set(e.sha, e.text);
8701
8700
  const wanted = [...snap.files].filter(([path, e]) => isTextPath(path, e.size));
8702
- const missing2 = [];
8703
- await Promise.all(
8704
- wanted.map(async ([path, e]) => {
8705
- const held = known.get(e.sha)?.text ?? await this.kv.get(`blob:${e.sha}`);
8706
- if (held !== void 0) e.text = held;
8707
- else missing2.push([path, e]);
8708
- })
8709
- );
8701
+ for (const [, e] of wanted) e.text = known.get(e.sha);
8702
+ let missing2 = wanted.filter(([, e]) => e.text === void 0);
8703
+ const key2 = `bodies:${repo}@${sha}`;
8704
+ if (missing2.length) {
8705
+ const kept = await this.kv.get(key2);
8706
+ if (kept) {
8707
+ const bodies = JSON.parse(kept);
8708
+ for (const [, e] of missing2) e.text = bodies[e.sha];
8709
+ missing2 = missing2.filter(([, e]) => e.text === void 0);
8710
+ }
8711
+ }
8712
+ const fetched = missing2.length > 0;
8710
8713
  if (missing2.length > TARBALL_OVER) {
8711
8714
  say("downloading the repository");
8712
8715
  const tgz = await gh.request("GET", `repos/${repo}/tarball/${sha}`, {
@@ -8718,14 +8721,10 @@ var Snapshots = class {
8718
8721
  const e = snap.files.get(t.path);
8719
8722
  if (!e || !t.data) continue;
8720
8723
  const text2 = decode(t.data);
8721
- if (text2 === void 0) continue;
8722
- e.text = text2;
8723
- void this.kv.put(`blob:${e.sha}`, text2);
8724
- }
8725
- } else {
8726
- if (missing2.length) {
8727
- say(`fetching ${missing2.length} changed file${missing2.length === 1 ? "" : "s"}`);
8724
+ if (text2 !== void 0) e.text = text2;
8728
8725
  }
8726
+ } else if (missing2.length) {
8727
+ say(`fetching ${missing2.length} changed file${missing2.length === 1 ? "" : "s"}`);
8729
8728
  await pool2(missing2, 8, async ([, e]) => {
8730
8729
  const res = await gh.request("GET", `repos/${repo}/git/blobs/${e.sha}`, {
8731
8730
  accept: "application/vnd.github.raw",
@@ -8733,11 +8732,14 @@ var Snapshots = class {
8733
8732
  });
8734
8733
  if (!res.ok || !res.data) return;
8735
8734
  const text2 = decode(res.data);
8736
- if (text2 === void 0) return;
8737
- e.text = text2;
8738
- void this.kv.put(`blob:${e.sha}`, text2);
8735
+ if (text2 !== void 0) e.text = text2;
8739
8736
  });
8740
8737
  }
8738
+ if (fetched) {
8739
+ const bodies = {};
8740
+ for (const [, e] of wanted) if (e.text !== void 0) bodies[e.sha] = e.text;
8741
+ void this.kv.put(key2, JSON.stringify(bodies));
8742
+ }
8741
8743
  await this.dates(gh, repo, snap, say, before);
8742
8744
  return { ok: true, snap };
8743
8745
  }
@@ -5091,7 +5091,6 @@ var Snapshots = class {
5091
5091
  });
5092
5092
  addDirs(snap.dirs, path);
5093
5093
  if (commit2) snap.sha = commit2;
5094
- void this.kv.put(`blob:${sha}`, text2);
5095
5094
  }
5096
5095
  async load(gh, repo, pathsOnly, say) {
5097
5096
  say("checking for changes");
@@ -5147,16 +5146,20 @@ var Snapshots = class {
5147
5146
  }
5148
5147
  if (pathsOnly) return { ok: true, snap };
5149
5148
  const known = /* @__PURE__ */ new Map();
5150
- for (const [_path, e] of before?.files ?? []) known.set(e.sha, e);
5149
+ for (const [, e] of before?.files ?? []) if (e.text !== void 0) known.set(e.sha, e.text);
5151
5150
  const wanted = [...snap.files].filter(([path, e]) => isTextPath(path, e.size));
5152
- const missing2 = [];
5153
- await Promise.all(
5154
- wanted.map(async ([path, e]) => {
5155
- const held = known.get(e.sha)?.text ?? await this.kv.get(`blob:${e.sha}`);
5156
- if (held !== void 0) e.text = held;
5157
- else missing2.push([path, e]);
5158
- })
5159
- );
5151
+ for (const [, e] of wanted) e.text = known.get(e.sha);
5152
+ let missing2 = wanted.filter(([, e]) => e.text === void 0);
5153
+ const key3 = `bodies:${repo}@${sha}`;
5154
+ if (missing2.length) {
5155
+ const kept = await this.kv.get(key3);
5156
+ if (kept) {
5157
+ const bodies = JSON.parse(kept);
5158
+ for (const [, e] of missing2) e.text = bodies[e.sha];
5159
+ missing2 = missing2.filter(([, e]) => e.text === void 0);
5160
+ }
5161
+ }
5162
+ const fetched = missing2.length > 0;
5160
5163
  if (missing2.length > TARBALL_OVER) {
5161
5164
  say("downloading the repository");
5162
5165
  const tgz = await gh.request("GET", `repos/${repo}/tarball/${sha}`, {
@@ -5168,14 +5171,10 @@ var Snapshots = class {
5168
5171
  const e = snap.files.get(t.path);
5169
5172
  if (!e || !t.data) continue;
5170
5173
  const text2 = decode(t.data);
5171
- if (text2 === void 0) continue;
5172
- e.text = text2;
5173
- void this.kv.put(`blob:${e.sha}`, text2);
5174
- }
5175
- } else {
5176
- if (missing2.length) {
5177
- say(`fetching ${missing2.length} changed file${missing2.length === 1 ? "" : "s"}`);
5174
+ if (text2 !== void 0) e.text = text2;
5178
5175
  }
5176
+ } else if (missing2.length) {
5177
+ say(`fetching ${missing2.length} changed file${missing2.length === 1 ? "" : "s"}`);
5179
5178
  await pool2(missing2, 8, async ([, e]) => {
5180
5179
  const res = await gh.request("GET", `repos/${repo}/git/blobs/${e.sha}`, {
5181
5180
  accept: "application/vnd.github.raw",
@@ -5183,11 +5182,14 @@ var Snapshots = class {
5183
5182
  });
5184
5183
  if (!res.ok || !res.data) return;
5185
5184
  const text2 = decode(res.data);
5186
- if (text2 === void 0) return;
5187
- e.text = text2;
5188
- void this.kv.put(`blob:${e.sha}`, text2);
5185
+ if (text2 !== void 0) e.text = text2;
5189
5186
  });
5190
5187
  }
5188
+ if (fetched) {
5189
+ const bodies = {};
5190
+ for (const [, e] of wanted) if (e.text !== void 0) bodies[e.sha] = e.text;
5191
+ void this.kv.put(key3, JSON.stringify(bodies));
5192
+ }
5191
5193
  await this.dates(gh, repo, snap, say, before);
5192
5194
  return { ok: true, snap };
5193
5195
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nanocollective/roster",
3
- "version": "0.1.0-beta.29",
3
+ "version": "0.1.0-beta.30",
4
4
  "description": "An agent-run org, powered by GitHub. Scaffold AI staff members whose brain is a repo.",
5
5
  "type": "module",
6
6
  "bin": {