Skip to content

Commit a443f1c

Browse files
alltomatosclaude
andcommitted
Merge branch 'dev' into claude/fix-pr-test-errors-082173
Resolves conflicts in run-process.test.ts, workspace.test.ts, and prompt.test.ts: dev already landed an equivalent/superset fix for the same timeout issue via #163 (explicitly "port fix from #202") and a follow-up prompt.test.ts timeout widen — kept dev's versions since they're functionally identical or better (same 60s/30s/5000ms values, plus dev's own additional widened prompt-shell-loop timeouts). Co-Authored-By: Claude Sonnet 5 <[email protected]>
2 parents b6351b7 + 6b9ebbd commit a443f1c

14 files changed

Lines changed: 584 additions & 53 deletions

File tree

‎packages/app/playwright.config.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ const serverHost = process.env.PLAYWRIGHT_SERVER_HOST ?? "127.0.0.1"
66
const serverPort = process.env.PLAYWRIGHT_SERVER_PORT ?? "4096"
77
const command = `bun run dev -- --host 0.0.0.0 --port ${port}`
88
const reuse = !process.env.CI
9-
const workers = Number(process.env.PLAYWRIGHT_WORKERS ?? (process.env.CI ? 5 : 0)) || undefined
9+
const isWindows = process.platform === "win32"
10+
const workers = Number(
11+
process.env.PLAYWRIGHT_WORKERS ?? (process.env.CI ? (isWindows ? 3 : 5) : 0),
12+
) || undefined
1013
export default defineConfig({
1114
testDir: "./e2e",
1215
testIgnore: process.env.OPENCODE_PERFORMANCE === "1" ? "performance/**/*.test.ts" : "performance/**",
1316
outputDir: "./e2e/test-results",
14-
timeout: 60_000,
17+
timeout: isWindows ? 90_000 : 60_000,
1518
expect: {
16-
timeout: 10_000,
19+
timeout: isWindows ? 25_000 : 10_000,
1720
},
1821
fullyParallel: process.env.PLAYWRIGHT_FULLY_PARALLEL === "1",
1922
forbidOnly: !!process.env.CI,

‎packages/opencode/src/memory/index.ts‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ export interface Interface {
143143
// to global silently.
144144
readonly promoteGlobal: (input: { summary: string }) => Effect.Effect<{ path: string }>
145145
readonly load: (input: { directory?: string }) => Effect.Effect<{ context: string }>
146+
readonly loadProject: (directory: string) => Effect.Effect<{ content: string }>
147+
readonly loadGlobal: () => Effect.Effect<{ content: string }>
146148
readonly forgetProject: (directory: string) => Effect.Effect<void>
147149
// Used to decide whether closing a project should even ask about
148150
// forgetting its memory — no memory recorded means no dialog, no
@@ -306,6 +308,22 @@ const layer: Layer.Layer<Service, never, Config.Service | Provider.Service> = La
306308
return { context: [global, project].filter(Boolean).join("\n\n") }
307309
})
308310

311+
const loadProject = Effect.fn("Memory.loadProject")(function* (directory: string) {
312+
const content = yield* Effect.tryPromise({
313+
try: () => readRecentMemoryFiles(projectDir(directory), 30),
314+
catch: () => "",
315+
}).pipe(Effect.orElseSucceed(() => ""))
316+
return { content }
317+
})
318+
319+
const loadGlobal = Effect.fn("Memory.loadGlobal")(function* () {
320+
const content = yield* Effect.tryPromise({
321+
try: () => readRecentMemoryFiles(globalDir(), 30),
322+
catch: () => "",
323+
}).pipe(Effect.orElseSucceed(() => ""))
324+
return { content }
325+
})
326+
309327
const forgetProject = Effect.fn("Memory.forgetProject")(function* (directory: string) {
310328
yield* Effect.tryPromise({ try: () => rm(projectDir(directory), { recursive: true, force: true }), catch: () => undefined }).pipe(
311329
Effect.orDie,
@@ -319,7 +337,7 @@ const layer: Layer.Layer<Service, never, Config.Service | Provider.Service> = La
319337
return entries.some((entry) => entry.endsWith(".md"))
320338
})
321339

322-
return Service.of({ get, set, summarize, promoteGlobal, load, forgetProject, hasProjectMemory, remember })
340+
return Service.of({ get, set, summarize, promoteGlobal, load, loadProject, loadGlobal, forgetProject, hasProjectMemory, remember })
323341
}),
324342
)
325343

