@adhdev/daemon-standalone 0.8.4 → 0.8.5

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.js CHANGED
@@ -34609,6 +34609,37 @@ ${data.message || ""}`.trim();
34609
34609
  }
34610
34610
  return resolved;
34611
34611
  }
34612
+ function listDirectoryEntriesSafe(dirPath) {
34613
+ const entries = fs42.readdirSync(dirPath, { withFileTypes: true });
34614
+ const files = [];
34615
+ for (const entry of entries) {
34616
+ const entryPath = path6.join(dirPath, entry.name);
34617
+ try {
34618
+ if (entry.isDirectory()) {
34619
+ files.push({ name: entry.name, type: "directory" });
34620
+ continue;
34621
+ }
34622
+ if (entry.isFile()) {
34623
+ let size;
34624
+ try {
34625
+ size = fs42.statSync(entryPath).size;
34626
+ } catch {
34627
+ size = void 0;
34628
+ }
34629
+ files.push({ name: entry.name, type: "file", size });
34630
+ continue;
34631
+ }
34632
+ const stat4 = fs42.statSync(entryPath);
34633
+ files.push({
34634
+ name: entry.name,
34635
+ type: stat4.isDirectory() ? "directory" : "file",
34636
+ size: stat4.isFile() ? stat4.size : void 0
34637
+ });
34638
+ } catch {
34639
+ }
34640
+ }
34641
+ return files;
34642
+ }
34612
34643
  async function handleFileRead(h, args) {
34613
34644
  try {
34614
34645
  const filePath = resolveSafePath(args?.path);
@@ -34631,19 +34662,20 @@ ${data.message || ""}`.trim();
34631
34662
  async function handleFileList(h, args) {
34632
34663
  try {
34633
34664
  const dirPath = resolveSafePath(args?.path || ".");
34634
- const entries = fs42.readdirSync(dirPath, { withFileTypes: true });
34635
- const files = entries.map((e) => ({
34636
- name: e.name,
34637
- type: e.isDirectory() ? "directory" : "file",
34638
- size: e.isFile() ? fs42.statSync(path6.join(dirPath, e.name)).size : void 0
34639
- }));
34665
+ const files = listDirectoryEntriesSafe(dirPath);
34640
34666
  return { success: true, files, path: dirPath };
34641
34667
  } catch (e) {
34642
34668
  return { success: false, error: e.message };
34643
34669
  }
34644
34670
  }
34645
34671
  async function handleFileListBrowse(h, args) {
34646
- return handleFileList(h, args);
34672
+ try {
34673
+ const dirPath = resolveSafePath(args?.path || ".");
34674
+ const files = listDirectoryEntriesSafe(dirPath).filter((entry) => entry.type === "directory").sort((a, b2) => a.name.localeCompare(b2.name));
34675
+ return { success: true, files, path: dirPath };
34676
+ } catch (e) {
34677
+ return { success: false, error: e.message };
34678
+ }
34647
34679
  }
34648
34680
  init_logger();
34649
34681
  function getCliPresentationMode(h, targetSessionId) {