@tryarcanist/cli 0.1.75 → 0.1.77

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 +58 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -883,6 +883,52 @@ function projectBranchChanged(data, index) {
883
883
  ...resolvePromptId(data) ? { promptId: resolvePromptId(data) } : {}
884
884
  };
885
885
  }
886
+ function projectMemoryUsage(data, index) {
887
+ const activeMemoryIds = Array.isArray(data?.activeMemoryIds) ? data.activeMemoryIds.filter((id) => typeof id === "string" && id.trim().length > 0) : [];
888
+ const activeMemories = mergeMemoryRefs(activeMemoryIds, data?.activeMemories);
889
+ return {
890
+ type: "memory_usage",
891
+ id: `mem-${data?.timestamp ?? index}`,
892
+ activeMemoryIds,
893
+ activeMemories,
894
+ ...resolvePromptId(data) ? { promptId: resolvePromptId(data) } : {}
895
+ };
896
+ }
897
+ function projectMemoryRecallUsage(data, index) {
898
+ const requestedMemoryIds = Array.isArray(data?.requestedMemoryIds) ? data.requestedMemoryIds.filter((id) => typeof id === "string" && id.trim().length > 0) : [];
899
+ const returnedMemoryIds = Array.isArray(data?.returnedMemoryIds) ? data.returnedMemoryIds.filter((id) => typeof id === "string" && id.trim().length > 0) : [];
900
+ const requestedMemories = mergeMemoryRefs(requestedMemoryIds, data?.requestedMemories);
901
+ const returnedMemories = mergeMemoryRefs(returnedMemoryIds, data?.returnedMemories);
902
+ const eventName = typeof data?.eventName === "string" ? data.eventName : "memory_recall.returned";
903
+ return {
904
+ type: "memory_recall_usage",
905
+ id: `mrec-${data?.timestamp ?? index}-${eventName}`,
906
+ eventName,
907
+ requestedMemoryIds,
908
+ returnedMemoryIds,
909
+ requestedMemories,
910
+ returnedMemories,
911
+ ...typeof data?.intent === "string" && data.intent.trim() ? { intent: data.intent.trim() } : {},
912
+ ...typeof data?.tool === "string" && data.tool.trim() ? { tool: data.tool.trim() } : {},
913
+ ...resolvePromptId(data) ? { promptId: resolvePromptId(data) } : {}
914
+ };
915
+ }
916
+ function mergeMemoryRefs(ids, rawRefs) {
917
+ const byId = /* @__PURE__ */ new Map();
918
+ if (Array.isArray(rawRefs)) {
919
+ for (const entry of rawRefs) {
920
+ if (!entry || typeof entry !== "object") continue;
921
+ const record = entry;
922
+ const id = typeof record.id === "string" ? record.id.trim() : "";
923
+ if (!id) continue;
924
+ const ref = { id };
925
+ if (typeof record.path === "string" && record.path.trim()) ref.path = record.path.trim();
926
+ if (typeof record.title === "string" && record.title.trim()) ref.title = record.title.trim();
927
+ byId.set(id, ref);
928
+ }
929
+ }
930
+ return ids.map((id) => byId.get(id) ?? { id });
931
+ }
886
932
  function projectAgentTimeline(data, index) {
887
933
  return {
888
934
  type: "agent_timeline",
@@ -1083,6 +1129,12 @@ function flattenSessionEvents(raw) {
1083
1129
  case "branch_changed":
1084
1130
  pushEvent(state, projectBranchChanged(data, state.merged.length));
1085
1131
  break;
1132
+ case "memory_usage":
1133
+ pushEvent(state, projectMemoryUsage(data, state.merged.length));
1134
+ break;
1135
+ case "memory_recall_usage":
1136
+ pushEvent(state, projectMemoryRecallUsage(data, state.merged.length));
1137
+ break;
1086
1138
  case "agent_timeline":
1087
1139
  pushEvent(state, projectAgentTimeline(data, state.merged.length));
1088
1140
  break;
@@ -1362,6 +1414,12 @@ ${event.answer ? `**Answer:** ${event.answer}
1362
1414
  case "branch_changed":
1363
1415
  return `*[switched to branch \`${event.branch}\`]*
1364
1416
  `;
1417
+ case "memory_usage":
1418
+ return event.activeMemoryIds.length > 0 ? `*[used ${event.activeMemoryIds.length === 1 ? "1 memory" : `${event.activeMemoryIds.length} memories`}: ${event.activeMemories.map((memory) => `\`${memory.title || memory.id}\``).join(", ")}]*
1419
+ ` : "";
1420
+ case "memory_recall_usage":
1421
+ return event.returnedMemoryIds.length > 0 ? `*[recalled ${event.returnedMemoryIds.length === 1 ? "1 memory" : `${event.returnedMemoryIds.length} memories`}: ${event.returnedMemories.map((memory) => `\`${memory.title || memory.id}\``).join(", ")}]*
1422
+ ` : "";
1365
1423
  case "agent_timeline":
1366
1424
  return `*[${event.eventType}${event.status ? ` (${event.status})` : ""}: ${event.summary}]*
1367
1425
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryarcanist/cli",
3
- "version": "0.1.75",
3
+ "version": "0.1.77",
4
4
  "description": "CLI for Arcanist — create and manage coding agent sessions",
5
5
  "type": "module",
6
6
  "bin": {