MCPcopy Index your code
hub / github.com/callstack/agent-device / formatLastSnapshotContext

Function formatLastSnapshotContext

test/integration/test-helpers.ts:163–190  ·  view source on GitHub ↗
(args: string[])

Source from the content-addressed store, hash-verified

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);

Callers 1

buildFailureDebugFunction · 0.70

Calls 4

summarizeNodeFunction · 0.85
startsWithMethod · 0.80
pushMethod · 0.80
normalizeRefFunction · 0.70

Tested by

no test coverage detected