|
@@ -910,19 +910,36 @@ describe('tokenizeSessionFixtureCwd', () => {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('extractSnapshotSpillPaths', () => {
|
|
describe('extractSnapshotSpillPaths', () => {
|
|
|
- it('recognizes locators in nested JSON omissions without scrubbing byte counts', () => {
|
|
|
|
|
- const locator = '/tmp/dsh-acp-snap-123456789/session-123456abcdef/abcdef123456-session-reference-1.txt'
|
|
|
|
|
|
|
+ it.each([
|
|
|
|
|
+ ['/tmp', '/'],
|
|
|
|
|
+ ['/tmp', String.fromCharCode(92)],
|
|
|
|
|
+ ['C:/t', String.fromCharCode(92)],
|
|
|
|
|
+ ])('recognizes %s locators with %s separators in nested JSON omissions without scrubbing byte counts', (root, separator) => {
|
|
|
|
|
+ const locator = `${root}/dsh-acp-snap-123456789/session-123456abcdef/abcdef123456-session-reference-1.txt`.replaceAll('/', separator)
|
|
|
const notice = { sessionId: 'source', omittedBytes: 42, fullSnapshot: { status: 'saved', locator, bytes: 1234 } }
|
|
const notice = { sessionId: 'source', omittedBytes: 42, fullSnapshot: { status: 'saved', locator, bytes: 1234 } }
|
|
|
const log = JSON.stringify({ type: 'user/message', data: { content: [{ type: 'text', text: JSON.stringify([notice]) }] } })
|
|
const log = JSON.stringify({ type: 'user/message', data: { content: [{ type: 'text', text: JSON.stringify([notice]) }] } })
|
|
|
- expect(extractSnapshotSpillPaths(log)).toEqual(new Map([['session-reference-1.txt', locator]]))
|
|
|
|
|
|
|
+ const encodedLocator = JSON.stringify(JSON.stringify(locator).slice(1, -1)).slice(1, -1)
|
|
|
|
|
+ expect(extractSnapshotSpillPaths(log)).toEqual(new Map([['session-reference-1.txt', encodedLocator]]))
|
|
|
const normalized = normalizeSessionLog(log, ctx)
|
|
const normalized = normalizeSessionLog(log, ctx)
|
|
|
const unrelated = '/tmp/unrelated/session-123456abcdef/abcdef123456-session-reference-1.txt'
|
|
const unrelated = '/tmp/unrelated/session-123456abcdef/abcdef123456-session-reference-1.txt'
|
|
|
- expect(normalizeSessionLog(log.replaceAll(locator, unrelated), ctx)).toContain(unrelated)
|
|
|
|
|
|
|
+ expect(normalizeSessionLog(log.replaceAll(encodedLocator, unrelated), ctx)).toContain(unrelated)
|
|
|
|
|
+ const expectedNotice = { ...notice, fullSnapshot: { ...notice.fullSnapshot, locator: '{{spillLocator:session-reference-1.txt}}' } }
|
|
|
|
|
+ expect(normalized).toBe(JSON.stringify({ type: 'user/message', data: { content: [{ type: 'text', text: JSON.stringify([expectedNotice]) }] } }) + '\n')
|
|
|
expect(normalized).toContain('{{spillLocator:session-reference-1.txt}}')
|
|
expect(normalized).toContain('{{spillLocator:session-reference-1.txt}}')
|
|
|
expect(normalized).toContain('omittedBytes\\":42')
|
|
expect(normalized).toContain('omittedBytes\\":42')
|
|
|
expect(normalized).toContain('bytes\\":1234')
|
|
expect(normalized).toContain('bytes\\":1234')
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ it.each(['canonical', 'native'] as const)('normalizes nested Windows local spill locators with %s paths', (cwdPathMode) => {
|
|
|
|
|
+ const locator = String.raw`{{cwd}}\.spill\session-123456abcdef\abcdef123456-session-reference-1.txt`
|
|
|
|
|
+ const notice = { locator, unrelated: String.raw`C:\work\literal\file.txt`, regex: String.raw`\d+\w` }
|
|
|
|
|
+ const log = JSON.stringify({ type: 'user/message', data: { text: JSON.stringify(notice) } })
|
|
|
|
|
+ const expected = { ...notice, locator: '{{spillLocator:session-reference-1.txt}}' }
|
|
|
|
|
+ expect(normalizeSessionLog(log, ctx, { cwdPathMode })).toBe(
|
|
|
|
|
+ JSON.stringify({ type: 'user/message', data: { text: JSON.stringify(expected) } }) + '\n',
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
it('maps each spill filename to its full matched path, last match wins per name', () => {
|
|
it('maps each spill filename to its full matched path, last match wins per name', () => {
|
|
|
const log = [
|
|
const log = [
|
|
|
'Full formatted result stored at: /tmp/dsh-acp-snapshot-spill/session-c22bc3f1d2af/8a7b6c5d4e3f-bash.txt. Use read with offset/limit, or grep this path to search within it.',
|
|
'Full formatted result stored at: /tmp/dsh-acp-snapshot-spill/session-c22bc3f1d2af/8a7b6c5d4e3f-bash.txt. Use read with offset/limit, or grep this path to search within it.',
|