‎packages/opencode/src/server/routes/instance/httpapi/groups/memory.ts‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,39 @@ export const ForgetProjectQuery = Schema.Struct({
1010
directory: Schema.String,
1111
})
1212

13+
export const ProjectEntriesQuery = Schema.Struct({
14+
directory: Schema.String,
15+
})
16+
1317
export const ProjectMemoryStatus = Schema.Struct({
1418
hasMemory: Schema.Boolean,
1519
})
1620

21+
export const MemoryContent = Schema.Struct({
22+
content: Schema.String,
23+
})
24+
25+
export const AddMemoryPayload = Schema.Struct({
26+
directory: Schema.optional(Schema.String),
27+
note: Schema.String,
28+
global: Schema.optional(Schema.Boolean),
29+
})
30+
31+
export const PromoteMemoryPayload = Schema.Struct({
32+
summary: Schema.String,
33+
})
34+
35+
export const MemoryFileResult = Schema.Struct({
36+
path: Schema.String,
37+
})
38+
1739
export const MemoryPaths = {
1840
config: "/memory",
1941
forgetProject: "/memory/project",
42+
projectEntries: "/memory/project/entries",
43+
globalEntries: "/memory/global",
44+
addEntry: "/memory/entry",
45+
promote: "/memory/promote",
2046
} as const
2147

2248
export const MemoryApi = HttpApi.make("memory")
@@ -65,6 +91,48 @@ export const MemoryApi = HttpApi.make("memory")
6591
description: "Deletes all memory entries recorded for the given project directory. Global memory is untouched.",
6692
}),
6793
),
94+
HttpApiEndpoint.get("getProjectEntries", MemoryPaths.projectEntries, {
95+
query: ProjectEntriesQuery,
96+
success: described(MemoryContent, "Project memory entries"),
97+
}).annotateMerge(
98+
OpenApi.annotations({
99+
identifier: "memory.getProjectEntries",
100+
summary: "Get project memory content",
101+
description: "Returns markdown content of recorded memories for the given project directory.",
102+
}),
103+
),
104+
HttpApiEndpoint.get("getGlobalEntries", MemoryPaths.globalEntries, {
105+
query: WorkspaceRoutingQuery,
106+
success: described(MemoryContent, "Global memory entries"),
107+
}).annotateMerge(
108+
OpenApi.annotations({
109+
identifier: "memory.getGlobalEntries",
110+
summary: "Get global memory content",
111+
description: "Returns markdown content of recorded global memories across all projects.",
112+
}),
113+
),
114+
HttpApiEndpoint.post("addEntry", MemoryPaths.addEntry, {
115+
query: WorkspaceRoutingQuery,
116+
payload: AddMemoryPayload,
117+
success: described(MemoryFileResult, "Path of written memory file"),
118+
}).annotateMerge(
119+
OpenApi.annotations({
120+
identifier: "memory.addEntry",
121+
summary: "Add a memory note",
122+
description: "Directly records a note in project memory or global memory without requiring LLM execution.",
123+
}),
124+
),
125+
HttpApiEndpoint.post("promote", MemoryPaths.promote, {
126+
query: WorkspaceRoutingQuery,
127+
payload: PromoteMemoryPayload,
128+
success: described(MemoryFileResult, "Path of written global memory file"),
129+
}).annotateMerge(
130+
OpenApi.annotations({
131+
identifier: "memory.promote",
132+
summary: "Promote memory to global",
133+
description: "Promotes a summary/decision to global memory and regenerates the global memory skill file.",
134+
}),
135+
),
68136
)
69137
.annotateMerge(
70138
OpenApi.annotations({

‎packages/opencode/src/server/routes/instance/httpapi/handlers/memory.ts‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { ConfigMemoryV1 } from "@opencode-ai/core/v1/config/memory"
33
import { Effect } from "effect"
44
import { HttpApiBuilder } from "effect/unstable/httpapi"
55
import { InstanceHttpApi } from "../api"
6-
import type { ForgetProjectQuery } from "../groups/memory"
6+
import type { AddMemoryPayload, ForgetProjectQuery, ProjectEntriesQuery, PromoteMemoryPayload } from "../groups/memory"
77

88
export const memoryHandlers = HttpApiBuilder.group(InstanceHttpApi, "memory", (handlers) =>
99
Effect.gen(function* () {
@@ -30,10 +30,39 @@ export const memoryHandlers = HttpApiBuilder.group(InstanceHttpApi, "memory", (h
3030
return { hasMemory: yield* memory.hasProjectMemory(ctx.query.directory) }
3131
})
3232

33+
const getProjectEntries = Effect.fn("MemoryHttpApi.getProjectEntries")(function* (ctx: {
34+
query: typeof ProjectEntriesQuery.Type
35+
}) {
36+
return yield* memory.loadProject(ctx.query.directory)
37+
})
38+
39+
const getGlobalEntries = Effect.fn("MemoryHttpApi.getGlobalEntries")(function* () {
40+
return yield* memory.loadGlobal()
41+
})
42+
43+
const addEntry = Effect.fn("MemoryHttpApi.addEntry")(function* (ctx: {
44+
payload: typeof AddMemoryPayload.Type
45+
}) {
46+
if (ctx.payload.global || !ctx.payload.directory) {
47+
return yield* memory.promoteGlobal({ summary: ctx.payload.note })
48+
}
49+
return yield* memory.remember({ directory: ctx.payload.directory, note: ctx.payload.note })
50+
})
51+
52+
const promote = Effect.fn("MemoryHttpApi.promote")(function* (ctx: {
53+
payload: typeof PromoteMemoryPayload.Type
54+
}) {
55+
return yield* memory.promoteGlobal({ summary: ctx.payload.summary })
56+
})
57+
3358
return handlers
3459
.handle("getConfig", getConfig)
3560
.handle("setConfig", setConfig)
3661
.handle("forgetProject", forgetProject)
3762
.handle("projectMemoryStatus", projectMemoryStatus)
63+
.handle("getProjectEntries", getProjectEntries)
64+
.handle("getGlobalEntries", getGlobalEntries)
65+
.handle("addEntry", addEntry)
66+
.handle("promote", promote)
3867
}),
3968
)

‎packages/opencode/test/cli/run/run-process.test.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,6 @@ describe("opencode run (non-interactive subprocess)", () => {
175175
})
176176
expect(result.stdout.split("\n").filter(Boolean)).toHaveLength(1)
177177
}),
178-
// 60s to match the harness's own subprocess timeout default (test/lib/cli-process.ts) —
179-
// a 30s outer bound was tighter than the process it's timing, so CI-load variance could
180-
// trip the outer timeout before the subprocess itself finished. Observed 30060ms on 2026-09-12.
181178
60_000,
182179
)
183180

