Skip to content

Commit 3883cb5

Browse files
refactor(arch2): remove remaining shared type leakage
Move shared session contracts onto plugin-core so server code no longer reaches through UI packages, and drop the stale unused Electrobun patch. Co-Authored-By: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
1 parent 7349749 commit 3883cb5

11 files changed

Lines changed: 38 additions & 352 deletions

File tree

packages/server/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
"@cookielab.io/klovi-plugin-codex": "workspace:*",
4141
"@cookielab.io/klovi-plugin-core": "workspace:*",
4242
"@cookielab.io/klovi-plugin-opencode": "workspace:*",
43-
"@cookielab.io/klovi-ui-components": "workspace:*",
4443
"effect": "*",
4544
"@effect/platform": "*",
4645
"@effect/platform-bun": "*",

packages/server/src/effect/server-services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {
33
GlobalSessionResult,
44
Session,
55
SessionSummary,
6-
} from "@cookielab.io/klovi-ui-components/types";
6+
} from "@cookielab.io/klovi-plugin-core";
77
import { Context, Effect, Layer } from "effect";
88
import {
99
completeOnboarding,

packages/server/src/services/app-services.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { access, rm } from "node:fs/promises";
2-
import { encodeSessionId, parseSessionId, sortByIsoDesc } from "@cookielab.io/klovi-plugin-core";
3-
import type { GlobalSessionResult, SessionSummary } from "@cookielab.io/klovi-ui-components/types";
2+
import {
3+
encodeSessionId,
4+
type GlobalSessionResult,
5+
parseSessionId,
6+
type SessionSummary,
7+
sortByIsoDesc,
8+
} from "@cookielab.io/klovi-plugin-core";
49
import { runPluginEffect, runRegistryEffect } from "../effect/plugin-runtime.ts";
510
import { BUILTIN_PLUGIN_DESCRIPTORS, BUILTIN_PLUGIN_ID_SET } from "./catalog.ts";
611
import type { PluginRegistry } from "./registry.ts";

packages/server/src/services/plugin-types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import type {
22
MergedProject as CoreMergedProject,
33
PluginProject as CorePluginProject,
44
ToolPlugin as CoreToolPlugin,
5+
Session,
6+
SessionSummary,
57
} from "@cookielab.io/klovi-plugin-core";
6-
import type { Session, SessionSummary } from "@cookielab.io/klovi-ui-components/types";
78

89
export type PluginProject = CorePluginProject<string>;
910

packages/server/src/services/registry.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { describe, expect, test } from "bun:test";
22
import type { RegistryRequirements } from "@cookielab.io/klovi-plugin-core";
3-
import { PluginError, SqliteClientTag } from "@cookielab.io/klovi-plugin-core";
4-
import type { SessionSummary } from "@cookielab.io/klovi-ui-components/types";
3+
import { PluginError, type SessionSummary, SqliteClientTag } from "@cookielab.io/klovi-plugin-core";
54
import { NodeFileSystem } from "@effect/platform-node";
65
import { Effect, Layer } from "effect";
76
import type { MergedProject, PluginProject, ToolPlugin } from "./plugin-types.ts";

packages/server/src/services/registry.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import {
22
PluginRegistry as CorePluginRegistryImpl,
33
type SessionIdEncoder as CoreSessionIdEncoder,
44
encodeResolvedPath,
5+
type Session,
6+
type SessionSummary,
57
} from "@cookielab.io/klovi-plugin-core";
6-
import type { Session, SessionSummary } from "@cookielab.io/klovi-ui-components/types";
78

89
export { encodeResolvedPath };
910

packages/server/src/services/stats.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, test } from "bun:test";
2+
import type { Session, SessionSummary } from "@cookielab.io/klovi-plugin-core";
23
import { PluginError } from "@cookielab.io/klovi-plugin-core";
3-
import type { Session, SessionSummary } from "@cookielab.io/klovi-ui-components/types";
44
import { Effect } from "effect";
55
import type { ToolPlugin } from "./plugin-types.ts";
66
import { PluginRegistry } from "./registry.ts";

packages/server/src/services/stats.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { parseSessionId } from "@cookielab.io/klovi-plugin-core";
21
import type {
32
DashboardStats,
43
ModelTokenUsage,
54
SessionSummary,
65
TokenUsage,
76
Turn,
8-
} from "@cookielab.io/klovi-ui-components/types";
7+
} from "@cookielab.io/klovi-plugin-core";
8+
import { parseSessionId } from "@cookielab.io/klovi-plugin-core";
99
import { runPluginEffect, runRegistryEffect } from "../effect/plugin-runtime.ts";
1010
import type { PluginRegistry } from "./registry.ts";
1111

packages/ui-components/src/types/index.ts

