Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/server/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,37 @@ export const MANIFEST_FILE = '_manifest.json'
export const ARCHIVE_IMPORTANCE_THRESHOLD = 35
export const DEFAULT_GHOST_CUE_MAX_TOKENS = 220

/** Patterns the context-tree .gitignore must contain (derived artifacts only). */
/** Patterns the context-tree .gitignore must contain. */
Comment thread
bao-byterover marked this conversation as resolved.
export const CONTEXT_TREE_GITIGNORE_PATTERNS = [
// Derived artifacts
'.gitignore',
'.snapshot.json',
'_manifest.json',
'_index.md',
'*.abstract.md',
'*.overview.md',

// macOS
'.DS_Store',
'._*',

// Windows
'Thumbs.db',
'ehthumbs.db',
'Desktop.ini',

// Linux
'.directory',
'.fuse_hidden*',
'.nfs*',

// Editor swap / backup / temp
'*.swp',
'*.swo',
'*~',
'.#*',
'*.bak',
'*.tmp',
]

export const CONTEXT_TREE_GITIGNORE_HEADER = '# Derived artifacts — do not track'
34 changes: 34 additions & 0 deletions test/unit/server/constants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,38 @@ describe('CONTEXT_TREE_GITIGNORE_PATTERNS', () => {
expect(CONTEXT_TREE_GITIGNORE_PATTERNS).to.include('_manifest.json')
expect(CONTEXT_TREE_GITIGNORE_PATTERNS).to.include('_index.md')
})

describe('OS-generated junk files', () => {
it('should exclude macOS junk (Finder metadata + AppleDouble forks)', () => {
expect(CONTEXT_TREE_GITIGNORE_PATTERNS).to.include('.DS_Store')
expect(CONTEXT_TREE_GITIGNORE_PATTERNS).to.include('._*')
})

it('should exclude Windows junk (thumbnail cache + folder config)', () => {
expect(CONTEXT_TREE_GITIGNORE_PATTERNS).to.include('Thumbs.db')
expect(CONTEXT_TREE_GITIGNORE_PATTERNS).to.include('ehthumbs.db')
expect(CONTEXT_TREE_GITIGNORE_PATTERNS).to.include('Desktop.ini')
})

it('should exclude Linux junk (KDE metadata + FUSE/NFS hidden files)', () => {
expect(CONTEXT_TREE_GITIGNORE_PATTERNS).to.include('.directory')
expect(CONTEXT_TREE_GITIGNORE_PATTERNS).to.include('.fuse_hidden*')
expect(CONTEXT_TREE_GITIGNORE_PATTERNS).to.include('.nfs*')
})

it('should exclude editor swap / backup / temp files', () => {
expect(CONTEXT_TREE_GITIGNORE_PATTERNS).to.include('*.swp')
expect(CONTEXT_TREE_GITIGNORE_PATTERNS).to.include('*.swo')
expect(CONTEXT_TREE_GITIGNORE_PATTERNS).to.include('*~')
expect(CONTEXT_TREE_GITIGNORE_PATTERNS).to.include('.#*')
expect(CONTEXT_TREE_GITIGNORE_PATTERNS).to.include('*.bak')
expect(CONTEXT_TREE_GITIGNORE_PATTERNS).to.include('*.tmp')
})

it('should deliberately NOT include trash folders (out of scope per ENG-2154)', () => {
Comment thread
bao-byterover marked this conversation as resolved.
expect(CONTEXT_TREE_GITIGNORE_PATTERNS).to.not.include('.Trashes')
expect(CONTEXT_TREE_GITIGNORE_PATTERNS).to.not.include('.Trash-*')
expect(CONTEXT_TREE_GITIGNORE_PATTERNS).to.not.include('$RECYCLE.BIN/')
})
})
})
21 changes: 5 additions & 16 deletions test/unit/utils/gitignore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,10 @@ _index.md
})

it('should handle lines with leading/trailing whitespace', async () => {
const withSpaces = `# Derived artifacts — do not track
.gitignore
.snapshot.json
_manifest.json
_index.md
*.abstract.md
*.overview.md
`
const withSpaces = FULL_GITIGNORE
.replace(/^\.gitignore$/m, ' .gitignore')
.replace(/^\.snapshot\.json$/m, ' .snapshot.json')
.replace(/^\*\.abstract\.md$/m, ' *.abstract.md')
writeFileSync(path.join(testDir, '.gitignore'), withSpaces)

await ensureContextTreeGitignore(testDir)
Expand All @@ -365,14 +361,7 @@ _index.md
})

it('should skip pattern when a variant already covers it — /_manifest.json contains _manifest.json', async () => {
const withSlash = `# Derived artifacts — do not track
.gitignore
.snapshot.json
/_manifest.json
_index.md
*.abstract.md
*.overview.md
`
const withSlash = FULL_GITIGNORE.replace(/^_manifest\.json$/m, '/_manifest.json')
writeFileSync(path.join(testDir, '.gitignore'), withSlash)

await ensureContextTreeGitignore(testDir)
Expand Down
Loading