npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cmflow/source-pack

v3.22.0

Published

Versioned source code index (chunks + embeddings) built and published at each production release

Readme

npm version code style: oxfmt

source-pack builds, at each production release of a project hosted on GitHub or GitLab, a versioned index of its code (chunks + embeddings + manifest) and publishes it on the release of the tag. The Dataviz loads it with readSourcePack() to answer source_search on any production version, without a local checkout.

The package is generic: everything that depends on a project lives in its source-pack.config.ts.

Commands

npx @cmflow/source-pack init                      # create ./source-pack.config.ts
npx @cmflow/source-pack build                     # index HEAD, version from package.json
npx @cmflow/source-pack build --tag version-1.2.3 # index the tag, version extracted from it
npx @cmflow/source-pack publish                   # upload the last build on the release of its tag

Global option: -c, --config <path> (default ./source-pack.config.ts). Paths of the config are resolved against the directory the command is run from. The config may be a .ts file (loaded with tsx) or a .mjs file. It can import defineConfig from @cmflow/source-pack even when the package is not installed in the project (npx usage): the import resolves to the running CLI.

| Command | Options | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | init | --force overwrites an existing file. repository is deduced from the origin remote; exclusions are pre-filled for the detected project type (node, python, jvm, go). | | build | --ref <commit-ish> (default: --tag, otherwise HEAD), --tag <tag>, --release-version <v> (default: from --tag with publish.tag, otherwise version of package.json at the ref), --skip-embeddings, --dry-run (no LiteLLM call, nothing written, sizes estimated). | | publish | --archive <path> (default: last build of outputDir), --dry-run (logs the planned upload, no HTTP call). |

Secrets are read from the environment only, never from the config, and are never logged nor written to the pack:

| Variable | Used by | | ----------------- | ------------------------------------------------------------------------- | | LITELLM_API_KEY | build (embeddings; the name can be changed with embedding.apiKeyEnv) | | GITHUB_TOKEN | publish on a GitHub repository (contents: write) | | GITLAB_TOKEN | publish on a GitLab project (api scope; falls back to CI_JOB_TOKEN) |

Configuration

import { defineConfig } from "@cmflow/source-pack";

export default defineConfig({
  outputDir: "./tmp/source-pack",
  repository: { provider: "github", owner: "acme", name: "example-api" },
  // GitLab: { provider: "gitlab", projectId: "group/project" (or 1234), apiUrl: "https://gitlab.example.com/api/v4" }
  sources: {
    include: ["**/*.{ts,tsx,js,json,yaml,yml,md,feature}"],
    exclude: ["mock/**", "test/functionnal/**", "package-lock.json", "coverage/**", "dist/**"],
    maxFileBytes: 1048576
  },
  chunking: { lines: 100, overlap: 15 },
  embedding: {
    baseUrl: "https://litellm.example.com",
    model: "text-embedding-3-small",
    fallbackModels: ["text-embedding-3-small-fallback-1", "text-embedding-3-small-fallback-2"],
    referenceModel: "text-embedding-3-small",
    dimensions: 1536,
    batchSize: 64,
    concurrency: 4
  },
  publish: {
    tag: "version-{version}",
    assetName: "source-pack-{version}.tar.gz"
  }
});
  • Only files tracked by Git at the indexed commit are read (from the Git objects, not the working tree: the result does not depend on the checkout, line endings or the OS). Binary files (NUL byte in the first 8000 bytes), symlinks, submodules and files above maxFileBytes are skipped. Test files (*.spec.*, *.test.* and their Python, Go and JVM equivalents) are excluded by default: they double the index size without describing production behavior.
  • Globs use minimatch with dot files. Defaults when sources is omitted: common text extensions, excluding tests, node_modules, dist, build, coverage and lockfiles.
  • Chunks are windows of lines lines advancing by lines - overlap; blank windows are skipped; id = sha256("<path>:<startLine>:<text>") — identical to the state-control indexer.
  • Embeddings use the OpenAI-compatible /v1/embeddings endpoint of LiteLLM (/v1 is appended to baseUrl), in batches of batchSize, concurrency (4) batches at a time, each retried maxRetries (3) times before switching to the next fallbackModels alias. The embedded text of a chunk is "<path>\n<text>" truncated to maxInputChars (12000). The manifest records the reference model (referenceModel, default: model): set it to the public model behind the gateway aliases so the manifest never names the regional alias that answered.
  • Omit embedding (or use --skip-embeddings) for a lexical-only pack.
  • publish.createRelease (default false) creates the release when the tag has none; by default the release tool owns releases and a missing release is an error.

