@cortexkit/opencode-magic-context 0.13.2 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -7
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli.js +59 -3
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +61 -22
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
- package/dist/features/magic-context/git-commits/git-log-reader.d.ts +57 -0
- package/dist/features/magic-context/git-commits/git-log-reader.d.ts.map +1 -0
- package/dist/features/magic-context/git-commits/index.d.ts +7 -0
- package/dist/features/magic-context/git-commits/index.d.ts.map +1 -0
- package/dist/features/magic-context/git-commits/indexer.d.ts +44 -0
- package/dist/features/magic-context/git-commits/indexer.d.ts.map +1 -0
- package/dist/features/magic-context/git-commits/search-git-commits.d.ts +32 -0
- package/dist/features/magic-context/git-commits/search-git-commits.d.ts.map +1 -0
- package/dist/features/magic-context/git-commits/storage-git-commit-embeddings.d.ts +18 -0
- package/dist/features/magic-context/git-commits/storage-git-commit-embeddings.d.ts.map +1 -0
- package/dist/features/magic-context/git-commits/storage-git-commits.d.ts +47 -0
- package/dist/features/magic-context/git-commits/storage-git-commits.d.ts.map +1 -0
- package/dist/features/magic-context/memory/embedding-local.d.ts +2 -2
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-openai.d.ts +25 -2
- package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-provider.d.ts +8 -2
- package/dist/features/magic-context/memory/embedding-provider.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding.d.ts +2 -2
- package/dist/features/magic-context/memory/embedding.d.ts.map +1 -1
- package/dist/features/magic-context/migrations.d.ts.map +1 -1
- package/dist/features/magic-context/overflow-detection.d.ts +51 -0
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -0
- package/dist/features/magic-context/search.d.ts +40 -9
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +40 -0
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta.d.ts +1 -1
- package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
- package/dist/features/magic-context/storage.d.ts +1 -1
- package/dist/features/magic-context/storage.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-hint.d.ts +34 -0
- package/dist/hooks/magic-context/auto-search-hint.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-runner.d.ts +51 -0
- package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-payloads.d.ts +15 -1
- package/dist/hooks/magic-context/event-payloads.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-resolvers.d.ts +20 -1
- package/dist/hooks/magic-context/event-resolvers.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook-handlers.d.ts +5 -0
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +14 -6
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +12 -0
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/note-nudger.d.ts.map +1 -1
- package/dist/hooks/magic-context/reasoning-capability.d.ts +23 -0
- package/dist/hooks/magic-context/reasoning-capability.d.ts.map +1 -0
- package/dist/hooks/magic-context/strip-content.d.ts +3 -3
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +22 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +12 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2058 -569
- package/dist/plugin/dream-timer.d.ts +24 -7
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +4 -0
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/tool-registry.d.ts.map +1 -1
- package/dist/shared/models-dev-cache.d.ts +20 -6
- package/dist/shared/models-dev-cache.d.ts.map +1 -1
- package/dist/tools/ctx-note/tools.d.ts.map +1 -1
- package/dist/tools/ctx-search/constants.d.ts +1 -1
- package/dist/tools/ctx-search/constants.d.ts.map +1 -1
- package/dist/tools/ctx-search/tools.d.ts.map +1 -1
- package/dist/tools/ctx-search/types.d.ts +8 -0
- package/dist/tools/ctx-search/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/shared/models-dev-cache.test.ts +57 -6
- package/src/shared/models-dev-cache.ts +119 -38
package/README.md
CHANGED
|
@@ -42,16 +42,22 @@ Your agent should never stop working to manage its own context. Magic Context is
|
|
|
42
42
|
|
|
43
43
|
**5.** TUI sidebar with live context breakdown, token usage, historian status, and memory counts — right inside the terminal.
|
|
44
44
|
|
|
45
|
-
###
|
|
45
|
+
### ✨ Graduated in v0.14
|
|
46
|
+
|
|
47
|
+
**User Memories** — now enabled by default under `dreamer.user_memories`. Historian extracts behavioral observations about you alongside its normal compartment output (communication style, expertise level, review focus, working patterns). Recurring observations are promoted by the dreamer to stable user memories that appear in all sessions via `<user-profile>`. Set `dreamer.user_memories.enabled: false` to opt out. Requires dreamer.
|
|
46
48
|
|
|
47
|
-
**
|
|
49
|
+
**Key File Pinning** — now under `dreamer.pin_key_files`, still opt-in. Dreamer analyzes which files your agent reads most frequently across the session. Core orientation files (architecture, config, types) that get re-read after every context drop are pinned into the system prompt as `<key-files>`, so the agent always has them without needing to re-read from disk. Files are read fresh on each cache-busting pass. Enable with `dreamer.pin_key_files.enabled: true`.
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
> Migrating from an earlier version? Running `bunx --bun @cortexkit/opencode-magic-context@latest doctor` rewrites old `experimental.user_memories.*` and `experimental.pin_key_files.*` keys into their new `dreamer.*` homes, preserving any `enabled` state you had.
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
### 🧪 New Experimental Features
|
|
52
54
|
|
|
53
55
|
**Temporal Awareness** — gives the agent real-time perception. Each user message gets a small `<!-- +5m -->`/`<!-- +2h 15m -->`/`<!-- +3d 4h -->` gap marker showing time since the previous message, and every compartment in `<session-history>` carries `start-date`/`end-date` attributes. Lets the agent reason correctly about how long a build ran, when a decision was made, or how stale a prior session is. Cache-safe — markers derive from immutable timestamps. Enable with `experimental.temporal_awareness: true`.
|
|
54
56
|
|
|
57
|
+
**Git Commit Indexing** — indexes HEAD git commits (skipping merges) from the project and makes them searchable through `ctx_search`. Commits are embedded so semantic queries like "when did we change the auth pattern" or "why did we pick X over Y" surface the right work. HEAD-only, windowed to the last year by default, capped at 2000 commits per project with oldest evicted. Enable with `experimental.git_commit_indexing.enabled: true`.
|
|
58
|
+
|
|
59
|
+
**Auto Search Hints** — before each turn, Magic Context runs a background `ctx_search` on your prompt. When highly relevant content exists, a compact "vague recall" hint is appended to your message with caveman-compressed fragments of the top matches — like a human feeling they almost remember something and going to check their notes. The agent then decides whether to run `ctx_search` for the full content. Cache-safe, fires on top-score ≥ 0.55 by default. Enable with `experimental.auto_search.enabled: true`.
|
|
60
|
+
|
|
55
61
|
---
|
|
56
62
|
|
|
57
63
|
## Get Started
|
|
@@ -284,13 +290,13 @@ The dreamer runs during a configurable schedule window and creates ephemeral Ope
|
|
|
284
290
|
|
|
285
291
|
When dreamer is enabled, ARCHITECTURE.md and STRUCTURE.md are automatically injected into the agent's system prompt (configurable via `inject_docs`). Content is cached per-session and refreshed on cache-busting passes.
|
|
286
292
|
|
|
287
|
-
### User Memories
|
|
293
|
+
### User Memories
|
|
288
294
|
|
|
289
|
-
|
|
295
|
+
Enabled by default under `dreamer.user_memories`. Historian extracts behavioral observations about the user alongside its normal compartment output — things like communication style, expertise level, review focus, and working patterns. These go into a candidate pool.
|
|
290
296
|
|
|
291
297
|
During dreamer runs, a dedicated review pass checks candidates for recurring patterns across sessions. Observations that appear at least `promotion_threshold` times (default 3) are promoted to stable user memories and injected into all sessions via `<user-profile>` in the system prompt.
|
|
292
298
|
|
|
293
|
-
Stable user memories are visible and manageable in the dashboard's User Memories page. Requires dreamer to be enabled for the promotion step.
|
|
299
|
+
Stable user memories are visible and manageable in the dashboard's User Memories page. Requires dreamer to be enabled for the promotion step — without dreamer, candidates accumulate but are never promoted. Set `dreamer.user_memories.enabled: false` to opt out.
|
|
294
300
|
|
|
295
301
|
### TUI Sidebar
|
|
296
302
|
|
package/dist/cli/doctor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/cli/doctor.ts"],"names":[],"mappings":"AA+XA,wBAAsB,SAAS,CAC3B,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GACnD,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/cli/doctor.ts"],"names":[],"mappings":"AA+XA,wBAAsB,SAAS,CAC3B,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GACnD,OAAO,CAAC,MAAM,CAAC,CAyejB"}
|
package/dist/cli.js
CHANGED
|
@@ -10455,6 +10455,62 @@ async function runDoctor(options = {}) {
|
|
|
10455
10455
|
R2.success("Migrated experimental.compaction_markers → compaction_markers (now default: true)");
|
|
10456
10456
|
fixed++;
|
|
10457
10457
|
}
|
|
10458
|
+
if (experimental && "user_memories" in experimental) {
|
|
10459
|
+
const dreamer = mcConfig.dreamer ?? {};
|
|
10460
|
+
const oldUM = experimental.user_memories;
|
|
10461
|
+
const existingUM = dreamer.user_memories;
|
|
10462
|
+
if (existingUM === undefined) {
|
|
10463
|
+
if (typeof oldUM === "boolean") {
|
|
10464
|
+
dreamer.user_memories = { enabled: oldUM };
|
|
10465
|
+
} else {
|
|
10466
|
+
dreamer.user_memories = oldUM;
|
|
10467
|
+
}
|
|
10468
|
+
} else if (typeof oldUM === "object" && oldUM !== null && typeof existingUM === "object" && existingUM !== null) {
|
|
10469
|
+
const merged = {
|
|
10470
|
+
...oldUM,
|
|
10471
|
+
...existingUM
|
|
10472
|
+
};
|
|
10473
|
+
dreamer.user_memories = merged;
|
|
10474
|
+
} else if (typeof oldUM === "object" && oldUM !== null) {
|
|
10475
|
+
const coerced = {
|
|
10476
|
+
...oldUM,
|
|
10477
|
+
enabled: Boolean(existingUM)
|
|
10478
|
+
};
|
|
10479
|
+
dreamer.user_memories = coerced;
|
|
10480
|
+
R2.warn(`Coerced malformed dreamer.user_memories (${typeof existingUM}) to object form while merging sub-fields from experimental.user_memories`);
|
|
10481
|
+
}
|
|
10482
|
+
mcConfig.dreamer = dreamer;
|
|
10483
|
+
delete experimental.user_memories;
|
|
10484
|
+
mcChanged = true;
|
|
10485
|
+
R2.success("Migrated experimental.user_memories → dreamer.user_memories (now default: enabled)");
|
|
10486
|
+
fixed++;
|
|
10487
|
+
}
|
|
10488
|
+
if (experimental && "pin_key_files" in experimental) {
|
|
10489
|
+
const dreamer = mcConfig.dreamer ?? {};
|
|
10490
|
+
const oldPKF = experimental.pin_key_files;
|
|
10491
|
+
const existingPKF = dreamer.pin_key_files;
|
|
10492
|
+
if (existingPKF === undefined) {
|
|
10493
|
+
dreamer.pin_key_files = oldPKF;
|
|
10494
|
+
} else if (typeof oldPKF === "object" && oldPKF !== null && typeof existingPKF === "object" && existingPKF !== null) {
|
|
10495
|
+
const merged = {
|
|
10496
|
+
...oldPKF,
|
|
10497
|
+
...existingPKF
|
|
10498
|
+
};
|
|
10499
|
+
dreamer.pin_key_files = merged;
|
|
10500
|
+
} else if (typeof oldPKF === "object" && oldPKF !== null) {
|
|
10501
|
+
const coerced = {
|
|
10502
|
+
...oldPKF,
|
|
10503
|
+
enabled: Boolean(existingPKF)
|
|
10504
|
+
};
|
|
10505
|
+
dreamer.pin_key_files = coerced;
|
|
10506
|
+
R2.warn(`Coerced malformed dreamer.pin_key_files (${typeof existingPKF}) to object form while merging sub-fields from experimental.pin_key_files`);
|
|
10507
|
+
}
|
|
10508
|
+
mcConfig.dreamer = dreamer;
|
|
10509
|
+
delete experimental.pin_key_files;
|
|
10510
|
+
mcChanged = true;
|
|
10511
|
+
R2.success("Migrated experimental.pin_key_files → dreamer.pin_key_files (preserved user enabled state)");
|
|
10512
|
+
fixed++;
|
|
10513
|
+
}
|
|
10458
10514
|
if ("compartment_token_budget" in mcConfig) {
|
|
10459
10515
|
delete mcConfig.compartment_token_budget;
|
|
10460
10516
|
mcChanged = true;
|
|
@@ -10561,12 +10617,12 @@ async function runDoctor(options = {}) {
|
|
|
10561
10617
|
try {
|
|
10562
10618
|
const mcRaw = readFileSync6(paths.magicContextConfig, "utf-8");
|
|
10563
10619
|
const mcConfig = import_comment_json3.parse(mcRaw);
|
|
10564
|
-
const userMemObj = mcConfig?.experimental?.user_memories;
|
|
10565
|
-
const userMemEnabled = userMemObj?.enabled === true;
|
|
10566
10620
|
const dreamerObj = mcConfig?.dreamer;
|
|
10567
10621
|
const dreamerEnabled = dreamerObj?.enabled === true;
|
|
10622
|
+
const userMemObj = dreamerObj?.user_memories;
|
|
10623
|
+
const userMemEnabled = userMemObj?.enabled !== false;
|
|
10568
10624
|
if (userMemEnabled && !dreamerEnabled) {
|
|
10569
|
-
R2.warn("
|
|
10625
|
+
R2.warn("dreamer.user_memories is enabled (default) but dreamer itself is disabled — user memory candidates will be collected but never promoted to stable memories. Enable `dreamer.enabled: true` or set `dreamer.user_memories.enabled: false` to silence this.");
|
|
10570
10626
|
issues++;
|
|
10571
10627
|
}
|
|
10572
10628
|
} catch {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,kBAAkB,EAA4B,MAAM,wBAAwB,CAAC;AAG3F,MAAM,WAAW,wBAAyB,SAAQ,kBAAkB;IAChE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CACZ,MAAM,EACN;QACI,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,OAAO,CAAC;KACrB,CACJ,CAAC;CACL;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,kBAAkB,EAA4B,MAAM,wBAAwB,CAAC;AAG3F,MAAM,WAAW,wBAAyB,SAAQ,kBAAkB;IAChE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CACZ,MAAM,EACN;QACI,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,OAAO,CAAC;KACrB,CACJ,CAAC;CACL;AA2SD,wBAAgB,gBAAgB,CAC5B,SAAS,EAAE,MAAM,GAClB,wBAAwB,GAAG;IAAE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAuC1D"}
|
|
@@ -90,6 +90,15 @@ export declare const DreamerConfigSchema: z.ZodObject<{
|
|
|
90
90
|
}>>>;
|
|
91
91
|
task_timeout_minutes: z.ZodDefault<z.ZodNumber>;
|
|
92
92
|
inject_docs: z.ZodDefault<z.ZodBoolean>;
|
|
93
|
+
user_memories: z.ZodDefault<z.ZodObject<{
|
|
94
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
95
|
+
promotion_threshold: z.ZodDefault<z.ZodNumber>;
|
|
96
|
+
}, z.core.$strip>>;
|
|
97
|
+
pin_key_files: z.ZodDefault<z.ZodObject<{
|
|
98
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
99
|
+
token_budget: z.ZodDefault<z.ZodNumber>;
|
|
100
|
+
min_reads: z.ZodDefault<z.ZodNumber>;
|
|
101
|
+
}, z.core.$strip>>;
|
|
93
102
|
}, z.core.$strip>;
|
|
94
103
|
export type DreamerConfig = z.infer<typeof DreamerConfigSchema>;
|
|
95
104
|
export declare const SidekickConfigSchema: z.ZodOptional<z.ZodObject<{
|
|
@@ -275,20 +284,30 @@ export interface MagicContextConfig {
|
|
|
275
284
|
grace_compartments: number;
|
|
276
285
|
};
|
|
277
286
|
experimental: {
|
|
278
|
-
|
|
287
|
+
/** Inject elapsed-time markers between user messages and date ranges on
|
|
288
|
+
* compartments so the agent has a wall-clock sense of the session. */
|
|
289
|
+
temporal_awareness: boolean;
|
|
290
|
+
/** Index git commit messages from HEAD into a new ctx_search source so
|
|
291
|
+
* agents can recall recent regressions, fixes, and decisions from
|
|
292
|
+
* commit history without running git log manually. */
|
|
293
|
+
git_commit_indexing: {
|
|
279
294
|
enabled: boolean;
|
|
280
|
-
|
|
295
|
+
/** Days of history to index (default: 365) */
|
|
296
|
+
since_days: number;
|
|
297
|
+
/** Max commits kept per project; oldest evicted (default: 2000) */
|
|
298
|
+
max_commits: number;
|
|
281
299
|
};
|
|
282
|
-
|
|
300
|
+
/** Appends a compact hint to new user messages when ctx_search finds
|
|
301
|
+
* highly-related memories, facts, or git commits. Does NOT inject
|
|
302
|
+
* full content — just vague fragments that nudge the agent to run
|
|
303
|
+
* ctx_search for full context if relevant. */
|
|
304
|
+
auto_search: {
|
|
283
305
|
enabled: boolean;
|
|
284
|
-
/**
|
|
285
|
-
|
|
286
|
-
/** Minimum
|
|
287
|
-
|
|
306
|
+
/** Top hit score must exceed this threshold for the hint to fire. */
|
|
307
|
+
score_threshold: number;
|
|
308
|
+
/** Minimum user message length in characters (skip short prompts). */
|
|
309
|
+
min_prompt_chars: number;
|
|
288
310
|
};
|
|
289
|
-
/** Inject elapsed-time markers between user messages and date ranges on
|
|
290
|
-
* compartments so the agent has a wall-clock sense of the session. */
|
|
291
|
-
temporal_awareness: boolean;
|
|
292
311
|
};
|
|
293
312
|
embedding: EmbeddingConfig;
|
|
294
313
|
memory: {
|
|
@@ -414,6 +433,15 @@ export declare const MagicContextConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
414
433
|
}>>>;
|
|
415
434
|
task_timeout_minutes: z.ZodDefault<z.ZodNumber>;
|
|
416
435
|
inject_docs: z.ZodDefault<z.ZodBoolean>;
|
|
436
|
+
user_memories: z.ZodDefault<z.ZodObject<{
|
|
437
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
438
|
+
promotion_threshold: z.ZodDefault<z.ZodNumber>;
|
|
439
|
+
}, z.core.$strip>>;
|
|
440
|
+
pin_key_files: z.ZodDefault<z.ZodObject<{
|
|
441
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
442
|
+
token_budget: z.ZodDefault<z.ZodNumber>;
|
|
443
|
+
min_reads: z.ZodDefault<z.ZodNumber>;
|
|
444
|
+
}, z.core.$strip>>;
|
|
417
445
|
}, z.core.$strip>>;
|
|
418
446
|
cache_ttl: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
419
447
|
default: z.ZodString;
|
|
@@ -472,16 +500,17 @@ export declare const MagicContextConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
472
500
|
api_key?: string | undefined;
|
|
473
501
|
}>>>;
|
|
474
502
|
experimental: z.ZodDefault<z.ZodObject<{
|
|
475
|
-
|
|
503
|
+
temporal_awareness: z.ZodDefault<z.ZodBoolean>;
|
|
504
|
+
git_commit_indexing: z.ZodDefault<z.ZodObject<{
|
|
476
505
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
477
|
-
|
|
506
|
+
since_days: z.ZodDefault<z.ZodNumber>;
|
|
507
|
+
max_commits: z.ZodDefault<z.ZodNumber>;
|
|
478
508
|
}, z.core.$strip>>;
|
|
479
|
-
|
|
509
|
+
auto_search: z.ZodDefault<z.ZodObject<{
|
|
480
510
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
481
|
-
|
|
482
|
-
|
|
511
|
+
score_threshold: z.ZodDefault<z.ZodNumber>;
|
|
512
|
+
min_prompt_chars: z.ZodDefault<z.ZodNumber>;
|
|
483
513
|
}, z.core.$strip>>;
|
|
484
|
-
temporal_awareness: z.ZodDefault<z.ZodBoolean>;
|
|
485
514
|
}, z.core.$strip>>;
|
|
486
515
|
memory: z.ZodDefault<z.ZodObject<{
|
|
487
516
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -586,16 +615,17 @@ export declare const MagicContextConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
586
615
|
model?: undefined;
|
|
587
616
|
};
|
|
588
617
|
experimental: {
|
|
589
|
-
|
|
618
|
+
temporal_awareness: boolean;
|
|
619
|
+
git_commit_indexing: {
|
|
590
620
|
enabled: boolean;
|
|
591
|
-
|
|
621
|
+
since_days: number;
|
|
622
|
+
max_commits: number;
|
|
592
623
|
};
|
|
593
|
-
|
|
624
|
+
auto_search: {
|
|
594
625
|
enabled: boolean;
|
|
595
|
-
|
|
596
|
-
|
|
626
|
+
score_threshold: number;
|
|
627
|
+
min_prompt_chars: number;
|
|
597
628
|
};
|
|
598
|
-
temporal_awareness: boolean;
|
|
599
629
|
};
|
|
600
630
|
memory: {
|
|
601
631
|
enabled: boolean;
|
|
@@ -633,6 +663,15 @@ export declare const MagicContextConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
633
663
|
tasks: ("consolidate" | "verify" | "archive-stale" | "improve" | "maintain-docs")[];
|
|
634
664
|
task_timeout_minutes: number;
|
|
635
665
|
inject_docs: boolean;
|
|
666
|
+
user_memories: {
|
|
667
|
+
enabled: boolean;
|
|
668
|
+
promotion_threshold: number;
|
|
669
|
+
};
|
|
670
|
+
pin_key_files: {
|
|
671
|
+
enabled: boolean;
|
|
672
|
+
token_budget: number;
|
|
673
|
+
min_reads: number;
|
|
674
|
+
};
|
|
636
675
|
model?: string | undefined;
|
|
637
676
|
temperature?: number | undefined;
|
|
638
677
|
top_p?: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"magic-context.d.ts","sourceRoot":"","sources":["../../../src/config/schema/magic-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,6BAA6B,QAAS,CAAC;AACpD,eAAO,MAAM,oCAAoC,KAAK,CAAC;AACvD,eAAO,MAAM,4BAA4B,SAAU,CAAC;AACpD,eAAO,MAAM,iCAAiC,OAAO,CAAC;AACtD,eAAO,MAAM,6BAA6B,4BAA4B,CAAC;AACvE,0EAA0E;AAC1E,eAAO,MAAM,wCAAwC,OAAO,CAAC;AAC7D,eAAO,MAAM,kCAAkC,IAAI,CAAC;AACpD,eAAO,MAAM,8BAA8B,SAAU,CAAC;AACtD;8FAC8F;AAC9F,eAAO,MAAM,4CAA4C,KAAK,CAAC;AAC/D;;yFAEyF;AACzF,eAAO,MAAM,qCAAqC,KAAK,CAAC;AACxD;+EAC+E;AAC/E,eAAO,MAAM,+BAA+B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAMlE,CAAC;AAEF,eAAO,MAAM,aAAa,iFAMhB,CAAC;AAEX,eAAO,MAAM,kBAAkB;;;;;;EAAwB,CAAC;AACxD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkM/B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compartment-storage.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/compartment-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA6B3C,MAAM,WAAW,WAAW;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACrB;AAsDD,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACnB;AA8DD,wBAAgB,eAAe,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,WAAW,EAAE,CAQ9E;AAED,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAKpF;AAED,wBAAgB,sBAAsB,CAClC,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,gBAAgB,EAAE,GACjC,IAAI,CAMN;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAC9B,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,gBAAgB,EAAE,GACjC,IAAI,CAMN;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAC/B,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,KAAK,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GACpD,IAAI,
|
|
1
|
+
{"version":3,"file":"compartment-storage.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/compartment-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA6B3C,MAAM,WAAW,WAAW;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,K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gCtF;AAED,oEAAoE;AACpE,wBAAgB,oBAAoB,CAChC,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,GAClB;IACC,YAAY,EAAE,gBAAgB,EAAE,CAAC;IACjC,KAAK,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACvD,GAAG,IAAI,CAuBP;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAUjE;AAED,0FAA0F;AAC1F,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAexE;AAID;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACjC,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,GAClB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAcvC;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACjC,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAC7C,IAAI,CASN;AAwCD,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAO/C;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAElD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read git commit history from a working directory using `git log`.
|
|
3
|
+
*
|
|
4
|
+
* Wraps a single `git log` invocation with controlled flags and parses the
|
|
5
|
+
* delimited output. Runs synchronously with a timeout guard — indexing
|
|
6
|
+
* happens on a plugin timer, not on the hot transform path, so blocking for
|
|
7
|
+
* a few hundred milliseconds once per refresh is acceptable.
|
|
8
|
+
*
|
|
9
|
+
* Parsing contract:
|
|
10
|
+
* - We request `--format=%H%x1f%s%x1f%ae%x1f%ct%x1f%b%x1e`:
|
|
11
|
+
* %H = full 40-char SHA
|
|
12
|
+
* %s = subject (one line)
|
|
13
|
+
* %ae = author email
|
|
14
|
+
* %ct = committer time (seconds since epoch)
|
|
15
|
+
* %b = body (multi-line)
|
|
16
|
+
* Fields are separated by US (0x1f, ASCII Unit Separator), records by RS
|
|
17
|
+
* (0x1e, ASCII Record Separator). We deliberately AVOID NUL (0x00) here:
|
|
18
|
+
* Node's `child_process.execFile` validation rejects argv elements that
|
|
19
|
+
* contain embedded NUL bytes ("must be a string without null bytes"),
|
|
20
|
+
* even when the underlying program (git) would happily accept them via
|
|
21
|
+
* other entry points. Bun's execFile is more permissive, which masked
|
|
22
|
+
* this in unit tests until live OpenCode runtime exposed it. US/RS
|
|
23
|
+
* never appear naturally in commit subjects, emails, or bodies.
|
|
24
|
+
* - Subject + trimmed body combine into the searchable message.
|
|
25
|
+
* - We skip merge commits via `--no-merges` so merge "Merge branch 'x'"
|
|
26
|
+
* noise doesn't fill the index.
|
|
27
|
+
*/
|
|
28
|
+
export interface GitCommit {
|
|
29
|
+
/** Full 40-char SHA. */
|
|
30
|
+
sha: string;
|
|
31
|
+
/** First 7 chars of SHA for display. */
|
|
32
|
+
shortSha: string;
|
|
33
|
+
/** Subject + body, joined with a blank line when body exists. */
|
|
34
|
+
message: string;
|
|
35
|
+
/** Author email, or null when unavailable. */
|
|
36
|
+
author: string | null;
|
|
37
|
+
/** Committer time in milliseconds since epoch. */
|
|
38
|
+
committedAtMs: number;
|
|
39
|
+
}
|
|
40
|
+
export interface ReadGitCommitsOptions {
|
|
41
|
+
/** Only include commits newer than this (milliseconds since epoch). */
|
|
42
|
+
sinceMs?: number;
|
|
43
|
+
/** Only include commits reachable from HEAD (the default). */
|
|
44
|
+
branch?: string;
|
|
45
|
+
/** Hard cap on returned commits. Default 5000. */
|
|
46
|
+
maxCommits?: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Read commits reachable from HEAD (or `branch` when provided) up to
|
|
50
|
+
* `maxCommits`, optionally filtered by `sinceMs`. Returns an empty array
|
|
51
|
+
* when git is unavailable or the directory is not a repo. Does NOT throw
|
|
52
|
+
* on non-zero git exit — logs and returns empty so indexing failures
|
|
53
|
+
* never crash the plugin.
|
|
54
|
+
*/
|
|
55
|
+
export declare function readGitCommits(directory: string, options?: ReadGitCommitsOptions): Promise<GitCommit[]>;
|
|
56
|
+
export declare function parseGitLogOutput(stdout: string): GitCommit[];
|
|
57
|
+
//# sourceMappingURL=git-log-reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-log-reader.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/git-commits/git-log-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAeH,MAAM,WAAW,SAAS;IACtB,wBAAwB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,kDAAkD;IAClD,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,qBAAqB;IAClC,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAChC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,qBAA0B,GACpC,OAAO,CAAC,SAAS,EAAE,CAAC,CA2CtB;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,CA6C7D"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { GitCommit, ReadGitCommitsOptions } from "./git-log-reader";
|
|
2
|
+
export { parseGitLogOutput, readGitCommits } from "./git-log-reader";
|
|
3
|
+
export { _resetIndexerGuards, embedUnembeddedCommits, type IndexCommitsOptions, type IndexCommitsResult, indexCommitsForProject, } from "./indexer";
|
|
4
|
+
export { type GitCommitSearchHit, type SearchGitCommitsOptions, searchGitCommitsSync, } from "./search-git-commits";
|
|
5
|
+
export { clearProjectCommitEmbeddings, countEmbeddedCommits, loadProjectCommitEmbeddings, loadUnembeddedCommits, saveCommitEmbedding, } from "./storage-git-commit-embeddings";
|
|
6
|
+
export { enforceProjectCap, evictOldestCommits, getCommitBySha, getCommitCount, getLatestIndexedCommitTimeMs, type StoredGitCommit, upsertCommit, upsertCommits, } from "./storage-git-commits";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/git-commits/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACH,mBAAmB,EACnB,sBAAsB,EACtB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,sBAAsB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACH,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,oBAAoB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,4BAA4B,EAC5B,oBAAoB,EACpB,2BAA2B,EAC3B,qBAAqB,EACrB,mBAAmB,GACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,4BAA4B,EAC5B,KAAK,eAAe,EACpB,YAAY,EACZ,aAAa,GAChB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commit indexer — bridges `git log` output into the plugin's storage.
|
|
3
|
+
*
|
|
4
|
+
* Public entry points:
|
|
5
|
+
* - indexCommitsForProject() — sweep HEAD, upsert, evict to cap, embed backlog
|
|
6
|
+
* - embedUnembeddedCommits() — drain embedding backlog only (called from dream timer)
|
|
7
|
+
*
|
|
8
|
+
* Concurrency: both functions are guarded by a singleton in-progress flag
|
|
9
|
+
* scoped to (projectPath, operation) so the dream timer can't spawn parallel
|
|
10
|
+
* sweeps of the same project.
|
|
11
|
+
*/
|
|
12
|
+
import type { Database } from "bun:sqlite";
|
|
13
|
+
import type { EmbeddingConfig } from "../../../config/schema/magic-context";
|
|
14
|
+
export interface IndexCommitsOptions {
|
|
15
|
+
sinceDays: number;
|
|
16
|
+
maxCommits: number;
|
|
17
|
+
/** If true, skip the embed step after indexing. Useful when the caller
|
|
18
|
+
* plans to embed in a separate scheduled pass. Default false. */
|
|
19
|
+
skipEmbed?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface IndexCommitsResult {
|
|
22
|
+
scanned: number;
|
|
23
|
+
inserted: number;
|
|
24
|
+
updated: number;
|
|
25
|
+
evicted: number;
|
|
26
|
+
embedded: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Sweep commits from `directory` (must be a git repo), upsert them for
|
|
30
|
+
* `projectPath`, enforce max-commits cap, and optionally embed the backlog.
|
|
31
|
+
*
|
|
32
|
+
* Safe to call repeatedly — existing commits whose message hasn't changed
|
|
33
|
+
* are skipped cheaply (SQLite WHERE clause in the UPSERT).
|
|
34
|
+
*/
|
|
35
|
+
export declare function indexCommitsForProject(db: Database, projectPath: string, directory: string, embeddingConfig: EmbeddingConfig, options: IndexCommitsOptions): Promise<IndexCommitsResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Embed unembedded commits for a project, draining until exhausted or hitting
|
|
38
|
+
* the wall-clock / per-sweep limits. Mirrors the memory embedding sweep
|
|
39
|
+
* behavior so provider switches refresh the commit index as quickly as memories.
|
|
40
|
+
*/
|
|
41
|
+
export declare function embedUnembeddedCommits(db: Database, projectPath: string, _config: EmbeddingConfig): Promise<number>;
|
|
42
|
+
/** Test-only: reset in-progress guards. */
|
|
43
|
+
export declare function _resetIndexerGuards(): void;
|
|
44
|
+
//# sourceMappingURL=indexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/git-commits/indexer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAyB5E,MAAM,WAAW,mBAAmB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB;sEACkE;IAClE,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CACxC,EAAE,EAAE,QAAQ,EACZ,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,mBAAmB,GAC7B,OAAO,CAAC,kBAAkB,CAAC,CAgE7B;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CACxC,EAAE,EAAE,QAAQ,EACZ,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,eAAe,GACzB,OAAO,CAAC,MAAM,CAAC,CAsDjB;AAED,2CAA2C;AAC3C,wBAAgB,mBAAmB,IAAI,IAAI,CAG1C"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hybrid FTS + semantic search for indexed git commits.
|
|
3
|
+
*
|
|
4
|
+
* Returns raw scored matches; the caller (unifiedSearch) slots these into
|
|
5
|
+
* the existing merged ranking with source boosts.
|
|
6
|
+
*/
|
|
7
|
+
import type { Database } from "bun:sqlite";
|
|
8
|
+
import type { StoredGitCommit } from "./storage-git-commits";
|
|
9
|
+
export interface GitCommitSearchHit {
|
|
10
|
+
commit: StoredGitCommit;
|
|
11
|
+
/** 0..1 combined score. */
|
|
12
|
+
score: number;
|
|
13
|
+
matchType: "semantic" | "fts" | "hybrid";
|
|
14
|
+
}
|
|
15
|
+
export interface SearchGitCommitsOptions {
|
|
16
|
+
limit: number;
|
|
17
|
+
/** Raw semantic score weight. Default 0.7. */
|
|
18
|
+
semanticWeight?: number;
|
|
19
|
+
/** Raw FTS score weight. Default 0.3. */
|
|
20
|
+
ftsWeight?: number;
|
|
21
|
+
/** When semantic OR FTS has only one signal, scale the score by this
|
|
22
|
+
* penalty to favor hybrid matches. Default 0.8. */
|
|
23
|
+
singleSourcePenalty?: number;
|
|
24
|
+
/** Pre-computed query embedding. When omitted, we skip the semantic pass. */
|
|
25
|
+
queryEmbedding?: Float32Array | null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Return top-K commits matching `query` for `projectPath`, combining FTS
|
|
29
|
+
* and semantic ranks. Falls back to LIKE when FTS fails (e.g. short queries).
|
|
30
|
+
*/
|
|
31
|
+
export declare function searchGitCommitsSync(db: Database, projectPath: string, query: string, options: SearchGitCommitsOptions): GitCommitSearchHit[];
|
|
32
|
+
//# sourceMappingURL=search-git-commits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-git-commits.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/git-commits/search-git-commits.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAK3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAyE7D,MAAM,WAAW,kBAAkB;IAC/B,MAAM,EAAE,eAAe,CAAC;IACxB,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,UAAU,GAAG,KAAK,GAAG,QAAQ,CAAC;CAC5C;AAED,MAAM,WAAW,uBAAuB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;wDACoD;IACpD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,6EAA6E;IAC7E,cAAc,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CACxC;AAOD;;;GAGG;AACH,wBAAgB,oBAAoB,CAChC,EAAE,EAAE,QAAQ,EACZ,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,uBAAuB,GACjC,kBAAkB,EAAE,CAmGtB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embedding storage for git commits.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the memory-embedding storage layout but keyed by commit SHA rather
|
|
5
|
+
* than memory id. Embeddings are byte-equivalent to memory embeddings (Float32
|
|
6
|
+
* serialized via Float32Array.buffer), so the same cosine-similarity helpers
|
|
7
|
+
* apply without conversion.
|
|
8
|
+
*/
|
|
9
|
+
import type { Database } from "bun:sqlite";
|
|
10
|
+
export declare function saveCommitEmbedding(db: Database, sha: string, embedding: Float32Array, modelId: string): void;
|
|
11
|
+
export declare function loadProjectCommitEmbeddings(db: Database, projectPath: string): Map<string, Float32Array>;
|
|
12
|
+
export declare function loadUnembeddedCommits(db: Database, projectPath: string, limit: number): Array<{
|
|
13
|
+
sha: string;
|
|
14
|
+
message: string;
|
|
15
|
+
}>;
|
|
16
|
+
export declare function countEmbeddedCommits(db: Database, projectPath: string): number;
|
|
17
|
+
export declare function clearProjectCommitEmbeddings(db: Database, projectPath: string): number;
|
|
18
|
+
//# sourceMappingURL=storage-git-commit-embeddings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-git-commit-embeddings.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/git-commits/storage-git-commit-embeddings.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA2F3C,wBAAgB,mBAAmB,CAC/B,EAAE,EAAE,QAAQ,EACZ,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,MAAM,GAChB,IAAI,CAGN;AAED,wBAAgB,2BAA2B,CACvC,EAAE,EAAE,QAAQ,EACZ,WAAW,EAAE,MAAM,GACpB,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAW3B;AAED,wBAAgB,qBAAqB,CACjC,EAAE,EAAE,QAAQ,EACZ,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,GACd,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAEzC;AAED,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAG9E;AAED,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAEtF"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite storage layer for indexed git commits.
|
|
3
|
+
*
|
|
4
|
+
* Separate from the memory embedding table because:
|
|
5
|
+
* - Identity is the SHA, not a memory row id
|
|
6
|
+
* - Lifecycle is managed by git, not by Dreamer review flow
|
|
7
|
+
* - FTS is also separate so commit queries never pollute memory BM25 ranks
|
|
8
|
+
*
|
|
9
|
+
* Eviction: when `max_commits` is exceeded for a project, we delete the oldest
|
|
10
|
+
* commits by `committed_at ASC` (not by indexed_at — indexed_at can reorder
|
|
11
|
+
* when we catch up after a long absence). ON DELETE CASCADE removes matching
|
|
12
|
+
* embedding rows and FTS triggers remove matching FTS rows, so a single DELETE
|
|
13
|
+
* cleans all three tables.
|
|
14
|
+
*/
|
|
15
|
+
import type { Database } from "bun:sqlite";
|
|
16
|
+
import type { GitCommit } from "./git-log-reader";
|
|
17
|
+
export interface StoredGitCommit extends GitCommit {
|
|
18
|
+
projectPath: string;
|
|
19
|
+
indexedAtMs: number;
|
|
20
|
+
}
|
|
21
|
+
/** Insert or update a single commit. Use upsertCommits() for batch writes. */
|
|
22
|
+
export declare function upsertCommit(db: Database, projectPath: string, commit: GitCommit): void;
|
|
23
|
+
/** Batch upsert in a single transaction. Returns the count actually inserted
|
|
24
|
+
* or updated (skipped unchanged rows don't count). */
|
|
25
|
+
export declare function upsertCommits(db: Database, projectPath: string, commits: GitCommit[]): {
|
|
26
|
+
inserted: number;
|
|
27
|
+
updated: number;
|
|
28
|
+
};
|
|
29
|
+
/** Return the total count of indexed commits for a project. */
|
|
30
|
+
export declare function getCommitCount(db: Database, projectPath: string): number;
|
|
31
|
+
/** Return the most recent committed_at (ms) for this project, or null. */
|
|
32
|
+
export declare function getLatestIndexedCommitTimeMs(db: Database, projectPath: string): number | null;
|
|
33
|
+
/** Delete the oldest `excess` commits for a project. ON DELETE CASCADE cleans
|
|
34
|
+
* embedding rows; FTS triggers clean FTS rows. Returns rows deleted.
|
|
35
|
+
*
|
|
36
|
+
* We compute the deletion count by diffing count-before and count-after because
|
|
37
|
+
* `stmt.run().changes` can be inflated by FTS5 trigger propagation (each
|
|
38
|
+
* `INSERT INTO ..._fts(_fts, ...) VALUES('delete', ...)` inside an AFTER DELETE
|
|
39
|
+
* trigger can add to the reported change count). */
|
|
40
|
+
export declare function evictOldestCommits(db: Database, projectPath: string, excess: number): number;
|
|
41
|
+
/** Keep at most `maxCommits` rows for this project, evicting oldest overflow.
|
|
42
|
+
* Returns number of rows evicted. */
|
|
43
|
+
export declare function enforceProjectCap(db: Database, projectPath: string, maxCommits: number): number;
|
|
44
|
+
/** Return a commit by SHA (any project). For single-project reads, prefer the
|
|
45
|
+
* project-scoped variants. */
|
|
46
|
+
export declare function getCommitBySha(db: Database, sha: string): StoredGitCommit | null;
|
|
47
|
+
//# sourceMappingURL=storage-git-commits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-git-commits.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/git-commits/storage-git-commits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIlD,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACvB;AAoFD,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,CAUvF;AAED;uDACuD;AACvD,wBAAgB,aAAa,CACzB,EAAE,EAAE,QAAQ,EACZ,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,SAAS,EAAE,GACrB;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAqCvC;AAED,+DAA+D;AAC/D,wBAAgB,cAAc,CAAC,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAGxE;AAED,0EAA0E;AAC1E,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK7F;AAED;;;;;;qDAMqD;AACrD,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAM5F;AAED;sCACsC;AACtC,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAa/F;AAED;+BAC+B;AAC/B,wBAAgB,cAAc,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAKhF"}
|
|
@@ -6,8 +6,8 @@ export declare class LocalEmbeddingProvider implements EmbeddingProvider {
|
|
|
6
6
|
private initPromise;
|
|
7
7
|
constructor(model?: string);
|
|
8
8
|
initialize(): Promise<boolean>;
|
|
9
|
-
embed(text: string): Promise<Float32Array | null>;
|
|
10
|
-
embedBatch(texts: string[]): Promise<(Float32Array | null)[]>;
|
|
9
|
+
embed(text: string, signal?: AbortSignal): Promise<Float32Array | null>;
|
|
10
|
+
embedBatch(texts: string[], signal?: AbortSignal): Promise<(Float32Array | null)[]>;
|
|
11
11
|
dispose(): Promise<void>;
|
|
12
12
|
isLoaded(): boolean;
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedding-local.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/memory/embedding-local.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAyN9D,qBAAa,sBAAuB,YAAW,iBAAiB;IAC5D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,WAAW,CAA8B;gBAErC,KAAK,SAAgC;IAK3C,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAoH9B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"embedding-local.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/memory/embedding-local.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAyN9D,qBAAa,sBAAuB,YAAW,iBAAiB;IAC5D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,WAAW,CAA8B;gBAErC,KAAK,SAAgC;IAK3C,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAoH9B,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IA8BvE,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE,CAAC;IAiCnF,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB9B,QAAQ,IAAI,OAAO;CAGtB"}
|
|
@@ -4,18 +4,41 @@ interface OpenAICompatibleEmbeddingProviderOptions {
|
|
|
4
4
|
model?: string;
|
|
5
5
|
apiKey?: string;
|
|
6
6
|
}
|
|
7
|
+
type CircuitState = "closed" | "open" | "half_open";
|
|
7
8
|
export declare class OpenAICompatibleEmbeddingProvider implements EmbeddingProvider {
|
|
8
9
|
readonly modelId: string;
|
|
9
10
|
private readonly endpoint;
|
|
10
11
|
private readonly model;
|
|
11
12
|
private readonly apiKey;
|
|
12
13
|
private initialized;
|
|
14
|
+
private failureTimes;
|
|
15
|
+
private circuitOpenUntil;
|
|
16
|
+
private openLogged;
|
|
17
|
+
/** True while a half-open probe is in flight. Only the caller who set this
|
|
18
|
+
* to true is allowed to make a real HTTP call; everyone else short-
|
|
19
|
+
* circuits as if the circuit were still OPEN. */
|
|
20
|
+
private halfOpenProbeInFlight;
|
|
13
21
|
constructor(options: OpenAICompatibleEmbeddingProviderOptions);
|
|
14
22
|
initialize(): Promise<boolean>;
|
|
15
|
-
embed(text: string): Promise<Float32Array | null>;
|
|
16
|
-
embedBatch(texts: string[]): Promise<(Float32Array | null)[]>;
|
|
23
|
+
embed(text: string, signal?: AbortSignal): Promise<Float32Array | null>;
|
|
24
|
+
embedBatch(texts: string[], signal?: AbortSignal): Promise<(Float32Array | null)[]>;
|
|
17
25
|
dispose(): Promise<void>;
|
|
18
26
|
isLoaded(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Decide what this caller should do:
|
|
29
|
+
* - "allow": CLOSED — proceed with a real request, not as a probe
|
|
30
|
+
* - "probe": HALF_OPEN — this caller owns the probe slot
|
|
31
|
+
* - "short_circuit": OPEN or half-open probe already in flight — return nulls
|
|
32
|
+
*
|
|
33
|
+
* Claiming the probe slot (setting `halfOpenProbeInFlight = true`) is done
|
|
34
|
+
* here, synchronously, so concurrent callers see the flag and short-circuit.
|
|
35
|
+
*/
|
|
36
|
+
private claimProbeOrShortCircuit;
|
|
37
|
+
private recordFailure;
|
|
38
|
+
private recordSuccess;
|
|
39
|
+
_getCircuitState(): CircuitState;
|
|
40
|
+
_getFailureCount(): number;
|
|
41
|
+
_resetCircuit(): void;
|
|
19
42
|
}
|
|
20
43
|
export {};
|
|
21
44
|
//# sourceMappingURL=embedding-openai.d.ts.map
|