@chosengeneration/light-code 0.140.0 → 0.142.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.
Files changed (3) hide show
  1. package/dist/cli.cjs +487 -368
  2. package/dist/server.cjs +479 -360
  3. package/package.json +1 -1
package/dist/server.cjs CHANGED
@@ -63499,9 +63499,308 @@ function stripAnsi(text) {
63499
63499
  // ../../packages/core/dist/jupyter/mirror.js
63500
63500
  var import_node_crypto10 = require("node:crypto");
63501
63501
  var import_promises16 = __toESM(require("node:fs/promises"), 1);
63502
+ var import_node_path30 = __toESM(require("node:path"), 1);
63503
+
63504
+ // ../../packages/core/dist/tools/nativeSearch.js
63505
+ var import_node_os4 = __toESM(require("node:os"), 1);
63502
63506
  var import_node_path29 = __toESM(require("node:path"), 1);
63507
+ var ALWAYS_SKIPPED = /* @__PURE__ */ new Set([".git", "node_modules"]);
63508
+ var DEFAULT_MAX_FILES = 5e4;
63509
+ var caseFlag = process.platform === "win32" ? "i" : "";
63510
+ function globToRegExp(glob, anchored) {
63511
+ let body = "";
63512
+ for (let index = 0; index < glob.length; index += 1) {
63513
+ const char = glob[index];
63514
+ if (char === "*") {
63515
+ if (glob[index + 1] === "*") {
63516
+ const slashAfter = glob[index + 2] === "/";
63517
+ const atSegmentStart = index === 0 || glob[index - 1] === "/";
63518
+ if (atSegmentStart && slashAfter) {
63519
+ body += "(?:.*/)?";
63520
+ index += 2;
63521
+ } else {
63522
+ body += ".*";
63523
+ index += 1;
63524
+ }
63525
+ } else {
63526
+ body += "[^/]*";
63527
+ }
63528
+ } else if (char === "?") {
63529
+ body += "[^/]";
63530
+ } else if (char === "[") {
63531
+ const close = glob.indexOf("]", index + 2);
63532
+ if (close === -1) {
63533
+ body += "\\[";
63534
+ } else {
63535
+ let inner = glob.slice(index + 1, close);
63536
+ if (inner.startsWith("!"))
63537
+ inner = `^${inner.slice(1)}`;
63538
+ body += `[${inner.replace(/\\/g, "\\\\")}]`;
63539
+ index = close;
63540
+ }
63541
+ } else if (char === "{") {
63542
+ const close = glob.indexOf("}", index);
63543
+ if (close === -1) {
63544
+ body += "\\{";
63545
+ } else {
63546
+ const options = glob.slice(index + 1, close).split(",");
63547
+ body += `(?:${options.map((option) => globToRegExp(option, true).source.slice(1, -1)).join("|")})`;
63548
+ index = close;
63549
+ }
63550
+ } else if (char === "\\" && index + 1 < glob.length) {
63551
+ body += escapeRegExp2(glob[index + 1]);
63552
+ index += 1;
63553
+ } else {
63554
+ body += escapeRegExp2(char);
63555
+ }
63556
+ }
63557
+ return new RegExp(anchored ? `^${body}$` : `^(?:.*/)?${body}$`, caseFlag);
63558
+ }
63559
+ function escapeRegExp2(text) {
63560
+ return text.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
63561
+ }
63562
+ function parseIgnoreFile(text, base) {
63563
+ const rules = [];
63564
+ for (const raw of text.split(/\r?\n/)) {
63565
+ let line = raw.replace(/(?<!\\)\s+$/, "");
63566
+ if (line.length === 0 || line.startsWith("#"))
63567
+ continue;
63568
+ let negate = false;
63569
+ if (line.startsWith("!")) {
63570
+ negate = true;
63571
+ line = line.slice(1);
63572
+ } else if (line.startsWith("\\!") || line.startsWith("\\#")) {
63573
+ line = line.slice(1);
63574
+ }
63575
+ let dirOnly = false;
63576
+ if (line.endsWith("/")) {
63577
+ dirOnly = true;
63578
+ line = line.slice(0, -1);
63579
+ }
63580
+ if (line.length === 0)
63581
+ continue;
63582
+ const anchored = line.includes("/");
63583
+ if (line.startsWith("/"))
63584
+ line = line.slice(1);
63585
+ rules.push({ base, regex: globToRegExp(line, anchored), negate, dirOnly });
63586
+ }
63587
+ return rules;
63588
+ }
63589
+ function isIgnored(rules, relative, isDirectory2) {
63590
+ return ignoreDecision(rules, relative, isDirectory2, false);
63591
+ }
63592
+ function ignoreDecision(rules, relative, isDirectory2, initial) {
63593
+ let ignored = initial;
63594
+ for (const rule of rules) {
63595
+ if (rule.dirOnly && !isDirectory2)
63596
+ continue;
63597
+ let scoped = relative;
63598
+ if (rule.base.length > 0) {
63599
+ if (!relative.startsWith(`${rule.base}/`))
63600
+ continue;
63601
+ scoped = relative.slice(rule.base.length + 1);
63602
+ }
63603
+ if (rule.regex.test(scoped))
63604
+ ignored = !rule.negate;
63605
+ }
63606
+ return ignored;
63607
+ }
63608
+ async function repositoryWideRules(fs41, root, globalIgnoreFile) {
63609
+ const sources = [
63610
+ globalIgnoreFile ?? import_node_path29.default.join(process.env["XDG_CONFIG_HOME"] ?? import_node_path29.default.join(import_node_os4.default.homedir(), ".config"), "git", "ignore"),
63611
+ import_node_path29.default.join(root, ".git", "info", "exclude")
63612
+ ];
63613
+ const rules = [];
63614
+ for (const source of sources) {
63615
+ try {
63616
+ rules.push(...parseIgnoreFile(await fs41.readFile(source), ""));
63617
+ } catch {
63618
+ }
63619
+ }
63620
+ return rules;
63621
+ }
63622
+ async function walkFiles(fs41, root, options) {
63623
+ const maxFiles = options.maxFiles ?? DEFAULT_MAX_FILES;
63624
+ const files = [];
63625
+ const baseRules = options.includeIgnored ? [] : await repositoryWideRules(fs41, root, options.globalIgnoreFile);
63626
+ const pending = [{ relative: "", rules: baseRules }];
63627
+ while (pending.length > 0) {
63628
+ if (options.signal?.aborted === true)
63629
+ break;
63630
+ const { relative, rules: inherited } = pending.pop();
63631
+ const absolute = relative.length > 0 ? import_node_path29.default.join(root, ...relative.split("/")) : root;
63632
+ let entries;
63633
+ try {
63634
+ entries = await fs41.readdir(absolute);
63635
+ } catch {
63636
+ continue;
63637
+ }
63638
+ let rules = inherited;
63639
+ if (!options.includeIgnored && entries.some((entry) => entry.name === ".gitignore" && !entry.isDirectory)) {
63640
+ try {
63641
+ const text = await fs41.readFile(import_node_path29.default.join(absolute, ".gitignore"));
63642
+ rules = [...inherited, ...parseIgnoreFile(text, relative)];
63643
+ } catch {
63644
+ }
63645
+ }
63646
+ const sorted = [...entries].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
63647
+ const subdirectories = [];
63648
+ for (const entry of sorted) {
63649
+ if (ALWAYS_SKIPPED.has(entry.name))
63650
+ continue;
63651
+ const child = relative.length > 0 ? `${relative}/${entry.name}` : entry.name;
63652
+ if (!options.includeIgnored && isIgnored(rules, child, entry.isDirectory))
63653
+ continue;
63654
+ if (entry.isDirectory) {
63655
+ subdirectories.push(child);
63656
+ } else if (entry.isFile) {
63657
+ files.push(child);
63658
+ if (files.length >= maxFiles)
63659
+ return { files, truncated: true };
63660
+ }
63661
+ }
63662
+ for (const child of subdirectories.reverse())
63663
+ pending.push({ relative: child, rules });
63664
+ }
63665
+ return { files, truncated: false };
63666
+ }
63667
+ var MAX_FILE_BYTES = 5 * 1024 * 1024;
63668
+ var DEFAULT_MAX_OUTPUT = 2 * 1024 * 1024;
63669
+ function compilePattern(pattern) {
63670
+ let source = pattern;
63671
+ let flags = "";
63672
+ const inline2 = /^\(\?([a-z]+)\)/.exec(source);
63673
+ if (inline2 !== null) {
63674
+ source = source.slice(inline2[0].length);
63675
+ if (inline2[1].includes("i"))
63676
+ flags += "i";
63677
+ if (inline2[1].includes("s"))
63678
+ flags += "s";
63679
+ if (inline2[1].includes("m"))
63680
+ flags += "m";
63681
+ }
63682
+ try {
63683
+ return new RegExp(source, `${flags}u`);
63684
+ } catch {
63685
+ try {
63686
+ return new RegExp(source, flags);
63687
+ } catch (error51) {
63688
+ throw new Error(`The search pattern is not a valid regular expression: ${error51 instanceof Error ? error51.message : String(error51)}`, { cause: error51 });
63689
+ }
63690
+ }
63691
+ }
63692
+ function fileFilter(filePattern) {
63693
+ if (filePattern === void 0 || filePattern.trim().length === 0)
63694
+ return () => true;
63695
+ let glob = filePattern.trim();
63696
+ const exclude = glob.startsWith("!");
63697
+ if (exclude)
63698
+ glob = glob.slice(1);
63699
+ const anchored = glob.includes("/");
63700
+ const regex = globToRegExp(glob.startsWith("/") ? glob.slice(1) : glob, anchored);
63701
+ return (relative) => regex.test(relative) !== exclude;
63702
+ }
63703
+ async function searchFiles(fs41, root, options) {
63704
+ const regex = compilePattern(options.pattern);
63705
+ const admits = fileFilter(options.filePattern);
63706
+ const context = options.contextLines ?? 2;
63707
+ const maxOutput = options.maxOutputChars ?? DEFAULT_MAX_OUTPUT;
63708
+ const { files, truncated: walkTruncated } = await walkFiles(fs41, root, options);
63709
+ const separator = process.platform === "win32" ? "\\" : "/";
63710
+ const chunks = [];
63711
+ let size = 0;
63712
+ let firstGroup = true;
63713
+ for (const relative of files) {
63714
+ if (options.signal?.aborted === true)
63715
+ break;
63716
+ if (!admits(relative))
63717
+ continue;
63718
+ const absolute = import_node_path29.default.join(root, ...relative.split("/"));
63719
+ let bytes;
63720
+ try {
63721
+ const stat = await fs41.stat(absolute);
63722
+ if (stat.size > MAX_FILE_BYTES)
63723
+ continue;
63724
+ bytes = await fs41.readBytes(absolute);
63725
+ } catch {
63726
+ continue;
63727
+ }
63728
+ if (bytes.subarray(0, 8e3).includes(0))
63729
+ continue;
63730
+ const lines = bytes.toString("utf8").split("\n").map((line) => line.endsWith("\r") ? line.slice(0, -1) : line);
63731
+ const matched = [];
63732
+ for (let index = 0; index < lines.length; index += 1) {
63733
+ regex.lastIndex = 0;
63734
+ if (regex.test(lines[index]))
63735
+ matched.push(index);
63736
+ }
63737
+ if (matched.length === 0)
63738
+ continue;
63739
+ const shown2 = `.${separator}${relative.split("/").join(separator)}`;
63740
+ const matchSet = new Set(matched);
63741
+ let lastPrinted = -2;
63742
+ for (const hit of matched) {
63743
+ const from = Math.max(0, hit - context, lastPrinted + 1);
63744
+ const to = Math.min(lines.length - 1, hit + context);
63745
+ if (from > lastPrinted + 1 && !firstGroup)
63746
+ chunks.push("--");
63747
+ firstGroup = false;
63748
+ for (let index = from; index <= to; index += 1) {
63749
+ if (index === lines.length - 1 && lines[index] === "" && !matchSet.has(index))
63750
+ continue;
63751
+ const line = `${shown2}${matchSet.has(index) ? ":" : "-"}${index + 1}${matchSet.has(index) ? ":" : "-"}${lines[index]}`;
63752
+ chunks.push(line);
63753
+ size += line.length + 1;
63754
+ }
63755
+ lastPrinted = Math.max(lastPrinted, to);
63756
+ if (size > maxOutput) {
63757
+ return { output: chunks.join("\n"), truncated: true };
63758
+ }
63759
+ }
63760
+ }
63761
+ return { output: chunks.join("\n"), truncated: walkTruncated };
63762
+ }
63763
+
63764
+ // ../../packages/core/dist/jupyter/hubIgnore.js
63765
+ var HUBIGNORE = ".hubignore";
63766
+ var BUILT_IN_SKIPS = /* @__PURE__ */ new Set([
63767
+ ".ipynb_checkpoints",
63768
+ "__pycache__",
63769
+ ".git",
63770
+ "node_modules",
63771
+ ".venv",
63772
+ "venv",
63773
+ ".mypy_cache",
63774
+ ".pytest_cache"
63775
+ ]);
63776
+ function skippedByDefault(name) {
63777
+ if (name === HUBIGNORE)
63778
+ return false;
63779
+ return name.startsWith(".") || BUILT_IN_SKIPS.has(name);
63780
+ }
63781
+ var HubIgnore = class _HubIgnore {
63782
+ rules;
63783
+ constructor(rules = []) {
63784
+ this.rules = rules;
63785
+ }
63786
+ /** These rules plus a `.hubignore` read in the folder `base` (relative to the synced folder, `/`-separated). */
63787
+ with(text, base) {
63788
+ return new _HubIgnore([...this.rules, ...parseIgnoreFile(text, base)]);
63789
+ }
63790
+ /** Whether a path inside the synced folder (`/`-separated) is left out. */
63791
+ ignores(relative, isDirectory2) {
63792
+ const name = relative.split("/").pop() ?? relative;
63793
+ if (name === HUBIGNORE)
63794
+ return false;
63795
+ return ignoreDecision(this.rules, relative, isDirectory2, skippedByDefault(name));
63796
+ }
63797
+ get empty() {
63798
+ return this.rules.length === 0;
63799
+ }
63800
+ };
63801
+
63802
+ // ../../packages/core/dist/jupyter/mirror.js
63503
63803
  var MANIFEST = ".lightcode-hub.json";
63504
- var SKIPPED_FOLDERS = /* @__PURE__ */ new Set([".ipynb_checkpoints", "__pycache__", ".git", "node_modules", ".venv", "venv", ".mypy_cache", ".pytest_cache"]);
63505
63804
  var CONCURRENCY = 8;
63506
63805
  var HubMirror = class {
63507
63806
  client;
@@ -63527,14 +63826,14 @@ var HubMirror = class {
63527
63826
  if (this.manifest !== void 0)
63528
63827
  return this.manifest;
63529
63828
  try {
63530
- this.manifest = JSON.parse(await import_promises16.default.readFile(import_node_path29.default.join(this.root, MANIFEST), "utf8"));
63829
+ this.manifest = JSON.parse(await import_promises16.default.readFile(import_node_path30.default.join(this.root, MANIFEST), "utf8"));
63531
63830
  } catch {
63532
63831
  this.manifest = {};
63533
63832
  }
63534
63833
  return this.manifest;
63535
63834
  }
63536
63835
  async saveManifest() {
63537
- const target = import_node_path29.default.join(this.root, MANIFEST);
63836
+ const target = import_node_path30.default.join(this.root, MANIFEST);
63538
63837
  const temporary = `${target}.${String(process.pid)}.tmp`;
63539
63838
  await import_promises16.default.mkdir(this.root, { recursive: true });
63540
63839
  await import_promises16.default.writeFile(temporary, JSON.stringify(this.manifest ?? {}), "utf8");
@@ -63542,10 +63841,10 @@ var HubMirror = class {
63542
63841
  }
63543
63842
  /** The hub path for a local file, or undefined when it is not inside one of the hub folders. */
63544
63843
  remoteOf(localAbsolute) {
63545
- const relative = import_node_path29.default.relative(this.root, localAbsolute);
63546
- if (relative.startsWith("..") || import_node_path29.default.isAbsolute(relative))
63844
+ const relative = import_node_path30.default.relative(this.root, localAbsolute);
63845
+ if (relative.startsWith("..") || import_node_path30.default.isAbsolute(relative))
63547
63846
  return void 0;
63548
- const parts = relative.split(import_node_path29.default.sep);
63847
+ const parts = relative.split(import_node_path30.default.sep);
63549
63848
  const folder = this.folders.find((f) => f.local.toLowerCase() === (parts[0] ?? "").toLowerCase());
63550
63849
  if (folder === void 0)
63551
63850
  return void 0;
@@ -63564,13 +63863,13 @@ var HubMirror = class {
63564
63863
  }
63565
63864
  async pullNow(signal) {
63566
63865
  const manifest = await this.loadManifest();
63567
- const result = { fetched: [], unchanged: 0, removed: [], conflicts: [], skipped: [], failed: [] };
63866
+ const result = { fetched: [], unchanged: 0, removed: [], conflicts: [], skipped: [], ignored: [], failed: [] };
63568
63867
  const maxBytes = (this.spec.maxFileMB ?? 20) * 1024 * 1024;
63569
63868
  const seen = /* @__PURE__ */ new Set();
63570
63869
  for (const folder of this.folders) {
63571
63870
  let files;
63572
63871
  try {
63573
- files = await this.walk(folder.remote, signal);
63872
+ files = await this.walk(folder, signal);
63574
63873
  } catch (error51) {
63575
63874
  result.failed.push({ path: folder.remote || "(top folder)", problem: error51 instanceof Error ? error51.message : String(error51) });
63576
63875
  for (const key2 of Object.keys(manifest))
@@ -63582,7 +63881,7 @@ var HubMirror = class {
63582
63881
  const inside = folder.remote.length > 0 ? entry.path.slice(folder.remote.length + 1) : entry.path;
63583
63882
  const key2 = `${folder.local}/${inside}`;
63584
63883
  seen.add(key2);
63585
- const local = import_node_path29.default.join(this.root, ...key2.split("/"));
63884
+ const local = import_node_path30.default.join(this.root, ...key2.split("/"));
63586
63885
  const known = manifest[key2];
63587
63886
  const localHash = await hashFile(local);
63588
63887
  const changedHere = localHash !== void 0 && (known === void 0 || known.hash !== localHash);
@@ -63615,7 +63914,12 @@ var HubMirror = class {
63615
63914
  for (const [key2, known] of Object.entries(manifest)) {
63616
63915
  if (seen.has(key2))
63617
63916
  continue;
63618
- const local = import_node_path29.default.join(this.root, ...key2.split("/"));
63917
+ if (await this.ignoredHere(key2)) {
63918
+ delete manifest[key2];
63919
+ result.ignored.push(key2);
63920
+ continue;
63921
+ }
63922
+ const local = import_node_path30.default.join(this.root, ...key2.split("/"));
63619
63923
  const localHash = await hashFile(local);
63620
63924
  if (localHash !== void 0 && localHash !== known.hash) {
63621
63925
  result.conflicts.push(key2);
@@ -63628,24 +63932,35 @@ var HubMirror = class {
63628
63932
  await this.saveManifest();
63629
63933
  return result;
63630
63934
  }
63631
- /** Every file under a remote folder, folders listed in parallel. */
63632
- async walk(remote, signal) {
63935
+ /**
63936
+ * Every file under a remote folder that is not ignored, folders listed in parallel. An ignored
63937
+ * folder is not listed at all - which is the point for a `node_modules` of forty thousand files.
63938
+ */
63939
+ async walk(folder, signal) {
63633
63940
  const files = [];
63634
- let level = [remote];
63941
+ let level = [{ remote: folder.remote, inside: "", ignore: new HubIgnore() }];
63635
63942
  while (level.length > 0) {
63636
63943
  const next = [];
63637
- await inBatches(level, CONCURRENCY, async (folder) => {
63638
- const entries = await this.client.list(folder, signal);
63944
+ await inBatches(level, CONCURRENCY, async (dir) => {
63945
+ const entries = await this.client.list(dir.remote, signal);
63639
63946
  if (entries === void 0) {
63640
- if (folder === remote)
63641
- throw new Error(`The hub has no folder "${remote}".`);
63947
+ if (dir.remote === folder.remote)
63948
+ throw new Error(`The hub has no folder "${folder.remote}".`);
63642
63949
  return;
63643
63950
  }
63951
+ let ignore = dir.ignore;
63952
+ const rules = entries.find((entry) => entry.name === HUBIGNORE && entry.type !== "directory");
63953
+ if (rules !== void 0) {
63954
+ const local = import_node_path30.default.join(this.root, folder.local, ...dir.inside.split("/").filter((p) => p.length > 0), HUBIGNORE);
63955
+ const text = await import_promises16.default.readFile(local, "utf8").catch(async () => (await this.client.read(rules.path, signal)).bytes.toString("utf8"));
63956
+ ignore = ignore.with(text, dir.inside);
63957
+ }
63644
63958
  for (const entry of entries) {
63645
- if (entry.name.startsWith(".") || SKIPPED_FOLDERS.has(entry.name))
63959
+ const inside = dir.inside.length > 0 ? `${dir.inside}/${entry.name}` : entry.name;
63960
+ if (ignore.ignores(inside, entry.type === "directory"))
63646
63961
  continue;
63647
63962
  if (entry.type === "directory")
63648
- next.push(entry.path);
63963
+ next.push({ remote: entry.path, inside, ignore });
63649
63964
  else
63650
63965
  files.push(entry);
63651
63966
  }
@@ -63654,6 +63969,27 @@ var HubMirror = class {
63654
63969
  }
63655
63970
  return files;
63656
63971
  }
63972
+ /**
63973
+ * Whether a local key (`<folder>/<path>`) is left out by `.hubignore` - the rules in this machine's
63974
+ * copy, from the synced folder down to the file, and any folder on the way that is itself left out.
63975
+ */
63976
+ async ignoredHere(key2) {
63977
+ const [folderName, ...parts] = key2.split("/");
63978
+ const folder = this.folders.find((f) => f.local.toLowerCase() === (folderName ?? "").toLowerCase());
63979
+ if (folder === void 0 || parts.length === 0)
63980
+ return false;
63981
+ let ignore = new HubIgnore();
63982
+ for (let depth = 0; depth < parts.length; depth++) {
63983
+ const inside = parts.slice(0, depth).join("/");
63984
+ const text = await import_promises16.default.readFile(import_node_path30.default.join(this.root, folder.local, ...parts.slice(0, depth), HUBIGNORE), "utf8").catch(() => void 0);
63985
+ if (text !== void 0)
63986
+ ignore = ignore.with(text, inside);
63987
+ const here = parts.slice(0, depth + 1).join("/");
63988
+ if (ignore.ignores(here, depth < parts.length - 1))
63989
+ return true;
63990
+ }
63991
+ return false;
63992
+ }
63657
63993
  /**
63658
63994
  * Saves one local file to the hub. Refuses - and changes nothing - when the hub's copy changed
63659
63995
  * since this copy last agreed with it.
@@ -63666,7 +64002,9 @@ var HubMirror = class {
63666
64002
  if (remote === void 0)
63667
64003
  return { saved: false, message: "not inside one of the JupyterHub folders, so it stays local" };
63668
64004
  const manifest = await this.loadManifest();
63669
- const key2 = import_node_path29.default.relative(this.root, localAbsolute).split(import_node_path29.default.sep).join("/");
64005
+ const key2 = import_node_path30.default.relative(this.root, localAbsolute).split(import_node_path30.default.sep).join("/");
64006
+ if (await this.ignoredHere(key2))
64007
+ return { saved: false, ignored: true, message: `listed in ${HUBIGNORE} (or skipped by default), so it stays local` };
63670
64008
  let bytes;
63671
64009
  try {
63672
64010
  bytes = await import_promises16.default.readFile(localAbsolute);
@@ -63712,7 +64050,7 @@ var HubMirror = class {
63712
64050
  const manifest = await this.loadManifest();
63713
64051
  const file2 = await this.client.read(remote, signal);
63714
64052
  await writeWhole(localAbsolute, file2.bytes);
63715
- manifest[import_node_path29.default.relative(this.root, localAbsolute).split(import_node_path29.default.sep).join("/")] = { remote, lastModified: file2.lastModified, hash: sha(file2.bytes) };
64053
+ manifest[import_node_path30.default.relative(this.root, localAbsolute).split(import_node_path30.default.sep).join("/")] = { remote, lastModified: file2.lastModified, hash: sha(file2.bytes) };
63716
64054
  await this.saveManifest();
63717
64055
  return remote;
63718
64056
  });
@@ -63723,8 +64061,8 @@ var HubMirror = class {
63723
64061
  const changes = [];
63724
64062
  const seen = /* @__PURE__ */ new Set();
63725
64063
  for (const folder of this.folders) {
63726
- for (const local of await listLocal(import_node_path29.default.join(this.root, folder.local))) {
63727
- const key2 = import_node_path29.default.relative(this.root, local).split(import_node_path29.default.sep).join("/");
64064
+ for (const local of await listLocal(import_node_path30.default.join(this.root, folder.local), "", new HubIgnore())) {
64065
+ const key2 = import_node_path30.default.relative(this.root, local).split(import_node_path30.default.sep).join("/");
63728
64066
  seen.add(key2);
63729
64067
  const known = manifest[key2];
63730
64068
  const remote = this.remoteOf(local) ?? key2;
@@ -63735,7 +64073,7 @@ var HubMirror = class {
63735
64073
  }
63736
64074
  }
63737
64075
  for (const [key2, known] of Object.entries(manifest)) {
63738
- if (!seen.has(key2))
64076
+ if (!seen.has(key2) && !await this.ignoredHere(key2))
63739
64077
  changes.push({ local: key2, remote: known.remote, kind: "deleted" });
63740
64078
  }
63741
64079
  return changes;
@@ -63752,12 +64090,12 @@ function sha(bytes) {
63752
64090
  return (0, import_node_crypto10.createHash)("sha256").update(bytes).digest("hex");
63753
64091
  }
63754
64092
  async function writeWhole(target, bytes) {
63755
- await import_promises16.default.mkdir(import_node_path29.default.dirname(target), { recursive: true });
64093
+ await import_promises16.default.mkdir(import_node_path30.default.dirname(target), { recursive: true });
63756
64094
  const temporary = `${target}.${String(process.pid)}.part`;
63757
64095
  await import_promises16.default.writeFile(temporary, bytes);
63758
64096
  await replaceFile(temporary, target);
63759
64097
  }
63760
- async function listLocal(folder) {
64098
+ async function listLocal(folder, inside, ignore) {
63761
64099
  const found2 = [];
63762
64100
  let entries;
63763
64101
  try {
@@ -63765,12 +64103,18 @@ async function listLocal(folder) {
63765
64103
  } catch {
63766
64104
  return found2;
63767
64105
  }
64106
+ if (entries.some((entry) => entry.name === HUBIGNORE && entry.isFile())) {
64107
+ const text = await import_promises16.default.readFile(import_node_path30.default.join(folder, HUBIGNORE), "utf8").catch(() => void 0);
64108
+ if (text !== void 0)
64109
+ ignore = ignore.with(text, inside);
64110
+ }
63768
64111
  for (const entry of entries) {
63769
- if (entry.name.startsWith(".") || SKIPPED_FOLDERS.has(entry.name))
64112
+ const relative = inside.length > 0 ? `${inside}/${entry.name}` : entry.name;
64113
+ if (ignore.ignores(relative, entry.isDirectory()))
63770
64114
  continue;
63771
- const full = import_node_path29.default.join(folder, entry.name);
64115
+ const full = import_node_path30.default.join(folder, entry.name);
63772
64116
  if (entry.isDirectory())
63773
- found2.push(...await listLocal(full));
64117
+ found2.push(...await listLocal(full, relative, ignore));
63774
64118
  else if (entry.isFile() && !entry.name.endsWith(".part"))
63775
64119
  found2.push(full);
63776
64120
  }
@@ -63815,7 +64159,15 @@ function hubGuidance(runtime) {
63815
64159
  "look up a hub library's API with hub_inspect rather than guessing. The local language server cannot see those",
63816
64160
  'libraries, so "import could not be resolved" is not reported here - it says nothing about the hub.',
63817
64161
  "The git repository is on the hub too, not in this copy: run git there with hub_run shell (cwd = the folder),",
63818
- 'and after anything that changes files (pull, checkout, merge) use hub_sync "pull" to bring them here.'
64162
+ 'and after anything that changes files (pull, checkout, merge) use hub_sync "pull" to bring them here.',
64163
+ "",
64164
+ "**.hubignore** lists files and folders that are never synced, in either direction - .gitignore syntax (`dist/`,",
64165
+ "`*.log`, `/build/`, `!keep.me`), in any synced folder, applying beneath it. Dot-files, node_modules, .git,",
64166
+ "virtualenvs and Python caches are skipped already (`!.editorconfig` brings one back). When you create or set up",
64167
+ "a project whose tools generate output or caches - Angular, React, any Node or Java build - write a .hubignore in",
64168
+ "its folder FIRST, before installing or building, listing what those tools generate (for Angular: dist/,",
64169
+ ".angular/, out-tsc/, coverage/, *.log), and tell the user what you put in it. A file already synced that a new",
64170
+ "rule lists simply stops being synced; nothing is deleted on either side."
63819
64171
  ].join("\n");
63820
64172
  }
63821
64173
  function withoutMissingImports(provider) {
@@ -63834,7 +64186,7 @@ function withoutMissingImports(provider) {
63834
64186
 
63835
64187
  // ../../packages/core/dist/python/machineApprovals.js
63836
64188
  var import_promises17 = __toESM(require("node:fs/promises"), 1);
63837
- var import_node_path30 = __toESM(require("node:path"), 1);
64189
+ var import_node_path31 = __toESM(require("node:path"), 1);
63838
64190
  var FileMachineApprovals = class {
63839
64191
  file;
63840
64192
  cache;
@@ -63877,7 +64229,7 @@ var FileMachineApprovals = class {
63877
64229
  }
63878
64230
  if (!changed)
63879
64231
  return;
63880
- await import_promises17.default.mkdir(import_node_path30.default.dirname(this.file), { recursive: true });
64232
+ await import_promises17.default.mkdir(import_node_path31.default.dirname(this.file), { recursive: true });
63881
64233
  const temporary = `${this.file}.${String(process.pid)}.${String(Date.now())}.tmp`;
63882
64234
  await import_promises17.default.writeFile(temporary, JSON.stringify(ledger, null, 1), "utf8");
63883
64235
  await replaceFile(temporary, this.file);
@@ -63890,21 +64242,21 @@ var FileMachineApprovals = class {
63890
64242
 
63891
64243
  // ../../packages/core/dist/addons/discover.js
63892
64244
  var import_promises18 = __toESM(require("node:fs/promises"), 1);
63893
- var import_node_path31 = __toESM(require("node:path"), 1);
64245
+ var import_node_path32 = __toESM(require("node:path"), 1);
63894
64246
  function defaultAddonFolders(env2, execPath, platform) {
63895
64247
  const folders = [];
63896
64248
  const prefix = env2["npm_config_prefix"] ?? env2["NPM_CONFIG_PREFIX"];
63897
64249
  if (platform === "win32") {
63898
64250
  if (prefix !== void 0 && prefix.length > 0)
63899
- folders.push(import_node_path31.default.join(prefix, "node_modules"));
64251
+ folders.push(import_node_path32.default.join(prefix, "node_modules"));
63900
64252
  if (env2["APPDATA"] !== void 0)
63901
- folders.push(import_node_path31.default.join(env2["APPDATA"], "npm", "node_modules"));
64253
+ folders.push(import_node_path32.default.join(env2["APPDATA"], "npm", "node_modules"));
63902
64254
  } else {
63903
64255
  if (prefix !== void 0 && prefix.length > 0)
63904
- folders.push(import_node_path31.default.join(prefix, "lib", "node_modules"));
63905
- folders.push(import_node_path31.default.join(import_node_path31.default.dirname(import_node_path31.default.dirname(execPath)), "lib", "node_modules"));
64256
+ folders.push(import_node_path32.default.join(prefix, "lib", "node_modules"));
64257
+ folders.push(import_node_path32.default.join(import_node_path32.default.dirname(import_node_path32.default.dirname(execPath)), "lib", "node_modules"));
63906
64258
  }
63907
- return [...new Set(folders.map((folder) => import_node_path31.default.resolve(folder)))];
64259
+ return [...new Set(folders.map((folder) => import_node_path32.default.resolve(folder)))];
63908
64260
  }
63909
64261
  function addonServerName(pkg) {
63910
64262
  const bare = pkg.replace(/^@[^/]+\//, "").replace(/^(light-code|lightcode|fire-code)-addon-/i, "");
@@ -63914,14 +64266,14 @@ function addonServerName(pkg) {
63914
64266
  async function readAddon(dir) {
63915
64267
  let manifest;
63916
64268
  try {
63917
- manifest = JSON.parse((await import_promises18.default.readFile(import_node_path31.default.join(dir, "package.json"), "utf8")).replace(/^\uFEFF/, ""));
64269
+ manifest = JSON.parse((await import_promises18.default.readFile(import_node_path32.default.join(dir, "package.json"), "utf8")).replace(/^\uFEFF/, ""));
63918
64270
  } catch {
63919
64271
  return void 0;
63920
64272
  }
63921
64273
  const label = manifest["lightCode"]?.["addon"];
63922
64274
  if (label === void 0)
63923
64275
  return void 0;
63924
- const pkg = typeof manifest["name"] === "string" ? manifest["name"] : import_node_path31.default.basename(dir);
64276
+ const pkg = typeof manifest["name"] === "string" ? manifest["name"] : import_node_path32.default.basename(dir);
63925
64277
  const fail = (problem) => ({ dir, package: pkg, problem });
63926
64278
  if (label === null || typeof label !== "object" || Array.isArray(label)) {
63927
64279
  return fail('"lightCode.addon" in package.json must be an object, e.g. { "main": "server.js" }.');
@@ -63931,9 +64283,9 @@ async function readAddon(dir) {
63931
64283
  const mainField = typeof fields["main"] === "string" ? fields["main"] : typeof manifest["main"] === "string" ? manifest["main"] : void 0;
63932
64284
  if (mainField === void 0)
63933
64285
  return fail('No server script: set "lightCode.addon.main" to the MCP server file.');
63934
- const main = import_node_path31.default.resolve(dir, mainField);
63935
- const relative = import_node_path31.default.relative(dir, main);
63936
- if (relative.startsWith("..") || import_node_path31.default.isAbsolute(relative))
64286
+ const main = import_node_path32.default.resolve(dir, mainField);
64287
+ const relative = import_node_path32.default.relative(dir, main);
64288
+ if (relative.startsWith("..") || import_node_path32.default.isAbsolute(relative))
63937
64289
  return fail(`"${mainField}" is outside the package folder.`);
63938
64290
  try {
63939
64291
  if (!(await import_promises18.default.stat(main)).isFile())
@@ -63986,7 +64338,7 @@ async function discoverAddons(folders) {
63986
64338
  for (const entry of entries.sort()) {
63987
64339
  if (entry.startsWith("."))
63988
64340
  continue;
63989
- const full = import_node_path31.default.join(folder, entry);
64341
+ const full = import_node_path32.default.join(folder, entry);
63990
64342
  if (entry.startsWith("@")) {
63991
64343
  let scoped;
63992
64344
  try {
@@ -63995,7 +64347,7 @@ async function discoverAddons(folders) {
63995
64347
  continue;
63996
64348
  }
63997
64349
  for (const name of scoped.sort())
63998
- await consider(import_node_path31.default.join(full, name));
64350
+ await consider(import_node_path32.default.join(full, name));
63999
64351
  } else {
64000
64352
  await consider(full);
64001
64353
  }
@@ -64063,13 +64415,13 @@ function runnableServers(servers, addons, runtime, repositoryServers = []) {
64063
64415
  // ../../packages/core/dist/agent/codebaseInstructions.js
64064
64416
  var import_node_crypto12 = require("node:crypto");
64065
64417
  var import_promises19 = __toESM(require("node:fs/promises"), 1);
64066
- var import_node_path33 = __toESM(require("node:path"), 1);
64418
+ var import_node_path34 = __toESM(require("node:path"), 1);
64067
64419
 
64068
64420
  // ../../packages/core/dist/usage/events.js
64069
64421
  var import_node_crypto11 = require("node:crypto");
64070
64422
  var import_node_fs5 = require("node:fs");
64071
- var import_node_os4 = __toESM(require("node:os"), 1);
64072
- var import_node_path32 = __toESM(require("node:path"), 1);
64423
+ var import_node_os5 = __toESM(require("node:os"), 1);
64424
+ var import_node_path33 = __toESM(require("node:path"), 1);
64073
64425
  function isUsageEvent(value) {
64074
64426
  if (value === null || typeof value !== "object")
64075
64427
  return false;
@@ -64094,11 +64446,11 @@ function usageDay(t) {
64094
64446
  return new Date(t).toISOString().slice(0, 10);
64095
64447
  }
64096
64448
  function usageInstanceId(storageDir) {
64097
- return (0, import_node_crypto11.createHash)("sha256").update(`${import_node_os4.default.hostname()}
64098
- ${import_node_path32.default.resolve(storageDir).toLowerCase()}`).digest("hex").slice(0, 12);
64449
+ return (0, import_node_crypto11.createHash)("sha256").update(`${import_node_os5.default.hostname()}
64450
+ ${import_node_path33.default.resolve(storageDir).toLowerCase()}`).digest("hex").slice(0, 12);
64099
64451
  }
64100
64452
  async function writeFileAtomically(target, text) {
64101
- await import_node_fs5.promises.mkdir(import_node_path32.default.dirname(target), { recursive: true });
64453
+ await import_node_fs5.promises.mkdir(import_node_path33.default.dirname(target), { recursive: true });
64102
64454
  const temporary = `${target}.${(0, import_node_crypto11.randomBytes)(6).toString("hex")}.tmp`;
64103
64455
  await import_node_fs5.promises.writeFile(temporary, text, "utf8");
64104
64456
  try {
@@ -64117,15 +64469,15 @@ var UsageLog = class {
64117
64469
  session;
64118
64470
  constructor(storageDir, session) {
64119
64471
  this.storageDir = storageDir;
64120
- this.queueDir = import_node_path32.default.join(storageDir, "usage", "queue");
64121
- this.manifestFile = import_node_path32.default.join(storageDir, "usage", "pushed.json");
64122
- this.rolledFile = import_node_path32.default.join(storageDir, "usage", "rolled.json");
64123
- this.legacyFile = import_node_path32.default.join(storageDir, "usage-events.jsonl");
64472
+ this.queueDir = import_node_path33.default.join(storageDir, "usage", "queue");
64473
+ this.manifestFile = import_node_path33.default.join(storageDir, "usage", "pushed.json");
64474
+ this.rolledFile = import_node_path33.default.join(storageDir, "usage", "rolled.json");
64475
+ this.legacyFile = import_node_path33.default.join(storageDir, "usage-events.jsonl");
64124
64476
  this.session = session ?? (0, import_node_crypto11.randomBytes)(6).toString("hex");
64125
64477
  }
64126
64478
  async append(event) {
64127
64479
  await import_node_fs5.promises.mkdir(this.queueDir, { recursive: true });
64128
- await import_node_fs5.promises.appendFile(import_node_path32.default.join(this.queueDir, `${usageDay(event.t)}__${this.session}.jsonl`), `${JSON.stringify(event)}
64480
+ await import_node_fs5.promises.appendFile(import_node_path33.default.join(this.queueDir, `${usageDay(event.t)}__${this.session}.jsonl`), `${JSON.stringify(event)}
64129
64481
  `, "utf8");
64130
64482
  }
64131
64483
  /**
@@ -64133,7 +64485,7 @@ var UsageLog = class {
64133
64485
  * never appended, so two sessions importing at once leave one copy rather than two.
64134
64486
  */
64135
64487
  async writeFixed(day, name, events) {
64136
- await writeFileAtomically(import_node_path32.default.join(this.queueDir, `${day}__${name}.jsonl`), events.map((event) => JSON.stringify(event)).join("\n") + (events.length > 0 ? "\n" : ""));
64488
+ await writeFileAtomically(import_node_path33.default.join(this.queueDir, `${day}__${name}.jsonl`), events.map((event) => JSON.stringify(event)).join("\n") + (events.length > 0 ? "\n" : ""));
64137
64489
  }
64138
64490
  /**
64139
64491
  * Moves a 0.156/0.157 single queue file into the per-day layout, once. Deterministic names, so two
@@ -64153,7 +64505,7 @@ var UsageLog = class {
64153
64505
  for (const [day, events] of byDay)
64154
64506
  await this.writeFixed(day, "legacy", events);
64155
64507
  await import_node_fs5.promises.rename(this.legacyFile, `${this.legacyFile}.migrated`).catch(() => void 0);
64156
- await import_node_fs5.promises.rm(import_node_path32.default.join(this.storageDir, "usage-sync.json"), { force: true }).catch(() => void 0);
64508
+ await import_node_fs5.promises.rm(import_node_path33.default.join(this.storageDir, "usage-sync.json"), { force: true }).catch(() => void 0);
64157
64509
  }
64158
64510
  /** Every day with local files, and its signature. */
64159
64511
  async days() {
@@ -64168,7 +64520,7 @@ var UsageLog = class {
64168
64520
  const match = QUEUE_FILE.exec(name);
64169
64521
  if (match === null)
64170
64522
  continue;
64171
- const size = await import_node_fs5.promises.stat(import_node_path32.default.join(this.queueDir, name)).then((stat) => stat.size).catch(() => void 0);
64523
+ const size = await import_node_fs5.promises.stat(import_node_path33.default.join(this.queueDir, name)).then((stat) => stat.size).catch(() => void 0);
64172
64524
  if (size === void 0)
64173
64525
  continue;
64174
64526
  const entry = days.get(match[1]) ?? { files: [], signature: "" };
@@ -64190,7 +64542,7 @@ var UsageLog = class {
64190
64542
  const entry = (await this.days()).get(day);
64191
64543
  if (entry === void 0)
64192
64544
  return [];
64193
- const texts = await Promise.all(entry.files.map((file2) => import_node_fs5.promises.readFile(import_node_path32.default.join(this.queueDir, file2.name), "utf8").catch(() => "")));
64545
+ const texts = await Promise.all(entry.files.map((file2) => import_node_fs5.promises.readFile(import_node_path33.default.join(this.queueDir, file2.name), "utf8").catch(() => "")));
64194
64546
  return texts.flatMap(parseUsageLines).sort((a, b) => a.t - b.t);
64195
64547
  }
64196
64548
  /** Every queued event (the last few weeks), for finding names worth looking up. */
@@ -64237,7 +64589,7 @@ var UsageLog = class {
64237
64589
  if (day >= cutoff || pushed[day] !== entry.signature)
64238
64590
  continue;
64239
64591
  for (const file2 of entry.files) {
64240
- await import_node_fs5.promises.rm(import_node_path32.default.join(this.queueDir, file2.name), { force: true }).catch(() => void 0);
64592
+ await import_node_fs5.promises.rm(import_node_path33.default.join(this.queueDir, file2.name), { force: true }).catch(() => void 0);
64241
64593
  removed++;
64242
64594
  }
64243
64595
  }
@@ -64250,14 +64602,14 @@ var CODEBASE_INSTRUCTIONS_FILE = "codebase-instructions.md";
64250
64602
  var CODEBASE_INSTRUCTIONS_LIMIT = 2e4;
64251
64603
  function codebaseInstructionsPath(options) {
64252
64604
  if (options.codebaseDir !== void 0)
64253
- return import_node_path33.default.join(options.codebaseDir, "instructions", CODEBASE_INSTRUCTIONS_FILE);
64605
+ return import_node_path34.default.join(options.codebaseDir, "instructions", CODEBASE_INSTRUCTIONS_FILE);
64254
64606
  if (options.workspaceRoot === void 0)
64255
64607
  return void 0;
64256
- const resolved = import_node_path33.default.resolve(options.workspaceRoot);
64608
+ const resolved = import_node_path34.default.resolve(options.workspaceRoot);
64257
64609
  const key2 = process.platform === "win32" ? resolved.toLowerCase() : resolved;
64258
64610
  const digest = (0, import_node_crypto12.createHash)("sha256").update(key2).digest("hex").slice(0, 12);
64259
- const slug = import_node_path33.default.basename(resolved).toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "workspace";
64260
- return import_node_path33.default.join(options.storageDir, "codebases", `${slug}-${digest}`, CODEBASE_INSTRUCTIONS_FILE);
64611
+ const slug = import_node_path34.default.basename(resolved).toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "workspace";
64612
+ return import_node_path34.default.join(options.storageDir, "codebases", `${slug}-${digest}`, CODEBASE_INSTRUCTIONS_FILE);
64261
64613
  }
64262
64614
  async function readCodebaseInstructions(file2) {
64263
64615
  if (file2 === void 0)
@@ -64357,7 +64709,7 @@ async function readToolCredential(options) {
64357
64709
 
64358
64710
  // ../../packages/core/dist/jupyter/tools.js
64359
64711
  var import_promises21 = __toESM(require("node:fs/promises"), 1);
64360
- var import_node_path34 = __toESM(require("node:path"), 1);
64712
+ var import_node_path35 = __toESM(require("node:path"), 1);
64361
64713
  var RUN_DEFAULT_SECONDS = 300;
64362
64714
  var SCRIPT_PREVIEW_CHARS = 6e3;
64363
64715
  var runSchema = external_exports.object({
@@ -64467,6 +64819,8 @@ function describePull(result) {
64467
64819
  lines.push(`Changed both here and on the hub - kept as they are here, NOT replaced: ${result.conflicts.join(", ")}. Compare with hub_sync "hub_version".`);
64468
64820
  if (result.skipped.length > 0)
64469
64821
  lines.push(`Too large to copy: ${result.skipped.join(", ")}`);
64822
+ if (result.ignored.length > 0)
64823
+ lines.push(`Now listed in .hubignore, so no longer synced (left as they are here and on the hub): ${result.ignored.slice(0, 20).join(", ")}${result.ignored.length > 20 ? ", \u2026" : ""}`);
64470
64824
  for (const failure of result.failed)
64471
64825
  lines.push(`Could not fetch ${failure.path}: ${failure.problem}`);
64472
64826
  if (lines.length === 0)
@@ -64543,7 +64897,7 @@ function createHubTools(runtime) {
64543
64897
  const syncTool = {
64544
64898
  name: "hub_sync",
64545
64899
  group: "edit",
64546
- description: `Keep the workspace and the JupyterHub folders in step. Edits are saved to the hub automatically and changes there are fetched every few minutes; use this to fetch now ("pull"), save local changes made another way, such as by a shell command ("push", optionally one path), list what is not saved ("status"), read the hub's copy of a file after a refused save ("hub_version"), or replace the local file with the hub's copy ("use_hub_version" - discards the local edit; ask the user first). Never overwrites anything changed on the other side.`,
64900
+ description: `Keep the workspace and the JupyterHub folders in step. Edits are saved to the hub automatically and changes there are fetched every few minutes; use this to fetch now ("pull"), save local changes made another way, such as by a shell command ("push", optionally one path), list what is not saved ("status"), read the hub's copy of a file after a refused save ("hub_version"), or replace the local file with the hub's copy ("use_hub_version" - discards the local edit; ask the user first). Never overwrites anything changed on the other side. Files and folders listed in a .hubignore file (gitignore syntax, in any synced folder) are never synced either way.`,
64547
64901
  parametersSchema: syncSchema,
64548
64902
  async preview(params3, context) {
64549
64903
  if (params3.action === "push") {
@@ -64578,8 +64932,8 @@ ${pending.map((p) => `- ${p.local} (${p.kind}${p.kind === "deleted" ? " here; st
64578
64932
  let failed2 = false;
64579
64933
  for (const file2 of pending.files) {
64580
64934
  const result = await runtime.mirror.push(file2, context.signal);
64581
- failed2 ||= !result.saved;
64582
- lines.push(`- ${import_node_path34.default.relative(runtime.mirror.root, file2).split(import_node_path34.default.sep).join("/")}: ${result.message}`);
64935
+ failed2 ||= !result.saved && result.ignored !== true;
64936
+ lines.push(`- ${import_node_path35.default.relative(runtime.mirror.root, file2).split(import_node_path35.default.sep).join("/")}: ${result.message}`);
64583
64937
  }
64584
64938
  return { content: lines.length > 0 ? lines.join("\n") : "Nothing to save.", ...failed2 ? { isError: true } : {} };
64585
64939
  }
@@ -64618,7 +64972,7 @@ async function pendingFor(runtime, context, target) {
64618
64972
  const pending = (await runtime.mirror.pending()).filter((p) => p.kind !== "deleted");
64619
64973
  return {
64620
64974
  ok: true,
64621
- files: pending.map((p) => import_node_path34.default.join(runtime.mirror.root, ...p.local.split("/"))),
64975
+ files: pending.map((p) => import_node_path35.default.join(runtime.mirror.root, ...p.local.split("/"))),
64622
64976
  changes: pending.map((p) => `${p.local} \u2192 ${p.remote} (${p.kind})`)
64623
64977
  };
64624
64978
  }
@@ -64668,7 +65022,7 @@ if __SOURCE__:
64668
65022
  `;
64669
65023
 
64670
65024
  // ../../packages/core/dist/jupyter/hubGit.js
64671
- var import_node_path35 = __toESM(require("node:path"), 1);
65025
+ var import_node_path36 = __toESM(require("node:path"), 1);
64672
65026
  var MARKER = "__LC_HUBGIT__";
64673
65027
  var LISTED = 40;
64674
65028
  var py2 = (value) => JSON.stringify(value);
@@ -64783,7 +65137,7 @@ async function hubGitStatus(runtime, signal) {
64783
65137
  total.upstream &&= one.upstream;
64784
65138
  if (total.branch === void 0 && one.branch !== void 0)
64785
65139
  total.branch = one.branch;
64786
- const prefix = results.length > 1 ? `${import_node_path35.default.posix.basename(repo.repo)}/` : "";
65140
+ const prefix = results.length > 1 ? `${import_node_path36.default.posix.basename(repo.repo)}/` : "";
64787
65141
  for (const file2 of one.files)
64788
65142
  if (total.files.length < LISTED)
64789
65143
  total.files.push(`${file2.slice(0, 2)}${prefix}${file2.slice(2)}`);
@@ -64796,7 +65150,7 @@ async function hubGitCommitPush(runtime, message4, signal) {
64796
65150
  return { ok: false, text: "Write a commit message first." };
64797
65151
  const pending = await runtime.mirror.pending();
64798
65152
  for (const change of pending.filter((p) => p.kind !== "deleted")) {
64799
- const saved = await runtime.mirror.push(import_node_path35.default.join(runtime.mirror.root, ...change.local.split("/")), signal);
65153
+ const saved = await runtime.mirror.push(import_node_path36.default.join(runtime.mirror.root, ...change.local.split("/")), signal);
64800
65154
  if (!saved.saved)
64801
65155
  return { ok: false, text: `Nothing was committed: ${change.local} could not be saved to the hub first (${saved.message}).` };
64802
65156
  }
@@ -64809,7 +65163,7 @@ async function hubGitCommitPush(runtime, message4, signal) {
64809
65163
  const lines = [];
64810
65164
  let ok = true;
64811
65165
  for (const repo of results) {
64812
- const name = results.length > 1 ? `${import_node_path35.default.posix.basename(repo.repo)}: ` : "";
65166
+ const name = results.length > 1 ? `${import_node_path36.default.posix.basename(repo.repo)}: ` : "";
64813
65167
  const committed = repo.commit?.ok === true;
64814
65168
  const nothing = /nothing to commit/.test(`${repo.commit?.out ?? ""}${repo.commit?.err ?? ""}`);
64815
65169
  if (repo.add?.ok !== true) {
@@ -64839,7 +65193,7 @@ async function hubGitPull(runtime, signal) {
64839
65193
  const lines = [];
64840
65194
  let ok = true;
64841
65195
  for (const repo of results) {
64842
- const name = results.length > 1 ? `${import_node_path35.default.posix.basename(repo.repo)}: ` : "";
65196
+ const name = results.length > 1 ? `${import_node_path36.default.posix.basename(repo.repo)}: ` : "";
64843
65197
  const all = `${repo.pull?.out ?? ""}${repo.pull?.err ?? ""}`;
64844
65198
  if (repo.pull?.ok === true)
64845
65199
  lines.push(`${name}${/Already up.to.date/i.test(all) ? "Already up to date." : "Pulled on the hub."}`);
@@ -65117,7 +65471,7 @@ function buildAutoGuidance(environment) {
65117
65471
 
65118
65472
  // ../../packages/core/dist/migrate/folders.js
65119
65473
  var import_promises22 = __toESM(require("node:fs/promises"), 1);
65120
- var import_node_path36 = __toESM(require("node:path"), 1);
65474
+ var import_node_path37 = __toESM(require("node:path"), 1);
65121
65475
  function nameOf(entry, kind) {
65122
65476
  return kind === "skills" ? entry.replace(/\.md$/i, "") : entry.replace(/\.py$/i, "");
65123
65477
  }
@@ -65142,7 +65496,7 @@ async function namesAt(dir, kind) {
65142
65496
  if (kind === "skills") {
65143
65497
  if (entry.toLowerCase().endsWith(".md"))
65144
65498
  found2.add(nameOf(entry, kind));
65145
- else if (await isDirectory(import_node_path36.default.join(dir, entry)))
65499
+ else if (await isDirectory(import_node_path37.default.join(dir, entry)))
65146
65500
  found2.add(entry);
65147
65501
  } else if (entry.toLowerCase().endsWith(".py")) {
65148
65502
  found2.add(nameOf(entry, kind));
@@ -65154,7 +65508,7 @@ async function planMigration(options) {
65154
65508
  const { from, to, kind } = options;
65155
65509
  const copy = [];
65156
65510
  const skip = [];
65157
- if (import_node_path36.default.resolve(from) === import_node_path36.default.resolve(to))
65511
+ if (import_node_path37.default.resolve(from) === import_node_path37.default.resolve(to))
65158
65512
  return { copy, skip };
65159
65513
  const existing = await namesAt(to, kind);
65160
65514
  let entries;
@@ -65166,14 +65520,14 @@ async function planMigration(options) {
65166
65520
  for (const entry of entries) {
65167
65521
  if (entry.startsWith("."))
65168
65522
  continue;
65169
- const source = import_node_path36.default.join(from, entry);
65523
+ const source = import_node_path37.default.join(from, entry);
65170
65524
  const directory = await isDirectory(source);
65171
65525
  if (kind === "skills") {
65172
65526
  if (!directory && !entry.toLowerCase().endsWith(".md"))
65173
65527
  continue;
65174
65528
  if (directory) {
65175
65529
  try {
65176
- await import_promises22.default.stat(import_node_path36.default.join(source, "SKILL.md"));
65530
+ await import_promises22.default.stat(import_node_path37.default.join(source, "SKILL.md"));
65177
65531
  } catch {
65178
65532
  continue;
65179
65533
  }
@@ -65186,7 +65540,7 @@ async function planMigration(options) {
65186
65540
  skip.push(name);
65187
65541
  continue;
65188
65542
  }
65189
- copy.push({ name, source, destination: import_node_path36.default.join(to, entry), directory });
65543
+ copy.push({ name, source, destination: import_node_path37.default.join(to, entry), directory });
65190
65544
  }
65191
65545
  copy.sort((a, b) => a.name.localeCompare(b.name));
65192
65546
  skip.sort();
@@ -65197,7 +65551,7 @@ async function runMigration(plan2) {
65197
65551
  const failed2 = [];
65198
65552
  for (const item of plan2.copy) {
65199
65553
  try {
65200
- await import_promises22.default.mkdir(import_node_path36.default.dirname(item.destination), { recursive: true });
65554
+ await import_promises22.default.mkdir(import_node_path37.default.dirname(item.destination), { recursive: true });
65201
65555
  await import_promises22.default.cp(item.source, item.destination, {
65202
65556
  recursive: item.directory,
65203
65557
  force: false,
@@ -65224,7 +65578,7 @@ function describeMigration(result, kind) {
65224
65578
 
65225
65579
  // ../../packages/core/dist/platform/node/shell.js
65226
65580
  var import_node_fs6 = __toESM(require("node:fs"), 1);
65227
- var import_node_path37 = __toESM(require("node:path"), 1);
65581
+ var import_node_path38 = __toESM(require("node:path"), 1);
65228
65582
  function windowsExtensions(env2) {
65229
65583
  const raw = env2["PATHEXT"] ?? ".COM;.EXE;.BAT;.CMD";
65230
65584
  return raw.split(";").filter((entry) => entry.length > 0);
@@ -65238,7 +65592,7 @@ function onPath(name, env2 = process.env) {
65238
65592
  continue;
65239
65593
  for (const extension of extensions) {
65240
65594
  try {
65241
- const candidate = import_node_path37.default.join(directory, name + extension);
65595
+ const candidate = import_node_path38.default.join(directory, name + extension);
65242
65596
  if (import_node_fs6.default.statSync(candidate).isFile())
65243
65597
  return true;
65244
65598
  } catch {
@@ -65260,7 +65614,7 @@ function resolveShell(configured, env2 = process.env) {
65260
65614
  return { command: void 0, kind: "posix", label: env2["SHELL"] ?? "/bin/sh" };
65261
65615
  }
65262
65616
  function kindOf(command) {
65263
- const base = import_node_path37.default.basename(command).toLowerCase().replace(/\.exe$/, "");
65617
+ const base = import_node_path38.default.basename(command).toLowerCase().replace(/\.exe$/, "");
65264
65618
  if (base === "pwsh")
65265
65619
  return "pwsh";
65266
65620
  if (base === "powershell")
@@ -65270,7 +65624,7 @@ function kindOf(command) {
65270
65624
  return "posix";
65271
65625
  }
65272
65626
  function labelFor(command) {
65273
- const base = import_node_path37.default.basename(command).toLowerCase().replace(/\.exe$/, "");
65627
+ const base = import_node_path38.default.basename(command).toLowerCase().replace(/\.exe$/, "");
65274
65628
  if (base === "pwsh")
65275
65629
  return "PowerShell 7 (pwsh)";
65276
65630
  if (base === "powershell")
@@ -65352,7 +65706,7 @@ function fastFsCapabilities(exe, timeoutMs = 5e3) {
65352
65706
  var import_node_child_process9 = require("node:child_process");
65353
65707
 
65354
65708
  // ../../packages/core/dist/tools/readStamps.js
65355
- var import_node_path38 = __toESM(require("node:path"), 1);
65709
+ var import_node_path39 = __toESM(require("node:path"), 1);
65356
65710
  async function stamp(context, realPath) {
65357
65711
  try {
65358
65712
  const s = await context.fs.stat(realPath);
@@ -65397,14 +65751,14 @@ async function staleFilesNamedIn(context, command) {
65397
65751
  };
65398
65752
  const stale = [];
65399
65753
  for (const [key2, known] of context.readStamps) {
65400
- const relative = import_node_path38.default.relative(root, key2);
65401
- const names = [key2, relative, relative.split(import_node_path38.default.sep).join("/"), import_node_path38.default.basename(key2)].map((n) => n.toLowerCase());
65754
+ const relative = import_node_path39.default.relative(root, key2);
65755
+ const names = [key2, relative, relative.split(import_node_path39.default.sep).join("/"), import_node_path39.default.basename(key2)].map((n) => n.toLowerCase());
65402
65756
  if (!names.some(stands))
65403
65757
  continue;
65404
65758
  try {
65405
65759
  const s = await context.fs.stat(key2);
65406
65760
  if (`${String(s.mtimeMs)}:${String(s.size)}` !== known)
65407
- stale.push(relative.split(import_node_path38.default.sep).join("/"));
65761
+ stale.push(relative.split(import_node_path39.default.sep).join("/"));
65408
65762
  } catch {
65409
65763
  }
65410
65764
  }
@@ -66934,7 +67288,7 @@ var RecordedChanges = class extends Set {
66934
67288
  // ../../packages/core/dist/office/bridge.js
66935
67289
  var import_node_child_process11 = require("node:child_process");
66936
67290
  var import_promises24 = __toESM(require("node:fs/promises"), 1);
66937
- var import_node_path39 = __toESM(require("node:path"), 1);
67291
+ var import_node_path40 = __toESM(require("node:path"), 1);
66938
67292
 
66939
67293
  // ../../packages/core/dist/office/workerSource.js
66940
67294
  var OFFICE_WORKER_SOURCE = `# Light Code office worker.
@@ -69668,7 +70022,7 @@ var OfficeBridge = class {
69668
70022
  return this.starting;
69669
70023
  }
69670
70024
  async start() {
69671
- const target = import_node_path39.default.join(this.options.storageDir, "office-worker.ps1");
70025
+ const target = import_node_path40.default.join(this.options.storageDir, "office-worker.ps1");
69672
70026
  await import_promises24.default.mkdir(this.options.storageDir, { recursive: true });
69673
70027
  const BOM = "\uFEFF";
69674
70028
  await import_promises24.default.writeFile(target, `${BOM}${OFFICE_WORKER_SOURCE}`, "utf8");
@@ -70175,7 +70529,7 @@ function createDeleteRoleTool(access) {
70175
70529
 
70176
70530
  // ../../packages/core/dist/rag/indexNaming.js
70177
70531
  var import_node_crypto13 = __toESM(require("node:crypto"), 1);
70178
- var import_node_path40 = __toESM(require("node:path"), 1);
70532
+ var import_node_path41 = __toESM(require("node:path"), 1);
70179
70533
  var DEFAULT_INDEX_PREFIX = "light-code";
70180
70534
  var DOMAIN_OR_PATH = /[\\/]/;
70181
70535
  function normaliseOwner(owner) {
@@ -70190,7 +70544,7 @@ function ownerSlug(owner) {
70190
70544
  function deriveIndexName(input) {
70191
70545
  const prefix = input.prefix ?? DEFAULT_INDEX_PREFIX;
70192
70546
  const slug = ownerSlug(input.owner);
70193
- const root = import_node_path40.default.resolve(input.workspaceRoot).toLowerCase();
70547
+ const root = import_node_path41.default.resolve(input.workspaceRoot).toLowerCase();
70194
70548
  const identity = input.owner === void 0 ? "" : normaliseOwner(input.owner);
70195
70549
  const digest = import_node_crypto13.default.createHash("sha256").update(`${identity}\0${root}`).digest("hex").slice(0, 16);
70196
70550
  const base = slug === void 0 ? `${prefix}-${digest}` : `${prefix}-${slug}-${digest}`;
@@ -70198,7 +70552,7 @@ function deriveIndexName(input) {
70198
70552
  }
70199
70553
 
70200
70554
  // ../../packages/core/dist/tools/exportConfig.js
70201
- var import_node_path41 = __toESM(require("node:path"), 1);
70555
+ var import_node_path42 = __toESM(require("node:path"), 1);
70202
70556
  var sectionIds = SHARE_SECTIONS.map((section) => section.id);
70203
70557
  var paramsSchema11 = external_exports.object({
70204
70558
  path: external_exports.string().min(1).describe('Where to write it in the workspace, e.g. "onboarding/light-code-team.json".'),
@@ -70238,7 +70592,7 @@ function createExportConfigTool(options) {
70238
70592
  if (!resolved.ok)
70239
70593
  return { content: resolved.message, isError: true };
70240
70594
  const { json: json2, notes } = prepare(await options.loadConfig(), params3);
70241
- await context.fs.mkdir(import_node_path41.default.dirname(resolved.realPath));
70595
+ await context.fs.mkdir(import_node_path42.default.dirname(resolved.realPath));
70242
70596
  await context.fs.writeFile(resolved.realPath, json2);
70243
70597
  return { content: `Wrote ${params3.path}. ${notes}`, path: resolved.realPath };
70244
70598
  }
@@ -70407,7 +70761,7 @@ function describeAtlassianFailure(product, doing, status2, body) {
70407
70761
  }
70408
70762
 
70409
70763
  // ../../packages/core/dist/atlassian/uploads.js
70410
- var import_node_path42 = __toESM(require("node:path"), 1);
70764
+ var import_node_path43 = __toESM(require("node:path"), 1);
70411
70765
 
70412
70766
  // ../../packages/core/dist/diagrams/layout.js
70413
70767
  var NODE_HEIGHT = 52;
@@ -71049,7 +71403,7 @@ async function prepareUploads(params3, context) {
71049
71403
  const resolved = await resolveToolPath(context, attachment.path);
71050
71404
  if (!resolved.ok)
71051
71405
  return { ok: false, message: resolved.message };
71052
- const name = attachment.name ?? import_node_path42.default.basename(resolved.realPath);
71406
+ const name = attachment.name ?? import_node_path43.default.basename(resolved.realPath);
71053
71407
  const problem = claim(name);
71054
71408
  if (problem !== void 0)
71055
71409
  return { ok: false, message: problem };
@@ -75266,7 +75620,7 @@ var NodeFileSystem = class {
75266
75620
  };
75267
75621
 
75268
75622
  // ../../packages/core/dist/config/project.js
75269
- var import_node_path43 = __toESM(require("node:path"), 1);
75623
+ var import_node_path44 = __toESM(require("node:path"), 1);
75270
75624
  function configuredProjectName(config2) {
75271
75625
  const name = config2?.project?.name?.trim();
75272
75626
  return name !== void 0 && name.length > 0 ? name : void 0;
@@ -75275,7 +75629,7 @@ function projectName(config2, workspaceRoot) {
75275
75629
  const configured = configuredProjectName(config2);
75276
75630
  if (configured !== void 0)
75277
75631
  return configured;
75278
- return workspaceRoot === void 0 ? void 0 : import_node_path43.default.basename(import_node_path43.default.resolve(workspaceRoot));
75632
+ return workspaceRoot === void 0 ? void 0 : import_node_path44.default.basename(import_node_path44.default.resolve(workspaceRoot));
75279
75633
  }
75280
75634
  function projectSlug(name) {
75281
75635
  if (name === void 0)
@@ -75285,7 +75639,7 @@ function projectSlug(name) {
75285
75639
  }
75286
75640
 
75287
75641
  // ../../packages/core/dist/rag/renameIndexes.js
75288
- var import_node_path44 = __toESM(require("node:path"), 1);
75642
+ var import_node_path45 = __toESM(require("node:path"), 1);
75289
75643
  var import_node_fs7 = require("node:fs");
75290
75644
  function planIndexRenames(names) {
75291
75645
  const plans = [];
@@ -75349,7 +75703,7 @@ async function copyBookkeeping(directory, from, to, storeId) {
75349
75703
  continue;
75350
75704
  const target = `${to}@${storeId}.${entry.slice(prefix.length)}`;
75351
75705
  try {
75352
- await import_node_fs7.promises.copyFile(import_node_path44.default.join(directory, entry), import_node_path44.default.join(directory, target), import_node_fs7.constants.COPYFILE_EXCL);
75706
+ await import_node_fs7.promises.copyFile(import_node_path45.default.join(directory, entry), import_node_path45.default.join(directory, target), import_node_fs7.constants.COPYFILE_EXCL);
75353
75707
  copied.push(target);
75354
75708
  } catch {
75355
75709
  }
@@ -75357,263 +75711,6 @@ async function copyBookkeeping(directory, from, to, storeId) {
75357
75711
  return copied;
75358
75712
  }
75359
75713
 
75360
- // ../../packages/core/dist/tools/nativeSearch.js
75361
- var import_node_os5 = __toESM(require("node:os"), 1);
75362
- var import_node_path45 = __toESM(require("node:path"), 1);
75363
- var ALWAYS_SKIPPED = /* @__PURE__ */ new Set([".git", "node_modules"]);
75364
- var DEFAULT_MAX_FILES = 5e4;
75365
- var caseFlag = process.platform === "win32" ? "i" : "";
75366
- function globToRegExp(glob, anchored) {
75367
- let body = "";
75368
- for (let index = 0; index < glob.length; index += 1) {
75369
- const char = glob[index];
75370
- if (char === "*") {
75371
- if (glob[index + 1] === "*") {
75372
- const slashAfter = glob[index + 2] === "/";
75373
- const atSegmentStart = index === 0 || glob[index - 1] === "/";
75374
- if (atSegmentStart && slashAfter) {
75375
- body += "(?:.*/)?";
75376
- index += 2;
75377
- } else {
75378
- body += ".*";
75379
- index += 1;
75380
- }
75381
- } else {
75382
- body += "[^/]*";
75383
- }
75384
- } else if (char === "?") {
75385
- body += "[^/]";
75386
- } else if (char === "[") {
75387
- const close = glob.indexOf("]", index + 2);
75388
- if (close === -1) {
75389
- body += "\\[";
75390
- } else {
75391
- let inner = glob.slice(index + 1, close);
75392
- if (inner.startsWith("!"))
75393
- inner = `^${inner.slice(1)}`;
75394
- body += `[${inner.replace(/\\/g, "\\\\")}]`;
75395
- index = close;
75396
- }
75397
- } else if (char === "{") {
75398
- const close = glob.indexOf("}", index);
75399
- if (close === -1) {
75400
- body += "\\{";
75401
- } else {
75402
- const options = glob.slice(index + 1, close).split(",");
75403
- body += `(?:${options.map((option) => globToRegExp(option, true).source.slice(1, -1)).join("|")})`;
75404
- index = close;
75405
- }
75406
- } else if (char === "\\" && index + 1 < glob.length) {
75407
- body += escapeRegExp2(glob[index + 1]);
75408
- index += 1;
75409
- } else {
75410
- body += escapeRegExp2(char);
75411
- }
75412
- }
75413
- return new RegExp(anchored ? `^${body}$` : `^(?:.*/)?${body}$`, caseFlag);
75414
- }
75415
- function escapeRegExp2(text) {
75416
- return text.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
75417
- }
75418
- function parseIgnoreFile(text, base) {
75419
- const rules = [];
75420
- for (const raw of text.split(/\r?\n/)) {
75421
- let line = raw.replace(/(?<!\\)\s+$/, "");
75422
- if (line.length === 0 || line.startsWith("#"))
75423
- continue;
75424
- let negate = false;
75425
- if (line.startsWith("!")) {
75426
- negate = true;
75427
- line = line.slice(1);
75428
- } else if (line.startsWith("\\!") || line.startsWith("\\#")) {
75429
- line = line.slice(1);
75430
- }
75431
- let dirOnly = false;
75432
- if (line.endsWith("/")) {
75433
- dirOnly = true;
75434
- line = line.slice(0, -1);
75435
- }
75436
- if (line.length === 0)
75437
- continue;
75438
- const anchored = line.includes("/");
75439
- if (line.startsWith("/"))
75440
- line = line.slice(1);
75441
- rules.push({ base, regex: globToRegExp(line, anchored), negate, dirOnly });
75442
- }
75443
- return rules;
75444
- }
75445
- function isIgnored(rules, relative, isDirectory2) {
75446
- let ignored = false;
75447
- for (const rule of rules) {
75448
- if (rule.dirOnly && !isDirectory2)
75449
- continue;
75450
- let scoped = relative;
75451
- if (rule.base.length > 0) {
75452
- if (!relative.startsWith(`${rule.base}/`))
75453
- continue;
75454
- scoped = relative.slice(rule.base.length + 1);
75455
- }
75456
- if (rule.regex.test(scoped))
75457
- ignored = !rule.negate;
75458
- }
75459
- return ignored;
75460
- }
75461
- async function repositoryWideRules(fs41, root, globalIgnoreFile) {
75462
- const sources = [
75463
- globalIgnoreFile ?? import_node_path45.default.join(process.env["XDG_CONFIG_HOME"] ?? import_node_path45.default.join(import_node_os5.default.homedir(), ".config"), "git", "ignore"),
75464
- import_node_path45.default.join(root, ".git", "info", "exclude")
75465
- ];
75466
- const rules = [];
75467
- for (const source of sources) {
75468
- try {
75469
- rules.push(...parseIgnoreFile(await fs41.readFile(source), ""));
75470
- } catch {
75471
- }
75472
- }
75473
- return rules;
75474
- }
75475
- async function walkFiles(fs41, root, options) {
75476
- const maxFiles = options.maxFiles ?? DEFAULT_MAX_FILES;
75477
- const files = [];
75478
- const baseRules = options.includeIgnored ? [] : await repositoryWideRules(fs41, root, options.globalIgnoreFile);
75479
- const pending = [{ relative: "", rules: baseRules }];
75480
- while (pending.length > 0) {
75481
- if (options.signal?.aborted === true)
75482
- break;
75483
- const { relative, rules: inherited } = pending.pop();
75484
- const absolute = relative.length > 0 ? import_node_path45.default.join(root, ...relative.split("/")) : root;
75485
- let entries;
75486
- try {
75487
- entries = await fs41.readdir(absolute);
75488
- } catch {
75489
- continue;
75490
- }
75491
- let rules = inherited;
75492
- if (!options.includeIgnored && entries.some((entry) => entry.name === ".gitignore" && !entry.isDirectory)) {
75493
- try {
75494
- const text = await fs41.readFile(import_node_path45.default.join(absolute, ".gitignore"));
75495
- rules = [...inherited, ...parseIgnoreFile(text, relative)];
75496
- } catch {
75497
- }
75498
- }
75499
- const sorted = [...entries].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
75500
- const subdirectories = [];
75501
- for (const entry of sorted) {
75502
- if (ALWAYS_SKIPPED.has(entry.name))
75503
- continue;
75504
- const child = relative.length > 0 ? `${relative}/${entry.name}` : entry.name;
75505
- if (!options.includeIgnored && isIgnored(rules, child, entry.isDirectory))
75506
- continue;
75507
- if (entry.isDirectory) {
75508
- subdirectories.push(child);
75509
- } else if (entry.isFile) {
75510
- files.push(child);
75511
- if (files.length >= maxFiles)
75512
- return { files, truncated: true };
75513
- }
75514
- }
75515
- for (const child of subdirectories.reverse())
75516
- pending.push({ relative: child, rules });
75517
- }
75518
- return { files, truncated: false };
75519
- }
75520
- var MAX_FILE_BYTES = 5 * 1024 * 1024;
75521
- var DEFAULT_MAX_OUTPUT = 2 * 1024 * 1024;
75522
- function compilePattern(pattern) {
75523
- let source = pattern;
75524
- let flags = "";
75525
- const inline2 = /^\(\?([a-z]+)\)/.exec(source);
75526
- if (inline2 !== null) {
75527
- source = source.slice(inline2[0].length);
75528
- if (inline2[1].includes("i"))
75529
- flags += "i";
75530
- if (inline2[1].includes("s"))
75531
- flags += "s";
75532
- if (inline2[1].includes("m"))
75533
- flags += "m";
75534
- }
75535
- try {
75536
- return new RegExp(source, `${flags}u`);
75537
- } catch {
75538
- try {
75539
- return new RegExp(source, flags);
75540
- } catch (error51) {
75541
- throw new Error(`The search pattern is not a valid regular expression: ${error51 instanceof Error ? error51.message : String(error51)}`, { cause: error51 });
75542
- }
75543
- }
75544
- }
75545
- function fileFilter(filePattern) {
75546
- if (filePattern === void 0 || filePattern.trim().length === 0)
75547
- return () => true;
75548
- let glob = filePattern.trim();
75549
- const exclude = glob.startsWith("!");
75550
- if (exclude)
75551
- glob = glob.slice(1);
75552
- const anchored = glob.includes("/");
75553
- const regex = globToRegExp(glob.startsWith("/") ? glob.slice(1) : glob, anchored);
75554
- return (relative) => regex.test(relative) !== exclude;
75555
- }
75556
- async function searchFiles(fs41, root, options) {
75557
- const regex = compilePattern(options.pattern);
75558
- const admits = fileFilter(options.filePattern);
75559
- const context = options.contextLines ?? 2;
75560
- const maxOutput = options.maxOutputChars ?? DEFAULT_MAX_OUTPUT;
75561
- const { files, truncated: walkTruncated } = await walkFiles(fs41, root, options);
75562
- const separator = process.platform === "win32" ? "\\" : "/";
75563
- const chunks = [];
75564
- let size = 0;
75565
- let firstGroup = true;
75566
- for (const relative of files) {
75567
- if (options.signal?.aborted === true)
75568
- break;
75569
- if (!admits(relative))
75570
- continue;
75571
- const absolute = import_node_path45.default.join(root, ...relative.split("/"));
75572
- let bytes;
75573
- try {
75574
- const stat = await fs41.stat(absolute);
75575
- if (stat.size > MAX_FILE_BYTES)
75576
- continue;
75577
- bytes = await fs41.readBytes(absolute);
75578
- } catch {
75579
- continue;
75580
- }
75581
- if (bytes.subarray(0, 8e3).includes(0))
75582
- continue;
75583
- const lines = bytes.toString("utf8").split("\n").map((line) => line.endsWith("\r") ? line.slice(0, -1) : line);
75584
- const matched = [];
75585
- for (let index = 0; index < lines.length; index += 1) {
75586
- regex.lastIndex = 0;
75587
- if (regex.test(lines[index]))
75588
- matched.push(index);
75589
- }
75590
- if (matched.length === 0)
75591
- continue;
75592
- const shown2 = `.${separator}${relative.split("/").join(separator)}`;
75593
- const matchSet = new Set(matched);
75594
- let lastPrinted = -2;
75595
- for (const hit of matched) {
75596
- const from = Math.max(0, hit - context, lastPrinted + 1);
75597
- const to = Math.min(lines.length - 1, hit + context);
75598
- if (from > lastPrinted + 1 && !firstGroup)
75599
- chunks.push("--");
75600
- firstGroup = false;
75601
- for (let index = from; index <= to; index += 1) {
75602
- if (index === lines.length - 1 && lines[index] === "" && !matchSet.has(index))
75603
- continue;
75604
- const line = `${shown2}${matchSet.has(index) ? ":" : "-"}${index + 1}${matchSet.has(index) ? ":" : "-"}${lines[index]}`;
75605
- chunks.push(line);
75606
- size += line.length + 1;
75607
- }
75608
- lastPrinted = Math.max(lastPrinted, to);
75609
- if (size > maxOutput) {
75610
- return { output: chunks.join("\n"), truncated: true };
75611
- }
75612
- }
75613
- }
75614
- return { output: chunks.join("\n"), truncated: walkTruncated };
75615
- }
75616
-
75617
75714
  // ../../packages/core/dist/platform/node/terminal.js
75618
75715
  var import_node_child_process13 = require("node:child_process");
75619
75716
  var NodeTerminalProcess = class {
@@ -79808,6 +79905,8 @@ ${preview.text}` } : {}
79808
79905
  ...hub !== void 0 ? {
79809
79906
  afterEdit: async (realPath) => {
79810
79907
  const saved = await hub.mirror.push(realPath, activeAbortController?.signal);
79908
+ if (saved.ignored === true)
79909
+ return `JupyterHub: not synced - ${saved.message}.`;
79811
79910
  return saved.saved ? `JupyterHub: ${saved.message}.` : `JupyterHub: NOT saved to the hub - ${saved.message}`;
79812
79911
  }
79813
79912
  } : {},
@@ -89174,7 +89273,19 @@ desktops of the same person; importing the file is how a second machine is set u
89174
89273
  "hub_browse",
89175
89274
  "browse the hub",
89176
89275
  "other codebase hub",
89177
- "files on the hub"
89276
+ "files on the hub",
89277
+ "hubignore",
89278
+ ".hubignore",
89279
+ "ignore files",
89280
+ "do not sync",
89281
+ "not synced",
89282
+ "exclude from sync",
89283
+ "skip folder",
89284
+ "node_modules",
89285
+ "dist folder",
89286
+ "angular",
89287
+ "build output",
89288
+ "sync ignore"
89178
89289
  ],
89179
89290
  body: `
89180
89291
  **Add codebase \u2192 On JupyterHub** (Fire Code): the hub's address, your hub user name, the folders on
@@ -89184,6 +89295,14 @@ on the hub's Token page (\`<hub>/hub/token\`). The token is saved encrypted in C
89184
89295
  a kernel (e.g. python3). Right-click the codebase \u2192 JupyterHub settings\u2026 changes them later.
89185
89296
  Your hub server must be running; if it is not, the agent says so - start it from the hub's home page.
89186
89297
 
89298
+ **\`.hubignore\`** lists files and folders that are never synced, either way - \`.gitignore\` syntax
89299
+ (\`dist/\`, \`*.log\`, \`/build/\`, \`!keep.me\`), in any synced folder, applying beneath it. Dot-files and
89300
+ dot-folders, \`node_modules\`, \`.git\`, virtualenvs and Python caches are skipped already; \`!.editorconfig\`
89301
+ brings one back. The \`.hubignore\` file itself is synced, so the hub and other machines follow it too.
89302
+ A file synced before a rule listed it just stops being synced - nothing is deleted on either side. For
89303
+ an Angular project: \`dist/\`, \`.angular/\`, \`out-tsc/\`, \`coverage/\`, \`*.log\`. The agent writes one
89304
+ when it sets up such a project, before installing or building, and says what it put in it.
89305
+
89187
89306
  **How it works**: Fire Code keeps a copy of the folders on this computer, so reading and searching
89188
89307
  are as fast as for any local codebase (and the Rust search tools apply). Changes on the hub are
89189
89308
  fetched when the agent starts and every 5 minutes; \`hub_sync\` "pull" fetches now. Every edit the