Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/opencode/src/git/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]
})
})
Expand Down
8 changes: 6 additions & 2 deletions packages/opencode/src/project/vcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -353,9 +355,11 @@ export const layer: Layer.Layer<Service, never, Git.Service | EventV2Bridge.Serv
[git.status(ctx.directory), ref ? git.stats(ctx.directory, ref) : Effect.succeed([])],
{ concurrency: 2 },
)
const truncated = list.length > 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 =
Expand Down
Loading