@qablehq/atto 0.0.31 → 0.0.33

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/bin/atto.js CHANGED
@@ -1,50 +1,104 @@
1
1
  #!/usr/bin/env node
2
2
  // Opens the built Atto desktop window. Installed as the `atto` command.
3
- // If a silent update was queued on the previous quit, kick it off in the
4
- // background — never block the window on npm install.
3
+ //
4
+ // Silent updates must NOT rewrite this package while Electron is loading it.
5
+ // If an update is pending, finish npm install first, then open the window.
5
6
  const { spawn, spawnSync } = require("node:child_process");
6
7
  const fs = require("node:fs");
7
8
  const os = require("node:os");
8
9
  const path = require("node:path");
9
10
 
10
11
  const PENDING_FILE = path.join(os.homedir(), ".atto", "pending-npm-update.json");
12
+ const LOCK_FILE = path.join(os.homedir(), ".atto", "npm-update.lock");
11
13
 
12
- function kickPendingSilentUpdate() {
13
- let pending;
14
+ function readPending() {
14
15
  try {
15
- pending = JSON.parse(fs.readFileSync(PENDING_FILE, "utf8"));
16
+ return JSON.parse(fs.readFileSync(PENDING_FILE, "utf8"));
16
17
  } catch {
17
- return;
18
+ return null;
19
+ }
20
+ }
21
+
22
+ function clearPending() {
23
+ try {
24
+ fs.unlinkSync(PENDING_FILE);
25
+ } catch {
26
+ /* ignore */
18
27
  }
28
+ }
29
+
30
+ function clearLock() {
31
+ try {
32
+ fs.unlinkSync(LOCK_FILE);
33
+ } catch {
34
+ /* ignore */
35
+ }
36
+ }
37
+
38
+ function appLooksComplete(appDir) {
39
+ return (
40
+ fs.existsSync(path.join(appDir, "package.json")) &&
41
+ fs.existsSync(path.join(appDir, "out", "renderer", "index.html")) &&
42
+ fs.existsSync(path.join(appDir, "out", "main", "index.js"))
43
+ );
44
+ }
45
+
46
+ /**
47
+ * Apply a queued npm update before Electron starts.
48
+ * In-place `npm install -g` replaces files under this package — never race that
49
+ * with window open (clients would see missing package.json / index.html).
50
+ */
51
+ function applyPendingUpdateBeforeOpen(appDir) {
52
+ const pending = readPending();
19
53
  if (!pending?.name || !pending?.version) {
20
- try {
21
- fs.unlinkSync(PENDING_FILE);
22
- } catch {
23
- /* ignore */
24
- }
54
+ if (pending) clearPending();
25
55
  return;
26
56
  }
27
57
 
28
- const npm = process.platform === "win32" ? "npm.cmd" : "npm";
29
- const args = ["install", "-g", `${pending.name}@${pending.version}`, "--silent", "--no-fund", "--no-audit"];
30
- if (pending.prefix) args.push("--prefix", pending.prefix);
31
-
32
- // Fire-and-forget: this session keeps the current build; next `atto` gets the update.
33
- // Do not wait — spawnSync here used to delay open by minutes on slow networks.
34
- try {
35
- const child = spawn(npm, args, {
36
- detached: true,
58
+ // Another atto may already be installing; wait briefly for lock, then proceed.
59
+ const started = Date.now();
60
+ while (fs.existsSync(LOCK_FILE) && Date.now() - started < 120_000) {
61
+ spawnSync(process.execPath, ["-e", "Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,500)"], {
37
62
  stdio: "ignore",
38
- windowsHide: true,
39
63
  });
40
- child.unref();
41
- try {
42
- fs.unlinkSync(PENDING_FILE);
43
- } catch {
44
- /* ignore */
45
- }
64
+ if (appLooksComplete(appDir) && !readPending()) return;
65
+ }
66
+
67
+ try {
68
+ fs.mkdirSync(path.dirname(LOCK_FILE), { recursive: true });
69
+ fs.writeFileSync(
70
+ LOCK_FILE,
71
+ JSON.stringify({ version: pending.version, pid: process.pid, at: new Date().toISOString() }),
72
+ "utf8",
73
+ );
46
74
  } catch {
47
- /* keep pending file for next open */
75
+ /* best effort */
76
+ }
77
+
78
+ console.log(`Updating Atto to ${pending.version}…`);
79
+ const npm = process.platform === "win32" ? "npm.cmd" : "npm";
80
+ const args = ["install", "-g", `${pending.name}@${pending.version}`, "--no-fund", "--no-audit"];
81
+ if (pending.prefix) args.push("--prefix", pending.prefix);
82
+
83
+ const result = spawnSync(npm, args, {
84
+ stdio: "inherit",
85
+ windowsHide: true,
86
+ // Large Electron download can take a while on slow networks.
87
+ timeout: 10 * 60 * 1000,
88
+ });
89
+
90
+ clearLock();
91
+ if (result.status === 0 && appLooksComplete(appDir)) {
92
+ clearPending();
93
+ return;
94
+ }
95
+
96
+ // Keep pending so the next open retries; only open if current files are still usable.
97
+ if (!appLooksComplete(appDir)) {
98
+ console.error(
99
+ "Atto update did not finish cleanly. Try again, or run:\n npm install -g @qablehq/atto@latest --prefix \"$HOME/.local\"",
100
+ );
101
+ process.exit(1);
48
102
  }
49
103
  }
50
104
 
@@ -73,13 +127,12 @@ function ensureElectronBinary(electronPkgDir) {
73
127
  return result.status === 0 && electronLooksReady(electronPkgDir);
74
128
  }
75
129
 
76
- kickPendingSilentUpdate();
77
-
78
130
  const appDir = path.resolve(__dirname, "..");
79
- const rendererHtml = path.join(appDir, "out", "renderer", "index.html");
80
- if (!fs.existsSync(rendererHtml)) {
131
+ applyPendingUpdateBeforeOpen(appDir);
132
+
133
+ if (!appLooksComplete(appDir)) {
81
134
  console.error(
82
- "Atto UI files are missing (out/renderer/index.html). Reinstall with:\n npm install -g @qablehq/atto@latest --prefix \"$HOME/.local\""
135
+ "Atto UI files are missing. Reinstall with:\n npm install -g @qablehq/atto@latest --prefix \"$HOME/.local\"",
83
136
  );
84
137
  process.exit(1);
85
138
  }
@@ -92,7 +145,7 @@ try {
92
145
  console.error(
93
146
  "Electron failed to install. Fix with:\n cd \"" +
94
147
  path.join(appDir, "node_modules", "electron") +
95
- '" && node install.js'
148
+ '" && node install.js',
96
149
  );
97
150
  process.exit(1);
98
151
  }
package/out/main/index.js CHANGED
@@ -425,7 +425,7 @@ function attachEngineForRemoteAnswers(adapter) {
425
425
  function mirrorEngineEventToChat(event) {
426
426
  const jobId = remoteJobByDesktopSession.get(event.sessionId);
427
427
  if (!jobId) return;
428
- if (event.type !== "narration_step" && event.type !== "assertion_result" && event.type !== "stuck_question" && event.type !== "session_status_changed" && event.type !== "agent_log" && event.type !== "code_generated") {
428
+ if (event.type !== "narration_step" && event.type !== "assertion_result" && event.type !== "stuck_question" && event.type !== "session_status_changed" && event.type !== "agent_log" && event.type !== "code_generated" && event.type !== "quality_gate_report" && event.type !== "failure_diagnosis") {
429
429
  return;
430
430
  }
431
431
  if (event.type === "narration_step" && event.status === "in_progress") return;
@@ -12683,26 +12683,11 @@ function setupNpmUpdater() {
12683
12683
  const name = readPackageName();
12684
12684
  let pending = null;
12685
12685
  const prefix = detectNpmPrefix();
12686
- const installQuietly = (version) => {
12687
- const npm = process.platform === "win32" ? "npm.cmd" : "npm";
12688
- const args = ["install", "-g", `${name}@${version}`, "--silent", "--no-fund", "--no-audit"];
12689
- if (prefix) args.push("--prefix", prefix);
12690
- console.log(
12691
- `[npm-updater] installing ${name}@${version}${prefix ? ` --prefix ${prefix}` : ""} after quit`
12692
- );
12693
- const child = node_child_process.spawn(npm, args, {
12694
- detached: true,
12695
- stdio: "ignore",
12696
- windowsHide: true
12697
- });
12698
- child.unref();
12699
- };
12700
12686
  electron.app.on("before-quit", () => {
12701
12687
  if (!pending) return;
12702
- const version = pending;
12688
+ writePendingUpdate(name, pending, prefix);
12689
+ console.log(`[npm-updater] ${pending} queued — will install on next atto launch`);
12703
12690
  pending = null;
12704
- writePendingUpdate(name, version, prefix);
12705
- installQuietly(version);
12706
12691
  });
12707
12692
  const current = electron.app.getVersion();
12708
12693
  void (async () => {
@@ -12715,7 +12700,7 @@ function setupNpmUpdater() {
12715
12700
  if (!body.version || !isNewerVersion(body.version, current)) return;
12716
12701
  pending = body.version;
12717
12702
  writePendingUpdate(name, body.version, prefix);
12718
- console.log(`[npm-updater] ${body.version} queued for silent install on quit / next launch`);
12703
+ console.log(`[npm-updater] ${body.version} queued for install on next launch`);
12719
12704
  } catch (error) {
12720
12705
  console.error("[npm-updater] check failed", error);
12721
12706
  } finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qablehq/atto",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "description": "Atto — AI-assisted desktop test automation",
5
5
  "homepage": "https://github.com/QAbleHQ/Atto",
6
6
  "author": {