fix(acp-snapshot): stabilize /private prefix and spill paths in snapshots

macOS symlinks /tmp → /private/tmp; when the session header cwd lacks
the /private prefix but fs tools resolve symlinks, tool result paths
get the prefix and the cwd replacement never matches.  Strip the prefix
before cwd→{{cwd}} replacement so both forms normalize identically.

Also extend refreshFixtureReplacements to match spill paths by filename
suffix, preventing raw fixture churn when a refresh runs from a
different session directory.
This commit is contained in:
_Kerman
2026-07-24 23:00:17 +08:00
parent b36a82fc98
commit 6b4c26a1b9
11 changed files with 55 additions and 10 deletions
@@ -192,6 +192,21 @@ describe('normalizeSessionLog', () => {
expect(out).not.toContain('/private{{spillLocator')
})
it('scrubs macOS /private prefix on cwd-rooted fs tool result paths', () => {
const ev = JSON.stringify({
type: 'tool/result', seq: 2, time: 5,
data: {
content: [{
type: 'text',
text: `The file /private${ctx.cwd}/config.txt has been updated successfully.`,
}],
},
})
const out = normalizeSessionLog(`${header({ cwd: ctx.cwd })}\n${ev}\n`, ctx)
expect(out).toContain('{{cwd}}/config.txt')
expect(out).not.toContain('/private{{cwd}}')
})
it('scrubs fixed snapshot spill paths', () => {
const ev = JSON.stringify({
type: 'tool/result', seq: 2, time: 5,