diff --git a/packages/opencode/src/git/index.ts b/packages/opencode/src/git/index.ts index 81358ef960b3..d13c84bd61a2 100644 --- a/packages/opencode/src/git/index.ts +++ b/packages/opencode/src/git/index.ts @@ -214,13 +214,17 @@ export const layer = Layer.effect( const status = Effect.fn("Git.status")(function* (cwd: string) { return nuls( - yield* text(["status", "--porcelain=v1", "--untracked-files=all", "--no-renames", "-z", "--", "."], { - cwd, - }), + yield* text( + ["status", "--porcelain=v1", "--untracked-files=normal", "--no-renames", "-z", "--", "."], + { + cwd, + }, + ), ).flatMap((item) => { const file = item.slice(3) if (!file) return [] const code = item.slice(0, 2) + if (file.endsWith("/")) return [] return [{ file, code, status: kind(code) } satisfies Item] }) }) diff --git a/packages/opencode/src/project/vcs.ts b/packages/opencode/src/project/vcs.ts index 164bcbbd2dfd..216eca3ef9c9 100644 --- a/packages/opencode/src/project/vcs.ts +++ b/packages/opencode/src/project/vcs.ts @@ -11,6 +11,7 @@ import { VcsEvent } from "@opencode-ai/schema/vcs-event" const PATCH_CONTEXT_LINES = 2_147_483_647 const MAX_PATCH_BYTES = 10_000_000 const MAX_TOTAL_PATCH_BYTES = 10_000_000 +const MAX_STATUS_FILES = 2000 type DiffOptions = { readonly context?: number } @@ -175,8 +176,9 @@ const files = Effect.fnUntraced(function* ( const next: FileDiff[] = [] let total = 0 let capped = false + const items = list.length > MAX_STATUS_FILES ? list.slice(0, MAX_STATUS_FILES) : list - for (const item of list.toSorted((a, b) => a.file.localeCompare(b.file))) { + for (const item of items.toSorted((a, b) => a.file.localeCompare(b.file))) { const stat = map.get(item.file) ?? (item.status === "added" ? yield* git.statUntracked(cwd, item.file) : undefined) const patch = yield* patchForItem(git, cwd, ref, item, batch, capped, options) const result: { patch: string; capped: boolean } = capped @@ -353,9 +355,11 @@ export const layer: Layer.Layer MAX_STATUS_FILES + const items = truncated ? list.slice(0, MAX_STATUS_FILES) : list const map = nums(stats) return yield* Effect.forEach( - list.toSorted((a, b) => a.file.localeCompare(b.file)), + items.toSorted((a, b) => a.file.localeCompare(b.file)), (item) => Effect.gen(function* () { const stat =