@joshski/dust 0.1.34 → 0.1.35

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 (2) hide show
  1. package/dist/dust.js +37 -27
  2. package/package.json +1 -1
package/dist/dust.js CHANGED
@@ -1,10 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { createRequire } from "node:module";
3
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
4
-
5
2
  // lib/cli/run.ts
6
3
  import { existsSync } from "node:fs";
7
- import { chmod, mkdir, readdir, readFile, writeFile } from "node:fs/promises";
4
+ import { chmod as chmod2, mkdir as mkdir2, readdir as readdir2, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
8
5
 
9
6
  // lib/config/settings.ts
10
7
  import { join } from "node:path";
@@ -543,6 +540,9 @@ async function audit(dependencies) {
543
540
 
544
541
  // lib/cli/commands/bucket.ts
545
542
  import { spawn as nodeSpawn3 } from "node:child_process";
543
+ import { accessSync } from "node:fs";
544
+ import { chmod, mkdir, readdir, readFile, writeFile } from "node:fs/promises";
545
+ import { createServer as httpCreateServer } from "node:http";
546
546
  import { homedir, tmpdir } from "node:os";
547
547
 
548
548
  // lib/bucket/auth.ts
@@ -2071,11 +2071,30 @@ function defaultWriteStdout(data) {
2071
2071
  process.stdout.write(data);
2072
2072
  }
2073
2073
  function defaultCreateServer(handler) {
2074
- const server = Bun.serve({
2075
- port: 0,
2076
- fetch: handler
2074
+ let resolvedPort = 0;
2075
+ const server = httpCreateServer(async (nodeRequest, nodeResponse) => {
2076
+ const url = new URL(nodeRequest.url ?? "/", `http://localhost:${resolvedPort}`);
2077
+ const request = new Request(url.toString(), {
2078
+ method: nodeRequest.method ?? "GET"
2079
+ });
2080
+ const response = handler(request);
2081
+ const body = await response.text();
2082
+ nodeResponse.writeHead(response.status, {
2083
+ "Content-Type": response.headers.get("content-type") ?? "text/plain"
2084
+ });
2085
+ nodeResponse.end(body);
2077
2086
  });
2078
- return { port: server.port ?? 0, stop: () => server.stop() };
2087
+ server.listen(0, () => {
2088
+ const addr2 = server.address();
2089
+ if (addr2 && typeof addr2 === "object") {
2090
+ resolvedPort = addr2.port;
2091
+ }
2092
+ });
2093
+ const addr = server.address();
2094
+ if (addr && typeof addr === "object") {
2095
+ resolvedPort = addr.port;
2096
+ }
2097
+ return { port: resolvedPort, stop: () => server.close() };
2079
2098
  }
2080
2099
  function defaultOpenBrowser(url) {
2081
2100
  const cmd = process.platform === "darwin" ? "open" : "xdg-open";
@@ -2085,26 +2104,17 @@ function createDefaultBucketDependencies() {
2085
2104
  const authFileSystem = {
2086
2105
  exists: (path) => {
2087
2106
  try {
2088
- const file = Bun.file(path);
2089
- return file.size > 0;
2107
+ accessSync(path);
2108
+ return true;
2090
2109
  } catch {
2091
2110
  return false;
2092
2111
  }
2093
2112
  },
2094
- readFile: (path) => Bun.file(path).text(),
2095
- writeFile: (path, content) => Bun.write(path, content).then(() => {}),
2096
- mkdir: (path, options) => {
2097
- const { mkdir } = __require("node:fs/promises");
2098
- return mkdir(path, options);
2099
- },
2100
- readdir: (path) => {
2101
- const { readdir } = __require("node:fs/promises");
2102
- return readdir(path);
2103
- },
2104
- chmod: (path, mode) => {
2105
- const { chmod } = __require("node:fs/promises");
2106
- return chmod(path, mode);
2107
- }
2113
+ readFile: (path) => readFile(path, "utf8"),
2114
+ writeFile: (path, content) => writeFile(path, content, "utf8"),
2115
+ mkdir: (path, options) => mkdir(path, options).then(() => {}),
2116
+ readdir: (path) => readdir(path),
2117
+ chmod: (path, mode) => chmod(path, mode)
2108
2118
  };
2109
2119
  return {
2110
2120
  spawn: nodeSpawn3,
@@ -3766,10 +3776,10 @@ function createFileSystem(primitives) {
3766
3776
  chmod: (path, mode) => primitives.chmod(path, mode)
3767
3777
  };
3768
3778
  }
3769
- function createGlobScanner(readdir) {
3779
+ function createGlobScanner(readdir2) {
3770
3780
  return {
3771
3781
  scan: async function* (dir) {
3772
- for (const entry of await readdir(dir, { recursive: true })) {
3782
+ for (const entry of await readdir2(dir, { recursive: true })) {
3773
3783
  if (entry.endsWith(".md"))
3774
3784
  yield entry;
3775
3785
  }
@@ -3793,4 +3803,4 @@ async function wireEntry(fsPrimitives, processPrimitives, consolePrimitives) {
3793
3803
  }
3794
3804
 
3795
3805
  // lib/cli/run.ts
3796
- await wireEntry({ existsSync, readFile, writeFile, mkdir, readdir, chmod }, { argv: process.argv, cwd: () => process.cwd(), exit: process.exit }, { log: console.log, error: console.error });
3806
+ await wireEntry({ existsSync, readFile: readFile2, writeFile: writeFile2, mkdir: mkdir2, readdir: readdir2, chmod: chmod2 }, { argv: process.argv, cwd: () => process.cwd(), exit: process.exit }, { log: console.log, error: console.error });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joshski/dust",
3
- "version": "0.1.34",
3
+ "version": "0.1.35",
4
4
  "description": "Flow state for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {