From 0294342f77599da6593835934658332db3f42afc Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" Date: Wed, 3 Jun 2026 03:27:34 +0000 Subject: [PATCH] chore: generate --- .../snapshot.json | 162 +++++------------- packages/core/src/git.ts | 8 +- packages/core/src/project/copy-strategies.ts | 7 +- packages/core/src/project/copy.ts | 40 +++-- packages/core/test/project.test.ts | 8 +- packages/opencode/src/project/project.ts | 4 +- .../opencode/test/server/project-copy.test.ts | 8 +- 7 files changed, 91 insertions(+), 146 deletions(-) diff --git a/packages/core/migration/20260602182828_add_project_directories/snapshot.json b/packages/core/migration/20260602182828_add_project_directories/snapshot.json index 10332e288..c96598c2a 100644 --- a/packages/core/migration/20260602182828_add_project_directories/snapshot.json +++ b/packages/core/migration/20260602182828_add_project_directories/snapshot.json @@ -2,10 +2,7 @@ "version": "7", "dialect": "sqlite", "id": "80f2378a-ed35-45cb-9d3b-9f4837fac801", - "prevIds": [ - "7f4866d3-a95b-4141-bb59-28e31c521605", - "80d6efb8-93fd-4ce5-b320-45a05aaebdd7" - ], + "prevIds": ["7f4866d3-a95b-4141-bb59-28e31c521605", "80d6efb8-93fd-4ce5-b320-45a05aaebdd7"], "ddl": [ { "name": "workspace", @@ -1252,13 +1249,9 @@ "table": "session_share" }, { - "columns": [ - "project_id" - ], + "columns": ["project_id"], "tableTo": "project", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "NO ACTION", "onDelete": "CASCADE", "nameExplicit": false, @@ -1267,13 +1260,9 @@ "table": "workspace" }, { - "columns": [ - "active_account_id" - ], + "columns": ["active_account_id"], "tableTo": "account", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "NO ACTION", "onDelete": "SET NULL", "nameExplicit": false, @@ -1282,13 +1271,9 @@ "table": "account_state" }, { - "columns": [ - "aggregate_id" - ], + "columns": ["aggregate_id"], "tableTo": "event_sequence", - "columnsTo": [ - "aggregate_id" - ], + "columnsTo": ["aggregate_id"], "onUpdate": "NO ACTION", "onDelete": "CASCADE", "nameExplicit": false, @@ -1297,13 +1282,9 @@ "table": "event" }, { - "columns": [ - "project_id" - ], + "columns": ["project_id"], "tableTo": "project", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "NO ACTION", "onDelete": "CASCADE", "nameExplicit": false, @@ -1312,13 +1293,9 @@ "table": "permission" }, { - "columns": [ - "project_id" - ], + "columns": ["project_id"], "tableTo": "project", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "NO ACTION", "onDelete": "CASCADE", "nameExplicit": false, @@ -1327,13 +1304,9 @@ "table": "project_directory" }, { - "columns": [ - "session_id" - ], + "columns": ["session_id"], "tableTo": "session", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "NO ACTION", "onDelete": "CASCADE", "nameExplicit": false, @@ -1342,13 +1315,9 @@ "table": "message" }, { - "columns": [ - "message_id" - ], + "columns": ["message_id"], "tableTo": "message", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "NO ACTION", "onDelete": "CASCADE", "nameExplicit": false, @@ -1357,13 +1326,9 @@ "table": "part" }, { - "columns": [ - "session_id" - ], + "columns": ["session_id"], "tableTo": "session", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "NO ACTION", "onDelete": "CASCADE", "nameExplicit": false, @@ -1372,13 +1337,9 @@ "table": "session_message" }, { - "columns": [ - "project_id" - ], + "columns": ["project_id"], "tableTo": "project", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "NO ACTION", "onDelete": "CASCADE", "nameExplicit": false, @@ -1387,13 +1348,9 @@ "table": "session" }, { - "columns": [ - "session_id" - ], + "columns": ["session_id"], "tableTo": "session", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "NO ACTION", "onDelete": "CASCADE", "nameExplicit": false, @@ -1402,13 +1359,9 @@ "table": "todo" }, { - "columns": [ - "session_id" - ], + "columns": ["session_id"], "tableTo": "session", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "NO ACTION", "onDelete": "CASCADE", "nameExplicit": false, @@ -1417,147 +1370,112 @@ "table": "session_share" }, { - "columns": [ - "email", - "url" - ], + "columns": ["email", "url"], "nameExplicit": false, "name": "control_account_pk", "entityType": "pks", "table": "control_account" }, { - "columns": [ - "project_id", - "directory" - ], + "columns": ["project_id", "directory"], "nameExplicit": false, "name": "project_directory_pk", "entityType": "pks", "table": "project_directory" }, { - "columns": [ - "session_id", - "position" - ], + "columns": ["session_id", "position"], "nameExplicit": false, "name": "todo_pk", "entityType": "pks", "table": "todo" }, { - "columns": [ - "id" - ], + "columns": ["id"], "nameExplicit": false, "name": "workspace_pk", "table": "workspace", "entityType": "pks" }, { - "columns": [ - "name" - ], + "columns": ["name"], "nameExplicit": false, "name": "data_migration_pk", "table": "data_migration", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "nameExplicit": false, "name": "account_state_pk", "table": "account_state", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "nameExplicit": false, "name": "account_pk", "table": "account", "entityType": "pks" }, { - "columns": [ - "aggregate_id" - ], + "columns": ["aggregate_id"], "nameExplicit": false, "name": "event_sequence_pk", "table": "event_sequence", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "nameExplicit": false, "name": "event_pk", "table": "event", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "nameExplicit": false, "name": "permission_pk", "table": "permission", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "nameExplicit": false, "name": "project_pk", "table": "project", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "nameExplicit": false, "name": "message_pk", "table": "message", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "nameExplicit": false, "name": "part_pk", "table": "part", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "nameExplicit": false, "name": "session_message_pk", "table": "session_message", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "nameExplicit": false, "name": "session_pk", "table": "session", "entityType": "pks" }, { - "columns": [ - "session_id" - ], + "columns": ["session_id"], "nameExplicit": false, "name": "session_share_pk", "table": "session_share", @@ -1743,4 +1661,4 @@ } ], "renames": [] -} \ No newline at end of file +} diff --git a/packages/core/src/git.ts b/packages/core/src/git.ts index 17550f59f..8b50f6772 100644 --- a/packages/core/src/git.ts +++ b/packages/core/src/git.ts @@ -186,7 +186,13 @@ export const layer = Layer.effect( }) const worktreeRemove = Effect.fn("Git.worktreeRemove")(function* (input: { repo: Repo; directory: AbsolutePath }) { - yield* worktree("remove", input.repo, ["worktree", "remove", "--force", input.directory], input.directory, input.repo.store) + yield* worktree( + "remove", + input.repo, + ["worktree", "remove", "--force", input.directory], + input.directory, + input.repo.store, + ) }) const worktreeList = Effect.fn("Git.worktreeList")(function* (repo: Repo) { diff --git a/packages/core/src/project/copy-strategies.ts b/packages/core/src/project/copy-strategies.ts index b9ecbf849..7a27b2e2b 100644 --- a/packages/core/src/project/copy-strategies.ts +++ b/packages/core/src/project/copy-strategies.ts @@ -10,7 +10,8 @@ export function makeStrategies(input: { fs: FSUtil.Interface canonical: (directory: AbsolutePath) => Effect.Effect }) { - const repo = (sourceDirectory: AbsolutePath) => ({ directory: sourceDirectory, store: sourceDirectory }) satisfies Git.Repo + const repo = (sourceDirectory: AbsolutePath) => + ({ directory: sourceDirectory, store: sourceDirectory }) satisfies Git.Repo const gitWorktree: Strategy = { id: "git_worktree", @@ -26,7 +27,9 @@ export function makeStrategies(input: { list: Effect.fn("ProjectCopy.GitWorktree.list")(function* (directory) { const entries = yield* input.git.worktreeList(repo(directory)) return yield* Effect.forEach(entries, (entry) => - entry === directory ? Effect.succeed(undefined) : input.canonical(entry).pipe(Effect.map((directory) => ({ directory }))), + entry === directory + ? Effect.succeed(undefined) + : input.canonical(entry).pipe(Effect.map((directory) => ({ directory }))), ).pipe(Effect.map((items) => items.filter((item): item is Copy => item !== undefined))) }), detect: Effect.fn("ProjectCopy.GitWorktree.detect")(function* (inputDirectory) { diff --git a/packages/core/src/project/copy.ts b/packages/core/src/project/copy.ts index 7de4335e1..317b7403b 100644 --- a/packages/core/src/project/copy.ts +++ b/packages/core/src/project/copy.ts @@ -120,7 +120,9 @@ export const layer = Layer.effect( const row = yield* db .select({ directory: ProjectDirectoryTable.directory }) .from(ProjectDirectoryTable) - .where(and(eq(ProjectDirectoryTable.project_id, projectID), eq(ProjectDirectoryTable.directory, sourceDirectory))) + .where( + and(eq(ProjectDirectoryTable.project_id, projectID), eq(ProjectDirectoryTable.directory, sourceDirectory)), + ) .get() .pipe(Effect.orDie) if (!row) return yield* new SourceDirectoryNotFoundError({ directory: sourceDirectory }) @@ -135,10 +137,18 @@ export const layer = Layer.effect( const row = yield* tx .select({ directory: ProjectDirectoryTable.directory }) .from(ProjectDirectoryTable) - .where(and(eq(ProjectDirectoryTable.project_id, projectID), eq(ProjectDirectoryTable.directory, copyDirectory))) + .where( + and( + eq(ProjectDirectoryTable.project_id, projectID), + eq(ProjectDirectoryTable.directory, copyDirectory), + ), + ) .get() if (row) return false - yield* tx.insert(ProjectDirectoryTable).values({ project_id: projectID, directory: copyDirectory, type }).run() + yield* tx + .insert(ProjectDirectoryTable) + .values({ project_id: projectID, directory: copyDirectory, type }) + .run() return true }), { behavior: "immediate" }, @@ -150,7 +160,9 @@ export const layer = Layer.effect( return ( (yield* db .delete(ProjectDirectoryTable) - .where(and(eq(ProjectDirectoryTable.project_id, projectID), eq(ProjectDirectoryTable.directory, copyDirectory))) + .where( + and(eq(ProjectDirectoryTable.project_id, projectID), eq(ProjectDirectoryTable.directory, copyDirectory)), + ) .returning({ directory: ProjectDirectoryTable.directory }) .get() .pipe(Effect.orDie)) !== undefined @@ -171,7 +183,8 @@ export const layer = Layer.effect( }) const create = Effect.fn("ProjectCopy.create")(function* (input: CreateInput) { - if (yield* fs.existsSafe(input.directory)) return yield* new DestinationExistsError({ directory: input.directory }) + if (yield* fs.existsSafe(input.directory)) + return yield* new DestinationExistsError({ directory: input.directory }) const result = yield* strategy(input.strategy).create({ directory: input.directory, sourceDirectory: yield* source(input.sourceDirectory, input.projectID), @@ -192,7 +205,12 @@ export const layer = Layer.effect( const roots = yield* db .select({ directory: ProjectDirectoryTable.directory }) .from(ProjectDirectoryTable) - .where(and(eq(ProjectDirectoryTable.project_id, input.projectID), inArray(ProjectDirectoryTable.type, ["main", "root"]))) + .where( + and( + eq(ProjectDirectoryTable.project_id, input.projectID), + inArray(ProjectDirectoryTable.type, ["main", "root"]), + ), + ) .all() .pipe(Effect.orDie) const sourceDirectories = yield* Effect.forEach(roots, (item) => canonical(AbsolutePath.make(item.directory)), { @@ -207,16 +225,18 @@ export const layer = Layer.effect( .pipe(Effect.map((items) => items.map((item) => ({ ...item, type: strategy.id })))), ), { concurrency: "unbounded" }, - ).pipe(Effect.map((sets) => new Map(sets.flat(2).map((item) => [item.directory, item] as const)).values().toArray())) + ).pipe( + Effect.map((sets) => new Map(sets.flat(2).map((item) => [item.directory, item] as const)).values().toArray()), + ) const stored = yield* db .select({ directory: ProjectDirectoryTable.directory }) .from(ProjectDirectoryTable) .where(eq(ProjectDirectoryTable.project_id, input.projectID)) .all() .pipe(Effect.orDie) - const inserted = yield* Effect.forEach(discovered, (item) => insert(input.projectID, item.directory, item.type)).pipe( - Effect.map((items) => items.some(Boolean)), - ) + const inserted = yield* Effect.forEach(discovered, (item) => + insert(input.projectID, item.directory, item.type), + ).pipe(Effect.map((items) => items.some(Boolean))) const removed = yield* Effect.forEach(stored, (item) => fs .isDir(item.directory) diff --git a/packages/core/test/project.test.ts b/packages/core/test/project.test.ts index edc97ba53..c65ac4778 100644 --- a/packages/core/test/project.test.ts +++ b/packages/core/test/project.test.ts @@ -54,9 +54,11 @@ async function rootCommit(dir: string) { describe("Project directories schemas", () => { it.effect("decodes project directory input and inline directory results", () => Effect.sync(() => { - expect(Schema.decodeUnknownSync(ProjectV2.DirectoriesInput)({ projectID: ProjectV2.ID.make("project") })).toEqual({ - projectID: ProjectV2.ID.make("project"), - }) + expect(Schema.decodeUnknownSync(ProjectV2.DirectoriesInput)({ projectID: ProjectV2.ID.make("project") })).toEqual( + { + projectID: ProjectV2.ID.make("project"), + }, + ) expect(Schema.decodeUnknownSync(ProjectV2.Directories)([AbsolutePath.make("/tmp/project")])).toEqual([ AbsolutePath.make("/tmp/project"), ]) diff --git a/packages/opencode/src/project/project.ts b/packages/opencode/src/project/project.ts index 893670eeb..80cde325e 100644 --- a/packages/opencode/src/project/project.ts +++ b/packages/opencode/src/project/project.ts @@ -232,7 +232,9 @@ export const layer = Layer.effect( const hasMain = yield* d .select({ directory: ProjectDirectoryTable.directory }) .from(ProjectDirectoryTable) - .where(and(eq(ProjectDirectoryTable.project_id, input.projectID), eq(ProjectDirectoryTable.type, "main"))) + .where( + and(eq(ProjectDirectoryTable.project_id, input.projectID), eq(ProjectDirectoryTable.type, "main")), + ) .get() yield* d .insert(ProjectDirectoryTable) diff --git a/packages/opencode/test/server/project-copy.test.ts b/packages/opencode/test/server/project-copy.test.ts index afa53c8ef..1433436f1 100644 --- a/packages/opencode/test/server/project-copy.test.ts +++ b/packages/opencode/test/server/project-copy.test.ts @@ -22,13 +22,7 @@ afterEach(async () => { const noopBootstrap = Layer.succeed(InstanceBootstrap.Service, InstanceBootstrap.Service.of({ run: Effect.void })) const testInstanceStore = InstanceStore.defaultLayer.pipe(Layer.provide(noopBootstrap)) const it = testEffect( - Layer.mergeAll( - FSUtil.defaultLayer, - Database.defaultLayer, - Snapshot.defaultLayer, - testInstanceStore, - httpApiLayer, - ), + Layer.mergeAll(FSUtil.defaultLayer, Database.defaultLayer, Snapshot.defaultLayer, testInstanceStore, httpApiLayer), ) function request(directory: string, url: string, init: RequestInit = {}) {