fix(snapshot): canonicalize macOS cwd tokens

This commit is contained in:
Hypatia May
2026-07-31 09:45:48 +08:00
parent ff8c5600f4
commit 00cc600b14
11 changed files with 36 additions and 15 deletions
@@ -470,6 +470,24 @@ describe('tokenizeSessionFixtureCwd', () => {
expect(tokenizeSessionFixtureCwd(out)).toBe(out)
})
it('collapses a residual macOS realpath prefix around an existing cwd token', () => {
const raw = [
JSON.stringify({ type: 'session', id: 's', createdAt: 1, cwd: '{{cwd}}' }),
JSON.stringify({
type: 'tool/result',
seq: 1,
time: 2,
data: { content: [{ type: 'text', text: 'wrote /private{{cwd}}/proof.txt' }] },
}),
'',
].join('\n')
const out = tokenizeSessionFixtureCwd(raw)
expect(out).toContain('wrote {{cwd}}/proof.txt')
expect(out).not.toContain('/private{{cwd}}')
expect(tokenizeSessionFixtureCwd(out)).toBe(out)
})
it('rejects a log without a session cwd', () => {
expect(() => tokenizeSessionFixtureCwd('')).toThrow(
'acp-snapshot: cannot tokenize a cwd without a basename',