@cortexkit/opencode-magic-context 0.49.15 → 0.49.17
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/auto-search-worker.js +76 -63
- package/dist/chunk-embedding-write-worker.js +12 -10
- package/dist/{compaction-marker-candidates-v5c6997n.js → compaction-marker-candidates-n4krhat4.js} +2 -2
- package/dist/compaction-marker-candidates-worker.js +2 -2
- package/dist/config/schema/magic-context.d.ts +343 -343
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-mgq17yr3.js → conflict-warning-hook-4pmz879v.js} +6 -6
- package/dist/{context-0m46day0.js → context-yhetp0kn.js} +297 -141
- package/dist/embedding-backfill-fmz50tsy.js +24 -0
- package/dist/embedding-worker-process.js +1 -1
- package/dist/embedding-worker.js +5 -5
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts +1 -1
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/git-commits/indexer.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
- package/dist/features/magic-context/memory/project-identity-cache.d.ts +2 -0
- package/dist/features/magic-context/memory/project-identity-cache.d.ts.map +1 -1
- package/dist/features/magic-context/message-fts-rowid-map.d.ts +2 -2
- package/dist/features/magic-context/message-fts-rowid-map.d.ts.map +1 -1
- package/dist/features/magic-context/message-fts-session-filter.d.ts +2 -0
- package/dist/features/magic-context/message-fts-session-filter.d.ts.map +1 -1
- package/dist/features/magic-context/message-index-async.d.ts +1 -1
- package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
- package/dist/features/magic-context/message-index.d.ts +5 -0
- package/dist/features/magic-context/message-index.d.ts.map +1 -1
- package/dist/features/magic-context/message-time-backfill.d.ts +2 -2
- package/dist/features/magic-context/message-time-backfill.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts +6 -1
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +2 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-shared.d.ts +2 -2
- package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
- package/dist/features/magic-context/storage-session-tables.d.ts +9 -1
- package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-deadline.d.ts +2 -1
- package/dist/hooks/magic-context/auto-search-deadline.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-hint.d.ts +3 -0
- package/dist/hooks/magic-context/auto-search-hint.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-worker-client.d.ts +10 -2
- package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts +4 -2
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
- package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-host-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-prompt-fit.d.ts +2 -1
- package/dist/hooks/magic-context/historian-prompt-fit.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -1
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts +26 -0
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts +3 -3
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-diagnostics.d.ts +8 -0
- package/dist/hooks/magic-context/system-prompt-diagnostics.d.ts.map +1 -0
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +6 -1
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/todo-view.d.ts +2 -2
- package/dist/hooks/magic-context/tool-drop-target.d.ts +3 -2
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-stage-logger.d.ts +3 -0
- package/dist/hooks/magic-context/transform-stage-logger.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +1 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-3kdm78zp.js → index-24fezq97.js} +4 -4
- package/dist/{index-a8bvhwqs.js → index-2vxtcb95.js} +32 -3
- package/dist/{index-f71thw8j.js → index-4s3t0nd0.js} +1 -1
- package/dist/{index-ts1hjk1h.js → index-4yt7dtf4.js} +453 -227
- package/dist/{index-mc1cqza6.js → index-5a1ex6x8.js} +5 -5
- package/dist/{index-fkx2qnvw.js → index-6x57ar45.js} +2 -2
- package/dist/{index-dyvbsvga.js → index-a6mc0v4d.js} +25 -11
- package/dist/{index-snp5wbge.js → index-a7c4r5re.js} +160 -749
- package/dist/{index-42vcjcwe.js → index-aabzay3h.js} +180 -103
- package/dist/{index-3kx0kg0f.js → index-b5vqckbw.js} +14 -8
- package/dist/{v2/server-wafzvyhg.js → index-beht37jy.js} +8 -0
- package/dist/{index-e20m7284.js → index-bjcnntmz.js} +3 -3
- package/dist/{index-hqkczed7.js → index-c5pytzne.js} +22 -2
- package/dist/{index-thvnpfsv.js → index-cwzfcbtq.js} +967 -88
- package/dist/{index-yxycg7fs.js → index-fb2qxs2y.js} +26 -18
- package/dist/{index-mht7bq0z.js → index-hqhm3wke.js} +32 -8
- package/dist/{index-e4dsjj1p.js → index-jn12fvvh.js} +1 -1
- package/dist/index-kaqs6h31.js +58 -0
- package/dist/{index-n6m03s3n.js → index-ke416mdc.js} +1 -1
- package/dist/index-kmdj7dsq.js +96 -0
- package/dist/{index-1d289pq2.js → index-kq82mtg0.js} +2 -2
- package/dist/{index-n78avt2p.js → index-n37sebck.js} +1 -1
- package/dist/{index-1vc7jrkg.js → index-nkpmm9q8.js} +3 -3
- package/dist/{index-944w16m0.js → index-p7m7j0cp.js} +25 -17
- package/dist/{index-wk0n1cgt.js → index-qn7xstt2.js} +2 -2
- package/dist/{index-saews2s3.js → index-rr2bb45z.js} +1 -1
- package/dist/{index-mmfa86mt.js → index-s734jcsr.js} +169 -149
- package/dist/{index-dgs16axy.js → index-s74zqahq.js} +1 -1
- package/dist/{index-bxdg2nbt.js → index-v8awdgvd.js} +4 -4
- package/dist/{index-xn6q9pg6.js → index-vrzjhftj.js} +36 -76
- package/dist/{index-1sarmj9z.js → index-wgypt3cs.js} +6 -6
- package/dist/{index-y1qysm3q.js → index-ze7mvk54.js} +11 -8
- package/dist/index.js +47 -45
- package/dist/message-fts-rowid-map-17s0dfn4.js +25 -0
- package/dist/{message-index-bounded-vtgpq6b4.js → message-index-bounded-1633vc7f.js} +17 -17
- package/dist/{message-index-a6gztaqx.js → message-index-dprebmtt.js} +15 -15
- package/dist/{message-time-backfill-qjge9044.js → message-time-backfill-73mmm76q.js} +5 -5
- package/dist/migration-worker.js +9 -7
- package/dist/plugin/dream-timer.d.ts +11 -0
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/{project-embedding-registry-x45bv3qr.js → project-embedding-registry-z74mhqkf.js} +12 -10
- package/dist/raw-ordinal-warmup-worker.js +40 -10
- package/dist/{read-session-chunk-3ae3nfdn.js → read-session-chunk-4zp09ejb.js} +9 -9
- package/dist/{read-session-raw-m56hc7v2.js → read-session-raw-rsc8c7qy.js} +2 -2
- package/dist/{recomp-orchestrator-nwzcfhx4.js → recomp-orchestrator-z3ecszx6.js} +26 -26
- package/dist/{search-deajrd90.js → search-6mee3vty.js} +23 -22
- package/dist/search-archive-znyy44ve.js +25 -0
- package/dist/{send-session-notification-24r4esbh.js → send-session-notification-6ve0e8p4.js} +5 -5
- package/dist/shared/historian-cache.d.ts +8 -0
- package/dist/shared/historian-cache.d.ts.map +1 -0
- package/dist/shared/model-suggestion-retry.d.ts +4 -0
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- package/dist/shared/resolve-fallbacks.d.ts +3 -3
- package/dist/shared/rpc-discovery-cleanup.d.ts +3 -0
- package/dist/shared/rpc-discovery-cleanup.d.ts.map +1 -0
- package/dist/shared/rpc-server.d.ts +2 -0
- package/dist/shared/rpc-server.d.ts.map +1 -1
- package/dist/shared/search-text.d.ts +8 -0
- package/dist/shared/search-text.d.ts.map +1 -0
- package/dist/shared/sqlite.d.ts +4 -2
- package/dist/shared/sqlite.d.ts.map +1 -1
- package/dist/shared/storage-file-mutex.d.ts.map +1 -1
- package/dist/shared/subagent-runner.d.ts +2 -0
- package/dist/shared/subagent-runner.d.ts.map +1 -1
- package/dist/shared/system-directive.d.ts +2 -0
- package/dist/shared/system-directive.d.ts.map +1 -1
- package/dist/{sqlite-4pqyynrs.js → sqlite-zf72c52d.js} +1 -1
- package/dist/{storage-memory-j3v3hc83.js → storage-memory-y3qmy00r.js} +2 -2
- package/dist/{storage-tags-s5bg1ahx.js → storage-tags-8qns3012.js} +8 -4
- package/dist/tools/ctx-expand/search-archive.d.ts +5 -1
- package/dist/tools/ctx-expand/search-archive.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-ne3z1zmt.js → transform-postprocess-phase-3ydzxa62.js} +26 -26
- package/dist/v2/auto-search-worker.js +76 -63
- package/dist/v2/chunk-embedding-write-worker.js +12 -10
- package/dist/v2/{compaction-marker-candidates-1vqwr3s5.js → compaction-marker-candidates-ebx3388k.js} +2 -2
- package/dist/v2/compaction-marker-candidates-worker.js +2 -2
- package/dist/v2/{context-4qczzck7.js → context-jn3zpeqh.js} +909 -454
- package/dist/v2/embedding-backfill-7c7yr69y.js +23 -0
- package/dist/v2/embedding-worker-process.js +1 -1
- package/dist/v2/embedding-worker.js +5 -5
- package/dist/v2/fold/native-replay.d.ts +11 -2
- package/dist/v2/fold/native-replay.d.ts.map +1 -1
- package/dist/v2/fold/policy.d.ts.map +1 -1
- package/dist/v2/fold/restore.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-child.d.ts +8 -0
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
- package/dist/v2/hooks/types.d.ts +17 -0
- package/dist/v2/hooks/types.d.ts.map +1 -1
- package/dist/v2/message-fts-rowid-map-wfx67gfd.js +24 -0
- package/dist/v2/{message-index-bounded-rxxznd34.js → message-index-bounded-hpejqyd8.js} +17 -17
- package/dist/v2/{message-index-f947qtbz.js → message-index-pxehjpzx.js} +15 -15
- package/dist/v2/{message-time-backfill-bsteyc4d.js → message-time-backfill-04t0km1z.js} +5 -5
- package/dist/v2/migration-worker.js +9 -7
- package/dist/v2/{project-embedding-registry-0msp56p8.js → project-embedding-registry-gnkj56xp.js} +12 -10
- package/dist/v2/raw-ordinal-warmup-worker.js +40 -10
- package/dist/v2/{read-session-chunk-rq9nx1nn.js → read-session-chunk-zdppn4bj.js} +9 -9
- package/dist/v2/{read-session-raw-b3tf6ra1.js → read-session-raw-yaegtjzh.js} +2 -2
- package/dist/v2/{recomp-orchestrator-5zhxtwha.js → recomp-orchestrator-cmqnfpp3.js} +26 -26
- package/dist/v2/{search-n8wqxb1j.js → search-66842dya.js} +23 -22
- package/dist/v2/search-archive-gfh11vs0.js +24 -0
- package/dist/v2/{send-session-notification-8ghn9tnv.js → send-session-notification-3pxn658x.js} +5 -5
- package/dist/v2/{server-yrvqaswb.js → server-1wy7b9de.js} +25 -11
- package/dist/v2/{server-th4y11y7.js → server-271qxsf5.js} +6 -6
- package/dist/v2/{server-e298hswg.js → server-3rhpvy84.js} +967 -88
- package/dist/v2/{server-qhfvvfxj.js → server-46neh5fa.js} +14 -8
- package/dist/v2/{server-rrqpvwqd.js → server-6tmj0s7j.js} +2 -2
- package/dist/v2/{server-hek6z3w6.js → server-8by8qfec.js} +11 -8
- package/dist/v2/{server-vbe4se57.js → server-a9xqj88f.js} +1 -1
- package/dist/{index-wafzvyhg.js → v2/server-beht37jy.js} +8 -0
- package/dist/v2/{server-05xjtq6c.js → server-d04vrx0j.js} +1 -1
- package/dist/v2/server-ec4ca92p.js +96 -0
- package/dist/v2/{server-dd0tz6cn.js → server-fw7wrk01.js} +160 -750
- package/dist/v2/{server-zs8d0s3b.js → server-g3qma5c0.js} +1 -1
- package/dist/v2/{server-k2bzedxk.js → server-gpvay0xz.js} +2 -2
- package/dist/v2/{server-kmbarfmn.js → server-gtfhttbr.js} +26 -18
- package/dist/v2/{server-g10mdym6.js → server-h1v0pyxb.js} +3 -3
- package/dist/v2/{server-4gn3z5an.js → server-hy3d3vsx.js} +1 -1
- package/dist/v2/server-kaqs6h31.js +58 -0
- package/dist/v2/{server-ehyava47.js → server-kh7dpa1a.js} +25 -17
- package/dist/v2/{server-6cdy4rc0.js → server-my7k4eds.js} +4 -4
- package/dist/v2/{server-d8tj10db.js → server-n1prf1g6.js} +1 -1
- package/dist/v2/{server-n78avt2p.js → server-n37sebck.js} +1 -1
- package/dist/v2/{server-zc3e54vy.js → server-nj659894.js} +6 -6
- package/dist/v2/{server-gvkm8xaj.js → server-rmygf5pn.js} +32 -3
- package/dist/v2/{server-0ppsweh6.js → server-tgnbmwah.js} +22 -2
- package/dist/v2/{server-cfbr1s2x.js → server-vsw8tmm6.js} +36 -76
- package/dist/v2/{server-prg55b7k.js → server-xj136kt8.js} +23 -3
- package/dist/v2/{server-atbc19ab.js → server-zyzawhdw.js} +32 -8
- package/dist/v2/{server-ef89gdsx.js → server-zzkj2fch.js} +4 -4
- package/dist/v2/server.js +5 -5
- package/dist/v2/{sqlite-4pqyynrs.js → sqlite-zf72c52d.js} +1 -1
- package/dist/v2/{storage-memory-j3v3hc83.js → storage-memory-y3qmy00r.js} +2 -2
- package/dist/v2/{storage-tags-hcc2adpf.js → storage-tags-1h8k6ra9.js} +8 -4
- package/dist/v2/store-reader.d.ts +2 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{wrapup-orchestrator-65pwye0d.js → wrapup-orchestrator-xs8redz9.js} +26 -26
- package/dist/wrapup-orchestrator-j7d7ry5b.js +48 -0
- package/package.json +1 -1
- package/src/config/latch-permanence-guard.test.ts +4 -0
- package/src/config/schema/magic-context.ts +14 -6
- package/src/shared/historian-cache.test.ts +69 -0
- package/src/shared/historian-cache.ts +55 -0
- package/src/shared/model-resolution.test.ts +22 -0
- package/src/shared/model-suggestion-retry.ts +11 -3
- package/src/shared/resolve-fallbacks.test.ts +2 -3
- package/src/shared/resolve-fallbacks.ts +3 -3
- package/src/shared/rpc-discovery-cleanup.test.ts +57 -0
- package/src/shared/rpc-discovery-cleanup.ts +57 -0
- package/src/shared/rpc-server.ts +36 -13
- package/src/shared/search-text.test.ts +47 -0
- package/src/shared/search-text.ts +63 -0
- package/src/shared/sqlite.test.ts +56 -0
- package/src/shared/sqlite.ts +51 -2
- package/src/shared/storage-file-mutex-review.test.ts +22 -2
- package/src/shared/storage-file-mutex.ts +11 -1
- package/src/shared/subagent-runner.ts +2 -0
- package/src/shared/system-directive.ts +19 -1
- package/src/shared/tag-transcript.ts +12 -4
- package/dist/embedding-backfill-5e1t5wha.js +0 -22
- package/dist/v2/embedding-backfill-jmaf8zrr.js +0 -21
- package/dist/wrapup-orchestrator-28xzsj5q.js +0 -48
|
@@ -1,163 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
inRootAsyncContext2,
|
|
3
|
-
getSqliteDatabasePath2,
|
|
4
|
-
releaseIndexOwner2
|
|
5
|
-
} from "./index-wafzvyhg.js";
|
|
6
1
|
import {
|
|
7
2
|
registerExitAbort
|
|
8
3
|
} from "./index-v0p37hm2.js";
|
|
9
4
|
import {
|
|
10
5
|
log2
|
|
11
6
|
} from "./index-j75v2476.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
import {
|
|
8
|
+
inRootAsyncContext2,
|
|
9
|
+
getSqliteDatabasePath2,
|
|
10
|
+
releaseIndexOwner2
|
|
11
|
+
} from "./index-beht37jy.js";
|
|
15
12
|
|
|
16
13
|
// src/hooks/magic-context/raw-ordinal-warmup.ts
|
|
17
14
|
import { Worker } from "node:worker_threads";
|
|
18
|
-
var ACCEPT_TIMEOUT_MS = 2000;
|
|
19
|
-
var RESULT_TIMEOUT_MS = 10 * 60000;
|
|
20
|
-
var FAILURE_BACKOFF_MS = 5 * 60000;
|
|
21
|
-
var inFlight = new Map;
|
|
22
|
-
var connectionIds = new WeakMap;
|
|
23
|
-
var nextConnectionId = 0;
|
|
24
|
-
var failedAt = new Map;
|
|
25
|
-
var activeWorkers = new Map;
|
|
26
|
-
var failures = new Map;
|
|
27
|
-
var exitHookRegistered = false;
|
|
28
|
-
function stopRawSessionOrdinalWarmups() {
|
|
29
|
-
for (const stop of [...activeWorkers.values()])
|
|
30
|
-
stop("stopped");
|
|
31
|
-
}
|
|
32
|
-
function defaultEntry() {
|
|
33
|
-
return new URL(new URL(import.meta.url).pathname.endsWith(".ts") ? "./raw-ordinal-warmup-worker.ts" : "./raw-ordinal-warmup-worker.js", import.meta.url);
|
|
34
|
-
}
|
|
35
|
-
function ensureExitHook() {
|
|
36
|
-
if (exitHookRegistered)
|
|
37
|
-
return;
|
|
38
|
-
exitHookRegistered = true;
|
|
39
|
-
const controller = new AbortController;
|
|
40
|
-
controller.signal.addEventListener("abort", stopRawSessionOrdinalWarmups, { once: true });
|
|
41
|
-
registerExitAbort(controller);
|
|
42
|
-
}
|
|
43
|
-
function runSessionWarmupWorker(input, options) {
|
|
44
|
-
ensureExitHook();
|
|
45
|
-
return new Promise((resolve) => {
|
|
46
|
-
let worker;
|
|
47
|
-
let deadline;
|
|
48
|
-
let settled = false;
|
|
49
|
-
const finish = (result) => {
|
|
50
|
-
if (settled)
|
|
51
|
-
return;
|
|
52
|
-
settled = true;
|
|
53
|
-
clearTimeout(deadline);
|
|
54
|
-
if (worker) {
|
|
55
|
-
activeWorkers.delete(worker);
|
|
56
|
-
const stopped = worker.terminate();
|
|
57
|
-
worker.unref();
|
|
58
|
-
stopped.finally(() => {
|
|
59
|
-
releaseIndexOwner2(input);
|
|
60
|
-
resolve(result);
|
|
61
|
-
});
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
releaseIndexOwner2(input);
|
|
65
|
-
resolve(result);
|
|
66
|
-
};
|
|
67
|
-
const arm = (failure, ms) => {
|
|
68
|
-
clearTimeout(deadline);
|
|
69
|
-
deadline = setTimeout(() => finish({ failure, detail: `no reply within ${ms} ms` }), ms);
|
|
70
|
-
deadline.unref?.();
|
|
71
|
-
};
|
|
72
|
-
try {
|
|
73
|
-
worker = inRootAsyncContext2(() => new Worker(options.entry ?? defaultEntry(), { workerData: input }));
|
|
74
|
-
} catch (error) {
|
|
75
|
-
finish({ failure: "start-failed", detail: String(error) });
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
worker.unref();
|
|
79
|
-
activeWorkers.set(worker, (failure) => finish({ failure, detail: "stopped" }));
|
|
80
|
-
arm("not-accepted", options.acceptMs ?? ACCEPT_TIMEOUT_MS);
|
|
81
|
-
worker.on("message", (reply) => {
|
|
82
|
-
if (reply.kind === "accepted")
|
|
83
|
-
arm("no-result", options.resultMs ?? RESULT_TIMEOUT_MS);
|
|
84
|
-
else if (reply.kind === "scan")
|
|
85
|
-
finish({ scan: reply.scan });
|
|
86
|
-
else if (reply.kind === "tag-summary")
|
|
87
|
-
finish({ summary: reply.summary });
|
|
88
|
-
else if (reply.kind === "tag-delta")
|
|
89
|
-
finish({ delta: reply.delta });
|
|
90
|
-
else if (reply.kind === "indexed")
|
|
91
|
-
finish({ inserted: reply.inserted, measurements: reply.measurements });
|
|
92
|
-
else if (reply.kind === "orphan-sweep")
|
|
93
|
-
finish({ orphanSweep: reply.result });
|
|
94
|
-
else if (reply.kind === "exact-ordinal-ids")
|
|
95
|
-
finish({ exactOrdinalIds: reply.ids });
|
|
96
|
-
else
|
|
97
|
-
finish({ failure: "worker-error", detail: reply.error });
|
|
98
|
-
});
|
|
99
|
-
worker.on("error", (error) => finish({ failure: "worker-error", detail: String(error) }));
|
|
100
|
-
worker.on("exit", (code) => finish({ failure: "exited", detail: `exit code ${code}` }));
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
function prewarmRawSessionOrdinalsForDb(db, sessionId, options = {}) {
|
|
104
|
-
if (isRawSessionSummaryWarm2(db, sessionId))
|
|
105
|
-
return Promise.resolve("warm");
|
|
106
|
-
if (!db.prepare("SELECT 1 FROM sqlite_master WHERE name = 'message' AND type IN ('table', 'view')").get())
|
|
107
|
-
return Promise.resolve("warm");
|
|
108
|
-
const path = getSqliteDatabasePath2(db);
|
|
109
|
-
if (!path) {
|
|
110
|
-
countRawSessionMessageOrdinalsFromDb2(db, sessionId);
|
|
111
|
-
return Promise.resolve("warm");
|
|
112
|
-
}
|
|
113
|
-
let connectionId = connectionIds.get(db);
|
|
114
|
-
if (connectionId === undefined) {
|
|
115
|
-
connectionId = ++nextConnectionId;
|
|
116
|
-
connectionIds.set(db, connectionId);
|
|
117
|
-
}
|
|
118
|
-
const key = `${path}\x00${sessionId}\x00${connectionId}`;
|
|
119
|
-
let shared = inFlight.get(key);
|
|
120
|
-
if (!shared) {
|
|
121
|
-
const failed = failedAt.get(key);
|
|
122
|
-
if (failed !== undefined && Date.now() - failed < FAILURE_BACKOFF_MS)
|
|
123
|
-
return Promise.resolve("failed");
|
|
124
|
-
const epoch = getRawSessionSummaryEpoch2(sessionId);
|
|
125
|
-
const started = performance.now();
|
|
126
|
-
const result = runSessionWarmupWorker({ path, sessionId, previous: rawOrdinalSummarySeed2(db, sessionId) }, options).then((outcome) => {
|
|
127
|
-
if ("failure" in outcome)
|
|
128
|
-
recordFailure(key, sessionId, outcome.failure, outcome.detail);
|
|
129
|
-
return outcome;
|
|
130
|
-
}).finally(() => {
|
|
131
|
-
if (inFlight.get(key) === scan)
|
|
132
|
-
inFlight.delete(key);
|
|
133
|
-
});
|
|
134
|
-
const scan = { epoch, started, result };
|
|
135
|
-
inFlight.set(key, scan);
|
|
136
|
-
shared = scan;
|
|
137
|
-
}
|
|
138
|
-
const awaited = shared;
|
|
139
|
-
return awaited.result.then((result) => {
|
|
140
|
-
if (!("scan" in result))
|
|
141
|
-
return "failed";
|
|
142
|
-
try {
|
|
143
|
-
if (installRawSessionSummaryScan2(db, sessionId, result.scan, awaited.epoch, true)) {
|
|
144
|
-
failedAt.delete(key);
|
|
145
|
-
log2(`[magic-context] canonical ordinals of ${sessionId} warmed off-thread (${result.scan.sessionRows} messages, ${Math.round(performance.now() - awaited.started)} ms)`);
|
|
146
|
-
return "warm";
|
|
147
|
-
}
|
|
148
|
-
} catch {}
|
|
149
|
-
recordFailure(key, sessionId, "superseded", `session removed during scan: epoch=${awaited.epoch}/${getRawSessionSummaryEpoch2(sessionId)}`);
|
|
150
|
-
return "failed";
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
function recordFailure(key, sessionId, failure, detail) {
|
|
154
|
-
failures.set(failure, (failures.get(failure) ?? 0) + 1);
|
|
155
|
-
if (failure !== "superseded")
|
|
156
|
-
failedAt.set(key, Date.now());
|
|
157
|
-
log2(`[magic-context] WARN canonical ordinal warm-up failed for ${sessionId} (${failure}: ${detail}); counts remain bounded and callers must defer or retry`);
|
|
158
|
-
}
|
|
159
15
|
|
|
160
16
|
// src/hooks/magic-context/read-session-raw.ts
|
|
17
|
+
import { isMainThread } from "node:worker_threads";
|
|
161
18
|
function isStrictGapHealingMessage2(message) {
|
|
162
19
|
if (message.storeType === "synthetic")
|
|
163
20
|
return true;
|
|
@@ -1267,4 +1124,167 @@ function readRawSessionBoundaryEndpointsFromDb2(db, sessionId, ids, blockIds = [
|
|
|
1267
1124
|
}
|
|
1268
1125
|
}
|
|
1269
1126
|
|
|
1127
|
+
// src/hooks/magic-context/raw-ordinal-warmup.ts
|
|
1128
|
+
var ACCEPT_TIMEOUT_MS = 2000;
|
|
1129
|
+
var RESULT_TIMEOUT_MS = 10 * 60000;
|
|
1130
|
+
var FAILURE_BACKOFF_MS = 5 * 60000;
|
|
1131
|
+
var inFlight = new Map;
|
|
1132
|
+
var connectionIds = new WeakMap;
|
|
1133
|
+
var nextConnectionId = 0;
|
|
1134
|
+
var failedAt = new Map;
|
|
1135
|
+
var activeWorkers = new Map;
|
|
1136
|
+
var failures = new Map;
|
|
1137
|
+
var exitHookRegistered = false;
|
|
1138
|
+
function stopRawSessionOrdinalWarmups() {
|
|
1139
|
+
for (const stop of [...activeWorkers.values()])
|
|
1140
|
+
stop("stopped");
|
|
1141
|
+
}
|
|
1142
|
+
function defaultEntry() {
|
|
1143
|
+
return new URL(new URL(import.meta.url).pathname.endsWith(".ts") ? "./raw-ordinal-warmup-worker.ts" : "./raw-ordinal-warmup-worker.js", import.meta.url);
|
|
1144
|
+
}
|
|
1145
|
+
function ensureExitHook() {
|
|
1146
|
+
if (exitHookRegistered)
|
|
1147
|
+
return;
|
|
1148
|
+
exitHookRegistered = true;
|
|
1149
|
+
const controller = new AbortController;
|
|
1150
|
+
controller.signal.addEventListener("abort", stopRawSessionOrdinalWarmups, { once: true });
|
|
1151
|
+
registerExitAbort(controller);
|
|
1152
|
+
}
|
|
1153
|
+
function runSessionWarmupWorker(input, options) {
|
|
1154
|
+
ensureExitHook();
|
|
1155
|
+
return new Promise((resolve) => {
|
|
1156
|
+
const openCancellation = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
|
1157
|
+
let worker;
|
|
1158
|
+
let deadline;
|
|
1159
|
+
let settled = false;
|
|
1160
|
+
const finish = (result) => {
|
|
1161
|
+
if (settled)
|
|
1162
|
+
return;
|
|
1163
|
+
settled = true;
|
|
1164
|
+
Atomics.store(openCancellation, 0, 1);
|
|
1165
|
+
clearTimeout(deadline);
|
|
1166
|
+
options.signal?.removeEventListener("abort", abort);
|
|
1167
|
+
if (worker) {
|
|
1168
|
+
activeWorkers.delete(worker);
|
|
1169
|
+
const stopped = worker.terminate();
|
|
1170
|
+
worker.unref();
|
|
1171
|
+
stopped.finally(() => {
|
|
1172
|
+
releaseIndexOwner2(input);
|
|
1173
|
+
resolve(result);
|
|
1174
|
+
});
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
releaseIndexOwner2(input);
|
|
1178
|
+
resolve(result);
|
|
1179
|
+
};
|
|
1180
|
+
const arm = (failure, ms) => {
|
|
1181
|
+
clearTimeout(deadline);
|
|
1182
|
+
deadline = setTimeout(() => finish({ failure, detail: `no reply within ${ms} ms` }), ms);
|
|
1183
|
+
deadline.unref?.();
|
|
1184
|
+
};
|
|
1185
|
+
const abort = () => finish({ failure: "stopped", detail: "stopped" });
|
|
1186
|
+
if (options.signal?.aborted) {
|
|
1187
|
+
abort();
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1190
|
+
options.signal?.addEventListener("abort", abort, { once: true });
|
|
1191
|
+
try {
|
|
1192
|
+
worker = inRootAsyncContext2(() => new Worker(options.entry ?? defaultEntry(), {
|
|
1193
|
+
workerData: { ...input, openCancellation: openCancellation.buffer }
|
|
1194
|
+
}));
|
|
1195
|
+
} catch (error) {
|
|
1196
|
+
finish({ failure: "start-failed", detail: String(error) });
|
|
1197
|
+
return;
|
|
1198
|
+
}
|
|
1199
|
+
worker.unref();
|
|
1200
|
+
activeWorkers.set(worker, (failure) => finish({ failure, detail: "stopped" }));
|
|
1201
|
+
arm("not-accepted", options.acceptMs ?? ACCEPT_TIMEOUT_MS);
|
|
1202
|
+
worker.on("message", (reply) => {
|
|
1203
|
+
if (reply.kind === "accepted")
|
|
1204
|
+
arm("no-result", options.resultMs ?? RESULT_TIMEOUT_MS);
|
|
1205
|
+
else if (reply.kind === "scan")
|
|
1206
|
+
finish({ scan: reply.scan });
|
|
1207
|
+
else if (reply.kind === "tag-summary")
|
|
1208
|
+
finish({ summary: reply.summary });
|
|
1209
|
+
else if (reply.kind === "tag-delta")
|
|
1210
|
+
finish({ delta: reply.delta });
|
|
1211
|
+
else if (reply.kind === "indexed")
|
|
1212
|
+
finish({ inserted: reply.inserted, measurements: reply.measurements });
|
|
1213
|
+
else if (reply.kind === "orphan-sweep")
|
|
1214
|
+
finish({ orphanSweep: reply.result });
|
|
1215
|
+
else if (reply.kind === "exact-ordinal-ids")
|
|
1216
|
+
finish({ exactOrdinalIds: reply.ids });
|
|
1217
|
+
else if (reply.kind === "search-archive")
|
|
1218
|
+
finish({ searchArchive: reply.text });
|
|
1219
|
+
else if (reply.kind === "fts-rowid-backfill")
|
|
1220
|
+
finish({ ftsRowidBackfill: true });
|
|
1221
|
+
else
|
|
1222
|
+
finish({
|
|
1223
|
+
failure: "worker-error",
|
|
1224
|
+
detail: reply.error,
|
|
1225
|
+
code: reply.code,
|
|
1226
|
+
errcode: reply.errcode
|
|
1227
|
+
});
|
|
1228
|
+
});
|
|
1229
|
+
worker.on("error", (error) => finish({ failure: "worker-error", detail: String(error) }));
|
|
1230
|
+
worker.on("exit", (code) => finish({ failure: "exited", detail: `exit code ${code}` }));
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
function prewarmRawSessionOrdinalsForDb(db, sessionId, options = {}) {
|
|
1234
|
+
if (isRawSessionSummaryWarm2(db, sessionId))
|
|
1235
|
+
return Promise.resolve("warm");
|
|
1236
|
+
if (!db.prepare("SELECT 1 FROM sqlite_master WHERE name = 'message' AND type IN ('table', 'view')").get())
|
|
1237
|
+
return Promise.resolve("warm");
|
|
1238
|
+
const path = getSqliteDatabasePath2(db);
|
|
1239
|
+
if (!path) {
|
|
1240
|
+
countRawSessionMessageOrdinalsFromDb2(db, sessionId);
|
|
1241
|
+
return Promise.resolve("warm");
|
|
1242
|
+
}
|
|
1243
|
+
let connectionId = connectionIds.get(db);
|
|
1244
|
+
if (connectionId === undefined) {
|
|
1245
|
+
connectionId = ++nextConnectionId;
|
|
1246
|
+
connectionIds.set(db, connectionId);
|
|
1247
|
+
}
|
|
1248
|
+
const key = `${path}\x00${sessionId}\x00${connectionId}`;
|
|
1249
|
+
let shared = inFlight.get(key);
|
|
1250
|
+
if (!shared) {
|
|
1251
|
+
const failed = failedAt.get(key);
|
|
1252
|
+
if (failed !== undefined && Date.now() - failed < FAILURE_BACKOFF_MS)
|
|
1253
|
+
return Promise.resolve("failed");
|
|
1254
|
+
const epoch = getRawSessionSummaryEpoch2(sessionId);
|
|
1255
|
+
const started = performance.now();
|
|
1256
|
+
const result = runSessionWarmupWorker({ path, sessionId, previous: rawOrdinalSummarySeed2(db, sessionId) }, options).then((outcome) => {
|
|
1257
|
+
if ("failure" in outcome)
|
|
1258
|
+
recordFailure(key, sessionId, outcome.failure, outcome.detail);
|
|
1259
|
+
return outcome;
|
|
1260
|
+
}).finally(() => {
|
|
1261
|
+
if (inFlight.get(key) === scan)
|
|
1262
|
+
inFlight.delete(key);
|
|
1263
|
+
});
|
|
1264
|
+
const scan = { epoch, started, result };
|
|
1265
|
+
inFlight.set(key, scan);
|
|
1266
|
+
shared = scan;
|
|
1267
|
+
}
|
|
1268
|
+
const awaited = shared;
|
|
1269
|
+
return awaited.result.then((result) => {
|
|
1270
|
+
if (!("scan" in result))
|
|
1271
|
+
return "failed";
|
|
1272
|
+
try {
|
|
1273
|
+
if (installRawSessionSummaryScan2(db, sessionId, result.scan, awaited.epoch, true)) {
|
|
1274
|
+
failedAt.delete(key);
|
|
1275
|
+
log2(`[magic-context] canonical ordinals of ${sessionId} warmed off-thread (${result.scan.sessionRows} messages, ${Math.round(performance.now() - awaited.started)} ms)`);
|
|
1276
|
+
return "warm";
|
|
1277
|
+
}
|
|
1278
|
+
} catch {}
|
|
1279
|
+
recordFailure(key, sessionId, "superseded", `session removed during scan: epoch=${awaited.epoch}/${getRawSessionSummaryEpoch2(sessionId)}`);
|
|
1280
|
+
return "failed";
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
function recordFailure(key, sessionId, failure, detail) {
|
|
1284
|
+
failures.set(failure, (failures.get(failure) ?? 0) + 1);
|
|
1285
|
+
if (failure !== "superseded")
|
|
1286
|
+
failedAt.set(key, Date.now());
|
|
1287
|
+
log2(`[magic-context] WARN canonical ordinal warm-up failed for ${sessionId} (${failure}: ${detail}); counts remain bounded and callers must defer or retry`);
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1270
1290
|
export { isStrictGapHealingMessage2, isRawCompactionSummaryInfo2, readRawSessionMessagesFromDb2, readRawSessionMessagePageFromDb2, readRawSessionMessageSummaryPageFromDb2, countRawSessionMessageOrdinalsFromDb2, readRawSessionMessageIdOrdinalsForRangeFromDb2, readRawSessionMessageIdsAtOrdinalsFromDb2, readRawSessionMessageOrdinalPageFromDb2, countStoredRawSessionMessagesFromDb2, readRawSessionTailFromDb2, extractInMemoryMessageViews2, buildInMemoryTailRawMessages2, readRawSessionMessagePartsByIdFromDb2, forgetRawSessionOrdinalWatermark2, forgetRawSessionSummaryRows2, noteRawSessionSummaryRowWritten2, RawOrdinalsNotReady2, rawOrdinalSummarySeed2, scanRawSessionSummaryRows2, getRawSessionSummaryEpoch2, installRawSessionSummaryScan2, isRawSessionSummaryWarm2, readRawSessionMessageOrdinalByIdFromDb2, readRawSessionMessageByIdFromDb2, hasRawSessionMessageByIdFromDb2, readRawSeedTailFromDb2, readRawSessionBoundaryEndpointsFromDb2, runSessionWarmupWorker, prewarmRawSessionOrdinalsForDb };
|
|
@@ -7,17 +7,17 @@ import {
|
|
|
7
7
|
} from "./index-pavzsdc6.js";
|
|
8
8
|
import {
|
|
9
9
|
isTransientSqliteError2
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-beht37jy.js";
|
|
11
11
|
import {
|
|
12
12
|
PROMOTABLE_CATEGORIES,
|
|
13
13
|
CATEGORY_DEFAULT_TTL
|
|
14
14
|
} from "./index-fr0wbhdn.js";
|
|
15
15
|
import {
|
|
16
16
|
managedAuthorityNoteRow
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-qn7xstt2.js";
|
|
18
18
|
import {
|
|
19
19
|
embedTextForProject2
|
|
20
|
-
} from "./index-
|
|
20
|
+
} from "./index-ze7mvk54.js";
|
|
21
21
|
import {
|
|
22
22
|
saveEmbeddingIfHashMatches
|
|
23
23
|
} from "./index-4dhv7mqz.js";
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
buildWorkspaceMemorySqlFilter2,
|
|
31
31
|
getMemoryById2,
|
|
32
32
|
updateMemorySeenCount2
|
|
33
|
-
} from "./index-
|
|
33
|
+
} from "./index-n37sebck.js";
|
|
34
34
|
import {
|
|
35
35
|
computeNormalizedHash
|
|
36
36
|
} from "./index-2bvekkfy.js";
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
StaleRouteHandleError,
|
|
7
7
|
SubcClient,
|
|
8
8
|
isConsumerReconnectTransient
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-6x57ar45.js";
|
|
10
10
|
import {
|
|
11
11
|
getHarness2
|
|
12
12
|
} from "./index-pavzsdc6.js";
|
|
@@ -18,11 +18,11 @@ import {
|
|
|
18
18
|
} from "./index-j75v2476.js";
|
|
19
19
|
import {
|
|
20
20
|
inRootAsyncContext2
|
|
21
|
-
} from "./index-
|
|
21
|
+
} from "./index-beht37jy.js";
|
|
22
22
|
import {
|
|
23
23
|
buildCanonicalChunkTextFromFts,
|
|
24
24
|
loadCompartmentChunkEmbeddingsForSearch
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-b5vqckbw.js";
|
|
26
26
|
import {
|
|
27
27
|
recordEmbeddingMeasurement,
|
|
28
28
|
saveCommitEmbedding,
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
enqueueShadowEmbeddingItems2,
|
|
40
40
|
getProjectEmbeddingSnapshot2,
|
|
41
41
|
embedItemsForProject2
|
|
42
|
-
} from "./index-
|
|
42
|
+
} from "./index-ze7mvk54.js";
|
|
43
43
|
import {
|
|
44
44
|
getProjectEmbeddings2
|
|
45
45
|
} from "./index-4dhv7mqz.js";
|
|
@@ -48,13 +48,13 @@ import {
|
|
|
48
48
|
isEmbeddingEnabled,
|
|
49
49
|
embedText,
|
|
50
50
|
ensureMemoryEmbeddings2
|
|
51
|
-
} from "./index-
|
|
51
|
+
} from "./index-24fezq97.js";
|
|
52
52
|
import {
|
|
53
53
|
ModuleMemoryAuthorityError2,
|
|
54
54
|
getMemoriesByProject2,
|
|
55
55
|
getMemoriesByProjects2,
|
|
56
56
|
updateMemoryRetrievalCount2
|
|
57
|
-
} from "./index-
|
|
57
|
+
} from "./index-n37sebck.js";
|
|
58
58
|
import {
|
|
59
59
|
USER_FACING_FAILURES,
|
|
60
60
|
getNotes,
|
|
@@ -63,20 +63,27 @@ import {
|
|
|
63
63
|
sanitizeFtsQuery,
|
|
64
64
|
searchMemoriesFTS,
|
|
65
65
|
searchMemoriesFTSUnion
|
|
66
|
-
} from "./index-
|
|
67
|
-
import {
|
|
68
|
-
isRecord
|
|
69
|
-
} from "./index-mht7bq0z.js";
|
|
66
|
+
} from "./index-v8awdgvd.js";
|
|
70
67
|
import {
|
|
68
|
+
cleanSearchText,
|
|
69
|
+
keywordRelevance,
|
|
70
|
+
matchedSearchSnippet,
|
|
71
71
|
getIndexedMessageCorpusSize2
|
|
72
|
-
} from "./index-
|
|
72
|
+
} from "./index-cwzfcbtq.js";
|
|
73
|
+
import {
|
|
74
|
+
MESSAGE_FTS_SESSION_FILTER_SQL,
|
|
75
|
+
withMessageFtsSessionFilter
|
|
76
|
+
} from "./index-kaqs6h31.js";
|
|
77
|
+
import {
|
|
78
|
+
isRecord
|
|
79
|
+
} from "./index-hqhm3wke.js";
|
|
73
80
|
import {
|
|
74
81
|
resolveWorkspaceShareCategories,
|
|
75
82
|
resolveWorkspaceIdentitySet,
|
|
76
83
|
expandWorkspaceIdentitySetWithAliases,
|
|
77
84
|
resolveStoredPathWorkspaceIdentity,
|
|
78
85
|
sourceNameForMemory
|
|
79
|
-
} from "./index-
|
|
86
|
+
} from "./index-qn7xstt2.js";
|
|
80
87
|
import {
|
|
81
88
|
isKnownAutocommit
|
|
82
89
|
} from "./index-8ajstryz.js";
|
|
@@ -966,6 +973,10 @@ async function indexCommitsForProject(db, projectPath, directory, options) {
|
|
|
966
973
|
embedded: 0,
|
|
967
974
|
nonIndexable: false
|
|
968
975
|
};
|
|
976
|
+
if (projectPath.startsWith("dir:")) {
|
|
977
|
+
result.nonIndexable = true;
|
|
978
|
+
return result;
|
|
979
|
+
}
|
|
969
980
|
if (indexInProgress.has(projectPath)) {
|
|
970
981
|
log2(`[git-commits] index already in progress for ${projectPath}, skipping`);
|
|
971
982
|
return result;
|
|
@@ -1019,6 +1030,7 @@ async function embedUnembeddedCommits(db, projectPath) {
|
|
|
1019
1030
|
embedInProgress.add(projectPath);
|
|
1020
1031
|
const startedAt = Date.now();
|
|
1021
1032
|
const deadline = startedAt + EMBED_SWEEP_MAX_WALL_CLOCK_MS;
|
|
1033
|
+
const signal = AbortSignal.timeout(EMBED_SWEEP_MAX_WALL_CLOCK_MS);
|
|
1022
1034
|
let total = 0;
|
|
1023
1035
|
try {
|
|
1024
1036
|
while (Date.now() < deadline && total < EMBED_MAX_PER_SWEEP) {
|
|
@@ -1031,7 +1043,7 @@ async function embedUnembeddedCommits(db, projectPath) {
|
|
|
1031
1043
|
id: `commit:${row.sha}`,
|
|
1032
1044
|
text: row.message,
|
|
1033
1045
|
contentSha256: contentSha2562(row.message)
|
|
1034
|
-
})),
|
|
1046
|
+
})), signal, db, projectPath);
|
|
1035
1047
|
if (!result)
|
|
1036
1048
|
break;
|
|
1037
1049
|
db.transaction(() => {
|
|
@@ -1264,61 +1276,6 @@ function searchGitCommitsSync(db, projectPath, query, options) {
|
|
|
1264
1276
|
});
|
|
1265
1277
|
return results.slice(0, options.limit);
|
|
1266
1278
|
}
|
|
1267
|
-
// src/features/magic-context/message-fts-session-filter.ts
|
|
1268
|
-
var MESSAGE_FTS_SESSION_FILTER_SQL = `+message_history_fts.rowid IN (
|
|
1269
|
-
SELECT fts_rowid FROM message_fts_rowid_map WHERE session_id = ?1
|
|
1270
|
-
) AND `;
|
|
1271
|
-
var coverageCaches = new WeakMap;
|
|
1272
|
-
function getCoverageCache(db) {
|
|
1273
|
-
let cache = coverageCaches.get(db);
|
|
1274
|
-
if (!cache) {
|
|
1275
|
-
cache = {
|
|
1276
|
-
pin: db.prepare("SELECT fts_rowid FROM message_fts_rowid_map LIMIT 1"),
|
|
1277
|
-
stamp: db.prepare("SELECT total_changes() AS changes, data_version AS version FROM pragma_data_version"),
|
|
1278
|
-
missing: db.prepare(`SELECT DISTINCT session_id AS sessionId
|
|
1279
|
-
FROM message_history_fts WHERE rowid IN (
|
|
1280
|
-
SELECT id FROM message_history_fts_docsize
|
|
1281
|
-
EXCEPT SELECT fts_rowid FROM message_fts_rowid_map
|
|
1282
|
-
)`)
|
|
1283
|
-
};
|
|
1284
|
-
coverageCaches.set(db, cache);
|
|
1285
|
-
}
|
|
1286
|
-
return cache;
|
|
1287
|
-
}
|
|
1288
|
-
function withMessageFtsSessionFilter(db, sessionId, read) {
|
|
1289
|
-
let cacheable = false;
|
|
1290
|
-
try {
|
|
1291
|
-
const transaction = db;
|
|
1292
|
-
cacheable = transaction.inTransaction === false || transaction.isTransaction === false;
|
|
1293
|
-
if (!cacheable)
|
|
1294
|
-
coverageCaches.delete(db);
|
|
1295
|
-
} catch {
|
|
1296
|
-
coverageCaches.delete(db);
|
|
1297
|
-
}
|
|
1298
|
-
return db.transaction(() => {
|
|
1299
|
-
let sessionFirst = false;
|
|
1300
|
-
try {
|
|
1301
|
-
const cache = getCoverageCache(db);
|
|
1302
|
-
cache.pin.get();
|
|
1303
|
-
const stamp = cache.stamp.get();
|
|
1304
|
-
let incomplete = cache.incompleteSessions;
|
|
1305
|
-
if (!cacheable || !incomplete || cache.version !== stamp.version || cache.changes !== stamp.changes) {
|
|
1306
|
-
const rows = cache.missing.all();
|
|
1307
|
-
incomplete = new Set(rows.map((row) => row.sessionId));
|
|
1308
|
-
if (cacheable) {
|
|
1309
|
-
cache.version = stamp.version;
|
|
1310
|
-
cache.changes = stamp.changes;
|
|
1311
|
-
cache.incompleteSessions = incomplete;
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
sessionFirst = !incomplete.has(sessionId);
|
|
1315
|
-
} catch {
|
|
1316
|
-
coverageCaches.delete(db);
|
|
1317
|
-
}
|
|
1318
|
-
return read(sessionFirst);
|
|
1319
|
-
}).deferred();
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1322
1279
|
// src/features/magic-context/literal-probes.ts
|
|
1323
1280
|
var MAX_PROBES = 5;
|
|
1324
1281
|
var MIN_PROBE_LENGTH = 3;
|
|
@@ -2432,7 +2389,7 @@ function searchMessagesInSnapshot(args, sessionFirst) {
|
|
|
2432
2389
|
const filtered = rows.slice(0, limit);
|
|
2433
2390
|
return filtered.map((row, rank) => ({
|
|
2434
2391
|
source: "message",
|
|
2435
|
-
content: previewText(row.content),
|
|
2392
|
+
content: matchedSearchSnippet(row.content, args.query) || previewText(row.content),
|
|
2436
2393
|
score: linearDecayScore(rank, filtered.length),
|
|
2437
2394
|
messageOrdinal: row.messageOrdinal,
|
|
2438
2395
|
messageId: row.messageId,
|
|
@@ -2509,7 +2466,7 @@ function searchMessagesInSnapshot(args, sessionFirst) {
|
|
|
2509
2466
|
const ranked = [...fused.values()].sort((a, b) => b.score !== a.score ? b.score - a.score : a.row.messageOrdinal - b.row.messageOrdinal).slice(0, resultLimit);
|
|
2510
2467
|
return ranked.map((entry, rank) => ({
|
|
2511
2468
|
source: "message",
|
|
2512
|
-
content: previewText(entry.row.content),
|
|
2469
|
+
content: matchedSearchSnippet(entry.row.content, args.query) || previewText(entry.row.content),
|
|
2513
2470
|
score: linearDecayScore(rank, ranked.length),
|
|
2514
2471
|
messageOrdinal: entry.row.messageOrdinal,
|
|
2515
2472
|
messageId: entry.row.messageId,
|
|
@@ -2732,10 +2689,7 @@ function mergeMessageAndCompartmentResults(args) {
|
|
|
2732
2689
|
}
|
|
2733
2690
|
}
|
|
2734
2691
|
const ranked = [...fused.values()].sort((left, right) => right.score !== left.score ? right.score - left.score : left.tieOrdinal - right.tieOrdinal).slice(0, args.limit);
|
|
2735
|
-
return ranked.map((entry
|
|
2736
|
-
...entry.result,
|
|
2737
|
-
score: linearDecayScore(rank, ranked.length)
|
|
2738
|
-
}));
|
|
2692
|
+
return ranked.map((entry) => entry.result);
|
|
2739
2693
|
}
|
|
2740
2694
|
function getSourceBoost(result) {
|
|
2741
2695
|
switch (result.source) {
|
|
@@ -3013,7 +2967,7 @@ async function unifiedSearch2(db, sessionId, projectPath, query, options = {}) {
|
|
|
3013
2967
|
if (options.diagnostics) {
|
|
3014
2968
|
options.diagnostics.suppressedLiveMessageMatches = outcome.suppressedLiveMessageMatches;
|
|
3015
2969
|
}
|
|
3016
|
-
messageResults = outcome.results;
|
|
2970
|
+
messageResults = outcome.results.filter((result) => result.messageId !== options.excludeMessageId);
|
|
3017
2971
|
if (lanes)
|
|
3018
2972
|
lanes.message_fts = (outcome.laneResults ?? outcome.results).slice(0, 25);
|
|
3019
2973
|
}
|
|
@@ -3146,6 +3100,12 @@ async function unifiedSearch2(db, sessionId, projectPath, query, options = {}) {
|
|
|
3146
3100
|
}).immediate();
|
|
3147
3101
|
}
|
|
3148
3102
|
}
|
|
3103
|
+
if (options.autoHint) {
|
|
3104
|
+
return results.map((result) => ({
|
|
3105
|
+
...result,
|
|
3106
|
+
relevanceScore: cleanSearchText(result.source === "compartment" ? result.title : result.content).length === 0 ? 0 : result.source === "message" || ("matchType" in result) && result.source !== "compartment" && result.matchType !== "semantic" ? keywordRelevance(trimmedQuery, result.content) : result.score
|
|
3107
|
+
}));
|
|
3108
|
+
}
|
|
3149
3109
|
return results;
|
|
3150
3110
|
}
|
|
3151
3111
|
var SEARCH_NOTE_EXPAND_HINT = "Use ctx_expand(start=N-10, end=N) around any note @msg anchor above to read the surrounding conversation context.";
|
|
@@ -3266,4 +3226,4 @@ ${bodyParts.join(`
|
|
|
3266
3226
|
`)}`;
|
|
3267
3227
|
}
|
|
3268
3228
|
|
|
3269
|
-
export { renderSingleStoreMigrationRequiredRefusal, SingleStoreMigrationRequiredError, singleStoreMigrationRequiredFailure, projectNeedsSingleStoreMigration, STORE_AHEAD_OF_BINARY_CODE, storeAheadOfBinaryFailure, TRANSFORM_PAGE_UPLOAD_TIMEOUT_MS, transformColdStartExecuteTimeoutMs, MAX_WRAPUP_REQUEST_BUDGET_MS, getDefaultSubcConnectionFile, isModuleTransportGenerationChangedResult, SubcModuleTransport, indexCommitsForProject, embedUnembeddedCommits,
|
|
3229
|
+
export { renderSingleStoreMigrationRequiredRefusal, SingleStoreMigrationRequiredError, singleStoreMigrationRequiredFailure, projectNeedsSingleStoreMigration, STORE_AHEAD_OF_BINARY_CODE, storeAheadOfBinaryFailure, TRANSFORM_PAGE_UPLOAD_TIMEOUT_MS, transformColdStartExecuteTimeoutMs, MAX_WRAPUP_REQUEST_BUDGET_MS, getDefaultSubcConnectionFile, isModuleTransportGenerationChangedResult, SubcModuleTransport, indexCommitsForProject, embedUnembeddedCommits, createUnifiedSearchDiagnostics2, searchMessageHistory2, parseIdShapedQuery2, resolveMemoriesByIdsForSearch2, unifiedSearch2, formatSearchResults2 };
|
|
@@ -5517,18 +5517,18 @@ var OmpEntryObjectSchema = object({
|
|
|
5517
5517
|
}).strict();
|
|
5518
5518
|
var OmpEntrySchema = union([string(), OmpEntryObjectSchema]);
|
|
5519
5519
|
var OpenCodeHarnessBlockSchema = object({
|
|
5520
|
-
model: OcEntrySchema.optional().describe("Primary OpenCode model entry."),
|
|
5521
|
-
fallback_models: array(OcEntrySchema).optional().describe("Ordered fallback OpenCode entries.
|
|
5520
|
+
model: OcEntrySchema.optional().describe("Primary historian OpenCode model entry. When set, only this model and fallback_models are used; exhaustion reports failure, never the session model. When absent, OpenCode inherits the session model."),
|
|
5521
|
+
fallback_models: array(OcEntrySchema).optional().describe("Ordered historian fallback OpenCode entries. A configured primary never adds the session model after this list. Requires an array; legacy singleton values migrate to a one-element array."),
|
|
5522
5522
|
variant: string().optional().describe("OpenCode reasoning variant for the primary entry when it declares none. Fallback entries declare variants per-entry.")
|
|
5523
5523
|
}).strict().describe("Strict OpenCode model-resolution block. It accepts no Pi vocabulary.");
|
|
5524
5524
|
var PiHarnessBlockSchema = object({
|
|
5525
|
-
model: PiEntrySchema.optional().describe("Primary Pi model entry."),
|
|
5526
|
-
fallback_models: array(PiEntrySchema).optional().describe("Ordered fallback Pi entries.
|
|
5525
|
+
model: PiEntrySchema.optional().describe("Primary historian Pi model entry. When set, only this model and fallback_models are used; exhaustion reports failure, never the session model. When absent, Pi does not run the historian."),
|
|
5526
|
+
fallback_models: array(PiEntrySchema).optional().describe("Ordered historian fallback Pi entries. The session model is never appended. Requires an array; legacy singleton values migrate to a one-element array."),
|
|
5527
5527
|
thinking_level: PiThinkingLevelSchema.describe("Pi thinking level for the primary entry when it declares none. Fallback entries declare thinking levels per-entry.")
|
|
5528
5528
|
}).strict().describe("Strict Pi model-resolution block. It accepts no OpenCode vocabulary.");
|
|
5529
5529
|
var OmpHarnessBlockSchema = object({
|
|
5530
|
-
model: OmpEntrySchema.optional().describe("Primary OMP model entry."),
|
|
5531
|
-
fallback_models: array(OmpEntrySchema).optional().describe("Ordered fallback OMP entries."),
|
|
5530
|
+
model: OmpEntrySchema.optional().describe("Primary historian OMP model entry. When set, only this model and fallback_models are used; exhaustion reports failure, never the session model. An absent OMP block inherits the Pi block; a selected block without a model does not run the historian."),
|
|
5531
|
+
fallback_models: array(OmpEntrySchema).optional().describe("Ordered historian fallback OMP entries. The session model is never appended."),
|
|
5532
5532
|
thinking_level: OmpThinkingLevelSchema.describe("OMP thinking level for the primary entry when it declares none. Fallback entries declare thinking levels per-entry.")
|
|
5533
5533
|
}).strict().describe("Strict OMP model-resolution block. It accepts no OpenCode vocabulary.");
|
|
5534
5534
|
var OpenCodeTaskExecutionSchema = object({
|