(contextDir: string, buildId: string)
| 43 | } |
| 44 | |
| 45 | async function createMinimalIndex(contextDir: string, buildId: string): Promise<void> { |
| 46 | await fs.mkdir(contextDir, { recursive: true }); |
| 47 | await fs.mkdir(path.join(contextDir, VECTOR_DB_DIRNAME), { recursive: true }); |
| 48 | |
| 49 | // Create index-meta.json (authoritative) |
| 50 | const meta = { |
| 51 | metaVersion: INDEX_META_VERSION, |
| 52 | formatVersion: INDEX_FORMAT_VERSION, |
| 53 | buildId, |
| 54 | generatedAt: new Date().toISOString(), |
| 55 | toolVersion: 'test', |
| 56 | artifacts: { |
| 57 | keywordIndex: { path: KEYWORD_INDEX_FILENAME }, |
| 58 | vectorDb: { path: VECTOR_DB_DIRNAME, provider: 'lancedb' }, |
| 59 | intelligence: { path: INTELLIGENCE_FILENAME } |
| 60 | } |
| 61 | }; |
| 62 | await fs.writeFile(path.join(contextDir, INDEX_META_FILENAME), JSON.stringify(meta, null, 2)); |
| 63 | |
| 64 | // Create index.json with matching buildId |
| 65 | const index = { |
| 66 | header: { buildId, formatVersion: INDEX_FORMAT_VERSION }, |
| 67 | chunks: [] |
| 68 | }; |
| 69 | await fs.writeFile(path.join(contextDir, KEYWORD_INDEX_FILENAME), JSON.stringify(index)); |
| 70 | |
| 71 | // Create intelligence.json with matching buildId |
| 72 | const intelligence = { |
| 73 | header: { buildId, formatVersion: INDEX_FORMAT_VERSION }, |
| 74 | libraryUsage: {}, |
| 75 | patterns: {}, |
| 76 | generatedAt: new Date().toISOString() |
| 77 | }; |
| 78 | await fs.writeFile(path.join(contextDir, INTELLIGENCE_FILENAME), JSON.stringify(intelligence)); |
| 79 | |
| 80 | // Create vector DB build marker |
| 81 | await fs.writeFile( |
| 82 | path.join(contextDir, VECTOR_DB_DIRNAME, 'index-build.json'), |
| 83 | JSON.stringify({ buildId, formatVersion: INDEX_FORMAT_VERSION }) |
| 84 | ); |
| 85 | } |
| 86 | |
| 87 | async function readBuildIdFromMeta(contextDir: string): Promise<string | null> { |
| 88 | try { |
no outgoing calls
no test coverage detected