[Bug] Files whose names start with ".." (for example "..env") are treated as outside the workspace
Summary
Several containment checks use relative.startsWith('..'). That also matches a normal file called ..env, so checkpoints and the timeline skip it.
Steps to reproduce
- Create a workspace containing
..envandok.txt. - Run
new FileSnapshotService(root).captureFiles(['..env', 'ok.txt']). - Run
new TimelineManager(root, 's1').toRelativePath('..env').
Expected behaviour
..env is captured, and toRelativePath returns '..env'.
Actual behaviour
snapshots: [ 'ok.txt' ] skipped: [ { path: '..env', reason: 'Outside the workspace' } ]
toRelativePath('..env') -> null
Two specs fail (snapshots is missing '..env', and - null + '..env'). A checkpoint or undo will not restore such a file.
Environment
Windows 11, Node v22.22.3, Nanocoder 1.31.0 (main at 948a4e74)
Suggested fix
Replace relative.startsWith('..') with relative === '..' || relative.startsWith('..' + path.sep) in:
source/services/file-snapshot.ts:63source/services/timeline-manager.ts:158source/services/lifecycle-hooks.ts:296source/skills/install.ts:480source/init/initializer.ts:35source/storage/diagnostics.ts:209and:590
A small shared helper would avoid repeating it.
I'd like to take this — will tighten the containment checks so a file named ..env is treated as in-workspace (prefix ../ / exact ..), not as parent-path escape via startsWith('..').
Hi @ShahadatTest, thanks for the PR! I've assigned this issue to you, so you're good to go this time. From next time, please ask to be assigned on the issue first and wait for a maintainer to assign it before opening a PR.