@phnx-labs/agents-cli 1.23.37 → 1.23.38

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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.23.38
4
+
5
+ - **The Lead can say what moved today (PHNX-4432).** Its tools now print dates. `agents lead tool linear tasks` lists the most recently updated tickets first, each with its age, cut to `--limit` and with a count of older ones (`linear tasks --json` sorts by priority and returns every match, so a done list started with tickets from August). `prs list` and the roster add when each PR was updated, and when each session started and was last active. The brief now keeps the merged and closed PRs among the 40 most recently updated, with their age, under "Merged or closed lately". Before this, "what happened in the last 24 hours" got "none of my tools show history". Source: cli/src/lib/lead/tools.ts, cli/src/lib/lead/brief.ts, cli/src/lib/lead/roster.ts
6
+
3
7
  ## 1.23.37
4
8
 
5
9
  - **A headless run an agent starts no longer takes over that agent's tab.** When a Claude session in an editor tab ran `claude -p` through its shell, the SessionStart hook walked up to the tab agent's `~/.agents/.cache/terminals/by-pid/<pid>.json` and rewrote its session id, so `agents ps`, the feed and the editor showed the tab as the one-second headless run (observed on yosemite-s0 for a zion tab, 2026-10-19). A by-pid entry now yields to the session its own process recorded at SessionStart (`state/sessions/<pid>.json`), which only that process writes, so the tab, its launch id and `agents message` resolve to the real session again, including for entries an older hook already rewrote. Source: cli/src/lib/session/pid-registry.ts, cli/src/lib/session/hook-sessions.ts
@@ -13,6 +13,9 @@ export interface BriefPr {
13
13
  url: string;
14
14
  draft: boolean;
15
15
  open: boolean;
16
+ updatedAt?: string;
17
+ mergedAt?: string;
18
+ closedAt?: string;
16
19
  }
