@cortexkit/opencode-magic-context 0.1.3 → 0.2.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 +14 -3
- package/dist/agents/magic-context-prompt.d.ts +1 -1
- package/dist/agents/magic-context-prompt.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +6 -0
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
- package/dist/features/magic-context/index.d.ts +1 -0
- package/dist/features/magic-context/index.d.ts.map +1 -1
- package/dist/features/magic-context/memory/storage-memory-fts.d.ts +8 -0
- package/dist/features/magic-context/memory/storage-memory-fts.d.ts.map +1 -1
- package/dist/features/magic-context/message-index.d.ts +4 -0
- package/dist/features/magic-context/message-index.d.ts.map +1 -0
- package/dist/features/magic-context/search.d.ts +36 -0
- package/dist/features/magic-context/search.d.ts.map +1 -0
- package/dist/features/magic-context/sidekick/agent.d.ts +1 -1
- package/dist/features/magic-context/sidekick/agent.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.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/hook-handlers.d.ts +2 -0
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +1 -0
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts +5 -0
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-hash.d.ts +1 -0
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1715 -1305
- package/dist/plugin/dream-timer.d.ts +14 -0
- package/dist/plugin/dream-timer.d.ts.map +1 -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/tools/ctx-memory/constants.d.ts +1 -1
- package/dist/tools/ctx-memory/constants.d.ts.map +1 -1
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-memory/types.d.ts +3 -10
- package/dist/tools/ctx-memory/types.d.ts.map +1 -1
- package/dist/tools/ctx-search/constants.d.ts +4 -0
- package/dist/tools/ctx-search/constants.d.ts.map +1 -0
- package/dist/tools/ctx-search/index.d.ts +4 -0
- package/dist/tools/ctx-search/index.d.ts.map +1 -0
- package/dist/tools/ctx-search/tools.d.ts +4 -0
- package/dist/tools/ctx-search/tools.d.ts.map +1 -0
- package/dist/tools/ctx-search/types.d.ts +19 -0
- package/dist/tools/ctx-search/types.d.ts.map +1 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -81,7 +81,7 @@ And overnight, a **dreamer** agent consolidates, verifies, and improves memories
|
|
|
81
81
|
|
|
82
82
|
## What Your Agent Gets
|
|
83
83
|
|
|
84
|
-
Magic Context injects structured context automatically and gives the agent
|
|
84
|
+
Magic Context injects structured context automatically and gives the agent five tools.
|
|
85
85
|
|
|
86
86
|
### `ctx_reduce` — Shed weight
|
|
87
87
|
|
|
@@ -120,10 +120,19 @@ Architecture decisions, naming conventions, user preferences — anything that s
|
|
|
120
120
|
|
|
121
121
|
```
|
|
122
122
|
ctx_memory(action="write", category="ARCHITECTURE_DECISIONS", content="Event sourcing for orders.")
|
|
123
|
-
ctx_memory(action="search", query="authentication approach")
|
|
124
123
|
ctx_memory(action="delete", id=42)
|
|
125
124
|
```
|
|
126
125
|
|
|
126
|
+
### `ctx_search` — Unified search
|
|
127
|
+
|
|
128
|
+
Search across all data layers with a single query — project memories, session facts, and raw conversation history. Results are ranked by source (memories first, then facts, then message hits).
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
ctx_search(query="authentication approach")
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Message results include ordinal numbers the agent can pass to `ctx_expand` to retrieve the surrounding conversation context.
|
|
135
|
+
|
|
127
136
|
### Automatic context injection
|
|
128
137
|
|
|
129
138
|
Every turn, Magic Context injects a `<session-history>` block containing:
|
|
@@ -170,7 +179,7 @@ As context usage grows, Magic Context sends rolling reminders suggesting the age
|
|
|
170
179
|
|
|
171
180
|
After each historian run, qualifying facts are promoted to the persistent memory store. On every subsequent turn, active memories are injected in `<session-history>`. New sessions inherit all project memories from previous sessions.
|
|
172
181
|
|
|
173
|
-
Memories are searchable via `
|
|
182
|
+
Memories are searchable via `ctx_search` alongside session facts and raw conversation history, using semantic embeddings (local by default) with full-text search as fallback.
|
|
174
183
|
|
|
175
184
|
### Dreamer
|
|
176
185
|
|
|
@@ -230,6 +239,8 @@ All durable states live in a local SQLite database. If the database can't be ope
|
|
|
230
239
|
| `memory_embeddings` | Embedding vectors for semantic search |
|
|
231
240
|
| `dream_state` | Dreamer lease locking and task progress |
|
|
232
241
|
| `dream_queue` | Queued projects awaiting dream processing |
|
|
242
|
+
| `message_history_fts` | FTS5 index of user/assistant message text for `ctx_search` |
|
|
243
|
+
| `message_history_index` | Tracks last indexed ordinal per session for incremental FTS population |
|
|
233
244
|
| `recomp_compartments` | Staging for `/ctx-recomp` partial progress |
|
|
234
245
|
| `recomp_facts` | Staging for `/ctx-recomp` partial progress |
|
|
235
246
|
|
|
@@ -9,6 +9,6 @@ type AgentType = "sisyphus" | "atlas" | "hephaestus" | "sisyphus-junior" | "orac
|
|
|
9
9
|
* Order matters — more specific signatures (e.g., "Sisyphus-Junior") are checked first.
|
|
10
10
|
*/
|
|
11
11
|
export declare function detectAgentFromSystemPrompt(systemPrompt: string): AgentType | null;
|
|
12
|
-
export declare function buildMagicContextSection(agent: AgentType | null, protectedTags: number): string;
|
|
12
|
+
export declare function buildMagicContextSection(agent: AgentType | null, protectedTags: number, ctxReduceEnabled?: boolean): string;
|
|
13
13
|
export {};
|
|
14
14
|
//# sourceMappingURL=magic-context-prompt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"magic-context-prompt.d.ts","sourceRoot":"","sources":["../../src/agents/magic-context-prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,KAAK,SAAS,GACR,UAAU,GACV,OAAO,GACP,YAAY,GACZ,iBAAiB,GACjB,QAAQ,GACR,QAAQ,GACR,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"magic-context-prompt.d.ts","sourceRoot":"","sources":["../../src/agents/magic-context-prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,KAAK,SAAS,GACR,UAAU,GACV,OAAO,GACP,YAAY,GACZ,iBAAiB,GACjB,QAAQ,GACR,QAAQ,GACR,eAAe,CAAC;AAsKtB;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAOlF;AAED,wBAAgB,wBAAwB,CACpC,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,aAAa,EAAE,MAAM,EACrB,gBAAgB,UAAO,GACxB,MAAM,CAaR"}
|
|
@@ -176,6 +176,10 @@ export type EmbeddingConfig = z.infer<typeof EmbeddingConfigSchema>;
|
|
|
176
176
|
export type DreamingConfig = z.infer<typeof DreamingConfigSchema>;
|
|
177
177
|
export interface MagicContextConfig {
|
|
178
178
|
enabled: boolean;
|
|
179
|
+
/** When false, ctx_reduce tool is not registered, all nudges are disabled,
|
|
180
|
+
* and prompt guidance about ctx_reduce is stripped. Heuristic cleanup,
|
|
181
|
+
* compartments, memory, and other features continue to work. Default: true. */
|
|
182
|
+
ctx_reduce_enabled: boolean;
|
|
179
183
|
historian?: z.infer<typeof AgentOverrideConfigSchema>;
|
|
180
184
|
dreamer?: DreamerConfig;
|
|
181
185
|
cache_ttl: string | {
|
|
@@ -205,6 +209,7 @@ export interface MagicContextConfig {
|
|
|
205
209
|
}
|
|
206
210
|
export declare const MagicContextConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
207
211
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
212
|
+
ctx_reduce_enabled: z.ZodDefault<z.ZodBoolean>;
|
|
208
213
|
historian: z.ZodOptional<z.ZodObject<{
|
|
209
214
|
model: z.ZodOptional<z.ZodString>;
|
|
210
215
|
temperature: z.ZodOptional<z.ZodNumber>;
|
|
@@ -417,6 +422,7 @@ export declare const MagicContextConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
417
422
|
}, z.core.$strip>>;
|
|
418
423
|
}, z.core.$strip>, z.ZodTransform<MagicContextConfig, {
|
|
419
424
|
enabled: boolean;
|
|
425
|
+
ctx_reduce_enabled: boolean;
|
|
420
426
|
cache_ttl: string | {
|
|
421
427
|
[x: string]: string;
|
|
422
428
|
default: string;
|
|
@@ -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;AAGxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,eAAO,MAAM,6BAA6B,QAAS,CAAC;AACpD,eAAO,MAAM,oCAAoC,KAAK,CAAC;AACvD,eAAO,MAAM,gCAAgC,QAAS,CAAC;AACvD,eAAO,MAAM,4BAA4B,SAAU,CAAC;AACpD,eAAO,MAAM,iCAAiC,OAAO,CAAC;AACtD,eAAO,MAAM,6BAA6B,4BAA4B,CAAC;AAEvE,eAAO,MAAM,aAAa,iFAMhB,CAAC;AAEX,eAAO,MAAM,kBAAkB;;;;;;EAAwB,CAAC;AACxD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,qBAAqB,EAAE,YAAY,EAK/C,CAAC;AAEF,eAAO,MAA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AAe,CAAC;IAC3B,MAAM,EAAE;QACJ,OAAO,EAAE,OAAO,CAAC;QACjB,uBAAuB,EAAE,MAAM,CAAC;QAChC,YAAY,EAAE,OAAO,CAAC;QACtB,mCAAmC,EAAE,MAAM,CAAC;KAC/C,CAAC;IACF,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC7B;AAED,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4E/B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DreamingTask } from "../../../config/schema/magic-context";
|
|
2
|
-
export declare const DREAMER_SYSTEM_PROMPT = "You are a memory maintenance agent for the magic-context system.\nYou run during scheduled dream windows to maintain a project's cross-session memory store and codebase documentation.\n\n## Available Tools\n\n**Memory operations** (ctx_memory with extended dreamer actions):\n- `action=\"list\"` \u2014 browse all active memories, optionally filter by category\n- `action=\"
|
|
2
|
+
export declare const DREAMER_SYSTEM_PROMPT = "You are a memory maintenance agent for the magic-context system.\nYou run during scheduled dream windows to maintain a project's cross-session memory store and codebase documentation.\n\n## Available Tools\n\n**Memory operations** (ctx_memory with extended dreamer actions):\n- `action=\"list\"` \u2014 browse all active memories, optionally filter by category\n- `action=\"update\", id=N, content=\"...\"` \u2014 rewrite a memory's content\n- `action=\"merge\", ids=[N,M,...], content=\"...\", category=\"...\"` \u2014 consolidate duplicates into one canonical memory\n- `action=\"archive\", id=N, reason=\"...\"` \u2014 archive a stale memory with provenance\n- `action=\"write\", category=\"...\", content=\"...\"` \u2014 create a new memory\n- `action=\"delete\", id=N` \u2014 permanently remove a memory\n\n**Codebase tools** (standard OpenCode tools):\n- Read files, grep, glob, bash \u2014 for verification against actual code\n\n## Rules\n\n1. **Work methodically.** Decide your own batch size based on the task \u2014 process as many items per round as makes sense.\n2. **Always verify against actual files** before declaring a memory stale or updating it.\n3. **Be conservative with archives.** Only archive when the codebase clearly contradicts the memory.\n4. **Explain reasoning briefly** before each action \u2014 one line is enough.\n5. **Use present-tense operational language** in all memory rewrites. \"X uses Y\" not \"X was changed to use Y.\"\n6. **One rule/fact per memory.** Split compound memories during improvement.\n7. **Never read or quote secrets** from .env, credentials, keys, or similar sensitive files.\n8. **Do not commit changes.** The user handles git operations.";
|
|
3
3
|
export declare function buildConsolidatePrompt(projectPath: string): string;
|
|
4
4
|
export declare function buildVerifyPrompt(projectPath: string): string;
|
|
5
5
|
export declare function buildArchiveStalePrompt(projectPath: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-prompts.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/dreamer/task-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAIzE,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"task-prompts.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/dreamer/task-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAIzE,eAAO,MAAM,qBAAqB,wqDAyB6B,CAAC;AAIhE,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CA+BlE;AAID,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAoC7D;AAID,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAwCnE;AAID,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CA0C9D;AAID,wBAAgB,uBAAuB,CACnC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,YAAY,EAAE;IAAE,YAAY,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,GAC5D,MAAM,CA+CR;AA0GD,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE;IACF,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,CAAC,EAAE;QAAE,YAAY,EAAE,OAAO,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;CAChE,GACF,MAAM,CAiBR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { Database } from "bun:sqlite";
|
|
2
2
|
import type { Memory } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Sanitize a user query for FTS5 MATCH syntax.
|
|
5
|
+
*
|
|
6
|
+
* FTS5 interprets characters like `-`, `:`, `*`, `(`, `)` as operators.
|
|
7
|
+
* This wraps each whitespace-delimited token in double quotes so special
|
|
8
|
+
* characters are treated as literal content rather than query syntax.
|
|
9
|
+
*/
|
|
10
|
+
export declare function sanitizeFtsQuery(query: string): string;
|
|
3
11
|
export declare function searchMemoriesFTS(db: Database, projectPath: string, query: string, limit?: number): Memory[];
|
|
4
12
|
//# sourceMappingURL=storage-memory-fts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-memory-fts.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/memory/storage-memory-fts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"storage-memory-fts.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/memory/storage-memory-fts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAsBtC;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKtD;AAED,wBAAgB,iBAAiB,CAC7B,EAAE,EAAE,QAAQ,EACZ,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,KAAK,SAAuB,GAC7B,MAAM,EAAE,CAcV"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Database } from "bun:sqlite";
|
|
2
|
+
import type { RawMessage } from "../../hooks/magic-context/read-session-raw";
|
|
3
|
+
export declare function ensureMessagesIndexed(db: Database, sessionId: string, readMessages: (sessionId: string) => RawMessage[]): void;
|
|
4
|
+
//# sourceMappingURL=message-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-index.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/message-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAM3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAwG7E,wBAAgB,qBAAqB,CACjC,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,UAAU,EAAE,GAClD,IAAI,CA4CN"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Database } from "bun:sqlite";
|
|
2
|
+
import type { RawMessage } from "../../hooks/magic-context/read-session-raw";
|
|
3
|
+
export interface UnifiedSearchOptions {
|
|
4
|
+
limit?: number;
|
|
5
|
+
memoryEnabled?: boolean;
|
|
6
|
+
embeddingEnabled?: boolean;
|
|
7
|
+
readMessages?: (sessionId: string) => RawMessage[];
|
|
8
|
+
embedQuery?: (text: string) => Promise<Float32Array | null>;
|
|
9
|
+
isEmbeddingRuntimeEnabled?: () => boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface MemorySearchResult {
|
|
12
|
+
source: "memory";
|
|
13
|
+
content: string;
|
|
14
|
+
score: number;
|
|
15
|
+
memoryId: number;
|
|
16
|
+
category: string;
|
|
17
|
+
matchType: "semantic" | "fts" | "hybrid";
|
|
18
|
+
}
|
|
19
|
+
export interface FactSearchResult {
|
|
20
|
+
source: "fact";
|
|
21
|
+
content: string;
|
|
22
|
+
score: number;
|
|
23
|
+
factId: number;
|
|
24
|
+
factCategory: string;
|
|
25
|
+
}
|
|
26
|
+
export interface MessageSearchResult {
|
|
27
|
+
source: "message";
|
|
28
|
+
content: string;
|
|
29
|
+
score: number;
|
|
30
|
+
messageOrdinal: number;
|
|
31
|
+
messageId: string;
|
|
32
|
+
role: string;
|
|
33
|
+
}
|
|
34
|
+
export type UnifiedSearchResult = MemorySearchResult | FactSearchResult | MessageSearchResult;
|
|
35
|
+
export declare function unifiedSearch(db: Database, sessionId: string, projectPath: string, query: string, options?: UnifiedSearchOptions): Promise<UnifiedSearchResult[]>;
|
|
36
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAoC7E,MAAM,WAAW,oBAAoB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,UAAU,EAAE,CAAC;IACnD,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAC5D,yBAAyB,CAAC,EAAE,MAAM,OAAO,CAAC;CAC7C;AAED,MAAM,WAAW,kBAAkB;IAC/B,MAAM,EAAE,QAAQ,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,UAAU,GAAG,KAAK,GAAG,QAAQ,CAAC;CAC5C;AAED,MAAM,WAAW,gBAAgB;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,mBAAmB,CAAC;AAsV9F,wBAAsB,aAAa,CAC/B,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,oBAAyB,GACnC,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAiDhC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SidekickConfig } from "../../../config/schema/magic-context";
|
|
2
2
|
import type { PluginContext } from "../../../plugin/types";
|
|
3
|
-
export declare const SIDEKICK_SYSTEM_PROMPT = "You are Sidekick, a focused memory-retrieval subagent for an AI coding assistant.\n\nYour job is to search project memories and return a concise augmentation for the user's prompt.\n\nRules:\n- Use
|
|
3
|
+
export declare const SIDEKICK_SYSTEM_PROMPT = "You are Sidekick, a focused memory-retrieval subagent for an AI coding assistant.\n\nYour job is to search project memories, session facts, and conversation history and return a concise augmentation for the user's prompt.\n\nRules:\n- Use ctx_search(query=\"...\") to look up relevant memories, facts, and history before answering.\n- Run targeted searches only; prefer 1-3 precise queries.\n- Return only findings that materially help with the user's prompt.\n- If nothing useful is found, respond with exactly: No relevant memories found.\n- Keep the response focused and concise.\n- Do not invent facts or speculate beyond what memories support.";
|
|
4
4
|
export declare function runSidekick(deps: {
|
|
5
5
|
client: PluginContext["client"];
|
|
6
6
|
sessionId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/sidekick/agent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAK3D,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/sidekick/agent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAK3D,eAAO,MAAM,sBAAsB,6oBAU8B,CAAC;AAUlE,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACpC,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,cAAc,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC7B,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAuEzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-db.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage-db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAiBtC,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"storage-db.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage-db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAiBtC,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CA6NrD;AA6BD,wBAAgB,YAAY,IAAI,QAAQ,CAqCvC;AAED,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAEzD;AAED,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAEvE;AAED,wBAAgB,aAAa,IAAI,IAAI,CAUpC;AAED,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { buildCompartmentBlock, escapeXmlAttr, escapeXmlContent, getCompartments, getSessionFacts, replaceAllCompartmentState, } from "./compartment-storage";
|
|
1
|
+
export { buildCompartmentBlock, escapeXmlAttr, escapeXmlContent, getCompartments, getSessionFacts, replaceAllCompartmentState, type SessionFact, } from "./compartment-storage";
|
|
2
2
|
export { type ContextDatabase, closeDatabase, getDatabasePersistenceError, isDatabasePersisted, openDatabase, } from "./storage-db";
|
|
3
3
|
export { clearPersistedNudgePlacement, clearPersistedStickyTurnReminder, clearSession, getOrCreateSessionMeta, getPersistedNudgePlacement, getPersistedStickyTurnReminder, loadPersistedUsage, setPersistedNudgePlacement, setPersistedStickyTurnReminder, updateSessionMeta, } from "./storage-meta";
|
|
4
4
|
export { addSessionNote, clearSessionNotes, getSessionNotes, replaceAllSessionNotes, type SessionNote, } from "./storage-notes";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,qBAAqB,EACrB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,0BAA0B,
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,qBAAqB,EACrB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,0BAA0B,EAC1B,KAAK,WAAW,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACH,KAAK,eAAe,EACpB,aAAa,EACb,2BAA2B,EAC3B,mBAAmB,EACnB,YAAY,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACH,4BAA4B,EAC5B,gCAAgC,EAChC,YAAY,EACZ,sBAAsB,EACtB,0BAA0B,EAC1B,8BAA8B,EAC9B,kBAAkB,EAClB,0BAA0B,EAC1B,8BAA8B,EAC9B,iBAAiB,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,KAAK,WAAW,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,eAAe,EACf,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EACH,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACH,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,eAAe,GAClB,MAAM,gBAAgB,CAAC"}
|
|
@@ -22,6 +22,7 @@ export declare function createChatMessageHook(args: {
|
|
|
22
22
|
variantBySession: VariantBySession;
|
|
23
23
|
flushedSessions: FlushedSessions;
|
|
24
24
|
lastHeuristicsTurnId: LastHeuristicsTurnId;
|
|
25
|
+
ctxReduceEnabled?: boolean;
|
|
25
26
|
}): (input: {
|
|
26
27
|
sessionID?: string;
|
|
27
28
|
variant?: string;
|
|
@@ -51,6 +52,7 @@ export declare function createEventHook(args: {
|
|
|
51
52
|
commitSeenLastPass?: Map<string, boolean>;
|
|
52
53
|
client: PluginContext["client"];
|
|
53
54
|
protectedTags: number;
|
|
55
|
+
ctxReduceEnabled?: boolean;
|
|
54
56
|
}): (input: {
|
|
55
57
|
event: {
|
|
56
58
|
type: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook-handl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,OAAO,CAAA;KAAE,CAAA;CAAE,mBA+EzE;AAED,wBAAgB,8BAA8B,CAAC,cAAc,EAAE;IAC3D,wBAAwB,EAAE,CACtB,KAAK,EAAE,OAAO,mBAAmB,EAAE,mBAAmB,EACtD,MAAM,EAAE,OAAO,mBAAmB,EAAE,oBAAoB,EACxD,MAAM,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KAClF,OAAO,CAAC,OAAO,CAAC,CAAC;CACzB,IACiB,OAAO,OAAO,EAAE,QAAQ,OAAO,sBAmBhD;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAC7C,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,sBAAsB,EAAE,sBAAsB,CAAC;CAClD,IACiB,OAAO,OAAO,mBAkB/B"}
|
|
@@ -13,6 +13,7 @@ export interface MagicContextDeps {
|
|
|
13
13
|
compactionHandler: ReturnType<typeof createCompactionHandler>;
|
|
14
14
|
config: {
|
|
15
15
|
protected_tags: number;
|
|
16
|
+
ctx_reduce_enabled?: boolean;
|
|
16
17
|
nudge_interval_tokens?: number;
|
|
17
18
|
auto_drop_tool_age?: number;
|
|
18
19
|
clear_reasoning_age?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,aAAa,EAClB,KAAK,cAAc,EACtB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAOvF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAMxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAElE,OAAO,KAAK,EAA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,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAE9C,wBAAwB,CAAC,EAAE,MAAM,CAAC;QAClC,yBAAyB,CAAC,EAAE,MAAM,CAAC;QACnC,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,MAAM,CAAC,EAAE;YACL,OAAO,EAAE,OAAO,CAAC;YACjB,uBAAuB,EAAE,MAAM,CAAC;SACnC,CAAC;QACF,QAAQ,CAAC,EAAE,cAAc,CAAC;QAC1B,OAAO,CAAC,EAAE,aAAa,CAAC;KAC3B,CAAC;CACL;AAqCD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,gBAAgB;;;;;iBAtF3D,CAAC;;;;;;;;;;;;iBA0BO,CAAC;eAAiB,CAAC;;mBA0QA;QAAE,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,UAAU,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE;;;SAY7E"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { type SessionChunkLine } from "./read-session-formatting";
|
|
2
|
+
import { type RawMessage } from "./read-session-raw";
|
|
3
|
+
export { extractTexts, hasMeaningfulUserText } from "./read-session-formatting";
|
|
4
|
+
/** Strip system-reminder blocks and OMO markers from user text for chunk compaction. */
|
|
5
|
+
export declare function cleanUserText(text: string): string;
|
|
2
6
|
export interface SessionChunk {
|
|
3
7
|
startIndex: number;
|
|
4
8
|
endIndex: number;
|
|
@@ -12,6 +16,7 @@ export interface SessionChunk {
|
|
|
12
16
|
/** Number of distinct commit clusters — assistant blocks with commits separated by meaningful user turns */
|
|
13
17
|
commitClusterCount: number;
|
|
14
18
|
}
|
|
19
|
+
export declare function readRawSessionMessages(sessionId: string): RawMessage[];
|
|
15
20
|
export declare function getRawSessionMessageCount(sessionId: string): number;
|
|
16
21
|
export declare function getRawSessionTagKeysThrough(sessionId: string, upToMessageIndex: number): string[];
|
|
17
22
|
export declare function getProtectedTailStartOrdinal(sessionId: string): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-session-chunk.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/read-session-chunk.ts"],"names":[],"mappings":"AAGA,OAAO,EAUH,KAAK,gBAAgB,EACxB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"read-session-chunk.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/read-session-chunk.ts"],"names":[],"mappings":"AAGA,OAAO,EAUH,KAAK,gBAAgB,EACxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,UAAU,EAAgC,MAAM,oBAAoB,CAAC;AAGnF,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAEhF,wFAAwF;AACxF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,MAAM,WAAW,YAAY;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,4GAA4G;IAC5G,kBAAkB,EAAE,MAAM,CAAC;CAC9B;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE,CAEtE;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,EAAE,CAuBjG;AAID,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAWtE;AAED,wBAAgB,gBAAgB,CAC5B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,MAAU,EAClB,kBAAkB,CAAC,EAAE,MAAM,GAC5B,YAAY,CAsHd;AAED,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAO9F"}
|
|
@@ -15,6 +15,7 @@ import { type ContextDatabase } from "../../features/magic-context/storage";
|
|
|
15
15
|
export declare function createSystemPromptHashHandler(deps: {
|
|
16
16
|
db: ContextDatabase;
|
|
17
17
|
protectedTags: number;
|
|
18
|
+
ctxReduceEnabled: boolean;
|
|
18
19
|
flushedSessions: Set<string>;
|
|
19
20
|
lastHeuristicsTurnId: Map<string, string>;
|
|
20
21
|
}): (input: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt-hash.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/system-prompt-hash.ts"],"names":[],"mappings":"AAIA,OAAO,EACH,KAAK,eAAe,EAGvB,MAAM,sCAAsC,CAAC;AAK9C;;;;;;;;;;;;GAYG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE;IAChD,EAAE,EAAE,eAAe,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C,GAAG,CAAC,KAAK,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,KAAK,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"system-prompt-hash.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/system-prompt-hash.ts"],"names":[],"mappings":"AAIA,OAAO,EACH,KAAK,eAAe,EAGvB,MAAM,sCAAsC,CAAC;AAK9C;;;;;;;;;;;;GAYG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE;IAChD,EAAE,EAAE,eAAe,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C,GAAG,CAAC,KAAK,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAwDjF"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAiBlD,QAAA,MAAM,MAAM,EAAE,MAoHb,CAAC;AAEF,eAAe,MAAM,CAAC"}
|