An invalid config is rejected with one line per field, e.g.:

Invalid source-pack config (/repo/source-pack.config.ts):
  - repository.provider: expected "github" or "gitlab" (received "bitbucket")
  - chunking.overlap: expected a value lower than chunking.lines

Pack format (source-pack-<version>.tar.gz)

| Entry | Content | | ----------------- | ------------------------------------------------------------------------------------------------------ | | manifest.json | Project, version, tag, ref, SHA, dates, chunking version + config fingerprint, embedding model, counts | | chunks.jsonl.gz | One JSON object per line: { id, path, startLine, endLine, text } (lines are 1-based and inclusive) | | embeddings.f32 | chunks.count × dimensions little-endian float32, in chunk order (absent without embeddings) |

manifest.project.id (github:<owner>/<repo> or gitlab:<project>), sha, config.fingerprint (sha256 of sources + chunking + chunking format version) and embedding.model/dimensions uniquely identify the pack content.

Packs built by versions 3.19 and 3.20 may also contain an attachments/ directory and a manifest.attachments field. The format version is unchanged (2): readSourcePack still reads these packs and ignores both.

Publishing

The destination follows repository.provider:

  • GitHub: asset of the GitHub release of the tag; an asset with the same name is deleted first (idempotent).
  • GitLab: PUT /projects/:id/packages/generic/<packageName>/<version>/<assetName> (Generic Package Registry, packageName defaults to source-pack), older files with the same name in that package version are deleted, then a package link with the same name is created or updated on the GitLab release of the tag.

Reading a pack (Dataviz)

import { embeddingInput, readSourcePack } from "@cmflow/source-pack";

const pack = await readSourcePack("./source-pack-0.3503.0.tar.gz"); // or the downloaded bytes (Uint8Array)

pack.manifest.sha;
pack.chunks[0]; // { id, path, startLine, endLine, text }
pack.getEmbedding(0); // Float32Array(1536) | null

readSourcePack checks the format version, the chunk count and the embeddings size. Embed queries with the same manifest.embedding.model/dimensions; use embeddingInput() to re-embed chunks consistently.

Onboarding a project

  1. In the project root: npx @cmflow/source-pack init, then adjust sources.exclude (mocks, fixtures, generated data, vendored code…).
  2. Check the result locally: npx @cmflow/source-pack build --dry-run (chunk count and estimated size), then LITELLM_API_KEY=… npx @cmflow/source-pack build and npx @cmflow/source-pack publish --dry-run.
  3. Commit source-pack.config.ts and add tmp/source-pack to .gitignore.
  4. Add the job to the production merge pipeline only, after the job that creates the tag and its release (snippets below). It must not be required by any other job so that a failure never blocks the release; rerunning it republishes the pack.
  5. Provide the secrets: LITELLM_API_KEY and GITHUB_TOKEN (CircleCI shared context source-pack) or LITELLM_API_KEY and GITLAB_TOKEN (masked GitLab CI/CD variables).
  6. Enable the project in the « Source pack » tab of the Dataviz.

CircleCI

Copy templates/circleci-job.yml under jobs: and add to the production workflow:

- source-pack:
    requires: [cm-release-prod]
    filters:
      branches:
        only: /^production$/
    context: source-pack

The job resolves the first version-* tag containing the pipeline commit (the release commit created by cmrelease), then runs build --tag "$TAG" and publish.

GitLab CI

include:
  - remote: "https://raw.githubusercontent.com/ClubMediterranee/cmflow/master/packages/source-pack/templates/gitlab-ci.yml"

source-pack:
  extends: .source-pack
  needs: ["release"]
  rules:
    - if: $CI_COMMIT_BRANCH == "production"

The .source-pack template (templates/gitlab-ci.yml) is allow_failure: true and accepts SOURCE_PACK_VERSION and SOURCE_PACK_TAG_PATTERN variables.