@gmickel/gno 2.8.2 → 2.8.4
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 +1 -1
- package/assets/spa-production.json.gz +0 -0
- package/browser-extension/artifacts/{gno-browser-clipper-v2.8.2.zip → gno-browser-clipper-v2.8.4.zip} +0 -0
- package/browser-extension/artifacts/gno-browser-clipper-v2.8.4.zip.sha256 +1 -0
- package/browser-extension/dist/manifest.json +1 -1
- package/package.json +9 -1
- package/spec/cli.md +77 -6
- package/spec/mcp.md +5 -6
- package/spec/output-schemas/doctor.schema.json +10 -4
- package/spec/output-schemas/status.schema.json +4 -2
- package/src/cli/commands/daemon.ts +7 -2
- package/src/cli/commands/doctor-activation.ts +38 -11
- package/src/cli/commands/doctor.ts +46 -25
- package/src/cli/commands/index-cmd.ts +10 -2
- package/src/cli/commands/links.ts +5 -22
- package/src/cli/commands/shared.ts +26 -1
- package/src/cli/commands/status.ts +76 -4
- package/src/cli/commands/update.ts +6 -1
- package/src/cli/commands/vec.ts +42 -2
- package/src/cli/program.ts +2 -2
- package/src/config/types.ts +19 -0
- package/src/converters/adapters/markitdownTs/adapter.ts +1 -52
- package/src/converters/adapters/shared/ooxml-protection.ts +58 -0
- package/src/converters/adapters/xlsx/adapter.ts +132 -0
- package/src/converters/adapters/xlsx/sheet-markdown.ts +312 -0
- package/src/converters/registry.ts +62 -6
- package/src/converters/versions.ts +2 -0
- package/src/core/activation-empty.ts +16 -0
- package/src/core/activation-status.ts +23 -5
- package/src/core/audit-freshness.ts +1 -1
- package/src/core/audit-outside-index.ts +48 -3
- package/src/core/change-diff.ts +16 -4
- package/src/core/link-destination-parse.ts +21 -4
- package/src/core/link-inventory-markdown.ts +23 -3
- package/src/core/links.ts +127 -31
- package/src/core/network-boundary-inventory.ts +18 -0
- package/src/index.ts +10 -0
- package/src/ingestion/document-metadata.ts +256 -0
- package/src/ingestion/file-child-env.ts +9 -0
- package/src/ingestion/file-child.ts +106 -0
- package/src/ingestion/file-processor.ts +546 -0
- package/src/ingestion/frontmatter.ts +6 -2
- package/src/ingestion/index.ts +1 -0
- package/src/ingestion/prepare-convert.ts +32 -0
- package/src/ingestion/prepare-file.ts +272 -0
- package/src/ingestion/prepare-worker.ts +43 -0
- package/src/ingestion/record-container.ts +7 -2
- package/src/ingestion/strip.ts +136 -31
- package/src/ingestion/sync-options.ts +7 -1
- package/src/ingestion/sync.ts +207 -400
- package/src/ingestion/types.ts +18 -0
- package/src/llm/native-worker/embedding-identity.ts +15 -3
- package/src/mcp/http-transport.ts +11 -0
- package/src/mcp/tools/links.ts +10 -38
- package/src/serve/activation-health.ts +25 -7
- package/src/serve/public/components/BootstrapStatus.tsx +9 -4
- package/src/serve/resident-request.ts +19 -0
- package/src/serve/resident-runtime.ts +84 -8
- package/src/serve/routes/links.ts +6 -24
- package/src/serve/server.ts +3 -2
- package/src/serve/status.ts +27 -8
- package/src/sessions/config-refresh.ts +3 -2
- package/src/store/sqlite/graph-similarity.ts +5 -13
- package/src/store/vector/partition-index.ts +100 -0
- package/src/store/vector/stored-vectors.ts +20 -15
- package/browser-extension/artifacts/gno-browser-clipper-v2.8.2.zip.sha256 +0 -1
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maintenance of an activated vector partition's vec0 index
|
|
3
|
+
* (`vec_v1_<partition>`), which mirrors the partition's `vector_variants`.
|
|
4
|
+
* `gno vec sync` and `gno vec rebuild` use it on indexes embedded since 2.7.
|
|
5
|
+
* Neither changes authority, owners or variants, so the variant epoch stays.
|
|
6
|
+
*
|
|
7
|
+
* @module src/store/vector/partition-index
|
|
8
|
+
*/
|
|
9
|
+
import type { Database } from "bun:sqlite";
|
|
10
|
+
|
|
11
|
+
export interface StoredPartition {
|
|
12
|
+
partitionId: string;
|
|
13
|
+
dimensions: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const tableName = (partition: StoredPartition): string =>
|
|
17
|
+
`vec_v1_${partition.partitionId}`;
|
|
18
|
+
|
|
19
|
+
const createTable = (db: Database, partition: StoredPartition): void => {
|
|
20
|
+
db.exec(`CREATE VIRTUAL TABLE IF NOT EXISTS ${tableName(partition)} USING vec0(
|
|
21
|
+
variant_id INTEGER PRIMARY KEY,
|
|
22
|
+
embedding FLOAT[${partition.dimensions}] distance_metric=cosine
|
|
23
|
+
)`);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const insertVariants = (
|
|
27
|
+
db: Database,
|
|
28
|
+
partition: StoredPartition,
|
|
29
|
+
rows: Iterable<{ variantId: number; embedding: Uint8Array }>
|
|
30
|
+
): number => {
|
|
31
|
+
let inserted = 0;
|
|
32
|
+
for (const row of rows) {
|
|
33
|
+
db.run(
|
|
34
|
+
`INSERT INTO ${tableName(partition)}(variant_id, embedding) VALUES (?, ?)`,
|
|
35
|
+
[row.variantId, row.embedding]
|
|
36
|
+
);
|
|
37
|
+
inserted += 1;
|
|
38
|
+
}
|
|
39
|
+
return inserted;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Remove index rows without a matching variant (orphans and stale
|
|
44
|
+
* embeddings), then add the variants the index lacks. Requires sqlite-vec.
|
|
45
|
+
*/
|
|
46
|
+
export function syncPartitionIndex(
|
|
47
|
+
db: Database,
|
|
48
|
+
partition: StoredPartition
|
|
49
|
+
): { added: number; removed: number } {
|
|
50
|
+
const table = tableName(partition);
|
|
51
|
+
return db
|
|
52
|
+
.transaction(() => {
|
|
53
|
+
createTable(db, partition);
|
|
54
|
+
const stale = db
|
|
55
|
+
.query<{ variantId: number }, [string]>(`
|
|
56
|
+
SELECT x.variant_id AS variantId FROM ${table} x
|
|
57
|
+
LEFT JOIN vector_variants v ON v.variant_id = x.variant_id
|
|
58
|
+
AND v.partition_id = ?
|
|
59
|
+
WHERE v.variant_id IS NULL OR x.embedding != v.embedding
|
|
60
|
+
`)
|
|
61
|
+
.all(partition.partitionId);
|
|
62
|
+
for (const { variantId } of stale) {
|
|
63
|
+
db.run(`DELETE FROM ${table} WHERE variant_id = ?`, [variantId]);
|
|
64
|
+
}
|
|
65
|
+
const missing = db
|
|
66
|
+
.query<{ variantId: number; embedding: Uint8Array }, [string]>(`
|
|
67
|
+
SELECT v.variant_id AS variantId, v.embedding FROM vector_variants v
|
|
68
|
+
LEFT JOIN ${table} x ON x.variant_id = v.variant_id
|
|
69
|
+
WHERE v.partition_id = ? AND x.variant_id IS NULL
|
|
70
|
+
`)
|
|
71
|
+
.all(partition.partitionId);
|
|
72
|
+
return {
|
|
73
|
+
added: insertVariants(db, partition, missing),
|
|
74
|
+
removed: stale.length,
|
|
75
|
+
};
|
|
76
|
+
})
|
|
77
|
+
.immediate();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Drop and repopulate the index from the partition's variants. */
|
|
81
|
+
export function rebuildPartitionIndex(
|
|
82
|
+
db: Database,
|
|
83
|
+
partition: StoredPartition
|
|
84
|
+
): number {
|
|
85
|
+
return db
|
|
86
|
+
.transaction(() => {
|
|
87
|
+
db.exec(`DROP TABLE IF EXISTS ${tableName(partition)}`);
|
|
88
|
+
createTable(db, partition);
|
|
89
|
+
return insertVariants(
|
|
90
|
+
db,
|
|
91
|
+
partition,
|
|
92
|
+
db
|
|
93
|
+
.query<{ variantId: number; embedding: Uint8Array }, [string]>(
|
|
94
|
+
"SELECT variant_id AS variantId, embedding FROM vector_variants WHERE partition_id = ?"
|
|
95
|
+
)
|
|
96
|
+
.iterate(partition.partitionId)
|
|
97
|
+
);
|
|
98
|
+
})
|
|
99
|
+
.immediate();
|
|
100
|
+
}
|
|
@@ -53,25 +53,30 @@ interface PartitionVectorRow {
|
|
|
53
53
|
embedding: Uint8Array;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
const unitVector = (vector: Float32Array): Float32Array => {
|
|
57
|
+
let norm = 0;
|
|
58
|
+
for (const value of vector) norm += value * value;
|
|
59
|
+
norm = Math.sqrt(norm);
|
|
60
|
+
return norm > 0 ? vector.map((value) => value / norm) : vector;
|
|
61
|
+
};
|
|
62
|
+
|
|
56
63
|
/**
|
|
57
|
-
*
|
|
58
|
-
* document id
|
|
59
|
-
*
|
|
60
|
-
*
|
|
64
|
+
* The similarity source vector of each current active document, keyed by
|
|
65
|
+
* document id: the stored vector of its first chunk (lowest seq whose vector
|
|
66
|
+
* is current), unit-normalized. Every similarity surface (CLI, MCP, REST and
|
|
67
|
+
* graph edges) uses this one rule, so scores agree. Partition vectors count
|
|
68
|
+
* only while their owner still yields the stored input (the rule vector
|
|
69
|
+
* search applies).
|
|
61
70
|
*/
|
|
62
|
-
export function
|
|
71
|
+
export function readSimilaritySourceVectors(
|
|
63
72
|
db: Database,
|
|
64
73
|
source: StoredVectorSource,
|
|
65
|
-
documents: StoredVectorDocument[]
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const vectors = new Map<number, Float32Array[]>();
|
|
74
|
+
documents: StoredVectorDocument[]
|
|
75
|
+
): Map<number, Float32Array> {
|
|
76
|
+
const vectors = new Map<number, Float32Array>();
|
|
69
77
|
const add = (documentId: number, blob: Uint8Array): void => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const embedding = decodeEmbedding(blob);
|
|
73
|
-
if (existing) existing.push(embedding);
|
|
74
|
-
else vectors.set(documentId, [embedding]);
|
|
78
|
+
if (!vectors.has(documentId))
|
|
79
|
+
vectors.set(documentId, unitVector(decodeEmbedding(blob)));
|
|
75
80
|
};
|
|
76
81
|
if (documents.length === 0) return vectors;
|
|
77
82
|
|
|
@@ -95,7 +100,7 @@ export function readStoredDocumentVectors(
|
|
|
95
100
|
JSON.stringify(documents.map((document) => document.id))
|
|
96
101
|
);
|
|
97
102
|
for (const row of rows) {
|
|
98
|
-
if (
|
|
103
|
+
if (vectors.has(row.documentId)) continue;
|
|
99
104
|
const input = formatDocForEmbedding(
|
|
100
105
|
row.text,
|
|
101
106
|
row.title ?? undefined,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
7bc830276cb923a482b662b980208b0978bf8ddbfbade0873e67d9757cf9c989 gno-browser-clipper-v2.8.2.zip
|