@phnx-labs/agents-cli 1.23.30 → 1.23.31

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.31
4
+
5
+ - **A session row's `title` is the one name to show, and a fork says it is one.** `title` on `agents ps --json`, `agents ps watch --json` and `agents feed watch --json` (live and history rows) is never Claude's `<folder>-<n>` placeholder such as "agents-92" or "agents-1f", never the `[host/<device>]` fallback, and never an injected note, sub-agent hand-back or bare slash command; it falls through to the next usable name instead of going empty. A session started by `agents fork` carries `forkOf` (the source session id) and, until it has a name of its own, the source's name as its `title` instead of "fork of …". `agents fork` no longer launches an unnamed fork with `--name "fork of …"`, so the harness's own title takes over once it writes one; `--name` still names it. Source: `cli/src/lib/session/title.ts`, `cli/src/lib/session/fork.ts`, `cli/src/lib/session/active.ts`, `cli/src/lib/session/remote/watch.ts`, `cli/src/commands/fork.ts`.
6
+
3
7
  ## 1.23.30
4
8
 
5
9
  - **Session rows tell the truth about questions, replies, PRs and limits (#3989).** A permission prompt no longer replaces the open question a Claude session is asking, and an `AskUserQuestion` permission request opens nothing of its own, so the question's choices stay answerable. A question the user rejects clears (`PostToolUseFailure`), so the next permission prompt shows. `agents feed answer` types into the terminal the watchdog resolves (a VSCodium tab, or a tmux pane) when the session has no reply rail; VSCodium cannot confirm delivery, so that answer reports `unknown` and resolves when the session moves on. Live rows carry `prs` when a session opened more than one PR (rows of ended sessions keep the newest `pr`). With `@phnx-labs/sessions-cli` 0.8.7, a session reads as rate-limited only when it is stopped on a limit (not when its tool output mentions 429), a transcript ending in a large compaction line still reads, and pages rewritten under `.agents/artifacts/`, `plans/` or `reports/` count as artifacts. Source: cli/src/lib/feed/feed.ts, cli/src/lib/answer-router.ts, cli/src/lib/session/active.ts
@@ -40,6 +40,8 @@ const FORK_HELP = {
40
40
  - The recap carries the source id — the sibling can run '/continue <id>' for the
41
41
  full history if it needs more than the recap.
42
42
  - Resolve the source the same way as resume: an exact or prefix id fragment.
43
+ - Without --name the fork's row carries forkOf (the source id) and the source's
44
+ name as its title until the harness gives the fork a name of its own.
43
45
  `,
44
46
  };
45
47
  export async function runFork(sessionArg, options, deps = defaultDeps()) {
@@ -81,7 +83,9 @@ export async function runFork(sessionArg, options, deps = defaultDeps()) {
81
83
  lastAssistant: digest?.lastAssistant,
82
84
  changes: digest?.changes,
83
85
  });
84
- const runArgs = ['run', source.agent, recap, '-i', '--strategy', 'balanced', '--name', options.name || `fork of ${label}`];
86
+ const runArgs = ['run', source.agent, recap, '-i', '--strategy', 'balanced'];
87
+ if (options.name)
88
+ runArgs.push('--name', options.name);
85
89
  const sourceIsHere = !source.machine || isSelfHost(source.machine);
86
90
  const landsOnSource = !options.device
87
91
  ? sourceIsHere
@@ -106,7 +110,7 @@ export function registerForkCommand(program) {
106
110
  const cmd = program
107
111
  .command('fork <session>')
108
112
  .description('Branch a session into a new same-harness sibling, seeded with a recap so it continues the work. The original is untouched.')
109
- .option('--name <label>', 'Session label for the fork (default: "fork of <original>")')
113
+ .option('--name <label>', 'Session label for the fork (default: the source\'s name until the fork names itself)')
110
114
  .option('--device <host>', 'Place the sibling on a fleet device (name or "auto"); defaults to here')
111
115
  .option('--terminal [backend]', 'Open the sibling in a real terminal tab (iterm | ghostty | terminal | tmux | vscodium-agent) instead of in-place');
112
116
  setHelpSections(cmd, FORK_HELP);
@@ -43,7 +43,7 @@ export declare function serializeActiveSessionsForJson(sessions: ActiveSession[]
43
43
  export declare function serializeSessionsJson(sessions: SessionMeta[]): string;
44
44
  export type ActiveStatus = 'running' | 'idle' | 'queued' | 'input_required' | 'closed' | 'abandoned' | 'orphaned' | 'crashed' | 'unknown';
45
45
  export type SessionPhase = 'running' | 'waiting' | 'failed' | 'done' | 'idle';
46
- export type RecapSource = 'label' | 'generated' | 'prompt';
46
+ export type RecapSource = 'label' | 'generated' | 'fork' | 'prompt';
47
47
  export type ImportantMessageKind = 'question' | 'needs_you' | 'activity';
48
48
  export interface SessionImportantMessage {
49
49
  text: string;
@@ -80,6 +80,7 @@ export interface ActiveSession {
80
80
  lastUserMessage?: string;
81
81
  generatedTitle?: string;
82
82
  title?: string;
83
+ forkOf?: string;
83
84
  startedAs?: string;
84
85
  recap?: SessionRecap;
85
86
  recapSource?: RecapSource;
@@ -265,8 +266,9 @@ export declare function foldExecutionMachine(rows: ActiveSession[], machineOf: (
265
266
  export declare function sessionProcessIsLocal(s: Pick<ActiveSession, 'machine' | 'offloadedFrom'>, self: string): boolean;
266
267
  export declare function sessionProcessHost(s: Pick<ActiveSession, 'machine' | 'offloadedFrom'>, self: string): string | undefined;
267
268
  export declare function foldHostLink(rows: ActiveSession[]): void;
268
- export declare function deriveSessionRecap(row: Pick<ActiveSession, 'label' | 'generatedTitle' | 'topic' | 'tail' | 'firstUserMessage' | 'lastUserMessage' | 'attachments' | 'request'>): {
269
+ export declare function deriveSessionRecap(row: Pick<ActiveSession, 'label' | 'generatedTitle' | 'topic' | 'tail' | 'firstUserMessage' | 'lastUserMessage' | 'attachments' | 'request' | 'cwd' | 'startedAs'>): {
269
270
  title?: string;
271
+ forkOf?: string;
270
272
  recapSource?: RecapSource;
271
273
  userPromptClean?: string;
272
274
  userPromptKind?: UserPromptKind;
@@ -16,7 +16,8 @@ import { readSessionActorRecord, writeSessionAliasRecord } from './actor-sidecar
16
16
  import { loadHookSessionIndex, resolveHookSessionRecord, readStateSessionRecord } from './hook-sessions.js';
17
17
  import { extractClaudeUserText, getAgentSessionDirs, readClaudeLiveNames } from './discover.js';
18
18
  import { buildRunNameMap } from './run-names.js';
19
- import { resolveSessionName, startedAsFromUserTurn } from './title.js';
19
+ import { cleanDisplayTitle, isPlaceholderSessionName, resolveSessionName, startedAsFromUserTurn } from './title.js';
20
+ import { forkSourceOf } from './fork.js';
20
21
  import { getIndexedSessionNames, latestSessionFileForCwd, indexedSessionIdForFile, findSessionsByShortIds, findSessionMachinesByIds, getSessionById } from './db.js';
21
22
  import { extractSessionTopic, classifyUserPrompt, tidyRequest } from '@phnx-labs/sessions-cli/reader';
22
23
  import { readSessionTailWithRaw } from '@phnx-labs/sessions-cli/reader';
@@ -1445,25 +1446,29 @@ export function deriveSessionRecap(row) {
1445
1446
  });
1446
1447
  const userPromptClean = tidied?.headline ?? fallback?.clean;
1447
1448
  const userPromptKind = tidied?.kind ?? fallback?.kind;
1448
- const label = recapLine(row.label);
1449
- const generated = recapLine(row.generatedTitle);
1450
- const prompt = recapLine(userPromptClean || row.topic);
1449
+ const fork = forkSourceOf(row.firstUserMessage ?? row.topic);
1450
+ const ownLabel = row.label && !(fork && row.label.trim() === `fork of ${fork.label}`) ? row.label : undefined;
1451
+ const rungs = [
1452
+ ['label', ownLabel],
1453
+ ['fork', fork?.label],
1454
+ ['generated', row.generatedTitle],
1455
+ ['prompt', userPromptClean],
1456
+ ['prompt', row.topic],
1457
+ ['prompt', row.startedAs],
1458
+ ];
1451
1459
  let title;
1452
1460
  let recapSource;
1453
- if (label) {
1454
- title = label;
1455
- recapSource = 'label';
1456
- }
1457
- else if (generated) {
1458
- title = generated;
1459
- recapSource = 'generated';
1460
- }
1461
- else if (prompt) {
1462
- title = prompt;
1463
- recapSource = 'prompt';
1461
+ for (const [source, candidate] of rungs) {
1462
+ const clean = isPlaceholderSessionName(candidate, row.cwd) ? undefined : recapLine(cleanDisplayTitle(candidate));
1463
+ if (clean) {
1464
+ title = clean;
1465
+ recapSource = source;
1466
+ break;
1467
+ }
1464
1468
  }
1465
1469
  return {
1466
1470
  title,
1471
+ ...(fork?.id ? { forkOf: fork.id } : {}),
1467
1472
  recapSource,
1468
1473
  userPromptClean: recapLine(userPromptClean),
1469
1474
  userPromptKind,
@@ -1495,9 +1500,10 @@ export function deriveImportantMessage(row) {
1495
1500
  return undefined;
1496
1501
  }
1497
1502
  function applyRecap(s) {
1503
+ s.startedAs ??= s.firstUserMessage ? startedAsFromUserTurn(s.firstUserMessage) : undefined;
1498
1504
  const recap = deriveSessionRecap(s);
1499
1505
  s.title = recap.title;
1500
- s.startedAs ??= s.firstUserMessage ? startedAsFromUserTurn(s.firstUserMessage) : undefined;
1506
+ s.forkOf = recap.forkOf;
1501
1507
  s.recapSource = recap.recapSource;
1502
1508
  s.userPromptClean = recap.userPromptClean;
1503
1509
  s.userPromptKind = recap.userPromptKind;
@@ -15,6 +15,11 @@ interface ForkRecapInput {
15
15
  lastAssistant?: string;
16
16
  changes?: ForkRecapChanges;
17
17
  }
18
- export declare function forkLabelFor(session: Pick<SessionMeta, 'label' | 'generatedTitle' | 'topic' | 'shortId'>): string;
18
+ export declare function forkLabelFor(session: Pick<SessionMeta, 'label' | 'generatedTitle' | 'topic' | 'shortId' | 'cwd'>): string;
19
+ export interface ForkSource {
20
+ label: string;
21
+ id?: string;
22
+ }
23
+ export declare function forkSourceOf(firstUserMessage: string | null | undefined): ForkSource | undefined;
19
24
  export declare function buildForkRecap(input: ForkRecapInput): string;
20
25
  export {};
@@ -9,6 +9,15 @@ function trimLastLine(text) {
9
9
  export function forkLabelFor(session) {
10
10
  return sessionHeadline(session) || session.shortId;
11
11
  }
12
+ const FORK_OPENING_RE = /^Continue a prior \S+ session \("(.+)"\)\. Pick up where it left off/;
13
+ const FORK_SOURCE_RE = /run `\/continue ([^`\s]+)` if you need the full transcript\.$/m;
14
+ export function forkSourceOf(firstUserMessage) {
15
+ const label = firstUserMessage ? FORK_OPENING_RE.exec(firstUserMessage)?.[1] : undefined;
16
+ if (!label)
17
+ return undefined;
18
+ const id = FORK_SOURCE_RE.exec(firstUserMessage)?.[1];
19
+ return id ? { label, id } : { label };
20
+ }
12
21
  export function buildForkRecap(input) {
13
22
  const lines = [];
14
23
  lines.push(`Continue a prior ${input.agent} session ("${input.label}"). Pick up where it left off — do not restart it.`);
@@ -73,9 +73,6 @@ function epochMs(value) {
73
73
  function previousSessionWatchRowKey(scope, sessionId) {
74
74
  return createHash('sha256').update(`${scope}\0previous\0${sessionId}`).digest('base64url').slice(0, 22);
75
75
  }
76
- function previousRowTitle(session, foldedHeadline) {
77
- return session.label || session.generatedTitle || foldedHeadline || session.topic || undefined;
78
- }
79
76
  function previousRowCard(session, request, attachments) {
80
77
  const digest = readCachedPreviewDigest(session);
81
78
  const recap = deriveSessionRecap({
@@ -89,6 +86,8 @@ function previousRowCard(session, request, attachments) {
89
86
  const todos = digest?.todos ?? session.todos;
90
87
  const importantMessage = deriveImportantMessage({ status: 'closed', lastAgentLine: recap.lastAgentLine });
91
88
  return {
89
+ ...(recap.title ? { title: recap.title } : {}),
90
+ ...(recap.forkOf ? { forkOf: recap.forkOf } : {}),
92
91
  ...(recap.lastAgentLine ? { lastAgentLine: recap.lastAgentLine } : {}),
93
92
  ...(recap.request ? { request: recap.request } : {}),
94
93
  ...(recap.userPromptClean ? { userPromptClean: recap.userPromptClean } : {}),
@@ -116,7 +115,6 @@ export function toPreviousSessionWatchRow(scope, session, accounts = listNativeA
116
115
  : readSessionSummaryAny(session.id);
117
116
  const folded = readSessionTimelineAny(session.id);
118
117
  const model = folded?.model ?? session.model;
119
- const title = previousRowTitle(session, folded?.request?.headline);
120
118
  const card = previousRowCard(session, folded?.request, folded?.attachments);
121
119
  return {
122
120
  context: 'recent',
@@ -129,7 +127,6 @@ export function toPreviousSessionWatchRow(scope, session, accounts = listNativeA
129
127
  confirmedProject: confirmedProjectForCwd(session.cwd) ?? null,
130
128
  ...(session.label ? { label: session.label } : {}),
131
129
  ...(session.generatedTitle ? { generatedTitle: session.generatedTitle } : {}),
132
- ...(title ? { title } : {}),
133
130
  ...(session.topic ? { topic: session.topic } : {}),
134
131
  ...(session.firstUserMessage ? { firstUserMessage: session.firstUserMessage } : {}),
135
132
  ...(session.version ? { version: session.version } : {}),
@@ -25,7 +25,10 @@ export declare function sessionHeadline<T extends {
25
25
  label?: string | null;
26
26
  generatedTitle?: string | null;
27
27
  topic?: string | null;
28
+ cwd?: string | null;
28
29
  }>(row: CarriesTitleRung<T>): string | undefined;
30
+ export declare function isPlaceholderSessionName(name: string | null | undefined, cwd?: string | null): boolean;
31
+ export declare function cleanDisplayTitle(raw: string | null | undefined): string | undefined;
29
32
  export interface SessionRecap {
30
33
  text: string;
31
34
  at: string;
@@ -69,7 +69,38 @@ export function sanitizeGeneratedTitle(raw) {
69
69
  return title || undefined;
70
70
  }
71
71
  export function sessionHeadline(row) {
72
- return row.label || row.generatedTitle || row.topic || undefined;
72
+ const label = isPlaceholderSessionName(row.label, row.cwd) ? undefined : row.label;
73
+ return label || row.generatedTitle || row.topic || undefined;
74
+ }
75
+ const HOST_FALLBACK_LABEL_RE = /^\[host\/[^\]]+\]$/;
76
+ const PLACEHOLDER_SUFFIX_RE = /^(?:\d+|(?=[0-9a-f]*\d)[0-9a-f]{1,4})$/i;
77
+ export function isPlaceholderSessionName(name, cwd) {
78
+ const n = name?.trim();
79
+ if (!n)
80
+ return false;
81
+ if (HOST_FALLBACK_LABEL_RE.test(n))
82
+ return true;
83
+ const dir = cwd?.replace(/[/\\]+$/, '').split(/[/\\]/).pop();
84
+ if (!dir || n.length <= dir.length + 1)
85
+ return false;
86
+ return n.slice(0, dir.length + 1).toLowerCase() === `${dir.toLowerCase()}-` && PLACEHOLDER_SUFFIX_RE.test(n.slice(dir.length + 1));
87
+ }
88
+ const INJECTED_NOTE_RE = /^another \w+ session sent a message:?\s*/i;
89
+ export function cleanDisplayTitle(raw) {
90
+ if (!raw || /^\s*<(?:task-notification|system-reminder)/i.test(raw))
91
+ return undefined;
92
+ const t = raw
93
+ .replace(/<\/?agent-message[^>]*>/gi, ' ')
94
+ .replace(INJECTED_NOTE_RE, '')
95
+ .replace(/\[([^\]]+)\]\([^)]*(?:\)|$)/g, '$1')
96
+ .replace(/[`*]+/g, '')
97
+ .replace(/^[#>\s]+/, '')
98
+ .replace(/\s+/g, ' ')
99
+ .trim()
100
+ .replace(/^[…. ]+$/, '');
101
+ if (!t || /^\[subagent hand-back\]/i.test(t) || /^\/[\w:-]+(?:\s|$)/.test(t))
102
+ return undefined;
103
+ return t;
73
104
  }
74
105
  const CLAUDE_RECAP_HINT_RE = /\s*\(disable recaps in \/config\)\s*$/i;
75
106
  export function claudeRecapFromLine(parsed) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phnx-labs/agents-cli",
3
- "version": "1.23.30",
3
+ "version": "1.23.31",
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",