@tryarcanist/cli 0.1.52 → 0.1.54

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.
Files changed (2) hide show
  1. package/dist/index.js +22 -87
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -523,7 +523,6 @@ function isRecord(value) {
523
523
 
524
524
  // ../../shared/transcript/projector.ts
525
525
  var DUPLICATE_TEXT_DELTA_MIN_CHARS = 24;
526
- var SUBAGENT_EVENT_TYPES = /* @__PURE__ */ new Set(["subagent_start", "subagent_complete", "subagent_tool_call", "subagent_text"]);
527
526
  var RAW_CODEX_NOISE = /* @__PURE__ */ new Set([
528
527
  "session.updated",
529
528
  "session.diff",
@@ -1129,66 +1128,6 @@ function getEmbeddedTerminalHistory(raw) {
1129
1128
  function resolveAuthoritativePromptEvents(raw) {
1130
1129
  return getEmbeddedTerminalHistory(raw) ?? raw;
1131
1130
  }
1132
- function extractSubagentInfo(raw) {
1133
- const empty = {
1134
- names: /* @__PURE__ */ new Map(),
1135
- activity: /* @__PURE__ */ new Map(),
1136
- toolToChildSessions: /* @__PURE__ */ new Map(),
1137
- subagentUsage: /* @__PURE__ */ new Map()
1138
- };
1139
- if (!raw.some((event) => SUBAGENT_EVENT_TYPES.has(getRawSessionEventKind(event)))) return empty;
1140
- const { names, activity, toolToChildSessions, subagentUsage } = empty;
1141
- for (const event of raw) {
1142
- const type = getRawSessionEventKind(event);
1143
- const data = getRawSessionEventData(event);
1144
- if (!data) continue;
1145
- const childSessionId = typeof data.childSessionId === "string" ? data.childSessionId : void 0;
1146
- const parentToolId = typeof data.parentToolId === "string" ? data.parentToolId : void 0;
1147
- const key = childSessionId || parentToolId;
1148
- if (!key) continue;
1149
- if (type === "subagent_start" || type === "subagent_complete") {
1150
- const name = typeof data.name === "string" ? data.name : "";
1151
- if (name) names.set(key, name);
1152
- if (parentToolId && childSessionId) {
1153
- const existing = toolToChildSessions.get(parentToolId) ?? [];
1154
- if (!existing.includes(childSessionId)) existing.push(childSessionId);
1155
- toolToChildSessions.set(parentToolId, existing);
1156
- }
1157
- if (type === "subagent_complete" && isRecord(data.tokenUsage)) {
1158
- subagentUsage.set(key, {
1159
- input: Number(data.tokenUsage.input ?? 0),
1160
- output: Number(data.tokenUsage.output ?? 0),
1161
- cacheRead: Number(data.tokenUsage.cacheRead ?? 0),
1162
- cacheWrite: Number(data.tokenUsage.cacheWrite ?? 0)
1163
- });
1164
- }
1165
- continue;
1166
- }
1167
- if (type === "subagent_tool_call") {
1168
- const items = activity.get(key) ?? [];
1169
- items.push({
1170
- type: "tool",
1171
- tool: typeof data.tool === "string" ? data.tool : "unknown",
1172
- summary: typeof data.summary === "string" ? data.summary : ""
1173
- });
1174
- activity.set(key, items);
1175
- continue;
1176
- }
1177
- if (type === "subagent_text") {
1178
- const delta = typeof data.delta === "string" ? data.delta : typeof data.text === "string" ? data.text : "";
1179
- if (!delta) continue;
1180
- const items = activity.get(key) ?? [];
1181
- const last = items[items.length - 1];
1182
- if (last?.type === "text") {
1183
- items[items.length - 1] = { ...last, text: last.text + delta };
1184
- } else {
1185
- items.push({ type: "text", text: delta });
1186
- }
1187
- activity.set(key, items);
1188
- }
1189
- }
1190
- return { names, activity, toolToChildSessions, subagentUsage };
1191
- }
1192
1131
 
1193
1132
  // ../../shared/types/error-codes.ts
1194
1133
  var ERROR_CODES = [
@@ -1276,33 +1215,13 @@ function formatDate(value) {
1276
1215
  if (Number.isNaN(date.getTime())) return value;
1277
1216
  return date.toISOString().replace("T", " ").replace(/\.\d+Z$/, " UTC");
1278
1217
  }
1279
- function renderSubagentActivityItem(item) {
1280
- if (item.type === "text") return ` - ${item.text}
1281
- `;
1282
- return ` - **Tool:** ${item.tool}${item.summary ? ` - ${item.summary}` : ""}
1283
- `;
1284
- }
1285
- function renderSubagentActivityForTool(toolId, subagents) {
1286
- const childSessionIds = subagents.toolToChildSessions.get(toolId) ?? [];
1287
- if (childSessionIds.length === 0) return "";
1288
- const lines = [];
1289
- for (const childSessionId of childSessionIds) {
1290
- const name = subagents.names.get(childSessionId);
1291
- lines.push(` - **Subagent:** ${name ?? childSessionId}`);
1292
- for (const item of subagents.activity.get(childSessionId) ?? []) {
1293
- lines.push(renderSubagentActivityItem(item).trimEnd());
1294
- }
1295
- }
1296
- return `${lines.join("\n")}
1297
- `;
1298
- }
1299
- function renderTranscriptEvent(event, subagents) {
1218
+ function renderTranscriptEvent(event) {
1300
1219
  switch (event.type) {
1301
1220
  case "text":
1302
1221
  return event.text;
1303
1222
  case "tool_call":
1304
1223
  return `**Tool call:** ${event.tool}${event.summary ? ` - ${event.summary}` : ""}${event.toolStatus ? ` (${event.toolStatus})` : ""}
1305
- ${subagents ? renderSubagentActivityForTool(event.id, subagents) : ""}`;
1224
+ `;
1306
1225
  case "reasoning":
1307
1226
  return `<details><summary>Reasoning</summary>
1308
1227
 
@@ -1378,7 +1297,6 @@ function renderSessionTranscript(exportData) {
1378
1297
  const rawEvents = eventBuckets.get(prompt.id) ?? [];
1379
1298
  const authoritativeEvents = resolveAuthoritativePromptEvents(rawEvents);
1380
1299
  const events = flattenSessionEvents(authoritativeEvents);
1381
- const subagents = extractSubagentInfo(authoritativeEvents);
1382
1300
  lines.push("---\n");
1383
1301
  lines.push(`## Turn ${i + 1}
1384
1302
  `);
@@ -1392,7 +1310,7 @@ function renderSessionTranscript(exportData) {
1392
1310
  lines.push("**Assistant:**\n");
1393
1311
  let pendingText = "";
1394
1312
  for (const event of events) {
1395
- const rendered = renderTranscriptEvent(event, subagents);
1313
+ const rendered = renderTranscriptEvent(event);
1396
1314
  if (!rendered) continue;
1397
1315
  if (event.type === "text") {
1398
1316
  pendingText += rendered;
@@ -1890,6 +1808,9 @@ async function listSessionsCommand(options, command) {
1890
1808
  const query = new URLSearchParams();
1891
1809
  if (options.status) query.set("status", options.status);
1892
1810
  if (options.scope) query.set("scope", options.scope);
1811
+ if (options.search) query.set("q", options.search);
1812
+ if (options.tag) query.set("tag", options.tag);
1813
+ if (options.repo) query.set("repo", options.repo);
1893
1814
  if (options.limit) query.set("limit", options.limit);
1894
1815
  if (options.cursor) query.set("cursor", options.cursor);
1895
1816
  const payload = await apiFetch(
@@ -1908,10 +1829,15 @@ async function listSessionsCommand(options, command) {
1908
1829
  const id = String(session.id ?? session.sessionId ?? "");
1909
1830
  const status = String(session.status ?? "");
1910
1831
  const title = typeof session.title === "string" ? ` ${session.title}` : "";
1911
- console.log(`${id} ${status}${title}`);
1832
+ const tags = Array.isArray(session.titleTags) ? session.titleTags.filter((tag) => typeof tag === "string") : [];
1833
+ const tagText = tags.length > 0 ? ` tags: ${tags.join(", ")}` : "";
1834
+ console.log(`${id} ${status}${title}${tagText}`);
1912
1835
  }
1913
1836
  if (payload.nextCursor) console.log(`Next cursor: ${payload.nextCursor}`);
1914
1837
  }
1838
+ async function searchSessionsCommand(query, options, command) {
1839
+ await listSessionsCommand({ ...options, search: query }, command);
1840
+ }
1915
1841
  async function getSessionCommand(sessionId, options, command) {
1916
1842
  const runtime = getRuntimeOptions(command, options);
1917
1843
  const config = requireConfig(runtime);
@@ -2194,14 +2120,23 @@ Examples:
2194
2120
  arcanist sessions get <session-id> --json
2195
2121
  `
2196
2122
  ).action((sessionId, options, command) => getSessionCommand(sessionId, options, command));
2197
- sessions.command("list").description("List sessions").option("--status <status>", "Filter by session status").option("--scope <scope>", "Session scope: mine or business").option("--limit <n>", "Maximum sessions to return").option("--cursor <cursor>", "Pagination cursor").addHelpText(
2123
+ sessions.command("list").description("List sessions").option("--status <status>", "Filter by session status").option("--scope <scope>", "Session scope: mine or business").option("--search <query>", "Search session titles, tags, and repo metadata").option("--tag <tag>", "Filter by generated session tag").option("--repo <repo>", "Filter by repo metadata").option("--limit <n>", "Maximum sessions to return").option("--cursor <cursor>", "Pagination cursor").addHelpText(
2198
2124
  "after",
2199
2125
  `
2200
2126
  Examples:
2201
2127
  arcanist sessions list
2202
2128
  arcanist sessions list --status idle --json
2129
+ arcanist sessions list --search "architect agent" --tag codex
2203
2130
  `
2204
2131
  ).action((options, command) => listSessionsCommand(options, command));
2132
+ sessions.command("search").description("Search sessions by title, tag, and repo metadata").argument("<query>", "Search query").option("--status <status>", "Filter by session status").option("--scope <scope>", "Session scope: mine or business").option("--tag <tag>", "Filter by generated session tag").option("--repo <repo>", "Filter by repo metadata").option("--limit <n>", "Maximum sessions to return").option("--cursor <cursor>", "Pagination cursor").addHelpText(
2133
+ "after",
2134
+ `
2135
+ Examples:
2136
+ arcanist sessions search "architect agent"
2137
+ arcanist sessions search "mcp debugging" --tag codex --json
2138
+ `
2139
+ ).action((query, options, command) => searchSessionsCommand(query, options, command));
2205
2140
  sessions.command("events").description("Read or follow session replay events").argument("<session-id>", "Session ID").option("--after-sequence <n>", "Return events after this sequence").option("--before-sequence <n>", "Return events before this sequence").option("--prompt-id <id>", "Filter events by prompt ID").option("--limit <n>", "Maximum events to return").option("--follow", "Follow events until the session is idle").option("--poll-interval <ms>", "Polling interval in milliseconds", String(DEFAULT_WATCH_POLL_INTERVAL_MS)).addHelpText(
2206
2141
  "after",
2207
2142
  `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryarcanist/cli",
3
- "version": "0.1.52",
3
+ "version": "0.1.54",
4
4
  "description": "CLI for Arcanist — create and manage coding agent sessions",
5
5
  "type": "module",
6
6
  "bin": {