omgbase 0.2.0 → 0.3.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/cmd/_mutate.js +2 -19
- package/dist/src/cmd/mcp.js +38 -2
- package/package.json +3 -3
package/dist/src/cmd/_mutate.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync, readSync } from "node:fs";
|
|
2
2
|
import { userInfo } from "node:os";
|
|
3
|
-
import { apply } from "@omgbase/core";
|
|
3
|
+
import { apply, unifiedDiff } from "@omgbase/core";
|
|
4
4
|
import { CliUsageError, EXIT_OK, EXIT_ERROR } from "../output.js";
|
|
5
5
|
import { remoteCall } from "./_remote.js";
|
|
6
6
|
// Shared plumbing for every write command (11 §5.6, §5.7). Sugar commands build
|
|
@@ -166,7 +166,7 @@ function renderDryRun(cli, result) {
|
|
|
166
166
|
io.err(style.dim(` dry run — ${Object.keys(result.diffs ?? {}).length} file(s) would change, nothing committed`));
|
|
167
167
|
for (const [path, { before, after }] of Object.entries(result.diffs ?? {})) {
|
|
168
168
|
io.out(`${style.bold(path)}`);
|
|
169
|
-
for (const line of unifiedDiff(before, after)) {
|
|
169
|
+
for (const line of unifiedDiff(before, after).split("\n")) {
|
|
170
170
|
if (line.startsWith("+"))
|
|
171
171
|
io.out(style.ok(line));
|
|
172
172
|
else if (line.startsWith("-"))
|
|
@@ -190,22 +190,5 @@ function renderCommitted(cli, result) {
|
|
|
190
190
|
io.out(id);
|
|
191
191
|
return EXIT_OK;
|
|
192
192
|
}
|
|
193
|
-
// Minimal line-based unified diff (matches the engine's diffUnified style; a
|
|
194
|
-
// full Myers isn't needed for a human preview).
|
|
195
|
-
function unifiedDiff(before, after) {
|
|
196
|
-
const a = before.split("\n");
|
|
197
|
-
const b = after.split("\n");
|
|
198
|
-
const out = [];
|
|
199
|
-
const max = Math.max(a.length, b.length);
|
|
200
|
-
for (let i = 0; i < max; i++) {
|
|
201
|
-
if (a[i] === b[i])
|
|
202
|
-
continue;
|
|
203
|
-
if (a[i] !== undefined)
|
|
204
|
-
out.push(`- ${a[i]}`);
|
|
205
|
-
if (b[i] !== undefined)
|
|
206
|
-
out.push(`+ ${b[i]}`);
|
|
207
|
-
}
|
|
208
|
-
return out;
|
|
209
|
-
}
|
|
210
193
|
export { EXIT_OK, EXIT_ERROR };
|
|
211
194
|
//# sourceMappingURL=_mutate.js.map
|
package/dist/src/cmd/mcp.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseArgs } from "node:util";
|
|
2
|
-
import { serveStdio, Watcher, WatchLease, watchLeaseLive, freshnessSweep, EmbedDrainer, EngineError } from "@omgbase/core";
|
|
3
|
-
import { EngineErrorLike, EXIT_OK, renderHelp } from "../output.js";
|
|
2
|
+
import { serveStdio, Watcher, WatchLease, watchLeaseLive, freshnessSweep, EmbedDrainer, EngineError, pinClock, sequentialMinter, setIdMinter } from "@omgbase/core";
|
|
3
|
+
import { CliUsageError, EngineErrorLike, EXIT_OK, renderHelp } from "../output.js";
|
|
4
4
|
import { loadEmbedding } from "./_embed.js";
|
|
5
5
|
import { openRepoSource } from "./_source.js";
|
|
6
6
|
// `omg mcp [--no-watch]` (11 §5.8) — MCP server on stdio; the host owns the
|
|
@@ -10,6 +10,41 @@ import { openRepoSource } from "./_source.js";
|
|
|
10
10
|
//
|
|
11
11
|
// CRITICAL: on stdio, stdout is the MCP protocol channel. Nothing may write to
|
|
12
12
|
// stdout here — every diagnostic goes to stderr (cli.io.err).
|
|
13
|
+
/**
|
|
14
|
+
* The two conformance seams of spec/surface §7.1, read from the environment
|
|
15
|
+
* BEFORE the workspace opens (so no id is minted and no timestamp read without
|
|
16
|
+
* them). For conformance runs only — never set in production:
|
|
17
|
+
*
|
|
18
|
+
* OMGBASE_SPEC_MINTER=sequential the fixture minter of spec/store §2.2 for
|
|
19
|
+
* the whole process (`d_0, d_1, …`, each
|
|
20
|
+
* prefix from 0); any other value is a
|
|
21
|
+
* startup error
|
|
22
|
+
* OMGBASE_SPEC_CLOCK=<RFC 3339> "now" is that instant for the whole
|
|
23
|
+
* process: every commit a tool stamps, every
|
|
24
|
+
* `ts` reported as current
|
|
25
|
+
*
|
|
26
|
+
* Both are announced on stderr (stdout is the protocol channel).
|
|
27
|
+
*/
|
|
28
|
+
function installSpecSeams(cli) {
|
|
29
|
+
const minter = process.env.OMGBASE_SPEC_MINTER;
|
|
30
|
+
if (minter !== undefined && minter !== "") {
|
|
31
|
+
if (minter !== "sequential") {
|
|
32
|
+
throw new CliUsageError(`OMGBASE_SPEC_MINTER=${JSON.stringify(minter)}: the only value is "sequential" (spec/surface §7.1)`, "unset it, or set OMGBASE_SPEC_MINTER=sequential for a conformance run");
|
|
33
|
+
}
|
|
34
|
+
setIdMinter(sequentialMinter());
|
|
35
|
+
cli.io.err(cli.style.dim("[mcp] spec seam: sequential id minter (OMGBASE_SPEC_MINTER=sequential) — conformance run, not for production"));
|
|
36
|
+
}
|
|
37
|
+
const clock = process.env.OMGBASE_SPEC_CLOCK;
|
|
38
|
+
if (clock !== undefined && clock !== "") {
|
|
39
|
+
try {
|
|
40
|
+
pinClock(clock);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
throw new CliUsageError(`OMGBASE_SPEC_CLOCK=${JSON.stringify(clock)}: not an RFC 3339 instant (spec/surface §7.1)`, "e.g. OMGBASE_SPEC_CLOCK=2026-09-27T00:00:00.000Z");
|
|
44
|
+
}
|
|
45
|
+
cli.io.err(cli.style.dim(`[mcp] spec seam: clock pinned to ${new Date().toISOString()} (OMGBASE_SPEC_CLOCK) — conformance run, not for production`));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
13
48
|
async function runMcp(cli, args) {
|
|
14
49
|
const { values } = parseArgs({
|
|
15
50
|
args,
|
|
@@ -29,6 +64,7 @@ async function runMcp(cli, args) {
|
|
|
29
64
|
notes: [`host config: {"command": "${cli.prog}", "args": ["mcp", "-C", "/path/to/notes"]}`],
|
|
30
65
|
});
|
|
31
66
|
}
|
|
67
|
+
installSpecSeams(cli);
|
|
32
68
|
// The host launches us from its own cwd, so a missing workspace here almost
|
|
33
69
|
// always means the host config lacks `-C <dir>` — say so, rather than the
|
|
34
70
|
// generic "run init" hint (which would create an empty workspace in the wrong place).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omgbase",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Open Markdown Graph Base — CLI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"omg": "./dist/src/main.js"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@omgbase/core": "^0.
|
|
48
|
+
"@omgbase/core": "^0.3.0",
|
|
49
49
|
"@omgbase/fs-adapter": "^0.1.0",
|
|
50
|
-
"@omgbase/sync": "^0.
|
|
50
|
+
"@omgbase/sync": "^0.3.0",
|
|
51
51
|
"yaml": "^2.9.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|