Skip to content

Commit 7d2c1ce

Browse files
chore: generate
1 parent a9ef5a0 commit 7d2c1ce

4 files changed

Lines changed: 74 additions & 20 deletions

File tree

packages/core/src/git.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ export const layer = Layer.effect(
7979
}),
8080
)
8181

82-
export const defaultLayer = layer.pipe(Layer.provide(AppFileSystem.defaultLayer), Layer.provide(AppProcess.defaultLayer))
82+
export const defaultLayer = layer.pipe(
83+
Layer.provide(AppFileSystem.defaultLayer),
84+
Layer.provide(AppProcess.defaultLayer),
85+
)
8386

8487
interface Result {
8588
readonly exitCode: number
@@ -97,7 +100,7 @@ function run(cwd: string, proc: AppProcess.Interface) {
97100
}),
98101
)
99102
.pipe(
100-
Effect.map((result) => ({ exitCode: result.exitCode, text: result.stdout.toString("utf8") } satisfies Result)),
103+
Effect.map((result) => ({ exitCode: result.exitCode, text: result.stdout.toString("utf8") }) satisfies Result),
101104
Effect.catch(() => Effect.succeed({ exitCode: 1, text: "" } satisfies Result)),
102105
)
103106
}

packages/core/test/project.test.ts

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ async function rootCommit(dir: string) {
4040
describe("ProjectV2.resolve", () => {
4141
it.live("returns global for non-git directory", () =>
4242
Effect.gen(function* () {
43-
const tmp = yield* Effect.acquireRelease(Effect.promise(() => tmpdir()), (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()))
43+
const tmp = yield* Effect.acquireRelease(
44+
Effect.promise(() => tmpdir()),
45+
(tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()),
46+
)
4447
const project = yield* Project.Service
4548

4649
const result = yield* project.resolve(abs(tmp.path))
@@ -54,7 +57,10 @@ describe("ProjectV2.resolve", () => {
5457

5558
it.live("returns git global for repo with no commits and no remote", () =>
5659
Effect.gen(function* () {
57-
const tmp = yield* Effect.acquireRelease(Effect.promise(() => tmpdir()), (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()))
60+
const tmp = yield* Effect.acquireRelease(
61+
Effect.promise(() => tmpdir()),
62+
(tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()),
63+
)
5864
yield* Effect.promise(() => initRepo(tmp.path))
5965
const project = yield* Project.Service
6066

@@ -69,7 +75,10 @@ describe("ProjectV2.resolve", () => {
6975

7076
it.live("falls back to root commit when origin is missing", () =>
7177
Effect.gen(function* () {
72-
const tmp = yield* Effect.acquireRelease(Effect.promise(() => tmpdir()), (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()))
78+
const tmp = yield* Effect.acquireRelease(
79+
Effect.promise(() => tmpdir()),
80+
(tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()),
81+
)
7382
yield* Effect.promise(() => initRepo(tmp.path, { commit: true }))
7483
const project = yield* Project.Service
7584

@@ -84,7 +93,10 @@ describe("ProjectV2.resolve", () => {
8493

8594
it.live("prefers normalized origin over root commit", () =>
8695
Effect.gen(function* () {
87-
const tmp = yield* Effect.acquireRelease(Effect.promise(() => tmpdir()), (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()))
96+
const tmp = yield* Effect.acquireRelease(
97+
Effect.promise(() => tmpdir()),
98+
(tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()),
99+
)
88100
yield* Effect.promise(() => initRepo(tmp.path, { commit: true, remote: "git@github.com:Acme/App.git" }))
89101
const project = yield* Project.Service
90102

@@ -99,8 +111,14 @@ describe("ProjectV2.resolve", () => {
99111

100112
it.live("normalizes ssh and https remotes to the same id", () =>
101113
Effect.gen(function* () {
102-
const ssh = yield* Effect.acquireRelease(Effect.promise(() => tmpdir()), (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()))
103-
const https = yield* Effect.acquireRelease(Effect.promise(() => tmpdir()), (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()))
114+
const ssh = yield* Effect.acquireRelease(
115+
Effect.promise(() => tmpdir()),
116+
(tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()),
117+
)
118+
const https = yield* Effect.acquireRelease(
119+
Effect.promise(() => tmpdir()),
120+
(tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()),
121+
)
104122
yield* Effect.promise(() => initRepo(ssh.path, { commit: true, remote: "git@github.com:owner/repo.git" }))
105123
yield* Effect.promise(() => initRepo(https.path, { commit: true, remote: "https://github.com/owner/repo.git" }))
106124
const project = yield* Project.Service
@@ -115,7 +133,10 @@ describe("ProjectV2.resolve", () => {
115133

116134
it.live("ignores file remotes and falls back to root commit", () =>
117135
Effect.gen(function* () {
118-
const tmp = yield* Effect.acquireRelease(Effect.promise(() => tmpdir()), (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()))
136+
const tmp = yield* Effect.acquireRelease(
137+
Effect.promise(() => tmpdir()),
138+
(tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()),
139+
)
119140
yield* Effect.promise(() => initRepo(tmp.path, { commit: true, remote: `file://${tmp.path}` }))
120141
const project = yield* Project.Service
121142

@@ -127,7 +148,10 @@ describe("ProjectV2.resolve", () => {
127148

128149
it.live("returns previous cached id from common dir", () =>
129150
Effect.gen(function* () {
130-
const tmp = yield* Effect.acquireRelease(Effect.promise(() => tmpdir()), (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()))
151+
const tmp = yield* Effect.acquireRelease(
152+
Effect.promise(() => tmpdir()),
153+
(tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()),
154+
)
131155
yield* Effect.promise(() => initRepo(tmp.path, { commit: true, remote: "git@github.com:owner/repo.git" }))
132156
yield* Effect.promise(() => Bun.write(path.join(tmp.path, ".git", "opencode"), "old-id"))
133157
const project = yield* Project.Service
@@ -141,7 +165,10 @@ describe("ProjectV2.resolve", () => {
141165

142166
it.live("does not write the cache while resolving", () =>
143167
Effect.gen(function* () {
144-
const tmp = yield* Effect.acquireRelease(Effect.promise(() => tmpdir()), (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()))
168+
const tmp = yield* Effect.acquireRelease(
169+
Effect.promise(() => tmpdir()),
170+
(tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()),
171+
)
145172
yield* Effect.promise(() => initRepo(tmp.path, { commit: true, remote: "git@github.com:owner/repo.git" }))
146173
const project = yield* Project.Service
147174

@@ -153,7 +180,10 @@ describe("ProjectV2.resolve", () => {
153180

154181
it.live("resolves from nested directories to repo root", () =>
155182
Effect.gen(function* () {
156-
const tmp = yield* Effect.acquireRelease(Effect.promise(() => tmpdir()), (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()))
183+
const tmp = yield* Effect.acquireRelease(
184+
Effect.promise(() => tmpdir()),
185+
(tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()),
186+
)
157187
yield* Effect.promise(() => initRepo(tmp.path, { commit: true }))
158188
yield* Effect.promise(() => fs.mkdir(path.join(tmp.path, "a", "b"), { recursive: true }))
159189
const project = yield* Project.Service
@@ -166,9 +196,14 @@ describe("ProjectV2.resolve", () => {
166196

167197
it.live("linked worktree returns opened worktree directory and previous from common dir", () =>
168198
Effect.gen(function* () {
169-
const tmp = yield* Effect.acquireRelease(Effect.promise(() => tmpdir()), (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()))
199+
const tmp = yield* Effect.acquireRelease(
200+
Effect.promise(() => tmpdir()),
201+
(tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()),
202+
)
170203
const worktree = `${tmp.path}-worktree`
171-
yield* Effect.addFinalizer(() => Effect.promise(() => $`rm -rf ${worktree}`.quiet().nothrow()).pipe(Effect.ignore))
204+
yield* Effect.addFinalizer(() =>
205+
Effect.promise(() => $`rm -rf ${worktree}`.quiet().nothrow()).pipe(Effect.ignore),
206+
)
172207
yield* Effect.promise(() => initRepo(tmp.path, { commit: true, remote: "git@github.com:owner/repo.git" }))
173208
yield* Effect.promise(() => Bun.write(path.join(tmp.path, ".git", "opencode"), "old-id"))
174209
yield* Effect.promise(() => $`git worktree add ${worktree} -b test-${Date.now()}`.cwd(tmp.path).quiet())

packages/opencode/src/project/project.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@ export const layer = Layer.effect(
180180

181181
const scope = yield* Scope.Scope
182182

183-
const migrateProjectId = Effect.fn("Project.migrateProjectId")(function* (oldID: ProjectID | undefined, newID: ProjectID) {
183+
const migrateProjectId = Effect.fn("Project.migrateProjectId")(function* (
184+
oldID: ProjectID | undefined,
185+
newID: ProjectID,
186+
) {
184187
if (!oldID) return
185188
if (oldID === ProjectID.global) return
186189
if (oldID === newID) return
@@ -255,7 +258,11 @@ export const layer = Layer.effect(
255258
vcs: data.vcs?.type ?? fakeVcs,
256259
time: { ...existing.time, updated: Date.now() },
257260
}
258-
if (projectID !== ProjectID.global && data.directory !== result.worktree && !result.sandboxes.includes(data.directory))
261+
if (
262+
projectID !== ProjectID.global &&
263+
data.directory !== result.worktree &&
264+
!result.sandboxes.includes(data.directory)
265+
)
259266
result.sandboxes.push(data.directory)
260267
result.sandboxes = yield* Effect.forEach(
261268
result.sandboxes,

packages/opencode/test/project/project.test.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,19 @@ describe("Project.fromDirectory", () => {
239239
const { project } = yield* projects.fromDirectory(tmp)
240240

241241
expect(project.id).toBe(remoteID)
242-
expect(Database.use((db) => db.select().from(ProjectTable).where(eq(ProjectTable.id, rootProject.id)).get())).toBeUndefined()
243-
expect(Database.use((db) => db.select().from(SessionTable).where(eq(SessionTable.id, sessionID)).get())?.project_id).toBe(remoteID)
244-
expect(Database.use((db) => db.select().from(PermissionTable).where(eq(PermissionTable.project_id, remoteID)).get())).toBeDefined()
245-
expect(Database.use((db) => db.select().from(WorkspaceTable).where(eq(WorkspaceTable.id, workspaceID)).get())?.project_id).toBe(remoteID)
242+
expect(
243+
Database.use((db) => db.select().from(ProjectTable).where(eq(ProjectTable.id, rootProject.id)).get()),
244+
).toBeUndefined()
245+
expect(
246+
Database.use((db) => db.select().from(SessionTable).where(eq(SessionTable.id, sessionID)).get())?.project_id,
247+
).toBe(remoteID)
248+
expect(
249+
Database.use((db) => db.select().from(PermissionTable).where(eq(PermissionTable.project_id, remoteID)).get()),
250+
).toBeDefined()
251+
expect(
252+
Database.use((db) => db.select().from(WorkspaceTable).where(eq(WorkspaceTable.id, workspaceID)).get())
253+
?.project_id,
254+
).toBe(remoteID)
246255
}),
247256
)
248257
})

0 commit comments

Comments
 (0)