@omgbase/core 0.11.0 → 0.15.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 (62) hide show
  1. package/README.md +1 -1
  2. package/dist/src/core/ids.d.ts +4 -0
  3. package/dist/src/core/ids.js +17 -0
  4. package/dist/src/core/ingest.d.ts +39 -3
  5. package/dist/src/core/ingest.js +233 -202
  6. package/dist/src/core/store/schema.d.ts +3 -2
  7. package/dist/src/core/store/schema.js +28 -3
  8. package/dist/src/core/store/store.d.ts +9 -0
  9. package/dist/src/core/store/store.js +11 -0
  10. package/dist/src/graph/history.js +15 -12
  11. package/dist/src/index.d.ts +9 -5
  12. package/dist/src/index.js +14 -7
  13. package/dist/src/mcp/arguments.d.ts +9 -2
  14. package/dist/src/mcp/arguments.js +15 -2
  15. package/dist/src/mcp/errors.d.ts +1 -1
  16. package/dist/src/mcp/errors.js +3 -0
  17. package/dist/src/mcp/reference.d.ts +1 -1
  18. package/dist/src/mcp/reference.js +9 -9
  19. package/dist/src/mcp/server.d.ts +22 -0
  20. package/dist/src/mcp/server.js +263 -186
  21. package/dist/src/mutate/apply.d.ts +93 -12
  22. package/dist/src/mutate/apply.js +203 -113
  23. package/dist/src/mutate/commit.d.ts +150 -0
  24. package/dist/src/mutate/commit.js +349 -0
  25. package/dist/src/mutate/doc-store.d.ts +3 -3
  26. package/dist/src/mutate/doc-store.js +21 -6
  27. package/dist/src/mutate/docs.d.ts +42 -87
  28. package/dist/src/mutate/docs.js +50 -204
  29. package/dist/src/mutate/effects.d.ts +331 -0
  30. package/dist/src/mutate/effects.js +981 -0
  31. package/dist/src/mutate/materialize.d.ts +49 -0
  32. package/dist/src/mutate/materialize.js +174 -0
  33. package/dist/src/mutate/opset.d.ts +27 -2
  34. package/dist/src/mutate/opset.js +12 -5
  35. package/dist/src/mutate/plan-update.d.ts +1 -46
  36. package/dist/src/mutate/plan-update.js +19 -67
  37. package/dist/src/mutate/plan.d.ts +200 -0
  38. package/dist/src/mutate/plan.js +472 -0
  39. package/dist/src/mutate/sugar.d.ts +135 -0
  40. package/dist/src/mutate/sugar.js +167 -0
  41. package/dist/src/mutate/tree.d.ts +4 -2
  42. package/dist/src/oqx-js/run.js +1 -1
  43. package/dist/src/spec-versions.d.ts +5 -5
  44. package/dist/src/spec-versions.js +5 -5
  45. package/dist/src/surface-paths.d.ts +17 -26
  46. package/dist/src/surface-paths.js +27 -22
  47. package/dist/src/sync/checkpoint.d.ts +5 -2
  48. package/dist/src/sync/checkpoint.js +10 -6
  49. package/dist/src/sync/freshness.d.ts +10 -7
  50. package/dist/src/sync/freshness.js +15 -17
  51. package/dist/src/sync/observe.d.ts +4 -1
  52. package/dist/src/sync/observe.js +56 -5
  53. package/dist/src/sync/recovery.d.ts +4 -0
  54. package/dist/src/sync/recovery.js +4 -1
  55. package/dist/src/sync/stat-cache.d.ts +7 -0
  56. package/dist/src/sync/stat-cache.js +22 -0
  57. package/dist/src/sync/tombstone.js +23 -19
  58. package/dist/src/sync/watcher.d.ts +2 -0
  59. package/dist/src/sync/watcher.js +4 -1
  60. package/dist/src/sync/writer-lock.d.ts +15 -0
  61. package/dist/src/sync/writer-lock.js +104 -17
  62. package/package.json +1 -1
