Skip to content
Merged
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: 0 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ concurrency:

permissions:
contents: read
pull-requests: read

jobs:
quality:
Expand Down Expand Up @@ -70,12 +69,3 @@ jobs:
${{ runner.os }}-bun-
- run: bun install --frozen-lockfile
- run: bun run pack:check

dependency-review:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v4
- uses: actions/dependency-review-action@v4
6 changes: 3 additions & 3 deletions docs/en/pull-request-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ Use `.github/PULL_REQUEST_TEMPLATE.md` and include:

## Review Expectations

- at least one approval is required on `main`
- code owner review is required by branch protection
- pull requests are required for `main`
- required CI checks must pass before merge
- stale approvals are dismissed when the PR changes
- conversations must be resolved before merge
- history must remain linear and force-pushes are blocked on `main`

## Merge Guidance

Expand Down
6 changes: 3 additions & 3 deletions docs/tr/pr-kilavuzu.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ bun run ci:verify

## Inceleme Kurallari

- `main` branch'i icin en az bir onay gerekir
- code owner incelemesi branch protection ile istenir
- `main` branch'i icin pull request zorunludur
- zorunlu CI kontrolleri gecmeden merge yapilamaz
- PR degistiginde eski onaylar gecersiz olur
- tum konusmalar cozulmeden merge yapilamaz
- `main` branch'inde lineer history korunur ve force-push engellenir

## Merge Rehberi

Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ function extractGoal(parts: Array<{ type?: string; text?: string }>): string {
async function runPipeline(ctx: PipelineStageContext): Promise<void> {
for (;;) {
const pipeline = getPipelineBySession(ctx.db, ctx.sessionID)

if (pipeline) {
ctx.pipelineId = pipeline.id
}

const state = pipeline?.state ?? "intake"

if (state === "blocked" || state === "completed" || state === "failed") {
Expand Down
24 changes: 19 additions & 5 deletions tests/helpers/test-utils.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
import { Database } from "bun:sqlite"
import type { PluginInput } from "@opencode-ai/plugin"
import type { ToolContext } from "@opencode-ai/plugin/tool"
import { mkdtempSync } from "node:fs"
import { tmpdir } from "node:os"
import { join } from "node:path"

import { initializeDatabase } from "../../src/state/database.js"

function createTempProjectDirectory(): string {
return mkdtempSync(join(tmpdir(), "opencode-ceo-test-"))
}

Comment on lines +4 to +13
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createTempProjectDirectory() creates real temp directories but nothing in this helper or the call sites cleans them up, so repeated unit test runs will leak /tmp/opencode-ceo-test-* directories (and possibly .ceo/state.db files) on developer machines/CI runners. Consider tracking created directories and exposing a cleanup helper (to be called from test afterEach/afterAll), or allow callers to pass in a directory so tests that only need client don’t create filesystem state unnecessarily.

Suggested change
import { mkdtempSync } from "node:fs"
import { tmpdir } from "node:os"
import { join } from "node:path"
import { initializeDatabase } from "../../src/state/database.js"
function createTempProjectDirectory(): string {
return mkdtempSync(join(tmpdir(), "opencode-ceo-test-"))
}
import { mkdtempSync, rmSync } from "node:fs"
import { tmpdir } from "node:os"
import { join } from "node:path"
import { initializeDatabase } from "../../src/state/database.js"
const tempProjectDirectories: string[] = []
function createTempProjectDirectory(): string {
const directory = mkdtempSync(join(tmpdir(), "opencode-ceo-test-"))
tempProjectDirectories.push(directory)
return directory
}
export function cleanupTempProjectDirectories(): void {
for (const directory of tempProjectDirectories) {
try {
rmSync(directory, { recursive: true, force: true })
} catch {
// Ignore errors during cleanup to avoid failing tests on best-effort deletion.
}
}
tempProjectDirectories.length = 0
}

Copilot uses AI. Check for mistakes.
export function createTestDatabase(): Database {
const db = new Database(":memory:")
initializeDatabase(db)
return db
}

export function createMockPluginInput(): Pick<PluginInput, "directory" | "worktree" | "client"> {
const directory = createTempProjectDirectory()

return {
directory: "/tmp/test-project",
worktree: "/tmp/test-project",
directory,
worktree: directory,
client: {
session: {
create: async () => ({ data: { id: "mock-session-id" } }),
Expand All @@ -34,22 +43,27 @@ export function createMockPluginInput(): Pick<PluginInput, "directory" | "worktr
}

export function createMockToolContext() {
const directory = createTempProjectDirectory()

return {
sessionID: "mock-session-id",
directory: "/tmp/test-project",
directory: directory,
ask: async (_request: unknown) => {},
}
}

export function createMockToolExecutionContext(
overrides: Partial<ToolContext> = {},
): ToolContext {
const directory = overrides.directory ?? createTempProjectDirectory()
const worktree = overrides.worktree ?? directory

return {
sessionID: "mock-session-id",
messageID: "mock-message-id",
agent: "ceo",
directory: "/tmp/test-project",
worktree: "/tmp/test-project",
directory,
worktree,
abort: new AbortController().signal,
metadata() {},
ask: async () => {},
Expand Down
10 changes: 6 additions & 4 deletions tests/unit/github/git-utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { afterEach, describe, expect, test } from "bun:test"
import { mkdtempSync, rmSync } from "node:fs"
import { tmpdir } from "node:os"
import { join } from "node:path"
import { join, resolve } from "node:path"
import { $ } from "bun"

import {
Expand All @@ -13,7 +13,7 @@ import {
} from "../../../src/github/git-utils.ts"

const testDirectories: string[] = []
const projectDirectory = "/home/ugur/Projects/opencode-ceo"
const projectDirectory = resolve(import.meta.dir, "../../..")

function createTempDirectory(prefix: string): string {
const directory = mkdtempSync(join(tmpdir(), prefix))
Expand Down Expand Up @@ -54,8 +54,10 @@ describe("git-utils", () => {
})

test("getCurrentBranch returns a non-empty branch name", async () => {
expect(await getCurrentBranch(projectDirectory)).not.toHaveLength(0)
})
const directory = await createGitRepo("opencode-ceo-current-branch-")

expect(await getCurrentBranch(directory)).not.toHaveLength(0)
})

test("hasRemote resolves to a boolean without throwing", async () => {
const result = await hasRemote(projectDirectory)
Expand Down