@cortexkit/opencode-magic-context 0.7.1 → 0.7.4
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-handler.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/command-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EACH,KAAK,cAAc,EAGtB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAOtE,MAAM,WAAW,mBAAmB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,oBAAoB;IACjC,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACjD;
|
|
1
|
+
{"version":3,"file":"command-handler.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/command-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EACH,KAAK,cAAc,EAGtB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAOtE,MAAM,WAAW,mBAAmB;IAChC,OAAO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AAC;QACtB,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,OAAO,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;QACrE,wBAAwB,CAAC,EAAE;YAAE,OAAO,EAAE,OAAO,CAAC;YAAC,kBAAkB,EAAE,MAAM,CAAA;SAAE,CAAC;QAC5E,uBAAuB,CAAC,EAAE;YACtB,OAAO,EAAE,OAAO,CAAC;YACjB,YAAY,EAAE,MAAM,CAAC;YACrB,SAAS,EAAE,MAAM,CAAC;SACrB,CAAC;KACL,CAAC;CACL;sCASkB,mBAAmB,WACjB,oBAAoB,WACpB,kBAAkB,KAC5B,OAAO,CAAC,IAAI,CAAC;EA+FvB"}
|
package/dist/index.js
CHANGED
|
@@ -22315,7 +22315,7 @@ function loadPluginConfig(directory) {
|
|
|
22315
22315
|
// src/features/builtin-commands/commands.ts
|
|
22316
22316
|
var TUI_OVERRIDE_COMMANDS = new Set(["ctx-status"]);
|
|
22317
22317
|
function getMagicContextBuiltinCommands() {
|
|
22318
|
-
const isTui =
|
|
22318
|
+
const isTui = process.env.OPENCODE_CLIENT === "cli";
|
|
22319
22319
|
const commands = {
|
|
22320
22320
|
"ctx-status": {
|
|
22321
22321
|
template: "ctx-status",
|
|
@@ -28063,7 +28063,7 @@ function extractToastTitle(text) {
|
|
|
28063
28063
|
return "Magic Context";
|
|
28064
28064
|
}
|
|
28065
28065
|
async function sendIgnoredMessage(client, sessionId, text, params) {
|
|
28066
|
-
const isTui =
|
|
28066
|
+
const isTui = process.env.OPENCODE_CLIENT === "cli";
|
|
28067
28067
|
if (isTui) {
|
|
28068
28068
|
try {
|
|
28069
28069
|
const c2 = client;
|
|
@@ -28152,10 +28152,13 @@ async function sendUserPrompt(client, sessionId, text) {
|
|
|
28152
28152
|
var recompConfirmationBySession = new Map;
|
|
28153
28153
|
var RECOMP_CONFIRMATION_WINDOW_MS = 60000;
|
|
28154
28154
|
var SENTINEL_PREFIX = "__CONTEXT_MANAGEMENT_";
|
|
28155
|
+
function throwSentinel(command) {
|
|
28156
|
+
throw new Error(`${SENTINEL_PREFIX}${command.toUpperCase()}_HANDLED__`);
|
|
28157
|
+
}
|
|
28155
28158
|
async function executeAugmentation(deps, sessionId, userPrompt) {
|
|
28156
28159
|
if (!deps.sidekick?.config) {
|
|
28157
28160
|
await deps.sendNotification(sessionId, "## /ctx-aug\n\nSidekick is not configured. Add sidekick settings to `magic-context.jsonc` to use /ctx-aug.", {});
|
|
28158
|
-
|
|
28161
|
+
throwSentinel("CTX-AUG");
|
|
28159
28162
|
}
|
|
28160
28163
|
const prompt = userPrompt.trim();
|
|
28161
28164
|
if (prompt.length === 0) {
|
|
@@ -28164,7 +28167,7 @@ async function executeAugmentation(deps, sessionId, userPrompt) {
|
|
|
28164
28167
|
Usage: \`/ctx-aug <your prompt>\`
|
|
28165
28168
|
|
|
28166
28169
|
Provide a prompt to augment with project memory context.`, {});
|
|
28167
|
-
|
|
28170
|
+
throwSentinel("CTX-AUG");
|
|
28168
28171
|
}
|
|
28169
28172
|
await deps.sendNotification(sessionId, "\uD83D\uDD0D Preparing augmentation\u2026 this may take 2-10s depending on your sidekick provider.", {});
|
|
28170
28173
|
sessionLog(sessionId, "/ctx-aug: running sidekick");
|
|
@@ -28189,7 +28192,7 @@ ${sidekickResult}
|
|
|
28189
28192
|
sessionLog(sessionId, "/ctx-aug: sidekick returned no result, sending prompt as-is");
|
|
28190
28193
|
}
|
|
28191
28194
|
await sendUserPrompt(deps.sidekick.client, sessionId, augmentedPrompt);
|
|
28192
|
-
|
|
28195
|
+
throwSentinel("CTX-AUG");
|
|
28193
28196
|
}
|
|
28194
28197
|
function summarizeDreamResult(result) {
|
|
28195
28198
|
const taskLines = result.tasks.map((task) => {
|
|
@@ -28213,12 +28216,12 @@ async function executeDreaming(deps, sessionId) {
|
|
|
28213
28216
|
await deps.sendNotification(sessionId, `## /ctx-dream
|
|
28214
28217
|
|
|
28215
28218
|
Dreaming is not configured for this project.`, {});
|
|
28216
|
-
|
|
28219
|
+
throwSentinel("CTX-DREAM");
|
|
28217
28220
|
}
|
|
28218
28221
|
const entry = enqueueDream(deps.db, deps.dreamer.projectPath, "manual");
|
|
28219
28222
|
if (!entry) {
|
|
28220
28223
|
await deps.sendNotification(sessionId, "Dream already queued for this project", {});
|
|
28221
|
-
|
|
28224
|
+
throwSentinel("CTX-DREAM");
|
|
28222
28225
|
}
|
|
28223
28226
|
await deps.sendNotification(sessionId, "Starting dream run...", {});
|
|
28224
28227
|
const result = deps.dreamer.executeDream ? await deps.dreamer.executeDream(sessionId) : await processDreamQueue({
|
|
@@ -28231,7 +28234,7 @@ Dreaming is not configured for this project.`, {});
|
|
|
28231
28234
|
experimentalPinKeyFiles: deps.dreamer.experimentalPinKeyFiles
|
|
28232
28235
|
});
|
|
28233
28236
|
await deps.sendNotification(sessionId, result ? summarizeDreamResult(result) : "Dream queued, but another worker is already processing the queue.", {});
|
|
28234
|
-
|
|
28237
|
+
throwSentinel("CTX-DREAM");
|
|
28235
28238
|
}
|
|
28236
28239
|
function createMagicContextCommandHandler(deps) {
|
|
28237
28240
|
const isStatusCommand = (command) => command === "ctx-status";
|
|
@@ -28308,7 +28311,7 @@ Historian recomp started. Rebuilding compartments and facts from raw session his
|
|
|
28308
28311
|
}
|
|
28309
28312
|
await deps.sendNotification(sessionId, result, {});
|
|
28310
28313
|
sessionLog(sessionId, `command ${input.command} handled via command.execute.before`);
|
|
28311
|
-
|
|
28314
|
+
throwSentinel(input.command);
|
|
28312
28315
|
}
|
|
28313
28316
|
};
|
|
28314
28317
|
}
|
package/package.json
CHANGED
package/src/tui/index.tsx
CHANGED
|
@@ -277,10 +277,9 @@ const StatusDialog = (props: { api: TuiPluginApi; s: StatusDetail }) => {
|
|
|
277
277
|
return (
|
|
278
278
|
<box flexDirection="column" width="100%" paddingLeft={2} paddingRight={2} paddingTop={1} paddingBottom={1}>
|
|
279
279
|
{/* Title */}
|
|
280
|
-
<box justifyContent="center" width="100%" marginBottom={1}>
|
|
281
|
-
<text fg={t().accent}>
|
|
282
|
-
|
|
283
|
-
</text>
|
|
280
|
+
<box justifyContent="center" width="100%" marginBottom={1} flexDirection="row" gap={2}>
|
|
281
|
+
<text fg={t().accent}><b>⚡ Magic Context Status</b></text>
|
|
282
|
+
<text fg={t().textMuted}>v{packageJson.version}</text>
|
|
284
283
|
</box>
|
|
285
284
|
|
|
286
285
|
{/* Context summary line */}
|
|
@@ -319,12 +318,10 @@ const StatusDialog = (props: { api: TuiPluginApi; s: StatusDetail }) => {
|
|
|
319
318
|
<R t={t()} l="Active" v={`${s().activeTags} (~${fmtBytes(s().activeBytes)})`} />
|
|
320
319
|
<R t={t()} l="Dropped" v={String(s().droppedTags)} />
|
|
321
320
|
<R t={t()} l="Total" v={String(s().totalTags)} fg={t().textMuted} />
|
|
322
|
-
|
|
323
321
|
<box marginTop={1}>
|
|
324
322
|
<text fg={t().text}><b>Pending Queue</b></text>
|
|
325
323
|
</box>
|
|
326
324
|
<R t={t()} l="Drops" v={String(s().pendingOpsCount)} fg={s().pendingOpsCount > 0 ? t().warning : t().textMuted} />
|
|
327
|
-
|
|
328
325
|
<box marginTop={1}>
|
|
329
326
|
<text fg={t().text}><b>Cache TTL</b></text>
|
|
330
327
|
</box>
|
|
@@ -332,14 +329,12 @@ const StatusDialog = (props: { api: TuiPluginApi; s: StatusDetail }) => {
|
|
|
332
329
|
<R t={t()} l="Last response" v={s().lastResponseTime > 0 ? `${Math.round(elapsed() / 1000)}s ago` : "never"} />
|
|
333
330
|
<R t={t()} l="Remaining" v={s().cacheExpired ? "expired" : `${Math.round(s().cacheRemainingMs / 1000)}s`} fg={s().cacheExpired ? t().warning : t().textMuted} />
|
|
334
331
|
<R t={t()} l="Auto-execute" v={s().cacheExpired ? "yes (expired)" : `at TTL or ≥${s().executeThreshold}%`} fg={t().textMuted} />
|
|
335
|
-
|
|
336
332
|
<box marginTop={1}>
|
|
337
333
|
<text fg={t().text}><b>Memory</b></text>
|
|
338
334
|
</box>
|
|
339
335
|
<R t={t()} l="Active" v={String(s().memoryCount)} fg={t().accent} />
|
|
340
336
|
<R t={t()} l="Injected" v={String(s().memoryBlockCount)} fg={t().textMuted} />
|
|
341
337
|
</box>
|
|
342
|
-
|
|
343
338
|
{/* Right column */}
|
|
344
339
|
<box flexDirection="column" flexGrow={1} flexBasis={0}>
|
|
345
340
|
<text fg={t().text}><b>Rolling Nudges</b></text>
|
|
@@ -348,13 +343,11 @@ const StatusDialog = (props: { api: TuiPluginApi; s: StatusDetail }) => {
|
|
|
348
343
|
<R t={t()} l="Interval" v={`${fmt(s().nudgeInterval)} tok`} fg={t().textMuted} />
|
|
349
344
|
<R t={t()} l="Next nudge after" v={`${fmt(s().nextNudgeAfter)} tok`} />
|
|
350
345
|
{s().lastNudgeBand ? <R t={t()} l="Current band" v={s().lastNudgeBand} /> : null}
|
|
351
|
-
|
|
352
346
|
<box marginTop={1}>
|
|
353
347
|
<text fg={t().text}><b>Context Details</b></text>
|
|
354
348
|
</box>
|
|
355
349
|
<R t={t()} l="Protected tags" v={String(s().protectedTagCount)} fg={t().textMuted} />
|
|
356
350
|
<R t={t()} l="Subagent" v={s().isSubagent ? "yes" : "no"} fg={t().textMuted} />
|
|
357
|
-
|
|
358
351
|
<box marginTop={1}>
|
|
359
352
|
<text fg={t().text}><b>History Compression</b></text>
|
|
360
353
|
</box>
|