(args, context)
| 19 | } |
| 20 | |
| 21 | export const call: LocalCommandCall = async (args, context) => { |
| 22 | if ((process.env.NCODE_BUILD_MODE !== 'noumena' && process.env.USER_TYPE !== 'ant')) { |
| 23 | return text('`/summary` is only available in ANT builds.') |
| 24 | } |
| 25 | |
| 26 | const trimmed = args.trim() |
| 27 | if (trimmed && HELP_FLAGS.has(trimmed.toLowerCase())) { |
| 28 | return text(usage()) |
| 29 | } |
| 30 | if (trimmed) { |
| 31 | return text(`Unknown argument "${trimmed}".\n\n${usage()}`) |
| 32 | } |
| 33 | |
| 34 | const messages = getMessagesAfterCompactBoundary(context.messages) |
| 35 | if (messages.length === 0) { |
| 36 | return text('No messages to summarize.') |
| 37 | } |
| 38 | |
| 39 | await waitForSessionMemoryExtraction() |
| 40 | |
| 41 | const result = await manuallyExtractSessionMemory(messages, context) |
| 42 | if (!result.success) { |
| 43 | return text( |
| 44 | `Session summary update failed: ${result.error ?? 'unknown error'}`, |
| 45 | ) |
| 46 | } |
| 47 | |
| 48 | await waitForSessionMemoryExtraction() |
| 49 | |
| 50 | const memoryPath = result.memoryPath ?? getSessionMemoryPath() |
| 51 | const sessionMemory = await getSessionMemoryContent() |
| 52 | |
| 53 | if (!sessionMemory) { |
| 54 | return text( |
| 55 | `Session summary updated at ${getDisplayPath(memoryPath)}, but no summary content is currently available.`, |
| 56 | ) |
| 57 | } |
| 58 | |
| 59 | return text( |
| 60 | `Session summary updated: ${getDisplayPath(memoryPath)}\n\n${sessionMemory}`, |
| 61 | ) |
| 62 | } |
nothing calls this directly
no test coverage detected