@cortexkit/opencode-magic-context 0.49.11 → 0.49.13
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/README.md +1 -1
- package/dist/agents/smart-notes-dreamer-gate.fixture.d.ts +28 -0
- package/dist/agents/smart-notes-dreamer-gate.fixture.d.ts.map +1 -0
- package/dist/{announcement-hdbkt8v5.js → announcement-g789dmt6.js} +2 -2
- package/dist/auto-search-worker.js +4 -4
- package/dist/chunk-embedding-write-worker.js +89 -0
- package/dist/{compaction-marker-candidates-xxz35vwp.js → compaction-marker-candidates-v5c6997n.js} +3 -3
- package/dist/compaction-marker-candidates-worker.js +1 -1
- package/dist/config/agent-disable.d.ts +14 -0
- package/dist/config/agent-disable.d.ts.map +1 -1
- package/dist/config/dependency-notes.d.ts +34 -0
- package/dist/config/dependency-notes.d.ts.map +1 -0
- package/dist/config/schema/agent-overrides.d.ts +12 -12
- package/dist/config/schema/magic-context.d.ts +88 -88
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-xwkfncav.js → conflict-warning-hook-mgq17yr3.js} +8 -8
- package/dist/{context-twz3s0cg.js → context-azqk0vfd.js} +121 -145
- package/dist/{derive-budgets-3nbxsyss.js → derive-budgets-zn7yzd2d.js} +3 -3
- package/dist/embedding-backfill-5e1t5wha.js +22 -0
- package/dist/embedding-worker-process.js +2 -2
- package/dist/embedding-worker.js +6 -6
- package/dist/features/magic-context/chunk-embedding-write-worker.d.ts +2 -0
- package/dist/features/magic-context/chunk-embedding-write-worker.d.ts.map +1 -0
- package/dist/features/magic-context/chunk-embedding-writer.d.ts +48 -0
- package/dist/features/magic-context/chunk-embedding-writer.d.ts.map +1 -0
- 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/dreamer/hidden-single-shot.d.ts +3 -2
- package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/map-memories.d.ts +8 -1
- package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts +2 -0
- package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts +5 -0
- package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-config.d.ts +22 -4
- package/dist/features/magic-context/dreamer/task-config.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-registry.d.ts +22 -0
- package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts +4 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify-prompt.d.ts +6 -1
- package/dist/features/magic-context/dreamer/verify-prompt.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify.d.ts +25 -11
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-openai.d.ts +32 -0
- package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
- package/dist/features/magic-context/memory/project-identity.d.ts +1 -0
- package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
- package/dist/features/magic-context/memory/unborn-head.d.ts +34 -0
- package/dist/features/magic-context/memory/unborn-head.d.ts.map +1 -0
- package/dist/features/magic-context/mural/compress-cues.d.ts +3 -0
- package/dist/features/magic-context/mural/compress-cues.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +5 -0
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +2 -0
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/{history-owner-ty29fz0f.js → history-owner-xp3pngv7.js} +3 -3
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-embed-session.d.ts +10 -0
- package/dist/hooks/magic-context/auto-embed-session.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-prompt.d.ts +6 -0
- package/dist/hooks/magic-context/compartment-prompt.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-types.d.ts +3 -0
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger-error.d.ts +12 -0
- package/dist/hooks/magic-context/compartment-trigger-error.d.ts.map +1 -0
- package/dist/hooks/magic-context/embed-session-state.d.ts +8 -1
- package/dist/hooks/magic-context/embed-session-state.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-prompt-fit.d.ts +2 -0
- package/dist/hooks/magic-context/historian-prompt-fit.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +3 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/pending-materialization.d.ts +2 -0
- package/dist/hooks/magic-context/pending-materialization.d.ts.map +1 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts +12 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/raw-exact-ordinal-read.d.ts +58 -0
- package/dist/hooks/magic-context/raw-exact-ordinal-read.d.ts.map +1 -0
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts +7 -0
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-raw.d.ts +19 -0
- package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts +2 -0
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts +2 -0
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +4 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
- package/dist/{index-bzp9s8z2.js → index-1d289pq2.js} +2 -2
- package/dist/{index-w28y7d0z.js → index-1sarmj9z.js} +15 -15
- package/dist/{index-z7avx6rw.js → index-2jr1smmh.js} +280 -160
- package/dist/{index-4ccdr7yw.js → index-3kdm78zp.js} +5 -5
- package/dist/{index-9159kk15.js → index-3kx0kg0f.js} +64 -7
- package/dist/{index-0jz47061.js → index-a8bvhwqs.js} +190 -30
- package/dist/{index-84j7jq8a.js → index-aw1bh90w.js} +10 -10
- package/dist/{index-qr1mkc2y.js → index-b16gpywn.js} +9 -9
- package/dist/{index-g7jkrz0x.js → index-bp5083x2.js} +1 -1
- package/dist/{index-yhrrx7qa.js → index-bxdg2nbt.js} +3 -3
- package/dist/{index-0abg88h2.js → index-dgs16axy.js} +4 -4
- package/dist/{index-mp2kghkv.js → index-dyvbsvga.js} +1 -1
- package/dist/{index-bmwfzz28.js → index-e20m7284.js} +4 -4
- package/dist/{index-4jkhhpn1.js → index-e4dsjj1p.js} +3 -3
- package/dist/{index-s178h9z8.js → index-f71thw8j.js} +1 -1
- package/dist/{index-kvw6xew3.js → index-fkx2qnvw.js} +2 -2
- package/dist/{index-f8cn4xqa.js → index-fwefky9w.js} +18 -5
- package/dist/{index-0sahzkwr.js → index-g2q4htwp.js} +46 -2
- package/dist/{index-mw7c950g.js → index-gp3kcpc4.js} +1 -1
- package/dist/{index-g40wgxxt.js → index-hnm8raee.js} +4 -4
- package/dist/{index-gjvjh960.js → index-hqkczed7.js} +1 -1
- package/dist/{index-mvvephtj.js → index-j75v2476.js} +1 -1
- package/dist/{index-150zz6fh.js → index-k29z4aqh.js} +1 -1
- package/dist/{index-b64n4d0h.js → index-kee4kn5j.js} +1 -1
- package/dist/index-ksdyrrav.js +52 -0
- package/dist/{index-angx1s0k.js → index-mmfa86mt.js} +16 -6
- package/dist/{index-9jvab89d.js → index-n6m03s3n.js} +2 -2
- package/dist/{index-q28hsbpg.js → index-nj7yykkx.js} +1 -1
- package/dist/{index-ghc9f0n7.js → index-p5y3k4g7.js} +29 -1
- package/dist/{index-xztdf9t7.js → index-qkd9zz0p.js} +17 -17
- package/dist/index-saews2s3.js +229 -0
- package/dist/{index-kkvxnbt8.js → index-sj89f3b0.js} +62 -33
- package/dist/{index-jw4gbfkv.js → index-v10f1rjv.js} +5 -5
- package/dist/{index-0j6crjgh.js → index-v13skev1.js} +13 -13
- package/dist/{index-hqnggmxn.js → index-wj6ht7nm.js} +547 -179
- package/dist/{index-a865mj02.js → index-wk0n1cgt.js} +4 -4
- package/dist/{index-q3qck7j2.js → index-wz6mzzb1.js} +6 -5
- package/dist/{index-se1w3v2m.js → index-y1qysm3q.js} +332 -256
- package/dist/{index-a4b0gbyg.js → index-y9f76s3f.js} +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +119 -129
- package/dist/{logger-wn328tfg.js → logger-jm3sqqzr.js} +2 -2
- package/dist/{message-index-bounded-0rbbg9rd.js → message-index-bounded-vm64mqpq.js} +16 -16
- package/dist/{message-index-ct5x2kwa.js → message-index-seaqpb7c.js} +16 -16
- package/dist/{message-time-backfill-nb5hhnrt.js → message-time-backfill-qjge9044.js} +3 -3
- package/dist/migration-worker.js +11 -11
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/tool-registry.d.ts.map +1 -1
- package/dist/{project-embedding-registry-ft9gh2e2.js → project-embedding-registry-x45bv3qr.js} +12 -11
- package/dist/raw-ordinal-warmup-worker.js +12 -7
- package/dist/{read-session-chunk-y3hhsbzw.js → read-session-chunk-ax05f7gr.js} +11 -11
- package/dist/{read-session-raw-gm6xj30v.js → read-session-raw-m56hc7v2.js} +7 -3
- package/dist/recomp-orchestrator-dmbeadwt.js +61 -0
- package/dist/{safe-notification-target-jdynm677.js → safe-notification-target-1szv1k5k.js} +3 -3
- package/dist/{search-jd8xh721.js → search-5yd5ytzs.js} +25 -24
- package/dist/{send-session-notification-vzhj8bsg.js → send-session-notification-24r4esbh.js} +6 -6
- package/dist/shared/data-path.d.ts +4 -0
- package/dist/shared/data-path.d.ts.map +1 -1
- package/dist/shared/model-suggestion-retry.d.ts +2 -0
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- package/dist/shared/prompt-async-transport.d.ts.map +1 -1
- package/dist/{storage-tags-35m4gms2.js → storage-tags-yygfb9c8.js} +7 -5
- package/dist/{task-config-cgpg0nvh.js → task-config-x3qmayd2.js} +6 -2
- package/dist/tools/ctx-note/tools.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-pmqxfq4q.js → transform-postprocess-phase-72v86syx.js} +32 -31
- package/dist/v2/auto-search-worker.js +4 -4
- package/dist/v2/chunk-embedding-write-worker.js +88 -0
- package/dist/v2/{compaction-marker-candidates-a15w3mqh.js → compaction-marker-candidates-1vqwr3s5.js} +2 -2
- package/dist/v2/compaction-marker-candidates-worker.js +1 -1
- package/dist/v2/{context-p1zfcw41.js → context-w055w17c.js} +628 -255
- package/dist/v2/{derive-budgets-0rmpmxjw.js → derive-budgets-2zh4gm2c.js} +3 -3
- package/dist/v2/embedding-backfill-jmaf8zrr.js +21 -0
- package/dist/v2/embedding-worker-process.js +1 -1
- package/dist/v2/embedding-worker.js +5 -5
- package/dist/v2/{history-owner-2cr9py37.js → history-owner-42e16w0n.js} +2 -2
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/dream-manual.d.ts.map +1 -1
- package/dist/v2/hooks/dream-trigger.d.ts +1 -1
- package/dist/v2/hooks/dream-trigger.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
- package/dist/v2/hooks/transform-features.d.ts +3 -2
- package/dist/v2/hooks/transform-features.d.ts.map +1 -1
- package/dist/v2/{logger-te6e1j72.js → logger-7qt02bnb.js} +1 -1
- package/dist/v2/{message-index-bounded-7wcbp975.js → message-index-bounded-wepg5723.js} +15 -15
- package/dist/v2/{message-index-cjhv92m2.js → message-index-gcmd0ng0.js} +15 -15
- package/dist/v2/{message-time-backfill-rz1pnpaj.js → message-time-backfill-bsteyc4d.js} +2 -2
- package/dist/v2/migration-worker.js +10 -10
- package/dist/v2/{project-embedding-registry-g34gcf74.js → project-embedding-registry-0msp56p8.js} +11 -10
- package/dist/v2/raw-ordinal-warmup-worker.js +12 -7
- package/dist/v2/{read-session-chunk-8d3v87vr.js → read-session-chunk-hr3w5bjk.js} +10 -10
- package/dist/v2/{read-session-raw-h4azh85b.js → read-session-raw-b3tf6ra1.js} +6 -2
- package/dist/v2/recomp-orchestrator-ca7qt75a.js +60 -0
- package/dist/v2/retrospective-raw-provider.d.ts.map +1 -1
- package/dist/v2/{safe-notification-target-936374xx.js → safe-notification-target-qg7n2s77.js} +2 -2
- package/dist/v2/{search-a1acjwf8.js → search-c86dcv14.js} +24 -23
- package/dist/v2/{send-session-notification-z5mcjdea.js → send-session-notification-8ghn9tnv.js} +5 -5
- package/dist/v2/{server-npm52h2q.js → server-05xjtq6c.js} +1 -1
- package/dist/v2/{server-s6jqh8bj.js → server-0ppsweh6.js} +1 -1
- package/dist/v2/server-0s95v3en.js +49 -0
- package/dist/v2/{server-hn9fb3v0.js → server-34kwfsr4.js} +2 -2
- package/dist/v2/server-4gn3z5an.js +229 -0
- package/dist/v2/{server-kn7skz9r.js → server-6cdy4rc0.js} +3 -3
- package/dist/v2/{server-7dv9wt9r.js → server-6pmqg9m4.js} +1 -1
- package/dist/v2/{server-7fvmt15t.js → server-b81w6sw3.js} +273 -107
- package/dist/v2/{server-kmapq3v0.js → server-bxpwy6fy.js} +18 -5
- package/dist/v2/{server-d6t16r89.js → server-d8tj10db.js} +1 -1
- package/dist/v2/{server-cxsr0ng6.js → server-da07v4xp.js} +1 -1
- package/dist/v2/{server-rxcq4t50.js → server-ef89gdsx.js} +5 -5
- package/dist/v2/{server-9e5r8y60.js → server-f2xf5gcb.js} +46 -2
- package/dist/v2/{server-83d71zab.js → server-g10mdym6.js} +3 -3
- package/dist/v2/{server-njnx39q2.js → server-gvkm8xaj.js} +189 -29
- package/dist/v2/{server-ckrb5rm8.js → server-h0410h0v.js} +1 -1
- package/dist/v2/{server-sg68np13.js → server-hek6z3w6.js} +330 -254
- package/dist/v2/{server-f27he3j1.js → server-k2bzedxk.js} +4 -4
- package/dist/v2/{server-wkhfyzpg.js → server-m97brnat.js} +9 -9
- package/dist/v2/{server-erfp0xb6.js → server-n8ch9683.js} +16 -16
- package/dist/v2/{server-bx59ezg6.js → server-prg55b7k.js} +16 -6
- package/dist/v2/{server-89fcbe37.js → server-pwv4ezb0.js} +1 -1
- package/dist/v2/{server-r5p3b1wy.js → server-qd11g795.js} +29 -1
- package/dist/v2/{server-ewqshbs8.js → server-qhfvvfxj.js} +64 -7
- package/dist/v2/{server-988cqjme.js → server-rrqpvwqd.js} +2 -2
- package/dist/v2/{server-d3f4g62c.js → server-t4prcjc1.js} +13 -13
- package/dist/v2/{server-nveratm5.js → server-tbe1femw.js} +4 -4
- package/dist/v2/{server-jc8v585p.js → server-th4y11y7.js} +15 -15
- package/dist/v2/{server-h3wc20sv.js → server-vbe4se57.js} +4 -4
- package/dist/v2/{server-pbpp8r8h.js → server-xh7jar6k.js} +9 -9
- package/dist/v2/{server-63ha7f0f.js → server-yrvqaswb.js} +1 -1
- package/dist/v2/{server-5x7kmyz8.js → server-zc3e54vy.js} +10 -51
- package/dist/v2/{server-xqf2d2mg.js → server-zs8d0s3b.js} +2 -2
- package/dist/v2/server.d.ts.map +1 -1
- package/dist/v2/server.js +18 -10
- package/dist/v2/{storage-tags-c4zfcxv4.js → storage-tags-a2gq6dw7.js} +6 -4
- package/dist/v2/store-reader.d.ts +1 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{task-config-x0hq3qfd.js → task-config-nvz8mapa.js} +6 -2
- package/dist/v2/{wrapup-orchestrator-87q9d5e2.js → wrapup-orchestrator-e1a2w6jh.js} +31 -29
- package/dist/wrapup-orchestrator-2051r6qm.js +48 -0
- package/package.json +6 -5
- package/src/agents/smart-notes-dreamer-gate.fixture.ts +171 -0
- package/src/agents/smart-notes-dreamer-gate.golden.json +245 -0
- package/src/agents/smart-notes-dreamer-gate.test.ts +161 -0
- package/src/config/agent-disable.ts +13 -0
- package/src/config/dependency-notes.test.ts +114 -0
- package/src/config/dependency-notes.ts +80 -0
- package/src/config/schema/magic-context.ts +23 -14
- package/src/features/magic-context/dreamer/task-registry.ts +40 -0
- package/src/shared/data-path.test.ts +35 -1
- package/src/shared/data-path.ts +57 -1
- package/src/shared/model-suggestion-retry.test.ts +34 -0
- package/src/shared/model-suggestion-retry.ts +23 -3
- package/src/shared/prompt-async-transport.test.ts +1 -1
- package/src/shared/prompt-async-transport.ts +16 -3
- package/dist/embedding-backfill-fjbfh1dt.js +0 -21
- package/dist/recomp-orchestrator-67k45s0b.js +0 -60
- package/dist/v2/embedding-backfill-xcw3t6hp.js +0 -20
- package/dist/v2/recomp-orchestrator-n0pq36f0.js +0 -59
- package/dist/wrapup-orchestrator-jqapepw0.js +0 -47
- /package/dist/{index-e6xnpach.js → index-b7p25tm0.js} +0 -0
- /package/dist/v2/{index-e6xnpach.js → index-b7p25tm0.js} +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-1sarmj9z.js";
|
|
4
4
|
import {
|
|
5
5
|
log2
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-j75v2476.js";
|
|
7
7
|
import {
|
|
8
8
|
isSynapseEmbeddingTruncated,
|
|
9
9
|
SynapseEmbeddingProvider
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-fkx2qnvw.js";
|
|
11
11
|
import {
|
|
12
12
|
LocalEmbeddingProvider
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-e20m7284.js";
|
|
14
14
|
import {
|
|
15
15
|
OpenAICompatibleEmbeddingProvider,
|
|
16
16
|
getProjectEmbeddingSnapshot2,
|
|
17
17
|
embedBatchForProject2
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-y1qysm3q.js";
|
|
19
19
|
import {
|
|
20
20
|
isEmbeddingHostBusy2
|
|
21
21
|
} from "./index-qt1qqasc.js";
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getTokenEstimatorFingerprint,
|
|
3
3
|
estimateTokens
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-hqkczed7.js";
|
|
5
5
|
import {
|
|
6
6
|
getHarness2
|
|
7
7
|
} from "./index-pavzsdc6.js";
|
|
8
8
|
import {
|
|
9
9
|
log2
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-j75v2476.js";
|
|
11
11
|
import {
|
|
12
12
|
isSynapseEmbeddingTruncated
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-fkx2qnvw.js";
|
|
14
14
|
import {
|
|
15
15
|
messageFtsOrdinalRangeIsMapped
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-dyvbsvga.js";
|
|
17
17
|
|
|
18
18
|
// src/features/magic-context/compartment-chunk-embedding.ts
|
|
19
19
|
import { createHash } from "node:crypto";
|
|
@@ -858,13 +858,17 @@ function loadUnembeddedShadowChunkCandidates(db, projectPath, primaryModelId, sh
|
|
|
858
858
|
const rows = getShadowBackfillCandidateStatement(db).all(projectPath, projectPath, primaryModelId);
|
|
859
859
|
return selectHashIncompleteChunkCandidates(db, projectPath, shadowModelId, mapBackfillCandidateRows(rows), Math.max(1, limit), shadowMaxInputTokens);
|
|
860
860
|
}
|
|
861
|
-
async function loadUnembeddedCompartmentChunkCandidatesPolite(db, projectPath, modelId, limit, maxInputTokens = DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS, leaseHeldRenumber = false) {
|
|
861
|
+
async function loadUnembeddedCompartmentChunkCandidatesPolite(db, projectPath, modelId, limit, maxInputTokens = DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS, leaseHeldRenumber = false, isEligible) {
|
|
862
862
|
const rows = getBackfillCandidateStatement(db).all(projectPath);
|
|
863
863
|
const candidates = mapBackfillCandidateRows(rows);
|
|
864
864
|
const missing = [];
|
|
865
865
|
const stale = [];
|
|
866
866
|
let sliceStarted = performance.now();
|
|
867
867
|
for (const candidate of candidates) {
|
|
868
|
+
if (isEligible && !isEligible(candidate)) {
|
|
869
|
+
sliceStarted = await yieldCoverageSlice(sliceStarted);
|
|
870
|
+
continue;
|
|
871
|
+
}
|
|
868
872
|
const classification = classifyChunkCoverageDefect(db, projectPath, modelId, candidate, maxInputTokens);
|
|
869
873
|
if (classification.defect === "missing")
|
|
870
874
|
missing.push(candidate);
|
|
@@ -1019,7 +1023,7 @@ function memoizedCoverageWindows(candidate, canonicalText, sourceKey, modelId, m
|
|
|
1019
1023
|
return windows;
|
|
1020
1024
|
}
|
|
1021
1025
|
async function yieldCoverageSlice(started) {
|
|
1022
|
-
if (performance.now() - started <
|
|
1026
|
+
if (performance.now() - started < 8)
|
|
1023
1027
|
return started;
|
|
1024
1028
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
1025
1029
|
return performance.now();
|
|
@@ -1093,6 +1097,47 @@ function selectHashIncompleteChunkCandidates(db, projectPath, modelId, candidate
|
|
|
1093
1097
|
return [...missing, ...stale].slice(0, limit);
|
|
1094
1098
|
}
|
|
1095
1099
|
var sessionBackfillCandidateStatements = new WeakMap;
|
|
1100
|
+
function loadUnembeddedSessionChunkCandidates(db, projectPath, sessionId, modelId, limit, excludeIds, maxInputTokens = DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS, leaseHeldRenumber = false) {
|
|
1101
|
+
const exclusions = excludeIds && excludeIds.length > 0 ? excludeIds : [];
|
|
1102
|
+
const exclusionSql = exclusions.length > 0 ? `AND c.id NOT IN (${exclusions.map(() => "?").join(", ")})` : "";
|
|
1103
|
+
const stmt = exclusions.length > 0 ? db.prepare(`SELECT c.id AS id,
|
|
1104
|
+
c.session_id AS sessionId,
|
|
1105
|
+
c.start_message AS startMessage,
|
|
1106
|
+
c.end_message AS endMessage,
|
|
1107
|
+
c.title AS title
|
|
1108
|
+
FROM compartments c
|
|
1109
|
+
JOIN session_projects sp
|
|
1110
|
+
ON sp.session_id = c.session_id
|
|
1111
|
+
AND sp.harness = c.harness
|
|
1112
|
+
AND sp.project_path = ?
|
|
1113
|
+
WHERE c.session_id = ?
|
|
1114
|
+
AND c.start_message IS NOT NULL
|
|
1115
|
+
AND c.end_message IS NOT NULL
|
|
1116
|
+
${exclusionSql}
|
|
1117
|
+
ORDER BY c.start_message ASC, c.id ASC`) : (() => {
|
|
1118
|
+
let cached = sessionBackfillCandidateStatements.get(db);
|
|
1119
|
+
if (!cached) {
|
|
1120
|
+
cached = db.prepare(`SELECT c.id AS id,
|
|
1121
|
+
c.session_id AS sessionId,
|
|
1122
|
+
c.start_message AS startMessage,
|
|
1123
|
+
c.end_message AS endMessage,
|
|
1124
|
+
c.title AS title
|
|
1125
|
+
FROM compartments c
|
|
1126
|
+
JOIN session_projects sp
|
|
1127
|
+
ON sp.session_id = c.session_id
|
|
1128
|
+
AND sp.harness = c.harness
|
|
1129
|
+
AND sp.project_path = ?
|
|
1130
|
+
WHERE c.session_id = ?
|
|
1131
|
+
AND c.start_message IS NOT NULL
|
|
1132
|
+
AND c.end_message IS NOT NULL
|
|
1133
|
+
ORDER BY c.start_message ASC, c.id ASC`);
|
|
1134
|
+
sessionBackfillCandidateStatements.set(db, cached);
|
|
1135
|
+
}
|
|
1136
|
+
return cached;
|
|
1137
|
+
})();
|
|
1138
|
+
const rows = stmt.all(projectPath, sessionId, ...exclusions);
|
|
1139
|
+
return selectHashIncompleteChunkCandidates(db, projectPath, modelId, mapBackfillCandidateRows(rows), Math.max(1, limit), maxInputTokens, leaseHeldRenumber);
|
|
1140
|
+
}
|
|
1096
1141
|
async function loadUnembeddedSessionChunkCandidatesPolite(db, projectPath, sessionId, modelId, limit, excludeIds = [], maxInputTokens = DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS, leaseHeldRenumber = false) {
|
|
1097
1142
|
const excluded = new Set(excludeIds);
|
|
1098
1143
|
const missing = [];
|
|
@@ -1109,10 +1154,22 @@ async function loadUnembeddedSessionChunkCandidatesPolite(db, projectPath, sessi
|
|
|
1109
1154
|
else if (leaseHeldRenumber) {
|
|
1110
1155
|
applyLeaseHeldCoverageRepair(db, candidate, projectPath, modelId, classification);
|
|
1111
1156
|
}
|
|
1157
|
+
if (missing.length >= Math.max(1, limit))
|
|
1158
|
+
return missing;
|
|
1112
1159
|
started = await yieldCoverageSlice(started);
|
|
1113
1160
|
}
|
|
1114
1161
|
return [...missing, ...stale].slice(0, Math.max(1, limit));
|
|
1115
1162
|
}
|
|
1163
|
+
function countUnembeddedSessionCompartments(db, projectPath, sessionId, modelId, maxInputTokens = DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS) {
|
|
1164
|
+
const rows = getSessionBackfillRows(db, projectPath, sessionId);
|
|
1165
|
+
let count = 0;
|
|
1166
|
+
for (const candidate of rows) {
|
|
1167
|
+
const { defect } = classifyChunkCoverageDefect(db, projectPath, modelId, candidate, maxInputTokens);
|
|
1168
|
+
if (defect === "missing" || defect === "stale")
|
|
1169
|
+
count++;
|
|
1170
|
+
}
|
|
1171
|
+
return count;
|
|
1172
|
+
}
|
|
1116
1173
|
function countSessionCompartmentEmbedCoverage(db, projectPath, sessionId, modelId, maxInputTokens = DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS) {
|
|
1117
1174
|
const candidates = getSessionBackfillRows(db, projectPath, sessionId);
|
|
1118
1175
|
let embedded = 0;
|
|
@@ -1165,4 +1222,4 @@ async function countUnembeddedSessionCompartmentsPolite(db, projectPath, session
|
|
|
1165
1222
|
return count;
|
|
1166
1223
|
}
|
|
1167
1224
|
|
|
1168
|
-
export { CHUNK_WINDOW_SAFETY_RATIO, normalizeCompartmentChunkMaxInputTokens, buildCanonicalChunkTextFromFts, buildCompartmentSummaryFallbackText, canonicalizeInMemoryChunkTextForEmbedding, chunkCanonicalText, chunkEmbeddingWindowsAreCurrent, replaceCompartmentChunkEmbeddings, loadCompartmentChunkEmbeddingsForSearch, loadUnembeddedShadowChunkCandidates, loadUnembeddedCompartmentChunkCandidatesPolite, deleteChunkEmbedBackoffForSession, recordChunkEmbedBackoff, chunkWindowSourceKey, loadUnembeddedSessionChunkCandidatesPolite, countSessionCompartmentEmbedCoverage, countSessionCompartmentEmbedCoveragePolite, countUnembeddedSessionCompartmentsPolite };
|
|
1225
|
+
export { DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS, CHUNK_WINDOW_SAFETY_RATIO, normalizeCompartmentChunkMaxInputTokens, buildCanonicalChunkTextFromFts, buildCompartmentSummaryFallbackText, canonicalizeInMemoryChunkTextForEmbedding, chunkCanonicalText, chunkEmbeddingWindowsAreCurrent, replaceCompartmentChunkEmbeddings, loadCompartmentChunkEmbeddingsForSearch, loadUnembeddedShadowChunkCandidates, loadUnembeddedCompartmentChunkCandidatesPolite, deleteChunkEmbedBackoffForSession, recordChunkEmbedBackoff, chunkWindowSourceKey, loadUnembeddedSessionChunkCandidates, loadUnembeddedSessionChunkCandidatesPolite, countUnembeddedSessionCompartments, countSessionCompartmentEmbedCoverage, countSessionCompartmentEmbedCoveragePolite, countUnembeddedSessionCompartmentsPolite };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getMagicContextStorageDir
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-g2q4htwp.js";
|
|
4
4
|
import {
|
|
5
5
|
log2
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-j75v2476.js";
|
|
7
7
|
import {
|
|
8
8
|
inRootAsyncContext2
|
|
9
9
|
} from "./index-wafzvyhg.js";
|
|
@@ -17,9 +17,9 @@ import {
|
|
|
17
17
|
// src/features/magic-context/memory/project-identity.ts
|
|
18
18
|
import { execFileSync } from "node:child_process";
|
|
19
19
|
import { createHash as createHash2 } from "node:crypto";
|
|
20
|
-
import { existsSync, realpathSync, statSync } from "node:fs";
|
|
20
|
+
import { existsSync, realpathSync as realpathSync2, statSync as statSync2 } from "node:fs";
|
|
21
21
|
import { homedir } from "node:os";
|
|
22
|
-
import
|
|
22
|
+
import path3 from "node:path";
|
|
23
23
|
|
|
24
24
|
// src/features/magic-context/memory/project-identity-cache.ts
|
|
25
25
|
import { createHash } from "node:crypto";
|
|
@@ -44,6 +44,162 @@ function readRememberedGitIdentity(directory, storageDir) {
|
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
// src/features/magic-context/memory/unborn-head.ts
|
|
48
|
+
import { readFileSync as readFileSync2, realpathSync, statSync } from "node:fs";
|
|
49
|
+
import path2 from "node:path";
|
|
50
|
+
var GIT_LOCATION_ENV_VARS = [
|
|
51
|
+
"GIT_DIR",
|
|
52
|
+
"GIT_COMMON_DIR",
|
|
53
|
+
"GIT_WORK_TREE",
|
|
54
|
+
"GIT_CEILING_DIRECTORIES"
|
|
55
|
+
];
|
|
56
|
+
function errorCode(error) {
|
|
57
|
+
if (error === null || typeof error !== "object" || !("code" in error))
|
|
58
|
+
return;
|
|
59
|
+
const code = error.code;
|
|
60
|
+
return typeof code === "string" ? code : undefined;
|
|
61
|
+
}
|
|
62
|
+
function readText(file) {
|
|
63
|
+
try {
|
|
64
|
+
return { ok: true, text: readFileSync2(file, "utf8") };
|
|
65
|
+
} catch (error) {
|
|
66
|
+
return { ok: false, missing: errorCode(error) === "ENOENT" };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function entryKind(entry) {
|
|
70
|
+
try {
|
|
71
|
+
const stat = statSync(entry);
|
|
72
|
+
if (stat.isFile())
|
|
73
|
+
return "file";
|
|
74
|
+
if (stat.isDirectory())
|
|
75
|
+
return "directory";
|
|
76
|
+
return "other";
|
|
77
|
+
} catch (error) {
|
|
78
|
+
return errorCode(error) === "ENOENT" ? "missing" : "error";
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function stripLineEnding(text) {
|
|
82
|
+
return text.replace(/\r?\n$/u, "");
|
|
83
|
+
}
|
|
84
|
+
function resolveMetadataPath(baseDirectory, value) {
|
|
85
|
+
return path2.resolve(baseDirectory, value);
|
|
86
|
+
}
|
|
87
|
+
function isPlainBranchName(name) {
|
|
88
|
+
if (name.length === 0 || name.endsWith("/") || name.endsWith("."))
|
|
89
|
+
return false;
|
|
90
|
+
if (name.includes("..") || name.includes("//") || name.includes("@{"))
|
|
91
|
+
return false;
|
|
92
|
+
for (const character of name) {
|
|
93
|
+
const code = character.charCodeAt(0);
|
|
94
|
+
if (code <= 32 || code === 127 || "~^:?*[\\".includes(character))
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
return name.split("/").every((component) => !component.startsWith(".") && !component.endsWith(".lock"));
|
|
98
|
+
}
|
|
99
|
+
function findGitDirectory(start) {
|
|
100
|
+
let current = start;
|
|
101
|
+
while (true) {
|
|
102
|
+
const dotGit = path2.join(current, ".git");
|
|
103
|
+
const kind = entryKind(dotGit);
|
|
104
|
+
if (kind === "directory")
|
|
105
|
+
return dotGit;
|
|
106
|
+
if (kind === "file") {
|
|
107
|
+
const read = readText(dotGit);
|
|
108
|
+
if (!read.ok)
|
|
109
|
+
return;
|
|
110
|
+
const match = /^gitdir: (.+)$/u.exec(stripLineEnding(read.text));
|
|
111
|
+
if (!match?.[1] || match[1].includes(`
|
|
112
|
+
`))
|
|
113
|
+
return;
|
|
114
|
+
return resolveMetadataPath(current, match[1]);
|
|
115
|
+
}
|
|
116
|
+
if (kind !== "missing")
|
|
117
|
+
return;
|
|
118
|
+
const parent = path2.dirname(current);
|
|
119
|
+
if (parent === current)
|
|
120
|
+
return;
|
|
121
|
+
current = parent;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function packedRefsList(text, ref) {
|
|
125
|
+
for (const rawLine of text.split(`
|
|
126
|
+
`)) {
|
|
127
|
+
const line = rawLine.replace(/\r$/u, "");
|
|
128
|
+
if (line === "" || line.startsWith("#") || line.startsWith("^"))
|
|
129
|
+
continue;
|
|
130
|
+
const match = /^[0-9a-f]{40,64} (\S+)$/u.exec(line);
|
|
131
|
+
if (!match)
|
|
132
|
+
return;
|
|
133
|
+
if (match[1] === ref)
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
function isUnbornHeadInLayout(directory) {
|
|
139
|
+
const gitDirectory = findGitDirectory(directory);
|
|
140
|
+
if (gitDirectory === undefined)
|
|
141
|
+
return false;
|
|
142
|
+
let commonDirectory = gitDirectory;
|
|
143
|
+
const commondir = readText(path2.join(gitDirectory, "commondir"));
|
|
144
|
+
if (commondir.ok) {
|
|
145
|
+
const value = stripLineEnding(commondir.text);
|
|
146
|
+
if (value === "" || value.includes(`
|
|
147
|
+
`))
|
|
148
|
+
return false;
|
|
149
|
+
commonDirectory = resolveMetadataPath(gitDirectory, value);
|
|
150
|
+
} else if (!commondir.missing) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
if (entryKind(path2.join(gitDirectory, "HEAD")) !== "file")
|
|
154
|
+
return false;
|
|
155
|
+
if (entryKind(path2.join(commonDirectory, "objects")) !== "directory")
|
|
156
|
+
return false;
|
|
157
|
+
if (entryKind(path2.join(commonDirectory, "refs")) !== "directory")
|
|
158
|
+
return false;
|
|
159
|
+
if (entryKind(path2.join(commonDirectory, "reftable")) !== "missing")
|
|
160
|
+
return false;
|
|
161
|
+
const config = readText(path2.join(commonDirectory, "config"));
|
|
162
|
+
if (config.ok) {
|
|
163
|
+
if (/refstorage/iu.test(config.text))
|
|
164
|
+
return false;
|
|
165
|
+
} else if (!config.missing) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
const head = readText(path2.join(gitDirectory, "HEAD"));
|
|
169
|
+
if (!head.ok)
|
|
170
|
+
return false;
|
|
171
|
+
const headMatch = /^ref: (refs\/heads\/(.+))$/u.exec(head.text.replace(/\s+$/u, ""));
|
|
172
|
+
const ref = headMatch?.[1];
|
|
173
|
+
const branch = headMatch?.[2];
|
|
174
|
+
if (!ref || branch === undefined || !isPlainBranchName(branch))
|
|
175
|
+
return false;
|
|
176
|
+
const refSegments = ref.split("/");
|
|
177
|
+
for (const base of new Set([commonDirectory, gitDirectory])) {
|
|
178
|
+
if (entryKind(path2.join(base, ...refSegments)) !== "missing")
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
const packed = readText(path2.join(commonDirectory, "packed-refs"));
|
|
182
|
+
if (packed.ok) {
|
|
183
|
+
if (packedRefsList(packed.text, ref) !== false)
|
|
184
|
+
return false;
|
|
185
|
+
} else if (!packed.missing) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
function isUnbornHeadOnDisk(directory, env = process.env) {
|
|
191
|
+
if (GIT_LOCATION_ENV_VARS.some((name) => env[name] !== undefined && env[name] !== "")) {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
let realDirectory;
|
|
195
|
+
try {
|
|
196
|
+
realDirectory = realpathSync.native(path2.resolve(directory));
|
|
197
|
+
} catch {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
return isUnbornHeadInLayout(realDirectory);
|
|
201
|
+
}
|
|
202
|
+
|
|
47
203
|
// src/features/magic-context/memory/project-identity.ts
|
|
48
204
|
var GIT_TIMEOUT_MS = 5000;
|
|
49
205
|
var TRANSIENT_FAILURE_COOLDOWN_MS = 5 * 60 * 1000;
|
|
@@ -79,6 +235,7 @@ function shouldSkipHomeProjectMemory(directory) {
|
|
|
79
235
|
}
|
|
80
236
|
}
|
|
81
237
|
var execFileSyncForIdentity = execFileSync;
|
|
238
|
+
var gitTimeoutMs = GIT_TIMEOUT_MS;
|
|
82
239
|
var userHomeDirectoryForIdentity = () => homedir();
|
|
83
240
|
var nowMs = () => Date.now();
|
|
84
241
|
var filesystemProbeObserverForTests;
|
|
@@ -133,7 +290,7 @@ function getErrorStderr(error) {
|
|
|
133
290
|
return "";
|
|
134
291
|
}
|
|
135
292
|
function directoryFallback(directory) {
|
|
136
|
-
const canonical =
|
|
293
|
+
const canonical = path3.resolve(directory);
|
|
137
294
|
const hash = createHash2("md5").update(canonical, "utf8").digest("hex").slice(0, 12);
|
|
138
295
|
return `dir:${hash}`;
|
|
139
296
|
}
|
|
@@ -142,7 +299,7 @@ function rememberedIdentityOrDirectoryFallback(canonical) {
|
|
|
142
299
|
}
|
|
143
300
|
function assertDirectoryUsable(canonicalDirectory, rawDirectory) {
|
|
144
301
|
try {
|
|
145
|
-
const stat =
|
|
302
|
+
const stat = statSync2(canonicalDirectory);
|
|
146
303
|
if (!stat.isDirectory()) {
|
|
147
304
|
throw new ProjectIdentityError("unknown", rawDirectory, `Project path is not a directory: ${canonicalDirectory}`);
|
|
148
305
|
}
|
|
@@ -168,7 +325,7 @@ function hasUnbornHead(directory) {
|
|
|
168
325
|
encoding: "utf8",
|
|
169
326
|
env: { ...process.env, LC_ALL: "C", LANG: "C" },
|
|
170
327
|
stdio: ["ignore", "pipe", "pipe"],
|
|
171
|
-
timeout:
|
|
328
|
+
timeout: gitTimeoutMs,
|
|
172
329
|
windowsHide: true
|
|
173
330
|
};
|
|
174
331
|
try {
|
|
@@ -185,7 +342,7 @@ function hasUnbornHead(directory) {
|
|
|
185
342
|
}
|
|
186
343
|
function classifyGitError(error, rawDirectory) {
|
|
187
344
|
if (isGitTimeoutError(error)) {
|
|
188
|
-
return new ProjectIdentityError("git_timeout", rawDirectory, `git rev-list timed out after ${
|
|
345
|
+
return new ProjectIdentityError("git_timeout", rawDirectory, `git rev-list timed out after ${gitTimeoutMs}ms`, asError(error));
|
|
189
346
|
}
|
|
190
347
|
const code = getErrorCode(error);
|
|
191
348
|
if (code === "ENOENT") {
|
|
@@ -205,7 +362,7 @@ function classifyGitError(error, rawDirectory) {
|
|
|
205
362
|
}
|
|
206
363
|
function resolveProjectIdentityStrict(directory, allowHomeProject = homeProjectPermission, options = {}) {
|
|
207
364
|
assertProjectAllowed(directory, allowHomeProject);
|
|
208
|
-
const canonical =
|
|
365
|
+
const canonical = path3.resolve(directory);
|
|
209
366
|
const cached = options.cache === false ? undefined : identityCache.get(canonical);
|
|
210
367
|
if (cached !== undefined) {
|
|
211
368
|
return cached;
|
|
@@ -214,6 +371,9 @@ function resolveProjectIdentityStrict(directory, allowHomeProject = homeProjectP
|
|
|
214
371
|
if (!hasGitDir(canonical)) {
|
|
215
372
|
throw new ProjectIdentityError("not_git_repo", directory, "Directory has no git metadata; caller may use directory fallback");
|
|
216
373
|
}
|
|
374
|
+
if (isUnbornHeadOnDisk(canonical)) {
|
|
375
|
+
throw new ProjectIdentityError("no_commits", directory, "Git repository has no commits yet");
|
|
376
|
+
}
|
|
217
377
|
let output;
|
|
218
378
|
try {
|
|
219
379
|
output = execFileSyncForIdentity("git", ["rev-list", "--max-parents=0", "HEAD"], {
|
|
@@ -221,7 +381,7 @@ function resolveProjectIdentityStrict(directory, allowHomeProject = homeProjectP
|
|
|
221
381
|
encoding: "utf8",
|
|
222
382
|
env: { ...process.env, LC_ALL: "C", LANG: "C" },
|
|
223
383
|
stdio: ["ignore", "pipe", "pipe"],
|
|
224
|
-
timeout:
|
|
384
|
+
timeout: gitTimeoutMs,
|
|
225
385
|
windowsHide: true
|
|
226
386
|
});
|
|
227
387
|
} catch (error) {
|
|
@@ -274,9 +434,9 @@ function nearestLastKnownGitIdentity(canonical) {
|
|
|
274
434
|
const cached = lastKnownGitIdentity(current);
|
|
275
435
|
if (cached !== undefined)
|
|
276
436
|
return { identity: cached, source: current };
|
|
277
|
-
if (existsSync(
|
|
437
|
+
if (existsSync(path3.join(current, ".git")))
|
|
278
438
|
break;
|
|
279
|
-
const parent =
|
|
439
|
+
const parent = path3.dirname(current);
|
|
280
440
|
if (parent === current)
|
|
281
441
|
break;
|
|
282
442
|
current = parent;
|
|
@@ -287,7 +447,7 @@ function nearestLastKnownGitIdentity(canonical) {
|
|
|
287
447
|
if (exactOrAncestor)
|
|
288
448
|
return exactOrAncestor;
|
|
289
449
|
try {
|
|
290
|
-
const realCanonical =
|
|
450
|
+
const realCanonical = realpathSync2.native(canonical);
|
|
291
451
|
if (realCanonical !== canonical)
|
|
292
452
|
return walk(realCanonical);
|
|
293
453
|
} catch {}
|
|
@@ -315,7 +475,7 @@ function recordDubiousOwnershipFallback(canonical) {
|
|
|
315
475
|
log2(`[magic-context] ${formatDubiousOwnershipWarning(canonical)}`);
|
|
316
476
|
}
|
|
317
477
|
function takeDubiousOwnershipProjectIdentityWarning(directory) {
|
|
318
|
-
const canonical =
|
|
478
|
+
const canonical = path3.resolve(directory);
|
|
319
479
|
if (!dubiousOwnershipFallbackDirectories.has(canonical))
|
|
320
480
|
return null;
|
|
321
481
|
if (dubiousOwnershipWarnedDirectories.has(canonical))
|
|
@@ -326,7 +486,7 @@ function takeDubiousOwnershipProjectIdentityWarning(directory) {
|
|
|
326
486
|
function canonicalUserHomeDirectory() {
|
|
327
487
|
const homeDirectory = userHomeDirectoryForIdentity();
|
|
328
488
|
try {
|
|
329
|
-
return
|
|
489
|
+
return realpathSync2.native(homeDirectory);
|
|
330
490
|
} catch {
|
|
331
491
|
return homeDirectory;
|
|
332
492
|
}
|
|
@@ -335,20 +495,20 @@ function isUserHomeDirectory(directory) {
|
|
|
335
495
|
if (projectDirectoryKey(directory) === projectDirectoryKey(userHomeDirectoryForIdentity()))
|
|
336
496
|
return true;
|
|
337
497
|
try {
|
|
338
|
-
return projectDirectoryKey(
|
|
498
|
+
return projectDirectoryKey(realpathSync2.native(path3.resolve(directory))) === projectDirectoryKey(canonicalUserHomeDirectory());
|
|
339
499
|
} catch {
|
|
340
500
|
return false;
|
|
341
501
|
}
|
|
342
502
|
}
|
|
343
503
|
function assertProjectAllowed(directory, allowHomeProject) {
|
|
344
|
-
const canonical =
|
|
504
|
+
const canonical = path3.resolve(directory);
|
|
345
505
|
if (!allowHomeProject && (isUserHomeDirectory(directory) || isUserHomeDirectory(gitRootDirectory(canonical) ?? canonical))) {
|
|
346
506
|
throw new ProjectIdentityError("home_project_disabled", directory, "Home project memory is disabled; set allow_home_project to opt in");
|
|
347
507
|
}
|
|
348
508
|
}
|
|
349
509
|
function resolveProjectIdentity(directory, allowHomeProject = homeProjectPermission) {
|
|
350
510
|
assertProjectAllowed(directory, allowHomeProject);
|
|
351
|
-
const canonical =
|
|
511
|
+
const canonical = path3.resolve(directory);
|
|
352
512
|
const cachedFallback = directoryFallbackCache.get(canonical);
|
|
353
513
|
if (cachedFallback !== undefined) {
|
|
354
514
|
if (!hasGitDir(canonical)) {
|
|
@@ -396,7 +556,7 @@ function resolveProjectIdentityOrFallback(directory, allowHomeProject = homeProj
|
|
|
396
556
|
try {
|
|
397
557
|
return resolveProjectIdentity(directory, allowHomeProject);
|
|
398
558
|
} catch (error) {
|
|
399
|
-
const canonical =
|
|
559
|
+
const canonical = path3.resolve(directory);
|
|
400
560
|
if (hasGitDir(canonical) || error instanceof ProjectIdentityError && error.errorClass === "home_project_disabled")
|
|
401
561
|
throw error;
|
|
402
562
|
const fallback = rememberedIdentityOrDirectoryFallback(canonical);
|
|
@@ -410,7 +570,7 @@ function hasGitDir(canonical) {
|
|
|
410
570
|
return true;
|
|
411
571
|
}
|
|
412
572
|
try {
|
|
413
|
-
const realCanonical =
|
|
573
|
+
const realCanonical = realpathSync2.native(canonical);
|
|
414
574
|
return realCanonical !== canonical && hasGitDirInAncestorChain(realCanonical);
|
|
415
575
|
} catch {
|
|
416
576
|
return false;
|
|
@@ -419,14 +579,14 @@ function hasGitDir(canonical) {
|
|
|
419
579
|
function gitRootInAncestorChain(startDirectory) {
|
|
420
580
|
let current = startDirectory;
|
|
421
581
|
while (true) {
|
|
422
|
-
if (existsSync(
|
|
582
|
+
if (existsSync(path3.join(current, ".git"))) {
|
|
423
583
|
try {
|
|
424
|
-
return
|
|
584
|
+
return realpathSync2.native(current);
|
|
425
585
|
} catch {
|
|
426
|
-
return
|
|
586
|
+
return path3.resolve(current);
|
|
427
587
|
}
|
|
428
588
|
}
|
|
429
|
-
const parent =
|
|
589
|
+
const parent = path3.dirname(current);
|
|
430
590
|
if (parent === current) {
|
|
431
591
|
return null;
|
|
432
592
|
}
|
|
@@ -441,21 +601,21 @@ function gitRootDirectory(canonical) {
|
|
|
441
601
|
if (direct)
|
|
442
602
|
return direct;
|
|
443
603
|
try {
|
|
444
|
-
const realCanonical =
|
|
604
|
+
const realCanonical = realpathSync2.native(canonical);
|
|
445
605
|
return realCanonical === canonical ? null : gitRootInAncestorChain(realCanonical);
|
|
446
606
|
} catch {
|
|
447
607
|
return null;
|
|
448
608
|
}
|
|
449
609
|
}
|
|
450
610
|
function directoryHasGitMetadata(directory) {
|
|
451
|
-
return gitRootDirectory(
|
|
611
|
+
return gitRootDirectory(path3.resolve(directory)) !== null;
|
|
452
612
|
}
|
|
453
613
|
function describeUnresolvedProjectIdentity(directory) {
|
|
454
|
-
const resolvedDirectory =
|
|
614
|
+
const resolvedDirectory = path3.resolve(directory);
|
|
455
615
|
const canonicalHome = canonicalUserHomeDirectory();
|
|
456
616
|
const canonicalDirectory = (() => {
|
|
457
617
|
try {
|
|
458
|
-
return
|
|
618
|
+
return realpathSync2.native(resolvedDirectory);
|
|
459
619
|
} catch {
|
|
460
620
|
return resolvedDirectory;
|
|
461
621
|
}
|
|
@@ -471,7 +631,7 @@ function isUsableProjectIdentity(identity) {
|
|
|
471
631
|
return typeof identity === "string" && identity.trim().length > 0;
|
|
472
632
|
}
|
|
473
633
|
function resolveProjectIdentityForSession(directory, allowHomeProject = homeProjectPermission) {
|
|
474
|
-
const resolvedDirectory =
|
|
634
|
+
const resolvedDirectory = path3.resolve(directory);
|
|
475
635
|
const cacheKey = `${allowHomeProject ? "1" : "0"}\x00${resolvedDirectory}`;
|
|
476
636
|
const cached = sessionIdentityCache.get(cacheKey);
|
|
477
637
|
if (cached && (cached.revalidateAt === null || nowMs() < cached.revalidateAt) && !(cached.identity?.startsWith("dir:") && hasGitDir(resolvedDirectory))) {
|
|
@@ -482,7 +642,7 @@ function resolveProjectIdentityForSession(directory, allowHomeProject = homeProj
|
|
|
482
642
|
const canonicalDirectory = (() => {
|
|
483
643
|
try {
|
|
484
644
|
filesystemProbeObserverForTests?.();
|
|
485
|
-
return
|
|
645
|
+
return realpathSync2.native(resolvedDirectory);
|
|
486
646
|
} catch {
|
|
487
647
|
return resolvedDirectory;
|
|
488
648
|
}
|
|
@@ -6,23 +6,23 @@ import {
|
|
|
6
6
|
StaleRouteHandleError,
|
|
7
7
|
SubcClient,
|
|
8
8
|
isConsumerReconnectTransient
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-fkx2qnvw.js";
|
|
10
10
|
import {
|
|
11
11
|
getHarness2
|
|
12
12
|
} from "./index-pavzsdc6.js";
|
|
13
13
|
import {
|
|
14
14
|
getDataDir
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-g2q4htwp.js";
|
|
16
16
|
import {
|
|
17
17
|
log2
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-j75v2476.js";
|
|
19
19
|
import {
|
|
20
20
|
inRootAsyncContext2
|
|
21
21
|
} from "./index-wafzvyhg.js";
|
|
22
22
|
import {
|
|
23
23
|
buildCanonicalChunkTextFromFts,
|
|
24
24
|
loadCompartmentChunkEmbeddingsForSearch
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-3kx0kg0f.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-y1qysm3q.js";
|
|
43
43
|
import {
|
|
44
44
|
getProjectEmbeddings2
|
|
45
45
|
} from "./index-4dhv7mqz.js";
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
isEmbeddingEnabled,
|
|
49
49
|
embedText,
|
|
50
50
|
ensureMemoryEmbeddings2
|
|
51
|
-
} from "./index-
|
|
51
|
+
} from "./index-3kdm78zp.js";
|
|
52
52
|
import {
|
|
53
53
|
ModuleMemoryAuthorityError2,
|
|
54
54
|
getMemoriesByProject2,
|
|
@@ -63,20 +63,20 @@ import {
|
|
|
63
63
|
sanitizeFtsQuery,
|
|
64
64
|
searchMemoriesFTS,
|
|
65
65
|
searchMemoriesFTSUnion
|
|
66
|
-
} from "./index-
|
|
66
|
+
} from "./index-bxdg2nbt.js";
|
|
67
67
|
import {
|
|
68
68
|
isRecord
|
|
69
|
-
} from "./index-
|
|
69
|
+
} from "./index-fwefky9w.js";
|
|
70
70
|
import {
|
|
71
71
|
getIndexedMessageCorpusSize2
|
|
72
|
-
} from "./index-
|
|
72
|
+
} from "./index-v13skev1.js";
|
|
73
73
|
import {
|
|
74
74
|
resolveWorkspaceShareCategories,
|
|
75
75
|
resolveWorkspaceIdentitySet,
|
|
76
76
|
expandWorkspaceIdentitySetWithAliases,
|
|
77
77
|
resolveStoredPathWorkspaceIdentity,
|
|
78
78
|
sourceNameForMemory
|
|
79
|
-
} from "./index-
|
|
79
|
+
} from "./index-wk0n1cgt.js";
|
|
80
80
|
import {
|
|
81
81
|
isKnownAutocommit
|
|
82
82
|
} from "./index-8ajstryz.js";
|