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
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
pull_request:
push:
branches:
- main

jobs:
check:
name: Check, typecheck, and test
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v2

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Check formatting and lint
run: bun run check

- name: Typecheck
run: bun run typecheck

- name: Test
run: bun test
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ Optional:
- `PIV_DRY_RUN=1` to avoid Linear/GitHub mutations
- `PIV_DEV_MODE=1` to stream Codex stdout/stderr logs during runs
- `CODEX_SANDBOX` (optional; leave empty to disable sandbox, or set `read-only`, `workspace-write`, `danger-full-access`)
- `CODEX_MODEL_PLAN` (optional; overrides planning model)
- `CODEX_MODEL_IMPLEMENT` (optional; overrides implementation model)
- `CODEX_MODEL_REVIEW_TEST` (optional; overrides review/testing model)
- `CODEX_HOME` to override Codex runtime state directory
- `PIV_LOG_LEVEL` (optional; default `info`)
- `PIV_LOG_PRETTY` (optional; default `1` in TTY, `0` otherwise)
Expand Down Expand Up @@ -107,3 +110,4 @@ bun test

- Run with authenticated `gh` (`gh auth status`).
- Codex uses the default CLI home unless you explicitly set `CODEX_HOME`.
- Linear integration uses the official `@linear/sdk` client.
7 changes: 7 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"typescript": "^5.9.3"
},
"dependencies": {
"@linear/sdk": "^83.0.0",
"pino": "^10.3.1",
"pino-pretty": "^13.1.3"
}
Expand Down
7 changes: 7 additions & 0 deletions piv-loop.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ const config: DeepPartial<PivLoopRootConfig> = {
},
autoCreateLabels: process.env.LINEAR_AUTO_CREATE_LABELS !== "0",
},
codex: {
models: {
plan: "gpt-5.5",
implement: "gpt-5.3-codex",
reviewTest: "gpt-5.3-codex",
},
},
skills: {
plan: path.join(cwd, "skills", "piv-plan", "SKILL.md"),
implement: path.join(cwd, "skills", "piv-implement", "SKILL.md"),
Expand Down
28 changes: 20 additions & 8 deletions src/codex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function buildCodexExecArgs(
config: ResolvedProjectConfig,
prompt: string,
outputFile: string,
modelOverride?: string,
): string[] {
const args = [
"exec",
Expand All @@ -23,8 +24,9 @@ export function buildCodexExecArgs(
"--output-last-message",
outputFile,
];
if (config.codex.model) {
args.push("--model", config.codex.model);
const model = modelOverride ?? config.codex.model;
if (model) {
args.push("--model", model);
}
if (config.codex.sandbox) {
args.push("--sandbox", config.codex.sandbox);
Expand All @@ -38,19 +40,19 @@ export function buildCodexResumeArgs(
sessionId: string,
prompt: string,
outputFile: string,
modelOverride?: string,
): string[] {
const args = [
"exec",
"resume",
"--json",
"--skip-git-repo-check",
"--cd",
config.executionPath,
"--output-last-message",
outputFile,
];
if (config.codex.model) {
args.push("--model", config.codex.model);
const model = modelOverride ?? config.codex.model;
if (model) {
args.push("--model", model);
}
args.push(sessionId, prompt);
return args;
Expand All @@ -60,9 +62,10 @@ export async function runPlanSession(
config: ResolvedProjectConfig,
prompt: string,
): Promise<CodexResult> {
const model = config.codex.models?.plan ?? config.codex.model;
return runCodex(
config,
buildCodexExecArgs(config, prompt, await nextOutputFile(config)),
buildCodexExecArgs(config, prompt, await nextOutputFile(config), model),
);
}

Expand All @@ -71,13 +74,15 @@ export async function runResumeSession(
sessionId: string,
prompt: string,
): Promise<CodexResult> {
const model = config.codex.models?.implement ?? config.codex.model;
return runCodex(
config,
buildCodexResumeArgs(
config,
sessionId,
prompt,
await nextOutputFile(config),
model,
),
);
}
Expand All @@ -86,7 +91,14 @@ export async function runReviewSession(
config: ResolvedProjectConfig,
prompt: string,
): Promise<CodexResult> {
return runPlanSession(config, prompt);
const model =
config.codex.models?.reviewTest ??
config.codex.models?.implement ??
config.codex.model;
return runCodex(
config,
buildCodexExecArgs(config, prompt, await nextOutputFile(config), model),
);
}

async function runCodex(
Expand Down
5 changes: 5 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ function buildEnvBase(cwd: string): ProjectRuntimeConfig {
codex: {
binary: env.CODEX_BINARY ?? "codex",
model: env.CODEX_MODEL,
models: {
plan: env.CODEX_MODEL_PLAN,
implement: env.CODEX_MODEL_IMPLEMENT,
reviewTest: env.CODEX_MODEL_REVIEW_TEST,
},
sandbox,
codexHome,
},
Expand Down
Loading
Loading