‎packages/opencode/test/control-plane/workspace.test.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,6 @@ function expectExitContains(exit: Exit.Exit<unknown, unknown>, ...messages: stri
155155
for (const message of messages) expect(String(exit.cause)).toContain(message)
156156
}
157157

158-
// 5000ms (was 1500ms): under CI-load, workspace sync status transitions (e.g. detecting
159-
// a missing target directory) can take longer than 1.5s to propagate, causing this poll
160-
// to exhaust its budget before the expected status is observed. Observed a 16875ms failure
161-
// on "local start reports error when the target directory is missing" on 2026-09-12.
162158
function eventuallyEffect(effect: Effect.Effect<void>, timeout = 5000) {
163159
return Effect.gen(function* () {
164160
const started = Date.now()

‎packages/opencode/test/memory/memory.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,24 @@ it.instance("forgetProject() removes only that project's memory, not global", ()
133133
expect(context).toContain("Continua global depois de esquecer um projeto.")
134134
}),
135135
)
136+
137+
it.instance("loadProject() and loadGlobal() return separate contents", () =>
138+
Effect.gen(function* () {
139+
const memory = yield* Memory.Service
140+
const directory = "/tmp/load-separate-test"
141+
142+
yield* memory.remember({ directory, note: "Nota especifica do projeto." })
143+
yield* memory.promoteGlobal({ summary: "Nota especifica global." })
144+
145+
const { content: projectContent } = yield* memory.loadProject(directory)
146+
const { content: globalContent } = yield* memory.loadGlobal()
147+
148+
expect(projectContent).toContain("Nota especifica do projeto.")
149+
expect(projectContent).not.toContain("Nota especifica global.")
150+
151+
expect(globalContent).toContain("Nota especifica global.")
152+
expect(globalContent).not.toContain("Nota especifica do projeto.")
153+
154+
yield* memory.forgetProject(directory)
155+
}),
156+
)

‎packages/opencode/test/project/instance-bootstrap.test.ts‎

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -67,49 +67,61 @@ function waitDisposed(directory: string) {
6767
})
6868
}
6969

70-
it.live("InstanceStore.provide runs InstanceBootstrap before effect", () =>
71-
Effect.gen(function* () {
72-
const tmp = yield* bootstrapFixture
73-
const store = yield* InstanceStore.Service
74-
75-
yield* store.provide({ directory: tmp.directory }, Effect.succeed("ok"))
76-
77-
expect(existsSync(tmp.marker)).toBe(true)
78-
}),
70+
it.live(
71+
"InstanceStore.provide runs InstanceBootstrap before effect",
72+
() =>
73+
Effect.gen(function* () {
74+
const tmp = yield* bootstrapFixture
75+
const store = yield* InstanceStore.Service
76+
77+
yield* store.provide({ directory: tmp.directory }, Effect.succeed("ok"))
78+
79+
expect(existsSync(tmp.marker)).toBe(true)
80+
}),
81+
120_000,
7982
)
8083

81-
it.live("CLI bootstrap runs InstanceBootstrap before callback", () =>
82-
Effect.gen(function* () {
83-
const tmp = yield* bootstrapFixture
84+
it.live(
85+
"CLI bootstrap runs InstanceBootstrap before callback",
86+
() =>
87+
Effect.gen(function* () {
88+
const tmp = yield* bootstrapFixture
8489

85-
yield* Effect.promise(() => cliBootstrap(tmp.directory, async () => "ok"))
90+
yield* Effect.promise(() => cliBootstrap(tmp.directory, async () => "ok"))
8691

87-
expect(existsSync(tmp.marker)).toBe(true)
88-
}),
92+
expect(existsSync(tmp.marker)).toBe(true)
93+
}),
94+
120_000,
8995
)
9096

91-
it.live("CLI bootstrap disposes the instance when the callback rejects", () =>
92-
Effect.gen(function* () {
93-
const tmp = yield* bootstrapFixture
94-
const disposed = yield* waitDisposed(tmp.directory).pipe(Effect.forkScoped({ startImmediately: true }))
95-
96-
const exit = yield* Effect.promise(() =>
97-
cliBootstrap(tmp.directory, async () => Promise.reject(new Error("boom"))),
98-
).pipe(Effect.exit)
99-
100-
expect(Exit.isFailure(exit)).toBe(true)
101-
if (Exit.isFailure(exit)) expect(Cause.squash(exit.cause)).toMatchObject({ message: "boom" })
102-
yield* Fiber.join(disposed)
103-
}),
97+
it.live(
98+
"CLI bootstrap disposes the instance when the callback rejects",
99+
() =>
100+
Effect.gen(function* () {
101+
const tmp = yield* bootstrapFixture
102+
const disposed = yield* waitDisposed(tmp.directory).pipe(Effect.forkScoped({ startImmediately: true }))
103+
104+
const exit = yield* Effect.promise(() =>
105+
cliBootstrap(tmp.directory, async () => Promise.reject(new Error("boom"))),
106+
).pipe(Effect.exit)
107+
108+
expect(Exit.isFailure(exit)).toBe(true)
109+
if (Exit.isFailure(exit)) expect(Cause.squash(exit.cause)).toMatchObject({ message: "boom" })
110+
yield* Fiber.join(disposed)
111+
}),
112+
120_000,
104113
)
105114

106-
it.live("InstanceStore.reload runs InstanceBootstrap", () =>
107-
Effect.gen(function* () {
108-
const tmp = yield* bootstrapFixture
109-
const store = yield* InstanceStore.Service
115+
it.live(
116+
"InstanceStore.reload runs InstanceBootstrap",
117+
() =>
118+
Effect.gen(function* () {
119+
const tmp = yield* bootstrapFixture
120+
const store = yield* InstanceStore.Service
110121

111-
yield* store.reload({ directory: tmp.directory })
122+
yield* store.reload({ directory: tmp.directory })
112123

113-
expect(existsSync(tmp.marker)).toBe(true)
114-
}),
124+
expect(existsSync(tmp.marker)).toBe(true)
125+
}),
126+
120_000,
115127
)

0 commit comments

Comments
 (0)