@cortexkit/opencode-magic-context 0.8.3 → 0.8.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.
Files changed (33) hide show
  1. package/README.md +17 -7
  2. package/dist/cli.js +2 -2
  3. package/dist/features/builtin-commands/commands.d.ts.map +1 -1
  4. package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
  5. package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +62246 -61171
  8. package/dist/plugin/rpc-handlers.d.ts +11 -0
  9. package/dist/plugin/rpc-handlers.d.ts.map +1 -0
  10. package/dist/shared/conflict-detector.d.ts +0 -4
  11. package/dist/shared/conflict-detector.d.ts.map +1 -1
  12. package/dist/shared/rpc-client.d.ts +16 -0
  13. package/dist/shared/rpc-client.d.ts.map +1 -0
  14. package/dist/shared/rpc-notifications.d.ts +21 -0
  15. package/dist/shared/rpc-notifications.d.ts.map +1 -0
  16. package/dist/shared/rpc-server.d.ts +17 -0
  17. package/dist/shared/rpc-server.d.ts.map +1 -0
  18. package/dist/shared/rpc-types.d.ts +59 -0
  19. package/dist/shared/rpc-types.d.ts.map +1 -0
  20. package/dist/shared/rpc-utils.d.ts +8 -0
  21. package/dist/shared/rpc-utils.d.ts.map +1 -0
  22. package/dist/tui/data/context-db.d.ts +17 -69
  23. package/dist/tui/data/context-db.d.ts.map +1 -1
  24. package/package.json +1 -1
  25. package/src/shared/conflict-detector.ts +1 -17
  26. package/src/shared/rpc-client.ts +123 -0
  27. package/src/shared/rpc-notifications.ts +44 -0
  28. package/src/shared/rpc-server.ts +136 -0
  29. package/src/shared/rpc-types.ts +58 -0
  30. package/src/shared/rpc-utils.ts +16 -0
  31. package/src/tui/data/context-db.ts +99 -625
  32. package/src/tui/index.tsx +53 -55
  33. package/src/tui/slots/sidebar-content.tsx +8 -7
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Shared types for RPC between server and TUI plugins.
3
+ * Both sides import these — no SQLite dependency.
4
+ */
5
+
6
+ export interface SidebarSnapshot {
7
+ sessionId: string;
8
+ usagePercentage: number;
9
+ inputTokens: number;
10
+ systemPromptTokens: number;
11
+ compartmentCount: number;
12
+ factCount: number;
13
+ memoryCount: number;
14
+ memoryBlockCount: number;
15
+ pendingOpsCount: number;
16
+ historianRunning: boolean;
17
+ compartmentInProgress: boolean;
18
+ sessionNoteCount: number;
19
+ readySmartNoteCount: number;
20
+ cacheTtl: string;
21
+ lastDreamerRunAt: number | null;
22
+ projectIdentity: string | null;
23
+ compartmentTokens: number;
24
+ factTokens: number;
25
+ memoryTokens: number;
26
+ }
27
+
28
+ export interface StatusDetail extends SidebarSnapshot {
29
+ tagCounter: number;
30
+ activeTags: number;
31
+ droppedTags: number;
32
+ totalTags: number;
33
+ activeBytes: number;
34
+ lastResponseTime: number;
35
+ lastNudgeTokens: number;
36
+ lastNudgeBand: string;
37
+ lastTransformError: string | null;
38
+ isSubagent: boolean;
39
+ pendingOps: Array<{ tagId: number; operation: string }>;
40
+ contextLimit: number;
41
+ cacheTtlMs: number;
42
+ cacheRemainingMs: number;
43
+ cacheExpired: boolean;
44
+ executeThreshold: number;
45
+ protectedTagCount: number;
46
+ nudgeInterval: number;
47
+ historyBudgetPercentage: number;
48
+ nextNudgeAfter: number;
49
+ historyBlockTokens: number;
50
+ compressionBudget: number | null;
51
+ compressionUsage: string | null;
52
+ }
53
+
54
+ export interface RpcNotificationMessage {
55
+ type: string;
56
+ payload: Record<string, unknown>;
57
+ sessionId?: string;
58
+ }
@@ -0,0 +1,16 @@
1
+ import { createHash } from "node:crypto";
2
+ import { join } from "node:path";
3
+
4
+ /**
5
+ * Stable hash for a project directory — scopes RPC port files per-project
6
+ * so multiple OpenCode instances don't collide.
7
+ */
8
+ export function projectHash(directory: string): string {
9
+ const normalized = directory.replace(/\/+$/, "");
10
+ return createHash("sha256").update(normalized).digest("hex").slice(0, 16);
11
+ }
12
+
13
+ /** Per-project RPC port file path. */
14
+ export function rpcPortFilePath(storageDir: string, directory: string): string {
15
+ return join(storageDir, "rpc", projectHash(directory), "port");
16
+ }