pi-mega-compact 0.8.20 → 0.8.21

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 (38) hide show
  1. package/README.md +6 -0
  2. package/dist/extensions/dashboard-client/src/hooks/useApi.js +51 -0
  3. package/dist/extensions/dashboard-client/src/hooks/useSSE.js +63 -0
  4. package/dist/extensions/mega-compact-s38.test.js +28 -2
  5. package/dist/extensions/mega-events/agent-handlers.js +16 -0
  6. package/dist/extensions/mega-events/error-classifier.js +8 -3
  7. package/extensions/dashboard-client/package-lock.json +1 -1
  8. package/extensions/dashboard-client/package.json +1 -1
  9. package/extensions/mega-compact-s38.test.ts +32 -2
  10. package/extensions/mega-events/agent-handlers.ts +15 -0
  11. package/extensions/mega-events/error-classifier.ts +8 -2
  12. package/package.json +1 -1
  13. package/dist/extensions/dashboard-server/helpers.js +0 -37
  14. package/dist/extensions/dashboard-server/html/all-repos-tab.js +0 -26
  15. package/dist/extensions/dashboard-server/html/body-open.js +0 -23
  16. package/dist/extensions/dashboard-server/html/current-repo-tab.js +0 -130
  17. package/dist/extensions/dashboard-server/html/head-open.js +0 -16
  18. package/dist/extensions/dashboard-server/html/high-score-tab.js +0 -25
  19. package/dist/extensions/dashboard-server/html/repo-detail-modal.js +0 -26
  20. package/dist/extensions/dashboard-server/html/script.js +0 -259
  21. package/dist/extensions/dashboard-server/html/styles.js +0 -103
  22. package/dist/extensions/dashboard-server/html/summary-tab.js +0 -19
  23. package/dist/extensions/dashboard-server/html-template.js +0 -41
  24. package/dist/src/store/sqlite/connection.js +0 -35
  25. package/dist/src/store/sqlite/index-store.js +0 -167
  26. package/dist/src/store/sqlite/memory.js +0 -54
  27. package/dist/src/store/sqlite/minhash-lsh.js +0 -47
  28. package/dist/src/store/sqlite/sessions.js +0 -39
  29. package/dist/src/store/sqlite/transaction.js +0 -19
  30. package/dist/src/vectorStore/add.js +0 -260
  31. package/dist/src/vectorStore/dedup.js +0 -52
  32. package/dist/src/vectorStore/index.js +0 -10
  33. package/dist/src/vectorStore/queries.js +0 -83
  34. package/dist/src/vectorStore/search.js +0 -95
  35. package/dist/src/vectorStore/session.js +0 -19
  36. package/dist/src/vectorStore/store.js +0 -105
  37. package/dist/src/vectorStore/types.js +0 -6
  38. package/dist/src/vectorStore/utils.js +0 -23