17
20
  export interface BriefInputs {
18
21
  project: string;
@@ -36,7 +39,7 @@ export declare function fetchRecentPrs(repo: string | undefined, cwd: string | u
36
39
  export declare function linearTeamKey(home: string): string | undefined;
37
40
  export declare function quoteNotes(memory: string): string;
38
41
  export declare function projectRepo(def: ProjectDef): string | undefined;
39
- export declare function buildBrief(inputs: BriefInputs): string;
42
+ export declare function buildBrief(inputs: BriefInputs, nowMs?: number): string;
40
43
  export declare function briefSummary(inputs: BriefInputs): string[];
41
44
  export declare function fleetLine(rows: Array<{
42
45
  status: string;
@@ -2,16 +2,16 @@ import * as fs from 'node:fs';
2
2
  import * as path from 'node:path';
3
3
  import { execFile } from 'node:child_process';
4
4
  import { createHash } from 'node:crypto';
5
- import { formatRosterRow } from './roster.js';
5
+ import { ago, formatRosterRow } from './roster.js';
6
6
  export const BRIEF_FETCH_TIMEOUT_MS = 8_000;
7
7
  const DIGEST_MAX_CHARS = 2_500;
8
8
  export const LEAD_RULES = [
9
9
  'You are the Lead for this project: one long-lived agent the owner talks or types to. You dispatch and manage coding agents; you never edit files.',
10
10
  'Your only tools are these shell commands, each run on its own (no pipes, ;, &&, redirects or $(...); those are denied):',
11
- ' `agents lead tool roster [--project <name>]` lists live sessions from the live feed. It is the only way to see sessions.',
11
+ ' `agents lead tool roster [--project <name>]` lists live sessions from the live feed, each with when it started and was last active. It is the only way to see sessions.',
12
12
  ' `agents lead tool attention` lists every open ask across the fleet (question, choices, its key). It is the only way to see what agents are asking.',
13
- ' `agents lead tool prs list [--repo <owner/repo>]` lists this project\'s open PRs.',
14
- ' `agents lead tool linear tasks [--status open|todo|progress|backlog|done]`, `agents lead tool linear view <ID>`, `agents lead tool linear create --title <title> [--description <text>]`.',
13
+ ' `agents lead tool prs list [--repo <owner/repo>]` lists this project\'s open PRs, each with when it was last updated.',
14
+ ' `agents lead tool linear tasks [--status open|todo|progress|backlog|done] [--limit 1-50]` (most recently updated first, each with its age), `agents lead tool linear view <ID>`, `agents lead tool linear create --title <title> [--description <text>]`.',
15
15
  'These queue one action for the owner\'s Confirm and never act themselves:',
16
16
  ' `agents lead tool answer --key <key> (--choice <id> | --text <answer>)` answers an open ask from the attention tool.',
17
17
  ' `agents lead tool send --session <id> -- <text>` types a message into a running session of this project (no slash commands).',
@@ -89,7 +89,12 @@ export async function fetchRecentPrs(repo, cwd) {
89
89
  if (!repo)
90
90
  throw new Error('project has no GitHub repo');
91
91
  const raw = JSON.parse(await run('gh', ['api', `repos/${repo}/pulls?state=all&sort=updated&direction=desc&per_page=40`], cwd));
92
- return raw.map((p) => ({ number: p.number, title: p.title, url: p.html_url, draft: p.draft === true, open: p.state === 'open' }));
92
+ return raw.map((p) => ({
93
+ number: p.number, title: p.title, url: p.html_url, draft: p.draft === true, open: p.state === 'open',
94
+ ...(p.updated_at ? { updatedAt: p.updated_at } : {}),
95
+ ...(p.merged_at ? { mergedAt: p.merged_at } : {}),
96
+ ...(p.closed_at ? { closedAt: p.closed_at } : {}),
97
+ }));
93
98
  }
94
99
  export function linearTeamKey(home) {
95
100
  let raw;
@@ -113,7 +118,7 @@ export function quoteNotes(memory) {
113
118
  export function projectRepo(def) {
114
119
  return def.repo ?? def.repos?.[0]?.slug;
115
120
  }
116
- export function buildBrief(inputs) {
121
+ export function buildBrief(inputs, nowMs = Date.now()) {
117
122
  const { def } = inputs;
118
123
  const out = [];
119
124
  out.push(`# Lead brief: ${inputs.project}`);
@@ -128,7 +133,7 @@ export function buildBrief(inputs) {
128
133
  if (inputs.agentsDigest)
129
134
  out.push('', '## AGENTS.md digest', inputs.agentsDigest);
130
135
  const rows = Object.values(inputs.roster);
131
- out.push('', `## Live sessions (${rows.length})`, ...(rows.length ? rows.map(formatRosterRow) : ['None.']), inputs.fleet);
136
+ out.push('', `## Live sessions (${rows.length})`, ...(rows.length ? rows.map((r) => formatRosterRow(r, nowMs)) : ['None.']), inputs.fleet);
132
137
  out.push('', '## Open tickets');
133
138
  if ('error' in inputs.tickets)
134
139
  out.push(`Unavailable: ${inputs.tickets.error}`);
@@ -143,7 +148,12 @@ export function buildBrief(inputs) {
143
148
  else if (open.length === 0)
144
149
  out.push('None.');
145
150
  else
146
- out.push(...open.map((p) => `- #${p.number} ${p.title}${p.draft ? ' (draft)' : ''}`));
151
+ out.push(...open.map((p) => `- #${p.number} ${p.title}${p.draft ? ' (draft)' : ''}${p.updatedAt ? ` · updated ${ago(p.updatedAt, nowMs)}` : ''}`));
152
+ const ended = 'error' in inputs.prs ? [] : inputs.prs.filter((p) => !p.open);
153
+ if (ended.length) {
154
+ out.push('', `## Merged or closed lately (as of ${new Date(nowMs).toISOString()})`);
155
+ out.push(...ended.map((p) => `- #${p.number} ${p.title} · ${p.mergedAt ? `merged ${ago(p.mergedAt, nowMs)}` : `closed without merging ${p.closedAt ? ago(p.closedAt, nowMs) : ''}`.trimEnd()}`));
156
+ }
147
157
  out.push('', '## Memory', quoteNotes(inputs.memory));
148
158
  return out.join('\n');
149
159
  }
@@ -307,7 +307,7 @@ export class LeadHost {
307
307
  if (!this.roster.ready)
308
308
  throw new Error('The live feed is not connected yet; try again in a few seconds.');
309
309
  const rows = Object.values(this.projectRoster(project));
310
- const lines = rows.length ? rows.map(formatRosterRow) : [`No live sessions for ${project}.`];
310
+ const lines = rows.length ? rows.map((r) => formatRosterRow(r, Date.now())) : [`No live sessions for ${project}.`];
311
311
  return { type: 'roster', text: [`Live sessions for ${project} (${rows.length}):`, ...lines, this.fleetSummary()].join('\n') };
312
312
  }
313
313
  resolveReply(session) {
@@ -6,6 +6,8 @@ export interface RosterRow {
6
6
  project?: string;
7
7
  cwd?: string;
8
8
  ticket?: string;
9
+ startedAtMs?: number;
10
+ lastActivityMs?: number;
9
11
  }
10
12
  export type RosterSnapshot = Record<string, RosterRow>;
11
13
  export interface LeadAttention {
@@ -38,7 +40,8 @@ export declare class FeedRoster {
38
40
  private scopeRows;
39
41
  }
40
42
  export declare function filterProject(snapshot: RosterSnapshot, project: string, projectForCwd: (cwd: string | undefined) => string | undefined, exclude?: ReadonlySet<string>): RosterSnapshot;
41
- export declare function formatRosterRow(row: RosterRow): string;
42
- export declare function rosterDelta(prev: RosterSnapshot | null, cur: RosterSnapshot): string[];
43
+ export declare function formatRosterRow(row: RosterRow, nowMs: number): string;
44
+ export declare function rosterDelta(prev: RosterSnapshot | null, cur: RosterSnapshot, nowMs?: number): string[];
45
+ export declare function ago(at: string | number, nowMs: number): string;
43
46
  export declare function formatAttention(ask: LeadAttention, row: RosterRow | undefined, nowMs?: number): string;
44
47
  export {};
@@ -2,6 +2,9 @@ import { sessionHeadline } from '../session/title.js';
2
2
  function str(v) {
3
3
  return typeof v === 'string' && v.length > 0 ? v : undefined;
4
4
  }
5
+ function num(v) {
6
+ return typeof v === 'number' && Number.isFinite(v) && v > 0 ? v : undefined;
7
+ }
5
8
  export function rosterRowFromFeed(scope, agent) {
6
9
  const id = str(agent.sessionId);
7
10
  if (!id || agent.previous === true)
@@ -16,6 +19,8 @@ export function rosterRowFromFeed(scope, agent) {
16
19
  project: str(agent.confirmedProject),
17
20
  cwd: str(agent.cwd),
18
21
  ticket: str(agent.ticketId),
22
+ startedAtMs: num(agent.startedAtMs),
23
+ lastActivityMs: num(agent.lastActivityMs),
19
24
  };
20
25
  }
21
26
  export function attentionFromFeed(item) {
@@ -148,14 +153,16 @@ export function filterProject(snapshot, project, projectForCwd, exclude = new Se
148
153
  }
149
154
  return out;
150
155
  }
151
- export function formatRosterRow(row) {
156
+ export function formatRosterRow(row, nowMs) {
152
157
  const ticket = row.ticket ? ` ${row.ticket}` : '';
153
- return `- ${row.id.slice(0, 8)} “${row.title}” ${row.status} on ${row.host}${ticket}`;
158
+ const started = row.startedAtMs ? ` · started ${ago(row.startedAtMs, nowMs)}` : '';
159
+ const active = row.lastActivityMs ? ` · last active ${ago(row.lastActivityMs, nowMs)}` : '';
160
+ return `- ${row.id.slice(0, 8)} “${row.title}” ${row.status} on ${row.host}${ticket}${started}${active}`;
154
161
  }
155
- export function rosterDelta(prev, cur) {
162
+ export function rosterDelta(prev, cur, nowMs = Date.now()) {
156
163
  if (!prev) {
157
164
  const rows = Object.values(cur);
158
- return rows.length === 0 ? ['No live sessions for this project.'] : rows.map(formatRosterRow);
165
+ return rows.length === 0 ? ['No live sessions for this project.'] : rows.map((r) => formatRosterRow(r, nowMs));
159
166
  }
160
167
  const lines = [];
161
168
  for (const row of Object.values(cur)) {
@@ -174,8 +181,8 @@ export function rosterDelta(prev, cur) {
174
181
  return lines;
175
182
  }
176
183
  const MAX_QUESTION_CHARS = 240;
177
- function age(openedAt, nowMs) {
178
- const ms = nowMs - Date.parse(openedAt);
184
+ export function ago(at, nowMs) {
185
+ const ms = nowMs - (typeof at === 'number' ? at : Date.parse(at));
179
186
  if (!Number.isFinite(ms) || ms < 0)
180
187
  return 'just now';
181
188
  const mins = Math.floor(ms / 60_000);
@@ -192,5 +199,5 @@ export function formatAttention(ask, row, nowMs = Date.now()) {
192
199
  const title = row?.title ?? ask.sessionId.slice(0, 8);
193
200
  const project = ask.project ?? row?.project;
194
201
  const choices = ask.choices.length ? ` Choices: ${ask.choices.map((c) => `${c.id}=${c.label}`).join(', ')}` : ' Free-text answer.';
195
- return `- ${ask.key} “${title}” on ${ask.host}${project ? ` · ${project}` : ''} · ${age(ask.openedAt, nowMs)}: ${trimmed}${choices}`;
202
+ return `- ${ask.key} “${title}” on ${ask.host}${project ? ` · ${project}` : ''} · ${ago(ask.openedAt, nowMs)}: ${trimmed}${choices}`;
196
203
  }
@@ -10,6 +10,16 @@ export interface LeadToolContext {
10
10
  export declare function leadToolContext(env?: NodeJS.ProcessEnv): LeadToolContext;
11
11
  export declare function toolRoster(ctx: LeadToolContext, project?: string): Promise<string>;
12
12
  export declare function toolAttention(ctx: LeadToolContext): Promise<string>;
13
+ interface LinearIssue {
14
+ identifier: string;
15
+ title: string;
16
+ state?: {
17
+ name?: string;
18
+ };
19
+ url?: string;
20
+ description?: string;
21
+ updatedAt?: string;
22
+ }
13
23
  export declare function toolDispatch(ctx: LeadToolContext, ticket: string, agent: string): Promise<string>;
14
24
  export declare function toolStart(ctx: LeadToolContext, agent: string, task: string): Promise<string>;
15
25
  export declare function toolSend(ctx: LeadToolContext, session: string, text: string): Promise<string>;
@@ -24,6 +34,7 @@ export declare function toolPrAct(ctx: LeadToolContext, verb: PrVerb, opts: {
24
34
  runId?: string;
25
35
  }): Promise<string>;
26
36
  export declare function toolLinearTasks(ctx: LeadToolContext, status: string, limit: number): Promise<string>;
37
+ export declare function formatLinearTasks(issues: LinearIssue[], status: string, limit: number, nowMs: number): string;
27
38
  export declare function toolLinearView(id: string): Promise<string>;
28
39
  export declare function toolLinearCreate(ctx: LeadToolContext, title: string, description?: string): Promise<string>;
29
40
  export declare function toolRemember(ctx: LeadToolContext, note: string): string;
@@ -2,6 +2,7 @@ import { loadProjectDef } from '../projects.js';
2
2
  import { atomicWriteFileSync } from '../fs-atomic.js';
3
3
  import { connectHost, sendRequest } from './client.js';
4
4
  import { runAgents, runLinear } from './act.js';
5
+ import { ago } from './roster.js';
5
6
  import { LeadToolError, answerArgv, appendNote, assertAgent, assertPrNumber, assertRepo, assertSessionId, assertTask, assertTicketId, dispatchPrompt, linearCreateArgv, linearPickupArgv, linearTasksArgv, linearViewArgv, prArgv, prFailureArgv, prReadArgv, prsListArgv, runArgv, sendArgv, } from './shapes.js';
6
7
  import { ensureLeadDir } from './paths.js';
7
8
  import { readMemory } from './store.js';
@@ -94,7 +95,7 @@ export async function toolPrsList(ctx, repo) {
94
95
  continue;
95
96
  }
96
97
  for (const pr of r.pullRequests)
97
- lines.push(`${r.slug}#${pr.number}${pr.isDraft ? ' [draft]' : ''} ${pr.title}`);
98
+ lines.push(`${r.slug}#${pr.number}${pr.isDraft ? ' [draft]' : ''} ${pr.title}${pr.updatedAt ? ` · updated ${ago(pr.updatedAt, Date.now())}` : ''}`);
98
99
  }
99
100
  return lines.length ? lines.join('\n') : `No open PRs for ${ctx.project}.`;
100
101
  }
@@ -147,10 +148,17 @@ export async function toolPrAct(ctx, verb, opts) {
147
148
  }
148
149
  export async function toolLinearTasks(ctx, status, limit) {
149
150
  const raw = JSON.parse(await runLinear(linearTasksArgv(ctx.def, status, limit)));
150
- const issues = raw.issues ?? [];
151
+ return formatLinearTasks(raw.issues ?? [], status, limit, Date.now());
152
+ }
153
+ export function formatLinearTasks(issues, status, limit, nowMs) {
151
154
  if (issues.length === 0)
152
155
  return `No ${status} tickets.`;
153
- return issues.map((i) => `${i.identifier} ${i.title}${i.state?.name ? ` (${i.state.name})` : ''}`).join('\n');
156
+ const when = (i) => (i.updatedAt ? Date.parse(i.updatedAt) || 0 : 0);
157
+ const shown = [...issues].sort((a, b) => when(b) - when(a)).slice(0, limit);
158
+ const lines = shown.map((i) => `${i.identifier} ${i.title}${i.state?.name ? ` (${i.state.name})` : ''}${i.updatedAt ? ` · updated ${ago(i.updatedAt, nowMs)}` : ''}`);
159
+ if (issues.length > shown.length)
160
+ lines.push(`(${issues.length - shown.length} older ${status} tickets not shown)`);
161
+ return lines.join('\n');
154
162
  }
155
163
  export async function toolLinearView(id) {
156
164
  const i = JSON.parse(await runLinear(linearViewArgv(id)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phnx-labs/agents-cli",
3
- "version": "1.23.37",
3
+ "version": "1.23.38",
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",