- web: Gitea OAuth2 login, signed session cookie, everything behind login; inbox with answers, project board (goals → tasks), task page with OpenSpec artifacts, questions and session controls; new project form; auto-refresh, light/dark, mobile - users + projects.owner_id; tokens AES-256-GCM encrypted; owner-only access - provisionProject (runner): new or existing Gitea repo, peppa-bot collaborator, template + openspec init, push, rollback; used by web and peppa project create (replaces scripts/bootstrap-project.sh) - peppa web login-link, peppa project owner; Gitea OAuth app script - bins/template resolved via PEPPA_ROOT (works inside the Next build) - testkit: mock-gitea + 10 tests (42 e2e total, all green) - OpenSpec: pep-1-web-platform archived into specs web-auth, project-provisioning, web-workspace Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
72 lines
2.4 KiB
TypeScript
72 lines
2.4 KiB
TypeScript
import { dirname, resolve } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import type { Session } from "@peppa/core";
|
|
import { peppaRoot } from "@peppa/shared";
|
|
import { writeRunRules, writeRunSettings } from "./run-settings.ts";
|
|
|
|
export type Provider = Session["provider"];
|
|
export const PROVIDERS: Provider[] = ["claude", "codex"];
|
|
|
|
// PEPPA_ROOT first: inside a Next.js build import.meta.url points into .next/.
|
|
const ROOT = () => peppaRoot(resolve(dirname(fileURLToPath(import.meta.url)), "../../.."));
|
|
const HOOK_BIN = () => `${ROOT()}/packages/runner/bin/peppa-hook`;
|
|
const MCP_BIN = () => `${ROOT()}/packages/mcp/bin/peppa-mcp`;
|
|
|
|
export interface LaunchContext {
|
|
sessionId: number;
|
|
generation: number;
|
|
cwd: string;
|
|
prompt: string;
|
|
rules: string;
|
|
resume?: string;
|
|
permissionMode?: string;
|
|
model?: string;
|
|
}
|
|
|
|
/** argv for one run of the agent CLI (executable first). */
|
|
export function buildCommand(provider: Provider, c: LaunchContext): string[] {
|
|
return provider === "codex" ? codexCommand(c) : claudeCommand(c);
|
|
}
|
|
|
|
function claudeCommand(c: LaunchContext): string[] {
|
|
return [
|
|
process.env.PEPPA_CLAUDE_BIN ?? "claude",
|
|
"--settings",
|
|
writeRunSettings(c.sessionId, c.generation),
|
|
"--append-system-prompt-file",
|
|
writeRunRules(c.sessionId, c.generation, c.rules),
|
|
"--permission-mode",
|
|
c.permissionMode ?? process.env.PEPPA_PERMISSION_MODE ?? "acceptEdits",
|
|
...(c.model ? ["--model", c.model] : []),
|
|
...(c.resume ? ["--resume", c.resume] : []),
|
|
"--",
|
|
c.prompt,
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Codex has no Claude-style hooks: Peppa only learns about completed turns through the
|
|
* `notify` callback, and about crashes, stalls and limits through the watchdog.
|
|
* Permission prompts can't be routed to the PM, so it runs in --full-auto by default.
|
|
*/
|
|
function codexCommand(c: LaunchContext): string[] {
|
|
const toml = (v: unknown) => JSON.stringify(v);
|
|
return [
|
|
process.env.PEPPA_CODEX_BIN ?? "codex",
|
|
"--no-alt-screen",
|
|
"--cd",
|
|
c.cwd,
|
|
...(c.permissionMode ?? process.env.PEPPA_CODEX_MODE ?? "--full-auto").split(" ").filter(Boolean),
|
|
...(c.model ? ["--model", c.model] : []),
|
|
"-c",
|
|
`notify=${toml([HOOK_BIN(), "codex-notify"])}`,
|
|
"-c",
|
|
`developer_instructions=${toml(c.rules)}`,
|
|
"-c",
|
|
`mcp_servers.peppa.command=${toml(MCP_BIN())}`,
|
|
...(c.resume ? ["resume", c.resume] : []),
|
|
"--",
|
|
c.prompt,
|
|
];
|
|
}
|