Skip to content

Commit 2d9f74b

Browse files
committed
tui: remove @effect/language-service and refactor tool output structure
Removed the @effect/language-service dependency from packages/opencode and packages/core to simplify the build and reduce unnecessary complexity. Refactored tool output handling to use a structured content array instead of flat fields. This enables richer tool responses with mixed content types (text, files) and better structured data support for future extensibility.
1 parent 1f9b23b commit 2d9f74b

9 files changed

Lines changed: 392 additions & 523 deletions

File tree

bun.lock

Lines changed: 325 additions & 474 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/tsconfig.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@
22
"$schema": "https://json.schemastore.org/tsconfig",
33
"extends": "@tsconfig/bun/tsconfig.json",
44
"compilerOptions": {
5-
"noUncheckedIndexedAccess": false,
6-
"plugins": [
7-
{
8-
"name": "@effect/language-service",
9-
"transform": "@effect/language-service/transform",
10-
"namespaceImportPackages": ["effect", "@effect/*"]
11-
}
12-
]
5+
"noUncheckedIndexedAccess": false
136
}
147
}

packages/opencode/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"license": "MIT",
77
"private": true,
88
"scripts": {
9-
"prepare": "effect-language-service patch || true",
109
"typecheck": "tsgo --noEmit",
1110
"test": "bun test --timeout 30000",
1211
"test:ci": "mkdir -p .artifacts/unit && bun test --timeout 30000 --reporter=junit --reporter-outfile=.artifacts/unit/junit.xml",
@@ -42,7 +41,6 @@
4241
},
4342
"devDependencies": {
4443
"@babel/core": "7.28.4",
45-
"@effect/language-service": "0.84.2",
4644
"@octokit/webhooks-types": "7.6.1",
4745
"@opencode-ai/script": "workspace:*",
4846
"@opencode-ai/core": "workspace:*",

packages/opencode/src/session/processor.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -380,22 +380,19 @@ export const layer: Layer.Layer<
380380
SyncEvent.run(SessionEvent.Tool.Success.Sync, {
381381
sessionID: ctx.sessionID,
382382
callID: value.toolCallId,
383-
output: value.output.output,
384-
attachments: value.output.attachments?.map((item: MessageV2.FilePart) => ({
385-
uri: item.url,
386-
mime: item.mime,
387-
...(item.filename ? { name: item.filename } : {}),
388-
...(item.source
389-
? {
390-
source: {
391-
start: item.source.text.start,
392-
end: item.source.text.end,
393-
text: item.source.text.value,
394-
},
395-
}
396-
: {}),
397-
})),
398-
details: value.output.metadata,
383+
structured: value.output.metadata,
384+
content: [
385+
{
386+
type: "text",
387+
text: value.output.output,
388+
},
389+
...value.output.attachments?.map((item: MessageV2.FilePart) => ({
390+
type: "file",
391+
uri: item.url,
392+
mime: item.mime,
393+
name: item.filename,
394+
})),
395+
],
399396
provider: {
400397
executed: toolCall?.part.metadata?.providerExecuted === true,
401398
},
@@ -410,7 +407,10 @@ export const layer: Layer.Layer<
410407
SyncEvent.run(SessionEvent.Tool.Error.Sync, {
411408
sessionID: ctx.sessionID,
412409
callID: value.toolCallId,
413-
error: errorMessage(value.error),
410+
error: {
411+
type: "unknown",
412+
message: errorMessage(value.error),
413+
},
414414
provider: {
415415
executed: toolCall?.part.metadata?.providerExecuted === true,
416416
},

packages/opencode/src/v2/session-event.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Event } from "./event"
33
import { FileAttachment, Prompt } from "./session-prompt"
44
import { Schema } from "effect"
55
export { FileAttachment }
6+
import { ToolOutput } from "./tool-output"
67

78
export const ID = Event.ID
89
export type ID = Schema.Schema.Type<typeof ID>
@@ -201,7 +202,8 @@ export namespace Tool {
201202
schema: {
202203
...Base,
203204
callID: Schema.String,
204-
details: Schema.Record(Schema.String, Schema.Unknown),
205+
structured: ToolOutput.Structured,
206+
content: Schema.Array(ToolOutput.Content),
205207
},
206208
})
207209
export type Progress = Schema.Schema.Type<typeof Progress>
@@ -212,9 +214,8 @@ export namespace Tool {
212214
schema: {
213215
...Base,
214216
callID: Schema.String,
215-
output: Schema.String.pipe(Schema.optional),
216-
attachments: Schema.Array(FileAttachment).pipe(Schema.optional),
217-
details: Schema.Record(Schema.String, Schema.Unknown).pipe(Schema.optional),
217+
structured: ToolOutput.Structured,
218+
content: Schema.Array(ToolOutput.Content),
218219
provider: Schema.Struct({
219220
executed: Schema.Boolean,
220221
metadata: Schema.Record(Schema.String, Schema.Unknown).pipe(Schema.optional),
@@ -229,7 +230,10 @@ export namespace Tool {
229230
schema: {
230231
...Base,
231232
callID: Schema.String,
232-
error: Schema.String,
233+
error: Schema.Struct({
234+
type: Schema.String,
235+
message: Schema.String,
236+
}),
233237
provider: Schema.Struct({
234238
executed: Schema.Boolean,
235239
metadata: Schema.Record(Schema.String, Schema.Unknown).pipe(Schema.optional),

packages/opencode/src/v2/session-message-updater.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ export function update<Result>(adapter: Adapter<Result>, event: SessionEvent.Eve
163163
match.state = {
164164
status: "running",
165165
input: event.data.input,
166+
structured: {},
167+
content: [],
166168
}
167169
}
168170
}),
@@ -174,7 +176,10 @@ export function update<Result>(adapter: Adapter<Result>, event: SessionEvent.Eve
174176
adapter.updateAssistant(
175177
produce(currentAssistant, (draft) => {
176178
const match = latestTool(draft, event.data.callID)
177-
if (match && match.state.status === "running") match.state.details = event.data.details
179+
if (match && match.state.status === "running") {
180+
match.state.structured = event.data.structured
181+
match.state.content = [...event.data.content]
182+
}
178183
}),
179184
)
180185
}
@@ -188,9 +193,8 @@ export function update<Result>(adapter: Adapter<Result>, event: SessionEvent.Eve
188193
match.state = {
189194
status: "completed",
190195
input: match.state.input,
191-
output: event.data.output ?? "",
192-
details: event.data.details,
193-
attachments: [...(event.data.attachments ?? [])],
196+
structured: event.data.structured,
197+
content: [...event.data.content],
194198
}
195199
}
196200
}),
@@ -207,6 +211,8 @@ export function update<Result>(adapter: Adapter<Result>, event: SessionEvent.Eve
207211
status: "error",
208212
error: event.data.error,
209213
input: match.state.input,
214+
structured: match.state.structured,
215+
content: match.state.content,
210216
}
211217
}
212218
}),

packages/opencode/src/v2/session-message.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Schema } from "effect"
22
import { Prompt } from "./session-prompt"
33
import { SessionEvent } from "./session-event"
44
import { Event } from "./event"
5+
import { ToolOutput } from "./tool-output"
56

67
export const ID = Event.ID
78
export type ID = Schema.Schema.Type<typeof ID>
@@ -62,22 +63,27 @@ export class ToolStatePending extends Schema.Class<ToolStatePending>("Session.Me
6263
export class ToolStateRunning extends Schema.Class<ToolStateRunning>("Session.Message.ToolState.Running")({
6364
status: Schema.Literal("running"),
6465
input: Schema.Record(Schema.String, Schema.Unknown),
65-
details: Schema.Record(Schema.String, Schema.Unknown).pipe(Schema.optional),
66+
structured: ToolOutput.Structured,
67+
content: ToolOutput.Content.pipe(Schema.Array),
6668
}) {}
6769

6870
export class ToolStateCompleted extends Schema.Class<ToolStateCompleted>("Session.Message.ToolState.Completed")({
6971
status: Schema.Literal("completed"),
7072
input: Schema.Record(Schema.String, Schema.Unknown),
71-
output: Schema.String,
72-
details: Schema.Record(Schema.String, Schema.Unknown).pipe(Schema.optional),
7373
attachments: SessionEvent.FileAttachment.pipe(Schema.Array, Schema.optional),
74+
content: ToolOutput.Content.pipe(Schema.Array),
75+
structured: ToolOutput.Structured,
7476
}) {}
7577

7678
export class ToolStateError extends Schema.Class<ToolStateError>("Session.Message.ToolState.Error")({
7779
status: Schema.Literal("error"),
7880
input: Schema.Record(Schema.String, Schema.Unknown),
79-
error: Schema.String,
80-
details: Schema.Record(Schema.String, Schema.Unknown).pipe(Schema.optional),
81+
content: ToolOutput.Content.pipe(Schema.Array),
82+
structured: ToolOutput.Structured,
83+
error: Schema.Struct({
84+
type: Schema.String,
85+
message: Schema.String,
86+
}),
8187
}) {}
8288

8389
export const ToolState = Schema.Union([ToolStatePending, ToolStateRunning, ToolStateCompleted, ToolStateError]).pipe(
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export * as ToolOutput from "./tool-output"
2+
import { Schema } from "effect"
3+
4+
export class TextContent extends Schema.Class<TextContent>("Tool.TextContent")({
5+
type: Schema.Literal("text"),
6+
text: Schema.String,
7+
}) {}
8+
9+
export class FileContent extends Schema.Class<FileContent>("Tool.FileContent")({
10+
type: Schema.Literal("file"),
11+
uri: Schema.String,
12+
mime: Schema.String,
13+
name: Schema.String.pipe(Schema.optional),
14+
}) {}
15+
16+
export const Content = Schema.Union([TextContent, FileContent]).pipe(Schema.toTaggedUnion("type"))
17+
18+
export const Structured = Schema.Record(Schema.String, Schema.Any)

packages/opencode/tsconfig.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@
1212
"@/*": ["./src/*"],
1313
"@tui/*": ["./src/cli/cmd/tui/*"],
1414
"@test/*": ["./test/*"]
15-
},
16-
"plugins": [
17-
{
18-
"name": "@effect/language-service",
19-
"transform": "@effect/language-service/transform",
20-
"namespaceImportPackages": ["effect", "@effect/*"]
21-
}
22-
]
15+
}
2316
}
2417
}

0 commit comments

Comments
 (0)