@atolis-hq/wake 0.3.14 → 0.3.16

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.
@@ -8,20 +8,13 @@ export function createSourceUpdatePort(input) {
8
8
  return (await execute('git', ['status', '--porcelain'], input.repoRoot)).trim().length === 0;
9
9
  },
10
10
  async latestTag() {
11
- const tag = (await execute('git', ['tag', '--sort=-v:refname'], input.repoRoot))
12
- .split(/\r?\n/u)
13
- .find((value) => value.trim().length > 0)
14
- ?.trim();
11
+ const tag = (await candidateTags(execute, input.repoRoot)).at(0);
15
12
  if (tag === undefined)
16
13
  throw new Error('No source version tag is available');
17
14
  return tag;
18
15
  },
19
16
  async candidateTags() {
20
- const output = await execute('git', ['tag', '--sort=-v:refname'], input.repoRoot);
21
- return output
22
- .split(/\r?\n/u)
23
- .map((line) => line.trim())
24
- .filter((line) => line.length > 0);
17
+ return candidateTags(execute, input.repoRoot);
25
18
  },
26
19
  async checkout(tag) {
27
20
  await execute('git', ['checkout', tag], input.repoRoot);
@@ -41,6 +34,14 @@ export function createSourceUpdatePort(input) {
41
34
  },
42
35
  };
43
36
  }
37
+ async function candidateTags(execute, repoRoot) {
38
+ await execute('git', ['fetch', '--tags'], repoRoot);
39
+ const output = await execute('git', ['tag', '--list', 'v*', '--sort=-v:refname'], repoRoot);
40
+ return output
41
+ .split(/\r?\n/u)
42
+ .map((line) => line.trim())
43
+ .filter((line) => line.length > 0);
44
+ }
44
45
  async function runProcess(command, args, cwd) {
45
46
  const result = await execFile(command, args, { cwd, encoding: 'utf8' });
46
47
  return result.stdout;
@@ -108,4 +108,4 @@ export function resolveWakeVersion(options = {}) {
108
108
  return `g${headHash.slice(0, 7)}`;
109
109
  return '0.1.0-dev';
110
110
  }
111
- export const wakeVersion = "gcf59f54";
111
+ export const wakeVersion = "g67a13f9";
@@ -1,29 +1,29 @@
1
- import { spawn } from 'node:child_process';
1
+ import { execa } from 'execa';
2
2
  export function runProcess(command, args, cwd, signal, timeoutMs) {
3
- const child = spawn(command, args, { cwd, shell: false, stdio: ['ignore', 'pipe', 'pipe'] });
4
- const result = new Promise((resolve, reject) => {
5
- let stdout = '';
6
- let stderr = '';
7
- let timedOut = false;
8
- const timeout = timeoutMs === undefined
9
- ? undefined
10
- : setTimeout(() => {
11
- timedOut = true;
12
- child.kill();
13
- }, timeoutMs);
14
- child.stdout.on('data', (chunk) => (stdout += chunk.toString()));
15
- child.stderr.on('data', (chunk) => (stderr += chunk.toString()));
16
- child.once('error', (error) => {
17
- if (timeout !== undefined)
18
- clearTimeout(timeout);
19
- reject(error);
20
- });
21
- child.once('close', (exitCode) => {
22
- if (timeout !== undefined)
23
- clearTimeout(timeout);
24
- resolve({ stdout, stderr, exitCode, timedOut });
25
- });
3
+ const child = execa(command, args, {
4
+ ...(cwd === undefined ? {} : { cwd }),
5
+ shell: false,
6
+ stdin: 'ignore',
7
+ stdout: 'pipe',
8
+ stderr: 'pipe',
9
+ cancelSignal: signal,
10
+ ...(timeoutMs === undefined ? {} : { timeout: timeoutMs }),
11
+ reject: false,
12
+ stripFinalNewline: false,
26
13
  });
27
- signal.addEventListener('abort', () => child.kill(), { once: true });
28
- return { result, cancel: async () => void child.kill() };
14
+ return {
15
+ result: child.then((result) => ({
16
+ stdout: result.stdout,
17
+ stderr: result.stderr,
18
+ exitCode: result.exitCode,
19
+ timedOut: result.timedOut,
20
+ ...(result.isMaxBuffer
21
+ ? {
22
+ failureKind: 'output-limit',
23
+ ...(result.shortMessage === undefined ? {} : { failureMessage: result.shortMessage }),
24
+ }
25
+ : {}),
26
+ })),
27
+ cancel: async () => void child.kill(),
28
+ };
29
29
  }
@@ -99,10 +99,12 @@ export function cliRunner(name, command, args, options = {}) {
99
99
  output: value.stdout,
100
100
  runner: name,
101
101
  failure: {
102
- kind: value.timedOut ? ExecutionCancellationReason.Timeout : 'process-exit',
102
+ kind: value.timedOut
103
+ ? ExecutionCancellationReason.Timeout
104
+ : (value.failureKind ?? 'process-exit'),
103
105
  message: value.timedOut
104
106
  ? `Runner timed out after ${options.timeoutMs}ms`
105
- : value.stderr || `exit ${value.exitCode}`,
107
+ : (value.failureMessage ?? (value.stderr || `exit ${value.exitCode}`)),
106
108
  },
107
109
  }),
108
110
  cancel: process.cancel,
@@ -3,7 +3,14 @@ export async function runSelfUpdate(input) {
3
3
  if (!input.force && (await input.readLedger()) === input.tag)
4
4
  return false;
5
5
  const priorTag = await input.readLedger();
6
- await input.update(input.tag);
6
+ try {
7
+ await input.update(input.tag);
8
+ }
9
+ catch (error) {
10
+ if (priorTag !== null && input.rollback !== undefined)
11
+ await input.rollback(priorTag);
12
+ throw error;
13
+ }
7
14
  if (input.health !== undefined && !(await input.health())) {
8
15
  if (priorTag !== null && input.rollback !== undefined)
9
16
  await input.rollback(priorTag);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atolis-hq/wake",
3
- "version": "0.3.14",
3
+ "version": "0.3.16",
4
4
  "description": "Local autonomous agent control plane for software development",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -66,6 +66,7 @@
66
66
  },
67
67
  "dependencies": {
68
68
  "@octokit/rest": "^22.0.0",
69
+ "execa": "^10.0.1",
69
70
  "handlebars": "^4.7.9",
70
71
  "ulid": "^3.0.2",
71
72
  "yaml": "^2.9.0",