Skip to content

feat(index): public library barrel re-exporting CspIndex + types#12

Merged
amondnet merged 1 commit into
mainfrom
feat/unit-16-barrel
May 28, 2026
Merged

feat(index): public library barrel re-exporting CspIndex + types#12
amondnet merged 1 commit into
mainfrom
feat/unit-16-barrel

Conversation

@amondnet

@amondnet amondnet commented May 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Unit 16 — port of src/semble/__init__.py and src/semble/version.py.

Stitches the documented public surface of @pleaseai/csp:

import { CspIndex, ContentType, type Chunk, type SearchResult } from '@pleaseai/csp'

What's in the barrel

  • CspIndex (value) — re-exported from ./indexing/index.ts (Unit 12)
  • Chunk, SearchResult, IndexStats, EmbeddingMatrix (types) — from ./types.ts (Unit 1)
  • ContentType (value + type) — re-exported with export { } (not export type { }) so the runtime enum object survives verbatimModuleSyntax — listing it under export type would erase the runtime side
  • version — from ./version.ts, currently '0.0.0' to match package.json#version

Placeholder stubs for sibling units

Per the unit instructions, this PR adds // TODO placeholder modules so the barrel type-checks and src/index.test.ts can run standalone:

  • src/types.ts — minimal stub mirroring Unit 1's ContentType const-object enum + Chunk / SearchResult / IndexStats / EmbeddingMatrix shapes
  • src/indexing/index.ts — placeholder CspIndex class that throws eagerly to surface sequencing bugs

Both files are clearly marked with TODO(unit-1) / TODO(unit-12) comments and will be overwritten when those units land.

Tests

bun test src/index.test.ts
 4 pass
 0 fail
 9 expect() calls

Smoke tests verify:

  1. The barrel imports without error (catches syntactic regressions / circular value-time imports)
  2. csp.version is a non-empty string
  3. csp.CspIndex is a function (covers class or factory style)
  4. csp.ContentType.Code === 'code' etc. — the lowercase string values are part of the on-disk / CLI contract with semble

Notes for reviewers

  • Tests pass against the stubs in this PR. They will continue to pass once Unit 1 (feat/unit-1-types) and Unit 12 (CspIndex implementation) land — the stubs are interface-compatible with the real ports.
  • package.json is intentionally untouched per unit instructions.

Source of truth


Summary by cubic

Adds a public barrel for @pleaseai/csp that re-exports CspIndex, ContentType, core types, and version to match the documented API. Includes minimal stubs and smoke tests so the surface is stable until Units 1 and 12 land.

  • New Features
    • Export CspIndex from ./indexing/index.ts and ContentType (as a value) plus Chunk, SearchResult, IndexStats, EmbeddingMatrix from ./types.ts.
    • Expose version from ./version.ts (0.0.0, mirroring package.json).
    • Add Unit 1 and Unit 12 stubs (constructor/methods throw or reject) to keep the barrel type-safe; add smoke tests for exported names, ContentType runtime values, and version shape.

Written for commit 9e56611. Summary will update on new commits.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request establishes the public library barrel (src/index.ts) and introduces placeholder stubs for CspIndex (src/indexing/index.ts) and associated types (src/types.ts) to enable isolated type-checking and imports. Additionally, it adds smoke tests (src/index.test.ts) to lock down the public API surface and a version module (src/version.ts). There are no review comments, and I have no feedback to provide.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

Architecture diagram
sequenceDiagram
    participant Consumer as External Consumer
    participant Barrel as src/index.ts (Barrel)
    participant Indexing as src/indexing/index.ts (CspIndex)
    participant Types as src/types.ts (Types)
    participant Version as src/version.ts
    participant Test as src/index.test.ts (Smoke Tests)

    Note over Consumer,Test: Public Library Barrel — Runtime & Type-Space Flow

    Consumer->>Barrel: import { CspIndex, ContentType, version } from '@pleaseai/csp'
    Note over Barrel: Re-exports both values & types

    Barrel->>Indexing: export { CspIndex }
    Note over Indexing: Placeholder stub (throws on construction)
    Indexing-->>Barrel: CspIndex class reference

    Barrel->>Types: export { ContentType } (value)
    Barrel->>Types: export type { Chunk, SearchResult, IndexStats, EmbeddingMatrix }
    Note over Types: Placeholder stubs with const-object enum
    Types-->>Barrel: ContentType runtime object + type aliases

    Barrel->>Version: export { version }
    Note over Version: '0.0.0' literal
    Version-->>Barrel: version string

    Barrel-->>Consumer: Resolved imports (types at compile-time, values at runtime)

    Note over Consumer: Runtime Usage (verified by smoke tests)

    Consumer->>Consumer: typeof csp.version === 'string' && length > 0
    Consumer->>Consumer: typeof csp.CspIndex === 'function'
    Consumer->>Consumer: csp.ContentType.Code === 'code'
    Consumer->>Consumer: csp.ContentType.Docs === 'docs'
    Consumer->>Consumer: csp.ContentType.Config === 'config'

    Note over Test: Smoke tests lock down exported surface

    Test->>Barrel: import * as csp
    Barrel-->>Test: Module namespace object
    Test->>Test: Object.keys(csp) includes CspIndex, ContentType, version
    Test->>Test: version is non-empty string
    Test->>Test: CspIndex is function
    Test->>Test: ContentType enum values match contract
Loading

Re-trigger cubic

@amondnet amondnet left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed both bot reviews; no actionable line comments. The stub modules are intentional placeholders pending Unit 12/Unit 1 PRs.

@amondnet amondnet self-assigned this May 28, 2026
Port of `src/semble/__init__.py` and `src/semble/version.py`.

The barrel stitches the documented public surface:
- `CspIndex` (from `./indexing/index.ts`, owned by Unit 12)
- `Chunk`, `SearchResult`, `IndexStats`, `EmbeddingMatrix`
  (types from `./types.ts`, owned by Unit 1)
- `ContentType` (re-exported as a *value* so the runtime enum object
  survives `verbatimModuleSyntax` — `export type {}` would erase it)
- `version` (from `./version.ts`, currently mirrors `package.json#version`)

Includes `// TODO` placeholder stubs for Unit 1 (`src/types.ts`) and
Unit 12 (`src/indexing/index.ts`) so the barrel type-checks and
`src/index.test.ts` runs in isolation. Both placeholders are clearly
marked and will be overwritten when the owning unit lands.

Co-authored-by: Minsu Lee <minsu.lee@dietfriends.kr>
@amondnet amondnet force-pushed the feat/unit-16-barrel branch from b61f7bd to 9e56611 Compare May 28, 2026 16:09
@amondnet amondnet merged commit a4931d8 into main May 28, 2026
@amondnet amondnet deleted the feat/unit-16-barrel branch May 28, 2026 16:10
This was referenced Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant