(args: string[])
| 161 | } |
| 162 | |
| 163 | function formatLastSnapshotContext(args: string[]): string { |
| 164 | if (!lastSnapshot) { |
| 165 | return '(none)'; |
| 166 | } |
| 167 | const snapshotLines = [ |
| 168 | `capturedAt: ${lastSnapshot.capturedAt}`, |
| 169 | `command: ${lastSnapshot.command}`, |
| 170 | `nodes: ${lastSnapshot.nodes.length}`, |
| 171 | ]; |
| 172 | const refArg = args.find((arg) => arg.startsWith('@')); |
| 173 | if (refArg) { |
| 174 | const normalized = normalizeRef(refArg); |
| 175 | const refNode = lastSnapshot.nodes.find( |
| 176 | (node) => normalizeRef(String(node?.ref ?? '')) === normalized, |
| 177 | ); |
| 178 | snapshotLines.push( |
| 179 | `targetRef: ${refArg}`, |
| 180 | refNode |
| 181 | ? `targetRefInSnapshot: yes (${summarizeNode(refNode)})` |
| 182 | : 'targetRefInSnapshot: no', |
| 183 | ); |
| 184 | } |
| 185 | const preview = lastSnapshot.nodes |
| 186 | .slice(0, 12) |
| 187 | .map((node, i) => `${i + 1}. ${summarizeNode(node)}`); |
| 188 | snapshotLines.push('nodePreview:', preview.length > 0 ? preview.join('\n') : '(empty)'); |
| 189 | return snapshotLines.join('\n'); |
| 190 | } |
| 191 | |
| 192 | function formatStepHistory(): string { |
| 193 | const recent = stepHistory.slice(-8); |
no test coverage detected