@tryarcanist/cli 0.1.59 → 0.1.60

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 +66 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1153,8 +1153,52 @@ function getEmbeddedTerminalHistory(raw) {
1153
1153
  }
1154
1154
  return null;
1155
1155
  }
1156
- function resolveAuthoritativePromptEvents(raw) {
1157
- return getEmbeddedTerminalHistory(raw) ?? raw;
1156
+ function promptActivityKey(event) {
1157
+ const data = getRawSessionEventData(event);
1158
+ return [
1159
+ getRawSessionEventPromptId(event) ?? "",
1160
+ typeof data?.phase === "string" ? data.phase : "",
1161
+ typeof data?.detail === "string" ? data.detail : ""
1162
+ ].join("\0");
1163
+ }
1164
+ function resolveAuthoritativePromptEventsWithDiagnostics(raw) {
1165
+ const embeddedHistory = getEmbeddedTerminalHistory(raw);
1166
+ const durablePromptActivity = raw.filter((event) => getRawSessionEventKind(event) === "prompt_activity");
1167
+ if (!embeddedHistory) {
1168
+ return {
1169
+ events: raw,
1170
+ diagnostics: {
1171
+ embeddedHistoryPresent: false,
1172
+ durablePromptActivityCount: durablePromptActivity.length,
1173
+ embeddedPromptActivityCount: 0,
1174
+ mergedDurablePromptActivityCount: 0,
1175
+ duplicateDurablePromptActivityCount: 0
1176
+ }
1177
+ };
1178
+ }
1179
+ const embeddedPromptActivity = embeddedHistory.filter((event) => getRawSessionEventKind(event) === "prompt_activity");
1180
+ const embeddedPromptActivityKeys = new Set(embeddedPromptActivity.map(promptActivityKey));
1181
+ const embeddedPromptActivityCount = embeddedPromptActivity.length;
1182
+ let duplicateDurablePromptActivityCount = 0;
1183
+ const missingDurablePromptActivity = durablePromptActivity.filter((event) => {
1184
+ const key = promptActivityKey(event);
1185
+ if (embeddedPromptActivityKeys.has(key)) {
1186
+ duplicateDurablePromptActivityCount += 1;
1187
+ return false;
1188
+ }
1189
+ embeddedPromptActivityKeys.add(key);
1190
+ return true;
1191
+ });
1192
+ return {
1193
+ events: missingDurablePromptActivity.length > 0 ? [...missingDurablePromptActivity, ...embeddedHistory] : embeddedHistory,
1194
+ diagnostics: {
1195
+ embeddedHistoryPresent: true,
1196
+ durablePromptActivityCount: durablePromptActivity.length,
1197
+ embeddedPromptActivityCount,
1198
+ mergedDurablePromptActivityCount: missingDurablePromptActivity.length,
1199
+ duplicateDurablePromptActivityCount
1200
+ }
1201
+ };
1158
1202
  }
1159
1203
 
1160
1204
  // ../../shared/types/error-codes.ts
@@ -1328,8 +1372,27 @@ function renderSessionTranscript(exportData) {
1328
1372
  for (let i = 0; i < exportData.prompts.length; i++) {
1329
1373
  const prompt = exportData.prompts[i];
1330
1374
  const rawEvents = eventBuckets.get(prompt.id) ?? [];
1331
- const authoritativeEvents = resolveAuthoritativePromptEvents(rawEvents);
1375
+ const { events: authoritativeEvents, diagnostics } = resolveAuthoritativePromptEventsWithDiagnostics(rawEvents);
1376
+ if (diagnostics.mergedDurablePromptActivityCount > 0) {
1377
+ console.error("[transcript] merged durable prompt_activity events missing from embedded terminal history", {
1378
+ sessionId: exportData.session.id,
1379
+ promptId: prompt.id,
1380
+ mergedDurablePromptActivityCount: diagnostics.mergedDurablePromptActivityCount,
1381
+ durablePromptActivityCount: diagnostics.durablePromptActivityCount,
1382
+ embeddedPromptActivityCount: diagnostics.embeddedPromptActivityCount,
1383
+ duplicateDurablePromptActivityCount: diagnostics.duplicateDurablePromptActivityCount
1384
+ });
1385
+ }
1332
1386
  const events = flattenSessionEvents(authoritativeEvents);
1387
+ const renderedPromptActivityCount = events.filter((event) => event.type === "prompt_activity").length;
1388
+ if (diagnostics.durablePromptActivityCount > 0 && renderedPromptActivityCount === 0) {
1389
+ console.error("[transcript] durable prompt_activity events did not render", {
1390
+ sessionId: exportData.session.id,
1391
+ promptId: prompt.id,
1392
+ durablePromptActivityCount: diagnostics.durablePromptActivityCount,
1393
+ authoritativeEventCount: authoritativeEvents.length
1394
+ });
1395
+ }
1333
1396
  lines.push("---\n");
1334
1397
  lines.push(`## Turn ${i + 1}
1335
1398
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryarcanist/cli",
3
- "version": "0.1.59",
3
+ "version": "0.1.60",
4
4
  "description": "CLI for Arcanist — create and manage coding agent sessions",
5
5
  "type": "module",
6
6
  "bin": {