@chosengeneration/light-code 0.150.0 → 0.151.0

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/server.cjs CHANGED
@@ -74655,28 +74655,9 @@ async function writeWhole2(file2, bytes) {
74655
74655
  await import_promises25.default.writeFile(temp, bytes);
74656
74656
  await replaceFile(temp, file2);
74657
74657
  }
74658
- async function fromBucketUnchanged(dir) {
74659
- const out = /* @__PURE__ */ new Map();
74660
- try {
74661
- const manifest = JSON.parse(await import_promises25.default.readFile(import_node_path45.default.join(dir, ".lightcode-sync.json"), "utf8"));
74662
- for (const [key2, entry] of Object.entries(manifest))
74663
- if (typeof entry.size === "number")
74664
- out.set(key2, entry.size);
74665
- } catch {
74666
- }
74667
- return out;
74668
- }
74669
- function cameFromBucket(bucket, relative, size) {
74670
- for (const [key2, recorded] of bucket) {
74671
- if ((key2 === relative || key2.endsWith(`/${relative}`)) && recorded === size)
74672
- return true;
74673
- }
74674
- return false;
74675
- }
74676
74658
  async function localFiles(dir, kind) {
74677
74659
  if (dir === void 0)
74678
74660
  return [];
74679
- const bucket = await fromBucketUnchanged(dir);
74680
74661
  const out = [];
74681
74662
  const walk = async (folder, prefix) => {
74682
74663
  let entries;
@@ -74693,10 +74674,7 @@ async function localFiles(dir, kind) {
74693
74674
  if (kind === "skills")
74694
74675
  await walk(import_node_path45.default.join(folder, entry.name), relative);
74695
74676
  } else if (entry.isFile() && (kind === "skills" || entry.name.endsWith(".py"))) {
74696
- const file2 = import_node_path45.default.join(folder, entry.name);
74697
- if (bucket.size > 0 && cameFromBucket(bucket, relative, (await import_promises25.default.stat(file2)).size))
74698
- continue;
74699
- out.push({ relative, file: file2 });
74677
+ out.push({ relative, file: import_node_path45.default.join(folder, entry.name) });
74700
74678
  }
74701
74679
  }
74702
74680
  };
@@ -74743,16 +74721,30 @@ async function syncTeamRepo(options) {
74743
74721
  state.head = head;
74744
74722
  }
