@chosengeneration/light-code 0.150.0 → 0.153.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/cli.cjs +262 -68
- package/dist/server.cjs +259 -65
- package/package.json +1 -1
package/dist/server.cjs
CHANGED
|
@@ -13963,11 +13963,11 @@ var require_util4 = __commonJS({
|
|
|
13963
13963
|
dataURL += serializeAMimeType(parsed);
|
|
13964
13964
|
}
|
|
13965
13965
|
dataURL += ";base64,";
|
|
13966
|
-
const
|
|
13966
|
+
const decoder2 = new StringDecoder2("latin1");
|
|
13967
13967
|
for (const chunk of bytes) {
|
|
13968
|
-
dataURL += btoa2(
|
|
13968
|
+
dataURL += btoa2(decoder2.write(chunk));
|
|
13969
13969
|
}
|
|
13970
|
-
dataURL += btoa2(
|
|
13970
|
+
dataURL += btoa2(decoder2.end());
|
|
13971
13971
|
return dataURL;
|
|
13972
13972
|
}
|
|
13973
13973
|
case "Text": {
|
|
@@ -13992,11 +13992,11 @@ var require_util4 = __commonJS({
|
|
|
13992
13992
|
}
|
|
13993
13993
|
case "BinaryString": {
|
|
13994
13994
|
let binaryString = "";
|
|
13995
|
-
const
|
|
13995
|
+
const decoder2 = new StringDecoder2("latin1");
|
|
13996
13996
|
for (const chunk of bytes) {
|
|
13997
|
-
binaryString +=
|
|
13997
|
+
binaryString += decoder2.write(chunk);
|
|
13998
13998
|
}
|
|
13999
|
-
binaryString +=
|
|
13999
|
+
binaryString += decoder2.end();
|
|
14000
14000
|
return binaryString;
|
|
14001
14001
|
}
|
|
14002
14002
|
}
|
|
@@ -43275,7 +43275,7 @@ function* completedToolCalls(accumulators) {
|
|
|
43275
43275
|
}
|
|
43276
43276
|
async function* parseSseStream(body, url2, signal, logger) {
|
|
43277
43277
|
const reader = body.getReader();
|
|
43278
|
-
const
|
|
43278
|
+
const decoder2 = new TextDecoder();
|
|
43279
43279
|
let buffer = "";
|
|
43280
43280
|
const thinking = new ThinkTagSplitter();
|
|
43281
43281
|
const toolCallAccumulators = /* @__PURE__ */ new Map();
|
|
@@ -43284,7 +43284,7 @@ async function* parseSseStream(body, url2, signal, logger) {
|
|
|
43284
43284
|
const { done, value } = await reader.read();
|
|
43285
43285
|
if (done)
|
|
43286
43286
|
break;
|
|
43287
|
-
buffer +=
|
|
43287
|
+
buffer += decoder2.decode(value, { stream: true });
|
|
43288
43288
|
const lines2 = buffer.split("\n");
|
|
43289
43289
|
buffer = lines2.pop() ?? "";
|
|
43290
43290
|
for (const line of lines2) {
|
|
@@ -43483,7 +43483,7 @@ function safeParseArguments(raw) {
|
|
|
43483
43483
|
}
|
|
43484
43484
|
async function* parseAnthropicStream(body, url2, signal, logger) {
|
|
43485
43485
|
const reader = body.getReader();
|
|
43486
|
-
const
|
|
43486
|
+
const decoder2 = new TextDecoder();
|
|
43487
43487
|
let buffer = "";
|
|
43488
43488
|
const toolUses = /* @__PURE__ */ new Map();
|
|
43489
43489
|
const completed = [];
|
|
@@ -43492,7 +43492,7 @@ async function* parseAnthropicStream(body, url2, signal, logger) {
|
|
|
43492
43492
|
const { done, value } = await reader.read();
|
|
43493
43493
|
if (done)
|
|
43494
43494
|
break;
|
|
43495
|
-
buffer +=
|
|
43495
|
+
buffer += decoder2.decode(value, { stream: true });
|
|
43496
43496
|
const lines2 = buffer.split("\n");
|
|
43497
43497
|
buffer = lines2.pop() ?? "";
|
|
43498
43498
|
for (const line of lines2) {
|
|
@@ -43722,7 +43722,7 @@ function safeParseArguments2(raw) {
|
|
|
43722
43722
|
}
|
|
43723
43723
|
async function* parseGeminiStream(body, url2, signal) {
|
|
43724
43724
|
const reader = body.getReader();
|
|
43725
|
-
const
|
|
43725
|
+
const decoder2 = new TextDecoder();
|
|
43726
43726
|
let buffer = "";
|
|
43727
43727
|
const toolCalls = [];
|
|
43728
43728
|
try {
|
|
@@ -43730,7 +43730,7 @@ async function* parseGeminiStream(body, url2, signal) {
|
|
|
43730
43730
|
const { done, value } = await reader.read();
|
|
43731
43731
|
if (done)
|
|
43732
43732
|
break;
|
|
43733
|
-
buffer +=
|
|
43733
|
+
buffer += decoder2.decode(value, { stream: true });
|
|
43734
43734
|
const lines2 = buffer.split("\n");
|
|
43735
43735
|
buffer = lines2.pop() ?? "";
|
|
43736
43736
|
for (const line of lines2) {
|
|
@@ -52689,8 +52689,8 @@ async function readTail(fs42, path62, size, count3) {
|
|
|
52689
52689
|
let start;
|
|
52690
52690
|
for (; ; ) {
|
|
52691
52691
|
start = Math.max(0, size - span);
|
|
52692
|
-
const
|
|
52693
|
-
text2 =
|
|
52692
|
+
const decoder2 = new import_node_string_decoder.StringDecoder("utf8");
|
|
52693
|
+
text2 = decoder2.write(await fs42.readBytesSlice(path62, start, size)) + decoder2.end();
|
|
52694
52694
|
const enough = text2.split("\n").length > count3;
|
|
52695
52695
|
if (enough || start === 0 || span >= size)
|
|
52696
52696
|
break;
|
|
@@ -52709,7 +52709,7 @@ async function readTail(fs42, path62, size, count3) {
|
|
|
52709
52709
|
};
|
|
52710
52710
|
}
|
|
52711
52711
|
async function readLineWindow(fs42, path62, size, from, count3) {
|
|
52712
|
-
const
|
|
52712
|
+
const decoder2 = new import_node_string_decoder.StringDecoder("utf8");
|
|
52713
52713
|
const lines2 = [];
|
|
52714
52714
|
let pending = "";
|
|
52715
52715
|
let lineNumber = 1;
|
|
@@ -52723,7 +52723,7 @@ async function readLineWindow(fs42, path62, size, from, count3) {
|
|
|
52723
52723
|
};
|
|
52724
52724
|
scan: while (position < size) {
|
|
52725
52725
|
const end = Math.min(size, position + CHUNK);
|
|
52726
|
-
pending +=
|
|
52726
|
+
pending += decoder2.write(await fs42.readBytesSlice(path62, position, end));
|
|
52727
52727
|
position = end;
|
|
52728
52728
|
const parts = pending.split(/\r\n|\r|\n/);
|
|
52729
52729
|
pending = parts.pop() ?? "";
|
|
@@ -52735,7 +52735,7 @@ async function readLineWindow(fs42, path62, size, from, count3) {
|
|
|
52735
52735
|
}
|
|
52736
52736
|
}
|
|
52737
52737
|
if (reachedEnd) {
|
|
52738
|
-
pending +=
|
|
52738
|
+
pending += decoder2.end();
|
|
52739
52739
|
if (pending.length > 0)
|
|
52740
52740
|
take(pending);
|
|
52741
52741
|
}
|
|
@@ -57137,11 +57137,11 @@ var EventSource = class extends EventTarget {
|
|
|
57137
57137
|
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Invalid response body, expected a web ReadableStream", status2), this.close();
|
|
57138
57138
|
return;
|
|
57139
57139
|
}
|
|
57140
|
-
const
|
|
57140
|
+
const decoder2 = new TextDecoder(), reader = body.getReader();
|
|
57141
57141
|
let open = true;
|
|
57142
57142
|
do {
|
|
57143
57143
|
const { done, value } = await reader.read();
|
|
57144
|
-
value && __privateGet(this, _parser).feed(
|
|
57144
|
+
value && __privateGet(this, _parser).feed(decoder2.decode(value, { stream: !done })), done && (open = false, __privateGet(this, _parser).reset(), __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this));
|
|
57145
57145
|
} while (open);
|
|
57146
57146
|
}), __privateAdd(this, _onFetchError, (err) => {
|
|
57147
57147
|
__privateSet(this, _controller, void 0), !(err.name === "AbortError" || err.type === "aborted") && __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this, flattenError2(err));
|
|
@@ -72708,7 +72708,7 @@ ${text2.slice(-2e4)}`);
|
|
|
72708
72708
|
const text2 = await response.text();
|
|
72709
72709
|
return { text: text2.slice(-options.tailBytes), totalBytes: text2.length, truncated: text2.length > options.tailBytes };
|
|
72710
72710
|
}
|
|
72711
|
-
const
|
|
72711
|
+
const decoder2 = new TextDecoder();
|
|
72712
72712
|
let totalBytes = 0;
|
|
72713
72713
|
let tail = "";
|
|
72714
72714
|
let partial2 = "";
|
|
@@ -72748,7 +72748,7 @@ ${text2.slice(-2e4)}`);
|
|
|
72748
72748
|
if (done)
|
|
72749
72749
|
break;
|
|
72750
72750
|
totalBytes += value.byteLength;
|
|
72751
|
-
const chunk =
|
|
72751
|
+
const chunk = decoder2.decode(value, { stream: true });
|
|
72752
72752
|
if (options.pattern === void 0) {
|
|
72753
72753
|
tail = (tail + chunk).slice(-options.tailBytes);
|
|
72754
72754
|
} else {
|
|
@@ -74620,7 +74620,23 @@ var import_node_crypto15 = require("node:crypto");
|
|
|
74620
74620
|
var import_promises25 = __toESM(require("node:fs/promises"), 1);
|
|
74621
74621
|
var import_node_path45 = __toESM(require("node:path"), 1);
|
|
74622
74622
|
var TEAM_REPO_STATE_FILE = ".lightcode-teamrepo.json";
|
|
74623
|
-
var
|
|
74623
|
+
var decoder = new TextDecoder("utf-8", { fatal: true });
|
|
74624
|
+
function contentHash(bytes) {
|
|
74625
|
+
let text2;
|
|
74626
|
+
if (!bytes.includes(0)) {
|
|
74627
|
+
try {
|
|
74628
|
+
text2 = decoder.decode(bytes);
|
|
74629
|
+
} catch {
|
|
74630
|
+
text2 = void 0;
|
|
74631
|
+
}
|
|
74632
|
+
}
|
|
74633
|
+
const digest = (0, import_node_crypto15.createHash)("sha256");
|
|
74634
|
+
if (text2 === void 0)
|
|
74635
|
+
return digest.update(bytes).digest("hex");
|
|
74636
|
+
return digest.update(text2.replace(/^\uFEFF/, "").replace(/\r\n?/g, "\n").replace(/\s+$/, "")).digest("hex");
|
|
74637
|
+
}
|
|
74638
|
+
var hash2 = contentHash;
|
|
74639
|
+
var rawHash = (bytes) => (0, import_node_crypto15.createHash)("sha256").update(bytes).digest("hex");
|
|
74624
74640
|
function repoPathFor(folder, kind, relative) {
|
|
74625
74641
|
const base = folder.replace(/\\/g, "/").replace(/^\/+|\/+$/g, "");
|
|
74626
74642
|
return [base, kind, relative.replace(/\\/g, "/")].filter((part) => part.length > 0).join("/");
|
|
@@ -74640,14 +74656,31 @@ function classifyRepoPath(folder, repoPath) {
|
|
|
74640
74656
|
}
|
|
74641
74657
|
return void 0;
|
|
74642
74658
|
}
|
|
74643
|
-
async function readState(file2) {
|
|
74659
|
+
async function readState(file2, mirrorFile) {
|
|
74644
74660
|
try {
|
|
74645
74661
|
const parsed = JSON.parse(await import_promises25.default.readFile(file2, "utf8"));
|
|
74646
|
-
|
|
74647
|
-
|
|
74662
|
+
const head = parsed.head !== void 0 ? { head: parsed.head } : {};
|
|
74663
|
+
if (parsed.version === 2)
|
|
74664
|
+
return { version: 2, files: parsed.files ?? {}, pushed: parsed.pushed ?? {}, ...head };
|
|
74665
|
+
if (parsed.version === 1) {
|
|
74666
|
+
const files = {};
|
|
74667
|
+
const pushed = {};
|
|
74668
|
+
for (const [repoPath, entry] of Object.entries(parsed.files ?? {})) {
|
|
74669
|
+
const local = mirrorFile(repoPath);
|
|
74670
|
+
if (local === void 0)
|
|
74671
|
+
continue;
|
|
74672
|
+
const bytes = await import_promises25.default.readFile(local).catch(() => void 0);
|
|
74673
|
+
if (bytes === void 0 || rawHash(bytes) !== entry.hash)
|
|
74674
|
+
continue;
|
|
74675
|
+
files[repoPath] = { commit: entry.commit, hash: contentHash(bytes) };
|
|
74676
|
+
if (parsed.pushed?.[repoPath] === entry.hash)
|
|
74677
|
+
pushed[repoPath] = contentHash(bytes);
|
|
74678
|
+
}
|
|
74679
|
+
return { version: 2, files, pushed, ...head };
|
|
74680
|
+
}
|
|
74648
74681
|
} catch {
|
|
74649
74682
|
}
|
|
74650
|
-
return { version:
|
|
74683
|
+
return { version: 2, files: {}, pushed: {} };
|
|
74651
74684
|
}
|
|
74652
74685
|
async function writeWhole2(file2, bytes) {
|
|
74653
74686
|
await import_promises25.default.mkdir(import_node_path45.default.dirname(file2), { recursive: true });
|
|
@@ -74655,28 +74688,9 @@ async function writeWhole2(file2, bytes) {
|
|
|
74655
74688
|
await import_promises25.default.writeFile(temp, bytes);
|
|
74656
74689
|
await replaceFile(temp, file2);
|
|
74657
74690
|
}
|
|
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
74691
|
async function localFiles(dir, kind) {
|
|
74677
74692
|
if (dir === void 0)
|
|
74678
74693
|
return [];
|
|
74679
|
-
const bucket = await fromBucketUnchanged(dir);
|
|
74680
74694
|
const out = [];
|
|
74681
74695
|
const walk = async (folder, prefix) => {
|
|
74682
74696
|
let entries;
|
|
@@ -74693,10 +74707,7 @@ async function localFiles(dir, kind) {
|
|
|
74693
74707
|
if (kind === "skills")
|
|
74694
74708
|
await walk(import_node_path45.default.join(folder, entry.name), relative);
|
|
74695
74709
|
} else if (entry.isFile() && (kind === "skills" || entry.name.endsWith(".py"))) {
|
|
74696
|
-
|
|
74697
|
-
if (bucket.size > 0 && cameFromBucket(bucket, relative, (await import_promises25.default.stat(file2)).size))
|
|
74698
|
-
continue;
|
|
74699
|
-
out.push({ relative, file: file2 });
|
|
74710
|
+
out.push({ relative, file: import_node_path45.default.join(folder, entry.name) });
|
|
74700
74711
|
}
|
|
74701
74712
|
}
|
|
74702
74713
|
};
|
|
@@ -74705,9 +74716,12 @@ async function localFiles(dir, kind) {
|
|
|
74705
74716
|
}
|
|
74706
74717
|
async function syncTeamRepo(options) {
|
|
74707
74718
|
const { api, branch, folder } = options;
|
|
74708
|
-
const state = await readState(options.stateFile);
|
|
74709
|
-
const report = { branch, pulled: [], removed: [], pushed: [], conflicts: [], deletedHere: [] };
|
|
74710
74719
|
const mirrorFile = (kind, relative) => import_node_path45.default.join(options.mirror[kind], ...relative.split("/"));
|
|
74720
|
+
const state = await readState(options.stateFile, (repoPath) => {
|
|
74721
|
+
const target = classifyRepoPath(folder, repoPath);
|
|
74722
|
+
return target === void 0 ? void 0 : mirrorFile(target.kind, target.relative);
|
|
74723
|
+
});
|
|
74724
|
+
const report = { branch, pulled: [], removed: [], pushed: [], conflicts: [], behind: [], deletedHere: [] };
|
|
74711
74725
|
let head = await api.branchHead(branch);
|
|
74712
74726
|
if (head !== void 0 && head !== state.head) {
|
|
74713
74727
|
const changed = state.head !== void 0 ? await api.changes(state.head, head) : (await api.listFiles(folder.replace(/^\/+|\/+$/g, ""), head)).map((relative) => ({
|
|
@@ -74743,16 +74757,30 @@ async function syncTeamRepo(options) {
|
|
|
74743
74757
|
state.head = head;
|
|
74744
74758
|
}
|
|
74745
74759
|
if (options.push !== false) {
|
|
74746
|
-
const locals = [
|
|
74747
|
-
|
|
74748
|
-
|
|
74749
|
-
|
|
74760
|
+
const locals = [];
|
|
74761
|
+
for (const kind of ["skills", "tools"]) {
|
|
74762
|
+
for (const dir of new Set(options.local[kind].filter((entry) => entry !== void 0).map((entry) => import_node_path45.default.resolve(entry)))) {
|
|
74763
|
+
locals.push(...(await localFiles(dir, kind)).map((entry) => ({ ...entry, kind })));
|
|
74764
|
+
}
|
|
74765
|
+
}
|
|
74750
74766
|
const present2 = /* @__PURE__ */ new Set();
|
|
74767
|
+
const chosen = /* @__PURE__ */ new Map();
|
|
74751
74768
|
for (const entry of locals) {
|
|
74752
74769
|
const repoPath = repoPathFor(folder, entry.kind, entry.relative);
|
|
74753
74770
|
present2.add(repoPath);
|
|
74754
74771
|
const bytes = new Uint8Array(await import_promises25.default.readFile(entry.file));
|
|
74755
74772
|
const mine = hash2(bytes);
|
|
74773
|
+
const earlier = chosen.get(repoPath);
|
|
74774
|
+
if (earlier !== void 0) {
|
|
74775
|
+
if (earlier.hash !== mine) {
|
|
74776
|
+
report.conflicts.push({
|
|
74777
|
+
path: repoPath,
|
|
74778
|
+
reason: `two different copies on this machine (${earlier.file} and ${entry.file}) - the first, which Light Code uses, is the one synced`
|
|
74779
|
+
});
|
|
74780
|
+
}
|
|
74781
|
+
continue;
|
|
74782
|
+
}
|
|
74783
|
+
chosen.set(repoPath, { hash: mine, file: entry.file });
|
|
74756
74784
|
const known = state.files[repoPath];
|
|
74757
74785
|
if (known?.hash === mine) {
|
|
74758
74786
|
state.pushed[repoPath] = mine;
|
|
@@ -74780,6 +74808,9 @@ async function syncTeamRepo(options) {
|
|
|
74780
74808
|
}
|
|
74781
74809
|
} else if (known.hash === state.pushed[repoPath]) {
|
|
74782
74810
|
sourceCommitId = known.commit;
|
|
74811
|
+
} else if (mine === state.pushed[repoPath]) {
|
|
74812
|
+
report.behind.push(repoPath);
|
|
74813
|
+
continue;
|
|
74783
74814
|
} else {
|
|
74784
74815
|
report.conflicts.push({
|
|
74785
74816
|
path: repoPath,
|
|
@@ -74801,6 +74832,15 @@ async function syncTeamRepo(options) {
|
|
|
74801
74832
|
report.pushed.push(repoPath);
|
|
74802
74833
|
} catch (error51) {
|
|
74803
74834
|
const status2 = error51.status;
|
|
74835
|
+
if (status2 === 409) {
|
|
74836
|
+
const now = await api.branchHead(branch).catch(() => void 0);
|
|
74837
|
+
const remote = now !== void 0 ? await api.readBytes(repoPath, now).catch(() => void 0) : void 0;
|
|
74838
|
+
if (now !== void 0 && remote !== void 0 && hash2(remote) === mine) {
|
|
74839
|
+
state.files[repoPath] = { commit: now, hash: mine };
|
|
74840
|
+
state.pushed[repoPath] = mine;
|
|
74841
|
+
continue;
|
|
74842
|
+
}
|
|
74843
|
+
}
|
|
74804
74844
|
report.conflicts.push({
|
|
74805
74845
|
path: repoPath,
|
|
74806
74846
|
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)}`
|
|
@@ -74816,6 +74856,45 @@ async function syncTeamRepo(options) {
|
|
|
74816
74856
|
await writeWhole2(options.stateFile, JSON.stringify(state, null, 1));
|
|
74817
74857
|
return report;
|
|
74818
74858
|
}
|
|
74859
|
+
async function checkCoverage(options) {
|
|
74860
|
+
const { folder } = options;
|
|
74861
|
+
const state = await readState(options.stateFile, (repoPath) => {
|
|
74862
|
+
const target = classifyRepoPath(folder, repoPath);
|
|
74863
|
+
return target === void 0 ? void 0 : import_node_path45.default.join(options.mirror[target.kind], ...target.relative.split("/"));
|
|
74864
|
+
});
|
|
74865
|
+
const covered = { skills: 0, tools: 0 };
|
|
74866
|
+
const problems = [];
|
|
74867
|
+
const repoPaths = [];
|
|
74868
|
+
for (const kind of ["skills", "tools"]) {
|
|
74869
|
+
for (const dir of new Set(options.dirs[kind].map((entry) => import_node_path45.default.resolve(entry)))) {
|
|
74870
|
+
for (const entry of await localFiles(dir, kind)) {
|
|
74871
|
+
const repoPath = repoPathFor(folder, kind, entry.relative);
|
|
74872
|
+
const mine = hash2(new Uint8Array(await import_promises25.default.readFile(entry.file)));
|
|
74873
|
+
const known = state.files[repoPath];
|
|
74874
|
+
if (known === void 0)
|
|
74875
|
+
problems.push(`${entry.file} - not in the repository yet`);
|
|
74876
|
+
else if (known.hash !== mine && state.pushed[repoPath] !== mine)
|
|
74877
|
+
problems.push(`${entry.file} - differs from the repository's copy`);
|
|
74878
|
+
else {
|
|
74879
|
+
covered[kind] += 1;
|
|
74880
|
+
repoPaths.push(repoPath);
|
|
74881
|
+
}
|
|
74882
|
+
}
|
|
74883
|
+
}
|
|
74884
|
+
}
|
|
74885
|
+
return { covered, problems, repoPaths: [...new Set(repoPaths)] };
|
|
74886
|
+
}
|
|
74887
|
+
async function releaseFromRecord(stateFile, repoPaths) {
|
|
74888
|
+
let parsed;
|
|
74889
|
+
try {
|
|
74890
|
+
parsed = JSON.parse(await import_promises25.default.readFile(stateFile, "utf8"));
|
|
74891
|
+
} catch {
|
|
74892
|
+
return;
|
|
74893
|
+
}
|
|
74894
|
+
for (const repoPath of repoPaths)
|
|
74895
|
+
delete parsed.pushed[repoPath];
|
|
74896
|
+
await writeWhole2(stateFile, JSON.stringify(parsed, null, 1));
|
|
74897
|
+
}
|
|
74819
74898
|
|
|
74820
74899
|
// ../../packages/core/dist/platform/httpTrace.js
|
|
74821
74900
|
var SECRET_NAME = /secret|password|passwd|token|api[-_]?key|assertion|credential|session|signature|cookie/i;
|
|
@@ -84112,8 +84191,94 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84112
84191
|
..."reason" in plan2 ? { reason: plan2.reason } : {},
|
|
84113
84192
|
...teamRepoStatus !== void 0 ? { status: teamRepoStatus } : {},
|
|
84114
84193
|
syncing: teamRepoSyncing,
|
|
84115
|
-
...saveError !== void 0 ? { saveError } : {}
|
|
84194
|
+
...saveError !== void 0 ? { saveError } : {},
|
|
84195
|
+
bucketFolders: bucketFolderLabels(config2),
|
|
84196
|
+
...teamRepoRetire !== void 0 ? { retire: teamRepoRetire } : {}
|
|
84197
|
+
});
|
|
84198
|
+
}
|
|
84199
|
+
function bucketFolderLabels(config2) {
|
|
84200
|
+
const label = (kind, mirror) => {
|
|
84201
|
+
const name = targetById(cachedS3, mirror.connectionId)?.label ?? mirror.connectionId;
|
|
84202
|
+
return `${kind}: ${name}${mirror.prefix !== void 0 ? ` / ${mirror.prefix}` : ""}`;
|
|
84203
|
+
};
|
|
84204
|
+
return [
|
|
84205
|
+
...(config2.s3?.skills ?? []).filter((mirror) => mirror.enabled === true).map((mirror) => label("Skills", mirror)),
|
|
84206
|
+
...(config2.s3?.tools ?? []).filter((mirror) => mirror.enabled === true).map((mirror) => label("Tools", mirror))
|
|
84207
|
+
];
|
|
84208
|
+
}
|
|
84209
|
+
let teamRepoRetire;
|
|
84210
|
+
async function handleRetireS3Buckets(confirm) {
|
|
84211
|
+
const config2 = await loadSettings();
|
|
84212
|
+
const plan2 = teamRepoPlan(config2);
|
|
84213
|
+
const folders = bucketFolderLabels(config2);
|
|
84214
|
+
const refuse = async (problems) => {
|
|
84215
|
+
teamRepoRetire = { ready: false, folders, covered: { skills: 0, tools: 0 }, problems };
|
|
84216
|
+
await postTeamRepo();
|
|
84217
|
+
};
|
|
84218
|
+
if ("reason" in plan2)
|
|
84219
|
+
return refuse([`The team repository is not set up: ${plan2.reason}`]);
|
|
84220
|
+
if (folders.length === 0)
|
|
84221
|
+
return refuse(["No S3 bucket folders are switched on for skills or tools."]);
|
|
84222
|
+
teamRepoRetire = { ready: false, folders, covered: { skills: 0, tools: 0 }, problems: [], checking: true };
|
|
84223
|
+
await postTeamRepo();
|
|
84224
|
+
await Promise.all([handleSyncS3("skills"), handleSyncS3("tools")]).catch(() => void 0);
|
|
84225
|
+
await handleTeamRepoSync(confirm ? "switching bucket folders off" : "checking before switching bucket folders off");
|
|
84226
|
+
const status2 = teamRepoStatus;
|
|
84227
|
+
if (status2?.error !== void 0)
|
|
84228
|
+
return refuse([`The sync failed: ${status2.error}`]);
|
|
84229
|
+
if (status2 !== void 0 && status2.conflicts.length > 0) {
|
|
84230
|
+
return refuse(status2.conflicts.map((conflict) => `${conflict.path} - ${conflict.reason}`));
|
|
84231
|
+
}
|
|
84232
|
+
const bucketDirs = {
|
|
84233
|
+
skills: mirroredSkillsDirs.filter((dir) => !samePath(dir, plan2.dirs.skills)),
|
|
84234
|
+
tools: mirroredToolsDirs.filter((dir) => !samePath(dir, plan2.dirs.tools))
|
|
84235
|
+
};
|
|
84236
|
+
const coverage = await checkCoverage({ folder: plan2.settings.folder, stateFile: plan2.stateFile, mirror: plan2.dirs, dirs: bucketDirs });
|
|
84237
|
+
if (coverage.problems.length > 0) {
|
|
84238
|
+
teamRepoRetire = { ready: false, folders, covered: coverage.covered, problems: coverage.problems };
|
|
84239
|
+
await postTeamRepo();
|
|
84240
|
+
return;
|
|
84241
|
+
}
|
|
84242
|
+
if (!confirm) {
|
|
84243
|
+
teamRepoRetire = { ready: true, folders, covered: coverage.covered, problems: [] };
|
|
84244
|
+
await postTeamRepo();
|
|
84245
|
+
return;
|
|
84246
|
+
}
|
|
84247
|
+
const off = (mirrors) => mirrors?.map((mirror) => {
|
|
84248
|
+
const rest = { ...mirror };
|
|
84249
|
+
delete rest.enabled;
|
|
84250
|
+
return rest;
|
|
84116
84251
|
});
|
|
84252
|
+
const s3 = { ...config2.s3 ?? {} };
|
|
84253
|
+
const skillMirrors = off(s3.skills);
|
|
84254
|
+
const toolMirrors = off(s3.tools);
|
|
84255
|
+
if (skillMirrors !== void 0)
|
|
84256
|
+
s3.skills = skillMirrors;
|
|
84257
|
+
if (toolMirrors !== void 0)
|
|
84258
|
+
s3.tools = toolMirrors;
|
|
84259
|
+
await configManager.save("user", { s3 });
|
|
84260
|
+
const stillHere = await checkCoverage({
|
|
84261
|
+
folder: plan2.settings.folder,
|
|
84262
|
+
stateFile: plan2.stateFile,
|
|
84263
|
+
mirror: plan2.dirs,
|
|
84264
|
+
dirs: { skills: [localSkillsDir].filter((dir) => dir !== void 0), tools: [localToolsDir(config2)].filter((dir) => dir !== void 0) }
|
|
84265
|
+
});
|
|
84266
|
+
await releaseFromRecord(plan2.stateFile, coverage.repoPaths.filter((repoPath) => !stillHere.repoPaths.includes(repoPath)));
|
|
84267
|
+
await loadSettings();
|
|
84268
|
+
await configurePythonFromSettings();
|
|
84269
|
+
await refreshSkills();
|
|
84270
|
+
void postSkills();
|
|
84271
|
+
await postPython();
|
|
84272
|
+
await postS3();
|
|
84273
|
+
teamRepoRetire = {
|
|
84274
|
+
ready: false,
|
|
84275
|
+
folders,
|
|
84276
|
+
covered: coverage.covered,
|
|
84277
|
+
problems: [],
|
|
84278
|
+
done: `Switched off: ${folders.join("; ")}. ${String(coverage.covered.skills)} skill file(s) and ${String(coverage.covered.tools)} tool(s) now load from the team repository. Nothing was deleted - tick the folders in Settings -> S3 to switch them back on.`
|
|
84279
|
+
};
|
|
84280
|
+
logger.info(`team repository: S3 bucket folders switched off (${folders.join("; ")})`);
|
|
84281
|
+
await handleTeamRepoSync("bucket folders switched off");
|
|
84117
84282
|
}
|
|
84118
84283
|
async function handleSaveTeamRepo(input) {
|
|
84119
84284
|
const project = input.project.trim();
|
|
@@ -84178,8 +84343,12 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84178
84343
|
api,
|
|
84179
84344
|
branch: plan2.settings.branch,
|
|
84180
84345
|
folder: plan2.settings.folder,
|
|
84181
|
-
//
|
|
84182
|
-
|
|
84346
|
+
// Every folder skills and tools load from here, in the order they win a name: the save folder,
|
|
84347
|
+
// the project's own folder, and S3 bucket folders - never the team copy itself.
|
|
84348
|
+
local: {
|
|
84349
|
+
skills: [skillsDir, localSkillsDir, ...mirroredSkillsDirs].filter((dir) => !samePath(dir, plan2.dirs.skills)),
|
|
84350
|
+
tools: [pythonFolders(config2).toolsDir, localToolsDir(config2), ...mirroredToolsDirs].filter((dir) => !samePath(dir, plan2.dirs.tools))
|
|
84351
|
+
},
|
|
84183
84352
|
mirror: plan2.dirs,
|
|
84184
84353
|
stateFile: plan2.stateFile,
|
|
84185
84354
|
author: cachedAttribution.author ?? "someone"
|
|
@@ -84193,6 +84362,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84193
84362
|
pulled: report.pulled,
|
|
84194
84363
|
removed: report.removed,
|
|
84195
84364
|
conflicts: report.conflicts,
|
|
84365
|
+
behind: report.behind,
|
|
84196
84366
|
deletedHere: report.deletedHere
|
|
84197
84367
|
};
|
|
84198
84368
|
logger.info(`team repository sync (${reason}): ${String(report.pushed.length)} pushed, ${String(report.pulled.length)} pulled, ${String(report.conflicts.length)} conflict(s)`);
|
|
@@ -85902,7 +86072,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
85902
86072
|
},
|
|
85903
86073
|
save: saveUsageProfile
|
|
85904
86074
|
});
|
|
85905
|
-
async function
|
|
86075
|
+
async function contentHash2(file2) {
|
|
85906
86076
|
try {
|
|
85907
86077
|
const text2 = (await import_promises28.default.readFile(file2, "utf8")).replace(/\r\n/g, "\n");
|
|
85908
86078
|
const meaningful = text2.split("\n").filter((line) => !/^(author|project|version|updated)\s*:/i.test(line) && !/^__(author|project|version|updated)__\s*=/.test(line)).join("\n").trim();
|
|
@@ -85921,7 +86091,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
85921
86091
|
return bucket !== void 0 ? `bucket ${bucket.label}` : "shared folder";
|
|
85922
86092
|
};
|
|
85923
86093
|
for (const skill of skills) {
|
|
85924
|
-
const hash3 = await
|
|
86094
|
+
const hash3 = await contentHash2(skill.filePath);
|
|
85925
86095
|
items.push({
|
|
85926
86096
|
kind: "skill",
|
|
85927
86097
|
name: skill.name,
|
|
@@ -85941,7 +86111,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
85941
86111
|
for (const skill of loaded.skills) {
|
|
85942
86112
|
if (items.some((item) => item.kind === "skill" && samePath(item.filePath, skill.filePath)))
|
|
85943
86113
|
continue;
|
|
85944
|
-
const hash3 = await
|
|
86114
|
+
const hash3 = await contentHash2(skill.filePath);
|
|
85945
86115
|
items.push({
|
|
85946
86116
|
kind: "skill",
|
|
85947
86117
|
name: skill.name,
|
|
@@ -85957,7 +86127,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
85957
86127
|
}
|
|
85958
86128
|
const status2 = python.status();
|
|
85959
86129
|
for (const tool of status2.tools) {
|
|
85960
|
-
const hash3 = await
|
|
86130
|
+
const hash3 = await contentHash2(tool.filePath);
|
|
85961
86131
|
items.push({
|
|
85962
86132
|
kind: "tool",
|
|
85963
86133
|
name: tool.name,
|
|
@@ -87782,6 +87952,8 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
87782
87952
|
reportFailure("handleSaveTeamRepo", handleSaveTeamRepo(message4.settings));
|
|
87783
87953
|
} else if (message4.type === "syncTeamRepo") {
|
|
87784
87954
|
reportFailure("handleTeamRepoSync", handleTeamRepoSync("asked"));
|
|
87955
|
+
} else if (message4.type === "retireS3Buckets") {
|
|
87956
|
+
reportFailure("handleRetireS3Buckets", handleRetireS3Buckets(message4.confirm));
|
|
87785
87957
|
} else if (message4.type === "saveTeamSkillSelection") {
|
|
87786
87958
|
reportFailure("saveTeamSkillSelection", saveKeepPrivate(message4.keepPrivate).then(postSkills));
|
|
87787
87959
|
} else if (message4.type === "saveSkillDefaults") {
|
|
@@ -90953,9 +91125,31 @@ listed as not synced, on the panel and in Settings \u2192 Usage \u2192 Needs att
|
|
|
90953
91125
|
refuses because someone committed first is the same. A skill or tool you **delete** stays in the
|
|
90954
91126
|
repository until somebody removes it there - the panel lists them.
|
|
90955
91127
|
|
|
90956
|
-
**With S3 buckets too.**
|
|
90957
|
-
|
|
90958
|
-
|
|
91128
|
+
**With S3 buckets too.** Everything skills and tools load from is committed - the folder new ones are
|
|
91129
|
+
saved in, the project's .lightcode folders, **and the S3 bucket folders** - so a team that keeps its
|
|
91130
|
+
skills and tools in a bucket gets all of them in the repository. Never the repository's own copy, so the
|
|
91131
|
+
two syncs cannot bounce files between them. Two colleagues committing the same bucket file meet as
|
|
91132
|
+
identical content, which is agreement, not a conflict; an edit someone makes in the bucket is committed
|
|
91133
|
+
by the next sync. The same name in two folders here is one file when identical; when the copies differ,
|
|
91134
|
+
the one Light Code uses is committed and the other is listed.
|
|
91135
|
+
|
|
91136
|
+
**"Newer in the repository"** (grey, not red): a colleague's change reached the repository before your
|
|
91137
|
+
bucket sync brought it here. Your copy is unchanged, so nothing clashes; it clears once the bucket syncs.
|
|
91138
|
+
**"Not synced - changed both here and in the repository"** (red) means both sides really changed. Compare
|
|
91139
|
+
your copy with the team copy, keep one, and the next sync agrees. Line-ending differences (Windows CRLF
|
|
91140
|
+
against LF) are not counted as changes.
|
|
91141
|
+
|
|
91142
|
+
**Do I still need the S3 bucket?** Either is enough to share: the bucket delivers files to everyone's
|
|
91143
|
+
machine, and the repository does too while keeping history and diffs. With both on, the same file in both
|
|
91144
|
+
is one file. A team can switch the bucket folders off and use the repository alone: **Use the repository
|
|
91145
|
+
instead of the S3 bucket**, in the same panel. **Check** syncs the bucket and the repository, then makes sure
|
|
91146
|
+
every skill and tool in the bucket folders is in the repository with the same content, listing anything that
|
|
91147
|
+
is not. Only after a clean check can **Switch bucket folders off** be pressed, and it checks once more first.
|
|
91148
|
+
It switches the skills and tools bucket folders off together and only unticks them - nothing is deleted in the bucket or on this computer, and ticking them again in
|
|
91149
|
+
Settings -> S3 undoes it. Afterwards new skills and tools are saved in the project's folders and committed to
|
|
91150
|
+
the repository, and what came from the bucket loads from the team copy (tools approved before stay approved
|
|
91151
|
+
when their content is the same). Colleagues still using only the bucket stop receiving yours, so switch over
|
|
91152
|
+
together.
|
|
90959
91153
|
|
|
90960
91154
|
Problems from syncing in the background (the repository, buckets, tools that did not load) show in
|
|
90961
91155
|
**Settings \u2192 Usage \u2192 Needs attention**.
|