breakaway 1.0.2-main.15 → 1.0.2-main.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "breakaway",
3
- "version": "1.0.2-main.15",
3
+ "version": "1.0.2-main.17",
4
4
  "description": "The task board for you and your coding agents: a Cloudflare Worker, its web app, Taskwarrior sync, and the CLI (npx breakaway).",
5
5
  "license": "FSL-1.1-Apache-2.0",
6
6
  "type": "module",
@@ -4,7 +4,7 @@
4
4
  * Each returns null/undefined rather than throwing when something's missing, because the hooks stay quiet.
5
5
  */
6
6
  import { execFileSync } from 'node:child_process';
7
- import { existsSync, readFileSync } from 'node:fs';
7
+ import { existsSync, readFileSync, rmSync } from 'node:fs';
8
8
  import { homedir } from 'node:os';
9
9
  import { join } from 'node:path';
10
10
  import { boardUrl, configDir, parseEnvFile, readSetting } from './settings.js';
@@ -73,3 +73,13 @@ export function boardConfig(root = projectRoot()) {
73
73
  const token = readSetting('TOKEN', { env: process.env, file });
74
74
  return { base: url, headers: token ? { Authorization: `Bearer ${token}` } : {} };
75
75
  }
76
+
77
+ /** The board says this checkout's task isn't claimed by its agent any more: drop the marker so later calls post nothing (BRK-87). */
78
+ export function dropClaim(claim, root = projectRoot()) {
79
+ try {
80
+ const marker = join(root, '.task-session');
81
+ if (JSON.parse(readFileSync(marker, 'utf8'))?.uuid === claim.uuid) rmSync(marker);
82
+ } catch {
83
+ /* already gone */
84
+ }
85
+ }
@@ -10,10 +10,10 @@
10
10
  * BREAKAWAY_SESSION_LOG=off (or SAMEWAVE_TASKS_SESSION_LOG=off), or on any error, it does nothing and exits 0. A post
11
11
  * that fails leaves its reason in the temp folder, which the CLI's next command here shows (BRK-86).
12
12
  */
13
- import { boardConfig, claimedTask, projectRoot } from './hook-config.js';
13
+ import { boardConfig, claimedTask, dropClaim, projectRoot } from './hook-config.js';
14
14
  import { clearHookFailure, noteHookFailure, sessionRequest } from './proxy.js';
15
15
  import { entryFor } from './session-log.js';
16
- import { CONTEXT_EVENTS, messageOutput } from './session-messages.js';
16
+ import { CONTEXT_EVENTS, messageOutput, releasedOutput } from './session-messages.js';
17
17
 
18
18
  async function main() {
19
19
  const root = projectRoot();
@@ -49,7 +49,14 @@ async function main() {
49
49
  }
50
50
  if (!res.ok) return noteHookFailure(claim.uuid, `HTTP ${res.status}`);
51
51
  clearHookFailure(claim.uuid);
52
- const output = messageOutput(await res.json(), hook.hook_event_name);
52
+ const answer = await res.json();
53
+ if (answer?.released) {
54
+ dropClaim(claim, root);
55
+ const output = releasedOutput(claim, hook.hook_event_name);
56
+ if (output) process.stdout.write(`${JSON.stringify(output)}\n`);
57
+ return;
58
+ }
59
+ const output = messageOutput(answer, hook.hook_event_name);
53
60
  if (output) process.stdout.write(`${JSON.stringify(output)}\n`);
54
61
  }
55
62
 
@@ -27,6 +27,13 @@ export function messageOutput(answer, event) {
27
27
  return { hookSpecificOutput: { hookEventName: event, additionalContext: text } };
28
28
  }
29
29
 
30
+ /** The one line the hook says when the board no longer has this checkout's task claimed by its agent (BRK-87), or null on an event that can't carry it. */
31
+ export function releasedOutput(claim, event) {
32
+ if (!CONTEXT_EVENTS.has(event)) return null;
33
+ const text = `${claim.wid ?? 'The task'} is no longer claimed by ${claim.agent ?? 'this agent'} (finished or released), so this checkout stops sending its live output. \`tasks claim\` starts it again on another task.`;
34
+ return { hookSpecificOutput: { hookEventName: event, additionalContext: text } };
35
+ }
36
+
30
37
  /** The board's answer → the messages as Claude reads them, one paragraph each, or '' when there are none. */
31
38
  export function messageText(answer) {
32
39
  const messages = Array.isArray(answer?.messages) ? answer.messages : [];
@@ -2,8 +2,7 @@
2
2
  * The version of the board's CLI and the files repos init copies with it (CLD-193). The board reports it
3
3
  * (every API answer's X-Tasks-Cli header, and health), so a copy in another repository can say it's older
4
4
  * and how to update it. scripts/tasks/version.test.js fails when the copied files change and this doesn't:
5
- * bump CLI_VERSION and set CLI_FINGERPRINT to the value it prints. Constants only: the board's Worker imports it,
6
5
  * so it lives in the board's package (CLD-135) and the CLI imports it from here.
7
6
  */
8
- export const CLI_VERSION = 41;
9
- export const CLI_FINGERPRINT = 'f527cead53066a35';
7
+ export const CLI_VERSION = 43;
8
+ export const CLI_FINGERPRINT = 'df7a5c482c51dd49';