@cortexkit/opencode-magic-context 0.27.2 → 0.28.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 -7
- package/dist/agents/language-directive.d.ts +27 -0
- package/dist/agents/language-directive.d.ts.map +1 -0
- package/dist/agents/magic-context-prompt.d.ts +1 -1
- package/dist/agents/magic-context-prompt.d.ts.map +1 -1
- package/dist/config/project-security.d.ts +1 -0
- package/dist/config/project-security.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +4 -0
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/refresh-primers.d.ts +1 -0
- package/dist/features/magic-context/dreamer/refresh-primers.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-config.d.ts +1 -1
- package/dist/features/magic-context/dreamer/task-config.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts +1 -0
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts +1 -0
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify.d.ts +1 -0
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/memory/memory-migration.d.ts +1 -0
- package/dist/features/magic-context/memory/memory-migration.d.ts.map +1 -1
- package/dist/features/magic-context/sidekick/agent.d.ts +1 -0
- package/dist/features/magic-context/sidekick/agent.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +0 -5
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/features/magic-context/transform-decision-log.d.ts +1 -0
- package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
- package/dist/features/magic-context/user-memory/review-user-memories.d.ts +1 -0
- package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -1
- package/dist/hooks/magic-context/command-handler.d.ts +1 -0
- package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts +1 -0
- package/dist/hooks/magic-context/compartment-runner-historian.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-partial-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +1 -0
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts +1 -1
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
- package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts +13 -3
- package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +1 -0
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts +1 -0
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-hash.d.ts +2 -0
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +235 -57
- package/dist/plugin/conflict-warning-hook.d.ts.map +1 -1
- package/dist/plugin/dream-timer.d.ts +1 -0
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/shared/announcement.d.ts +1 -1
- package/dist/shared/announcement.d.ts.map +1 -1
- package/dist/shared/tui-preferences.d.ts +1 -1
- package/dist/tui/badge-contrast.d.ts +31 -0
- package/dist/tui/badge-contrast.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/shared/announcement.ts +3 -6
- package/src/shared/tui-preferences.ts +2 -2
- package/src/tui/badge-contrast.test.ts +45 -0
- package/src/tui/badge-contrast.ts +46 -0
- package/src/tui/slots/sidebar-content.tsx +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conflict-warning-hook.d.ts","sourceRoot":"","sources":["../../src/plugin/conflict-warning-hook.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAsLlE;;GAEG;AACH,wBAAsB,mBAAmB,CACrC,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,cAAc,GAC/B,OAAO,CAAC,IAAI,CAAC,CAqDf;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CACzC,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAwHf;AAkCD;;;GAGG;AACH,wBAAsB,wBAAwB,CAC1C,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAsEf;AAED;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CACxC,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,GAC/D,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"conflict-warning-hook.d.ts","sourceRoot":"","sources":["../../src/plugin/conflict-warning-hook.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAsLlE;;GAEG;AACH,wBAAsB,mBAAmB,CACrC,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,cAA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AAiB,CAAC;;;;;;0BAAmtmC,CAAC;;;;;;EADnitC"}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* Bump only when there are user-visible changes worth a startup dialog.
|
|
19
19
|
* Does NOT need to match the published package version.
|
|
20
20
|
*/
|
|
21
|
-
export declare const ANNOUNCEMENT_VERSION = "0.
|
|
21
|
+
export declare const ANNOUNCEMENT_VERSION = "0.28.0";
|
|
22
22
|
/**
|
|
23
23
|
* Short, user-facing bullet strings. Keep each line ~80 chars or shorter so the
|
|
24
24
|
* TUI dialog renders cleanly without horizontal scroll on a typical terminal.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"announcement.d.ts","sourceRoot":"","sources":["../../src/shared/announcement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAOH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"announcement.d.ts","sourceRoot":"","sources":["../../src/shared/announcement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAOH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC,MAAM,CAGvD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,qDAAqD,CAAC;AAyBtF;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CAGjD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAS1D;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CA0BhD"}
|
|
@@ -3,7 +3,7 @@ export declare function getTuiPreferencesFile(): string;
|
|
|
3
3
|
export declare function readTuiPreferencesFile(): Promise<Record<string, unknown>>;
|
|
4
4
|
export declare function readTuiPreferencesFileSync(): Record<string, unknown>;
|
|
5
5
|
export declare const PLUGIN_KEY = "magic-context";
|
|
6
|
-
export declare const DEFAULT_SLOT_ORDER =
|
|
6
|
+
export declare const DEFAULT_SLOT_ORDER = 170;
|
|
7
7
|
export interface MagicContextTuiPrefs {
|
|
8
8
|
forceToTop: boolean;
|
|
9
9
|
order: number;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pick a readable text color (black or white) for text drawn ON TOP of a given
|
|
3
|
+
* background color.
|
|
4
|
+
*
|
|
5
|
+
* The sidebar header badge previously drew its label with `fg={theme.background}`
|
|
6
|
+
* on a `theme.accent` background. That breaks for themes that set
|
|
7
|
+
* `background: "none"` (transparent) to respect terminal transparency: the
|
|
8
|
+
* resolved background is `RGBA(0,0,0,0)`, so the badge text renders fully
|
|
9
|
+
* transparent and disappears (issue #186). The badge background (`accent`) is
|
|
10
|
+
* always opaque, so deriving the text color from it is transparency-proof.
|
|
11
|
+
*
|
|
12
|
+
* The pick is WHITE-BIASED off the accent's relative luminance: white for any
|
|
13
|
+
* accent in the dark half (luminance < 0.5), black only for genuinely light
|
|
14
|
+
* accents. A strict "higher-contrast-wins" pick (crossover at luminance 0.179)
|
|
15
|
+
* flips ordinary mid-tone accents to black: a typical orange/amber sidebar
|
|
16
|
+
* accent (luminance ~0.3) reads black ~5:1 vs white ~3.7:1, so contrast-wins
|
|
17
|
+
* picks black even though white at ~3.7:1 is perfectly legible for a short bold
|
|
18
|
+
* label. That looks heavy and clashes with the sibling status badges, so we
|
|
19
|
+
* prefer white across the whole dark half and only fall to black once the accent
|
|
20
|
+
* is actually light (pale/pastel/near-white), where white would be unreadable.
|
|
21
|
+
*
|
|
22
|
+
* `RGBA` channels from @opentui/core are normalized 0..1 floats. We accept the
|
|
23
|
+
* minimal `{ r, g, b }` shape so this stays a pure, trivially testable function
|
|
24
|
+
* independent of the native color class.
|
|
25
|
+
*/
|
|
26
|
+
export declare function readableTextColorOn(bg: {
|
|
27
|
+
r: number;
|
|
28
|
+
g: number;
|
|
29
|
+
b: number;
|
|
30
|
+
}): string;
|
|
31
|
+
//# sourceMappingURL=badge-contrast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"badge-contrast.d.ts","sourceRoot":"","sources":["../../src/tui/badge-contrast.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAmBH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAEnF"}
|
package/package.json
CHANGED
|
@@ -24,18 +24,15 @@ import { getMagicContextStorageDir } from "./data-path";
|
|
|
24
24
|
* Bump only when there are user-visible changes worth a startup dialog.
|
|
25
25
|
* Does NOT need to match the published package version.
|
|
26
26
|
*/
|
|
27
|
-
export const ANNOUNCEMENT_VERSION = "0.
|
|
27
|
+
export const ANNOUNCEMENT_VERSION = "0.28.0";
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Short, user-facing bullet strings. Keep each line ~80 chars or shorter so the
|
|
31
31
|
* TUI dialog renders cleanly without horizontal scroll on a typical terminal.
|
|
32
32
|
*/
|
|
33
33
|
export const ANNOUNCEMENT_FEATURES: ReadonlyArray<string> = [
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
"New Primers: durable answers to the questions that keep coming up about your project, kept current by the dreamer investigating the actual code.",
|
|
37
|
-
"Embedding storage no longer wipes your vectors when you change model or endpoint. Different models now coexist, so switching providers keeps your existing vectors.",
|
|
38
|
-
"Config moved to a shared CortexKit location (~/.config/cortexkit/ and <project>/.cortexkit/). This happens automatically on first run; your old file is preserved.",
|
|
34
|
+
'New \'language\' option: set a top-level 2-letter language code (e.g. "tr" or "es") and Magic Context writes its summaries, memories, and guidance in that language, while keeping all structure (tags, categories, code, paths) in English. User-level only, off by default.',
|
|
35
|
+
"The ctx_reduce reminder now reflects how much tool output is actually reclaimable, instead of escalating to 'urgent' just because you're near compaction. It also no longer suggests dropping the agent's task list or tiny status outputs.",
|
|
39
36
|
];
|
|
40
37
|
|
|
41
38
|
/**
|
|
@@ -11,7 +11,7 @@ import { parse, stringify } from "comment-json";
|
|
|
11
11
|
// Cross-plugin convention (anthropic-auth / aft / magic-context all mirror it):
|
|
12
12
|
// - same file name + env override + lookup order,
|
|
13
13
|
// - byte-identical `computeEffectiveOrder` so the three sort consistently,
|
|
14
|
-
// - a coordinated default-order ladder (anthropic-auth 160,
|
|
14
|
+
// - a coordinated default-order ladder (anthropic-auth 160, MC 170, AFT 180).
|
|
15
15
|
//
|
|
16
16
|
// MC uses `comment-json` (already a dep, Bun-safe) for the WRITE path — a full
|
|
17
17
|
// parse → mutate-one-key → stringify round-trip that preserves comments and
|
|
@@ -64,7 +64,7 @@ export function readTuiPreferencesFileSync(): Record<string, unknown> {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
export const PLUGIN_KEY = "magic-context";
|
|
67
|
-
export const DEFAULT_SLOT_ORDER =
|
|
67
|
+
export const DEFAULT_SLOT_ORDER = 170;
|
|
68
68
|
|
|
69
69
|
export interface MagicContextTuiPrefs {
|
|
70
70
|
forceToTop: boolean;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { readableTextColorOn } from "./badge-contrast";
|
|
3
|
+
|
|
4
|
+
describe("readableTextColorOn", () => {
|
|
5
|
+
test("dark accent gets white text", () => {
|
|
6
|
+
// A typical dark accent (deep blue/purple) should read as white.
|
|
7
|
+
expect(readableTextColorOn({ r: 0.1, g: 0.1, b: 0.3 })).toBe("#ffffff");
|
|
8
|
+
expect(readableTextColorOn({ r: 0, g: 0, b: 0 })).toBe("#ffffff");
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("light accent gets black text", () => {
|
|
12
|
+
// Only accents pale enough that white fails the contrast bar go black.
|
|
13
|
+
expect(readableTextColorOn({ r: 0.9, g: 0.9, b: 0.7 })).toBe("#000000");
|
|
14
|
+
expect(readableTextColorOn({ r: 1, g: 1, b: 1 })).toBe("#000000");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("mid-tone orange accent prefers white (white-bias, matches sibling badges)", () => {
|
|
18
|
+
// A typical orange/amber accent reads white ~4:1 and black ~5:1. A
|
|
19
|
+
// higher-contrast-wins pick would flip it to black (the #186 over-
|
|
20
|
+
// correction); the white bias keeps it white, clearing the bold-text bar.
|
|
21
|
+
expect(readableTextColorOn({ r: 0.69, g: 0.455, b: 0.188 })).toBe("#ffffff");
|
|
22
|
+
expect(readableTextColorOn({ r: 0.741, g: 0.482, b: 0.2 })).toBe("#ffffff");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("pure green is treated as light (white fails the contrast bar)", () => {
|
|
26
|
+
// A saturated green is bright enough that white drops below the bar.
|
|
27
|
+
expect(readableTextColorOn({ r: 0, g: 1, b: 0 })).toBe("#000000");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("pure blue is treated as dark (low luma weight)", () => {
|
|
31
|
+
// Blue contributes little to perceived brightness, so a saturated blue
|
|
32
|
+
// badge needs light text.
|
|
33
|
+
expect(readableTextColorOn({ r: 0, g: 0, b: 1 })).toBe("#ffffff");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("does not depend on the (possibly transparent) background alpha", () => {
|
|
37
|
+
// The helper only reads r/g/b — the regression in #186 was using a
|
|
38
|
+
// background color whose alpha could be 0. Two accents with identical
|
|
39
|
+
// rgb resolve identically regardless of any alpha the caller might pass.
|
|
40
|
+
const a = readableTextColorOn({ r: 0.2, g: 0.2, b: 0.2 });
|
|
41
|
+
const b = readableTextColorOn({ r: 0.2, g: 0.2, b: 0.2 });
|
|
42
|
+
expect(a).toBe(b);
|
|
43
|
+
expect(a).toBe("#ffffff");
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pick a readable text color (black or white) for text drawn ON TOP of a given
|
|
3
|
+
* background color.
|
|
4
|
+
*
|
|
5
|
+
* The sidebar header badge previously drew its label with `fg={theme.background}`
|
|
6
|
+
* on a `theme.accent` background. That breaks for themes that set
|
|
7
|
+
* `background: "none"` (transparent) to respect terminal transparency: the
|
|
8
|
+
* resolved background is `RGBA(0,0,0,0)`, so the badge text renders fully
|
|
9
|
+
* transparent and disappears (issue #186). The badge background (`accent`) is
|
|
10
|
+
* always opaque, so deriving the text color from it is transparency-proof.
|
|
11
|
+
*
|
|
12
|
+
* The pick is WHITE-BIASED off the accent's relative luminance: white for any
|
|
13
|
+
* accent in the dark half (luminance < 0.5), black only for genuinely light
|
|
14
|
+
* accents. A strict "higher-contrast-wins" pick (crossover at luminance 0.179)
|
|
15
|
+
* flips ordinary mid-tone accents to black: a typical orange/amber sidebar
|
|
16
|
+
* accent (luminance ~0.3) reads black ~5:1 vs white ~3.7:1, so contrast-wins
|
|
17
|
+
* picks black even though white at ~3.7:1 is perfectly legible for a short bold
|
|
18
|
+
* label. That looks heavy and clashes with the sibling status badges, so we
|
|
19
|
+
* prefer white across the whole dark half and only fall to black once the accent
|
|
20
|
+
* is actually light (pale/pastel/near-white), where white would be unreadable.
|
|
21
|
+
*
|
|
22
|
+
* `RGBA` channels from @opentui/core are normalized 0..1 floats. We accept the
|
|
23
|
+
* minimal `{ r, g, b }` shape so this stays a pure, trivially testable function
|
|
24
|
+
* independent of the native color class.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
// Luminance midpoint: accents below this keep white text, accents at/above it
|
|
28
|
+
// (light/pastel/near-white) get black. White-biased relative to the strict
|
|
29
|
+
// equal-contrast crossover (~0.179) so saturated mid-tone accents stay white.
|
|
30
|
+
const LIGHT_ACCENT_LUMINANCE = 0.5;
|
|
31
|
+
|
|
32
|
+
function srgbChannelToLinear(c: number): number {
|
|
33
|
+
return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function relativeLuminance(bg: { r: number; g: number; b: number }): number {
|
|
37
|
+
return (
|
|
38
|
+
0.2126 * srgbChannelToLinear(bg.r) +
|
|
39
|
+
0.7152 * srgbChannelToLinear(bg.g) +
|
|
40
|
+
0.0722 * srgbChannelToLinear(bg.b)
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function readableTextColorOn(bg: { r: number; g: number; b: number }): string {
|
|
45
|
+
return relativeLuminance(bg) < LIGHT_ACCENT_LUMINANCE ? "#ffffff" : "#000000";
|
|
46
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Show, createEffect, createMemo, createSignal, on, onCleanup } from "solid-js"
|
|
3
3
|
import type { TuiSlotPlugin, TuiPluginApi, TuiThemeCurrent } from "@opencode-ai/plugin/tui"
|
|
4
4
|
import packageJson from "../../../package.json"
|
|
5
|
+
import { readableTextColorOn } from '../badge-contrast';
|
|
5
6
|
import { loadSidebarSnapshot, type SidebarSnapshot } from "../data/context-db"
|
|
6
7
|
import { formatThresholdPercent } from "../../shared/format-threshold"
|
|
7
8
|
import {
|
|
@@ -694,7 +695,7 @@ const SidebarContent = (props: {
|
|
|
694
695
|
onMouseDown={() => props.controller.toggleCollapsed()}
|
|
695
696
|
>
|
|
696
697
|
<box paddingLeft={1} paddingRight={1} backgroundColor={props.theme.accent}>
|
|
697
|
-
<text fg={props.theme.
|
|
698
|
+
<text fg={readableTextColorOn(props.theme.accent)}>
|
|
698
699
|
<b>{collapsed() ? "▶ " : "▼ "}{headerLabel()}</b>
|
|
699
700
|
</text>
|
|
700
701
|
</box>
|