@cortexkit/opencode-magic-context 0.40.0 → 0.41.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 +1 -1
- package/dist/agents/permissions.d.ts +5 -3
- package/dist/agents/permissions.d.ts.map +1 -1
- package/dist/{announcement-5eg4t64s.js → announcement-3g9xg433.js} +2 -2
- package/dist/{conflict-warning-hook-f406ggbw.js → conflict-warning-hook-xj1r88a7.js} +4 -4
- package/dist/{derive-budgets-xk8cy5e6.js → derive-budgets-3xfyphvk.js} +3 -3
- package/dist/features/builtin-commands/commands.d.ts +35 -2
- package/dist/features/builtin-commands/commands.d.ts.map +1 -1
- package/dist/features/magic-context/context-authority.d.ts +10 -0
- package/dist/features/magic-context/context-authority.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/classify.d.ts +1 -0
- package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/lease.d.ts +12 -27
- package/dist/features/magic-context/dreamer/lease.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/map-memories-prompt.d.ts +1 -1
- package/dist/features/magic-context/dreamer/map-memories-prompt.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/map-memories.d.ts +2 -0
- package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/memory-claim-safety.d.ts +9 -0
- package/dist/features/magic-context/dreamer/memory-claim-safety.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-registry.d.ts +2 -0
- package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify-prompt.d.ts +7 -2
- package/dist/features/magic-context/dreamer/verify-prompt.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify.d.ts +13 -10
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-local.d.ts +19 -0
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/features/magic-context/memory/storage-memory-verifications.d.ts +5 -1
- package/dist/features/magic-context/memory/storage-memory-verifications.d.ts.map +1 -1
- package/dist/features/magic-context/memory/storage-memory.d.ts.map +1 -1
- package/dist/features/magic-context/migrations.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +3 -0
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +1 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-identity-merge.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +29 -3
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta.d.ts +1 -1
- package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +7 -0
- package/dist/features/magic-context/storage-tags.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/channel2-delivery.d.ts +2 -4
- package/dist/hooks/magic-context/channel2-delivery.d.ts.map +1 -1
- package/dist/hooks/magic-context/command-handler.d.ts +7 -0
- package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts +1 -0
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
- package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts +15 -14
- package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts.map +1 -1
- package/dist/hooks/magic-context/emergency-drop.d.ts +6 -8
- package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-resolvers.d.ts +2 -2
- package/dist/hooks/magic-context/execute-status.d.ts +4 -1
- package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts +6 -0
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook-handlers.d.ts +21 -8
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +16 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +6 -16
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/maintenance-authority.d.ts +3 -0
- package/dist/hooks/magic-context/maintenance-authority.d.ts.map +1 -0
- package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts +1 -0
- package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +9 -0
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/strip-content.d.ts +8 -0
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/stripped-command.d.ts +19 -0
- package/dist/hooks/magic-context/stripped-command.d.ts.map +1 -0
- package/dist/hooks/magic-context/supersession-reclaim.d.ts +11 -0
- package/dist/hooks/magic-context/supersession-reclaim.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +6 -0
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts +11 -0
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
- package/dist/hooks/magic-context/temporal-awareness.d.ts +1 -1
- package/dist/hooks/magic-context/temporal-awareness.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-operations.d.ts +1 -1
- package/dist/hooks/magic-context/transform-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +5 -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-pck9vadr.js → index-26ds03jd.js} +1 -1
- package/dist/{index-mg1yx1ph.js → index-2bykz3bx.js} +2 -2
- package/dist/{index-mmrhhk9a.js → index-37yzyeca.js} +36 -8
- package/dist/{index-btj2qhmc.js → index-88za3sz8.js} +3 -3
- package/dist/index-b4gv9f7g.js +284 -0
- package/dist/{index-ehpzdy0v.js → index-bf799gbq.js} +8 -1
- package/dist/{index-1h9t9xb5.js → index-dmgbar7r.js} +2 -2
- package/dist/{index-qf20mv7e.js → index-dmvy29z0.js} +1 -1
- package/dist/{index-sw8gnq34.js → index-jmwq2wxr.js} +2 -2
- package/dist/{index-3dkzzh0t.js → index-knna83k0.js} +1 -1
- package/dist/{index-axpym70t.js → index-w8rkbhn6.js} +617 -324
- package/dist/{index-rw0qrkvq.js → index-x9dmzyp5.js} +17 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2901 -2305
- package/dist/{model-resolution-r9jbcz86.js → model-resolution-jgrkt0z2.js} +3 -1
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +14 -0
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts +10 -0
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/{recomp-orchestrator-dmyvqekw.js → recomp-orchestrator-1w4xj6jt.js} +7 -7
- package/dist/{safe-notification-target-tepzc2xa.js → safe-notification-target-p0c0csxw.js} +3 -3
- package/dist/{send-session-notification-6v5b72b4.js → send-session-notification-kn34g7mx.js} +4 -4
- package/dist/shared/data-path.d.ts +12 -3
- package/dist/shared/data-path.d.ts.map +1 -1
- package/dist/shared/logger.d.ts.map +1 -1
- package/dist/shared/model-resolution.d.ts +1 -0
- package/dist/shared/model-resolution.d.ts.map +1 -1
- package/dist/shared/rpc-types.d.ts +5 -0
- package/dist/shared/rpc-types.d.ts.map +1 -1
- package/dist/shared/rust-mode-status.d.ts +3 -0
- package/dist/shared/rust-mode-status.d.ts.map +1 -0
- package/dist/shared/status-detail-text.d.ts.map +1 -1
- package/dist/shared/subagent-runner.d.ts +4 -0
- package/dist/shared/subagent-runner.d.ts.map +1 -1
- package/dist/shared/write-transaction-timing.d.ts +11 -0
- package/dist/shared/write-transaction-timing.d.ts.map +1 -0
- package/dist/{storage-meta-session-yvtbaw7c.js → storage-meta-session-snbzd26z.js} +4 -4
- package/dist/{task-config-a1qmj9bx.js → task-config-ty08ptc2.js} +2 -2
- package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tui/data/context-db.d.ts +10 -3
- package/dist/tui/data/context-db.d.ts.map +1 -1
- package/dist/tui-compiled/data/context-db.d.ts +10 -3
- package/dist/tui-compiled/data/context-db.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/agents/permissions.ts +14 -4
- package/src/config/index.test.ts +38 -0
- package/src/features/magic-context/dreamer/task-registry.ts +2 -0
- package/src/shared/data-path.test.ts +44 -4
- package/src/shared/data-path.ts +54 -11
- package/src/shared/logger.test.ts +15 -0
- package/src/shared/logger.ts +9 -4
- package/src/shared/model-resolution.test.ts +39 -0
- package/src/shared/model-resolution.ts +8 -0
- package/src/shared/redaction.ts +2 -2
- package/src/shared/rpc-types.ts +5 -0
- package/src/shared/rust-mode-status.ts +3 -0
- package/src/shared/status-detail-text.test.ts +13 -0
- package/src/shared/status-detail-text.ts +2 -0
- package/src/shared/subagent-runner.ts +4 -0
- package/src/shared/write-transaction-timing.ts +25 -0
- package/src/tui/data/context-db.test.ts +31 -1
- package/src/tui/data/context-db.ts +17 -61
- package/src/tui/index.tsx +36 -5
- package/src/tui-compiled/data/context-db.ts +17 -61
- package/src/tui-compiled/index.tsx +229 -191
- package/dist/index-8pqfcghm.js +0 -81
package/src/tui/index.tsx
CHANGED
|
@@ -12,6 +12,7 @@ import { closeRpc, dismissUpgradeReminder, getAnnouncement, getCompartmentCount,
|
|
|
12
12
|
import { startNotificationSocket, stopNotificationSocket, type SocketNotification } from "./data/notification-socket"
|
|
13
13
|
import { formatThresholdPercent } from "../shared/format-threshold"
|
|
14
14
|
import { formatTailHygiene } from "../shared/tail-hygiene-status"
|
|
15
|
+
import { RUST_MODE_HOST_PATHS_LINE } from "../shared/rust-mode-status"
|
|
15
16
|
import { formatWindowDerivationLine } from "../shared/window-geometry"
|
|
16
17
|
import { compactionOffSidebarRows, nativeCompactionContextLabel } from "./compaction-off"
|
|
17
18
|
import { isCompactionEnabled } from "../config/agent-disable"
|
|
@@ -321,6 +322,13 @@ const StatusDialog = (props: { api: TuiPluginApi; s: StatusDetail }) => {
|
|
|
321
322
|
)
|
|
322
323
|
})()}
|
|
323
324
|
|
|
325
|
+
{s().hostBackendsModuleSide && (
|
|
326
|
+
<box marginTop={1} width="100%" flexDirection="column">
|
|
327
|
+
<text fg={t().text}><b>Rust Mode</b></text>
|
|
328
|
+
<text fg={t().textMuted}>{RUST_MODE_HOST_PATHS_LINE}</text>
|
|
329
|
+
</box>
|
|
330
|
+
)}
|
|
331
|
+
|
|
324
332
|
<box flexDirection="row" width="100%" marginTop={1} gap={4}>
|
|
325
333
|
{compactionOff() ? (
|
|
326
334
|
<box flexDirection="column" flexGrow={1} flexBasis={0}>
|
|
@@ -344,8 +352,24 @@ const StatusDialog = (props: { api: TuiPluginApi; s: StatusDetail }) => {
|
|
|
344
352
|
<>
|
|
345
353
|
<box flexDirection="column" flexGrow={1} flexBasis={0}>
|
|
346
354
|
<text fg={t().text}><b>Tags</b></text>
|
|
347
|
-
<R
|
|
348
|
-
|
|
355
|
+
<R
|
|
356
|
+
t={t()}
|
|
357
|
+
l="Active"
|
|
358
|
+
v={
|
|
359
|
+
s().tagCountsAuthoritative === false
|
|
360
|
+
? "n/a (module total only)"
|
|
361
|
+
: `${s().activeTags} (~${fmtBytes(s().activeBytes)})`
|
|
362
|
+
}
|
|
363
|
+
/>
|
|
364
|
+
<R
|
|
365
|
+
t={t()}
|
|
366
|
+
l="Dropped"
|
|
367
|
+
v={
|
|
368
|
+
s().tagCountsAuthoritative === false
|
|
369
|
+
? "n/a (module total only)"
|
|
370
|
+
: String(s().droppedTags)
|
|
371
|
+
}
|
|
372
|
+
/>
|
|
349
373
|
<R t={t()} l="Total" v={String(s().totalTags)} fg={t().textMuted} />
|
|
350
374
|
<box marginTop={1}>
|
|
351
375
|
<text fg={t().text}><b>Pending Queue</b></text>
|
|
@@ -459,7 +483,7 @@ async function showRecompDialog(api: TuiPluginApi, targetSessionId = getSessionI
|
|
|
459
483
|
return false
|
|
460
484
|
}
|
|
461
485
|
|
|
462
|
-
const countResult = await getCompartmentCount(sessionId)
|
|
486
|
+
const countResult = await getCompartmentCount(sessionId, api.state.path.directory ?? "")
|
|
463
487
|
// Ack only after the dialog is actually shown for the same active session;
|
|
464
488
|
// route switches while the RPC detail load is in flight must leave it pending.
|
|
465
489
|
if (getSessionId(api) !== sessionId) return false
|
|
@@ -588,10 +612,17 @@ async function showStatusDialog(api: TuiPluginApi, targetSessionId = getSessionI
|
|
|
588
612
|
|
|
589
613
|
const directory = api.state.path.directory ?? ""
|
|
590
614
|
const modelKey = getModelKeyFromMessages(api, sessionId)
|
|
591
|
-
const
|
|
615
|
+
const result = await loadStatusDetail(sessionId, directory, modelKey)
|
|
592
616
|
if (getSessionId(api) !== sessionId) return false
|
|
617
|
+
if (!result.ok) {
|
|
618
|
+
showToast(api, {
|
|
619
|
+
message: `Status unavailable: ${result.error}`,
|
|
620
|
+
variant: "warning",
|
|
621
|
+
})
|
|
622
|
+
return false
|
|
623
|
+
}
|
|
593
624
|
|
|
594
|
-
api.ui.dialog.replace(() => <StatusDialog api={api} s={detail} />)
|
|
625
|
+
api.ui.dialog.replace(() => <StatusDialog api={api} s={result.detail} />)
|
|
595
626
|
return true
|
|
596
627
|
}
|
|
597
628
|
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* TUI data layer — pure RPC client, no direct SQLite access.
|
|
3
3
|
* All data is fetched from the server plugin via HTTP RPC.
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
6
|
-
import path from "node:path";
|
|
5
|
+
import { getMagicContextStorageDir } from "../../shared/data-path";
|
|
7
6
|
import { MagicContextRpcClient } from "../../shared/rpc-client";
|
|
8
7
|
import type { EmbedDetail, SidebarSnapshot, StatusDetail } from "../../shared/rpc-types";
|
|
9
8
|
|
|
@@ -12,18 +11,9 @@ export type { EmbedDetail, SidebarSnapshot, StatusDetail };
|
|
|
12
11
|
let rpcClient: MagicContextRpcClient | null = null;
|
|
13
12
|
let rpcGeneration = 0;
|
|
14
13
|
|
|
15
|
-
function getStorageDir(): string {
|
|
16
|
-
// Plugin v0.16+ uses the shared cortexkit/magic-context path so OpenCode
|
|
17
|
-
// and Pi can share state. The TUI just needs to point its RPC client at
|
|
18
|
-
// the same storage directory the server plugin uses for the lock-file
|
|
19
|
-
// discovery convention.
|
|
20
|
-
const dataDir = process.env.XDG_DATA_HOME ?? path.join(os.homedir(), ".local", "share");
|
|
21
|
-
return path.join(dataDir, "cortexkit", "magic-context");
|
|
22
|
-
}
|
|
23
|
-
|
|
24
14
|
/** Initialize the RPC client. Call once on TUI startup. */
|
|
25
15
|
export function initRpcClient(directory: string): void {
|
|
26
|
-
const storageDir =
|
|
16
|
+
const storageDir = getMagicContextStorageDir();
|
|
27
17
|
// Bump the generation before replacing the client so late notification
|
|
28
18
|
// responses from a disposed client are ignored (the WS socket observes the
|
|
29
19
|
// new generation and abandons its in-flight connect).
|
|
@@ -172,63 +162,26 @@ export async function loadSidebarSnapshot(
|
|
|
172
162
|
}
|
|
173
163
|
}
|
|
174
164
|
|
|
175
|
-
|
|
165
|
+
export type StatusDetailResult = { ok: true; detail: StatusDetail } | { ok: false; error: string };
|
|
166
|
+
|
|
167
|
+
/** Fetch full status detail without presenting transport failure as an empty session. */
|
|
176
168
|
export async function loadStatusDetail(
|
|
177
169
|
sessionId: string,
|
|
178
170
|
directory: string,
|
|
179
171
|
modelKey?: string,
|
|
180
|
-
): Promise<
|
|
181
|
-
|
|
182
|
-
...EMPTY_SNAPSHOT,
|
|
183
|
-
sessionId,
|
|
184
|
-
activeProfile: null,
|
|
185
|
-
tagCounter: 0,
|
|
186
|
-
activeTags: 0,
|
|
187
|
-
droppedTags: 0,
|
|
188
|
-
totalTags: 0,
|
|
189
|
-
activeBytes: 0,
|
|
190
|
-
lastResponseTime: 0,
|
|
191
|
-
lastNudgeTokens: 0,
|
|
192
|
-
lastTransformError: null,
|
|
193
|
-
isSubagent: false,
|
|
194
|
-
pendingOps: [],
|
|
195
|
-
contextLimit: 0,
|
|
196
|
-
cacheTtlMs: 0,
|
|
197
|
-
cacheRemainingMs: 0,
|
|
198
|
-
cacheExpired: false,
|
|
199
|
-
cacheNeverExpires: false,
|
|
200
|
-
executeThreshold: 65,
|
|
201
|
-
executeThresholdMode: "percentage",
|
|
202
|
-
protectedTagCount: 20,
|
|
203
|
-
historyBudgetPercentage: 0.15,
|
|
204
|
-
historyBlockTokens: 0,
|
|
205
|
-
compressionBudget: null,
|
|
206
|
-
compressionUsage: null,
|
|
207
|
-
toastDurationMs: 5000,
|
|
208
|
-
loggerDiagnostics: {
|
|
209
|
-
swallowedWriteCount: 0,
|
|
210
|
-
lastErrorMessage: null,
|
|
211
|
-
lastErrorTime: null,
|
|
212
|
-
},
|
|
213
|
-
storage_versions: {
|
|
214
|
-
context_db_schema_version: null,
|
|
215
|
-
plugin_supported_version: 0,
|
|
216
|
-
},
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
if (!rpcClient) return emptyDetail;
|
|
172
|
+
): Promise<StatusDetailResult> {
|
|
173
|
+
if (!rpcClient) return { ok: false, error: "RPC client is not initialized" };
|
|
220
174
|
try {
|
|
221
175
|
const result = await rpcClient.call<StatusDetail>("status-detail", {
|
|
222
176
|
sessionId,
|
|
223
177
|
directory,
|
|
224
178
|
modelKey,
|
|
225
179
|
});
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
return emptyDetail;
|
|
180
|
+
const error = (result as unknown as Record<string, unknown>).error;
|
|
181
|
+
if (typeof error === "string") return { ok: false, error };
|
|
182
|
+
return { ok: true, detail: result };
|
|
183
|
+
} catch (error) {
|
|
184
|
+
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
232
185
|
}
|
|
233
186
|
}
|
|
234
187
|
|
|
@@ -262,12 +215,15 @@ export async function loadEmbedDetail(sessionId: string, directory: string): Pro
|
|
|
262
215
|
export type CompartmentCountResult = { ok: true; count: number } | { ok: false; error: string };
|
|
263
216
|
|
|
264
217
|
/** Get compartment count without making transport failure look like a real zero. */
|
|
265
|
-
export async function getCompartmentCount(
|
|
218
|
+
export async function getCompartmentCount(
|
|
219
|
+
sessionId: string,
|
|
220
|
+
directory?: string,
|
|
221
|
+
): Promise<CompartmentCountResult> {
|
|
266
222
|
if (!rpcClient) return { ok: false, error: "RPC client is not initialized" };
|
|
267
223
|
try {
|
|
268
224
|
const result = await rpcClient.call<{ count?: number; error?: string }>(
|
|
269
225
|
"compartment-count",
|
|
270
|
-
{ sessionId },
|
|
226
|
+
{ sessionId, directory },
|
|
271
227
|
);
|
|
272
228
|
if (typeof result.error === "string") return { ok: false, error: result.error };
|
|
273
229
|
if (typeof result.count !== "number" || !Number.isFinite(result.count)) {
|