@phnx-labs/agents-cli 1.23.32 → 1.23.34
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/CHANGELOG.md +10 -0
- package/dist/lib/daemon/attention-notify-service.d.ts +3 -1
- package/dist/lib/daemon/attention-notify-service.js +47 -7
- package/dist/lib/daemon/finished-banners.d.ts +32 -0
- package/dist/lib/daemon/finished-banners.js +145 -0
- package/dist/lib/feed/hub.d.ts +4 -0
- package/dist/lib/feed/hub.js +9 -0
- package/dist/lib/feed/notify-schedule.js +2 -1
- package/dist/lib/session/active.d.ts +6 -1
- package/dist/lib/session/active.js +17 -1
- package/dist/lib/session/db.d.ts +3 -0
- package/dist/lib/session/db.js +9 -3
- package/dist/lib/session/discover.d.ts +11 -4
- package/dist/lib/session/discover.js +35 -6
- package/dist/lib/session/hook-sessions.d.ts +7 -0
- package/dist/lib/session/hook-sessions.js +17 -2
- package/dist/lib/session/touched.d.ts +30 -0
- package/dist/lib/session/touched.js +297 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.23.34
|
|
4
|
+
|
|
5
|
+
- **A session row says whether its last turn was done, and a finished turn posts a banner.** Live rows on `agents ps --json`, `agents ps watch --json` and `agents feed watch --json` (remote rows too) carry `doneVerdict: { state: 'done'|'open'|'unchecked', gaps, at }` from the Stop hook's verdict in `~/.agents/.cache/state/sessions/<pid>.json`, only when that record belongs to the row's live process. Off by default, an interactive session going from running to idle after at least 2 minutes of work can post one AGI Menu `done` banner: "✓ Done", "Not done" or "Finished" with the row's title, the verdict's gaps in words when it is open or else the first sentence of the agent's last line, and a tap opens the session. One banner per turn; three or more finishes that land together post one summary banner. The `menubar.menu.notifyLow` schedule governs it: its default `["sidebar"]` posts none, and `agents config set menubar.menu.notifyLow '["0m"]'` turns it on (low-urgency asks follow the same key). Source: cli/src/lib/session/hook-sessions.ts, cli/src/lib/session/active.ts, cli/src/lib/daemon/finished-banners.ts, cli/src/lib/daemon/attention-notify-service.ts
|
|
6
|
+
|
|
7
|
+
## 1.23.33
|
|
8
|
+
|
|
9
|
+
- **A Codex session that opened several PRs before the upgrade lists them all.** The resumable Codex parse state moves to v5, so a v4 checkpoint (written before the index recorded every PR) re-parses its transcript once instead of resuming with only its first PR, as Claude's v7 already does. Source: cli/src/lib/session/discover.ts
|
|
10
|
+
|
|
11
|
+
- **A live Claude row lists the PRs and tickets the session acted on.** `touchedPrs` (`[{ url, number, repo, action }]`, action `merged`, `reviewed`, `commented`, `checked out`, `edited` or `closed`) comes from `gh pr merge|review|comment|checkout|edit|close` and `agents projects prs merge|review|comment`; `touchedTickets` (`[{ id, action }]`) from `linear update`. Only calls that ran and succeeded count, newest first with the last action per item, leaving out what the session created itself (`prs`, `createdTickets`). Upgrading re-parses a Claude transcript from the start the next time it changes. Source: cli/src/lib/session/touched.ts, cli/src/lib/session/discover.ts, cli/src/lib/session/active.ts
|
|
12
|
+
|
|
3
13
|
## 1.23.32
|
|
4
14
|
|
|
5
15
|
- **A session row lists every PR the session opened (#3989).** The session index records each PR a Claude or Codex session created (`pr_urls`, schema v53), not only the first, and live and ended rows read it as `prs`, so a long session whose PR creations scrolled out of its transcript tail still lists them all. Upgrading re-parses only the transcripts of sessions that already have a PR. Source: cli/src/lib/session/discover.ts, cli/src/lib/session/db.ts, cli/src/lib/session/active.ts
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* `interactive.host` unset: this host's asks; this machine: every host's, from
|
|
8
8
|
* the shared fleet collector; another machine: none. The ledger under
|
|
9
9
|
* `feed/notified/` (`<key>`, `<key>#r<n>`) makes a restart re-send nothing.
|
|
10
|
-
* `done` banners
|
|
10
|
+
* Finished interactive turns post `done` banners here too (`finished-banners.ts`, docs/menubar.md).
|
|
11
11
|
*/
|
|
12
12
|
import { type ActiveSession } from '../session/active.js';
|
|
13
13
|
import { type AttentionItem, type AttentionUrgency } from '../feed/attention.js';
|
|
@@ -63,11 +63,13 @@ export declare class AttentionNotifyService extends BasePeriodicService {
|
|
|
63
63
|
private banners;
|
|
64
64
|
private fleetHub;
|
|
65
65
|
private detachFleet;
|
|
66
|
+
private readonly finishes;
|
|
66
67
|
constructor(opts?: AttentionNotifyServiceOptions);
|
|
67
68
|
protected onStart(_ctx: DaemonContext): Promise<void>;
|
|
68
69
|
protected onStop(): Promise<void>;
|
|
69
70
|
protected onTick(ctx: DaemonContext): Promise<void>;
|
|
70
71
|
private settings;
|
|
72
|
+
private postFinishes;
|
|
71
73
|
private localAsks;
|
|
72
74
|
private fleetAsks;
|
|
73
75
|
private releaseFleet;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* `interactive.host` unset: this host's asks; this machine: every host's, from
|
|
8
8
|
* the shared fleet collector; another machine: none. The ledger under
|
|
9
9
|
* `feed/notified/` (`<key>`, `<key>#r<n>`) makes a restart re-send nothing.
|
|
10
|
-
* `done` banners
|
|
10
|
+
* Finished interactive turns post `done` banners here too (`finished-banners.ts`, docs/menubar.md).
|
|
11
11
|
*/
|
|
12
12
|
import * as fs from 'fs';
|
|
13
13
|
import * as path from 'path';
|
|
@@ -25,6 +25,7 @@ import { sharedFleetFeedHub } from '../feed/watch.js';
|
|
|
25
25
|
import { DEFAULT_NOTIFY_SCHEDULES, NOTIFY_LEVELS, NOTIFY_LEVEL_KEYS, formatWaited, parseNotifySchedule, } from '../feed/notify-schedule.js';
|
|
26
26
|
import { notifyDesktop, withdrawDesktop } from '../menubar/notify-desktop.js';
|
|
27
27
|
import { BasePeriodicService } from './service.js';
|
|
28
|
+
import { TurnFinishTracker, buildBurstNotification, buildFinishNotification, finishKey, FINISH_BURST_MIN } from './finished-banners.js';
|
|
28
29
|
import { span, spanSync } from './diagnostics.js';
|
|
29
30
|
const ATTENTION_NOTIFY_TICK_MS = 5_000;
|
|
30
31
|
const ATTENTION_NOTIFY_DEADLINE_MS = 10_000;
|
|
@@ -117,6 +118,7 @@ export class AttentionNotifyService extends BasePeriodicService {
|
|
|
117
118
|
banners = null;
|
|
118
119
|
fleetHub = null;
|
|
119
120
|
detachFleet = null;
|
|
121
|
+
finishes = new TurnFinishTracker();
|
|
120
122
|
constructor(opts = {}) {
|
|
121
123
|
super();
|
|
122
124
|
this.getSessions = opts.getSessions ?? (() => getActiveSessions());
|
|
@@ -143,11 +145,11 @@ export class AttentionNotifyService extends BasePeriodicService {
|
|
|
143
145
|
if (scope !== 'fleet')
|
|
144
146
|
this.releaseFleet();
|
|
145
147
|
const local = scope === 'local' ? await this.localAsks(nowMs) : undefined;
|
|
146
|
-
const { asks, scopes } = local
|
|
147
|
-
? { asks: local.asks, scopes: null }
|
|
148
|
+
const { asks, scopes, rows } = local
|
|
149
|
+
? { asks: local.asks, scopes: null, rows: local.rows }
|
|
148
150
|
: scope === 'fleet'
|
|
149
151
|
? this.fleetAsks()
|
|
150
|
-
: { asks: [], scopes: null };
|
|
152
|
+
: { asks: [], scopes: null, rows: [] };
|
|
151
153
|
const banners = await this.loadBanners();
|
|
152
154
|
const toWithdraw = [];
|
|
153
155
|
const seen = new Set();
|
|
@@ -187,8 +189,10 @@ export class AttentionNotifyService extends BasePeriodicService {
|
|
|
187
189
|
posted += 1;
|
|
188
190
|
ctx.log('INFO', `attention-notify: posted ${level} ${item.kind} banner for ${item.key}${stage ? ` (reminder ${stage})` : ''}`, { event: 'attention.posted', kind: item.kind, key: item.key, level, reminder: stage });
|
|
189
191
|
}
|
|
192
|
+
this.finishes.observe(rows, nowMs);
|
|
193
|
+
posted += await this.postFinishes(ctx, this.finishes.due(nowMs), settings, banners, nowMs);
|
|
190
194
|
for (const state of banners.values()) {
|
|
191
|
-
const resolved = !seen.has(state.key) && (scopes === null || scopes.has(state.key.split('/')[0]));
|
|
195
|
+
const resolved = !state.finished && !seen.has(state.key) && (scopes === null || scopes.has(state.key.split('/')[0]));
|
|
192
196
|
if (resolved) {
|
|
193
197
|
if (state.bannerUp)
|
|
194
198
|
toWithdraw.push(state.key);
|
|
@@ -199,6 +203,10 @@ export class AttentionNotifyService extends BasePeriodicService {
|
|
|
199
203
|
toWithdraw.push(state.key);
|
|
200
204
|
state.bannerUp = false;
|
|
201
205
|
delete state.hideAt;
|
|
206
|
+
if (state.finished) {
|
|
207
|
+
banners.delete(state.key);
|
|
208
|
+
state.resolvedAt = new Date(nowMs).toISOString();
|
|
209
|
+
}
|
|
202
210
|
await this.writeState(state);
|
|
203
211
|
}
|
|
204
212
|
}
|
|
@@ -215,6 +223,38 @@ export class AttentionNotifyService extends BasePeriodicService {
|
|
|
215
223
|
}
|
|
216
224
|
return this.settingsCache.value;
|
|
217
225
|
}
|
|
226
|
+
async postFinishes(ctx, due, settings, banners, nowMs) {
|
|
227
|
+
const schedule = settings.schedules.low;
|
|
228
|
+
if (schedule.sidebar)
|
|
229
|
+
return 0;
|
|
230
|
+
const fresh = [];
|
|
231
|
+
for (const finish of due)
|
|
232
|
+
if (!await this.stageSent(finishKey(finish), 0, banners))
|
|
233
|
+
fresh.push(finish);
|
|
234
|
+
if (fresh.length === 0)
|
|
235
|
+
return 0;
|
|
236
|
+
const notifications = fresh.length >= FINISH_BURST_MIN
|
|
237
|
+
? [buildBurstNotification(fresh, `${fresh[0].scope}/done-burst-${nowMs}`)]
|
|
238
|
+
: fresh.map(buildFinishNotification);
|
|
239
|
+
for (const n of notifications) {
|
|
240
|
+
if (schedule.sound)
|
|
241
|
+
n.sound = true;
|
|
242
|
+
this.notify(n);
|
|
243
|
+
ctx.log('INFO', `attention-notify: posted done banner ${n.key}`, { event: 'attention.done.posted', key: n.key });
|
|
244
|
+
}
|
|
245
|
+
const bannerKeys = new Set(notifications.map((n) => n.key));
|
|
246
|
+
for (const key of new Set([...bannerKeys, ...fresh.map(finishKey)])) {
|
|
247
|
+
const up = bannerKeys.has(key) && !schedule.stay;
|
|
248
|
+
const state = {
|
|
249
|
+
key, postedAt: new Date(nowMs).toISOString(), level: 'low', stage: 0, bannerUp: up, finished: true,
|
|
250
|
+
...(up ? { hideAt: nowMs + BANNER_HIDE_AFTER_MS } : { resolvedAt: new Date(nowMs).toISOString() }),
|
|
251
|
+
};
|
|
252
|
+
if (up)
|
|
253
|
+
banners.set(key, state);
|
|
254
|
+
await this.writeState(state);
|
|
255
|
+
}
|
|
256
|
+
return notifications.length;
|
|
257
|
+
}
|
|
218
258
|
async localAsks(nowMs) {
|
|
219
259
|
const sessions = await span('attention.sessions', () => this.getSessions(), () => ({}));
|
|
220
260
|
const host = normalizeHost(this.self());
|
|
@@ -234,7 +274,7 @@ export class AttentionNotifyService extends BasePeriodicService {
|
|
|
234
274
|
if (item)
|
|
235
275
|
asks.push({ item, session: projected });
|
|
236
276
|
}
|
|
237
|
-
return { asks, sessions };
|
|
277
|
+
return { asks, sessions, rows: sessions.map((row) => ({ scope: host, row })) };
|
|
238
278
|
}
|
|
239
279
|
fleetAsks() {
|
|
240
280
|
const hub = this.fleetHubOf();
|
|
@@ -248,7 +288,7 @@ export class AttentionNotifyService extends BasePeriodicService {
|
|
|
248
288
|
item: item.urgency ? item : { ...item, urgency: 'normal' },
|
|
249
289
|
session: agent ?? {},
|
|
250
290
|
}));
|
|
251
|
-
return { asks, scopes: hub.state.reportingScopes };
|
|
291
|
+
return { asks, scopes: hub.state.reportingScopes, rows: hub.state.liveAgents() };
|
|
252
292
|
}
|
|
253
293
|
releaseFleet() {
|
|
254
294
|
this.detachFleet?.();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ActiveSession } from '../session/active.js';
|
|
2
|
+
import type { DesktopNotification } from '../menubar/notify-desktop.js';
|
|
3
|
+
export declare const FINISH_MIN_WORK_MS: number;
|
|
4
|
+
export declare const FINISH_SETTLE_MS = 15000;
|
|
5
|
+
export declare const FINISH_BURST_WINDOW_MS = 60000;
|
|
6
|
+
export declare const FINISH_BURST_MIN = 3;
|
|
7
|
+
export type FinishRow = Partial<Pick<ActiveSession, 'sessionId' | 'status' | 'lead' | 'title' | 'label' | 'lastAgentLine' | 'doneVerdict' | 'userTurns' | 'harness' | 'kind' | 'project' | 'pr'>> & {
|
|
8
|
+
context?: string;
|
|
9
|
+
previous?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export interface ObservedRow {
|
|
12
|
+
scope: string;
|
|
13
|
+
row: FinishRow;
|
|
14
|
+
}
|
|
15
|
+
export interface TurnFinish {
|
|
16
|
+
scope: string;
|
|
17
|
+
sessionId: string;
|
|
18
|
+
turnStartMs: number;
|
|
19
|
+
endedAtMs: number;
|
|
20
|
+
row: FinishRow;
|
|
21
|
+
}
|
|
22
|
+
export declare class TurnFinishTracker {
|
|
23
|
+
private readonly working;
|
|
24
|
+
private readonly idleAt;
|
|
25
|
+
private readonly pending;
|
|
26
|
+
observe(rows: readonly ObservedRow[], nowMs: number): void;
|
|
27
|
+
due(nowMs: number): TurnFinish[];
|
|
28
|
+
}
|
|
29
|
+
export declare function gapsInWords(gaps: readonly string[]): string;
|
|
30
|
+
export declare function finishKey(finish: TurnFinish): string;
|
|
31
|
+
export declare function buildFinishNotification(finish: TurnFinish): DesktopNotification;
|
|
32
|
+
export declare function buildBurstNotification(finishes: readonly TurnFinish[], key: string): DesktopNotification;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { harnessOf } from '../feed/attention.js';
|
|
2
|
+
import { formatWaited } from '../feed/notify-schedule.js';
|
|
3
|
+
export const FINISH_MIN_WORK_MS = 2 * 60_000;
|
|
4
|
+
export const FINISH_SETTLE_MS = 15_000;
|
|
5
|
+
export const FINISH_BURST_WINDOW_MS = 60_000;
|
|
6
|
+
export const FINISH_BURST_MIN = 3;
|
|
7
|
+
const BODY_MAX = 200;
|
|
8
|
+
const VERDICT_SKEW_MS = 5_000;
|
|
9
|
+
const GAP_WORDS = {
|
|
10
|
+
'open-pr': 'a pull request is still open',
|
|
11
|
+
'keep-moving': 'it stopped with work left to do',
|
|
12
|
+
delivery: 'the delivery is not verified',
|
|
13
|
+
'live-team': 'teammates are still running',
|
|
14
|
+
'self-audit': 'it has not checked its own work',
|
|
15
|
+
};
|
|
16
|
+
function isInteractive(row) {
|
|
17
|
+
return row.context === 'terminal' && !row.lead && !row.previous && !!row.sessionId;
|
|
18
|
+
}
|
|
19
|
+
function lastUserTurnMs(row) {
|
|
20
|
+
const turns = row.userTurns ?? [];
|
|
21
|
+
const at = turns.length ? turns[turns.length - 1].atMs : undefined;
|
|
22
|
+
return typeof at === 'number' && Number.isFinite(at) ? at : undefined;
|
|
23
|
+
}
|
|
24
|
+
export class TurnFinishTracker {
|
|
25
|
+
working = new Map();
|
|
26
|
+
idleAt = new Map();
|
|
27
|
+
pending = new Map();
|
|
28
|
+
observe(rows, nowMs) {
|
|
29
|
+
const present = new Set();
|
|
30
|
+
for (const { scope, row } of rows) {
|
|
31
|
+
if (!isInteractive(row))
|
|
32
|
+
continue;
|
|
33
|
+
const key = `${scope}/${row.sessionId}`;
|
|
34
|
+
present.add(key);
|
|
35
|
+
if (row.status === 'running') {
|
|
36
|
+
const resumed = this.pending.get(key);
|
|
37
|
+
if (resumed) {
|
|
38
|
+
this.pending.delete(key);
|
|
39
|
+
this.working.set(key, resumed.turnStartMs);
|
|
40
|
+
}
|
|
41
|
+
else if (!this.working.has(key)) {
|
|
42
|
+
const asked = lastUserTurnMs(row);
|
|
43
|
+
const idleAt = this.idleAt.get(key);
|
|
44
|
+
this.working.set(key, asked !== undefined && asked <= nowMs && (idleAt === undefined || asked > idleAt) ? asked : nowMs);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else if (row.status === 'idle') {
|
|
48
|
+
const startMs = this.working.get(key);
|
|
49
|
+
this.working.delete(key);
|
|
50
|
+
this.idleAt.set(key, nowMs);
|
|
51
|
+
const held = this.pending.get(key);
|
|
52
|
+
if (held)
|
|
53
|
+
held.row = row;
|
|
54
|
+
else if (startMs !== undefined && nowMs - startMs >= FINISH_MIN_WORK_MS) {
|
|
55
|
+
this.pending.set(key, { scope, sessionId: row.sessionId, turnStartMs: startMs, endedAtMs: nowMs, row });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
this.working.delete(key);
|
|
60
|
+
this.pending.delete(key);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
for (const map of [this.working, this.idleAt, this.pending]) {
|
|
64
|
+
for (const key of map.keys())
|
|
65
|
+
if (!present.has(key))
|
|
66
|
+
map.delete(key);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
due(nowMs) {
|
|
70
|
+
if (this.pending.size === 0)
|
|
71
|
+
return [];
|
|
72
|
+
const ends = [...this.pending.values()].map((f) => f.endedAtMs);
|
|
73
|
+
const settled = nowMs - Math.max(...ends) >= FINISH_SETTLE_MS;
|
|
74
|
+
const capped = nowMs - Math.min(...ends) >= FINISH_BURST_WINDOW_MS;
|
|
75
|
+
if (!settled && !capped)
|
|
76
|
+
return [];
|
|
77
|
+
const out = [...this.pending.values()].sort((a, b) => a.endedAtMs - b.endedAtMs);
|
|
78
|
+
this.pending.clear();
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function shorten(text, max = BODY_MAX) {
|
|
83
|
+
const flat = text.replace(/\s+/g, ' ').trim();
|
|
84
|
+
return flat.length > max ? `${flat.slice(0, max - 1)}…` : flat;
|
|
85
|
+
}
|
|
86
|
+
function firstSentence(text) {
|
|
87
|
+
const flat = text.replace(/\s+/g, ' ').trim();
|
|
88
|
+
const end = flat.search(/[.!?](\s|$)/);
|
|
89
|
+
return end >= 0 ? flat.slice(0, end + 1) : flat;
|
|
90
|
+
}
|
|
91
|
+
function turnVerdict(finish) {
|
|
92
|
+
const v = finish.row.doneVerdict;
|
|
93
|
+
if (!v)
|
|
94
|
+
return undefined;
|
|
95
|
+
const at = Date.parse(v.at);
|
|
96
|
+
return Number.isFinite(at) && at >= finish.turnStartMs - VERDICT_SKEW_MS ? v : undefined;
|
|
97
|
+
}
|
|
98
|
+
export function gapsInWords(gaps) {
|
|
99
|
+
const words = gaps.map((g) => GAP_WORDS[g] ?? g.replace(/-/g, ' '));
|
|
100
|
+
const text = words.join('; ');
|
|
101
|
+
return text ? `${text[0].toUpperCase()}${text.slice(1)}.` : '';
|
|
102
|
+
}
|
|
103
|
+
function rowTitle(finish) {
|
|
104
|
+
return finish.row.title?.trim() || finish.row.label?.trim() || finish.sessionId.slice(0, 8);
|
|
105
|
+
}
|
|
106
|
+
function verdictWord(v) {
|
|
107
|
+
return v?.state === 'done' ? '✓ Done' : v?.state === 'open' ? 'Not done' : 'Finished';
|
|
108
|
+
}
|
|
109
|
+
export function finishKey(finish) {
|
|
110
|
+
return `${finish.scope}/${finish.sessionId}/done-${finish.turnStartMs}`;
|
|
111
|
+
}
|
|
112
|
+
export function buildFinishNotification(finish) {
|
|
113
|
+
const verdict = turnVerdict(finish);
|
|
114
|
+
const worked = `worked ${formatWaited(finish.endedAtMs - finish.turnStartMs)}`;
|
|
115
|
+
const gaps = verdict?.state === 'open' ? gapsInWords(verdict.gaps) : '';
|
|
116
|
+
const line = finish.row.lastAgentLine ? firstSentence(finish.row.lastAgentLine) : '';
|
|
117
|
+
const n = {
|
|
118
|
+
title: `${verdictWord(verdict)} · ${rowTitle(finish)}`,
|
|
119
|
+
body: shorten(gaps || line || `The turn ended after it ${worked}.`),
|
|
120
|
+
subtitle: [finish.scope, finish.row.project, worked].filter(Boolean).join(' · '),
|
|
121
|
+
category: 'done',
|
|
122
|
+
key: finishKey(finish),
|
|
123
|
+
sessionId: finish.sessionId,
|
|
124
|
+
};
|
|
125
|
+
const agent = harnessOf(finish.row);
|
|
126
|
+
if (agent)
|
|
127
|
+
n.agent = agent;
|
|
128
|
+
if (finish.row.pr?.url)
|
|
129
|
+
n.action = `url:${finish.row.pr.url}`;
|
|
130
|
+
return n;
|
|
131
|
+
}
|
|
132
|
+
export function buildBurstNotification(finishes, key) {
|
|
133
|
+
const counts = new Map();
|
|
134
|
+
for (const f of finishes) {
|
|
135
|
+
const word = verdictWord(turnVerdict(f)).replace('✓ ', '').toLowerCase();
|
|
136
|
+
counts.set(word, (counts.get(word) ?? 0) + 1);
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
title: `${finishes.length} sessions finished`,
|
|
140
|
+
body: shorten(finishes.map(rowTitle).join(' · ')),
|
|
141
|
+
subtitle: [...counts].map(([word, n]) => `${n} ${word}`).join(' · '),
|
|
142
|
+
category: 'done',
|
|
143
|
+
key,
|
|
144
|
+
};
|
|
145
|
+
}
|
package/dist/lib/feed/hub.d.ts
CHANGED
|
@@ -11,6 +11,10 @@ export declare class FeedHubState {
|
|
|
11
11
|
snapshot(state: FeedWatchState): FeedWatchEnvelope[];
|
|
12
12
|
get scopeNames(): string[];
|
|
13
13
|
get reportingScopes(): Set<string>;
|
|
14
|
+
liveAgents(): Array<{
|
|
15
|
+
scope: string;
|
|
16
|
+
row: SessionWatchRow;
|
|
17
|
+
}>;
|
|
14
18
|
attention(): Array<{
|
|
15
19
|
scope: string;
|
|
16
20
|
item: AttentionItem;
|
package/dist/lib/feed/hub.js
CHANGED
|
@@ -87,6 +87,15 @@ export class FeedHubState {
|
|
|
87
87
|
out.add(name);
|
|
88
88
|
return out;
|
|
89
89
|
}
|
|
90
|
+
liveAgents() {
|
|
91
|
+
const out = [];
|
|
92
|
+
for (const [scope, state] of this.scopes) {
|
|
93
|
+
for (const row of state.agents.values())
|
|
94
|
+
if (!row.previous)
|
|
95
|
+
out.push({ scope, row });
|
|
96
|
+
}
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
90
99
|
attention() {
|
|
91
100
|
const out = [];
|
|
92
101
|
for (const [scope, state] of this.scopes) {
|
|
@@ -50,7 +50,8 @@ export function validateNotifySchedule(name) {
|
|
|
50
50
|
export function notifyScheduleDescription(level) {
|
|
51
51
|
return (`AGI Menu: when a ${level}-urgency agent ask posts a Mac banner. Times (5m, 1h) are measured from when the ask ` +
|
|
52
52
|
'opened: the first posts the banner, each later one a reminder. Add stay to keep the banner on screen and sound ' +
|
|
53
|
-
`to play a sound, or set just sidebar for no banner. Default ${JSON.stringify(DEFAULT_NOTIFY_SCHEDULES[level])}.`
|
|
53
|
+
`to play a sound, or set just sidebar for no banner. Default ${JSON.stringify(DEFAULT_NOTIFY_SCHEDULES[level])}.` +
|
|
54
|
+
(level === 'low' ? ' It also schedules the banner a finished session turn posts: sidebar (the default) posts none, any time turns it on.' : ''));
|
|
54
55
|
}
|
|
55
56
|
export function formatWaited(ms) {
|
|
56
57
|
const minutes = Math.round(ms / 60_000);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { CloudTaskStatus } from '../cloud/types.js';
|
|
2
2
|
import { type PidSessionEntry } from './pid-registry.js';
|
|
3
|
-
import { type HookSessionIndex } from './hook-sessions.js';
|
|
3
|
+
import { type DoneVerdict, type HookSessionIndex } from './hook-sessions.js';
|
|
4
4
|
import { type SessionRecap } from './title.js';
|
|
5
|
+
import type { TouchedPr, TouchedTicket } from './touched.js';
|
|
5
6
|
import { type UserPromptKind } from '@phnx-labs/sessions-cli/reader';
|
|
6
7
|
import { type SessionState, type SessionActivity, type AwaitingReason, type StructuredQuestion, type TodoProgress, type DetectedPr, type DetectedWorktree, type DetectedTicket } from '@phnx-labs/sessions-cli/reader';
|
|
7
8
|
import { type SessionAgentId, type SessionAttachment, type SessionFiles, type SessionMeta, type SessionRequest, type SessionTimeline } from '@phnx-labs/sessions-cli/reader';
|
|
@@ -108,6 +109,8 @@ export interface ActiveSession {
|
|
|
108
109
|
ticket?: DetectedTicket;
|
|
109
110
|
rateLimited?: boolean;
|
|
110
111
|
createdTickets?: string[];
|
|
112
|
+
touchedPrs?: TouchedPr[];
|
|
113
|
+
touchedTickets?: TouchedTicket[];
|
|
111
114
|
spawnedTeam?: string;
|
|
112
115
|
attachments?: SessionAttachment[];
|
|
113
116
|
request?: SessionRequest;
|
|
@@ -169,6 +172,7 @@ export interface ActiveSession {
|
|
|
169
172
|
checkpoints?: import('@phnx-labs/sessions-cli/reader').SessionCheckpoint[];
|
|
170
173
|
summaryChecklist?: import('@phnx-labs/sessions-cli/reader').SessionChecklistItem[];
|
|
171
174
|
summaryState?: import('@phnx-labs/sessions-cli/reader').SummaryState;
|
|
175
|
+
doneVerdict?: DoneVerdict;
|
|
172
176
|
}
|
|
173
177
|
export declare function activeStatusFromCloudStatus(status: CloudTaskStatus): ActiveStatus;
|
|
174
178
|
interface ActiveQueryOptions {
|
|
@@ -279,6 +283,7 @@ export declare function deriveSessionRecap(row: Pick<ActiveSession, 'label' | 'g
|
|
|
279
283
|
export declare function deriveImportantMessage(row: Pick<ActiveSession, 'status' | 'activity' | 'awaitingReason' | 'question' | 'preview' | 'lastAgentLine'>): SessionImportantMessage | undefined;
|
|
280
284
|
export declare function foldRecap(rows: ActiveSession[]): void;
|
|
281
285
|
export declare function derivePhase(status: ActiveStatus | undefined): SessionPhase;
|
|
286
|
+
export declare function foldDoneVerdict(rows: ActiveSession[]): void;
|
|
282
287
|
export declare function foldPhase(rows: ActiveSession[]): void;
|
|
283
288
|
export declare function isReapableOrphan(row: Pick<ActiveSession, 'status' | 'pidAlive'>): boolean;
|
|
284
289
|
export declare function annotateOrchestratorLabels(sessions: ActiveSession[]): void;
|
|
@@ -13,7 +13,7 @@ import { listNativeAccounts } from '../account-registry.js';
|
|
|
13
13
|
import { parseNativeIdentityKey } from '../native-accounts.js';
|
|
14
14
|
import { readLivePidSessionEntry as readPidSessionEntry, listPidSessionEntries, prunePidSessionRegistry, sessionIdFromLivePid, } from './pid-registry.js';
|
|
15
15
|
import { readSessionActorRecord, writeSessionAliasRecord } from './actor-sidecar.js';
|
|
16
|
-
import { loadHookSessionIndex, resolveHookSessionRecord, readStateSessionRecord } from './hook-sessions.js';
|
|
16
|
+
import { loadHookSessionIndex, resolveHookSessionRecord, readStateSessionRecord, readDoneVerdict } from './hook-sessions.js';
|
|
17
17
|
import { extractClaudeUserText, getAgentSessionDirs, readClaudeLiveNames } from './discover.js';
|
|
18
18
|
import { buildRunNameMap } from './run-names.js';
|
|
19
19
|
import { cleanDisplayTitle, isPlaceholderSessionName, resolveSessionName, startedAsFromUserTurn } from './title.js';
|
|
@@ -158,6 +158,10 @@ export function applySessionNames(sessions) {
|
|
|
158
158
|
}) ?? s.label;
|
|
159
159
|
if (stored?.recap)
|
|
160
160
|
s.recap = stored.recap;
|
|
161
|
+
if (stored?.touchedPrs)
|
|
162
|
+
s.touchedPrs = stored.touchedPrs;
|
|
163
|
+
if (stored?.touchedTickets)
|
|
164
|
+
s.touchedTickets = stored.touchedTickets;
|
|
161
165
|
}
|
|
162
166
|
}
|
|
163
167
|
export function sessionAccountLabel(kind, session, accounts = listNativeAccounts(readMeta())) {
|
|
@@ -1330,6 +1334,7 @@ export async function getActiveSessions(opts = {}) {
|
|
|
1330
1334
|
annotateOrchestratorLabels(merged);
|
|
1331
1335
|
foldRecap(merged);
|
|
1332
1336
|
foldPhase(merged);
|
|
1337
|
+
foldDoneVerdict(merged);
|
|
1333
1338
|
markLeadSessions(merged);
|
|
1334
1339
|
}, count(merged));
|
|
1335
1340
|
return merged;
|
|
@@ -1540,6 +1545,17 @@ export function derivePhase(status) {
|
|
|
1540
1545
|
return 'idle';
|
|
1541
1546
|
}
|
|
1542
1547
|
}
|
|
1548
|
+
export function foldDoneVerdict(rows) {
|
|
1549
|
+
for (const s of rows) {
|
|
1550
|
+
const verdict = s.pid && s.sessionId && s.pidAlive !== false
|
|
1551
|
+
? readDoneVerdict(s.pid, s.sessionId, s.processStartedAtMs ?? readPidSessionEntry(s.pid)?.startedAtMs)
|
|
1552
|
+
: undefined;
|
|
1553
|
+
if (verdict)
|
|
1554
|
+
s.doneVerdict = verdict;
|
|
1555
|
+
else
|
|
1556
|
+
delete s.doneVerdict;
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1543
1559
|
export function foldPhase(rows) {
|
|
1544
1560
|
for (const s of rows)
|
|
1545
1561
|
s.phase = derivePhase(s.status);
|
package/dist/lib/session/db.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Database from '../sqlite.js';
|
|
2
2
|
import type { SessionAgentId, SessionCheckpoint, SessionChecklistItem, SessionEvent, SessionFiles, SessionGlance, SessionMeta, SessionRequest, SessionSubagent, SessionTimeline, SummaryState } from '@phnx-labs/sessions-cli/reader';
|
|
3
3
|
import type { SessionRecap } from './title.js';
|
|
4
|
+
import type { TouchedPr, TouchedTicket } from './touched.js';
|
|
4
5
|
import { type IndexedToolCall } from '@phnx-labs/sessions-cli/reader';
|
|
5
6
|
import { type ToolScanResumePoint } from './tool-store.js';
|
|
6
7
|
import { type TimelineState } from '@phnx-labs/sessions-cli/reader';
|
|
@@ -94,6 +95,8 @@ export interface IndexedSessionNames {
|
|
|
94
95
|
label?: string;
|
|
95
96
|
customTitle?: string;
|
|
96
97
|
recap?: SessionRecap;
|
|
98
|
+
touchedPrs?: TouchedPr[];
|
|
99
|
+
touchedTickets?: TouchedTicket[];
|
|
97
100
|
}
|
|
98
101
|
export declare function getIndexedSessionNames(rows: Array<{
|
|
99
102
|
id: string;
|
package/dist/lib/session/db.js
CHANGED
|
@@ -1984,6 +1984,10 @@ export function upsertSessionsBatch(entries) {
|
|
|
1984
1984
|
}
|
|
1985
1985
|
maintainSessionSearchIndex(db);
|
|
1986
1986
|
}
|
|
1987
|
+
function nonEmptyJsonArray(raw) {
|
|
1988
|
+
const list = raw ? JSON.parse(raw) : undefined;
|
|
1989
|
+
return list && list.length > 0 ? list : undefined;
|
|
1990
|
+
}
|
|
1987
1991
|
export function getIndexedSessionNames(rows) {
|
|
1988
1992
|
const out = new Map();
|
|
1989
1993
|
if (rows.length === 0)
|
|
@@ -2010,14 +2014,16 @@ export function getIndexedSessionNames(rows) {
|
|
|
2010
2014
|
for (let i = 0; i < keys.length; i += CHUNK) {
|
|
2011
2015
|
const chunk = keys.slice(i, i + CHUNK);
|
|
2012
2016
|
const fromState = db
|
|
2013
|
-
.prepare(`SELECT file_path, json_extract(parser_state, '$.customTitle') AS custom_title, json_extract(parser_state, '$.recap') AS recap FROM scan_ledger WHERE file_path IN (${chunk.map(() => '?').join(',')}) AND json_valid(parser_state)`)
|
|
2017
|
+
.prepare(`SELECT file_path, json_extract(parser_state, '$.customTitle') AS custom_title, json_extract(parser_state, '$.recap') AS recap, json_extract(parser_state, '$.touchedPrs') AS touched_prs, json_extract(parser_state, '$.touchedTickets') AS touched_tickets FROM scan_ledger WHERE file_path IN (${chunk.map(() => '?').join(',')}) AND json_valid(parser_state)`)
|
|
2014
2018
|
.all(...chunk);
|
|
2015
2019
|
for (const row of fromState) {
|
|
2016
2020
|
const id = idByLedgerKey.get(row.file_path);
|
|
2017
2021
|
const customTitle = typeof row.custom_title === 'string' && row.custom_title ? row.custom_title : undefined;
|
|
2018
2022
|
const recap = row.recap ? JSON.parse(row.recap) : undefined;
|
|
2019
|
-
|
|
2020
|
-
|
|
2023
|
+
const touchedPrs = nonEmptyJsonArray(row.touched_prs);
|
|
2024
|
+
const touchedTickets = nonEmptyJsonArray(row.touched_tickets);
|
|
2025
|
+
if (customTitle || recap || touchedPrs || touchedTickets)
|
|
2026
|
+
out.set(id, { ...out.get(id), customTitle, recap, touchedPrs, touchedTickets });
|
|
2021
2027
|
}
|
|
2022
2028
|
}
|
|
2023
2029
|
return out;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SessionAgentId, SessionEvent, SessionMeta, TodoProgress } from '@phnx-labs/sessions-cli/reader';
|
|
2
2
|
export { machineForSessionFile } from './origin-machine.js';
|
|
3
3
|
import { type ScanStamp } from './db.js';
|
|
4
|
+
import { type CommandTouches, type TouchedPr, type TouchedTicket } from './touched.js';
|
|
4
5
|
import { type LiveSessionName, type SessionRecap } from './title.js';
|
|
5
6
|
import { ToolCallCollector, type IndexedToolCall, type ToolCallCollectorSnapshot } from '@phnx-labs/sessions-cli/reader';
|
|
6
7
|
interface DiscoverOptions {
|
|
@@ -209,6 +210,9 @@ interface ClaudeParseState {
|
|
|
209
210
|
prUrls: string[];
|
|
210
211
|
createdTickets: Set<string>;
|
|
211
212
|
pendingTicketTools: Set<string>;
|
|
213
|
+
touchedPrs: TouchedPr[];
|
|
214
|
+
touchedTickets: TouchedTicket[];
|
|
215
|
+
pendingTouches: Map<string, CommandTouches>;
|
|
212
216
|
spawnedTeam?: string;
|
|
213
217
|
plan?: string;
|
|
214
218
|
checklistEvents: SessionEvent[];
|
|
@@ -224,7 +228,7 @@ export declare function applyClaudeLine(state: ClaudeParseState, parsed: any): v
|
|
|
224
228
|
export declare function finalizeClaudeScan(state: ClaudeParseState, sessionFile?: string): ClaudeSessionScan;
|
|
225
229
|
export declare function scanClaudeSession(filePath: string): Promise<ClaudeSessionScan>;
|
|
226
230
|
export interface ClaudeParserState {
|
|
227
|
-
v:
|
|
231
|
+
v: 7;
|
|
228
232
|
subAgents: number;
|
|
229
233
|
backgroundShells: number | undefined;
|
|
230
234
|
offset: number;
|
|
@@ -259,9 +263,12 @@ export interface ClaudeParserState {
|
|
|
259
263
|
pendingPrCreates?: string[];
|
|
260
264
|
prUrl?: string;
|
|
261
265
|
prNumber?: number;
|
|
262
|
-
prUrls
|
|
266
|
+
prUrls: string[];
|
|
263
267
|
pendingTicketTools: string[];
|
|
264
268
|
createdTickets: string[];
|
|
269
|
+
touchedPrs: TouchedPr[];
|
|
270
|
+
touchedTickets: TouchedTicket[];
|
|
271
|
+
pendingTouches: Array<[string, CommandTouches]>;
|
|
265
272
|
spawnedTeam?: string;
|
|
266
273
|
ticketId?: string;
|
|
267
274
|
contentText?: string;
|
|
@@ -325,7 +332,7 @@ export declare function initCodexParseState(): CodexParseState;
|
|
|
325
332
|
export declare function applyCodexLine(state: CodexParseState, parsed: any): void;
|
|
326
333
|
export declare function finalizeCodexScan(state: CodexParseState): CodexSessionScan;
|
|
327
334
|
export interface CodexParserState {
|
|
328
|
-
v:
|
|
335
|
+
v: 5;
|
|
329
336
|
offset: number;
|
|
330
337
|
jsonlDroppingOversizedLine?: boolean;
|
|
331
338
|
sessionId?: string;
|
|
@@ -344,7 +351,7 @@ export interface CodexParserState {
|
|
|
344
351
|
pendingPrCreates?: string[];
|
|
345
352
|
prUrl?: string;
|
|
346
353
|
prNumber?: number;
|
|
347
|
-
prUrls
|
|
354
|
+
prUrls: string[];
|
|
348
355
|
pendingTicketTools: string[];
|
|
349
356
|
createdTickets: string[];
|
|
350
357
|
spawnedTeam?: string;
|
|
@@ -30,6 +30,7 @@ export { machineForSessionFile } from './origin-machine.js';
|
|
|
30
30
|
import { mapBounded } from '../concurrency.js';
|
|
31
31
|
import { getDB, getScanStampByPath, getScanStampsForPaths, getParserStatesForPaths, getDirLedgerForPaths, recordDirScans, recordScans, seedLabelsFromNames, syncTopics, upsertSessionsBatch, querySessions, countSessions, ftsSearch, getSessionById, tryClaimScan, releaseScan, scanInProgressByLivePid, cacheLinearProject, CONTENT_INDEX_VERSION, } from './db.js';
|
|
32
32
|
import { buildRunNameMap } from './run-names.js';
|
|
33
|
+
import { recordTouches, touchesFromCommand, trackPendingTouches } from './touched.js';
|
|
33
34
|
import { claudeRecapFromLine, resolveSessionName } from './title.js';
|
|
34
35
|
import { resolveLinearApiKey } from '../linear-cache.js';
|
|
35
36
|
import { ToolCallCollector, collectClaudeToolCalls, collectCodexToolCalls, } from '@phnx-labs/sessions-cli/reader';
|
|
@@ -2155,6 +2156,9 @@ export function initClaudeParseState() {
|
|
|
2155
2156
|
prUrls: [],
|
|
2156
2157
|
createdTickets: new Set(),
|
|
2157
2158
|
pendingTicketTools: new Set(),
|
|
2159
|
+
touchedPrs: [],
|
|
2160
|
+
touchedTickets: [],
|
|
2161
|
+
pendingTouches: new Map(),
|
|
2158
2162
|
spawnedTeam: undefined,
|
|
2159
2163
|
plan: undefined,
|
|
2160
2164
|
checklistEvents: [],
|
|
@@ -2212,6 +2216,9 @@ export function applyClaudeLine(state, parsed) {
|
|
|
2212
2216
|
if (typeof b?.id === 'string' && isTicketCreateTool(b?.name, b?.input?.command)) {
|
|
2213
2217
|
state.pendingTicketTools.add(b.id);
|
|
2214
2218
|
}
|
|
2219
|
+
if (typeof b?.id === 'string' && b?.name === 'Bash' && typeof b?.input?.command === 'string' && b.input.run_in_background !== true) {
|
|
2220
|
+
trackPendingTouches(state.pendingTouches, b.id, touchesFromCommand(b.input.command, typeof parsed.cwd === 'string' ? parsed.cwd : state.cwd));
|
|
2221
|
+
}
|
|
2215
2222
|
if (b?.name === 'ExitPlanMode' && typeof b?.input?.plan === 'string') {
|
|
2216
2223
|
const p = b.input.plan.trim();
|
|
2217
2224
|
if (p)
|
|
@@ -2255,6 +2262,22 @@ export function applyClaudeLine(state, parsed) {
|
|
|
2255
2262
|
recordCreatedPr(state, extractPrUrl(text));
|
|
2256
2263
|
}
|
|
2257
2264
|
}
|
|
2265
|
+
if (state.pendingTouches.size > 0 && parsed.type === 'user' && Array.isArray(parsed.message?.content)) {
|
|
2266
|
+
for (const b of parsed.message.content) {
|
|
2267
|
+
if (b?.type !== 'tool_result' || typeof b?.tool_use_id !== 'string')
|
|
2268
|
+
continue;
|
|
2269
|
+
const touches = state.pendingTouches.get(b.tool_use_id);
|
|
2270
|
+
if (!touches)
|
|
2271
|
+
continue;
|
|
2272
|
+
state.pendingTouches.delete(b.tool_use_id);
|
|
2273
|
+
if (b.is_error === true)
|
|
2274
|
+
continue;
|
|
2275
|
+
const output = typeof b.content === 'string'
|
|
2276
|
+
? b.content
|
|
2277
|
+
: Array.isArray(b.content) ? b.content.map((c) => c?.text || '').join('\n') : '';
|
|
2278
|
+
recordTouches(state, touches, output, { prUrls: state.prUrls, tickets: state.createdTickets });
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2258
2281
|
if (typeof parsed.timestamp === 'string') {
|
|
2259
2282
|
const ms = new Date(parsed.timestamp).getTime();
|
|
2260
2283
|
if (!Number.isNaN(ms)) {
|
|
@@ -2433,7 +2456,7 @@ export function serializeClaudeParserState(state, offset, jsonlDroppingOversized
|
|
|
2433
2456
|
: allIds;
|
|
2434
2457
|
const ticket = detectTicket(state.userTexts.join('\n') || undefined, state.gitBranch);
|
|
2435
2458
|
return {
|
|
2436
|
-
v:
|
|
2459
|
+
v: 7,
|
|
2437
2460
|
subAgents: state.subAgents,
|
|
2438
2461
|
backgroundShells: state.backgroundShells,
|
|
2439
2462
|
offset,
|
|
@@ -2471,6 +2494,9 @@ export function serializeClaudeParserState(state, offset, jsonlDroppingOversized
|
|
|
2471
2494
|
prUrls: state.prUrls,
|
|
2472
2495
|
pendingTicketTools: [...state.pendingTicketTools],
|
|
2473
2496
|
createdTickets: [...state.createdTickets],
|
|
2497
|
+
touchedPrs: state.touchedPrs,
|
|
2498
|
+
touchedTickets: state.touchedTickets,
|
|
2499
|
+
pendingTouches: [...state.pendingTouches],
|
|
2474
2500
|
spawnedTeam: state.spawnedTeam,
|
|
2475
2501
|
ticketId: ticket?.id,
|
|
2476
2502
|
contentText: state.userTexts.length > 0 ? state.userTexts.join('\n') : undefined,
|
|
@@ -2523,8 +2549,11 @@ export function hydrateClaudeParseState(prior) {
|
|
|
2523
2549
|
pendingPrCreates: new Set(prior.pendingPrCreates),
|
|
2524
2550
|
prUrl: prior.prUrl,
|
|
2525
2551
|
prNumber: prior.prNumber,
|
|
2526
|
-
prUrls: prior.prUrls
|
|
2552
|
+
prUrls: prior.prUrls,
|
|
2527
2553
|
createdTickets: new Set(prior.createdTickets),
|
|
2554
|
+
touchedPrs: prior.touchedPrs,
|
|
2555
|
+
touchedTickets: prior.touchedTickets,
|
|
2556
|
+
pendingTouches: new Map(prior.pendingTouches),
|
|
2528
2557
|
pendingTicketTools: new Set(prior.pendingTicketTools),
|
|
2529
2558
|
spawnedTeam: prior.spawnedTeam,
|
|
2530
2559
|
plan: prior.plan,
|
|
@@ -2609,7 +2638,7 @@ function parsePriorClaudeState(row) {
|
|
|
2609
2638
|
return null;
|
|
2610
2639
|
try {
|
|
2611
2640
|
const parsed = JSON.parse(row.parserState);
|
|
2612
|
-
if (parsed?.v !==
|
|
2641
|
+
if (parsed?.v !== 7 || typeof parsed.offset !== 'number' || parsed.toolCalls?.v !== 1)
|
|
2613
2642
|
return null;
|
|
2614
2643
|
return parsed;
|
|
2615
2644
|
}
|
|
@@ -2849,7 +2878,7 @@ async function scanCodexSession(filePath) {
|
|
|
2849
2878
|
export function serializeCodexParserState(state, offset, jsonlDroppingOversizedLine = false) {
|
|
2850
2879
|
const ticket = detectTicket(state.userTexts.join('\n') || undefined, state.gitBranch);
|
|
2851
2880
|
return {
|
|
2852
|
-
v:
|
|
2881
|
+
v: 5,
|
|
2853
2882
|
offset,
|
|
2854
2883
|
jsonlDroppingOversizedLine: jsonlDroppingOversizedLine || undefined,
|
|
2855
2884
|
sessionId: state.sessionId,
|
|
@@ -2902,7 +2931,7 @@ export function hydrateCodexParseState(prior) {
|
|
|
2902
2931
|
pendingPrCreates: new Set(prior.pendingPrCreates),
|
|
2903
2932
|
prUrl: prior.prUrl,
|
|
2904
2933
|
prNumber: prior.prNumber,
|
|
2905
|
-
prUrls: prior.prUrls
|
|
2934
|
+
prUrls: prior.prUrls,
|
|
2906
2935
|
createdTickets: new Set(prior.createdTickets),
|
|
2907
2936
|
pendingTicketTools: new Set(prior.pendingTicketTools),
|
|
2908
2937
|
spawnedTeam: prior.spawnedTeam,
|
|
@@ -2977,7 +3006,7 @@ function parsePriorCodexState(row) {
|
|
|
2977
3006
|
return null;
|
|
2978
3007
|
try {
|
|
2979
3008
|
const parsed = JSON.parse(row.parserState);
|
|
2980
|
-
if (parsed?.v !==
|
|
3009
|
+
if (parsed?.v !== 5 || typeof parsed.offset !== 'number' || parsed.toolCalls?.v !== 1)
|
|
2981
3010
|
return null;
|
|
2982
3011
|
return parsed;
|
|
2983
3012
|
}
|
|
@@ -8,6 +8,12 @@ export interface HookSessionRecord {
|
|
|
8
8
|
terminal_id?: string;
|
|
9
9
|
ts?: number;
|
|
10
10
|
completed?: boolean;
|
|
11
|
+
verdict?: unknown;
|
|
12
|
+
}
|
|
13
|
+
export interface DoneVerdict {
|
|
14
|
+
state: 'done' | 'open' | 'unchecked';
|
|
15
|
+
gaps: string[];
|
|
16
|
+
at: string;
|
|
11
17
|
}
|
|
12
18
|
export interface HookSessionIndex {
|
|
13
19
|
byLaunchId: Map<string, HookSessionRecord>;
|
|
@@ -15,6 +21,7 @@ export interface HookSessionIndex {
|
|
|
15
21
|
byPid: Map<number, HookSessionRecord>;
|
|
16
22
|
}
|
|
17
23
|
export declare function readStateSessionRecord(pid: number, startedAtMs?: number): HookSessionRecord | undefined;
|
|
24
|
+
export declare function readDoneVerdict(pid: number, sessionId: string, processStartedAtMs?: number): DoneVerdict | undefined;
|
|
18
25
|
export declare function captureLaunchBinding(pid: number | undefined, launchId: string): PidSessionEntry | undefined;
|
|
19
26
|
export declare function recordCompletedLaunch(binding: PidSessionEntry | undefined): void;
|
|
20
27
|
export declare function loadHookSessionIndex(): HookSessionIndex;
|
|
@@ -6,6 +6,8 @@ import { hostProcessView } from './process-view.js';
|
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import { getTerminalsDir, getRuntimeStateDir } from '../state.js';
|
|
8
8
|
import { listPidSessionEntries, pidSessionEntryMatchesLiveProcess, readLivePidSessionEntry, readPidSessionEntry } from './pid-registry.js';
|
|
9
|
+
const RECORD_SKEW_MS = 5_000;
|
|
10
|
+
const VERDICT_STATES = new Set(['done', 'open', 'unchecked']);
|
|
9
11
|
function hookSessionsDir() {
|
|
10
12
|
return path.join(getTerminalsDir(), 'sessions');
|
|
11
13
|
}
|
|
@@ -25,12 +27,25 @@ export function readStateSessionRecord(pid, startedAtMs) {
|
|
|
25
27
|
if (!rec)
|
|
26
28
|
return undefined;
|
|
27
29
|
if (startedAtMs !== undefined && typeof rec.ts === 'number') {
|
|
28
|
-
|
|
29
|
-
if (rec.ts * 1000 < startedAtMs - SKEW_MS)
|
|
30
|
+
if (rec.ts * 1000 < startedAtMs - RECORD_SKEW_MS)
|
|
30
31
|
return undefined;
|
|
31
32
|
}
|
|
32
33
|
return rec;
|
|
33
34
|
}
|
|
35
|
+
export function readDoneVerdict(pid, sessionId, processStartedAtMs) {
|
|
36
|
+
const rec = readStateSessionRecord(pid, processStartedAtMs);
|
|
37
|
+
if (!rec || rec.pid !== pid || rec.session_id !== sessionId)
|
|
38
|
+
return undefined;
|
|
39
|
+
const v = rec.verdict;
|
|
40
|
+
if (!v || typeof v !== 'object' || typeof v.state !== 'string' || !VERDICT_STATES.has(v.state))
|
|
41
|
+
return undefined;
|
|
42
|
+
if (typeof v.at !== 'number' || !Number.isFinite(v.at))
|
|
43
|
+
return undefined;
|
|
44
|
+
if (processStartedAtMs !== undefined && v.at < processStartedAtMs - RECORD_SKEW_MS)
|
|
45
|
+
return undefined;
|
|
46
|
+
const gaps = Array.isArray(v.gaps) ? v.gaps.filter((g) => typeof g === 'string' && g.length > 0) : [];
|
|
47
|
+
return { state: v.state, gaps, at: new Date(v.at).toISOString() };
|
|
48
|
+
}
|
|
34
49
|
function parseRecord(raw) {
|
|
35
50
|
try {
|
|
36
51
|
const o = JSON.parse(raw);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type TouchedPrAction = 'merged' | 'reviewed' | 'commented' | 'checked out' | 'edited' | 'closed';
|
|
2
|
+
export interface TouchedPr {
|
|
3
|
+
url: string;
|
|
4
|
+
number: number;
|
|
5
|
+
repo: string;
|
|
6
|
+
action: TouchedPrAction;
|
|
7
|
+
}
|
|
8
|
+
export interface TouchedTicket {
|
|
9
|
+
id: string;
|
|
10
|
+
action: string;
|
|
11
|
+
}
|
|
12
|
+
export interface CommandTouches {
|
|
13
|
+
prs: Array<TouchedPr & {
|
|
14
|
+
masked?: true;
|
|
15
|
+
}>;
|
|
16
|
+
tickets: Array<TouchedTicket & {
|
|
17
|
+
masked?: true;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
export declare function touchesFromCommand(command: string, cwd: string | undefined, repoForDir?: (dir: string) => string | undefined): CommandTouches;
|
|
21
|
+
interface TouchedLedger {
|
|
22
|
+
touchedPrs: TouchedPr[];
|
|
23
|
+
touchedTickets: TouchedTicket[];
|
|
24
|
+
}
|
|
25
|
+
export declare function trackPendingTouches(pending: Map<string, CommandTouches>, id: string, touches: CommandTouches): void;
|
|
26
|
+
export declare function recordTouches(ledger: TouchedLedger, touches: CommandTouches, output: string, created: {
|
|
27
|
+
prUrls: string[];
|
|
28
|
+
tickets: Iterable<string>;
|
|
29
|
+
}): void;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { linearIssueKeys, tokenizeBash } from '@phnx-labs/sessions-cli/reader';
|
|
6
|
+
import { repoFromRemote } from '../github/gh-overload.js';
|
|
7
|
+
const TOUCHED_MAX = 50;
|
|
8
|
+
const PENDING_MAX = 64;
|
|
9
|
+
const GH_BODY_FLAGS = ['-b', '--body', '-F', '--body-file'];
|
|
10
|
+
const GH_PR_VERBS = {
|
|
11
|
+
merge: { action: 'merged', valueFlags: new Set([...GH_BODY_FLAGS, '-t', '--subject', '--match-head-commit', '-A', '--author-email']) },
|
|
12
|
+
review: { action: 'reviewed', valueFlags: new Set(GH_BODY_FLAGS) },
|
|
13
|
+
comment: { action: 'commented', valueFlags: new Set(GH_BODY_FLAGS) },
|
|
14
|
+
checkout: { action: 'checked out', valueFlags: new Set(['-b', '--branch']) },
|
|
15
|
+
edit: {
|
|
16
|
+
action: 'edited',
|
|
17
|
+
valueFlags: new Set([...GH_BODY_FLAGS, '-t', '--title', '-B', '--base', '-m', '--milestone',
|
|
18
|
+
'--add-assignee', '--remove-assignee', '--add-label', '--remove-label', '--add-reviewer',
|
|
19
|
+
'--remove-reviewer', '--add-project', '--remove-project']),
|
|
20
|
+
},
|
|
21
|
+
close: { action: 'closed', valueFlags: new Set(['-c', '--comment']) },
|
|
22
|
+
};
|
|
23
|
+
const AGENTS_PRS_ACTIONS = {
|
|
24
|
+
merge: 'merged',
|
|
25
|
+
review: 'reviewed',
|
|
26
|
+
comment: 'commented',
|
|
27
|
+
};
|
|
28
|
+
const LINEAR_UPDATE_VALUE_FLAGS = new Set([
|
|
29
|
+
'--status', '--comment', '--proof', '--label', '--unlabel', '--priority', '--assign', '--delegate',
|
|
30
|
+
'--parent', '--project', '--milestone', '--title', '--description', '--description-file',
|
|
31
|
+
'--due-date', '--remind-at', '--cycle', '--blocks', '--blocked-by', '--relates', '--team',
|
|
32
|
+
]);
|
|
33
|
+
const MERGED_EVIDENCE_RE = /"merged":\s*true|\bmerged pull request\b/i;
|
|
34
|
+
const PR_URL_RE = /^https?:\/\/github\.com\/([^/\s]+)\/([^/\s]+)\/pull\/(\d+)(?:[/?#]\S*)?$/;
|
|
35
|
+
function heredocDelimiter(cmd, at) {
|
|
36
|
+
const m = cmd.slice(at).match(/^<<(-?)\s*(['"]?)([A-Za-z_][\w-]*)\2/);
|
|
37
|
+
return m ? { word: m[3], strip: m[1] === '-' } : undefined;
|
|
38
|
+
}
|
|
39
|
+
function splitTopLevel(cmd) {
|
|
40
|
+
const out = [];
|
|
41
|
+
const heredocs = [];
|
|
42
|
+
let start = 0;
|
|
43
|
+
let depth = 0;
|
|
44
|
+
let quote;
|
|
45
|
+
const cut = (end, op, next) => {
|
|
46
|
+
const text = cmd.slice(start, end).trim();
|
|
47
|
+
if (text)
|
|
48
|
+
out.push({ text, op });
|
|
49
|
+
else if (out.length > 0 && op)
|
|
50
|
+
out[out.length - 1].op = op;
|
|
51
|
+
start = next;
|
|
52
|
+
return next - 1;
|
|
53
|
+
};
|
|
54
|
+
for (let i = 0; i < cmd.length; i++) {
|
|
55
|
+
const c = cmd[i];
|
|
56
|
+
if (quote) {
|
|
57
|
+
if (c === '\\' && quote !== "'")
|
|
58
|
+
i++;
|
|
59
|
+
else if (c === quote)
|
|
60
|
+
quote = undefined;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (c === '\\') {
|
|
64
|
+
i++;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (c === "'" || c === '"' || c === '`') {
|
|
68
|
+
quote = c;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (c === '(') {
|
|
72
|
+
depth++;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (c === ')') {
|
|
76
|
+
depth = Math.max(0, depth - 1);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (depth > 0)
|
|
80
|
+
continue;
|
|
81
|
+
if (c === '<' && cmd[i + 1] === '<' && cmd[i + 2] !== '<') {
|
|
82
|
+
const h = heredocDelimiter(cmd, i);
|
|
83
|
+
if (h)
|
|
84
|
+
heredocs.push(h);
|
|
85
|
+
i++;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (c === '\n') {
|
|
89
|
+
let next = i + 1;
|
|
90
|
+
for (const h of heredocs.splice(0)) {
|
|
91
|
+
while (next < cmd.length) {
|
|
92
|
+
const eol = cmd.indexOf('\n', next);
|
|
93
|
+
const line = cmd.slice(next, eol < 0 ? cmd.length : eol);
|
|
94
|
+
next = eol < 0 ? cmd.length : eol + 1;
|
|
95
|
+
if ((h.strip ? line.replace(/^\t+/, '') : line) === h.word)
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
i = cut(i, ';', next);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (c === ';') {
|
|
103
|
+
i = cut(i, ';', i + 1);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (c === '&' && cmd[i + 1] === '&') {
|
|
107
|
+
i = cut(i, '&&', i + 2);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (c === '|' && cmd[i + 1] === '|') {
|
|
111
|
+
i = cut(i, '||', i + 2);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (c === '|') {
|
|
115
|
+
i = cut(i, '|', cmd[i + 1] === '&' ? i + 2 : i + 1);
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (c === '&' && cmd[i - 1] !== '>' && cmd[i + 1] !== '>') {
|
|
119
|
+
i = cut(i, '&', i + 1);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
cut(cmd.length, '', cmd.length);
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
126
|
+
function flagValue(tokens, names) {
|
|
127
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
128
|
+
const t = tokens[i];
|
|
129
|
+
for (const name of names) {
|
|
130
|
+
if (t === name)
|
|
131
|
+
return tokens[i + 1];
|
|
132
|
+
if (name.startsWith('--') && t.startsWith(`${name}=`))
|
|
133
|
+
return t.slice(name.length + 1);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
function positionals(tokens, valueFlags) {
|
|
139
|
+
const out = [];
|
|
140
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
141
|
+
const t = tokens[i];
|
|
142
|
+
if (t === '--') {
|
|
143
|
+
out.push(...tokens.slice(i + 1));
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
if (t.startsWith('-')) {
|
|
147
|
+
if (valueFlags.has(t))
|
|
148
|
+
i++;
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
out.push(t);
|
|
152
|
+
}
|
|
153
|
+
return out;
|
|
154
|
+
}
|
|
155
|
+
function normalizeRepo(value) {
|
|
156
|
+
if (!value)
|
|
157
|
+
return undefined;
|
|
158
|
+
const m = value.replace(/^https?:\/\//, '').replace(/^github\.com\//, '').replace(/\.git$/, '').match(/^([\w.-]+)\/([\w.-]+)$/);
|
|
159
|
+
return m ? `${m[1]}/${m[2]}` : undefined;
|
|
160
|
+
}
|
|
161
|
+
function prTouch(repo, number, action) {
|
|
162
|
+
return { url: `https://github.com/${repo}/pull/${number}`, number, repo, action };
|
|
163
|
+
}
|
|
164
|
+
function withoutEnvPrefix(tokens) {
|
|
165
|
+
let i = 0;
|
|
166
|
+
while (i < tokens.length && /^[A-Za-z_][A-Za-z0-9_]*=/.test(tokens[i]))
|
|
167
|
+
i++;
|
|
168
|
+
return tokens.slice(i);
|
|
169
|
+
}
|
|
170
|
+
function ghPrTouch(tokens, inferRepo) {
|
|
171
|
+
const verb = GH_PR_VERBS[tokens[2] ?? ''];
|
|
172
|
+
if (!verb)
|
|
173
|
+
return undefined;
|
|
174
|
+
const args = tokens.slice(3);
|
|
175
|
+
if (verb.action === 'merged' && (args.includes('--auto') || args.includes('--disable-auto')))
|
|
176
|
+
return undefined;
|
|
177
|
+
const target = positionals(args, new Set(['-R', '--repo', ...verb.valueFlags]))[0];
|
|
178
|
+
if (!target)
|
|
179
|
+
return undefined;
|
|
180
|
+
const url = target.match(PR_URL_RE);
|
|
181
|
+
if (url)
|
|
182
|
+
return prTouch(`${url[1]}/${url[2]}`, Number(url[3]), verb.action);
|
|
183
|
+
if (!/^\d+$/.test(target))
|
|
184
|
+
return undefined;
|
|
185
|
+
const repo = normalizeRepo(flagValue(args, ['-R', '--repo'])) ?? inferRepo();
|
|
186
|
+
return repo ? prTouch(repo, Number(target), verb.action) : undefined;
|
|
187
|
+
}
|
|
188
|
+
function agentsPrsTouch(tokens) {
|
|
189
|
+
const action = AGENTS_PRS_ACTIONS[tokens[3] ?? ''];
|
|
190
|
+
if (!action)
|
|
191
|
+
return undefined;
|
|
192
|
+
const args = tokens.slice(4);
|
|
193
|
+
const repo = normalizeRepo(flagValue(args, ['--repo']));
|
|
194
|
+
const number = flagValue(args, ['--number']);
|
|
195
|
+
return repo && number && /^\d+$/.test(number) ? prTouch(repo, Number(number), action) : undefined;
|
|
196
|
+
}
|
|
197
|
+
function linearUpdateTouches(tokens) {
|
|
198
|
+
const args = tokens.slice(2);
|
|
199
|
+
const status = args.includes('--done') ? 'done'
|
|
200
|
+
: args.includes('--pickup') ? 'started'
|
|
201
|
+
: args.includes('--todo') ? 'moved to Todo'
|
|
202
|
+
: flagValue(args, ['--status']) ? `moved to ${flagValue(args, ['--status'])}`
|
|
203
|
+
: undefined;
|
|
204
|
+
const action = status
|
|
205
|
+
?? (flagValue(args, ['--comment', '--proof']) !== undefined ? 'commented' : 'updated');
|
|
206
|
+
const ids = positionals(args, LINEAR_UPDATE_VALUE_FLAGS).flatMap(t => linearIssueKeys(t).filter(k => k === t.toUpperCase()));
|
|
207
|
+
return [...new Set(ids)].map(id => ({ id, action }));
|
|
208
|
+
}
|
|
209
|
+
function exitStatusCounts(segments, index) {
|
|
210
|
+
return segments.slice(index, -1).every(s => s.op === '&&');
|
|
211
|
+
}
|
|
212
|
+
export function touchesFromCommand(command, cwd, repoForDir = githubRepoForDir) {
|
|
213
|
+
const prs = [];
|
|
214
|
+
const tickets = [];
|
|
215
|
+
const segments = splitTopLevel(command);
|
|
216
|
+
let dir = cwd;
|
|
217
|
+
segments.forEach((segment, index) => {
|
|
218
|
+
const tokens = withoutEnvPrefix(tokenizeBash(segment.text)[0] ?? []);
|
|
219
|
+
const bin = path.basename(tokens[0] ?? '');
|
|
220
|
+
if (bin === 'cd') {
|
|
221
|
+
dir = resolveCommandDir(dir, tokens[1]);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const mark = exitStatusCounts(segments, index) ? {} : { masked: true };
|
|
225
|
+
if (bin === 'gh' && tokens[1] === 'pr') {
|
|
226
|
+
const pr = ghPrTouch(tokens, () => (dir ? repoForDir(dir) : undefined));
|
|
227
|
+
if (pr)
|
|
228
|
+
prs.push({ ...pr, ...mark });
|
|
229
|
+
}
|
|
230
|
+
else if ((bin === 'agents' || bin === 'ag') && tokens[1] === 'projects' && tokens[2] === 'prs') {
|
|
231
|
+
const pr = agentsPrsTouch(tokens);
|
|
232
|
+
if (pr)
|
|
233
|
+
prs.push({ ...pr, ...mark });
|
|
234
|
+
}
|
|
235
|
+
else if (bin === 'linear' && tokens[1] === 'update') {
|
|
236
|
+
tickets.push(...linearUpdateTouches(tokens).map(t => ({ ...t, ...mark })));
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
return { prs, tickets };
|
|
240
|
+
}
|
|
241
|
+
const REPO_CACHE_MAX = 1024;
|
|
242
|
+
const repoByDir = new Map();
|
|
243
|
+
function githubRepoForDir(dir) {
|
|
244
|
+
const cached = repoByDir.get(dir);
|
|
245
|
+
if (cached !== undefined)
|
|
246
|
+
return cached ?? undefined;
|
|
247
|
+
let repo = null;
|
|
248
|
+
try {
|
|
249
|
+
if (fs.statSync(dir).isDirectory()) {
|
|
250
|
+
const url = execFileSync('git', ['-C', dir, 'config', '--get', 'remote.origin.url'], {
|
|
251
|
+
encoding: 'utf-8',
|
|
252
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
253
|
+
timeout: 2_000,
|
|
254
|
+
});
|
|
255
|
+
repo = repoFromRemote(url);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
catch { }
|
|
259
|
+
if (repoByDir.size >= REPO_CACHE_MAX)
|
|
260
|
+
repoByDir.delete(repoByDir.keys().next().value);
|
|
261
|
+
repoByDir.set(dir, repo);
|
|
262
|
+
return repo ?? undefined;
|
|
263
|
+
}
|
|
264
|
+
function resolveCommandDir(cwd, cdTarget) {
|
|
265
|
+
if (!cdTarget || cdTarget === '~')
|
|
266
|
+
return os.homedir();
|
|
267
|
+
const expanded = cdTarget.startsWith('~/') ? path.join(os.homedir(), cdTarget.slice(2)) : cdTarget;
|
|
268
|
+
if (path.isAbsolute(expanded))
|
|
269
|
+
return expanded;
|
|
270
|
+
return cwd ? path.resolve(cwd, expanded) : undefined;
|
|
271
|
+
}
|
|
272
|
+
export function trackPendingTouches(pending, id, touches) {
|
|
273
|
+
if (touches.prs.length === 0 && touches.tickets.length === 0)
|
|
274
|
+
return;
|
|
275
|
+
if (pending.size >= PENDING_MAX)
|
|
276
|
+
pending.delete(pending.keys().next().value);
|
|
277
|
+
pending.set(id, touches);
|
|
278
|
+
}
|
|
279
|
+
export function recordTouches(ledger, touches, output, created) {
|
|
280
|
+
const createdPrs = new Set(created.prUrls.map(u => u.toLowerCase()));
|
|
281
|
+
const createdTickets = new Set([...created.tickets].map(t => t.toUpperCase()));
|
|
282
|
+
for (const { masked, ...pr } of touches.prs) {
|
|
283
|
+
if (masked && !(pr.action === 'merged' && MERGED_EVIDENCE_RE.test(output)))
|
|
284
|
+
continue;
|
|
285
|
+
const key = pr.url.toLowerCase();
|
|
286
|
+
if (createdPrs.has(key))
|
|
287
|
+
continue;
|
|
288
|
+
ledger.touchedPrs = [pr, ...ledger.touchedPrs.filter(p => p.url.toLowerCase() !== key)].slice(0, TOUCHED_MAX);
|
|
289
|
+
}
|
|
290
|
+
for (const { masked, ...ticket } of touches.tickets) {
|
|
291
|
+
if (masked)
|
|
292
|
+
continue;
|
|
293
|
+
if (createdTickets.has(ticket.id))
|
|
294
|
+
continue;
|
|
295
|
+
ledger.touchedTickets = [ticket, ...ledger.touchedTickets.filter(t => t.id !== ticket.id)].slice(0, TOUCHED_MAX);
|
|
296
|
+
}
|
|
297
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phnx-labs/agents-cli",
|
|
3
|
-
"version": "1.23.
|
|
3
|
+
"version": "1.23.34",
|
|
4
4
|
"description": "One CLI for all your AI coding agents - versions, config, cloud dispatch, sessions, and teams (now with first-class Grok Build CLI support)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|