Lines changed: 21 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,24 @@
1-
export interface Project {
2-
encodedPath: string;
3-
name: string;
4-
fullPath: string;
5-
sessionCount: number;
6-
lastActivity: string;
7-
}
8-
9-
export interface SessionSummary {
10-
sessionId: string;
11-
timestamp: string;
12-
slug: string;
13-
firstMessage: string;
14-
model: string;
15-
gitBranch: string;
16-
sessionType?: "plan" | "implementation" | undefined;
17-
pluginId?: string | undefined;
18-
}
19-
20-
export interface Session {
21-
sessionId: string;
22-
project: string;
23-
turns: Turn[];
24-
planSessionId?: string | undefined;
25-
implSessionId?: string | undefined;
26-
pluginId?: string | undefined;
27-
}
28-
29-
export type Turn = UserTurn | AssistantTurn | SystemTurn | ParseErrorTurn;
30-
31-
export interface Attachment {
32-
type: "image";
33-
mediaType: string;
34-
}
35-
36-
export interface UserTurn {
37-
kind: "user";
38-
uuid: string;
39-
timestamp: string;
40-
text: string;
41-
command?:
42-
| {
43-
name: string;
44-
args: string;
45-
}
46-
| undefined;
47-
attachments?: Attachment[] | undefined;
48-
bashInput?: string | undefined;
49-
bashStdout?: string | undefined;
50-
bashStderr?: string | undefined;
51-
ideOpenedFile?: string | undefined;
52-
}
53-
54-
export type ContentBlock =
55-
| { type: "thinking"; block: ThinkingBlock }
56-
| { type: "text"; text: string }
57-
| { type: "tool_call"; call: ToolCallWithResult };
58-
59-
export interface AssistantTurn {
60-
kind: "assistant";
61-
uuid: string;
62-
timestamp: string;
63-
model: string;
64-
contentBlocks: ContentBlock[];
65-
usage?: TokenUsage | undefined;
66-
stopReason?: string | undefined;
67-
}
68-
69-
export interface TokenUsage {
70-
inputTokens: number;
71-
outputTokens: number;
72-
cacheReadTokens?: number | undefined;
73-
cacheCreationTokens?: number | undefined;
74-
}
75-
76-
export interface SystemTurn {
77-
kind: "system";
78-
uuid: string;
79-
timestamp: string;
80-
text: string;
81-
}
82-
83-
export interface ParseErrorTurn {
84-
kind: "parse_error";
85-
uuid: string;
86-
timestamp: string;
87-
lineNumber: number;
88-
rawLine: string;
89-
errorType: "json_parse" | "invalid_structure";
90-
errorDetails?: string | undefined;
91-
}
92-
93-
export interface ThinkingBlock {
94-
text: string;
95-
}
96-
97-
export interface ToolCallWithResult {
98-
toolUseId: string;
99-
name: string;
100-
input: Record<string, unknown>;
101-
result: string;
102-
isError: boolean;
103-
resultImages?: ToolResultImage[] | undefined;
104-
subAgentId?: string | undefined;
105-
}
106-
107-
export interface ToolResultImage {
108-
mediaType: string;
109-
data: string;
110-
}
111-
112-
export interface GlobalSessionResult extends SessionSummary {
113-
encodedPath: string;
114-
projectName: string;
115-
pluginId?: string | undefined;
116-
}
117-
118-
export interface ModelTokenUsage {
119-
inputTokens: number;
120-
outputTokens: number;
121-
cacheReadTokens: number;
122-
cacheCreationTokens: number;
123-
}
124-
125-
export interface DashboardStats {
126-
projects: number;
127-
sessions: number;
128-
messages: number;
129-
todaySessions: number;
130-
thisWeekSessions: number;
131-
inputTokens: number;
132-
outputTokens: number;
133-
cacheReadTokens: number;
134-
cacheCreationTokens: number;
135-
toolCalls: number;
136-
models: Record<string, ModelTokenUsage>;
137-
}
1+
import type { ContentBlock } from "@cookielab.io/klovi-plugin-core";
2+
3+
export type {
4+
AssistantTurn,
5+
Attachment,
6+
ContentBlock,
7+
DashboardStats,
8+
GlobalSessionResult,
9+
ModelTokenUsage,
10+
ParseErrorTurn,
11+
Project,
12+
Session,
13+
SessionSummary,
14+
SystemTurn,
15+
ThinkingBlock,
16+
TokenUsage,
17+
ToolCallWithResult,
18+
ToolResultImage,
19+
Turn,
20+
UserTurn,
21+
} from "@cookielab.io/klovi-plugin-core";
13822

13923
/**
14024
* Groups content blocks into presentation steps.

packages/ui/src/shared/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ export type {
1616
ToolResultImage,
1717
Turn,
1818
UserTurn,
19-
} from "@cookielab.io/klovi-ui-components/types";
19+
} from "@cookielab.io/klovi-plugin-core";

0 commit comments

Comments
 (0)