@cortexkit/opencode-magic-context 0.4.2 → 0.5.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 +41 -0
- package/dist/cli/config-paths.d.ts +2 -0
- package/dist/cli/config-paths.d.ts.map +1 -1
- package/dist/cli/doctor.d.ts +2 -0
- package/dist/cli/doctor.d.ts.map +1 -0
- package/dist/cli/setup.d.ts.map +1 -1
- package/dist/cli.js +8549 -125
- package/dist/features/builtin-commands/commands.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
- package/dist/features/magic-context/scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts +2 -0
- package/dist/features/magic-context/search.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/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/send-session-notification.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 +8653 -238
- package/dist/plugin/conflict-warning-hook.d.ts +24 -0
- package/dist/plugin/conflict-warning-hook.d.ts.map +1 -0
- package/dist/shared/conflict-detector.d.ts +29 -0
- package/dist/shared/conflict-detector.d.ts.map +1 -0
- package/dist/shared/conflict-fixer.d.ts +3 -0
- package/dist/shared/conflict-fixer.d.ts.map +1 -0
- package/dist/shared/tui-config.d.ts +10 -0
- package/dist/shared/tui-config.d.ts.map +1 -0
- package/dist/tools/ctx-search/tools.d.ts.map +1 -1
- package/dist/tui/data/context-db.d.ts +54 -0
- package/dist/tui/data/context-db.d.ts.map +1 -0
- package/package.json +20 -1
- package/src/tui/data/context-db.ts +584 -0
- package/src/tui/index.tsx +461 -0
- package/src/tui/slots/sidebar-content.tsx +422 -0
- package/src/tui/types/opencode-plugin-tui.d.ts +232 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conflict warning for Desktop mode when magic-context is disabled.
|
|
3
|
+
*
|
|
4
|
+
* - When conflicts detected: reads Desktop app state → finds active session → sends ignored warning
|
|
5
|
+
* - When no conflicts: cleans up any leftover warning messages from previous runs
|
|
6
|
+
*
|
|
7
|
+
* TUI handles this via a startup dialog — this covers Desktop only.
|
|
8
|
+
*/
|
|
9
|
+
import type { ConflictResult } from "../shared/conflict-detector";
|
|
10
|
+
/**
|
|
11
|
+
* Send an ignored notification to the active Desktop session at plugin startup.
|
|
12
|
+
*/
|
|
13
|
+
export declare function sendConflictWarning(client: unknown, directory: string, conflictResult: ConflictResult): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Clean up leftover conflict warning messages from previous disabled runs.
|
|
16
|
+
* Called at startup when no conflicts exist (plugin is enabled normally).
|
|
17
|
+
*/
|
|
18
|
+
export declare function cleanupConflictWarnings(client: unknown, directory: string, serverUrl?: string): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Notify the user that tui.json was configured with the sidebar plugin.
|
|
21
|
+
* Sends an ignored message that auto-deletes after 1 second.
|
|
22
|
+
*/
|
|
23
|
+
export declare function sendTuiSetupNotification(client: unknown, directory: string, serverUrl?: string): Promise<void>;
|
|
24
|
+
//# sourceMappingURL=conflict-warning-hook.d.ts.map
|
|
@@ -0,0 +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;AA0KlE;;GAEG;AACH,wBAAsB,mBAAmB,CACrC,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,cAAc,GAC/B,OAAO,CAAC,IAAI,CAAC,CA+Cf;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CACzC,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAqHf;AAkCD;;;GAGG;AACH,wBAAsB,wBAAwB,CAC1C,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAkEf"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface ConflictResult {
|
|
2
|
+
/** Whether any blocking conflict was found */
|
|
3
|
+
hasConflict: boolean;
|
|
4
|
+
/** Human-readable reasons for each conflict */
|
|
5
|
+
reasons: string[];
|
|
6
|
+
/** Which conflicts were found — used for targeted fixes */
|
|
7
|
+
conflicts: {
|
|
8
|
+
compactionAuto: boolean;
|
|
9
|
+
compactionPrune: boolean;
|
|
10
|
+
dcpPlugin: boolean;
|
|
11
|
+
omoPreemptiveCompaction: boolean;
|
|
12
|
+
omoContextWindowMonitor: boolean;
|
|
13
|
+
omoAnthropicRecovery: boolean;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Detect all conflicts that would prevent magic-context from working correctly.
|
|
18
|
+
* Checks: OpenCode compaction, DCP plugin, OMO conflicting hooks.
|
|
19
|
+
*/
|
|
20
|
+
export declare function detectConflicts(directory: string): ConflictResult;
|
|
21
|
+
/**
|
|
22
|
+
* Generate a user-facing summary of conflicts for display in dialogs/notifications.
|
|
23
|
+
*/
|
|
24
|
+
export declare function formatConflictSummary(result: ConflictResult): string;
|
|
25
|
+
/**
|
|
26
|
+
* Generate a short conflict summary for ignored message display.
|
|
27
|
+
*/
|
|
28
|
+
export declare function formatConflictShort(result: ConflictResult): string;
|
|
29
|
+
//# sourceMappingURL=conflict-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict-detector.d.ts","sourceRoot":"","sources":["../../src/shared/conflict-detector.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,cAAc;IAC3B,8CAA8C;IAC9C,WAAW,EAAE,OAAO,CAAC;IACrB,+CAA+C;IAC/C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,2DAA2D;IAC3D,SAAS,EAAE;QACP,cAAc,EAAE,OAAO,CAAC;QACxB,eAAe,EAAE,OAAO,CAAC;QACzB,SAAS,EAAE,OAAO,CAAC;QACnB,uBAAuB,EAAE,OAAO,CAAC;QACjC,uBAAuB,EAAE,OAAO,CAAC;QACjC,oBAAoB,EAAE,OAAO,CAAC;KACjC,CAAC;CACL;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,CAyDjE;AA0LD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAWpE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAWlE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict-fixer.d.ts","sourceRoot":"","sources":["../../src/shared/conflict-fixer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAmG1D,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,CAAC,WAAW,CAAC,GAAG,MAAM,EAAE,CAiHhG"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-configure tui.json with magic-context TUI plugin entry.
|
|
3
|
+
* Called from the server plugin at startup so the TUI sidebar loads on next restart.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Ensure tui.json has the magic-context TUI plugin entry.
|
|
7
|
+
* Creates tui.json if it doesn't exist. Silently skips if already present.
|
|
8
|
+
*/
|
|
9
|
+
export declare function ensureTuiPluginEntry(): boolean;
|
|
10
|
+
//# sourceMappingURL=tui-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tui-config.d.ts","sourceRoot":"","sources":["../../src/shared/tui-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAoBH;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CA+B9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-search/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAQ,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-search/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAQ,MAAM,qBAAqB,CAAC;AAQhE,OAAO,KAAK,EAAiB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAoFhE,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAI5F"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface SidebarSnapshot {
|
|
2
|
+
sessionId: string;
|
|
3
|
+
usagePercentage: number;
|
|
4
|
+
inputTokens: number;
|
|
5
|
+
systemPromptTokens: number;
|
|
6
|
+
compartmentCount: number;
|
|
7
|
+
factCount: number;
|
|
8
|
+
memoryCount: number;
|
|
9
|
+
memoryBlockCount: number;
|
|
10
|
+
pendingOpsCount: number;
|
|
11
|
+
historianRunning: boolean;
|
|
12
|
+
compartmentInProgress: boolean;
|
|
13
|
+
sessionNoteCount: number;
|
|
14
|
+
readySmartNoteCount: number;
|
|
15
|
+
cacheTtl: string;
|
|
16
|
+
lastDreamerRunAt: number | null;
|
|
17
|
+
projectIdentity: string | null;
|
|
18
|
+
compartmentTokens: number;
|
|
19
|
+
factTokens: number;
|
|
20
|
+
memoryTokens: number;
|
|
21
|
+
}
|
|
22
|
+
/** Extended status info for the status dialog — reads more from DB */
|
|
23
|
+
export interface StatusDetail extends SidebarSnapshot {
|
|
24
|
+
tagCounter: number;
|
|
25
|
+
activeTags: number;
|
|
26
|
+
droppedTags: number;
|
|
27
|
+
totalTags: number;
|
|
28
|
+
activeBytes: number;
|
|
29
|
+
lastResponseTime: number;
|
|
30
|
+
lastNudgeTokens: number;
|
|
31
|
+
lastNudgeBand: string;
|
|
32
|
+
lastTransformError: string | null;
|
|
33
|
+
isSubagent: boolean;
|
|
34
|
+
pendingOps: Array<{
|
|
35
|
+
tagId: number;
|
|
36
|
+
operation: string;
|
|
37
|
+
}>;
|
|
38
|
+
contextLimit: number;
|
|
39
|
+
cacheTtlMs: number;
|
|
40
|
+
cacheRemainingMs: number;
|
|
41
|
+
cacheExpired: boolean;
|
|
42
|
+
executeThreshold: number;
|
|
43
|
+
protectedTagCount: number;
|
|
44
|
+
nudgeInterval: number;
|
|
45
|
+
historyBudgetPercentage: number;
|
|
46
|
+
nextNudgeAfter: number;
|
|
47
|
+
historyBlockTokens: number;
|
|
48
|
+
compressionBudget: number | null;
|
|
49
|
+
compressionUsage: string | null;
|
|
50
|
+
}
|
|
51
|
+
export declare function closeDb(): void;
|
|
52
|
+
export declare function loadSidebarSnapshot(sessionId: string, directory: string): SidebarSnapshot;
|
|
53
|
+
export declare function loadStatusDetail(sessionId: string, directory: string, modelKey?: string): StatusDetail;
|
|
54
|
+
//# sourceMappingURL=context-db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-db.d.ts","sourceRoot":"","sources":["../../../src/tui/data/context-db.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,eAAe;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EA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BAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AA+BD,wBAAgB,OAAO,IAAI,IAAI,CAU9B;AA+BD,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,eAAe,CAuNzF;AAED,wBAAgB,gBAAgB,CAC5B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,MAAM,GAClB,YAAY,CAmMd"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/opencode-magic-context",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "OpenCode plugin for Magic Context — cross-session memory and context management",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"dist",
|
|
30
|
+
"src/tui",
|
|
30
31
|
"README.md"
|
|
31
32
|
],
|
|
32
33
|
"scripts": {
|
|
@@ -46,6 +47,7 @@
|
|
|
46
47
|
"@opencode-ai/plugin": "^1.2.26",
|
|
47
48
|
"@opencode-ai/sdk": "^1.2.26",
|
|
48
49
|
"ai-tokenizer": "^1.0.6",
|
|
50
|
+
"comment-json": "^4.6.2",
|
|
49
51
|
"zod": "^4.1.8"
|
|
50
52
|
},
|
|
51
53
|
"devDependencies": {
|
|
@@ -53,5 +55,22 @@
|
|
|
53
55
|
"bun-types": "^1.3.10",
|
|
54
56
|
"typescript": "^5.8.0",
|
|
55
57
|
"@biomejs/biome": "^2.4.7"
|
|
58
|
+
},
|
|
59
|
+
"exports": {
|
|
60
|
+
".": {
|
|
61
|
+
"types": "./dist/index.d.ts",
|
|
62
|
+
"import": "./dist/index.js"
|
|
63
|
+
},
|
|
64
|
+
"./tui": {
|
|
65
|
+
"types": "./src/tui/index.tsx",
|
|
66
|
+
"import": "./src/tui/index.tsx"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"oc-plugin": [
|
|
70
|
+
"server",
|
|
71
|
+
"tui"
|
|
72
|
+
],
|
|
73
|
+
"peerDependencies": {
|
|
74
|
+
"@opencode-ai/plugin": ">=1.2.0"
|
|
56
75
|
}
|
|
57
76
|
}
|