@amoree-code/ocean 2.8.0 → 2.9.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/interfaces/cli/help-command.js +1 -1
- package/dist/interfaces/cli/memory-command.js +36 -10
- package/node_modules/@ocean/brain/dist/brain/brain-eval.js +45 -9
- package/node_modules/@ocean/brain/dist/brain/brain-markdown.js +10 -1
- package/node_modules/@ocean/brain/dist/brain/brain-reindex.js +4 -1
- package/node_modules/@ocean/brain/dist/brain/brain-service.js +69 -8
- package/node_modules/@ocean/brain/dist/infrastructure/brain/brain-index.js +5 -3
- package/node_modules/@ocean/brain/package.json +1 -1
- package/node_modules/@ocean/context/package.json +1 -1
- package/node_modules/@ocean/core/dist/domain/ports/brain-index-port.js +3 -2
- package/node_modules/@ocean/core/package.json +1 -1
- package/node_modules/@ocean/loop/package.json +1 -1
- package/node_modules/@ocean/market/package.json +1 -1
- package/node_modules/@ocean/services/dist/infrastructure/mcp/ocean-server.js +18 -0
- package/node_modules/@ocean/services/package.json +1 -1
- package/ocean-marketplace.json +34 -34
- package/package.json +7 -7
|
@@ -138,7 +138,7 @@ export const commandHelp = {
|
|
|
138
138
|
],
|
|
139
139
|
memory: [
|
|
140
140
|
"Search, read, review and maintain memory records and the brain index.",
|
|
141
|
-
"ocean memory doctor|sync [--apply]|review [list|approve <id> [--to <path>]|reject <id>]|eval <questions.json> [--k N] [--min R]|digest|harvest [--source <id>] [--yes]|import-claude <export-dir> [--yes]|history [path] [--limit N]|audit [--client <name>] [--days N] [--limit N] [--json]|restore <id> [--hash <sha256>]|delete <path> --hash <sha256>|purge [--days N] [--yes]|facts <profile> [key] [value]|facts <profile> delete <key>|reindex [--no-vectors]|search <q> [--project <id>|--all] [--json]|read <id|path>|neighbors <id|path> [--depth N] [--project <id>|--all]",
|
|
141
|
+
"ocean memory doctor|sync [--apply]|review [list|approve <id> [--to <path>]|reject <id>]|eval <questions.json|.jsonl> [--k N] [--min R] [--fts]|digest|harvest [--source <id>] [--yes]|import-claude <export-dir> [--yes]|history [path] [--limit N]|audit [--client <name>] [--days N] [--limit N] [--json]|restore <id> [--hash <sha256>]|delete <path> --hash <sha256>|purge [--days N] [--yes]|facts <profile> [key] [value]|facts <profile> delete <key>|reindex [--no-vectors]|search <q> [--project <id>|--all] [--type T] [--since D] [--as-of D] [--fts] [--json]|read <id|path>|neighbors <id|path> [--depth N] [--project <id>|--all]",
|
|
142
142
|
],
|
|
143
143
|
pull: [
|
|
144
144
|
"Pull what AI clients hold into Ocean as review candidates; a dry run until --yes.",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { evaluateRecall, } from "@ocean/brain/brain/brain-eval.js";
|
|
2
|
+
import { evaluateRecall, parseEvalCases, } from "@ocean/brain/brain/brain-eval.js";
|
|
3
3
|
import { brainIndexPath, computeCorpusHash, reindexBrain, } from "@ocean/brain/brain/brain-reindex.js";
|
|
4
4
|
import { brainNeighbors, brainRead, brainSearch, } from "@ocean/brain/brain/brain-service.js";
|
|
5
5
|
import { migrateBrainDumps } from "@ocean/brain/memory/brain-dump.js";
|
|
@@ -35,7 +35,9 @@ async function runReindex(args) {
|
|
|
35
35
|
});
|
|
36
36
|
console.log(JSON.stringify(result, null, 2));
|
|
37
37
|
}
|
|
38
|
-
const searchUsage = "Usage: ocean memory search <query> [--project <id> | --all] [--json]";
|
|
38
|
+
const searchUsage = "Usage: ocean memory search <query> [--project <id> | --all] [--type <type>]... [--since YYYY-MM-DD] [--as-of YYYY-MM-DD] [--fts] [--json]";
|
|
39
|
+
const SEARCH_VALUE_FLAGS = new Set(["--type", "--since", "--as-of"]);
|
|
40
|
+
const isDay = (value) => value === undefined || /^\d{4}-\d{2}-\d{2}$/.test(value);
|
|
39
41
|
const neighborsUsage = "Usage: ocean memory neighbors <id|path> [--depth N] [--project <id> | --all]";
|
|
40
42
|
// --project <id> / --all, shared by search and neighbors. Default: the cwd's project plus
|
|
41
43
|
// global records; --all is the explicit unscoped view. null means the flags are malformed.
|
|
@@ -66,10 +68,23 @@ async function scopeFrom(flags) {
|
|
|
66
68
|
async function runSearch(args) {
|
|
67
69
|
const flags = parseScopeFlags(args);
|
|
68
70
|
const json = args.includes("--json");
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
const rest = flags?.rest ?? [];
|
|
72
|
+
const words = [];
|
|
73
|
+
const types = [];
|
|
74
|
+
for (let index = 0; index < rest.length; index += 1) {
|
|
75
|
+
const arg = rest[index];
|
|
76
|
+
if (SEARCH_VALUE_FLAGS.has(arg)) {
|
|
77
|
+
if (arg === "--type" && rest[index + 1])
|
|
78
|
+
types.push(rest[index + 1]);
|
|
79
|
+
index += 1;
|
|
80
|
+
}
|
|
81
|
+
else if (!arg.startsWith("--"))
|
|
82
|
+
words.push(arg);
|
|
83
|
+
}
|
|
84
|
+
const query = words.join(" ");
|
|
85
|
+
const since = flagValue(rest, "--since");
|
|
86
|
+
const asOf = flagValue(rest, "--as-of");
|
|
87
|
+
if (!flags || !query || !isDay(since) || !isDay(asOf)) {
|
|
73
88
|
console.error(searchUsage);
|
|
74
89
|
process.exitCode = 1;
|
|
75
90
|
return;
|
|
@@ -78,7 +93,14 @@ async function runSearch(args) {
|
|
|
78
93
|
const result = await brainSearch({
|
|
79
94
|
query,
|
|
80
95
|
scope: await scopeFrom(flags),
|
|
96
|
+
types: types.length ? types : undefined,
|
|
97
|
+
since,
|
|
98
|
+
asOf,
|
|
81
99
|
indexPort: defaultBrainIndexPort,
|
|
100
|
+
// Hybrid whenever the local embedder answers (T-321); keyword-only otherwise, or with --fts.
|
|
101
|
+
embedder: rest.includes("--fts")
|
|
102
|
+
? null
|
|
103
|
+
: await createOllamaEmbedder().catch(() => null),
|
|
82
104
|
});
|
|
83
105
|
console.log(json ? JSON.stringify(result) : JSON.stringify(result, null, 2));
|
|
84
106
|
}
|
|
@@ -267,14 +289,18 @@ async function runReview(args) {
|
|
|
267
289
|
async function runEval(args) {
|
|
268
290
|
const file = args.find((arg, index) => !arg.startsWith("--") && !args[index - 1]?.startsWith("--"));
|
|
269
291
|
if (!file) {
|
|
270
|
-
console.error("Usage: ocean memory eval <questions.json> [--k N] [--min 0.9] [--
|
|
292
|
+
console.error("Usage: ocean memory eval <questions.json|.jsonl> [--k N] [--min 0.9] [--fts]");
|
|
271
293
|
process.exitCode = 1;
|
|
272
294
|
return;
|
|
273
295
|
}
|
|
274
|
-
const cases =
|
|
296
|
+
const cases = parseEvalCases(await readFile(file, "utf8"));
|
|
297
|
+
// Same embedder rule as search: vectors when the local model answers, unless --fts pins keyword-only.
|
|
298
|
+
const embedder = args.includes("--fts")
|
|
299
|
+
? null
|
|
300
|
+
: await createOllamaEmbedder().catch(() => null);
|
|
275
301
|
const result = await evaluateRecall(cases, {
|
|
276
302
|
indexPort: defaultBrainIndexPort,
|
|
277
|
-
embedder
|
|
303
|
+
embedder,
|
|
278
304
|
k: Number(flagValue(args, "--k") ?? 5),
|
|
279
305
|
});
|
|
280
306
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -406,7 +432,7 @@ export async function runMemoryCommand(action, args) {
|
|
|
406
432
|
console.log(JSON.stringify({ dryRun: !args.includes("--apply"), stores: result }, null, 2));
|
|
407
433
|
return;
|
|
408
434
|
}
|
|
409
|
-
console.error("Usage: ocean memory doctor|sync [--apply]|review [list|approve <id> [--to <path>]|reject <id>]|eval <questions.json> [--k N] [--min R]|digest|harvest [--source <id>] [--yes]|import-claude <export-dir> [--yes]|history [path] [--limit N]|audit [--client <name>] [--days N] [--limit N] [--json]|restore <id> [--hash <sha256>]|delete <path> --hash <sha256>|purge [--days N] [--yes]|facts <profile> [key] [value]|facts <profile> delete <key>|session-facts [on|off]|reindex [--no-vectors]|search <q> [--project <id>|--all] [--json]|read <id|path>|neighbors <id|path> [--depth N] [--project <id>|--all]");
|
|
435
|
+
console.error("Usage: ocean memory doctor|sync [--apply]|review [list|approve <id> [--to <path>]|reject <id>]|eval <questions.json|.jsonl> [--k N] [--min R] [--fts]|digest|harvest [--source <id>] [--yes]|import-claude <export-dir> [--yes]|history [path] [--limit N]|audit [--client <name>] [--days N] [--limit N] [--json]|restore <id> [--hash <sha256>]|delete <path> --hash <sha256>|purge [--days N] [--yes]|facts <profile> [key] [value]|facts <profile> delete <key>|session-facts [on|off]|reindex [--no-vectors]|search <q> [--project <id>|--all] [--type T] [--since D] [--as-of D] [--fts] [--json]|read <id|path>|neighbors <id|path> [--depth N] [--project <id>|--all]");
|
|
410
436
|
process.exitCode = 1;
|
|
411
437
|
}
|
|
412
438
|
//# sourceMappingURL=memory-command.js.map
|
|
@@ -1,28 +1,64 @@
|
|
|
1
1
|
import { brainSearch } from "./brain-service.js";
|
|
2
|
+
// MRR looks past k so a near miss at rank 6–10 still counts for something.
|
|
3
|
+
const MRR_DEPTH = 10;
|
|
4
|
+
// A JSON array, or JSON Lines (one case per line, blank lines ignored).
|
|
5
|
+
export function parseEvalCases(text) {
|
|
6
|
+
const trimmed = text.trim();
|
|
7
|
+
if (trimmed.startsWith("["))
|
|
8
|
+
return JSON.parse(trimmed);
|
|
9
|
+
return trimmed
|
|
10
|
+
.split("\n")
|
|
11
|
+
.map((line) => line.trim())
|
|
12
|
+
.filter(Boolean)
|
|
13
|
+
.map((line) => JSON.parse(line));
|
|
14
|
+
}
|
|
2
15
|
export async function evaluateRecall(cases, options) {
|
|
3
16
|
const k = options.k ?? 5;
|
|
17
|
+
const depth = Math.max(k, MRR_DEPTH);
|
|
4
18
|
const misses = [];
|
|
19
|
+
let hitsAt1 = 0;
|
|
20
|
+
let reciprocalSum = 0;
|
|
21
|
+
let hybrid = cases.length > 0;
|
|
5
22
|
for (const item of cases) {
|
|
6
23
|
const expect = [item.expect].flat();
|
|
7
|
-
const { results } = await brainSearch({
|
|
24
|
+
const { results, mode } = await brainSearch({
|
|
8
25
|
query: item.question,
|
|
9
|
-
limit:
|
|
26
|
+
limit: depth,
|
|
10
27
|
root: options.root,
|
|
11
28
|
embedder: options.embedder ?? null,
|
|
12
29
|
indexPort: options.indexPort,
|
|
13
30
|
scope: item.project === undefined ? undefined : { project: item.project },
|
|
14
31
|
});
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
32
|
+
if (mode !== "hybrid")
|
|
33
|
+
hybrid = false;
|
|
34
|
+
const rank = results.findIndex((hit) => expect.includes(hit.path) || expect.includes(hit.file)) + 1;
|
|
35
|
+
if (rank === 1)
|
|
36
|
+
hitsAt1 += 1;
|
|
37
|
+
if (rank > 0)
|
|
38
|
+
reciprocalSum += 1 / rank;
|
|
39
|
+
if (rank === 0 || rank > k)
|
|
40
|
+
misses.push({
|
|
41
|
+
question: item.question,
|
|
42
|
+
expect,
|
|
43
|
+
got: results.slice(0, k).map((hit) => hit.file),
|
|
44
|
+
});
|
|
19
45
|
}
|
|
20
|
-
const
|
|
46
|
+
const total = cases.length;
|
|
47
|
+
const hits = total - misses.length;
|
|
48
|
+
const ratio = (value) => total ? Math.round((value / total) * 1000) / 1000 : 0;
|
|
21
49
|
return {
|
|
50
|
+
settings: {
|
|
51
|
+
mode: hybrid ? "hybrid" : "fts",
|
|
52
|
+
embedder: hybrid ? (options.embedder?.model ?? null) : null,
|
|
53
|
+
k,
|
|
54
|
+
depth,
|
|
55
|
+
},
|
|
22
56
|
k,
|
|
23
|
-
total
|
|
57
|
+
total,
|
|
24
58
|
hits,
|
|
25
|
-
recall:
|
|
59
|
+
recall: ratio(hits),
|
|
60
|
+
hitAt1: ratio(hitsAt1),
|
|
61
|
+
mrr: ratio(reciprocalSum),
|
|
26
62
|
misses,
|
|
27
63
|
};
|
|
28
64
|
}
|
|
@@ -117,7 +117,16 @@ export function normalizeRecord(relPath, rawSource) {
|
|
|
117
117
|
? "defaulted"
|
|
118
118
|
: "declared",
|
|
119
119
|
};
|
|
120
|
-
return {
|
|
120
|
+
return {
|
|
121
|
+
record,
|
|
122
|
+
conformance,
|
|
123
|
+
body,
|
|
124
|
+
rawScope: scopeField.value,
|
|
125
|
+
validity: {
|
|
126
|
+
validFrom: fields.valid_from || null,
|
|
127
|
+
supersededBy: fields.superseded_by || null,
|
|
128
|
+
},
|
|
129
|
+
};
|
|
121
130
|
}
|
|
122
131
|
// Extracts `[[target]]`, `[[target|alias]]`, `[[target#heading]]`, ignoring fenced code
|
|
123
132
|
// blocks (``` ... ```) so a documentation example is never mistaken for a real link.
|
|
@@ -119,7 +119,7 @@ export async function reindexBrain(options) {
|
|
|
119
119
|
// A retired record (a superseded lesson or decision) stays on disk but out of search (T-314).
|
|
120
120
|
if (/^status:\s*["']?retired["']?\s*$/m.test(source.split(/\r?\n---/, 1)[0]))
|
|
121
121
|
continue;
|
|
122
|
-
const { record, conformance, body, rawScope } = normalizeRecord(relative, source);
|
|
122
|
+
const { record, conformance, body, rawScope, validity } = normalizeRecord(relative, source);
|
|
123
123
|
const links = extractWikilinks(body).map((link) => ({
|
|
124
124
|
targetRaw: link.target,
|
|
125
125
|
heading: link.heading,
|
|
@@ -131,6 +131,7 @@ export async function reindexBrain(options) {
|
|
|
131
131
|
record,
|
|
132
132
|
conformance,
|
|
133
133
|
rawScope,
|
|
134
|
+
validity,
|
|
134
135
|
body,
|
|
135
136
|
contentHash: createHash("sha256").update(source).digest("hex"),
|
|
136
137
|
bytes: Buffer.byteLength(source, "utf8"),
|
|
@@ -192,6 +193,8 @@ export async function reindexBrain(options) {
|
|
|
192
193
|
created: doc.record.created,
|
|
193
194
|
updated: doc.record.updated,
|
|
194
195
|
lastConfirmedAt: doc.record.lastConfirmedAt,
|
|
196
|
+
validFrom: doc.validity.validFrom,
|
|
197
|
+
supersededBy: doc.validity.supersededBy,
|
|
195
198
|
contentHash: doc.contentHash,
|
|
196
199
|
bytes: doc.bytes,
|
|
197
200
|
conformance: doc.conformance,
|
|
@@ -11,12 +11,60 @@ export class BrainIndexStaleError extends Error {
|
|
|
11
11
|
}
|
|
12
12
|
function assertScoped(reader) {
|
|
13
13
|
if (reader.meta.schemaVersion !== BRAIN_INDEX_SCHEMA_VERSION)
|
|
14
|
-
throw new BrainIndexStaleError(`brain index schema ${reader.meta.schemaVersion}
|
|
14
|
+
throw new BrainIndexStaleError(`brain index schema ${reader.meta.schemaVersion} is older than ${BRAIN_INDEX_SCHEMA_VERSION} — run \`ocean memory reindex\``);
|
|
15
15
|
}
|
|
16
16
|
const RRF_K = 60;
|
|
17
17
|
// The owner's own notes outrank what agents wrote on the same question (T-314).
|
|
18
18
|
const HUMAN_BOOST = 1.5;
|
|
19
19
|
const isHumanNote = (storePath) => storePath.startsWith("notes/");
|
|
20
|
+
// Rank adjustments (T-321), multiplied into the fused score. RRF scores sit close together, so
|
|
21
|
+
// these are nudges, not overrides. Tuned on the owner's 40-question eval (hybrid hit@5 0.825 →
|
|
22
|
+
// 0.90): a recency boost was tried and lowered both modes, so recency is the `since` filter only.
|
|
23
|
+
const RANK = {
|
|
24
|
+
decision: 1.05, // a decision answers "what did we decide" better than the talk around it
|
|
25
|
+
session: 0.6, // a raw session log loses to the curated record distilled from it
|
|
26
|
+
lowConfidence: 0.8, // confidence: low (COG memory hygiene, C1)
|
|
27
|
+
unverified: 0.9, // last confirmed more than STALE_DAYS ago
|
|
28
|
+
superseded: 0.5, // replaced by a newer record; still findable, never first
|
|
29
|
+
};
|
|
30
|
+
const STALE_DAYS = 180;
|
|
31
|
+
const DAY_MS = 86_400_000;
|
|
32
|
+
const text = (value) => typeof value === "string" && value ? value : null;
|
|
33
|
+
// Dates in frontmatter are YYYY-MM-DD, possibly with a time; the day is what is compared.
|
|
34
|
+
const dayOf = (value) => text(value)?.match(/^\d{4}-\d{2}-\d{2}/)?.[0] ?? null;
|
|
35
|
+
const daysBetween = (from, to) => (to.getTime() - Date.parse(`${from}T00:00:00Z`)) / DAY_MS;
|
|
36
|
+
const docDate = (doc) => dayOf(doc.updated) ?? dayOf(doc.last_confirmed_at) ?? dayOf(doc.created);
|
|
37
|
+
// When a record starts to hold: its declared valid_from, else when it was written.
|
|
38
|
+
const startOf = (doc) => dayOf(doc.valid_from) ?? dayOf(doc.created) ?? dayOf(doc.updated);
|
|
39
|
+
// Whether the fact a record states held on `asOf`: it had started, and whatever replaced it had
|
|
40
|
+
// not. A successor with no date, or one the index cannot resolve, counts as already in force.
|
|
41
|
+
function validOn(doc, asOf, successor) {
|
|
42
|
+
const start = startOf(doc);
|
|
43
|
+
if (start && start > asOf)
|
|
44
|
+
return false;
|
|
45
|
+
const replacedBy = text(doc.superseded_by);
|
|
46
|
+
if (!replacedBy)
|
|
47
|
+
return true;
|
|
48
|
+
const next = successor(replacedBy);
|
|
49
|
+
const nextStart = next ? startOf(next) : null;
|
|
50
|
+
return nextStart !== null && nextStart > asOf;
|
|
51
|
+
}
|
|
52
|
+
function rankFactor(doc, now, asOf) {
|
|
53
|
+
let factor = isHumanNote(String(doc.path ?? "")) ? HUMAN_BOOST : 1;
|
|
54
|
+
if (doc.type === "decision")
|
|
55
|
+
factor *= RANK.decision;
|
|
56
|
+
if (doc.type === "session")
|
|
57
|
+
factor *= RANK.session;
|
|
58
|
+
if (String(doc.confidence).toLowerCase() === "low")
|
|
59
|
+
factor *= RANK.lowConfidence;
|
|
60
|
+
const confirmed = dayOf(doc.last_confirmed_at);
|
|
61
|
+
if (confirmed && daysBetween(confirmed, now) > STALE_DAYS)
|
|
62
|
+
factor *= RANK.unverified;
|
|
63
|
+
// As of a past date the filter has already removed what was not yet replaced then.
|
|
64
|
+
if (!asOf && text(doc.superseded_by))
|
|
65
|
+
factor *= RANK.superseded;
|
|
66
|
+
return factor;
|
|
67
|
+
}
|
|
20
68
|
function snippetOf(text, maxLen = 240) {
|
|
21
69
|
const trimmed = text.trim().replace(/\s+/g, " ");
|
|
22
70
|
return trimmed.length > maxLen ? `${trimmed.slice(0, maxLen - 1)}…` : trimmed;
|
|
@@ -98,14 +146,18 @@ export async function brainSearch(options) {
|
|
|
98
146
|
});
|
|
99
147
|
}
|
|
100
148
|
}
|
|
149
|
+
const now = options.now ?? new Date();
|
|
150
|
+
const successor = (ref) => reader.getDocByIdOrPath(ref) ??
|
|
151
|
+
(ref.endsWith(".md") ? undefined : reader.getDocByIdOrPath(`${ref}.md`));
|
|
101
152
|
const ranked = [...byDoc.entries()]
|
|
102
|
-
.map(([docId, entry]) =>
|
|
103
|
-
docId
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
: entry.score,
|
|
108
|
-
|
|
153
|
+
.map(([docId, entry]) => {
|
|
154
|
+
const doc = reader.getDoc(docId);
|
|
155
|
+
return {
|
|
156
|
+
docId,
|
|
157
|
+
...entry,
|
|
158
|
+
score: doc ? entry.score * rankFactor(doc, now, options.asOf) : 0,
|
|
159
|
+
};
|
|
160
|
+
})
|
|
109
161
|
.sort((a, b) => b.score - a.score || a.docId - b.docId);
|
|
110
162
|
const results = [];
|
|
111
163
|
for (const item of ranked) {
|
|
@@ -117,6 +169,13 @@ export async function brainSearch(options) {
|
|
|
117
169
|
continue;
|
|
118
170
|
if (options.types?.length && !options.types.includes(String(doc.type)))
|
|
119
171
|
continue;
|
|
172
|
+
if (options.since) {
|
|
173
|
+
const dated = docDate(doc);
|
|
174
|
+
if (!dated || dated < options.since)
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (options.asOf && !validOn(doc, options.asOf, successor))
|
|
178
|
+
continue;
|
|
120
179
|
// Backstop for hits the SQL filter never saw (vector hits are not scope-filtered).
|
|
121
180
|
if (options.scope &&
|
|
122
181
|
!scopeVisible(String(doc.scope), options.scope.project))
|
|
@@ -133,6 +192,8 @@ export async function brainSearch(options) {
|
|
|
133
192
|
scope: String(doc.scope ?? "global"),
|
|
134
193
|
confidence: String(doc.confidence),
|
|
135
194
|
lastConfirmedAt: doc.last_confirmed_at ?? null,
|
|
195
|
+
validFrom: text(doc.valid_from),
|
|
196
|
+
supersededBy: text(doc.superseded_by),
|
|
136
197
|
heading: chunk ? (chunk.heading ?? null) : null,
|
|
137
198
|
snippet: chunk ? snippetOf(String(chunk.text)) : "",
|
|
138
199
|
score: Math.round(item.score * 1_000_000) / 1_000_000,
|
|
@@ -37,6 +37,8 @@ function createSchema(db, withVectors, dims) {
|
|
|
37
37
|
created TEXT,
|
|
38
38
|
updated TEXT,
|
|
39
39
|
last_confirmed_at TEXT,
|
|
40
|
+
valid_from TEXT,
|
|
41
|
+
superseded_by TEXT,
|
|
40
42
|
content_hash TEXT NOT NULL,
|
|
41
43
|
bytes INTEGER NOT NULL,
|
|
42
44
|
conformance_json TEXT NOT NULL
|
|
@@ -71,8 +73,8 @@ function createSchema(db, withVectors, dims) {
|
|
|
71
73
|
async function populate(db, docs, links, options) {
|
|
72
74
|
const insertDoc = db.prepare(`
|
|
73
75
|
INSERT INTO docs (id, path, title, summary, tags_json, type, scope, confidence, created, updated,
|
|
74
|
-
last_confirmed_at, content_hash, bytes, conformance_json)
|
|
75
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
76
|
+
last_confirmed_at, valid_from, superseded_by, content_hash, bytes, conformance_json)
|
|
77
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
76
78
|
`);
|
|
77
79
|
const insertChunk = db.prepare(`
|
|
78
80
|
INSERT INTO chunks (doc_id, ordinal, heading, text) VALUES (?, ?, ?, ?)
|
|
@@ -91,7 +93,7 @@ async function populate(db, docs, links, options) {
|
|
|
91
93
|
db.exec("BEGIN");
|
|
92
94
|
try {
|
|
93
95
|
for (const doc of docs) {
|
|
94
|
-
insertDoc.run(doc.id, doc.path, doc.title, doc.summary, JSON.stringify(doc.tags), doc.type, doc.scope, doc.confidence, doc.created, doc.updated, doc.lastConfirmedAt, doc.contentHash, doc.bytes, JSON.stringify(doc.conformance));
|
|
96
|
+
insertDoc.run(doc.id, doc.path, doc.title, doc.summary, JSON.stringify(doc.tags), doc.type, doc.scope, doc.confidence, doc.created, doc.updated, doc.lastConfirmedAt, doc.validFrom, doc.supersededBy, doc.contentHash, doc.bytes, JSON.stringify(doc.conformance));
|
|
95
97
|
const docIdRow = db.prepare("SELECT last_insert_rowid() AS id").get();
|
|
96
98
|
const docId = Number(docIdRow.id);
|
|
97
99
|
pathToDocId.set(doc.path, docId);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// concrete node:sqlite + sqlite-vec implementation lives in infrastructure/brain/brain-index.ts
|
|
3
3
|
// and is wired in through composition/runtime.js, never imported directly by application
|
|
4
4
|
// code (enforced by tests/architecture.test.mjs).
|
|
5
|
-
// 2: docs carry a scope.
|
|
6
|
-
|
|
5
|
+
// 2: docs carry a scope. 3: docs carry valid_from and superseded_by (T-321).
|
|
6
|
+
// The index is a disposable cache, so a bump means "reindex", not a migration.
|
|
7
|
+
export const BRAIN_INDEX_SCHEMA_VERSION = "3";
|
|
7
8
|
//# sourceMappingURL=brain-index-port.js.map
|
|
@@ -193,6 +193,14 @@ const tools = new McpToolRegistry(withContextAck([
|
|
|
193
193
|
query: { type: "string" },
|
|
194
194
|
limit: { type: "number" },
|
|
195
195
|
types: { type: "array", items: { type: "string" } },
|
|
196
|
+
since: {
|
|
197
|
+
type: "string",
|
|
198
|
+
description: "YYYY-MM-DD: only records dated on or after it",
|
|
199
|
+
},
|
|
200
|
+
asOf: {
|
|
201
|
+
type: "string",
|
|
202
|
+
description: "YYYY-MM-DD: only facts valid on that day (valid_from / superseded_by)",
|
|
203
|
+
},
|
|
196
204
|
project: { type: "string" },
|
|
197
205
|
cwd: { type: "string" },
|
|
198
206
|
},
|
|
@@ -580,6 +588,8 @@ async function callTool(name, args, ports) {
|
|
|
580
588
|
types: Array.isArray(args.types)
|
|
581
589
|
? args.types.filter((item) => typeof item === "string")
|
|
582
590
|
: undefined,
|
|
591
|
+
since: isoDay(args.since, "since"),
|
|
592
|
+
asOf: isoDay(args.asOf, "asOf"),
|
|
583
593
|
indexPort: ports.brainIndex,
|
|
584
594
|
embedder: ports.embedder ? await ports.embedder() : null,
|
|
585
595
|
});
|
|
@@ -767,6 +777,14 @@ async function readResource(uri, ports) {
|
|
|
767
777
|
text: JSON.stringify(value, null, 2),
|
|
768
778
|
};
|
|
769
779
|
}
|
|
780
|
+
// An optional YYYY-MM-DD argument; anything else is refused rather than silently ignored.
|
|
781
|
+
function isoDay(value, key) {
|
|
782
|
+
if (value === undefined || value === null || value === "")
|
|
783
|
+
return undefined;
|
|
784
|
+
if (typeof value !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(value))
|
|
785
|
+
throw new Error(`${key} must be a YYYY-MM-DD date`);
|
|
786
|
+
return value;
|
|
787
|
+
}
|
|
770
788
|
function requiredArgument(args, key) {
|
|
771
789
|
const value = args[key];
|
|
772
790
|
if (typeof value !== "string" || !value)
|
package/ocean-marketplace.json
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
{
|
|
6
6
|
"kind": "skill",
|
|
7
7
|
"name": "dev.ocean.skills.business-logic",
|
|
8
|
-
"version": "2.
|
|
8
|
+
"version": "2.9.0",
|
|
9
9
|
"engines": {
|
|
10
|
-
"ocean": ">=2.
|
|
10
|
+
"ocean": ">=2.9.0"
|
|
11
11
|
},
|
|
12
12
|
"source": {
|
|
13
13
|
"type": "path",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
{
|
|
24
24
|
"kind": "skill",
|
|
25
25
|
"name": "dev.ocean.skills.catch-up",
|
|
26
|
-
"version": "2.
|
|
26
|
+
"version": "2.9.0",
|
|
27
27
|
"engines": {
|
|
28
|
-
"ocean": ">=2.
|
|
28
|
+
"ocean": ">=2.9.0"
|
|
29
29
|
},
|
|
30
30
|
"source": {
|
|
31
31
|
"type": "path",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
{
|
|
42
42
|
"kind": "skill",
|
|
43
43
|
"name": "dev.ocean.skills.core-thinking",
|
|
44
|
-
"version": "2.
|
|
44
|
+
"version": "2.9.0",
|
|
45
45
|
"engines": {
|
|
46
|
-
"ocean": ">=2.
|
|
46
|
+
"ocean": ">=2.9.0"
|
|
47
47
|
},
|
|
48
48
|
"source": {
|
|
49
49
|
"type": "path",
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
{
|
|
60
60
|
"kind": "skill",
|
|
61
61
|
"name": "dev.ocean.skills.daily-harvest",
|
|
62
|
-
"version": "2.
|
|
62
|
+
"version": "2.9.0",
|
|
63
63
|
"engines": {
|
|
64
|
-
"ocean": ">=2.
|
|
64
|
+
"ocean": ">=2.9.0"
|
|
65
65
|
},
|
|
66
66
|
"source": {
|
|
67
67
|
"type": "path",
|
|
@@ -77,9 +77,9 @@
|
|
|
77
77
|
{
|
|
78
78
|
"kind": "skill",
|
|
79
79
|
"name": "dev.ocean.skills.design-thinking",
|
|
80
|
-
"version": "2.
|
|
80
|
+
"version": "2.9.0",
|
|
81
81
|
"engines": {
|
|
82
|
-
"ocean": ">=2.
|
|
82
|
+
"ocean": ">=2.9.0"
|
|
83
83
|
},
|
|
84
84
|
"source": {
|
|
85
85
|
"type": "path",
|
|
@@ -95,9 +95,9 @@
|
|
|
95
95
|
{
|
|
96
96
|
"kind": "skill",
|
|
97
97
|
"name": "dev.ocean.skills.graft",
|
|
98
|
-
"version": "2.
|
|
98
|
+
"version": "2.9.0",
|
|
99
99
|
"engines": {
|
|
100
|
-
"ocean": ">=2.
|
|
100
|
+
"ocean": ">=2.9.0"
|
|
101
101
|
},
|
|
102
102
|
"source": {
|
|
103
103
|
"type": "path",
|
|
@@ -113,9 +113,9 @@
|
|
|
113
113
|
{
|
|
114
114
|
"kind": "skill",
|
|
115
115
|
"name": "dev.ocean.skills.loop",
|
|
116
|
-
"version": "2.
|
|
116
|
+
"version": "2.9.0",
|
|
117
117
|
"engines": {
|
|
118
|
-
"ocean": ">=2.
|
|
118
|
+
"ocean": ">=2.9.0"
|
|
119
119
|
},
|
|
120
120
|
"source": {
|
|
121
121
|
"type": "path",
|
|
@@ -131,9 +131,9 @@
|
|
|
131
131
|
{
|
|
132
132
|
"kind": "skill",
|
|
133
133
|
"name": "dev.ocean.skills.memory-review",
|
|
134
|
-
"version": "2.
|
|
134
|
+
"version": "2.9.0",
|
|
135
135
|
"engines": {
|
|
136
|
-
"ocean": ">=2.
|
|
136
|
+
"ocean": ">=2.9.0"
|
|
137
137
|
},
|
|
138
138
|
"source": {
|
|
139
139
|
"type": "path",
|
|
@@ -149,9 +149,9 @@
|
|
|
149
149
|
{
|
|
150
150
|
"kind": "skill",
|
|
151
151
|
"name": "dev.ocean.skills.session-handoff",
|
|
152
|
-
"version": "2.
|
|
152
|
+
"version": "2.9.0",
|
|
153
153
|
"engines": {
|
|
154
|
-
"ocean": ">=2.
|
|
154
|
+
"ocean": ">=2.9.0"
|
|
155
155
|
},
|
|
156
156
|
"source": {
|
|
157
157
|
"type": "path",
|
|
@@ -167,9 +167,9 @@
|
|
|
167
167
|
{
|
|
168
168
|
"kind": "skill",
|
|
169
169
|
"name": "dev.ocean.skills.use-browser",
|
|
170
|
-
"version": "2.
|
|
170
|
+
"version": "2.9.0",
|
|
171
171
|
"engines": {
|
|
172
|
-
"ocean": ">=2.
|
|
172
|
+
"ocean": ">=2.9.0"
|
|
173
173
|
},
|
|
174
174
|
"source": {
|
|
175
175
|
"type": "path",
|
|
@@ -185,9 +185,9 @@
|
|
|
185
185
|
{
|
|
186
186
|
"kind": "skill",
|
|
187
187
|
"name": "dev.ocean.skills.verification",
|
|
188
|
-
"version": "2.
|
|
188
|
+
"version": "2.9.0",
|
|
189
189
|
"engines": {
|
|
190
|
-
"ocean": ">=2.
|
|
190
|
+
"ocean": ">=2.9.0"
|
|
191
191
|
},
|
|
192
192
|
"source": {
|
|
193
193
|
"type": "path",
|
|
@@ -203,9 +203,9 @@
|
|
|
203
203
|
{
|
|
204
204
|
"kind": "skill",
|
|
205
205
|
"name": "dev.ocean.skills.weekly-review",
|
|
206
|
-
"version": "2.
|
|
206
|
+
"version": "2.9.0",
|
|
207
207
|
"engines": {
|
|
208
|
-
"ocean": ">=2.
|
|
208
|
+
"ocean": ">=2.9.0"
|
|
209
209
|
},
|
|
210
210
|
"source": {
|
|
211
211
|
"type": "path",
|
|
@@ -247,9 +247,9 @@
|
|
|
247
247
|
"npx"
|
|
248
248
|
]
|
|
249
249
|
},
|
|
250
|
-
"version": "2.
|
|
250
|
+
"version": "2.9.0",
|
|
251
251
|
"engines": {
|
|
252
|
-
"ocean": ">=2.
|
|
252
|
+
"ocean": ">=2.9.0"
|
|
253
253
|
},
|
|
254
254
|
"source": {
|
|
255
255
|
"type": "path",
|
|
@@ -299,9 +299,9 @@
|
|
|
299
299
|
"kind": "mcp",
|
|
300
300
|
"name": "dev.ocean/mcp-gateway",
|
|
301
301
|
"description": "One MCP endpoint for every registered server: Ocean's own and those installed from the marketplace.",
|
|
302
|
-
"version": "2.
|
|
302
|
+
"version": "2.9.0",
|
|
303
303
|
"engines": {
|
|
304
|
-
"ocean": ">=2.
|
|
304
|
+
"ocean": ">=2.9.0"
|
|
305
305
|
},
|
|
306
306
|
"source": {
|
|
307
307
|
"type": "path",
|
|
@@ -343,9 +343,9 @@
|
|
|
343
343
|
"kind": "mcp",
|
|
344
344
|
"name": "dev.ocean/obsidian",
|
|
345
345
|
"description": "Ocean's Obsidian vault bridge over MCP.",
|
|
346
|
-
"version": "2.
|
|
346
|
+
"version": "2.9.0",
|
|
347
347
|
"engines": {
|
|
348
|
-
"ocean": ">=2.
|
|
348
|
+
"ocean": ">=2.9.0"
|
|
349
349
|
},
|
|
350
350
|
"source": {
|
|
351
351
|
"type": "path",
|
|
@@ -387,9 +387,9 @@
|
|
|
387
387
|
"kind": "mcp",
|
|
388
388
|
"name": "dev.ocean/ocean",
|
|
389
389
|
"description": "Ocean's own MCP server: workspace status, tasks, handoffs, sessions and the brain.",
|
|
390
|
-
"version": "2.
|
|
390
|
+
"version": "2.9.0",
|
|
391
391
|
"engines": {
|
|
392
|
-
"ocean": ">=2.
|
|
392
|
+
"ocean": ">=2.9.0"
|
|
393
393
|
},
|
|
394
394
|
"source": {
|
|
395
395
|
"type": "path",
|
|
@@ -441,9 +441,9 @@
|
|
|
441
441
|
"npx"
|
|
442
442
|
]
|
|
443
443
|
},
|
|
444
|
-
"version": "2.
|
|
444
|
+
"version": "2.9.0",
|
|
445
445
|
"engines": {
|
|
446
|
-
"ocean": ">=2.
|
|
446
|
+
"ocean": ">=2.9.0"
|
|
447
447
|
},
|
|
448
448
|
"source": {
|
|
449
449
|
"type": "path",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amoree-code/ocean",
|
|
3
3
|
"description": "Local-first memory, tasks and session capture shared by every AI coding client: one private workspace for Claude, Codex, Gemini and more.",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.9.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "AMEER ABDULKAREEM JABBAR LAMI",
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
"@langchain/core": "1.2.14",
|
|
54
54
|
"@langchain/langgraph": "1.4.19",
|
|
55
55
|
"@modelcontextprotocol/sdk": "1.32.0",
|
|
56
|
-
"@ocean/brain": "2.
|
|
57
|
-
"@ocean/context": "2.
|
|
58
|
-
"@ocean/core": "2.
|
|
59
|
-
"@ocean/loop": "2.
|
|
60
|
-
"@ocean/market": "2.
|
|
61
|
-
"@ocean/services": "2.
|
|
56
|
+
"@ocean/brain": "2.9.0",
|
|
57
|
+
"@ocean/context": "2.9.0",
|
|
58
|
+
"@ocean/core": "2.9.0",
|
|
59
|
+
"@ocean/loop": "2.9.0",
|
|
60
|
+
"@ocean/market": "2.9.0",
|
|
61
|
+
"@ocean/services": "2.9.0",
|
|
62
62
|
"playwright-core": "^1.48.0",
|
|
63
63
|
"sqlite-vec": "0.1.9",
|
|
64
64
|
"zod": "^4.6.5"
|