@lucas-bur/pix 0.5.2 → 0.6.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.
Files changed (2) hide show
  1. package/dist/index.mjs +18 -22
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -15,12 +15,20 @@ var Embedder = class extends Context.Tag("Embedder")() {};
15
15
  var VectorStore = class extends Context.Tag("VectorStore")() {};
16
16
  //#endregion
17
17
  //#region src/application/get-status.ts
18
- /** Use case: get index statistics. Depends on VectorStore via Effect tag. */
18
+ /** Use case: get index statistics. Depends on VectorStore and ConfigStore via Effect tags. */
19
19
  var GetStatus = class extends Effect.Service()("GetStatus", {
20
20
  accessors: true,
21
21
  effect: Effect.gen(function* () {
22
22
  const store = yield* VectorStore;
23
- const getStatus = () => store.getStats();
23
+ const configStore = yield* ConfigStore;
24
+ const getStatus = () => Effect.gen(function* () {
25
+ const status = yield* store.getStatus();
26
+ const configModel = yield* configStore.readConfig().pipe(Effect.map((c) => c.model), Effect.catchAll(() => Effect.succeed(status.model)));
27
+ return {
28
+ ...status,
29
+ model: configModel
30
+ };
31
+ });
24
32
  return { getStatus };
25
33
  })
26
34
  }) {};
@@ -55,7 +63,7 @@ var IndexProject = class extends Effect.Service()("IndexProject", {
55
63
  yield* Effect.logInfo("No chunks to index.");
56
64
  return {
57
65
  success: true,
58
- stats: {
66
+ status: {
59
67
  chunks: 0,
60
68
  files: 0,
61
69
  totalLines: 0,
@@ -69,7 +77,7 @@ var IndexProject = class extends Effect.Service()("IndexProject", {
69
77
  const dims = embeddings[0]?.dims ?? 384;
70
78
  return {
71
79
  success: true,
72
- stats: {
80
+ status: {
73
81
  chunks: totalChunks,
74
82
  files: totalFiles,
75
83
  totalLines,
@@ -166,11 +174,11 @@ const indexCommand = Command.make("index", {
166
174
  if (result._tag === "Left") return yield* Effect.fail(result.left);
167
175
  const duration = `${((Date.now() - startTime) / 1e3).toFixed(1)}s`;
168
176
  if (json) return yield* Console.log(JSON.stringify({
169
- chunks: result.right.stats.chunks,
170
- files: result.right.stats.files,
177
+ chunks: result.right.status.chunks,
178
+ files: result.right.status.files,
171
179
  duration
172
180
  }));
173
- yield* Effect.logInfo(`Indexed ${result.right.stats.chunks} chunks from ${result.right.stats.files} files in ${duration}.`);
181
+ yield* Effect.logInfo(`Indexed ${result.right.status.chunks} chunks from ${result.right.status.files} files in ${duration}.`);
174
182
  }).pipe(Effect.tapError((error) => Console.log(formatError(error)))));
175
183
  //#endregion
176
184
  //#region src/commands/init.ts
@@ -500,18 +508,6 @@ const STORE_DIR = ".pix";
500
508
  const CHUNKS_FILE = `${STORE_DIR}/chunks.jsonl`;
501
509
  const VECTORS_FILE = `${STORE_DIR}/vectors.bin`;
502
510
  /**
503
- * Reads the first line of chunks.jsonl to get the model name. Returns empty string if the file
504
- * doesn't exist or is empty.
505
- */
506
- const readModelFromChunks = (lines) => {
507
- if (lines.length === 0) return "";
508
- try {
509
- return JSON.parse(lines[0]).model ?? "";
510
- } catch {
511
- return "";
512
- }
513
- };
514
- /**
515
511
  * FileSystem adapter for VectorStore port. Reads from chunks.jsonl and vectors.bin to provide index
516
512
  * statistics.
517
513
  */
@@ -586,7 +582,7 @@ const make = Effect.gen(function* () {
586
582
  results.sort((a, b) => b.score - a.score);
587
583
  return results.slice(0, topK);
588
584
  });
589
- const getStats = () => Effect.gen(function* () {
585
+ const getStatus = () => Effect.gen(function* () {
590
586
  const chunksExists = yield* fs.exists(CHUNKS_FILE);
591
587
  const vectorsExists = yield* fs.exists(VECTORS_FILE);
592
588
  if (!chunksExists || !vectorsExists) return {
@@ -600,7 +596,7 @@ const make = Effect.gen(function* () {
600
596
  const lines = (yield* fs.readFileString(CHUNKS_FILE).pipe(Effect.catchAll(() => Effect.succeed("")))).split("\n").filter((l) => l.trim().length > 0);
601
597
  const chunks = lines.length;
602
598
  const files = countUniqueFiles(lines).size;
603
- const model = readModelFromChunks(lines);
599
+ const model = "";
604
600
  const totalLines = countTotalLines(lines);
605
601
  const vectorsStat = yield* fs.stat(VECTORS_FILE).pipe(Effect.catchAll(() => Effect.succeed(null)));
606
602
  const byteSize = vectorsStat && "size" in vectorsStat ? Number(vectorsStat.size) : 0;
@@ -638,7 +634,7 @@ const make = Effect.gen(function* () {
638
634
  return {
639
635
  store,
640
636
  search,
641
- getStats,
637
+ getStatus,
642
638
  reset
643
639
  };
644
640
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucas-bur/pix",
3
- "version": "0.5.2",
3
+ "version": "0.6.0",
4
4
  "description": "Lightweight local semantic project indexer",
5
5
  "keywords": [
6
6
  "cli",