@ai-ecoverse/slicc-kernel 1.170.1 → 1.170.3

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.
@@ -7513,7 +7513,7 @@ var init_version = __esm({
7513
7513
  "src/version.ts"() {
7514
7514
  "use strict";
7515
7515
  init_captured_globals();
7516
- KERNEL_VERSION = true ? "1.170.1" : "0.0.0-dev";
7516
+ KERNEL_VERSION = true ? "1.170.3" : "0.0.0-dev";
7517
7517
  OS_RELEASE = "6.0.0-slicc";
7518
7518
  }
7519
7519
  });
@@ -7512,7 +7512,7 @@ var init_version = __esm({
7512
7512
  "src/version.ts"() {
7513
7513
  "use strict";
7514
7514
  init_captured_globals();
7515
- KERNEL_VERSION = true ? "1.170.1" : "0.0.0-dev";
7515
+ KERNEL_VERSION = true ? "1.170.3" : "0.0.0-dev";
7516
7516
  OS_RELEASE = "6.0.0-slicc";
7517
7517
  }
7518
7518
  });
package/dist/node.js CHANGED
@@ -3695,7 +3695,7 @@ function satisfies(version, range2) {
3695
3695
  }
3696
3696
 
3697
3697
  // src/version.ts
3698
- var KERNEL_VERSION = true ? "1.170.1" : "0.0.0-dev";
3698
+ var KERNEL_VERSION = true ? "1.170.3" : "0.0.0-dev";
3699
3699
  var OS_RELEASE = "6.0.0-slicc";