74745
74723
  if (options.push !== false) {
74746
- const locals = [
74747
- ...(await localFiles(options.local.skills, "skills")).map((entry) => ({ ...entry, kind: "skills" })),
74748
- ...(await localFiles(options.local.tools, "tools")).map((entry) => ({ ...entry, kind: "tools" }))
74749
- ];
74724
+ const locals = [];
74725
+ for (const kind of ["skills", "tools"]) {
74726
+ for (const dir of new Set(options.local[kind].filter((entry) => entry !== void 0).map((entry) => import_node_path45.default.resolve(entry)))) {
74727
+ locals.push(...(await localFiles(dir, kind)).map((entry) => ({ ...entry, kind })));
74728
+ }
74729
+ }
74750
74730
  const present2 = /* @__PURE__ */ new Set();
74731
+ const chosen = /* @__PURE__ */ new Map();
74751
74732
  for (const entry of locals) {
74752
74733
  const repoPath = repoPathFor(folder, entry.kind, entry.relative);
74753
74734
  present2.add(repoPath);
74754
74735
  const bytes = new Uint8Array(await import_promises25.default.readFile(entry.file));
74755
74736
  const mine = hash2(bytes);
74737
+ const earlier = chosen.get(repoPath);
74738
+ if (earlier !== void 0) {
74739
+ if (earlier.hash !== mine) {
74740
+ report.conflicts.push({
74741
+ path: repoPath,
74742
+ reason: `two different copies on this machine (${earlier.file} and ${entry.file}) - the first, which Light Code uses, is the one synced`
74743
+ });
74744
+ }
74745
+ continue;
74746
+ }
74747
+ chosen.set(repoPath, { hash: mine, file: entry.file });
74756
74748
  const known = state.files[repoPath];
74757
74749
  if (known?.hash === mine) {
74758
74750
  state.pushed[repoPath] = mine;
@@ -74801,6 +74793,15 @@ async function syncTeamRepo(options) {
74801
74793
  report.pushed.push(repoPath);
74802
74794
  } catch (error51) {
74803
74795
  const status2 = error51.status;
74796
+ if (status2 === 409) {
74797
+ const now = await api.branchHead(branch).catch(() => void 0);
74798
+ const remote = now !== void 0 ? await api.readBytes(repoPath, now).catch(() => void 0) : void 0;
74799
+ if (now !== void 0 && remote !== void 0 && hash2(remote) === mine) {
74800
+ state.files[repoPath] = { commit: now, hash: mine };
74801
+ state.pushed[repoPath] = mine;
74802
+ continue;
74803
+ }
74804
+ }
74804
74805
  report.conflicts.push({
74805
74806
  path: repoPath,
74806
74807
  reason: status2 === 409 ? "changed in the repository since the last sync - not overwritten; the next sync brings theirs into the team copy" : `not committed: ${error51 instanceof Error ? error51.message : String(error51)}`
@@ -84178,8 +84179,12 @@ ${redact(shown2, cachedSecretValues)}` }
84178
84179
  api,
84179
84180
  branch: plan2.settings.branch,
84180
84181
  folder: plan2.settings.folder,
84181
- // This person's own folders: where skills and tools are written here.
84182
- local: { skills: skillsDir, tools: pythonFolders(config2).toolsDir ?? localToolsDir(config2) },
84182
+ // Every folder skills and tools load from here, in the order they win a name: the save folder,
84183
+ // the project's own folder, and S3 bucket folders - never the team copy itself.
84184
+ local: {
84185
+ skills: [skillsDir, localSkillsDir, ...mirroredSkillsDirs].filter((dir) => !samePath(dir, plan2.dirs.skills)),
84186
+ tools: [pythonFolders(config2).toolsDir, localToolsDir(config2), ...mirroredToolsDirs].filter((dir) => !samePath(dir, plan2.dirs.tools))
84187
+ },
84183
84188
  mirror: plan2.dirs,
84184
84189
  stateFile: plan2.stateFile,
84185
84190
  author: cachedAttribution.author ?? "someone"
@@ -90953,9 +90958,13 @@ listed as not synced, on the panel and in Settings \u2192 Usage \u2192 Needs att
90953
90958
  refuses because someone committed first is the same. A skill or tool you **delete** stays in the
90954
90959
  repository until somebody removes it there - the panel lists them.
90955
90960
 
90956
- **With S3 buckets too.** Only files in your own folders are committed - never a copy synced in from a
90957
- bucket, never the repository's own copy - so the two syncs cannot bounce files between each other. A
90958
- skill identical in two folders is one skill, silently.
90961
+ **With S3 buckets too.** Everything skills and tools load from is committed - the folder new ones are
90962
+ saved in, the project's .lightcode folders, **and the S3 bucket folders** - so a team that keeps its
90963
+ skills and tools in a bucket gets all of them in the repository. Never the repository's own copy, so the
90964
+ two syncs cannot bounce files between them. Two colleagues committing the same bucket file meet as
90965
+ identical content, which is agreement, not a conflict; an edit someone makes in the bucket is committed
90966
+ by the next sync. The same name in two folders here is one file when identical; when the copies differ,
90967
+ the one Light Code uses is committed and the other is listed.
90959
90968
 
90960
90969
  Problems from syncing in the background (the repository, buckets, tools that did not load) show in
90961
90970
  **Settings \u2192 Usage \u2192 Needs attention**.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chosengeneration/light-code",
3
- "version": "0.150.0",
3
+ "version": "0.151.0",
4
4
  "description": "A minimal agentic coding assistant, served to your browser from a local Node server",
5
5
  "license": "MIT",
6
6
  "type": "module",