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
48 changes: 48 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Smoke tests for the public library barrel.
//
// These don't exercise behavior — Unit 12 (CspIndex) and Unit 1 (types) own
// their own deep tests. The point here is to lock down the *shape* of the
// public surface so we'd catch:
// * an accidental rename of `CspIndex` / `ContentType` / `version`,
// * a regression of `ContentType` to a type-only export (which would
// break `import { ContentType } from '@pleaseai/csp'` at runtime).
//
// The wildcard `import * as csp` is deliberate: it also verifies the module
// is *syntactically* a valid ESM barrel (no circular value-time imports).
import { describe, expect, it } from 'bun:test'

import * as csp from './index.ts'

describe('public barrel', () => {
it('imports without error and exposes the documented names', () => {
// Use a `Set` so the assertion message is order-independent — easier to
// diagnose than a positional array diff when a name is missing.
const exported = new Set(Object.keys(csp))
for (const name of ['CspIndex', 'ContentType', 'version']) {
expect(exported.has(name)).toBe(true)
}
})

it('exposes `version` as a string', () => {
expect(typeof csp.version).toBe('string')
// Guard against an empty string sneaking in (e.g. failed build-time
// substitution); a real version is always non-empty.
expect(csp.version.length).toBeGreaterThan(0)
})

it('exposes `CspIndex` as a constructable value', () => {
// `typeof X === 'function'` covers both `class` and plain functions,
// which keeps the test resilient if Unit 12 chooses a factory-style
// implementation instead of a class.
expect(typeof csp.CspIndex).toBe('function')
})

it('exposes `ContentType` as a runtime enum object with `code | docs | config`', () => {
// The string values are part of the on-disk / CLI contract (`--content code`,
// persisted indices). They must NOT be tweaked without coordinating with
// the semble compatibility story documented in CLAUDE.md.
expect(csp.ContentType.Code).toBe('code')
expect(csp.ContentType.Docs).toBe('docs')
expect(csp.ContentType.Config).toBe('config')
})
})
24 changes: 23 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
export const version = '0.0.0'
// Public library barrel — port of `src/semble/__init__.py`.
//
// External consumers `import { CspIndex, ContentType, ... } from '@pleaseai/csp'`,
// so this file's surface is load-bearing and matches the README.
//
// `ContentType` is intentionally re-exported as a *value* (not via
// `export type`) because Unit 1's port models it as a `const`-object enum:
// the identifier carries both a runtime value and a same-named type alias.
// With `verbatimModuleSyntax`, exporting it via `export {}` carries both
// forms; listing it under `export type {}` would erase the runtime side.

export { CspIndex } from './indexing/index.ts'

export type {
Chunk,
EmbeddingMatrix,
IndexStats,
SearchResult,
} from './types.ts'

export { ContentType } from './types.ts'

export { version } from './version.ts'
Loading