3700
3700
  function procVersion() {
3701
3701
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -3964,9 +3964,19 @@ function replacesOf(manifest) {
3964
3964
  if (!Array.isArray(replaces)) return [];
3965
3965
  return replaces.every((name2) => typeof name2 === "string" && PACKAGE_NAME.test(name2)) ? replaces : [];
3966
3966
  }
3967
- async function tierPackages(fs, physical, roots, bins, kernel) {
3967
+ async function directInstalls(fs, root) {
3968
+ try {
3969
+ const project = root.slice(0, root.lastIndexOf("/"));
3970
+ const { dependencies } = JSON.parse(await fs.readFile(`${project}/package.json`));
3971
+ return new Set(Object.keys(dependencies ?? {}));
3972
+ } catch {
3973
+ return void 0;
3974
+ }
3975
+ }
3976
+ async function tierPackages(fs, physical, roots, bins, kernel, global) {
3968
3977
  const out = [];
3969
3978
  for (const root of roots) {
3979
+ const direct = global.has(root) ? await directInstalls(fs, root) : void 0;
3970
3980
  for (const pkg of await packages(fs, root)) {
3971
3981
  let manifest;
3972
3982
  try {
@@ -3978,12 +3988,15 @@ async function tierPackages(fs, physical, roots, bins, kernel) {
3978
3988
  const named = new Set(own.map((command) => command.name));
3979
3989
  const extra = bins ? await binCommandsOf(physical, pkg, manifest, named) : [];
3980
3990
  const refused3 = engineRefusal(manifest, kernel);
3981
- const commands = [...own, ...extra];
3991
+ const name2 = pkg.slice(root.length + 1);
3992
+ const dependency = direct?.has(name2) === false;
3993
+ const marks = { ...refused3 ? { refused: refused3 } : {}, ...dependency ? { dependency } : {} };
3982
3994
  out.push({
3983
- name: pkg.slice(root.length + 1),
3995
+ name: name2,
3984
3996
  pkg,
3985
3997
  replaces: replacesOf(manifest),
3986
- commands: refused3 ? commands.map((command) => ({ ...command, refused: refused3 })) : commands
3998
+ commands: [...own, ...extra].map((command) => ({ ...command, ...marks })),
3999
+ dependency
3987
4000
  });
3988
4001
  }
3989
4002
  }
@@ -4009,19 +4022,25 @@ function winners(tier) {
4009
4022
  }
4010
4023
  return out;
4011
4024
  }
4012
- async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY, kernel = KERNEL_VERSION, refused3) {
4025
+ async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY, kernel = KERNEL_VERSION, refused3, global = /* @__PURE__ */ new Set()) {
4013
4026
  const found = /* @__PURE__ */ new Map();
4014
4027
  const physical = physicalResolver(fs);
4015
4028
  const tiers = (typeof modules === "string" ? [modules] : modules).map(
4016
4029
  (tier) => typeof tier === "string" ? [tier] : tier
4017
4030
  );
4018
- for (const [index, roots] of tiers.entries()) {
4019
- const tier = await tierPackages(fs, physical, roots, index >= binsFrom, kernel);
4020
- if (refused3) refused3.push(...tier.flatMap((entry) => entry.commands.filter((c) => c.refused)));
4031
+ const take = async (tier) => {
4021
4032
  for (const [name2, { pkg, command }] of winners(tier)) {
4022
4033
  if (!found.has(name2)) found.set(name2, await withPackagePaths(fs, pkg, command));
4023
4034
  }
4035
+ };
4036
+ const dependencies = [];
4037
+ for (const [index, roots] of tiers.entries()) {
4038
+ const tier = await tierPackages(fs, physical, roots, index >= binsFrom, kernel, global);
4039
+ if (refused3) refused3.push(...tier.flatMap((entry) => entry.commands.filter((c) => c.refused)));
4040
+ await take(tier.filter((entry) => !entry.dependency));
4041
+ dependencies.push(tier.filter((entry) => entry.dependency));
4024
4042
  }
4043
+ for (const tier of dependencies) await take(tier);
4025
4044
  if (!found.has("sh") && found.has("bash")) {
4026
4045
  found.set("sh", { ...found.get("bash"), name: "sh", argv0: "sh" });
4027
4046
  }
@@ -4975,7 +4994,8 @@ var UnlinkedKeeper = class {
4975
4994
  if (at !== void 0 || !await this.present(path)) return at;
4976
4995
  throw fsError("EBUSY", `${path}: open, and it could not be kept aside`);
4977
4996
  }
4978
- present(path) {
4997
+ async present(path) {
4998
+ if (await this.fs.commandTarget?.(path)) return false;
4979
4999
  return this.fs.lstat(path).then(
4980
5000
  () => true,
4981
5001
  (err) => err?.code !== "ENOENT" && err?.code !== "ENOTDIR"
@@ -7847,8 +7867,9 @@ var FsWatchers = class {
7847
7867
  this.report(paths);
7848
7868
  this.emit("change", paths);
7849
7869
  }
7850
- report(paths) {
7870
+ report(paths, notify = true) {
7851
7871
  for (const tap of this.taps) tap(paths);
7872
+ if (!notify) return;
7852
7873
  for (const watcher of this.watchers) {
7853
7874
  for (const path of paths) {
7854
7875
  const changed = normalizePath(path);
@@ -7867,16 +7888,16 @@ var FsWatchers = class {
7867
7888
  watcher.notify(paths.length > WATCH_BATCH_LIMIT ? { overflow: true } : { paths });
7868
7889
  }
7869
7890
  wrap(fs) {
7870
- const after = (run2, changed, type) => async (...args) => {
7871
- let done4 = false;
7891
+ const after = (run2, changed, type, partly = () => false) => async (...args) => {
7872
7892
  try {
7873
7893
  await run2(...args);
7874
- done4 = true;
7875
- } finally {
7876
- const paths = changed(...args);
7877
- this.report(paths);
7878
- if (done4) this.emit(type, paths);
7894
+ } catch (err) {
7895
+ this.report(changed(...args), partly(err, ...args));
7896
+ throw err;
7879
7897
  }
7898
+ const paths = changed(...args);
7899
+ this.report(paths);
7900
+ this.emit(type, paths);
7880
7901
  };
7881
7902
  const reals = this.reals;
7882
7903
  const realOf = async (path) => {
@@ -7918,6 +7939,12 @@ var FsWatchers = class {
7918
7939
  this.reshaped();
7919
7940
  }
7920
7941
  };
7942
+ const removing = after(
7943
+ fs.rm.bind(fs),
7944
+ (path) => [path],
7945
+ "rename",
7946
+ (err, _path, options) => options?.recursive === true && err?.code !== "ENOENT"
7947
+ );
7921
7948
  const overrides = {
7922
7949
  writeFile: content(fs.writeFile.bind(fs), overwritten),
7923
7950
  ...fs.createExclusive ? { createExclusive: content(fs.createExclusive.bind(fs), () => ["rename"]) } : {},
@@ -7946,14 +7973,20 @@ var FsWatchers = class {
7946
7973
  if (done4) this.emit("rename", fresh3 ? [...created4, path] : created4);
7947
7974
  }
7948
7975
  },
7949
- rm: reshaping(after(fs.rm.bind(fs), (path) => [path], "rename")),
7976
+ rm: reshaping(async (path, options) => {
7977
+ const absent2 = options?.force === true && await fs.lstat(path).then(
7978
+ () => false,
7979
+ () => true
7980
+ );
7981
+ return absent2 ? fs.rm(path, options) : removing(path, options);
7982
+ }),
7950
7983
  rename: reshaping(async (from, to) => {
7951
7984
  let done4 = false;
7952
7985
  try {
7953
7986
  await fs.rename(from, to);
7954
7987
  done4 = true;
7955
7988
  } finally {
7956
- this.report([from, to]);
7989
+ this.report([from, to], done4);
7957
7990
  if (done4) this.renamed(from, to);
7958
7991
  }
7959
7992
  }),
@@ -31118,7 +31151,8 @@ var Launcher = class {
31118
31151
  tiers,
31119
31152
  tiers.length - appended2.length,
31120
31153
  void 0,
31121
- refused3
31154
+ refused3,
31155
+ await this.globalRoots(scope)
31122
31156
  );
31123
31157
  this.refusedOf.set(commands, refused3.map(refusing));
31124
31158
  return commands;
@@ -31143,11 +31177,31 @@ var Launcher = class {
31143
31177
  ownCommands(scope) {
31144
31178
  let found = this.ownCatalogs.get(scope);
31145
31179
  if (!found) {
31146
- found = pnpmGlobalRoots(this.base, scope).then((roots) => scanCommands(this.scanned, roots)).then((commands) => new Set(commands.keys()));
31180
+ found = this.ownCatalog(scope);
31147
31181
  this.ownCatalogs.set(scope, found);
31148
31182
  }
31149
31183
  return found;
31150
31184
  }
31185
+ async ownCatalog(scope) {
31186
+ const roots = await pnpmGlobalRoots(this.base, scope);
31187
+ const own = await scanCommands(
31188
+ this.scanned,
31189
+ roots,
31190
+ void 0,
31191
+ void 0,
31192
+ void 0,
31193
+ new Set(roots)
31194
+ );
31195
+ const system = await this.commands();
31196
+ return new Set(
31197
+ [...own.values()].filter((command) => !command.dependency || !system.has(command.name)).map((command) => command.name)
31198
+ );
31199
+ }
31200
+ async globalRoots(scope) {
31201
+ const homes = scope ? [scope, this.pnpmHome] : [this.pnpmHome];
31202
+ const roots = await Promise.all(homes.map((home) => pnpmGlobalRoots(this.base, home)));
31203
+ return new Set(roots.flat());
31204
+ }
31151
31205
  interpreters(scope = "") {
31152
31206
  let found = this.binfmts.get(scope);
31153
31207
  if (!found) {