@omgbase/core 0.28.0 → 0.29.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/dist/src/core/read/document.d.ts +11 -10
- package/dist/src/core/read/document.js +12 -11
- package/dist/src/core/read/nodes.d.ts +10 -10
- package/dist/src/core/read/nodes.js +11 -11
- package/dist/src/core/read/reader.d.ts +37 -24
- package/dist/src/core/read/reader.js +44 -31
- package/dist/src/graph/history.d.ts +25 -22
- package/dist/src/graph/history.js +17 -17
- package/dist/src/graph/inbound-links.d.ts +7 -7
- package/dist/src/graph/inbound-links.js +7 -7
- package/dist/src/graph/link-health.d.ts +9 -9
- package/dist/src/graph/link-health.js +9 -9
- package/dist/src/graph/links.d.ts +3 -3
- package/dist/src/graph/links.js +4 -4
- package/dist/src/mcp/arguments.d.ts +10 -3
- package/dist/src/mcp/arguments.js +32 -9
- package/dist/src/mcp/errors.d.ts +1 -1
- package/dist/src/mcp/graph.d.ts +22 -22
- package/dist/src/mcp/graph.js +53 -46
- package/dist/src/mcp/reference.d.ts +29 -1
- package/dist/src/mcp/reference.js +350 -222
- package/dist/src/mcp/server.d.ts +9 -0
- package/dist/src/mcp/server.js +169 -107
- package/dist/src/mutate/apply.d.ts +6 -6
- package/dist/src/mutate/apply.js +1 -1
- package/dist/src/mutate/canonical.d.ts +1 -1
- package/dist/src/mutate/canonical.js +2 -2
- package/dist/src/mutate/commit.d.ts +3 -3
- package/dist/src/mutate/commit.js +4 -4
- package/dist/src/mutate/docs.d.ts +1 -1
- package/dist/src/mutate/docs.js +8 -8
- package/dist/src/mutate/effects.d.ts +17 -17
- package/dist/src/mutate/effects.js +113 -113
- package/dist/src/mutate/macros.d.ts +5 -5
- package/dist/src/mutate/macros.js +1 -1
- package/dist/src/mutate/materialize.js +2 -2
- package/dist/src/mutate/ops.js +2 -2
- package/dist/src/mutate/opset.d.ts +7 -7
- package/dist/src/mutate/plan-update.js +2 -2
- package/dist/src/mutate/plan.d.ts +8 -8
- package/dist/src/mutate/plan.js +25 -25
- package/dist/src/mutate/select.d.ts +4 -4
- package/dist/src/mutate/select.js +52 -52
- package/dist/src/mutate/sugar.d.ts +10 -10
- package/dist/src/mutate/sugar.js +21 -21
- package/dist/src/oqx-js/context.d.ts +8 -4
- package/dist/src/oqx-js/context.js +206 -189
- package/dist/src/oqx-js/names.d.ts +28 -17
- package/dist/src/oqx-js/names.js +115 -78
- package/dist/src/oqx-js/planner.d.ts +4 -8
- package/dist/src/oqx-js/planner.js +6 -10
- package/dist/src/oqx-js/root-row.d.ts +6 -5
- package/dist/src/oqx-js/root-row.js +15 -16
- package/dist/src/oqx-js/run.d.ts +18 -17
- package/dist/src/oqx-js/run.js +57 -54
- package/dist/src/oqx-js/sql/translate.d.ts +5 -5
- package/dist/src/oqx-js/sql/translate.js +162 -161
- package/dist/src/oqx-js/store-index.d.ts +1 -1
- package/dist/src/oqx-js/store-index.js +28 -30
- package/dist/src/search/resolve.d.ts +2 -2
- package/dist/src/search/resolve.js +1 -1
- package/dist/src/search/rrf.js +2 -2
- package/dist/src/search/text.d.ts +5 -5
- package/dist/src/search/text.js +2 -2
- package/dist/src/spec-versions.d.ts +6 -6
- package/dist/src/spec-versions.js +6 -6
- package/dist/src/surface-paths.d.ts +18 -17
- package/dist/src/surface-paths.js +23 -21
- package/dist/src/sync/admin.d.ts +2 -2
- package/dist/src/sync/admin.js +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Store } from "../core/store/store.js";
|
|
2
|
-
/** A resolve hit (spec/search §4): the block's `
|
|
2
|
+
/** A resolve hit (spec/search §4): the block's `_id` (spec/surface §1.2, 5.0),
|
|
3
3
|
* its `locator`, a `preview` and the fusion `evidence`. */
|
|
4
4
|
export interface ResolveHit {
|
|
5
|
-
|
|
5
|
+
_id: string;
|
|
6
6
|
locator: string;
|
|
7
7
|
preview: string;
|
|
8
8
|
evidence: unknown;
|
|
@@ -18,6 +18,6 @@ export function resolve(store, input) {
|
|
|
18
18
|
if (input.vector)
|
|
19
19
|
hi.vector = input.vector;
|
|
20
20
|
const hits = hybridSearch(store, hi);
|
|
21
|
-
return hits.map((h) => ({
|
|
21
|
+
return hits.map((h) => ({ _id: h.blockId, locator: locatorFor(store, h.blockId), preview: previewFor(store, h.blockId), evidence: h.evidence }));
|
|
22
22
|
}
|
|
23
23
|
//# sourceMappingURL=resolve.js.map
|
package/dist/src/search/rrf.js
CHANGED
|
@@ -43,8 +43,8 @@ export function hybridSearch(store, input) {
|
|
|
43
43
|
const ftsRanks = new Map();
|
|
44
44
|
if (input.text) {
|
|
45
45
|
textSearch(store, input.repoId, input.text, { limit: 200 }).hits.forEach((h, i) => {
|
|
46
|
-
if (!ftsRanks.has(h.
|
|
47
|
-
ftsRanks.set(h.
|
|
46
|
+
if (!ftsRanks.has(h._id))
|
|
47
|
+
ftsRanks.set(h._id, i + 1);
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
const vecRanks = new Map();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Store } from "../core/store/store.js";
|
|
2
2
|
export interface TextHit {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
_id: string;
|
|
4
|
+
_doc_id: string;
|
|
5
|
+
_path: string;
|
|
6
|
+
_type: string;
|
|
7
|
+
_text: string;
|
|
8
8
|
score: number;
|
|
9
9
|
}
|
|
10
10
|
export interface TextSearchResult {
|
package/dist/src/search/text.js
CHANGED
|
@@ -5,8 +5,8 @@ export function textSearch(store, repoId, queryStr, opts = {}) {
|
|
|
5
5
|
if (match === "")
|
|
6
6
|
return { hits: [], truncated: false };
|
|
7
7
|
const rows = store.db
|
|
8
|
-
.prepare(`SELECT b.block_id AS "
|
|
9
|
-
b.text AS
|
|
8
|
+
.prepare(`SELECT b.block_id AS "_id", b.doc_id AS _doc_id, d.path AS "_path", b.type AS _type,
|
|
9
|
+
b.text AS _text, bm25(blocks_fts) AS score
|
|
10
10
|
FROM blocks_fts
|
|
11
11
|
JOIN blocks b ON b.rowid = blocks_fts.rowid
|
|
12
12
|
JOIN docs d ON d.doc_id = b.doc_id
|
|
@@ -4,11 +4,11 @@ export declare const SPEC_VERSIONS: {
|
|
|
4
4
|
readonly reconcile: "2.3";
|
|
5
5
|
readonly store: "16.0";
|
|
6
6
|
readonly properties: "1.2";
|
|
7
|
-
readonly graph: "
|
|
8
|
-
readonly search: "
|
|
9
|
-
readonly mutate: "
|
|
10
|
-
readonly sync: "
|
|
11
|
-
readonly surface: "
|
|
12
|
-
readonly cli: "
|
|
7
|
+
readonly graph: "2.0";
|
|
8
|
+
readonly search: "3.0";
|
|
9
|
+
readonly mutate: "4.0";
|
|
10
|
+
readonly sync: "3.0";
|
|
11
|
+
readonly surface: "5.1";
|
|
12
|
+
readonly cli: "5.0";
|
|
13
13
|
};
|
|
14
14
|
export type SpecName = keyof typeof SPEC_VERSIONS;
|
|
@@ -15,11 +15,11 @@ export const SPEC_VERSIONS = {
|
|
|
15
15
|
reconcile: "2.3",
|
|
16
16
|
store: "16.0",
|
|
17
17
|
properties: "1.2",
|
|
18
|
-
graph: "
|
|
19
|
-
search: "
|
|
20
|
-
mutate: "
|
|
21
|
-
sync: "
|
|
22
|
-
surface: "
|
|
23
|
-
cli: "
|
|
18
|
+
graph: "2.0",
|
|
19
|
+
search: "3.0",
|
|
20
|
+
mutate: "4.0",
|
|
21
|
+
sync: "3.0",
|
|
22
|
+
surface: "5.1",
|
|
23
|
+
cli: "5.0",
|
|
24
24
|
};
|
|
25
25
|
//# sourceMappingURL=spec-versions.js.map
|
|
@@ -6,40 +6,41 @@ import type { ObserveResult, ObserveDeleteResult } from "./sync/observe.js";
|
|
|
6
6
|
import type { SweepResult } from "./sync/freshness.js";
|
|
7
7
|
import type { TextSearchResult } from "./search/text.js";
|
|
8
8
|
import type { ResolveHit } from "./search/resolve.js";
|
|
9
|
-
/** `spec/mutate` §4's kernel result (the library's `apply`; no tool returns it since 4.0): `revisions[].
|
|
9
|
+
/** `spec/mutate` §4's kernel result (the library's `apply`; no tool returns it since 4.0): `revisions[]._path` and the dry-run `diffs` keys. */
|
|
10
10
|
export declare function surfaceApplyResult<T extends ApplyResult>(res: T): T;
|
|
11
11
|
/** An inbound link on the wire (`docs_move.dangling[]`, `omg mv`): a link row
|
|
12
|
-
* under the `links` target's names (spec/surface §1.2) — `
|
|
13
|
-
* (rooted), `
|
|
12
|
+
* under the `links` target's names (spec/surface §1.2, 5.0) — `_doc_id`,
|
|
13
|
+
* `_path` (rooted), `_block_id`, `target` (as authored; a role), `_anchor`,
|
|
14
|
+
* `_field?`. */
|
|
14
15
|
export interface SurfaceInboundLink {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
_doc_id: string;
|
|
17
|
+
_path: string;
|
|
18
|
+
_block_id: string | null;
|
|
18
19
|
target: string;
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
_anchor: string | null;
|
|
21
|
+
_field?: string;
|
|
21
22
|
}
|
|
22
23
|
export declare function surfaceInboundLink(l: InboundLink): SurfaceInboundLink;
|
|
23
|
-
/** An observe outcome on the wire (spec/surface §4,
|
|
24
|
+
/** An observe outcome on the wire (spec/surface §4, 5.0): `spec/store` §5's
|
|
24
25
|
* `{ docId, path, … }` (unchanged there) renamed to the document's row
|
|
25
|
-
* attributes `
|
|
26
|
+
* attributes `_id`/`_path`, the path rooted. */
|
|
26
27
|
export type SurfaceObserveResult<T extends {
|
|
27
28
|
docId: string | null;
|
|
28
29
|
path: string;
|
|
29
30
|
}> = Omit<T, "docId" | "path"> & {
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
_id: T["docId"];
|
|
32
|
+
_path: string;
|
|
32
33
|
};
|
|
33
34
|
/** `observe` / `observe_many` outcomes. */
|
|
34
35
|
export declare function surfaceObserveResult<T extends ObserveResult>(res: T): SurfaceObserveResult<T>;
|
|
35
36
|
/** `observe_delete`. */
|
|
36
37
|
export declare function surfaceObserveDeleteResult(res: ObserveDeleteResult): SurfaceObserveResult<ObserveDeleteResult>;
|
|
37
|
-
/** `blocks_search` hits (`
|
|
38
|
+
/** `blocks_search` hits (`_path` rooted). */
|
|
38
39
|
export declare function surfaceTextSearch(res: TextSearchResult): TextSearchResult;
|
|
39
40
|
/** `resolve` hits: the locator is `<path>#<type>[<ordinal>]`; its path half is
|
|
40
41
|
* rooted (a locator without `#` names no path and is left alone). */
|
|
41
42
|
export declare function surfaceResolveHits(hits: ResolveHit[]): ResolveHit[];
|
|
42
|
-
/** `links_retarget` / `links_repair` hits (`
|
|
43
|
+
/** `links_retarget` / `links_repair` hits (`_path` is the block's document). */
|
|
43
44
|
export declare function surfaceRetargetHits(hits: RetargetHit[]): RetargetHit[];
|
|
44
45
|
/**
|
|
45
46
|
* A Plan on the wire (spec/surface §4, 3.1): the executable core — `effects`,
|
|
@@ -47,11 +48,11 @@ export declare function surfaceRetargetHits(hits: RetargetHit[]): RetargetHit[];
|
|
|
47
48
|
* storage form, because `plan_id` digests exactly those bytes and the client
|
|
48
49
|
* hands the object back to `execute` (spec/mutate §11.5; the one result the
|
|
49
50
|
* path rule exempts, like `dangling[].target`). Only the un-digested `preview`
|
|
50
|
-
* is rooted: its `revisions[].
|
|
51
|
-
* (
|
|
51
|
+
* is rooted: its `revisions[]._path`, `diffs` keys and `retarget[].hits[]._path`
|
|
52
|
+
* (`identity` is keyed by document id and carries no path).
|
|
52
53
|
*/
|
|
53
54
|
export declare function surfacePlan(plan: Plan): Plan;
|
|
54
|
-
/** A Receipt on the wire: `revisions[].
|
|
55
|
+
/** A Receipt on the wire: `revisions[]._path` rooted (the same shape as an apply revision). */
|
|
55
56
|
export declare function surfaceReceipt(receipt: Receipt): Receipt;
|
|
56
57
|
/** `omg sync`'s one-shot sweep: the ingested / suppressed / deleted / conflicted paths. */
|
|
57
58
|
export declare function surfaceSweepResult(res: SweepResult): SweepResult;
|
|
@@ -8,41 +8,43 @@
|
|
|
8
8
|
// `spec/sync`'s sweep — keep their storage-form paths in the library (their
|
|
9
9
|
// own fixtures pin them) and are re-shaped HERE.
|
|
10
10
|
//
|
|
11
|
-
// Row names (spec/surface §1.2,
|
|
12
|
-
// or
|
|
13
|
-
// `
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
11
|
+
// Row names (spec/surface §1.2, 5.0 "underscore = engine"): a result that
|
|
12
|
+
// renders a document, block or link row spells it the way the query binding
|
|
13
|
+
// does — `_id`, `_path`, `_hash`, `_raw`, `_updated_at`, the foreign keys
|
|
14
|
+
// `_doc_id`/`_block_id`; a key naming a ROLE (`rev`, `target`, `locator`,
|
|
15
|
+
// `commitId`, `oldRaw`/`newRaw`) keeps its name. The shapes other specs own
|
|
16
|
+
// under their own names — `spec/store`'s observe outcome, a move's dangling
|
|
17
|
+
// inbound links — are re-shaped HERE too (`SurfaceObserveResult`,
|
|
18
|
+
// `surfaceInboundLink`, …).
|
|
17
19
|
//
|
|
18
20
|
// Both the MCP server and the `omg` verbs call these, so the two clients
|
|
19
21
|
// cannot drift. Each function returns a new value; the input is not mutated.
|
|
20
22
|
import { referencePath, referenceKeyed } from "./core/paths.js";
|
|
21
|
-
/** `spec/mutate` §4's kernel result (the library's `apply`; no tool returns it since 4.0): `revisions[].
|
|
23
|
+
/** `spec/mutate` §4's kernel result (the library's `apply`; no tool returns it since 4.0): `revisions[]._path` and the dry-run `diffs` keys. */
|
|
22
24
|
export function surfaceApplyResult(res) {
|
|
23
25
|
return {
|
|
24
26
|
...res,
|
|
25
|
-
revisions: res.revisions.map((r) => ({ ...r,
|
|
27
|
+
revisions: res.revisions.map((r) => ({ ...r, _path: referencePath(r._path) })),
|
|
26
28
|
...(res.diffs ? { diffs: referenceKeyed(res.diffs) } : {}),
|
|
27
29
|
};
|
|
28
30
|
}
|
|
29
31
|
export function surfaceInboundLink(l) {
|
|
30
|
-
const {
|
|
31
|
-
return {
|
|
32
|
+
const { _path, ...rest } = l;
|
|
33
|
+
return { _doc_id: rest._doc_id, _path: referencePath(_path), _block_id: rest._block_id, target: rest.target, _anchor: rest._anchor, ...(rest._field !== undefined ? { _field: rest._field } : {}) };
|
|
32
34
|
}
|
|
33
35
|
/** `observe` / `observe_many` outcomes. */
|
|
34
36
|
export function surfaceObserveResult(res) {
|
|
35
37
|
const { docId, path, ...rest } = res;
|
|
36
|
-
return {
|
|
38
|
+
return { _id: docId, _path: referencePath(path), ...rest };
|
|
37
39
|
}
|
|
38
40
|
/** `observe_delete`. */
|
|
39
41
|
export function surfaceObserveDeleteResult(res) {
|
|
40
42
|
const { docId, path, ...rest } = res;
|
|
41
|
-
return {
|
|
43
|
+
return { _id: docId, _path: referencePath(path), ...rest };
|
|
42
44
|
}
|
|
43
|
-
/** `blocks_search` hits (`
|
|
45
|
+
/** `blocks_search` hits (`_path` rooted). */
|
|
44
46
|
export function surfaceTextSearch(res) {
|
|
45
|
-
return { ...res, hits: res.hits.map((h) => ({ ...h,
|
|
47
|
+
return { ...res, hits: res.hits.map((h) => ({ ...h, _path: referencePath(h._path) })) };
|
|
46
48
|
}
|
|
47
49
|
/** `resolve` hits: the locator is `<path>#<type>[<ordinal>]`; its path half is
|
|
48
50
|
* rooted (a locator without `#` names no path and is left alone). */
|
|
@@ -52,9 +54,9 @@ export function surfaceResolveHits(hits) {
|
|
|
52
54
|
return i < 0 ? h : { ...h, locator: referencePath(h.locator.slice(0, i)) + h.locator.slice(i) };
|
|
53
55
|
});
|
|
54
56
|
}
|
|
55
|
-
/** `links_retarget` / `links_repair` hits (`
|
|
57
|
+
/** `links_retarget` / `links_repair` hits (`_path` is the block's document). */
|
|
56
58
|
export function surfaceRetargetHits(hits) {
|
|
57
|
-
return hits.map((h) => ({ ...h,
|
|
59
|
+
return hits.map((h) => ({ ...h, _path: referencePath(h._path) }));
|
|
58
60
|
}
|
|
59
61
|
/**
|
|
60
62
|
* A Plan on the wire (spec/surface §4, 3.1): the executable core — `effects`,
|
|
@@ -62,8 +64,8 @@ export function surfaceRetargetHits(hits) {
|
|
|
62
64
|
* storage form, because `plan_id` digests exactly those bytes and the client
|
|
63
65
|
* hands the object back to `execute` (spec/mutate §11.5; the one result the
|
|
64
66
|
* path rule exempts, like `dangling[].target`). Only the un-digested `preview`
|
|
65
|
-
* is rooted: its `revisions[].
|
|
66
|
-
* (
|
|
67
|
+
* is rooted: its `revisions[]._path`, `diffs` keys and `retarget[].hits[]._path`
|
|
68
|
+
* (`identity` is keyed by document id and carries no path).
|
|
67
69
|
*/
|
|
68
70
|
export function surfacePlan(plan) {
|
|
69
71
|
if (!plan.preview)
|
|
@@ -72,15 +74,15 @@ export function surfacePlan(plan) {
|
|
|
72
74
|
...plan,
|
|
73
75
|
preview: {
|
|
74
76
|
...plan.preview,
|
|
75
|
-
revisions: plan.preview.revisions.map((r) => ({ ...r,
|
|
77
|
+
revisions: plan.preview.revisions.map((r) => ({ ...r, _path: referencePath(r._path) })),
|
|
76
78
|
diffs: referenceKeyed(plan.preview.diffs),
|
|
77
79
|
...(plan.preview.retarget !== undefined ? { retarget: plan.preview.retarget.map((r) => ({ ...r, hits: surfaceRetargetHits(r.hits) })) } : {}),
|
|
78
80
|
},
|
|
79
81
|
};
|
|
80
82
|
}
|
|
81
|
-
/** A Receipt on the wire: `revisions[].
|
|
83
|
+
/** A Receipt on the wire: `revisions[]._path` rooted (the same shape as an apply revision). */
|
|
82
84
|
export function surfaceReceipt(receipt) {
|
|
83
|
-
return { ...receipt, revisions: receipt.revisions.map((r) => ({ ...r,
|
|
85
|
+
return { ...receipt, revisions: receipt.revisions.map((r) => ({ ...r, _path: referencePath(r._path) })) };
|
|
84
86
|
}
|
|
85
87
|
/** `omg sync`'s one-shot sweep: the ingested / suppressed / deleted / conflicted paths. */
|
|
86
88
|
export function surfaceSweepResult(res) {
|
package/dist/src/sync/admin.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ export interface DiskStatus extends DiskDrift {
|
|
|
10
10
|
checked: boolean;
|
|
11
11
|
}
|
|
12
12
|
export interface RepoStatus {
|
|
13
|
-
/** the repository's own id (spec/surface §1.2,
|
|
14
|
-
|
|
13
|
+
/** the repository's own id (spec/surface §1.2, 5.0: the root row's `_id`) */
|
|
14
|
+
_id: string;
|
|
15
15
|
slug: string;
|
|
16
16
|
rootPath: string;
|
|
17
17
|
docs: number;
|
package/dist/src/sync/admin.js
CHANGED
|
@@ -18,7 +18,7 @@ export function reposStatus(store, repoId, rootPath) {
|
|
|
18
18
|
? { ...detectDiskDrift(store, repoId, rootPath), checked: true }
|
|
19
19
|
: { changed: 0, deleted: 0, untracked: 0, checked: false };
|
|
20
20
|
return {
|
|
21
|
-
|
|
21
|
+
_id: repoId,
|
|
22
22
|
slug: repo?.slug ?? "",
|
|
23
23
|
rootPath: rootPath ?? "",
|
|
24
24
|
docs: count("SELECT count(*) c FROM docs WHERE repo_id = ? AND deleted_commit IS NULL"),
|