Documentation
¶
Overview ¶
Package fakecloud is the stand-in for the vendors' clouds that the tests run against: cloud sessions kept as JSON files in $FAKE_CLOUD_DIR, a local bare repository standing in for the GitHub repository the clouds clone and push, the cloud verbs of the stand-in claude and codex programs (see internal/testkit/fakeagent), a small third-party-style cloud CLI of its own (`fakecloud remote …`, driven by Stub), and `fakecloud work <id>`, which plays the cloud agent. Every call is logged to $FAKE_AGENT_LOG.
The vendors' output shapes come from their docs and source where those say; the rest is marked "unverified" where it is printed. Nothing here talks to a network.
FAKE_CLOUD_FAIL switches on one failure: signed-out, not-eligible, no-env, repo-mismatch, partial, empty, no-branch, archived, push-refused, bad-record (one unreadable record in a listing) or slow (a listing that takes five seconds).
It is test infrastructure, not part of hopsesh.
Index ¶
- Constants
- func Amp(p Proc) int
- func Claude(p Proc) (handled bool, code int)
- func Codex(p Proc) (handled bool, code int)
- func DemoCheckout(tb testing.TB) string
- func Devin(p Proc) int
- func Gh(p Proc) int
- func Jules(p Proc) int
- func Main(p Proc) int
- func Programs(dir string, vars map[string]string) map[string]func(argv []string, o agent.RunOptions) agent.Result
- func Remote(p Proc) int
- func Stub() agent.Module
- func TerminalStep(dir string, vars map[string]string, typed io.Reader) func(agent.Command) agent.StepOutput
- func Vendor(name string) func(Proc) int
- func Work(p Proc, id string, sameBranch bool) error
- type Message
- type Origin
- type Proc
- type Session
- type Store
Constants ¶
const ( ClaudeCloud = "claude-cloud" CodexCloud = "codex-cloud" FakeCloud = "fake-cloud" // the third-party-style cloud of `fakecloud remote` CopilotCloud = "copilot-cloud" // gh agent-task JulesCloud = "jules" // jules remote DevinCloud = "devin" // devin list AmpCloud = "amp" // amp threads )
Clouds the fake plays.
const ( StateRunning = "running" StateIdle = "idle" StateDone = "done" StateFailed = "failed" StateArchived = "archived" )
States, in the fake's own words (each vendor's verbs map them to theirs).
const ( ClaudeVersionLine = "2.1.284 (Claude Code)" CodexVersionLine = "codex-cli 0.153.2" )
The version lines the stand-in claude and codex print for --version: the versions of the agents' newest fixtures (agents/<id>/testdata/<version>).
const ( ExitSignedOut = 4 ExitNotEligible = 5 ExitRepoMismatch = 6 ExitNotFound = 7 )
Exit codes of `fakecloud remote`, so a module can map them without reading words.
Variables ¶
This section is empty.
Functions ¶
func Amp ¶
Amp answers Amp's CLI: --version, threads list (a table: title, last updated, visibility, messages, thread id, as a community SDK parses it; unverified), threads markdown T-… (the thread as Markdown; its layout is unverified) and the help hopsesh reads.
func Claude ¶
Claude answers Claude Code's cloud flags as 2.1.284 does (live probes, 2026-10-04): --cloud with -p is refused ("--cloud cannot be combined with --print"), and --cloud without a terminal too ("--cloud requires an interactive terminal"); in a terminal it asks whether a folder it has not seen is trusted (when FAKE_CLAUDE_TRUSTED names the file of trusted folders), then prints the three lines of a new session and exits. --cloud <id> (attaching) is refused as the docs say. It also answers --teleport <id>, and what hopsesh asks before using them: auth status --json and --help. handled is false for any other call (the stand-in claude answers those itself).
func Codex ¶
Codex answers Codex's cloud commands as codex-cli prints them: codex cloud exec|list|status|diff|apply, codex apply and codex login status. The output shapes and wordings are read from openai/codex (codex-rs/cloud-tasks/src/lib.rs and cli.rs, cloud-tasks-client/src/api.rs and http.rs, cli/src/login.rs) on 2026-10-04; none was seen from a real task, so each is "from source", not verified. handled is false for any other call.
func DemoCheckout ¶
DemoCheckout is a checkout of github.com/example/demo for a module's tests, whose remote is a local bare repository standing in for GitHub (git's global config, which the test points GIT_CONFIG_GLOBAL at, redirects the URL), with main pushed. Git's identity is a made-up one, and FAKE_CLOUD_FAIL is cleared.
func Devin ¶
Devin answers the Devin CLI: version, auth status, list --format json (documented; that it holds cloud sessions, and its fields, are unverified) and --help.
func Gh ¶
Gh answers gh --version, auth status --json hosts, agent-task list|view [--log] and the help hopsesh reads, and pr list|view for the branches of the agents' pull requests.
func Jules ¶
Jules answers Jules Tools: version, remote list --session|--repo (a table, columns split by two or more spaces, as scripts that read it describe; unverified), remote pull --session ID [--apply] (the session's patch; --apply applies it in the folder) and the help hopsesh reads.
func Main ¶
Main is the fakecloud program: `fakecloud work [--same-branch] <id>` plays the cloud agent on a session; `fakecloud remote …` is the fake's own cloud CLI; --version answers.
func Programs ¶
func Programs(dir string, vars map[string]string) map[string]func(argv []string, o agent.RunOptions) agent.Result
Programs are the stand-in claude, codex, gh, jules, devin, amp and fakecloud for agenttest.FakeHost.Programs (and agenttest.RunCloud): they answer --version and the cloud verbs, in this process, with the store in dir. A run's RunOptions.Env (FAKE_CLOUD_FAIL, say) is its environment on top of vars, without its RunOptions.Unset.
func Remote ¶
Remote is the fake's own third-party-style cloud CLI, the shape the cloud-only vendors' CLIs share (a prompt, a repository and a branch up; a branch and the messages down):
fakecloud remote new --repo R --branch B [--title T] PROMPT → the session as JSON fakecloud remote list [--known id,id] → the sessions as JSON fakecloud remote pull ID → the session with its messages fakecloud remote message ID TEXT → the session as JSON fakecloud remote archive ID
func Stub ¶
Stub is a cloud-only module that reaches the fake's own cloud (fake-cloud) through the fakecloud program, with all five cloud capabilities: what a second-wave cloud module looks like. The conformance kit and the core's tests use it; hopsesh never registers it.
func TerminalStep ¶
func TerminalStep(dir string, vars map[string]string, typed io.Reader) func(agent.Command) agent.StepOutput
TerminalStep runs a terminal step (a SendCloud's Sent.Run) with the stand-in claude in this process, as at a terminal 100 columns wide whose user types typed (nil: nothing), with the store in dir: for agenttest.CloudOptions.Step. Like Programs, the command's Env goes on top of vars, without its Unset.
func Vendor ¶
Vendor is the stand-in program for a second-wave vendor CLI by name (gh, jules, devin, amp), logged; nil for any other name.
func Work ¶
Work plays the cloud agent on a session: it clones the session's branch, commits a change, and, as its cloud does, pushes it to a branch of its own (claude/web-session-… for Claude Code, copilot/… and devin/… with a pull request, fake/… for the fake's own cloud; sameBranch pushes back to the branch it started from) or keeps it as the task's diff (Codex, Jules). The session then waits for the user (Claude Code) or is done.
Types ¶
type Message ¶
type Message struct {
Role string `json:"role"` // user | assistant
Text string `json:"text"`
Time time.Time `json:"time"`
}
Message is one turn of a cloud session's conversation.
type Origin ¶
type Origin struct {
Bare string // the bare repository
URL string // the URL it stands in for: https://github.com/example/demo.git
}
Origin is a bare repository standing in for a repository on GitHub.
func NewOrigin ¶
NewOrigin makes a bare repository under dir for url. Its pre-receive hook refuses every push while FAKE_CLOUD_FAIL=push-refused, as branch protection would.
func (Origin) Redirect ¶
Redirect makes git, with this config file (a repository's .git/config, or the file GIT_CONFIG_GLOBAL names), fetch from and push to the bare repository whenever it is asked for the GitHub URL. The remote's configured URL stays the GitHub one, so hopsesh still sees the repository as github.com/owner/repo.
type Proc ¶
type Proc struct {
Args []string
// Vars are variables set for this run; Env falls back to the process's own.
Vars map[string]string
Dir string
Stdin io.Reader // nil: empty
Stdout io.Writer
Stderr io.Writer
// TTY: the run has a terminal (claude --cloud needs one); In is what is typed there
// (nil: nothing), Width its width, Raw puts it in raw mode and returns how to put it back.
TTY bool
In io.Reader
Width int
Raw func() (restore func())
}
Proc is one run of a stand-in program: its arguments (after the program's name), its environment, its folder and its output.
type Session ¶
type Session struct {
ID string `json:"id"`
Cloud string `json:"cloud"`
Title string `json:"title"`
// Repo is the repository's identity (github.com/example/demo); CloneURL is where the
// cloud agent clones it (the remote after url.insteadOf: the bare origin).
Repo string `json:"repo"`
CloneURL string `json:"cloneUrl"`
Branch string `json:"branch"` // the branch it started from
Base string `json:"base"` // the commit it started from
Code string `json:"code"` // how the code came up: branch or bundle
Diff string `json:"diff,omitempty"` // a starting diff sent with it, then the task's diff (codex)
Result string `json:"result,omitempty"` // the branch the cloud pushed its work to
PR int `json:"pr,omitempty"` // the pull request it opened for Result (copilot, devin)
Env string `json:"env,omitempty"`
EnvLabel string `json:"envLabel,omitempty"`
Attempts int `json:"attempts"`
State string `json:"state"`
// Applied: codex apply ran for this task.
Applied bool `json:"applied,omitempty"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
Messages []Message `json:"messages"`
}
Session is one cloud session or task.