diff --git a/src/chunking/core.test.ts b/src/chunking/core.test.ts index 5dcfdb4..9900fd3 100644 --- a/src/chunking/core.test.ts +++ b/src/chunking/core.test.ts @@ -20,9 +20,9 @@ describe('constants', () => { }) describe('isSupportedLanguage', () => { - it('returns false for unknown languages (Unit 4 stub)', () => { - expect(isSupportedLanguage('typescript')).toBe(false) - expect(isSupportedLanguage('python')).toBe(false) + it('returns true for known languages and false for unknown ones', () => { + expect(isSupportedLanguage('typescript')).toBe(true) + expect(isSupportedLanguage('python')).toBe(true) expect(isSupportedLanguage('not-a-real-language')).toBe(false) }) }) diff --git a/src/chunking/core.ts b/src/chunking/core.ts index 78da8a5..3c72114 100644 --- a/src/chunking/core.ts +++ b/src/chunking/core.ts @@ -8,10 +8,7 @@ // loads even when the package is not yet installed, falling back to the // line chunker in that case. -// Stub for ALL_LANGUAGES until Unit 4 (language detection) lands. -// Once `src/indexing/files.ts` exists, replace this with: -// import { ALL_LANGUAGES } from '../indexing/files.ts' -const ALL_LANGUAGES: ReadonlySet = new Set() +import { ALL_LANGUAGES } from '../languages.ts' export const RECURSION_DEPTH = 500 export const MIN_CHUNK_SIZE = 50 diff --git a/src/indexing/cache.ts b/src/indexing/cache.ts index bf20422..1b0bca2 100644 --- a/src/indexing/cache.ts +++ b/src/indexing/cache.ts @@ -20,10 +20,10 @@ import { chmodSync, existsSync, mkdirSync, readdirSync, realpathSync, rmSync } f import { readFile, stat } from 'node:fs/promises' import { homedir } from 'node:os' import { basename, dirname, join, normalize, relative } from 'node:path' +import { getExtensions } from '../languages.ts' import { isGitUrl } from '../utils.ts' import { MAX_FILE_BYTES } from './create.ts' import { walkFiles } from './file-walker.ts' -import { getExtensions } from './files.ts' import { CspIndex, DEFAULT_CONTENT, parseManifest } from './index.ts' /** Directory permissions for every cache directory (owner-only). NFR-003. */ diff --git a/src/indexing/create.ts b/src/indexing/create.ts index a503954..446e75c 100644 --- a/src/indexing/create.ts +++ b/src/indexing/create.ts @@ -5,11 +5,11 @@ import type { Model } from './dense.ts' import { readFileSync, statSync } from 'node:fs' import { relative } from 'node:path' import { chunkSource } from '../chunking/chunk-source.ts' +import { detectLanguage, getExtensions } from '../languages.ts' import { tokenize } from '../tokens.ts' import { ContentType } from '../types.ts' import { embedChunks, SelectableBasicBackend } from './dense.ts' import { walkFiles } from './file-walker.ts' -import { detectLanguage, getExtensions } from './files.ts' import { Bm25Index, enrichForBm25 } from './sparse.ts' /** 1 MB max file size to read and index. */ diff --git a/src/indexing/files.test.ts b/src/languages.test.ts similarity index 99% rename from src/indexing/files.test.ts rename to src/languages.test.ts index 2090559..5a8c69c 100644 --- a/src/indexing/files.test.ts +++ b/src/languages.test.ts @@ -7,7 +7,7 @@ import { DOC_LANGUAGES, EXTENSION_TO_LANGUAGE, getExtensions, -} from './files.ts' +} from './languages.ts' describe('detectLanguage', () => { it('detects typescript from .ts', () => { diff --git a/src/indexing/files.ts b/src/languages.ts similarity index 100% rename from src/indexing/files.ts rename to src/languages.ts