@cortexkit/opencode-magic-context 0.1.0 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +3 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/index.js +254 -252
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/shared/model-requirements.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/agents/builtin-agents.d.ts +0 -8
- package/dist/agents/builtin-agents.d.ts.map +0 -1
- package/dist/agents/types.d.ts +0 -19
- package/dist/agents/types.d.ts.map +0 -1
- package/dist/cli/model-fallback-requirements.d.ts +0 -2
- package/dist/cli/model-fallback-requirements.d.ts.map +0 -1
- package/dist/features/magic-context/dreamer/task-consolidate.d.ts +0 -9
- package/dist/features/magic-context/dreamer/task-consolidate.d.ts.map +0 -1
- package/dist/features/magic-context/dreamer/task-decay.d.ts +0 -11
- package/dist/features/magic-context/dreamer/task-decay.d.ts.map +0 -1
- package/dist/features/magic-context/memory/injection.d.ts +0 -10
- package/dist/features/magic-context/memory/injection.d.ts.map +0 -1
- package/dist/features/magic-context/sidekick/client.d.ts +0 -12
- package/dist/features/magic-context/sidekick/client.d.ts.map +0 -1
- package/dist/features/magic-context/sidekick/types.d.ts +0 -48
- package/dist/features/magic-context/sidekick/types.d.ts.map +0 -1
- package/dist/hooks/auto-slash-command/constants.d.ts +0 -2
- package/dist/hooks/auto-slash-command/constants.d.ts.map +0 -1
- package/dist/hooks/magic-context/get-error-message.d.ts +0 -2
- package/dist/hooks/magic-context/get-error-message.d.ts.map +0 -1
- package/dist/plugin/hooks/create-core-hooks.d.ts +0 -37
- package/dist/plugin/hooks/create-core-hooks.d.ts.map +0 -1
- package/dist/shared/agent-display-names.d.ts +0 -2
- package/dist/shared/agent-display-names.d.ts.map +0 -1
- package/dist/shared/permission-compat.d.ts +0 -6
- package/dist/shared/permission-compat.d.ts.map +0 -1
- package/dist/tools/ctx-recall/constants.d.ts +0 -4
- package/dist/tools/ctx-recall/constants.d.ts.map +0 -1
- package/dist/tools/ctx-recall/index.d.ts +0 -4
- package/dist/tools/ctx-recall/index.d.ts.map +0 -1
- package/dist/tools/ctx-recall/tools.d.ts +0 -4
- package/dist/tools/ctx-recall/tools.d.ts.map +0 -1
- package/dist/tools/ctx-recall/types.d.ts +0 -20
- package/dist/tools/ctx-recall/types.d.ts.map +0 -1
- package/dist/tools/look-at/assistant-message-extractor.d.ts +0 -2
- package/dist/tools/look-at/assistant-message-extractor.d.ts.map +0 -1
|
@@ -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,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
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,C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,EAAE,aAAa,CAAC;KAC3B,CAAC;CACL;AAqCD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,gBAAgB;;;;;iBAtF7B,CAAC;;;;;;;;;;;;iBA0B7B,CAAC;eAAiB,CAAC;;mBAmQM;QAAE,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,UAAU,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE;;;SAY7E"}
|
|
@@ -4,11 +4,13 @@ import type { MessageLike } from "./tag-messages";
|
|
|
4
4
|
export interface PreparedCompartmentInjection {
|
|
5
5
|
block: string;
|
|
6
6
|
compartmentEndMessage: number;
|
|
7
|
+
compartmentEndMessageId: string;
|
|
7
8
|
compartmentCount: number;
|
|
8
9
|
skippedVisibleMessages: number;
|
|
9
10
|
factCount: number;
|
|
10
11
|
memoryCount: number;
|
|
11
12
|
}
|
|
13
|
+
export declare function clearInjectionCache(sessionId: string): void;
|
|
12
14
|
export interface CompartmentInjectionResult {
|
|
13
15
|
injected: boolean;
|
|
14
16
|
compartmentEndMessage: number;
|
|
@@ -16,6 +18,6 @@ export interface CompartmentInjectionResult {
|
|
|
16
18
|
skippedVisibleMessages: number;
|
|
17
19
|
}
|
|
18
20
|
export declare function renderMemoryBlock(memories: Memory[]): string | null;
|
|
19
|
-
export declare function prepareCompartmentInjection(db: Database, sessionId: string, messages: MessageLike[], projectPath?: string, injectionBudgetTokens?: number): PreparedCompartmentInjection | null;
|
|
21
|
+
export declare function prepareCompartmentInjection(db: Database, sessionId: string, messages: MessageLike[], isCacheBusting: boolean, projectPath?: string, injectionBudgetTokens?: number): PreparedCompartmentInjection | null;
|
|
20
22
|
export declare function renderCompartmentInjection(sessionId: string, messages: MessageLike[], prepared: PreparedCompartmentInjection): CompartmentInjectionResult;
|
|
21
23
|
//# sourceMappingURL=inject-compartments.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-compartments.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/inject-compartments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAS3C,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,2CAA2C,CAAC;AAExF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,WAAW,4BAA4B;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,0BAA0B;IACvC,QAAQ,EAAE,OAAO,CAAC;IAClB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,sBAAsB,EAAE,MAAM,CAAC;CAClC;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CA6BnE;AA4CD,wBAAgB,2BAA2B,CACvC,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,WAAW,EAAE,EACvB,WAAW,CAAC,EAAE,MAAM,EACpB,qBAAqB,CAAC,EAAE,MAAM,GAC/B,4BAA4B,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"inject-compartments.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/inject-compartments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAS3C,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,2CAA2C,CAAC;AAExF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,WAAW,4BAA4B;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,qBAAqB,EAAE,MAAM,CAAC;IAC9B,uBAAuB,EAAE,MAAM,CAAC;IAChC,gBAAgB,EAAE,MAAM,CAAC;IACzB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACvB;AAUD,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAE3D;AAED,MAAM,WAAW,0BAA0B;IACvC,QAAQ,EAAE,OAAO,CAAC;IAClB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,sBAAsB,EAAE,MAAM,CAAC;CAClC;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CA6BnE;AA4CD,wBAAgB,2BAA2B,CACvC,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,WAAW,EAAE,EACvB,cAAc,EAAE,OAAO,EACvB,WAAW,CAAC,EAAE,MAAM,EACpB,qBAAqB,CAAC,EAAE,MAAM,GAC/B,4BAA4B,GAAG,IAAI,CAwGrC;AAED,wBAAgB,0BAA0B,CACtC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,WAAW,EAAE,EACvB,QAAQ,EAAE,4BAA4B,GACvC,0BAA0B,CAyB5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-compartment-phase.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/transform-compartment-phase.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,eAAe,EAAqB,MAAM,sCAAsC,CAAC;AAC/F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMxD,OAAO,EACH,KAAK,4BAA4B,EAEpC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,UAAU,uBAAuB;IAC7B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,OAAO,CAAC;IACzB,WAAW,EAAE;QAAE,qBAAqB,EAAE,OAAO,CAAA;KAAE,CAAC;IAChD,YAAY,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IACrC,MAAM,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IACjC,EAAE,EAAE,eAAe,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,2BAA2B,EAAE,4BAA4B,GAAG,IAAI,CAAC;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,OAAO,6BAA6B,EAAE,kBAAkB,CAAC;IACvF,iFAAiF;IACjF,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC;IAC9E,2BAA2B,EAAE,4BAA4B,GAAG,IAAI,CAAC;IACjE,qBAAqB,EAAE,OAAO,CAAC;IAC/B,qBAAqB,EAAE,OAAO,CAAC;CAClC,CAAC,
|
|
1
|
+
{"version":3,"file":"transform-compartment-phase.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/transform-compartment-phase.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,eAAe,EAAqB,MAAM,sCAAsC,CAAC;AAC/F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMxD,OAAO,EACH,KAAK,4BAA4B,EAEpC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,UAAU,uBAAuB;IAC7B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,OAAO,CAAC;IACzB,WAAW,EAAE;QAAE,qBAAqB,EAAE,OAAO,CAAA;KAAE,CAAC;IAChD,YAAY,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IACrC,MAAM,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IACjC,EAAE,EAAE,eAAe,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,2BAA2B,EAAE,4BAA4B,GAAG,IAAI,CAAC;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,OAAO,6BAA6B,EAAE,kBAAkB,CAAC;IACvF,iFAAiF;IACjF,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC;IAC9E,2BAA2B,EAAE,4BAA4B,GAAG,IAAI,CAAC;IACjE,qBAAqB,EAAE,OAAO,CAAC;IAC/B,qBAAqB,EAAE,OAAO,CAAC;CAClC,CAAC,CAkKD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-postprocess-phase.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/transform-postprocess-phase.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,eAAe,EAIpB,aAAa,EAGhB,MA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,MAAM,KAChB,OAAO,6BAA6B,EAAE,kBAAkB,CAAC;CACjE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa,IAE3C,QAAQ,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAC7B,QAAQ;IAAE,QAAQ,EAAE,OAAO,EAAE,CAAA;CAAE,KAChC,OAAO,CAAC,IAAI,CAAC,CAoNnB"}
|
package/dist/index.js
CHANGED
|
@@ -14335,14 +14335,20 @@ if (!isTestEnv) {
|
|
|
14335
14335
|
var HISTORIAN_FALLBACK_CHAIN = [
|
|
14336
14336
|
{ providers: ["github-copilot", "anthropic", "opencode"], model: "claude-sonnet-4-6" },
|
|
14337
14337
|
{ providers: ["opencode-go"], model: "minimax-m2.7" },
|
|
14338
|
-
{
|
|
14338
|
+
{
|
|
14339
|
+
providers: ["zai-coding-plan", "bailian-coding-plan", "opencode-go", "opencode"],
|
|
14340
|
+
model: "glm-5"
|
|
14341
|
+
},
|
|
14339
14342
|
{ providers: ["openai", "github-copilot", "opencode"], model: "gpt-5.4" },
|
|
14340
14343
|
{ providers: ["google", "github-copilot", "opencode"], model: "gemini-3.1-pro" }
|
|
14341
14344
|
];
|
|
14342
14345
|
var DREAMER_FALLBACK_CHAIN = [
|
|
14343
14346
|
{ providers: ["github-copilot", "anthropic", "opencode"], model: "claude-sonnet-4-6" },
|
|
14344
14347
|
{ providers: ["google", "github-copilot", "opencode"], model: "gemini-3-flash" },
|
|
14345
|
-
{
|
|
14348
|
+
{
|
|
14349
|
+
providers: ["zai-coding-plan", "bailian-coding-plan", "opencode-go", "opencode"],
|
|
14350
|
+
model: "glm-5"
|
|
14351
|
+
},
|
|
14346
14352
|
{ providers: ["opencode-go"], model: "minimax-m2.7" },
|
|
14347
14353
|
{ providers: ["github-copilot", "openai", "opencode"], model: "gpt-5.4-mini" }
|
|
14348
14354
|
];
|
|
@@ -17281,187 +17287,6 @@ function createEventHandler2(deps) {
|
|
|
17281
17287
|
};
|
|
17282
17288
|
}
|
|
17283
17289
|
|
|
17284
|
-
// src/hooks/magic-context/nudger.ts
|
|
17285
|
-
var RECENT_CTX_REDUCE_WINDOW_MS = 2 * 60 * 1000;
|
|
17286
|
-
function formatLargestTags(tags) {
|
|
17287
|
-
if (tags.length === 0) {
|
|
17288
|
-
return "none";
|
|
17289
|
-
}
|
|
17290
|
-
return tags.map((tag) => `\xA7${tag.tagNumber}\xA7`).join(", ");
|
|
17291
|
-
}
|
|
17292
|
-
function formatOldToolTags(activeTags, protectedCount, count) {
|
|
17293
|
-
const sortedByNumber = [...activeTags].sort((a, b) => a.tagNumber - b.tagNumber);
|
|
17294
|
-
const protectedThreshold = protectedCount > 0 && sortedByNumber.length > protectedCount ? sortedByNumber[sortedByNumber.length - protectedCount].tagNumber : Infinity;
|
|
17295
|
-
const midpoint = Math.floor(sortedByNumber.length / 2);
|
|
17296
|
-
const earlyHalf = sortedByNumber.slice(0, midpoint);
|
|
17297
|
-
const earlyToolTags = earlyHalf.filter((t) => t.type === "tool" && t.tagNumber < protectedThreshold);
|
|
17298
|
-
if (earlyToolTags.length === 0)
|
|
17299
|
-
return "";
|
|
17300
|
-
const selected = earlyToolTags.sort((a, b) => b.byteSize - a.byteSize).slice(0, count);
|
|
17301
|
-
const formatted = selected.sort((a, b) => a.tagNumber - b.tagNumber).map((t) => `\xA7${t.tagNumber}\xA7(${formatBytes(t.byteSize)})`).join(", ");
|
|
17302
|
-
return ` Old tool outputs worth dropping: ${formatted}`;
|
|
17303
|
-
}
|
|
17304
|
-
function createNudger(config2) {
|
|
17305
|
-
const lastReduceAtBySession = config2.recentReduceBySession ?? new Map;
|
|
17306
|
-
return (sessionId, contextUsage, db, topNFn, preloadedTags, messagesSinceLastUser, preloadedSessionMeta) => {
|
|
17307
|
-
const sessionMeta = preloadedSessionMeta ?? getOrCreateSessionMeta(db, sessionId);
|
|
17308
|
-
const now = config2.now?.() ?? Date.now();
|
|
17309
|
-
const lastReduceAt = lastReduceAtBySession.get(sessionId);
|
|
17310
|
-
if (lastReduceAt !== undefined && now - lastReduceAt > RECENT_CTX_REDUCE_WINDOW_MS) {
|
|
17311
|
-
lastReduceAtBySession.delete(sessionId);
|
|
17312
|
-
}
|
|
17313
|
-
if (contextUsage.inputTokens < sessionMeta.lastNudgeTokens) {
|
|
17314
|
-
sessionMeta.lastNudgeTokens = contextUsage.inputTokens;
|
|
17315
|
-
updateSessionMeta(db, sessionId, { lastNudgeTokens: contextUsage.inputTokens });
|
|
17316
|
-
}
|
|
17317
|
-
if (lastReduceAt !== undefined && now - lastReduceAt <= RECENT_CTX_REDUCE_WINDOW_MS) {
|
|
17318
|
-
sessionLog(sessionId, `nudge: suppressed at ${contextUsage.percentage.toFixed(1)}% because ctx_reduce ran recently (${now - lastReduceAt}ms ago)`);
|
|
17319
|
-
return null;
|
|
17320
|
-
}
|
|
17321
|
-
const projectedPercentage = estimateProjectedPercentage(db, sessionId, contextUsage, preloadedTags);
|
|
17322
|
-
const executeThreshold = resolveExecuteThreshold(config2.execute_threshold_percentage, undefined, 65);
|
|
17323
|
-
const currentBand = getRollingNudgeBand(contextUsage.percentage, executeThreshold);
|
|
17324
|
-
const currentInterval = getRollingNudgeIntervalTokens(config2.nudge_interval_tokens, currentBand);
|
|
17325
|
-
const lastBand = sessionMeta.lastNudgeBand;
|
|
17326
|
-
if (getRollingNudgeBandPriority(currentBand) < getRollingNudgeBandPriority(lastBand)) {
|
|
17327
|
-
sessionMeta.lastNudgeBand = currentBand;
|
|
17328
|
-
updateSessionMeta(db, sessionId, { lastNudgeBand: currentBand });
|
|
17329
|
-
}
|
|
17330
|
-
const largest = formatLargestTags(topNFn(db, sessionId, 3));
|
|
17331
|
-
const protectedCount = config2.protected_tags;
|
|
17332
|
-
const activeTags = (preloadedTags ?? getTagsBySession(db, sessionId)).filter((t) => t.status === "active");
|
|
17333
|
-
const highestProtected = activeTags.map((t) => t.tagNumber).sort((a, b) => b - a).slice(0, protectedCount)[0];
|
|
17334
|
-
const protectedHint = highestProtected ? ` Tags \xA7${highestProtected}\xA7 and above are protected (last ${protectedCount}) \u2014 You MUST NOT try to reduce those.` : "";
|
|
17335
|
-
const oldToolHint = formatOldToolTags(activeTags, protectedCount, 5);
|
|
17336
|
-
const iterationThreshold = config2.iteration_nudge_threshold;
|
|
17337
|
-
if (messagesSinceLastUser !== undefined && messagesSinceLastUser >= iterationThreshold && contextUsage.percentage >= 35 && contextUsage.percentage < executeThreshold && contextUsage.inputTokens - sessionMeta.lastNudgeTokens >= currentInterval) {
|
|
17338
|
-
sessionLog(sessionId, `nudge fired: iteration_nudge at ${contextUsage.percentage.toFixed(1)}% (${messagesSinceLastUser} messages since user, interval: ${contextUsage.inputTokens - sessionMeta.lastNudgeTokens}/${currentInterval} tokens)`);
|
|
17339
|
-
updateSessionMeta(db, sessionId, { lastNudgeTokens: contextUsage.inputTokens });
|
|
17340
|
-
return {
|
|
17341
|
-
type: "assistant",
|
|
17342
|
-
text: [
|
|
17343
|
-
`
|
|
17344
|
-
|
|
17345
|
-
<instruction name="context_iteration">`,
|
|
17346
|
-
`CONTEXT ITERATION NOTICE \u2014 ~${Math.round(contextUsage.percentage)}%`,
|
|
17347
|
-
`You have been executing ${messagesSinceLastUser}+ tool calls without clearing old context.`,
|
|
17348
|
-
`Consider using \`ctx_reduce\` to drop old tool outputs you have already processed.`,
|
|
17349
|
-
``,
|
|
17350
|
-
`Largest: ${largest}.${oldToolHint}${protectedHint}`,
|
|
17351
|
-
`Tags are marked with \xA7N\xA7 identifiers (e.g., \xA71\xA7, \xA742\xA7).`,
|
|
17352
|
-
``,
|
|
17353
|
-
`Actions:`,
|
|
17354
|
-
`- drop: Remove content entirely. Best for old tool outputs you already acted on.`,
|
|
17355
|
-
`- Syntax: "3-5", "1,2,9", or "1-5,8,12-15" (bare integers).`,
|
|
17356
|
-
`- Only drop what you have already processed. NEVER drop large ranges blindly.`,
|
|
17357
|
-
`</instruction>`
|
|
17358
|
-
].join(`
|
|
17359
|
-
`)
|
|
17360
|
-
};
|
|
17361
|
-
}
|
|
17362
|
-
const intervalReached = contextUsage.inputTokens - sessionMeta.lastNudgeTokens >= currentInterval;
|
|
17363
|
-
const bandEscalated = lastBand !== null && getRollingNudgeBandPriority(currentBand) > getRollingNudgeBandPriority(lastBand);
|
|
17364
|
-
if (bandEscalated || intervalReached) {
|
|
17365
|
-
const reason = bandEscalated ? `band escalation (${formatRollingNudgeBand(lastBand)} -> ${currentBand})` : `interval ${contextUsage.inputTokens - sessionMeta.lastNudgeTokens}/${currentInterval} tokens`;
|
|
17366
|
-
sessionLog(sessionId, `nudge fired: rolling_${currentBand} at ${contextUsage.percentage.toFixed(1)}% (${reason})`);
|
|
17367
|
-
updateSessionMeta(db, sessionId, {
|
|
17368
|
-
lastNudgeTokens: contextUsage.inputTokens,
|
|
17369
|
-
lastNudgeBand: currentBand
|
|
17370
|
-
});
|
|
17371
|
-
return {
|
|
17372
|
-
type: "assistant",
|
|
17373
|
-
text: buildRollingNudgeText(currentBand, contextUsage.percentage, largest, oldToolHint, protectedHint)
|
|
17374
|
-
};
|
|
17375
|
-
}
|
|
17376
|
-
sessionLog(sessionId, `nudge: none fired at ${contextUsage.percentage.toFixed(1)}% (band=${currentBand} lastBand=${formatRollingNudgeBand(lastBand)} lastNudge=${sessionMeta.lastNudgeTokens} current=${contextUsage.inputTokens} interval=${currentInterval} projected=${projectedPercentage?.toFixed(1) ?? "none"})`);
|
|
17377
|
-
return null;
|
|
17378
|
-
};
|
|
17379
|
-
}
|
|
17380
|
-
function buildRollingNudgeText(band, percentage, largest, oldToolHint, protectedHint) {
|
|
17381
|
-
const titleByBand = {
|
|
17382
|
-
far: "CONTEXT REMINDER",
|
|
17383
|
-
near: "CONTEXT WARNING",
|
|
17384
|
-
urgent: "CONTEXT URGENT",
|
|
17385
|
-
critical: "CONTEXT CRITICAL"
|
|
17386
|
-
};
|
|
17387
|
-
const instructionByBand = {
|
|
17388
|
-
far: "You should use `ctx_reduce` to drop old tool outputs before continuing.",
|
|
17389
|
-
near: "You should call `ctx_reduce` soon to free space before more heavy reads or tool output.",
|
|
17390
|
-
urgent: "You should call `ctx_reduce` before doing more reads or tool-heavy work.",
|
|
17391
|
-
critical: "You MUST call `ctx_reduce` RIGHT NOW before doing ANYTHING else."
|
|
17392
|
-
};
|
|
17393
|
-
const cautionByBand = {
|
|
17394
|
-
far: "- Only drop what you have already processed. NEVER drop large ranges blindly.",
|
|
17395
|
-
near: "- Review what each tag contains. Drop processed outputs, keep anything you might need soon.",
|
|
17396
|
-
urgent: "- Review each tag before deciding. Avoid broad drops that could remove active context.",
|
|
17397
|
-
critical: '- NEVER drop large ranges blindly (e.g., "1-50"). Review each tag before deciding.'
|
|
17398
|
-
};
|
|
17399
|
-
return [
|
|
17400
|
-
`
|
|
17401
|
-
|
|
17402
|
-
<instruction name="context_${band}">`,
|
|
17403
|
-
`${titleByBand[band]} \u2014 ~${Math.round(percentage)}%`,
|
|
17404
|
-
instructionByBand[band],
|
|
17405
|
-
``,
|
|
17406
|
-
`Largest: ${largest}.${oldToolHint}${protectedHint}`,
|
|
17407
|
-
`Tags are marked with \xA7N\xA7 identifiers (e.g., \xA71\xA7, \xA742\xA7).`,
|
|
17408
|
-
``,
|
|
17409
|
-
`Actions:`,
|
|
17410
|
-
`- drop: Remove content entirely. Best for old tool outputs you already acted on.`,
|
|
17411
|
-
`- Syntax: "3-5", "1,2,9", or "1-5,8,12-15" (bare integers).`,
|
|
17412
|
-
cautionByBand[band],
|
|
17413
|
-
`</instruction>`
|
|
17414
|
-
].join(`
|
|
17415
|
-
`);
|
|
17416
|
-
}
|
|
17417
|
-
function estimateProjectedPercentage(db, sessionId, contextUsage, preloadedTags) {
|
|
17418
|
-
const pendingOps = getPendingOps(db, sessionId);
|
|
17419
|
-
const pendingDrops = pendingOps.filter((op) => op.operation === "drop");
|
|
17420
|
-
if (pendingDrops.length === 0) {
|
|
17421
|
-
return null;
|
|
17422
|
-
}
|
|
17423
|
-
const activeTags = (preloadedTags ?? getTagsBySession(db, sessionId)).filter((t) => t.status === "active");
|
|
17424
|
-
const totalActiveBytes = activeTags.reduce((sum, t) => sum + t.byteSize, 0);
|
|
17425
|
-
if (totalActiveBytes === 0) {
|
|
17426
|
-
return null;
|
|
17427
|
-
}
|
|
17428
|
-
const pendingDropTagIds = new Set(pendingDrops.map((op) => op.tagId));
|
|
17429
|
-
const pendingDropBytes = activeTags.filter((t) => pendingDropTagIds.has(t.tagNumber)).reduce((sum, t) => sum + t.byteSize, 0);
|
|
17430
|
-
const dropRatio = pendingDropBytes / totalActiveBytes;
|
|
17431
|
-
return contextUsage.percentage * (1 - dropRatio);
|
|
17432
|
-
}
|
|
17433
|
-
function generateEmergencyNudgeText(db, sessionId, contextUsage, config2) {
|
|
17434
|
-
const largest = formatLargestTags(getTopNBySize(db, sessionId, 3));
|
|
17435
|
-
const protectedCount = config2.protected_tags;
|
|
17436
|
-
const activeTags = getTagsBySession(db, sessionId).filter((t) => t.status === "active");
|
|
17437
|
-
const highestProtected = activeTags.map((t) => t.tagNumber).sort((a, b) => b - a).slice(0, protectedCount)[0];
|
|
17438
|
-
const protectedHint = highestProtected ? ` Tags \xA7${highestProtected}\xA7 and above are protected (last ${protectedCount}) \u2014 You MUST NOT try to reduce those.` : "";
|
|
17439
|
-
const oldToolHint = formatOldToolTags(activeTags, protectedCount, 5);
|
|
17440
|
-
return [
|
|
17441
|
-
`<instruction name="context_emergency">`,
|
|
17442
|
-
`CONTEXT EMERGENCY \u2014 ~${Math.round(contextUsage.percentage)}%. STOP all current work immediately.`,
|
|
17443
|
-
``,
|
|
17444
|
-
`You MUST use \`ctx_reduce\` RIGHT NOW to free space. If context overflows, you lose all work.`,
|
|
17445
|
-
``,
|
|
17446
|
-
`Steps:`,
|
|
17447
|
-
`1. Find OLD tool outputs (grep results, file reads, build logs) you already processed \u2014 look at \xA7N\xA7 tags`,
|
|
17448
|
-
`2. Drop those specifically: e.g. drop="3,7,12" \u2014 NEVER drop large ranges like "1-50"`,
|
|
17449
|
-
`3. KEEP anything related to current task, recent errors, or decisions`,
|
|
17450
|
-
``,
|
|
17451
|
-
`Largest tags: ${largest}.${oldToolHint}${protectedHint}`,
|
|
17452
|
-
`</instruction>`
|
|
17453
|
-
].join(`
|
|
17454
|
-
`);
|
|
17455
|
-
}
|
|
17456
|
-
|
|
17457
|
-
// src/hooks/magic-context/text-complete.ts
|
|
17458
|
-
var TAG_PREFIX_REGEX2 = /^(\u00a7\d+\u00a7\s*)+/;
|
|
17459
|
-
function createTextCompleteHandler() {
|
|
17460
|
-
return async (_input, output) => {
|
|
17461
|
-
output.text = output.text.replace(TAG_PREFIX_REGEX2, "");
|
|
17462
|
-
};
|
|
17463
|
-
}
|
|
17464
|
-
|
|
17465
17290
|
// src/features/magic-context/memory/constants.ts
|
|
17466
17291
|
var PROMOTABLE_CATEGORIES = [
|
|
17467
17292
|
"ARCHITECTURE_DECISIONS",
|
|
@@ -17803,6 +17628,10 @@ function archiveMemory(db, id, reason) {
|
|
|
17803
17628
|
}
|
|
17804
17629
|
|
|
17805
17630
|
// src/hooks/magic-context/inject-compartments.ts
|
|
17631
|
+
var injectionCache = new Map;
|
|
17632
|
+
function clearInjectionCache(sessionId) {
|
|
17633
|
+
injectionCache.delete(sessionId);
|
|
17634
|
+
}
|
|
17806
17635
|
function renderMemoryBlock(memories) {
|
|
17807
17636
|
const byCategory = new Map;
|
|
17808
17637
|
for (const m of memories) {
|
|
@@ -17853,19 +17682,31 @@ function trimMemoriesToBudget(sessionId, memories, budgetTokens) {
|
|
|
17853
17682
|
}
|
|
17854
17683
|
return result;
|
|
17855
17684
|
}
|
|
17856
|
-
function prepareCompartmentInjection(db, sessionId, messages, projectPath, injectionBudgetTokens) {
|
|
17685
|
+
function prepareCompartmentInjection(db, sessionId, messages, isCacheBusting, projectPath, injectionBudgetTokens) {
|
|
17686
|
+
const cached2 = injectionCache.get(sessionId);
|
|
17687
|
+
if (!isCacheBusting && cached2) {
|
|
17688
|
+
if (cached2.compartmentEndMessageId.length > 0) {
|
|
17689
|
+
const cutoffIndex2 = messages.findIndex((message) => message.info.id === cached2.compartmentEndMessageId);
|
|
17690
|
+
if (cutoffIndex2 >= 0) {
|
|
17691
|
+
const remaining = messages.slice(cutoffIndex2 + 1);
|
|
17692
|
+
messages.splice(0, messages.length, ...remaining);
|
|
17693
|
+
}
|
|
17694
|
+
}
|
|
17695
|
+
return cached2;
|
|
17696
|
+
}
|
|
17857
17697
|
const compartments = getCompartments(db, sessionId);
|
|
17858
17698
|
if (compartments.length === 0) {
|
|
17699
|
+
injectionCache.delete(sessionId);
|
|
17859
17700
|
return null;
|
|
17860
17701
|
}
|
|
17861
17702
|
const facts = getSessionFacts(db, sessionId);
|
|
17862
17703
|
let memoryBlock;
|
|
17863
17704
|
let memoryCount = 0;
|
|
17864
17705
|
if (projectPath) {
|
|
17865
|
-
const
|
|
17866
|
-
if (
|
|
17867
|
-
memoryBlock =
|
|
17868
|
-
memoryCount =
|
|
17706
|
+
const cachedMemory = db.prepare("SELECT memory_block_cache, memory_block_count FROM session_meta WHERE session_id = ?").get(sessionId);
|
|
17707
|
+
if (cachedMemory?.memory_block_cache) {
|
|
17708
|
+
memoryBlock = cachedMemory.memory_block_cache;
|
|
17709
|
+
memoryCount = cachedMemory.memory_block_count;
|
|
17869
17710
|
} else {
|
|
17870
17711
|
let memories = getMemoriesByProject(db, projectPath, ["active", "permanent"]);
|
|
17871
17712
|
if (injectionBudgetTokens && memories.length > 0) {
|
|
@@ -17885,14 +17726,17 @@ function prepareCompartmentInjection(db, sessionId, messages, projectPath, injec
|
|
|
17885
17726
|
compartmentCount: compartments.length,
|
|
17886
17727
|
compartmentEndMessage: lastEnd
|
|
17887
17728
|
});
|
|
17888
|
-
|
|
17729
|
+
const result2 = {
|
|
17889
17730
|
block,
|
|
17890
17731
|
compartmentEndMessage: lastEnd,
|
|
17732
|
+
compartmentEndMessageId: "",
|
|
17891
17733
|
compartmentCount: compartments.length,
|
|
17892
17734
|
skippedVisibleMessages: 0,
|
|
17893
17735
|
factCount: facts.length,
|
|
17894
17736
|
memoryCount
|
|
17895
17737
|
};
|
|
17738
|
+
injectionCache.set(sessionId, result2);
|
|
17739
|
+
return result2;
|
|
17896
17740
|
}
|
|
17897
17741
|
let skippedVisibleMessages = 0;
|
|
17898
17742
|
const cutoffIndex = messages.findIndex((message) => message.info.id === lastEndMessageId);
|
|
@@ -17901,14 +17745,17 @@ function prepareCompartmentInjection(db, sessionId, messages, projectPath, injec
|
|
|
17901
17745
|
const remaining = messages.slice(cutoffIndex + 1);
|
|
17902
17746
|
messages.splice(0, messages.length, ...remaining);
|
|
17903
17747
|
}
|
|
17904
|
-
|
|
17748
|
+
const result = {
|
|
17905
17749
|
block,
|
|
17906
17750
|
compartmentEndMessage: lastEnd,
|
|
17751
|
+
compartmentEndMessageId: lastEndMessageId,
|
|
17907
17752
|
compartmentCount: compartments.length,
|
|
17908
17753
|
skippedVisibleMessages,
|
|
17909
17754
|
factCount: facts.length,
|
|
17910
17755
|
memoryCount
|
|
17911
17756
|
};
|
|
17757
|
+
injectionCache.set(sessionId, result);
|
|
17758
|
+
return result;
|
|
17912
17759
|
}
|
|
17913
17760
|
function renderCompartmentInjection(sessionId, messages, prepared) {
|
|
17914
17761
|
const historyBlock = `<session-history>
|
|
@@ -17950,6 +17797,187 @@ function isDroppedPlaceholder(text) {
|
|
|
17950
17797
|
return /^\[dropped \u00A7\d+\u00A7\]$/.test(text.trim());
|
|
17951
17798
|
}
|
|
17952
17799
|
|
|
17800
|
+
// src/hooks/magic-context/nudger.ts
|
|
17801
|
+
var RECENT_CTX_REDUCE_WINDOW_MS = 2 * 60 * 1000;
|
|
17802
|
+
function formatLargestTags(tags) {
|
|
17803
|
+
if (tags.length === 0) {
|
|
17804
|
+
return "none";
|
|
17805
|
+
}
|
|
17806
|
+
return tags.map((tag) => `\xA7${tag.tagNumber}\xA7`).join(", ");
|
|
17807
|
+
}
|
|
17808
|
+
function formatOldToolTags(activeTags, protectedCount, count) {
|
|
17809
|
+
const sortedByNumber = [...activeTags].sort((a, b) => a.tagNumber - b.tagNumber);
|
|
17810
|
+
const protectedThreshold = protectedCount > 0 && sortedByNumber.length > protectedCount ? sortedByNumber[sortedByNumber.length - protectedCount].tagNumber : Infinity;
|
|
17811
|
+
const midpoint = Math.floor(sortedByNumber.length / 2);
|
|
17812
|
+
const earlyHalf = sortedByNumber.slice(0, midpoint);
|
|
17813
|
+
const earlyToolTags = earlyHalf.filter((t) => t.type === "tool" && t.tagNumber < protectedThreshold);
|
|
17814
|
+
if (earlyToolTags.length === 0)
|
|
17815
|
+
return "";
|
|
17816
|
+
const selected = earlyToolTags.sort((a, b) => b.byteSize - a.byteSize).slice(0, count);
|
|
17817
|
+
const formatted = selected.sort((a, b) => a.tagNumber - b.tagNumber).map((t) => `\xA7${t.tagNumber}\xA7(${formatBytes(t.byteSize)})`).join(", ");
|
|
17818
|
+
return ` Old tool outputs worth dropping: ${formatted}`;
|
|
17819
|
+
}
|
|
17820
|
+
function createNudger(config2) {
|
|
17821
|
+
const lastReduceAtBySession = config2.recentReduceBySession ?? new Map;
|
|
17822
|
+
return (sessionId, contextUsage, db, topNFn, preloadedTags, messagesSinceLastUser, preloadedSessionMeta) => {
|
|
17823
|
+
const sessionMeta = preloadedSessionMeta ?? getOrCreateSessionMeta(db, sessionId);
|
|
17824
|
+
const now = config2.now?.() ?? Date.now();
|
|
17825
|
+
const lastReduceAt = lastReduceAtBySession.get(sessionId);
|
|
17826
|
+
if (lastReduceAt !== undefined && now - lastReduceAt > RECENT_CTX_REDUCE_WINDOW_MS) {
|
|
17827
|
+
lastReduceAtBySession.delete(sessionId);
|
|
17828
|
+
}
|
|
17829
|
+
if (contextUsage.inputTokens < sessionMeta.lastNudgeTokens) {
|
|
17830
|
+
sessionMeta.lastNudgeTokens = contextUsage.inputTokens;
|
|
17831
|
+
updateSessionMeta(db, sessionId, { lastNudgeTokens: contextUsage.inputTokens });
|
|
17832
|
+
}
|
|
17833
|
+
if (lastReduceAt !== undefined && now - lastReduceAt <= RECENT_CTX_REDUCE_WINDOW_MS) {
|
|
17834
|
+
sessionLog(sessionId, `nudge: suppressed at ${contextUsage.percentage.toFixed(1)}% because ctx_reduce ran recently (${now - lastReduceAt}ms ago)`);
|
|
17835
|
+
return null;
|
|
17836
|
+
}
|
|
17837
|
+
const projectedPercentage = estimateProjectedPercentage(db, sessionId, contextUsage, preloadedTags);
|
|
17838
|
+
const executeThreshold = resolveExecuteThreshold(config2.execute_threshold_percentage, undefined, 65);
|
|
17839
|
+
const currentBand = getRollingNudgeBand(contextUsage.percentage, executeThreshold);
|
|
17840
|
+
const currentInterval = getRollingNudgeIntervalTokens(config2.nudge_interval_tokens, currentBand);
|
|
17841
|
+
const lastBand = sessionMeta.lastNudgeBand;
|
|
17842
|
+
if (getRollingNudgeBandPriority(currentBand) < getRollingNudgeBandPriority(lastBand)) {
|
|
17843
|
+
sessionMeta.lastNudgeBand = currentBand;
|
|
17844
|
+
updateSessionMeta(db, sessionId, { lastNudgeBand: currentBand });
|
|
17845
|
+
}
|
|
17846
|
+
const largest = formatLargestTags(topNFn(db, sessionId, 3));
|
|
17847
|
+
const protectedCount = config2.protected_tags;
|
|
17848
|
+
const activeTags = (preloadedTags ?? getTagsBySession(db, sessionId)).filter((t) => t.status === "active");
|
|
17849
|
+
const highestProtected = activeTags.map((t) => t.tagNumber).sort((a, b) => b - a).slice(0, protectedCount)[0];
|
|
17850
|
+
const protectedHint = highestProtected ? ` Tags \xA7${highestProtected}\xA7 and above are protected (last ${protectedCount}) \u2014 You MUST NOT try to reduce those.` : "";
|
|
17851
|
+
const oldToolHint = formatOldToolTags(activeTags, protectedCount, 5);
|
|
17852
|
+
const iterationThreshold = config2.iteration_nudge_threshold;
|
|
17853
|
+
if (messagesSinceLastUser !== undefined && messagesSinceLastUser >= iterationThreshold && contextUsage.percentage >= 35 && contextUsage.percentage < executeThreshold && contextUsage.inputTokens - sessionMeta.lastNudgeTokens >= currentInterval) {
|
|
17854
|
+
sessionLog(sessionId, `nudge fired: iteration_nudge at ${contextUsage.percentage.toFixed(1)}% (${messagesSinceLastUser} messages since user, interval: ${contextUsage.inputTokens - sessionMeta.lastNudgeTokens}/${currentInterval} tokens)`);
|
|
17855
|
+
updateSessionMeta(db, sessionId, { lastNudgeTokens: contextUsage.inputTokens });
|
|
17856
|
+
return {
|
|
17857
|
+
type: "assistant",
|
|
17858
|
+
text: [
|
|
17859
|
+
`
|
|
17860
|
+
|
|
17861
|
+
<instruction name="context_iteration">`,
|
|
17862
|
+
`CONTEXT ITERATION NOTICE \u2014 ~${Math.round(contextUsage.percentage)}%`,
|
|
17863
|
+
`You have been executing ${messagesSinceLastUser}+ tool calls without clearing old context.`,
|
|
17864
|
+
`Consider using \`ctx_reduce\` to drop old tool outputs you have already processed.`,
|
|
17865
|
+
``,
|
|
17866
|
+
`Largest: ${largest}.${oldToolHint}${protectedHint}`,
|
|
17867
|
+
`Tags are marked with \xA7N\xA7 identifiers (e.g., \xA71\xA7, \xA742\xA7).`,
|
|
17868
|
+
``,
|
|
17869
|
+
`Actions:`,
|
|
17870
|
+
`- drop: Remove content entirely. Best for old tool outputs you already acted on.`,
|
|
17871
|
+
`- Syntax: "3-5", "1,2,9", or "1-5,8,12-15" (bare integers).`,
|
|
17872
|
+
`- Only drop what you have already processed. NEVER drop large ranges blindly.`,
|
|
17873
|
+
`</instruction>`
|
|
17874
|
+
].join(`
|
|
17875
|
+
`)
|
|
17876
|
+
};
|
|
17877
|
+
}
|
|
17878
|
+
const intervalReached = contextUsage.inputTokens - sessionMeta.lastNudgeTokens >= currentInterval;
|
|
17879
|
+
const bandEscalated = lastBand !== null && getRollingNudgeBandPriority(currentBand) > getRollingNudgeBandPriority(lastBand);
|
|
17880
|
+
if (bandEscalated || intervalReached) {
|
|
17881
|
+
const reason = bandEscalated ? `band escalation (${formatRollingNudgeBand(lastBand)} -> ${currentBand})` : `interval ${contextUsage.inputTokens - sessionMeta.lastNudgeTokens}/${currentInterval} tokens`;
|
|
17882
|
+
sessionLog(sessionId, `nudge fired: rolling_${currentBand} at ${contextUsage.percentage.toFixed(1)}% (${reason})`);
|
|
17883
|
+
updateSessionMeta(db, sessionId, {
|
|
17884
|
+
lastNudgeTokens: contextUsage.inputTokens,
|
|
17885
|
+
lastNudgeBand: currentBand
|
|
17886
|
+
});
|
|
17887
|
+
return {
|
|
17888
|
+
type: "assistant",
|
|
17889
|
+
text: buildRollingNudgeText(currentBand, contextUsage.percentage, largest, oldToolHint, protectedHint)
|
|
17890
|
+
};
|
|
17891
|
+
}
|
|
17892
|
+
sessionLog(sessionId, `nudge: none fired at ${contextUsage.percentage.toFixed(1)}% (band=${currentBand} lastBand=${formatRollingNudgeBand(lastBand)} lastNudge=${sessionMeta.lastNudgeTokens} current=${contextUsage.inputTokens} interval=${currentInterval} projected=${projectedPercentage?.toFixed(1) ?? "none"})`);
|
|
17893
|
+
return null;
|
|
17894
|
+
};
|
|
17895
|
+
}
|
|
17896
|
+
function buildRollingNudgeText(band, percentage, largest, oldToolHint, protectedHint) {
|
|
17897
|
+
const titleByBand = {
|
|
17898
|
+
far: "CONTEXT REMINDER",
|
|
17899
|
+
near: "CONTEXT WARNING",
|
|
17900
|
+
urgent: "CONTEXT URGENT",
|
|
17901
|
+
critical: "CONTEXT CRITICAL"
|
|
17902
|
+
};
|
|
17903
|
+
const instructionByBand = {
|
|
17904
|
+
far: "You should use `ctx_reduce` to drop old tool outputs before continuing.",
|
|
17905
|
+
near: "You should call `ctx_reduce` soon to free space before more heavy reads or tool output.",
|
|
17906
|
+
urgent: "You should call `ctx_reduce` before doing more reads or tool-heavy work.",
|
|
17907
|
+
critical: "You MUST call `ctx_reduce` RIGHT NOW before doing ANYTHING else."
|
|
17908
|
+
};
|
|
17909
|
+
const cautionByBand = {
|
|
17910
|
+
far: "- Only drop what you have already processed. NEVER drop large ranges blindly.",
|
|
17911
|
+
near: "- Review what each tag contains. Drop processed outputs, keep anything you might need soon.",
|
|
17912
|
+
urgent: "- Review each tag before deciding. Avoid broad drops that could remove active context.",
|
|
17913
|
+
critical: '- NEVER drop large ranges blindly (e.g., "1-50"). Review each tag before deciding.'
|
|
17914
|
+
};
|
|
17915
|
+
return [
|
|
17916
|
+
`
|
|
17917
|
+
|
|
17918
|
+
<instruction name="context_${band}">`,
|
|
17919
|
+
`${titleByBand[band]} \u2014 ~${Math.round(percentage)}%`,
|
|
17920
|
+
instructionByBand[band],
|
|
17921
|
+
``,
|
|
17922
|
+
`Largest: ${largest}.${oldToolHint}${protectedHint}`,
|
|
17923
|
+
`Tags are marked with \xA7N\xA7 identifiers (e.g., \xA71\xA7, \xA742\xA7).`,
|
|
17924
|
+
``,
|
|
17925
|
+
`Actions:`,
|
|
17926
|
+
`- drop: Remove content entirely. Best for old tool outputs you already acted on.`,
|
|
17927
|
+
`- Syntax: "3-5", "1,2,9", or "1-5,8,12-15" (bare integers).`,
|
|
17928
|
+
cautionByBand[band],
|
|
17929
|
+
`</instruction>`
|
|
17930
|
+
].join(`
|
|
17931
|
+
`);
|
|
17932
|
+
}
|
|
17933
|
+
function estimateProjectedPercentage(db, sessionId, contextUsage, preloadedTags) {
|
|
17934
|
+
const pendingOps = getPendingOps(db, sessionId);
|
|
17935
|
+
const pendingDrops = pendingOps.filter((op) => op.operation === "drop");
|
|
17936
|
+
if (pendingDrops.length === 0) {
|
|
17937
|
+
return null;
|
|
17938
|
+
}
|
|
17939
|
+
const activeTags = (preloadedTags ?? getTagsBySession(db, sessionId)).filter((t) => t.status === "active");
|
|
17940
|
+
const totalActiveBytes = activeTags.reduce((sum, t) => sum + t.byteSize, 0);
|
|
17941
|
+
if (totalActiveBytes === 0) {
|
|
17942
|
+
return null;
|
|
17943
|
+
}
|
|
17944
|
+
const pendingDropTagIds = new Set(pendingDrops.map((op) => op.tagId));
|
|
17945
|
+
const pendingDropBytes = activeTags.filter((t) => pendingDropTagIds.has(t.tagNumber)).reduce((sum, t) => sum + t.byteSize, 0);
|
|
17946
|
+
const dropRatio = pendingDropBytes / totalActiveBytes;
|
|
17947
|
+
return contextUsage.percentage * (1 - dropRatio);
|
|
17948
|
+
}
|
|
17949
|
+
function generateEmergencyNudgeText(db, sessionId, contextUsage, config2) {
|
|
17950
|
+
const largest = formatLargestTags(getTopNBySize(db, sessionId, 3));
|
|
17951
|
+
const protectedCount = config2.protected_tags;
|
|
17952
|
+
const activeTags = getTagsBySession(db, sessionId).filter((t) => t.status === "active");
|
|
17953
|
+
const highestProtected = activeTags.map((t) => t.tagNumber).sort((a, b) => b - a).slice(0, protectedCount)[0];
|
|
17954
|
+
const protectedHint = highestProtected ? ` Tags \xA7${highestProtected}\xA7 and above are protected (last ${protectedCount}) \u2014 You MUST NOT try to reduce those.` : "";
|
|
17955
|
+
const oldToolHint = formatOldToolTags(activeTags, protectedCount, 5);
|
|
17956
|
+
return [
|
|
17957
|
+
`<instruction name="context_emergency">`,
|
|
17958
|
+
`CONTEXT EMERGENCY \u2014 ~${Math.round(contextUsage.percentage)}%. STOP all current work immediately.`,
|
|
17959
|
+
``,
|
|
17960
|
+
`You MUST use \`ctx_reduce\` RIGHT NOW to free space. If context overflows, you lose all work.`,
|
|
17961
|
+
``,
|
|
17962
|
+
`Steps:`,
|
|
17963
|
+
`1. Find OLD tool outputs (grep results, file reads, build logs) you already processed \u2014 look at \xA7N\xA7 tags`,
|
|
17964
|
+
`2. Drop those specifically: e.g. drop="3,7,12" \u2014 NEVER drop large ranges like "1-50"`,
|
|
17965
|
+
`3. KEEP anything related to current task, recent errors, or decisions`,
|
|
17966
|
+
``,
|
|
17967
|
+
`Largest tags: ${largest}.${oldToolHint}${protectedHint}`,
|
|
17968
|
+
`</instruction>`
|
|
17969
|
+
].join(`
|
|
17970
|
+
`);
|
|
17971
|
+
}
|
|
17972
|
+
|
|
17973
|
+
// src/hooks/magic-context/text-complete.ts
|
|
17974
|
+
var TAG_PREFIX_REGEX2 = /^(\u00a7\d+\u00a7\s*)+/;
|
|
17975
|
+
function createTextCompleteHandler() {
|
|
17976
|
+
return async (_input, output) => {
|
|
17977
|
+
output.text = output.text.replace(TAG_PREFIX_REGEX2, "");
|
|
17978
|
+
};
|
|
17979
|
+
}
|
|
17980
|
+
|
|
17953
17981
|
// src/hooks/magic-context/note-nudger.ts
|
|
17954
17982
|
var stateBySession = new Map;
|
|
17955
17983
|
function getState(sessionId) {
|
|
@@ -19718,7 +19746,7 @@ async function runCompartmentPhase(args) {
|
|
|
19718
19746
|
sessionLog(args.sessionId, reason);
|
|
19719
19747
|
await activeRun;
|
|
19720
19748
|
sessionLog(args.sessionId, "transform: compartment agent completed, refreshing compartment coverage");
|
|
19721
|
-
pendingCompartmentInjection = prepareCompartmentInjection(args.db, args.resolvedSessionId, args.messages, args.projectPath, args.injectionBudgetTokens);
|
|
19749
|
+
pendingCompartmentInjection = prepareCompartmentInjection(args.db, args.resolvedSessionId, args.messages, args.cacheAlreadyBusting ?? false, args.projectPath, args.injectionBudgetTokens);
|
|
19722
19750
|
}
|
|
19723
19751
|
if (args.canRunCompartments && args.sessionMeta.compartmentInProgress && !getActiveCompartmentRun(args.sessionId)) {
|
|
19724
19752
|
if (!hasEligibleHistoryForCompartment()) {
|
|
@@ -20400,7 +20428,6 @@ function tagMessages(sessionId, messages, tagger, db) {
|
|
|
20400
20428
|
}
|
|
20401
20429
|
// src/hooks/magic-context/nudge-injection.ts
|
|
20402
20430
|
var TRAILING_CONTEXT_NUDGE_PATTERN = /(?:\s*<instruction name="(?:context_[^"]+|deferred_notes)">[\s\S]*?<\/instruction>\s*)+$/;
|
|
20403
|
-
var TRAILING_DEFERRED_NOTES_PATTERN = /(?:\s*<instruction name="deferred_notes">[\s\S]*?<\/instruction>\s*)+$/;
|
|
20404
20431
|
function isToolProtocolPart(part) {
|
|
20405
20432
|
if (part === null || typeof part !== "object")
|
|
20406
20433
|
return false;
|
|
@@ -20422,12 +20449,6 @@ function stripTrailingExactNudge(text, nudgeText) {
|
|
|
20422
20449
|
function stripTrailingContextNudges(text) {
|
|
20423
20450
|
return text.replace(TRAILING_CONTEXT_NUDGE_PATTERN, "");
|
|
20424
20451
|
}
|
|
20425
|
-
function stripTrailingDeferredNotes(text) {
|
|
20426
|
-
return text.replace(TRAILING_DEFERRED_NOTES_PATTERN, "");
|
|
20427
|
-
}
|
|
20428
|
-
function isAppendableAssistantMessage(message) {
|
|
20429
|
-
return message.info.role === "assistant" && !hasToolProtocolParts(message) && !isMessageDropped(message);
|
|
20430
|
-
}
|
|
20431
20452
|
function mergeNudgeText(text, currentNudgeText, nextNudgeText) {
|
|
20432
20453
|
const withoutCurrentNudge = stripTrailingExactNudge(text, currentNudgeText);
|
|
20433
20454
|
const withoutManagedNudges = stripTrailingContextNudges(withoutCurrentNudge);
|
|
@@ -20505,40 +20526,6 @@ function appendNudgeToAssistant(messages, nudge, nudgePlacements, sessionId) {
|
|
|
20505
20526
|
}
|
|
20506
20527
|
sessionLog(sessionId, `nudge placement failed: no suitable assistant message found (${messages.length} messages)`);
|
|
20507
20528
|
}
|
|
20508
|
-
function appendSupplementalNudgeToAssistant(messages, nudge, nudgePlacements, sessionId) {
|
|
20509
|
-
const appendToMessage = (message) => {
|
|
20510
|
-
if (!isAppendableAssistantMessage(message))
|
|
20511
|
-
return false;
|
|
20512
|
-
for (let j = message.parts.length - 1;j >= 0; j--) {
|
|
20513
|
-
const part = message.parts[j];
|
|
20514
|
-
if (isTextPart(part)) {
|
|
20515
|
-
const nextText = `${stripTrailingDeferredNotes(part.text)}${nudge}`;
|
|
20516
|
-
if (nextText !== part.text) {
|
|
20517
|
-
part.text = nextText;
|
|
20518
|
-
}
|
|
20519
|
-
return true;
|
|
20520
|
-
}
|
|
20521
|
-
}
|
|
20522
|
-
message.parts.push({ type: "text", text: nudge });
|
|
20523
|
-
return true;
|
|
20524
|
-
};
|
|
20525
|
-
const placement = nudgePlacements.get(sessionId);
|
|
20526
|
-
if (!placement)
|
|
20527
|
-
return false;
|
|
20528
|
-
for (const message of messages) {
|
|
20529
|
-
if (message.info.id !== placement.messageId)
|
|
20530
|
-
continue;
|
|
20531
|
-
return appendToMessage(message);
|
|
20532
|
-
}
|
|
20533
|
-
return false;
|
|
20534
|
-
}
|
|
20535
|
-
function canAppendSupplementalNudgeToAssistant(messages, nudgePlacements, sessionId) {
|
|
20536
|
-
const placement = nudgePlacements.get(sessionId);
|
|
20537
|
-
if (!placement)
|
|
20538
|
-
return false;
|
|
20539
|
-
const anchoredMessage = messages.find((message) => message.info.id === placement.messageId);
|
|
20540
|
-
return anchoredMessage ? isAppendableAssistantMessage(anchoredMessage) : false;
|
|
20541
|
-
}
|
|
20542
20529
|
|
|
20543
20530
|
// src/hooks/magic-context/apply-context-nudge.ts
|
|
20544
20531
|
function applyContextNudge(messages, nudge, nudgePlacements, sessionId) {
|
|
@@ -20783,6 +20770,7 @@ function runPostTransformPhase(args) {
|
|
|
20783
20770
|
const pendingOps = shouldReadPendingOps ? getPendingOps(args.db, args.sessionId) : [];
|
|
20784
20771
|
const hasPendingUserOps = pendingOps.length > 0;
|
|
20785
20772
|
const shouldApplyPendingOps = (args.schedulerDecision === "execute" || isExplicitFlush) && !compartmentRunning;
|
|
20773
|
+
const isCacheBustingPass = isExplicitFlush || shouldApplyPendingOps;
|
|
20786
20774
|
const shouldRunHeuristics = args.fullFeatureMode && !compartmentRunning && (isExplicitFlush || forceMaterialization || hasPendingUserOps && args.schedulerDecision === "execute" && !alreadyRanThisTurn);
|
|
20787
20775
|
if (shouldRunHeuristics) {
|
|
20788
20776
|
const reason = isExplicitFlush ? "explicit_flush" : forceMaterialization ? `force_materialization (${args.contextUsage.percentage.toFixed(1)}% >= ${args.forceMaterializationPercentage}%)` : `pending_ops_execute (pendingOps=${pendingOps.length}, scheduler=${args.schedulerDecision})`;
|
|
@@ -20848,9 +20836,10 @@ function runPostTransformPhase(args) {
|
|
|
20848
20836
|
} catch (error48) {
|
|
20849
20837
|
sessionLog(args.sessionId, "transform failed applying pending operations:", error48);
|
|
20850
20838
|
updateSessionMeta(args.db, args.sessionId, { lastTransformError: getErrorMessage(error48) });
|
|
20851
|
-
|
|
20839
|
+
if (isCacheBustingPass)
|
|
20840
|
+
args.nudgePlacements.clear(args.sessionId);
|
|
20852
20841
|
}
|
|
20853
|
-
if (didMutateFromPendingOperations) {
|
|
20842
|
+
if (didMutateFromPendingOperations && isCacheBustingPass) {
|
|
20854
20843
|
args.nudgePlacements.clear(args.sessionId);
|
|
20855
20844
|
}
|
|
20856
20845
|
if (shouldRunHeuristics && (args.didMutateFromFlushedStatuses || didMutateFromPendingOperations)) {
|
|
@@ -20872,16 +20861,18 @@ function runPostTransformPhase(args) {
|
|
|
20872
20861
|
if (strippedDropped > 0) {
|
|
20873
20862
|
sessionLog(args.sessionId, `stripped ${strippedDropped} empty dropped-placeholder messages`);
|
|
20874
20863
|
}
|
|
20875
|
-
|
|
20876
|
-
|
|
20877
|
-
|
|
20878
|
-
|
|
20864
|
+
if (isCacheBustingPass) {
|
|
20865
|
+
const protectedTailStart = Math.max(0, args.messages.length - args.protectedTags * 2);
|
|
20866
|
+
const strippedSystemInjected = stripSystemInjectedMessages(args.messages, protectedTailStart);
|
|
20867
|
+
if (strippedSystemInjected > 0) {
|
|
20868
|
+
sessionLog(args.sessionId, `stripped ${strippedSystemInjected} system-injected messages (notifications/reminders)`);
|
|
20869
|
+
}
|
|
20879
20870
|
}
|
|
20880
20871
|
const pendingUserTurnReminder = getPersistedStickyTurnReminder(args.db, args.sessionId);
|
|
20881
20872
|
if (pendingUserTurnReminder) {
|
|
20882
|
-
if (args.hasRecentReduceCall) {
|
|
20873
|
+
if (args.hasRecentReduceCall && isCacheBustingPass) {
|
|
20883
20874
|
clearPersistedStickyTurnReminder(args.db, args.sessionId);
|
|
20884
|
-
sessionLog(args.sessionId, "sticky turn reminder cleared \u2014 ctx_reduce found in recent messages");
|
|
20875
|
+
sessionLog(args.sessionId, "sticky turn reminder cleared \u2014 ctx_reduce found in recent messages (cache-busting pass)");
|
|
20885
20876
|
} else {
|
|
20886
20877
|
if (pendingUserTurnReminder.messageId) {
|
|
20887
20878
|
const reinjected = appendReminderToUserMessageById(args.messages, pendingUserTurnReminder.messageId, pendingUserTurnReminder.text);
|
|
@@ -20908,15 +20899,20 @@ function runPostTransformPhase(args) {
|
|
|
20908
20899
|
const t9 = performance.now();
|
|
20909
20900
|
applyContextNudge(args.messages, nudge, args.nudgePlacements, args.sessionId);
|
|
20910
20901
|
logTransformTiming(args.sessionId, "applyContextNudge", t9);
|
|
20911
|
-
} else {
|
|
20902
|
+
} else if (isCacheBustingPass) {
|
|
20912
20903
|
args.nudgePlacements.clear(args.sessionId);
|
|
20904
|
+
} else {
|
|
20905
|
+
const existing = args.nudgePlacements.get(args.sessionId);
|
|
20906
|
+
if (existing) {
|
|
20907
|
+
reinjectNudgeAtAnchor(args.messages, existing.nudgeText, args.nudgePlacements, args.sessionId);
|
|
20908
|
+
}
|
|
20913
20909
|
}
|
|
20914
|
-
const canInjectDeferredNoteNudge = canAppendSupplementalNudgeToAssistant(args.messages, args.nudgePlacements, args.sessionId);
|
|
20915
20910
|
const deferredNoteText = getNoteNudgeText(args.db, args.sessionId);
|
|
20916
|
-
if (deferredNoteText
|
|
20917
|
-
|
|
20911
|
+
if (deferredNoteText) {
|
|
20912
|
+
const noteInstruction = `
|
|
20918
20913
|
|
|
20919
|
-
<instruction name="deferred_notes">${deferredNoteText}</instruction
|
|
20914
|
+
<instruction name="deferred_notes">${deferredNoteText}</instruction>`;
|
|
20915
|
+
appendReminderToLatestUserMessage(args.messages, noteInstruction);
|
|
20920
20916
|
}
|
|
20921
20917
|
} else {
|
|
20922
20918
|
args.nudgePlacements.clear(args.sessionId);
|
|
@@ -20983,10 +20979,13 @@ function createTransform(deps) {
|
|
|
20983
20979
|
const fullFeatureMode = !reducedMode;
|
|
20984
20980
|
const compartmentDirectory = deps.directory ?? "";
|
|
20985
20981
|
const canRunCompartments = fullFeatureMode && deps.client !== undefined && compartmentDirectory.length > 0;
|
|
20982
|
+
const contextUsageEarly = loadContextUsage(deps.contextUsageMap, db, sessionId);
|
|
20983
|
+
const schedulerDecisionEarly = resolveSchedulerDecision(deps.scheduler, sessionMeta, contextUsageEarly, sessionId);
|
|
20984
|
+
const isCacheBusting = deps.flushedSessions.has(sessionId) || schedulerDecisionEarly === "execute";
|
|
20986
20985
|
let pendingCompartmentInjection = null;
|
|
20987
20986
|
if (fullFeatureMode) {
|
|
20988
20987
|
const projectPath = deps.memoryConfig?.enabled ? resolveProjectIdentity(deps.directory ?? process.cwd()) : undefined;
|
|
20989
|
-
pendingCompartmentInjection = prepareCompartmentInjection(db, sessionId, messages, projectPath, deps.memoryConfig?.injectionBudgetTokens);
|
|
20988
|
+
pendingCompartmentInjection = prepareCompartmentInjection(db, sessionId, messages, isCacheBusting, projectPath, deps.memoryConfig?.injectionBudgetTokens);
|
|
20990
20989
|
}
|
|
20991
20990
|
let targets = new Map;
|
|
20992
20991
|
let reasoningByMessage = new Map;
|
|
@@ -21023,9 +21022,10 @@ function createTransform(deps) {
|
|
|
21023
21022
|
logTransformTiming(sessionId, "batchFinalize:flushed", t2);
|
|
21024
21023
|
} catch (error48) {
|
|
21025
21024
|
sessionLog(sessionId, "transform failed applying flushed statuses:", error48);
|
|
21026
|
-
|
|
21025
|
+
if (isCacheBusting)
|
|
21026
|
+
deps.nudgePlacements.clear(sessionId);
|
|
21027
21027
|
}
|
|
21028
|
-
if (didMutateFromFlushedStatuses) {
|
|
21028
|
+
if (didMutateFromFlushedStatuses && isCacheBusting) {
|
|
21029
21029
|
deps.nudgePlacements.clear(sessionId);
|
|
21030
21030
|
}
|
|
21031
21031
|
const t3 = performance.now();
|
|
@@ -21040,9 +21040,8 @@ function createTransform(deps) {
|
|
|
21040
21040
|
watermark = tag.tagNumber;
|
|
21041
21041
|
}
|
|
21042
21042
|
}
|
|
21043
|
-
const contextUsage =
|
|
21044
|
-
const schedulerDecision =
|
|
21045
|
-
const isCacheBusting = deps.flushedSessions.has(sessionId) || schedulerDecision === "execute";
|
|
21043
|
+
const contextUsage = contextUsageEarly;
|
|
21044
|
+
const schedulerDecision = schedulerDecisionEarly;
|
|
21046
21045
|
const rawGetNotifParams = deps.getNotificationParams;
|
|
21047
21046
|
const compartmentPhase = await runCompartmentPhase({
|
|
21048
21047
|
canRunCompartments,
|
|
@@ -21519,7 +21518,10 @@ function createMagicContextHook(deps) {
|
|
|
21519
21518
|
tagger: deps.tagger,
|
|
21520
21519
|
db,
|
|
21521
21520
|
nudgePlacements,
|
|
21522
|
-
onSessionCacheInvalidated:
|
|
21521
|
+
onSessionCacheInvalidated: (sessionId) => {
|
|
21522
|
+
clearInjectionCache(sessionId);
|
|
21523
|
+
deps.onSessionCacheInvalidated?.(sessionId);
|
|
21524
|
+
}
|
|
21523
21525
|
});
|
|
21524
21526
|
const runDreamQueueInBackground = () => {
|
|
21525
21527
|
const dreaming = deps.config.dreamer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-session-hooks.d.ts","sourceRoot":"","sources":["../../../src/plugin/hooks/create-session-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAU7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACrC,GAAG,EAAE,aAAa,CAAC;IACnB,YAAY,EAAE,wBAAwB,CAAC;CAC1C;;;;;;qBAgBW,CAAH;;;;;;;;;;;;qBAkBqC,CAAC;mBAAiB,CAAC;;;;;
|
|
1
|
+
{"version":3,"file":"create-session-hooks.d.ts","sourceRoot":"","sources":["../../../src/plugin/hooks/create-session-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAU7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACrC,GAAG,EAAE,aAAa,CAAC;IACnB,YAAY,EAAE,wBAAwB,CAAC;CAC1C;;;;;;qBAgBW,CAAH;;;;;;;;;;;;qBAkBqC,CAAC;mBAAiB,CAAC;;;;;0BAQk0S,CAAC;;;;;;EADn4S"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-requirements.d.ts","sourceRoot":"","sources":["../../src/shared/model-requirements.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IACxB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAChC,aAAa,EAAE,aAAa,EAAE,CAAC;CAClC,CAAC;
|
|
1
|
+
{"version":3,"file":"model-requirements.d.ts","sourceRoot":"","sources":["../../src/shared/model-requirements.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IACxB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAChC,aAAa,EAAE,aAAa,EAAE,CAAC;CAClC,CAAC;AAqCF,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAI1E,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,MAAM,EAAE,CAQpE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAI1E"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"builtin-agents.d.ts","sourceRoot":"","sources":["../../src/agents/builtin-agents.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,sBAAsB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,SAAS,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,cAAc,EAAE,sBAAsB,EAalD,CAAC"}
|
package/dist/agents/types.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { AgentConfig } from "@opencode-ai/sdk";
|
|
2
|
-
export type AgentMode = "primary" | "subagent" | "all";
|
|
3
|
-
export interface AgentPromptMetadata {
|
|
4
|
-
category: "exploration" | "specialist" | "advisor" | "utility";
|
|
5
|
-
cost: "FREE" | "CHEAP" | "EXPENSIVE";
|
|
6
|
-
triggers: Array<{
|
|
7
|
-
domain: string;
|
|
8
|
-
trigger: string;
|
|
9
|
-
}>;
|
|
10
|
-
useWhen?: string[];
|
|
11
|
-
avoidWhen?: string[];
|
|
12
|
-
dedicatedSection?: string;
|
|
13
|
-
promptAlias?: string;
|
|
14
|
-
keyTrigger?: string;
|
|
15
|
-
}
|
|
16
|
-
export type AgentFactory = ((model?: string) => AgentConfig) & {
|
|
17
|
-
mode: AgentMode;
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/agents/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,KAAK,CAAC;AAEvD,MAAM,WAAW,mBAAmB;IAChC,QAAQ,EAAE,aAAa,GAAG,YAAY,GAAG,SAAS,GAAG,SAAS,CAAC;IAC/D,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,WAAW,CAAC;IACrC,QAAQ,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,WAAW,CAAC,GAAG;IAC3D,IAAI,EAAE,SAAS,CAAC;CACnB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model-fallback-requirements.d.ts","sourceRoot":"","sources":["../../src/cli/model-fallback-requirements.ts"],"names":[],"mappings":"AAEA,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAErF"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/** @deprecated Legacy deterministic dream task retained for fallback/debugging only. */
|
|
2
|
-
import type { Database } from "bun:sqlite";
|
|
3
|
-
export interface ConsolidationResult {
|
|
4
|
-
clustersFound: number;
|
|
5
|
-
memoriesMerged: number;
|
|
6
|
-
memoriesSuperseded: number;
|
|
7
|
-
}
|
|
8
|
-
export declare function runConsolidateTask(db: Database, projectPath: string): Promise<ConsolidationResult>;
|
|
9
|
-
//# sourceMappingURL=task-consolidate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"task-consolidate.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/dreamer/task-consolidate.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA4B3C,MAAM,WAAW,mBAAmB;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;CAC9B;AAmCD,wBAAsB,kBAAkB,CACpC,EAAE,EAAE,QAAQ,EACZ,WAAW,EAAE,MAAM,GACpB,OAAO,CAAC,mBAAmB,CAAC,CA0G9B"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/** @deprecated Legacy deterministic dream task retained for fallback/debugging only. */
|
|
2
|
-
import type { Database } from "bun:sqlite";
|
|
3
|
-
export interface DecayResult {
|
|
4
|
-
expired: number;
|
|
5
|
-
promoted: number;
|
|
6
|
-
archived: number;
|
|
7
|
-
}
|
|
8
|
-
export declare function runDecayTask(db: Database, config: {
|
|
9
|
-
promotionThreshold: number;
|
|
10
|
-
}, projectPath: string): Promise<DecayResult>;
|
|
11
|
-
//# sourceMappingURL=task-decay.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"task-decay.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/dreamer/task-decay.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAS3C,MAAM,WAAW,WAAW;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAMD,wBAAsB,YAAY,CAC9B,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE;IAAE,kBAAkB,EAAE,MAAM,CAAA;CAAE,EACtC,WAAW,EAAE,MAAM,GACpB,OAAO,CAAC,WAAW,CAAC,CAqDtB"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Database } from "bun:sqlite";
|
|
2
|
-
import type { SidekickConfig, SidekickRunState } from "../sidekick/types";
|
|
3
|
-
/**
|
|
4
|
-
* Build the <project-memory> XML injection block from stored memories.
|
|
5
|
-
* Returns null if no memories are available for the project.
|
|
6
|
-
*
|
|
7
|
-
* Budget is in approximate tokens (~3.5 chars per token).
|
|
8
|
-
*/
|
|
9
|
-
export declare function buildMemoryInjectionBlock(db: Database, projectPath: string, budgetTokens: number, sidekickConfig?: SidekickConfig, sidekickState?: SidekickRunState, sessionId?: string, userMessage?: string): Promise<string | null>;
|
|
10
|
-
//# sourceMappingURL=injection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"injection.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/memory/injection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3C,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAwD1E;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC3C,EAAE,EAAE,QAAQ,EACZ,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,cAAc,CAAC,EAAE,cAAc,EAC/B,aAAa,CAAC,EAAE,gBAAgB,EAChC,SAAS,CAAC,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA4ExB"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { OpenAIChatCompletionResponse, OpenAIChatMessage, OpenAIChatTool } from "./types";
|
|
2
|
-
export declare function chatCompletions(args: {
|
|
3
|
-
endpoint: string;
|
|
4
|
-
apiKey: string;
|
|
5
|
-
model: string;
|
|
6
|
-
messages: OpenAIChatMessage[];
|
|
7
|
-
timeoutMs: number;
|
|
8
|
-
tools?: OpenAIChatTool[];
|
|
9
|
-
temperature?: number;
|
|
10
|
-
sessionId?: string;
|
|
11
|
-
}): Promise<OpenAIChatCompletionResponse>;
|
|
12
|
-
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/sidekick/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,4BAA4B,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAe/F,wBAAsB,eAAe,CAAC,IAAI,EAAE;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,4BAA4B,CAAC,CA2DxC"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export interface SidekickConfig {
|
|
2
|
-
enabled: boolean;
|
|
3
|
-
endpoint: string;
|
|
4
|
-
model: string;
|
|
5
|
-
api_key: string;
|
|
6
|
-
max_tool_calls: number;
|
|
7
|
-
timeout_ms: number;
|
|
8
|
-
system_prompt?: string;
|
|
9
|
-
}
|
|
10
|
-
export type OpenAIMessageRole = "system" | "user" | "assistant" | "tool";
|
|
11
|
-
export interface OpenAIChatToolFunction {
|
|
12
|
-
name: string;
|
|
13
|
-
description: string;
|
|
14
|
-
parameters: Record<string, unknown>;
|
|
15
|
-
}
|
|
16
|
-
export interface OpenAIChatTool {
|
|
17
|
-
type: "function";
|
|
18
|
-
function: OpenAIChatToolFunction;
|
|
19
|
-
}
|
|
20
|
-
export interface OpenAIChatToolCall {
|
|
21
|
-
id: string;
|
|
22
|
-
type: "function";
|
|
23
|
-
function: {
|
|
24
|
-
name: string;
|
|
25
|
-
arguments: string;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
export interface OpenAIChatMessage {
|
|
29
|
-
role: OpenAIMessageRole;
|
|
30
|
-
content: string | null;
|
|
31
|
-
name?: string;
|
|
32
|
-
tool_call_id?: string;
|
|
33
|
-
tool_calls?: OpenAIChatToolCall[];
|
|
34
|
-
}
|
|
35
|
-
export interface OpenAIChatCompletionChoice {
|
|
36
|
-
message: OpenAIChatMessage;
|
|
37
|
-
finish_reason: string | null;
|
|
38
|
-
}
|
|
39
|
-
export interface OpenAIChatCompletionUsage {
|
|
40
|
-
prompt_tokens?: number;
|
|
41
|
-
completion_tokens?: number;
|
|
42
|
-
total_tokens?: number;
|
|
43
|
-
}
|
|
44
|
-
export interface OpenAIChatCompletionResponse {
|
|
45
|
-
choices: OpenAIChatCompletionChoice[];
|
|
46
|
-
usage?: OpenAIChatCompletionUsage;
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/sidekick/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;AAEzE,MAAM,WAAW,sBAAsB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,sBAAsB,CAAC;CACpC;AAED,MAAM,WAAW,kBAAkB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;KACrB,CAAC;CACL;AAED,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,kBAAkB,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,0BAA0B;IACvC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,yBAAyB;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,4BAA4B;IACzC,OAAO,EAAE,0BAA0B,EAAE,CAAC;IACtC,KAAK,CAAC,EAAE,yBAAyB,CAAC;CACrC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/hooks/auto-slash-command/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B,yBAA0B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-error-message.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/get-error-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { MagicContextPluginConfig } from "../../config";
|
|
2
|
-
import type { PluginContext } from "../types";
|
|
3
|
-
export declare function createCoreHooks(args: {
|
|
4
|
-
ctx: PluginContext;
|
|
5
|
-
pluginConfig: MagicContextPluginConfig;
|
|
6
|
-
}): {
|
|
7
|
-
magicContext: {
|
|
8
|
-
"experimental.chat.messages.transform": (_input: Record<string, never>, output: {
|
|
9
|
-
messages: unknown[];
|
|
10
|
-
}) => Promise<void>;
|
|
11
|
-
"experimental.chat.system.transform": (input: {
|
|
12
|
-
sessionID?: string;
|
|
13
|
-
}, output: {
|
|
14
|
-
system: string[];
|
|
15
|
-
}) => Promise<void>;
|
|
16
|
-
"experimental.text.complete": (_input: {
|
|
17
|
-
sessionID: string;
|
|
18
|
-
messageID: string;
|
|
19
|
-
partID: string;
|
|
20
|
-
}, output: {
|
|
21
|
-
text: string;
|
|
22
|
-
}) => Promise<void>;
|
|
23
|
-
"chat.message": (input: {
|
|
24
|
-
sessionID?: string;
|
|
25
|
-
variant?: string;
|
|
26
|
-
}) => Promise<void>;
|
|
27
|
-
event: (input: {
|
|
28
|
-
event: {
|
|
29
|
-
type: string;
|
|
30
|
-
properties?: unknown;
|
|
31
|
-
};
|
|
32
|
-
}) => Promise<void>;
|
|
33
|
-
"command.execute.before": (input: unknown, output: unknown) => Promise<unknown>;
|
|
34
|
-
"tool.execute.after": (input: unknown) => Promise<void>;
|
|
35
|
-
} | null;
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=create-core-hooks.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-core-hooks.d.ts","sourceRoot":"","sources":["../../../src/plugin/hooks/create-core-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAI9C,wBAAgB,eAAe,CAAC,IAAI,EAAE;IAClC,GAAG,EAAE,aAAa,CAAC;IACnB,YAAY,EAAE,wBAAwB,CAAC;CAC1C;;;;;;qBAGi2B,CAAC;;;;;;;;;;;;qBAA67B,CAAC;mBAAiB,CAAC;;;;;0BAAmjE,CAAC;;;;;;EADt2H"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-display-names.d.ts","sourceRoot":"","sources":["../../src/shared/agent-display-names.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGtD,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export type PermissionValue = "ask" | "allow" | "deny";
|
|
2
|
-
export interface PermissionFormat {
|
|
3
|
-
permission: Record<string, PermissionValue>;
|
|
4
|
-
}
|
|
5
|
-
export declare function createAgentToolAllowlist(allowTools: string[]): PermissionFormat;
|
|
6
|
-
//# sourceMappingURL=permission-compat.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"permission-compat.d.ts","sourceRoot":"","sources":["../../src/shared/permission-compat.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAEvD,MAAM,WAAW,gBAAgB;IAC7B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CAC/C;AAED,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAO/E"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const CTX_RECALL_TOOL_NAME = "ctx_recall";
|
|
2
|
-
export declare const CTX_RECALL_DESCRIPTION = "Search cross-session project memories using natural language queries. Returns relevant memories ranked by semantic + keyword relevance. Use this to find previously stored architecture decisions, constraints, user preferences, config defaults, and other project knowledge.";
|
|
3
|
-
export declare const DEFAULT_RECALL_LIMIT = 10;
|
|
4
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-recall/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,eAAe,CAAC;AACjD,eAAO,MAAM,sBAAsB,oRAAoR,CAAC;AACxT,eAAO,MAAM,oBAAoB,KAAK,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-recall/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-recall/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAQ,MAAM,qBAAqB,CAAC;AAYhE,OAAO,KAAK,EAAkC,iBAAiB,EAAE,MAAM,SAAS,CAAC;AA4NjF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAI5F"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { Database } from "bun:sqlite";
|
|
2
|
-
export interface CtxRecallArgs {
|
|
3
|
-
query: string;
|
|
4
|
-
category?: string;
|
|
5
|
-
limit?: number;
|
|
6
|
-
}
|
|
7
|
-
export interface CtxRecallToolDeps {
|
|
8
|
-
db: Database;
|
|
9
|
-
projectPath: string;
|
|
10
|
-
memoryEnabled: boolean;
|
|
11
|
-
embeddingEnabled: boolean;
|
|
12
|
-
}
|
|
13
|
-
export interface CtxRecallResult {
|
|
14
|
-
id: number;
|
|
15
|
-
category: string;
|
|
16
|
-
content: string;
|
|
17
|
-
score: number;
|
|
18
|
-
source: string;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-recall/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,WAAW,aAAa;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAC9B,EAAE,EAAE,QAAQ,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,eAAe;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assistant-message-extractor.d.ts","sourceRoot":"","sources":["../../../src/tools/look-at/assistant-message-extractor.ts"],"names":[],"mappings":"AAwDA,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAiB3E"}
|