@loadmill/droid-cua 1.1.1 → 1.1.2

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.
@@ -1,8 +1,7 @@
1
- import { readdir, readFile, writeFile, unlink, stat } from "fs/promises";
1
+ import { readdir, readFile, writeFile, unlink, stat, mkdir } from "fs/promises";
2
2
  import path from "path";
3
- import { fileURLToPath } from "url";
4
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
5
- const TESTS_DIR = path.join(__dirname, "../../tests");
3
+ // Tests directory is relative to current working directory
4
+ const TESTS_DIR = path.join(process.cwd(), "tests");
6
5
  /**
7
6
  * Save a test script to the tests/ directory
8
7
  * @param {string} name - Test name (without .dcua extension)
@@ -14,6 +13,8 @@ export async function saveTest(name, content) {
14
13
  const cleanName = name.endsWith(".dcua") ? name.slice(0, -5) : name;
15
14
  const filename = `${cleanName}.dcua`;
16
15
  const filepath = path.join(TESTS_DIR, filename);
16
+ // Create tests directory if it doesn't exist
17
+ await mkdir(TESTS_DIR, { recursive: true });
17
18
  await writeFile(filepath, content, "utf-8");
18
19
  return filepath;
19
20
  }
@@ -46,6 +47,13 @@ export async function getTestContent(name) {
46
47
  * @returns {Promise<Array<{name: string, path: string, lines: number, modified: Date}>>}
47
48
  */
48
49
  export async function listTests() {
50
+ // Return empty array if tests directory doesn't exist
51
+ try {
52
+ await stat(TESTS_DIR);
53
+ }
54
+ catch {
55
+ return [];
56
+ }
49
57
  const files = await readdir(TESTS_DIR);
50
58
  const dcuaFiles = files.filter(f => f.endsWith(".dcua"));
51
59
  const tests = await Promise.all(dcuaFiles.map(async (filename) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loadmill/droid-cua",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "AI-powered Android testing agent using OpenAI's computer-use model and ADB",
5
5
  "main": "build/index.js",
6
6
  "type": "module",