@@ -1,19 +0,0 @@
1
- /**
2
- * vectorStore/session.ts — Session-state mutations (injection tracking).
3
- */
4
- import { normalizeSessionId } from "../store.js";
5
- import { loadSessionState, saveSessionState } from "../store/sqlite.js";
6
- /** Mark a checkpoint as injected into the window (recall dedup). */
7
- export function markInjectedStore(ctx, sessionId, checkpointId) {
8
- const sid = normalizeSessionId(sessionId);
9
- const state = loadSessionState(sid, ctx.stateDir);
10
- if (!state.injectedCheckpointIds.includes(checkpointId)) {
11
- state.injectedCheckpointIds.push(checkpointId);
12
- saveSessionState(sid, state, ctx.stateDir);
13
- }
14
- }
15
- /** True if this checkpoint was already injected this session. */
16
- export function wasInjectedStore(ctx, sessionId, checkpointId) {
17
- const state = loadSessionState(normalizeSessionId(sessionId), ctx.stateDir);
18
- return state.injectedCheckpointIds.includes(checkpointId);
19
- }
@@ -1,105 +0,0 @@
1
- /**
2
- * vectorStore/store.ts — VectorStore class (thin wrapper delegating to
3
- * sub-modules). Public API is identical to the pre-split monolith.
4
- */
5
- import { defaultEmbedder } from "../embedder.js";
6
- import { loadDedupConfig } from "../config/dedup.js";
7
- import { getStateDir } from "../store.js";
8
- import { openBloom } from "../store/bloom.js";
9
- import { migrateJsonToSqlite } from "../store/migrate.js";
10
- import { addToStore } from "./add.js";
11
- import { searchStore } from "./search.js";
12
- import { semDedupStore, dedupeCheck } from "./dedup.js";
13
- import { markInjectedStore, wasInjectedStore } from "./session.js";
14
- import { listSession, topSimilarSession, statsSession, repoStatsStore, dataInvariantStore, similarityScore, } from "./queries.js";
15
- export class VectorStore {
16
- ctx;
17
- constructor(opts = {}) {
18
- const embedder = opts.embedder ?? defaultEmbedder();
19
- const stateDir = opts.stateDir ?? getStateDir();
20
- // Sprint 14: all tier flags/thresholds flow from the single config source
21
- // (DedupConfig). The legacy opts.dedupSim / opts.l2Enabled remain accepted
22
- // for backward-compat callers but flags are authoritative via `cfg`.
23
- void opts.dedupSim;
24
- void opts.l2Enabled;
25
- // Sprint 12 L2 semantic tier. Threshold 0.85 is the default trigram
26
- // embedder's honest firing point; a direct override is allowed for tests.
27
- const cfg = opts.config ?? loadDedupConfig();
28
- const l2Threshold = opts.l2Threshold ?? cfg.L2_COSINE;
29
- this.ctx = {
30
- embedder,
31
- stateDir,
32
- l2Threshold,
33
- cfg,
34
- eventsPath: opts.eventsPath,
35
- };
36
- // Sprint 8: bring any v0.1.0 JSON checkpoint files into SQLite (idempotent).
37
- migrateJsonToSqlite(stateDir);
38
- // Sprint 10: warm the bloom accelerator (accelerator only — SQLite stays
39
- // source of truth; a bloom hit is always confirmed by a query below).
40
- openBloom(stateDir);
41
- }
42
- /** @internal Shared context for sub-module operations. */
43
- get context() {
44
- return this.ctx;
45
- }
46
- /** @internal Kept for test compatibility — delegates to ctx.stateDir. */
47
- get stateDir() {
48
- return this.ctx.stateDir;
49
- }
50
- add(input) {
51
- return addToStore(this.ctx, input);
52
- }
53
- search(sessionId, query, k = 3) {
54
- return searchStore(this.ctx, sessionId, query, k);
55
- }
56
- semDedup(sessionId, threshold = this.ctx.cfg.SEMDEDUP_COSINE) {
57
- return semDedupStore(this.ctx, sessionId, threshold);
58
- }
59
- dedupe(sessionId, regionHashOrText, isText = false) {
60
- return dedupeCheck(this.ctx, sessionId, regionHashOrText, isText);
61
- }
62
- /** Mark a checkpoint as injected into the window (recall dedup). */
63
- markInjected(sessionId, checkpointId) {
64
- markInjectedStore(this.ctx, sessionId, checkpointId);
65
- }
66
- /** True if this checkpoint was already injected this session. */
67
- wasInjected(sessionId, checkpointId) {
68
- return wasInjectedStore(this.ctx, sessionId, checkpointId);
69
- }
70
- /** Convenience for a raw vector cosine (exposed for tests). */
71
- similarity(a, b) {
72
- return similarityScore(a, b);
73
- }
74
- /** All checkpoints for a session (sorted by checkpointId). */
75
- list(sessionId) {
76
- return listSession(this.ctx, sessionId);
77
- }
78
- /**
79
- * Return the n most similar checkpoints to the current (most recent) checkpoint
80
- * by cosine similarity. Returns fewer than n if the session has fewer checkpoints.
81
- * The current checkpoint itself is excluded from results.
82
- */
83
- topSimilar(sessionId, n) {
84
- return topSimilarSession(this.ctx, sessionId, n);
85
- }
86
- /**
87
- * Store statistics for status reporting / logging. Returns counts + the last
88
- * (highest-numbered) checkpoint, or nulls when the session is empty.
89
- */
90
- stats(sessionId) {
91
- return statsSession(this.ctx, sessionId);
92
- }
93
- /**
94
- * Repo-wide stats — aggregates every session in this store (one per repo).
95
- * Cumulative, resumable, cross-device. Surfaces the dashboard's "Repo …"
96
- * figures; distinct from {@link stats} (per-session).
97
- */
98
- repoStats() {
99
- return repoStatsStore(this.ctx);
100
- }
101
- /** Data-safety invariant (Phase 0): regions retained vs bytes permanently deleted. */
102
- dataInvariant() {
103
- return dataInvariantStore(this.ctx);
104
- }
105
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * vectorStore/types.ts — Shared types, constants, and context interface for the
3
- * vector store sub-modules.
4
- */
5
- /** Default L2 semantic-dedup enable flag (trigram embedder is local, zero-network). */
6
- export const L2_ENABLED = true;
@@ -1,23 +0,0 @@
1
- /**
2
- * vectorStore/utils.ts — Hashing and monitoring utilities.
3
- */
4
- import { createHash } from "node:crypto";
5
- import { logDecision } from "../monitoring.js";
6
- /** Stable hash of a compacted region, the dedup sentinel key. */
7
- export function computeRegionHash(regionText) {
8
- // Normalize whitespace before hashing so "foo bar" and "foo bar" dedup.
9
- const normalized = regionText.replace(/\s+/g, " ").trim();
10
- return createHash("sha256").update(normalized).digest("hex").slice(0, 16);
11
- }
12
- /** Emit a structured dedup-decision event (best-effort, never throws). */
13
- export function recordDecision(ctx, tier, result, reason, latencyMs) {
14
- if (!ctx.eventsPath)
15
- return;
16
- logDecision(ctx.eventsPath, {
17
- ts: Date.now(),
18
- tier,
19
- result,
20
- reason,
21
- latencyMs: Math.round(latencyMs * 100) / 100,
22
- });
23
- }