Skip to content

Commit 6cdc4d7

Browse files
committed
chore: drop superseded fork patches and stale artifacts
Reset to upstream dev: - plugin/index.ts (upstream anomalyco#18280 rewrote plugin error handling) - cli/error.ts (upstream anomalyco#27803 reworked TUI error rendering) - session-data.ts (upstream error typing changes) - session/prompt.ts (massive upstream refactor) - cli/cmd/tui/worker.ts (restored — was deleted by stale merge) Removed dead artifacts: - script/patch-aft-lsp.sh (targets deleted worker.ts architecture) - session-ses_1d10.md, sessions.jsonl (stale session dumps) Backup: fork/local-backup
1 parent 0f1798d commit 6cdc4d7

8 files changed

Lines changed: 517 additions & 7265 deletions

File tree

packages/opencode/script/patch-aft-lsp.sh

Lines changed: 0 additions & 61 deletions
This file was deleted.

packages/opencode/src/cli/cmd/run/session-data.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,10 +1096,7 @@ export function reduceSessionData(input: SessionDataInput): SessionDataOutput {
10961096
}
10971097

10981098
if (event.type === "session.error") {
1099-
if (
1100-
(event.properties.sessionID !== undefined && event.properties.sessionID !== input.sessionID) ||
1101-
!event.properties.error
1102-
) {
1099+
if (event.properties.sessionID !== input.sessionID || !event.properties.error) {
11031100
return out(data, commits)
11041101
}
11051102

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import { Installation } from "@/installation"
2+
import { Server } from "@/server/server"
3+
import * as Log from "@opencode-ai/core/util/log"
4+
import { InstanceRuntime } from "@/project/instance-runtime"
5+
import { Rpc } from "@/util/rpc"
6+
import { upgrade } from "@/cli/upgrade"
7+
import { Config } from "@/config/config"
8+
import { GlobalBus } from "@/bus/global"
9+
import { ServerAuth } from "@/server/auth"
10+
import { writeHeapSnapshot } from "node:v8"
11+
import { Heap } from "@/cli/heap"
12+
import { AppRuntime } from "@/effect/app-runtime"
13+
import { ensureProcessMetadata } from "@opencode-ai/core/util/opencode-process"
14+
import { Effect } from "effect"
15+
import { disposeAllInstancesAndEmitGlobalDisposed } from "@/server/global-lifecycle"
16+
17+
ensureProcessMetadata("worker")
18+
19+
await Log.init({
20+
print: process.argv.includes("--print-logs"),
21+
dev: Installation.isLocal(),
22+
level: (() => {
23+
if (Installation.isLocal()) return "DEBUG"
24+
return "INFO"
25+
})(),
26+
})
27+
28+
Heap.start()
29+
30+
process.on("unhandledRejection", (e) => {
31+
Log.Default.error("rejection", {
32+
e: e instanceof Error ? e.message : e,
33+
})
34+
})
35+
36+
process.on("uncaughtException", (e) => {
37+
Log.Default.error("exception", {
38+
e: e instanceof Error ? e.message : e,
39+
})
40+
})
41+
42+
// Subscribe to global events and forward them via RPC
43+
GlobalBus.on("event", (event) => {
44+
Rpc.emit("global.event", event)
45+
})
46+
47+
let server: Awaited<ReturnType<typeof Server.listen>> | undefined
48+
49+
export const rpc = {
50+
async fetch(input: { url: string; method: string; headers: Record<string, string>; body?: string }) {
51+
const headers = { ...input.headers }
52+
const auth = ServerAuth.header()
53+
if (auth && !headers["authorization"] && !headers["Authorization"]) {
54+
headers["Authorization"] = auth
55+
}
56+
const request = new Request(input.url, {
57+
method: input.method,
58+
headers,
59+
body: input.body,
60+
})
61+
const response = await Server.Default().app.fetch(request)
62+
const body = await response.text()
63+
return {
64+
status: response.status,
65+
headers: Object.fromEntries(response.headers.entries()),
66+
body,
67+
}
68+
},
69+
snapshot() {
70+
const result = writeHeapSnapshot("server.heapsnapshot")
71+
return result
72+
},
73+
async server(input: { port: number; hostname: string; mdns?: boolean; cors?: string[] }) {
74+
if (server) await server.stop(true)
75+
server = await Server.listen(input)
76+
return { url: server.url.toString() }
77+
},
78+
async checkUpgrade(input: { directory: string }) {
79+
await InstanceRuntime.load({ directory: input.directory })
80+
await upgrade().catch(() => {})
81+
},
82+
async reload() {
83+
await AppRuntime.runPromise(
84+
Effect.gen(function* () {
85+
const cfg = yield* Config.Service
86+
yield* cfg.invalidate()
87+
yield* disposeAllInstancesAndEmitGlobalDisposed({ swallowErrors: true })
88+
}),
89+
)
90+
},
91+
async shutdown() {
92+
Log.Default.info("worker shutting down")
93+
94+
await InstanceRuntime.disposeAllInstances()
95+
if (server) await server.stop(true)
96+
},
97+
}
98+
99+
Rpc.listen(rpc)

packages/opencode/src/cli/error.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Cause } from "effect"
21
import { NamedError } from "@opencode-ai/core/util/error"
32
import { errorFormat } from "@/util/error"
43
import { isRecord } from "@/util/record"
@@ -33,14 +32,7 @@ function configIssues(input: Record<string, unknown>): ConfigIssue[] {
3332
: []
3433
}
3534

36-
const FiberFailureCauseId = Symbol.for("effect/FiberFailure")
37-
3835
export function FormatError(input: unknown): string | undefined {
39-
if (typeof input === "object" && input !== null && FiberFailureCauseId in input) {
40-
const cause = (input as Record<symbol, unknown>)[FiberFailureCauseId] as Cause.Cause<unknown>
41-
return FormatError(Cause.squash(cause))
42-
}
43-
4436
if (input instanceof Error && isRecord(input.cause) && "body" in input.cause) {
4537
const formatted = FormatError(input.cause.body)
4638
if (formatted) return formatted
@@ -102,18 +94,6 @@ export function FormatError(input: unknown): string | undefined {
10294
return stringField(configFrontmatter, "message") ?? ""
10395
}
10496

105-
// ConfigRemoteAuthError: { url: string, remote: string }
106-
const remoteAuth = configData(input, "ConfigRemoteAuthError")
107-
if (remoteAuth) {
108-
const url = stringField(remoteAuth, "url")
109-
const remote = stringField(remoteAuth, "remote")
110-
return [
111-
`Failed to load remote config${remote ? ` from ${remote}` : ""}: the server returned a login page instead of JSON.`,
112-
`Authentication is missing or has expired (the endpoint is likely behind an SSO or identity-aware proxy).`,
113-
...(url ? [`Run \`opencode auth login ${url}\` to re-authenticate.`] : []),
114-
].join("\n")
115-
}
116-
11797
// ConfigInvalidError: { path?: string, message?: string, issues?: Array<{ message: string, path: string[] }> }
11898
const configInvalid = configData(input, "ConfigInvalidError")
11999
if (configInvalid) {

0 commit comments

Comments
 (0)