fakecloud

package
v0.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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).

View Source
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>).

View Source
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

func Amp(p Proc) int

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

func Claude(p Proc) (handled bool, code int)

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

func Codex(p Proc) (handled bool, code int)

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

func DemoCheckout(tb testing.TB) string

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

func Devin(p Proc) int

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

func Gh(p Proc) int

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

func Jules(p Proc) int

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

func Main(p Proc) int

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

func Remote(p Proc) int

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

func Stub() agent.Module

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

func Vendor(name string) func(Proc) int

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

func Work(p Proc, id string, sameBranch bool) error

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

func NewOrigin(dir, url string) (Origin, error)

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) FileURL

func (o Origin) FileURL() string

FileURL is the bare repository as a file URL.

func (Origin) Redirect

func (o Origin) Redirect(configFile string) error

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.

func (Proc) Env

func (p Proc) Env(k string) string

Env returns a variable of the run.

func (Proc) Log

func (p Proc) Log(line string)

Log records a call in $FAKE_AGENT_LOG, one line each.

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.

func (Session) URL

func (s Session) URL() string

URL is the session's page, in its vendor's form.

type Store

type Store struct{ Dir string }

Store is the fake clouds' state: one JSON file per session under dir/sessions.

func Open

func Open(dir string) Store

Open returns the store in dir.

func (Store) Get

func (s Store) Get(id string) (Session, error)

Get reads a session.

func (Store) List

func (s Store) List(cloud string) ([]Session, error)

List returns one cloud's sessions, newest first.

func (Store) Put

func (s Store) Put(x Session) error

Put writes a session.

func (Store) Seed

func (s Store) Seed(x Session) (Session, error)

Seed adds a session as if the cloud had made it (for a test that starts from one): its id is made for its cloud unless given, and its times are now unless given.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL