@moxt-ai/cli 0.12.2 → 0.12.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.
package/dist/index.cjs CHANGED
@@ -9335,14 +9335,17 @@ var require_ignore = __commonJS({
9335
9335
  });
9336
9336
 
9337
9337
  // ../machine-connector/dist/runtime/local-codex-runtime/local-file-source.js
9338
- function isPathWithin(path4, directory) {
9339
- return path4 === directory || path4.startsWith(`${directory}/`);
9340
- }
9341
- function isStrictAncestorPath(path4, child) {
9342
- if (child === void 0)
9343
- return false;
9344
- const normalizedPath = path4 === "." ? "" : path4;
9345
- return normalizedPath === "" ? child !== "" : child.startsWith(`${normalizedPath}/`);
9338
+ function unignoreDirectory(rules, rootPath) {
9339
+ for (const rule of rules) {
9340
+ const localPath = relativePortable(rule.base, rootPath);
9341
+ if (localPath === void 0 || localPath === ".")
9342
+ continue;
9343
+ const localSegments = localPath.split("/");
9344
+ for (let index2 = 0; index2 < localSegments.length; index2 += 1) {
9345
+ const directory = localSegments.slice(0, index2 + 1).join("/");
9346
+ rule.matcher.add(`!/${directory}/`);
9347
+ }
9348
+ }
9346
9349
  }
9347
9350
  function resolveWithin(root, input) {
9348
9351
  if (input.length === 0 || input.includes("\0") || (0, import_node_path9.isAbsolute)(input) || import_node_path9.win32.isAbsolute(input) || /^[A-Za-z]:/.test(input) || input.split(/[\\/]/).includes("..")) {
@@ -9432,8 +9435,8 @@ var init_local_file_source = __esm({
9432
9435
  }
9433
9436
  async list(relativeDirectory = ".", cursor, requestedLimit = defaultPageSize) {
9434
9437
  const limit = clampLimit(requestedLimit);
9435
- const directory = await this.resolveDirectory(relativeDirectory);
9436
- const matcher = await this.ignoreMatcher(directory);
9438
+ const directory = await this.resolveDirectory(relativeDirectory, "browsable");
9439
+ const matcher = await this.ignoreMatcher(directory, directory);
9437
9440
  const candidates2 = await Promise.all((await (0, import_promises12.readdir)(directory, { withFileTypes: true })).map(async (entry) => {
9438
9441
  if (entry.name.includes("\\"))
9439
9442
  return void 0;
@@ -9524,7 +9527,7 @@ var init_local_file_source = __esm({
9524
9527
  detectSupportedImageType(await (0, import_promises12.readFile)(target));
9525
9528
  return entry;
9526
9529
  }
9527
- async resolveDirectory(path4) {
9530
+ async resolveDirectory(path4, visibility = "visible") {
9528
9531
  const absolute = resolveWithin(this.workingDirectory, path4);
9529
9532
  const directStat = await (0, import_promises12.lstat)(absolute);
9530
9533
  if (directStat.isSymbolicLink() || !directStat.isDirectory()) {
@@ -9532,7 +9535,9 @@ var init_local_file_source = __esm({
9532
9535
  }
9533
9536
  const canonical = await (0, import_promises12.realpath)(absolute);
9534
9537
  assertContained(this.workingDirectory, canonical);
9535
- await this.assertVisible(canonical);
9538
+ if (visibility === "visible" || isGitPath(portable((0, import_node_path9.relative)(this.pairedRoot, canonical)))) {
9539
+ await this.assertVisible(canonical, "directory");
9540
+ }
9536
9541
  return canonical;
9537
9542
  }
9538
9543
  async resolveFile(path4) {
@@ -9542,23 +9547,23 @@ var init_local_file_source = __esm({
9542
9547
  throw new Error("Local file path is not a regular file");
9543
9548
  const canonical = await (0, import_promises12.realpath)(absolute);
9544
9549
  assertContained(this.workingDirectory, canonical);
9545
- await this.assertVisible(canonical);
9550
+ await this.assertVisible(canonical, "file");
9546
9551
  return canonical;
9547
9552
  }
9548
- async assertVisible(absolute) {
9553
+ async assertVisible(absolute, kind) {
9549
9554
  const rootPath = portable((0, import_node_path9.relative)(this.pairedRoot, absolute));
9550
9555
  if (rootPath === ".")
9551
9556
  return;
9552
- if (isGitPath(rootPath) || (await this.ignoreMatcher((0, import_node_path9.dirname)(absolute))).ignores(rootPath)) {
9557
+ const explicitDirectory = kind === "directory" ? absolute : (0, import_node_path9.dirname)(absolute);
9558
+ if (isGitPath(rootPath) || (await this.ignoreMatcher((0, import_node_path9.dirname)(absolute), explicitDirectory)).ignores(rootPath)) {
9553
9559
  throw new Error("Local file path is ignored");
9554
9560
  }
9555
9561
  }
9556
- async ignoreMatcher(throughDirectory) {
9562
+ async ignoreMatcher(throughDirectory, explicitDirectory) {
9557
9563
  const matchers = [{ base: "", matcher: (0, import_ignore.default)().add(".git/").add(".git/**") }];
9558
9564
  const relativeThrough = (0, import_node_path9.relative)(this.pairedRoot, throughDirectory);
9559
9565
  const segments = relativeThrough === "" ? [] : relativeThrough.split(import_node_path9.sep);
9560
9566
  const workingDirectoryRootPath = portable((0, import_node_path9.relative)(this.pairedRoot, this.workingDirectory));
9561
- const workingDirectorySegments = workingDirectoryRootPath === "." ? [] : workingDirectoryRootPath.split("/");
9562
9567
  let directory = this.pairedRoot;
9563
9568
  for (let index2 = 0; index2 <= segments.length; index2 += 1) {
9564
9569
  const matcher = (0, import_ignore.default)();
@@ -9576,28 +9581,29 @@ var init_local_file_source = __esm({
9576
9581
  if (segment !== void 0)
9577
9582
  directory = (0, import_node_path9.join)(directory, segment);
9578
9583
  }
9579
- if (workingDirectorySegments.length === 0) {
9580
- return new ScopedIgnoreMatcher(matchers);
9584
+ const explicitDirectories = [workingDirectoryRootPath];
9585
+ if (explicitDirectory !== void 0) {
9586
+ explicitDirectories.push(portable((0, import_node_path9.relative)(this.pairedRoot, explicitDirectory)));
9581
9587
  }
9582
- const inheritedMatchers = matchers.slice(0, workingDirectorySegments.length + 1);
9583
- const workingDirectoryIsIgnored = new ScopedIgnoreMatcher(inheritedMatchers).ignores(workingDirectoryRootPath);
9584
- return new ScopedIgnoreMatcher(matchers, workingDirectoryIsIgnored ? workingDirectoryRootPath : void 0);
9588
+ for (const candidate of new Set(explicitDirectories)) {
9589
+ if (candidate === ".")
9590
+ continue;
9591
+ unignoreDirectory(matchers, candidate);
9592
+ }
9593
+ return new ScopedIgnoreMatcher(matchers);
9585
9594
  }
9586
9595
  };
9587
9596
  ScopedIgnoreMatcher = class {
9588
9597
  rules;
9589
- ignoredWorkingDirectory;
9590
- constructor(rules, ignoredWorkingDirectory) {
9598
+ constructor(rules) {
9591
9599
  this.rules = rules;
9592
- this.ignoredWorkingDirectory = ignoredWorkingDirectory;
9593
9600
  }
9594
9601
  ignores(rootPath) {
9602
+ return this.evaluate(rootPath);
9603
+ }
9604
+ evaluate(rootPath) {
9595
9605
  let ignored = false;
9596
- const skipInheritedRules = this.ignoredWorkingDirectory !== void 0 && isPathWithin(rootPath, this.ignoredWorkingDirectory);
9597
9606
  for (const rule of this.rules) {
9598
- if (skipInheritedRules && isStrictAncestorPath(rule.base, this.ignoredWorkingDirectory)) {
9599
- continue;
9600
- }
9601
9607
  const localPath = relativePortable(rule.base, rootPath);
9602
9608
  if (localPath === void 0 || localPath === ".")
9603
9609
  continue;
@@ -16629,7 +16635,7 @@ function getApiKeyOrUndefined() {
16629
16635
 
16630
16636
  // src/utils/http.ts
16631
16637
  function getUserAgent() {
16632
- return `moxt-cli/${"0.12.2"} (${(0, import_os.platform)()}/${(0, import_os.arch)()}) node/${process.versions.node}`;
16638
+ return `moxt-cli/${"0.12.3"} (${(0, import_os.platform)()}/${(0, import_os.arch)()}) node/${process.versions.node}`;
16633
16639
  }
16634
16640
  async function sendRequest(method, path4, init) {
16635
16641
  return await fetch(`${getApiBaseUrl()}${path4}`, {
@@ -31215,7 +31221,7 @@ var FLUSH_TIMEOUT_MS = 3e3;
31215
31221
  var MAX_BATCH_SIZE = 100;
31216
31222
  function commonLabels() {
31217
31223
  return {
31218
- cli_version: "0.12.2",
31224
+ cli_version: "0.12.3",
31219
31225
  node_version: process.versions.node,
31220
31226
  os: (0, import_node_os11.platform)(),
31221
31227
  arch: (0, import_node_os11.arch)(),
@@ -31261,7 +31267,7 @@ async function flush() {
31261
31267
  }
31262
31268
  const batch = buffer.splice(0, MAX_BATCH_SIZE);
31263
31269
  const payload = {
31264
- release_id: "0.12.2",
31270
+ release_id: "0.12.3",
31265
31271
  client_type: "cli",
31266
31272
  metric_data_list: batch.map((m) => ({
31267
31273
  profile: "cli",
@@ -31644,9 +31650,9 @@ function commandPath3(command) {
31644
31650
  }
31645
31651
 
31646
31652
  // src/index.ts
31647
- var program2 = createProgram("0.12.2");
31648
- installDaemonReconcileHook(program2, "0.12.2");
31649
- installUpdateHook(program2, "0.12.2");
31653
+ var program2 = createProgram("0.12.3");
31654
+ installDaemonReconcileHook(program2, "0.12.3");
31655
+ installUpdateHook(program2, "0.12.3");
31650
31656
  instrumentProgram(program2);
31651
31657
  installExitHandler();
31652
31658
  program2.parseAsync(process.argv).then(async () => {