@cmflow/source-pack 3.20.0 → 3.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -15
- package/dist/bin/source-pack.mjs +8 -8
- package/dist/bin/source-pack.mjs.map +1 -1
- package/dist/buildSourcePack-59jTztr3.mjs +3 -0
- package/dist/{buildSourcePack-CaaMZ_tw.mjs → buildSourcePack-YCfD24d4.mjs} +8 -27
- package/dist/{buildSourcePack-CaaMZ_tw.mjs.map → buildSourcePack-YCfD24d4.mjs.map} +1 -1
- package/dist/{constants-DkiLCuIK.mjs → constants-o4tbCIrY.mjs} +3 -4
- package/dist/constants-o4tbCIrY.mjs.map +1 -0
- package/dist/index.d.mts +7 -24
- package/dist/index.mjs +6 -7
- package/dist/index.mjs.map +1 -1
- package/dist/{initConfig-ByGsbShR.mjs → initConfig-Cy7oMMxo.mjs} +5 -6
- package/dist/{initConfig-ByGsbShR.mjs.map → initConfig-Cy7oMMxo.mjs.map} +1 -1
- package/dist/{loadConfig-CNrL90dq.mjs → loadConfig-KYduEj2v.mjs} +3 -5
- package/dist/loadConfig-KYduEj2v.mjs.map +1 -0
- package/dist/{packageVersion-B0749hF6.mjs → packageVersion-CpvQqEy_.mjs} +2 -2
- package/dist/{packageVersion-B0749hF6.mjs.map → packageVersion-CpvQqEy_.mjs.map} +1 -1
- package/dist/{publishSourcePack-xNr9RBgv.mjs → publishSourcePack-BfPLD37B.mjs} +2 -2
- package/dist/{publishSourcePack-xNr9RBgv.mjs.map → publishSourcePack-BfPLD37B.mjs.map} +1 -1
- package/dist/publishSourcePack-BwAIlydQ.mjs +3 -0
- package/package.json +1 -1
- package/dist/buildSourcePack-DIp8G_uL.mjs +0 -3
- package/dist/constants-DkiLCuIK.mjs.map +0 -1
- package/dist/loadConfig-CNrL90dq.mjs.map +0 -1
- package/dist/publishSourcePack-Dj1cdWfT.mjs +0 -3
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
</div>
|
|
13
13
|
|
|
14
14
|
`source-pack` builds, at each production release of a project hosted on GitHub or GitLab, a **versioned index of its code**
|
|
15
|
-
(chunks + embeddings +
|
|
15
|
+
(chunks + embeddings + manifest) and publishes it on the release of the tag. The Dataviz loads it with
|
|
16
16
|
`readSourcePack()` to answer `source_search` on any production version, without a local checkout.
|
|
17
17
|
|
|
18
18
|
The package is generic: everything that depends on a project lives in its `source-pack.config.ts`.
|
|
@@ -51,7 +51,7 @@ import { defineConfig } from "@cmflow/source-pack";
|
|
|
51
51
|
|
|
52
52
|
export default defineConfig({
|
|
53
53
|
outputDir: "./tmp/source-pack",
|
|
54
|
-
repository: { provider: "github", owner: "
|
|
54
|
+
repository: { provider: "github", owner: "acme", name: "example-api" },
|
|
55
55
|
// GitLab: { provider: "gitlab", projectId: "group/project" (or 1234), apiUrl: "https://gitlab.example.com/api/v4" }
|
|
56
56
|
sources: {
|
|
57
57
|
include: ["**/*.{ts,tsx,js,json,yaml,yml,md,feature}"],
|
|
@@ -60,15 +60,14 @@ export default defineConfig({
|
|
|
60
60
|
},
|
|
61
61
|
chunking: { lines: 100, overlap: 15 },
|
|
62
62
|
embedding: {
|
|
63
|
-
baseUrl: "https://
|
|
64
|
-
model: "text-embedding-3-small
|
|
65
|
-
fallbackModels: ["text-embedding-3-small-
|
|
63
|
+
baseUrl: "https://litellm.example.com",
|
|
64
|
+
model: "text-embedding-3-small",
|
|
65
|
+
fallbackModels: ["text-embedding-3-small-fallback-1", "text-embedding-3-small-fallback-2"],
|
|
66
66
|
referenceModel: "text-embedding-3-small",
|
|
67
67
|
dimensions: 1536,
|
|
68
68
|
batchSize: 64,
|
|
69
69
|
concurrency: 4
|
|
70
70
|
},
|
|
71
|
-
attachments: ["tools/build/cache-layers-adjacency-list-reference.json"],
|
|
72
71
|
publish: {
|
|
73
72
|
tag: "version-{version}",
|
|
74
73
|
assetName: "source-pack-{version}.tar.gz"
|
|
@@ -89,7 +88,6 @@ export default defineConfig({
|
|
|
89
88
|
`"<path>\n<text>"` truncated to `maxInputChars` (12000). The manifest records the **reference model** (`referenceModel`, default:
|
|
90
89
|
`model`): set it to the public model behind the gateway aliases so the manifest never names the regional alias that answered.
|
|
91
90
|
- Omit `embedding` (or use `--skip-embeddings`) for a lexical-only pack.
|
|
92
|
-
- `attachments` are copied verbatim (they do not need to match `sources`).
|
|
93
91
|
- `publish.createRelease` (default `false`) creates the release when the tag has none; by default the release tool owns releases and a
|
|
94
92
|
missing release is an error.
|
|
95
93
|
|
|
@@ -103,16 +101,18 @@ Invalid source-pack config (/repo/source-pack.config.ts):
|
|
|
103
101
|
|
|
104
102
|
## Pack format (`source-pack-<version>.tar.gz`)
|
|
105
103
|
|
|
106
|
-
| Entry
|
|
107
|
-
|
|
|
108
|
-
| `manifest.json`
|
|
109
|
-
| `chunks.jsonl.gz`
|
|
110
|
-
| `embeddings.f32`
|
|
111
|
-
| `attachments/<path>` | Files declared in `attachments` |
|
|
104
|
+
| Entry | Content |
|
|
105
|
+
| ----------------- | ------------------------------------------------------------------------------------------------------ |
|
|
106
|
+
| `manifest.json` | Project, version, tag, ref, SHA, dates, chunking version + config fingerprint, embedding model, counts |
|
|
107
|
+
| `chunks.jsonl.gz` | One JSON object per line: `{ id, path, startLine, endLine, text }` (lines are 1-based and inclusive) |
|
|
108
|
+
| `embeddings.f32` | `chunks.count × dimensions` little-endian float32, in chunk order (absent without embeddings) |
|
|
112
109
|
|
|
113
110
|
`manifest.project.id` (`github:<owner>/<repo>` or `gitlab:<project>`), `sha`, `config.fingerprint` (sha256 of `sources` +
|
|
114
111
|
`chunking` + chunking format version) and `embedding.model`/`dimensions` uniquely identify the pack content.
|
|
115
112
|
|
|
113
|
+
Packs built by versions 3.19 and 3.20 may also contain an `attachments/` directory and a `manifest.attachments` field. The format
|
|
114
|
+
version is unchanged (2): `readSourcePack` still reads these packs and ignores both.
|
|
115
|
+
|
|
116
116
|
### Publishing
|
|
117
117
|
|
|
118
118
|
The destination follows `repository.provider`:
|
|
@@ -132,7 +132,6 @@ const pack = await readSourcePack("./source-pack-0.3503.0.tar.gz"); // or the do
|
|
|
132
132
|
pack.manifest.sha;
|
|
133
133
|
pack.chunks[0]; // { id, path, startLine, endLine, text }
|
|
134
134
|
pack.getEmbedding(0); // Float32Array(1536) | null
|
|
135
|
-
pack.attachments.get("tools/build/cache-layers-adjacency-list-reference.json");
|
|
136
135
|
```
|
|
137
136
|
|
|
138
137
|
`readSourcePack` checks the format version, the chunk count and the embeddings size. Embed queries with the same
|
|
@@ -141,7 +140,7 @@ pack.attachments.get("tools/build/cache-layers-adjacency-list-reference.json");
|
|
|
141
140
|
## Onboarding a project
|
|
142
141
|
|
|
143
142
|
1. In the project root: `npx @cmflow/source-pack init`, then adjust `sources.exclude` (mocks, fixtures, generated data, vendored
|
|
144
|
-
code…)
|
|
143
|
+
code…).
|
|
145
144
|
2. Check the result locally: `npx @cmflow/source-pack build --dry-run` (chunk count and estimated size), then
|
|
146
145
|
`LITELLM_API_KEY=… npx @cmflow/source-pack build` and `npx @cmflow/source-pack publish --dry-run`.
|
|
147
146
|
3. Commit `source-pack.config.ts` and add `tmp/source-pack` to `.gitignore`.
|
package/dist/bin/source-pack.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as packageVersion, w as errorMessage } from "../packageVersion-
|
|
3
|
-
import {
|
|
4
|
-
import { t as loadConfig } from "../loadConfig-
|
|
2
|
+
import { t as packageVersion, w as errorMessage } from "../packageVersion-CpvQqEy_.mjs";
|
|
3
|
+
import { a as DEFAULT_CONFIG_FILE } from "../constants-o4tbCIrY.mjs";
|
|
4
|
+
import { t as loadConfig } from "../loadConfig-KYduEj2v.mjs";
|
|
5
5
|
import { t as logger } from "../logger-D1XGzzjT.mjs";
|
|
6
6
|
import { EventEmitter } from "node:events";
|
|
7
7
|
import childProcess from "node:child_process";
|
|
@@ -2988,7 +2988,7 @@ function run(action) {
|
|
|
2988
2988
|
function registerCommands(program) {
|
|
2989
2989
|
const configPath = () => path.resolve(process.cwd(), program.opts().config);
|
|
2990
2990
|
program.command("init").description("Create a default source-pack.config.ts (repository deduced from the Git remote)").option("--force", "Overwrite an existing config", false).action((options) => run(async () => {
|
|
2991
|
-
const { initConfig } = await import("../initConfig-
|
|
2991
|
+
const { initConfig } = await import("../initConfig-Cy7oMMxo.mjs");
|
|
2992
2992
|
const result = await initConfig({
|
|
2993
2993
|
configPath: configPath(),
|
|
2994
2994
|
force: options.force
|
|
@@ -2996,8 +2996,8 @@ function registerCommands(program) {
|
|
|
2996
2996
|
const remote = result.remote ? `${result.remote.provider} ${result.remote.owner}/${result.remote.name}` : "no recognized Git remote (edit repository)";
|
|
2997
2997
|
logger.info(`created ${result.configPath} (${result.projectType} project, ${remote})`);
|
|
2998
2998
|
}));
|
|
2999
|
-
program.command("build").description("Build the source pack (chunks + embeddings +
|
|
3000
|
-
const { buildSourcePack } = await import("../buildSourcePack-
|
|
2999
|
+
program.command("build").description("Build the source pack (chunks + embeddings + manifest) at a Git ref").option("--ref <ref>", "Commit-ish to index (default: --tag, otherwise HEAD)").option("--tag <tag>", "Release tag; the version is extracted from it with publish.tag").option("--release-version <version>", "Release version (default: from --tag, otherwise package.json at the ref)").option("--skip-embeddings", "Build without embeddings.f32 (no LiteLLM call)", false).option("--dry-run", "Compute chunks and sizes without calling LiteLLM nor writing files", false).action((options) => run(async () => {
|
|
3000
|
+
const { buildSourcePack } = await import("../buildSourcePack-59jTztr3.mjs");
|
|
3001
3001
|
const result = await buildSourcePack({
|
|
3002
3002
|
config: await loadConfig(configPath()),
|
|
3003
3003
|
ref: options.ref,
|
|
@@ -3010,12 +3010,12 @@ function registerCommands(program) {
|
|
|
3010
3010
|
const { manifest } = result;
|
|
3011
3011
|
const embedding = manifest.embedding ? `${manifest.embedding.model} x ${manifest.embedding.dimensions}` : "none";
|
|
3012
3012
|
logger.info(`project ${manifest.project.id}, version ${manifest.version}, tag ${manifest.tag}, sha ${manifest.sha}`);
|
|
3013
|
-
logger.info(`${manifest.chunks.count} chunks from ${manifest.files.indexed} files,
|
|
3013
|
+
logger.info(`${manifest.chunks.count} chunks from ${manifest.files.indexed} files, embeddings: ${embedding}`);
|
|
3014
3014
|
logger.info(`chunks.jsonl.gz ${formatBytes(result.chunksBytes)}, embeddings.f32 ${formatBytes(result.embeddingsBytes)}`);
|
|
3015
3015
|
logger.info(result.dryRun ? `[dry-run] estimated pack size ${formatBytes(result.bytes)}, nothing written` : `wrote ${result.archivePath} (${formatBytes(result.bytes)})`);
|
|
3016
3016
|
}));
|
|
3017
3017
|
program.command("publish").description("Publish the built pack on the release of its tag (replaces an asset with the same name)").option("--archive <path>", "Archive to publish (default: the last build in outputDir)").option("--dry-run", "Log what would be published without any HTTP call", false).action((options) => run(async () => {
|
|
3018
|
-
const { publishSourcePack } = await import("../publishSourcePack-
|
|
3018
|
+
const { publishSourcePack } = await import("../publishSourcePack-BwAIlydQ.mjs");
|
|
3019
3019
|
const result = await publishSourcePack({
|
|
3020
3020
|
config: await loadConfig(configPath()),
|
|
3021
3021
|
archivePath: options.archive,
|