@@ -10,11 +10,11 @@ export const QUERY_SYNTAX = `# query — OQX syntax reference
10
10
  The \`query\` tool takes ONE plain OQX string (+ optional \`limit\`/\`cursor\`). There
11
11
  is no {from, filter, order} envelope: every concern is a clause of the string.
12
12
 
13
- [select <items>] from <target> [where <pred>] [follow <dest> [{ … }], …]
13
+ [select <items>] from <target> [where <pred>] [frontier <pred>] [follow <dest> [{ … }], …]
14
14
  [order by <expr> [asc|desc], …] [limit N] [offset N]
15
15
  <target> count|exists|none|first|single { <block> } (scalar/one-row form: a bare target at the root scope)
16
16
 
17
- CLAUSE ORDER IS FIXED: select, from, where, follow, order by, limit, offset —
17
+ CLAUSE ORDER IS FIXED: select, from, where, frontier, follow, order by, limit, offset —
18
18
  each at most once; an out-of-order clause is a parse error naming the order.
19
19
  Only \`select\` may drop its keyword, and only as the first clause
20
20
  (\`path, era from docs where …\`). A top-level predicate needs \`where\`, because
@@ -270,7 +270,7 @@ links: (the authored link graph as rows — one per open link: the relation a l
270
270
  receiver = a relation (nodes, blocks, doc.out_links, section.blocks, …), a
271
271
  reach-through row (dst, doc: one row — dst { title }), a
272
272
  list property (tags), entries(x), or a root collection (^docs; 0^docs at depth ≥ 2).
273
- block = [select …] [where …] [follow …] [order by …] [limit N] [offset N]
273
+ block = [select …] [where …] [frontier …] [follow …] [order by …] [limit N] [offset N]
274
274
  — the same fixed order as the top level (\`from\` optional; the
275
275
  receiver supplies the rows). A leading name/alias list is the
276
276
  projection (\`select\` dropped); a predicate always needs \`where\`.
@@ -299,7 +299,7 @@ links: (the authored link graph as rows — one per open link: the relation a l
299
299
  raw whole file bytes (docs) — docs_read is cheaper for one doc.
300
300
  distinct select distinct type (dedup hits by projected value)
301
301
  values select <ONE item> values → bare values instead of records:
302
- from docs select distinct type values → values: ["hub","lab-note",…]
302
+ select distinct type values from docs → values: ["hub","lab-note",…]
303
303
  select path values from docs → values: ["/index.md", …]
304
304
  tags: tags collect { $it values } → a plain array
305
305
  h: nodes first { name values where kind == "md:section" order by first_ordinal }
@@ -366,7 +366,7 @@ links: (the authored link graph as rows — one per open link: the relation a l
366
366
  select d: dst.title, k: dst_kind from links the destination document's title
367
367
  from docs where out_links exists { where dst.layer == "draft" } links into drafts
368
368
  select b: in_links collect distinct { from doc } from docs backlinks as { id, path }
369
- from links where predicate == "depends_on" select doc_id, dst_path
369
+ select doc_id, dst_path from links where predicate == "depends_on"
370
370
  from docs where not doc.in_links exists { } orphans (nothing links in)
371
371
  (The \`graph\` tool is a convenience wrapper that compiles to a follow query.)
372
372
 
@@ -379,15 +379,15 @@ text()/where prune the candidate set; only order by reweights.
379
379
 
380
380
  from docs where layer == "working"
381
381
  from docs where path.startsWith("/guides/") and updated_at >= "2026-08-01"
382
- from docs where "pricing" in list(tags) select layer, tags
382
+ select layer, tags from docs where "pricing" in list(tags)
383
383
  from docs where inline.owner == "alice"
384
384
  from docs where title.lower().contains("q3 plan")
385
385
  from docs where format == "yaml"
386
386
  from docs where type == "practitioner" order by era desc limit 2
387
387
  from docs where nodes none { where kind == "md:task" and not checked }
388
388
  from docs where tags exists { where $it == "tria-prima" }
389
- from docs where path == "/x.md" select fm: entries(data) collect { k: $key, v: $it }
390
- from docs select owner_id, owner: ^nodes single { where kind == "person" and attrs.id == ^owner_id }
389
+ select fm: entries(data) collect { k: $key, v: $it } from docs where path == "/x.md"
390
+ select owner_id, owner: ^nodes single { where kind == "person" and attrs.id == ^owner_id } from docs
391
391
  from blocks where type == "task" and not checked and under_heading("Launch") and doc.layer == "working"
392
392
  from blocks where type == "paragraph" and has_edge("references", "d_92aaaaa")
393
393
  select path, $depth from docs where path == "/timeline/review.md" follow refs(before), refs(after)
@@ -399,7 +399,7 @@ text()/where prune the candidate set; only order by reweights.
399
399
  select path, back: nodes first { select p: 0^docs collect { path where ^^path in list(after) } values } from docs where type == "milestone"
400
400
  select path, prior: refs(before) collect { path, when } from docs where type == "milestone"
401
401
  from blocks order by semantic("identity preservation across edits") desc limit 10
402
- from links where dst_kind == "external" select uri
402
+ select uri from links where dst_kind == "external"
403
403
  docs count { where layer == "canon" }
404
404
 
405
405
  Common mistake: \`$path\`/\`$id\` (the 2.x spelling) — omgbase has no $ names; write
@@ -1,5 +1,6 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import type { Store } from "../core/store/store.js";
3
+ import { type WriterLockOptions } from "../sync/writer-lock.js";
3
4
  import { type HostInfo } from "../version.js";
4
5
  export interface ServerContext {
5
6
  store: Store;
@@ -10,6 +11,19 @@ export interface ServerContext {
10
11
  /** Default repo's working-tree root (for mutations that omit `repo`); a
11
12
  * `repo`-scoped call derives the target repo's root from its fs source. */
12
13
  rootPath?: string;
14
+ /**
15
+ * The workspace's `.omgbase/` directory. When set, every write tool
16
+ * (`WRITE_TOOLS`) runs under the workspace writer lock of spec/sync §7 for the
17
+ * whole call — one acquire per tool call, dry runs included — so an `omg`
18
+ * verb, another `omg mcp`, the Rust `omgbase mcp` or a watcher checkpoint
19
+ * sharing the workspace serialize with it (lock scope = write scope on every
20
+ * host). It also reaches the kernel (`ApplyRequest.omgbaseDir`), so the
21
+ * freshness stat cache is kept warm exactly as on the CLI path. Absent (a
22
+ * library embedding over a bare store) ⇒ no lock, no stat cache.
23
+ */
24
+ omgbaseDir?: string;
25
+ /** Lock wait/poll overrides for the tool-boundary lock (default 5 s / 25 ms, the spec's); a test seam. */
26
+ writerLock?: WriterLockOptions;
13
27
  /**
14
28
  * Embed a query string to a vector for semantic search. Absent ⇒ the `query`
15
29
  * tool's `semantic` param yields `provider_unavailable` (no provider). The
@@ -40,6 +54,14 @@ export interface ServerContext {
40
54
  }
41
55
  /** The message every tool uses for a `semantic(...)` call the server cannot rank. */
42
56
  export declare const PROVIDER_UNAVAILABLE_MESSAGE = "semantic(...) needs an embedding provider; none is configured \u2014 set embedding.provider (omg config set embedding.provider <command|url>) and embed the repository (omg embed drain)";
57
+ /**
58
+ * The tools that can commit — the host serializes these under the writer lock
59
+ * of spec/sync §7. The same list as the Rust catalog's `Surface::is_write_tool`
60
+ * (`crates/omgbase-surface/src/catalog.rs`). `plan` is listed too: it reads
61
+ * the documents a write would touch, so a preview waits for a writer exactly as
62
+ * the write would (through 3.x the sugar's `dry_run` played that role).
63
+ */
64
+ export declare const WRITE_TOOLS: ReadonlySet<string>;
43
65
  export declare function buildServer(ctx: ServerContext): McpServer;
44
66
  /** The catalog's tool names in registration order with their descriptions —
45
67
  * what `spec/surface/tool-descriptions.json` pins for both engines. */