From e744ac46871952d7d0123144bf665e3401ee7d68 Mon Sep 17 00:00:00 2001 From: -Puter <22245429+puterhimself@users.noreply.github.com> Date: Sat, 25 Jul 2026 03:18:23 +0530 Subject: [PATCH] Add Zopu dev bootstrap: git runtimes, Codex agent-os, dev agent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A vertical slice to bootstrap the product loop on the canonical zopu-code repo. Primitives (packages/primitives, all tested + lint/type clean): - GitRemoteRuntime: Gitea REST client (createIssue, createBranch, createPullRequest, listIssues, getIssue) as an Effect context service with a fetch-backed transport. Live-verified against puter/zopu-code. - GitLocalRuntime: clone, addWorktree, commit, push, currentBranch, setRemoteUrl over a pluggable Shell (host subprocess now, AgentOS VM exec later). Tested against real temp git repos. - agent-os: Codex support via @agentos-software/codex-cli — codexSoftware bundle (codex+git), makeCodexAgentOsConfig(), codexSessionEnv() for the OpenAI base URL/key. Env: - GITEA_URL/GITEA_TOKEN wired into convex.ts and convex.config.ts. - .env.example documents the self-hosted git section. Agents (packages/agents): - zopu-dev: development agent that creates issues on the canonical repo and starts autonomous work runs. git-remote tools (create/list/branch/PR) wired to GitRemoteRuntime; start_workflow tool enqueues a work run. - flue run zopu-dev verified live (lists/creates issues on real Gitea). Backend (packages/backend): - workflows.startIssueWork mutation: fetches a Gitea issue server-side and admits a queued work run. The Codex VM spawn body is the next step. --- .env.example | 4 + bun.lock | 1 + packages/agents/package.json | 3 +- packages/agents/src/agents/zopu-dev.ts | 51 +++ packages/agents/src/tools/git-remote.ts | 119 ++++++ packages/agents/src/tools/workflow.ts | 37 ++ packages/backend/convex/convex.config.ts | 2 + packages/backend/convex/workflows.ts | 64 +++ packages/env/src/convex.ts | 2 + packages/primitives/package.json | 7 +- packages/primitives/src/agent-os.test.ts | 25 ++ packages/primitives/src/agent-os.ts | 50 +++ .../primitives/src/git-local-runtime.test.ts | 116 ++++++ packages/primitives/src/git-local-runtime.ts | 268 +++++++++++++ .../primitives/src/git-remote-runtime.test.ts | 124 ++++++ packages/primitives/src/git-remote-runtime.ts | 367 ++++++++++++++++++ packages/primitives/src/index.ts | 2 + 17 files changed, 1239 insertions(+), 3 deletions(-) create mode 100644 packages/agents/src/agents/zopu-dev.ts create mode 100644 packages/agents/src/tools/git-remote.ts create mode 100644 packages/agents/src/tools/workflow.ts create mode 100644 packages/backend/convex/workflows.ts create mode 100644 packages/primitives/src/agent-os.test.ts create mode 100644 packages/primitives/src/git-local-runtime.test.ts create mode 100644 packages/primitives/src/git-local-runtime.ts create mode 100644 packages/primitives/src/git-remote-runtime.test.ts create mode 100644 packages/primitives/src/git-remote-runtime.ts diff --git a/.env.example b/.env.example index 76d0139..94f7e0b 100644 --- a/.env.example +++ b/.env.example @@ -32,3 +32,7 @@ AGENT_MODEL_BASE_URL=https://ai.example.com/v1 AGENT_MODEL_API_KEY=replace-with-provider-api-key AGENT_MODEL_CONTEXT_WINDOW=262000 AGENT_MODEL_MAX_TOKENS=131072 + +# Self-hosted git (Gitea) — canonical repository host and API token +GITEA_URL=https://git.openputer.com +GITEA_TOKEN=replace-with-a-gitea-personal-access-token diff --git a/bun.lock b/bun.lock index 1240940..cff17a7 100644 --- a/bun.lock +++ b/bun.lock @@ -246,6 +246,7 @@ "name": "@code/primitives", "version": "0.0.0", "dependencies": { + "@agentos-software/codex-cli": "0.3.4", "@agentos-software/git": "0.3.3", "@rivet-dev/agentos": "catalog:", "effect": "catalog:", diff --git a/packages/agents/package.json b/packages/agents/package.json index 11ba540..8b3b7fb 100644 --- a/packages/agents/package.json +++ b/packages/agents/package.json @@ -9,7 +9,8 @@ "dev": "bun --env-file=../../.env flue dev", "dev:tailscale": "bun --env-file=../../.env flue dev", "run": "bun --env-file=../../.env flue run", - "run:zopu": "bun --env-file=../../.env flue run zopu" + "run:zopu": "bun --env-file=../../.env flue run zopu", + "run:zopu-dev": "bun --env-file=../../.env flue run zopu-dev" }, "dependencies": { "@agentos-software/opencode": "0.2.7", diff --git a/packages/agents/src/agents/zopu-dev.ts b/packages/agents/src/agents/zopu-dev.ts new file mode 100644 index 0000000..1a75731 --- /dev/null +++ b/packages/agents/src/agents/zopu-dev.ts @@ -0,0 +1,51 @@ +import { parseAgentEnv } from "@code/env/agent"; +import { defineAgent } from "@flue/runtime"; +import { local } from "@flue/runtime/node"; + +import { createGitRemoteTools, makeGitRemoteConfig } from "../tools/git-remote"; +import { createWorkflowTools } from "../tools/workflow"; + +const INSTRUCTIONS = `You are Zopu Dev, the development agent for the canonical zopu-code repository (self-hosted Gitea: puter/zopu-code). + +## Your job + +You talk with the user and turn agreed-upon work into tracked issues, then kick off autonomous implementation. You operate on exactly one repository. + +## Loop + +1. Understand the request. Ask one focused clarifying question only when genuinely ambiguous. Do not create work from casual chat. + +2. Check for duplicates. Call list_issues to see what already exists. + +3. Create the issue. Call create_issue with a clear title and a body that captures the acceptance criteria. Report the issue number and URL back to the user. + +4. Start work only on explicit confirmation. When the user says to start (e.g. "go", "start", "work on it"), call start_workflow with the issue number. This spins up a Codex agent in an isolated worktree that implements, verifies, commits, and opens a pull request. + +5. Report outcomes plainly: "Created issue #N: