Agent-readable docs index: /llms.txt. Full docs in one file: /llms-full.txt. Download /docs.zip to grep all markdown files locally.

Lifecycle reference

This is the legacy repository lifecycle. It applies to projects that haven't saved an Environment revision yet, and to workspaces that still hold cloud resources a cloud/provision script recorded. Once a project saves its first revision, its machine profiles' checks and setup replace checks and machine/prepare, the other phases no longer run, and the revision supplies the browser origins, command environment and signed-caller routes. Service declarations in .gitspace/services.json, signed callers and service tokens apply to every project.
Repository configuration uses .gitspace/bundle.json version 1 and scripts under .gitspace/lifecycle. There is no second lifecycle manifest. For the human approval flow, see Workspace lifecycle.

Bundle

json
{ "version": 1, "defaultProfile": "base", "profiles": { "base": { "checks": ["bun"], "secrets": [], "values": ["APP_MODE"], "notes": "Local development" }, "preview": { "checks": ["github"], "secrets": ["GH_TOKEN"], "values": ["PREVIEW_REPOSITORY"] } }, "checks": { "bun": { "kind": "built-in", "check": "bun" }, "github": { "kind": "command", "label": "GitHub CLI version", "command": "gh --version" } }, "values": { "APP_MODE": { "default": "development", "description": "Application mode" }, "PREVIEW_REPOSITORY": { "description": "Existing GitHub owner/repository to adopt" } }, "terminal": { "path": ["node_modules/.bin", ".gitspace/bin", "~/.cargo/bin"], "env": { "NODE_ENV": "development" } } }
FieldRules
versionMust be 1
defaultProfileExisting profile name; defaults to base
profilesMust include base
Profile checks, secrets, valuesArrays; default to empty. A selected profile adds to base rather than replacing it
Profile notesOptional text, up to 2,000 characters
checksNamed built-in or command checks. Referenced check IDs must exist
valuesNamed non-secret values with optional default and description. Referenced value names must exist
terminalOptional. path and env for agent bash commands, declared services, and workspace terminals. See Terminal environment
Profile and check IDs start with a lowercase letter and contain lowercase letters, digits, or hyphens, up to 64 characters. Value and secret names start with an uppercase letter and contain uppercase letters, digits, or underscores, up to 128 characters. Unknown fields reject.
Built-in checks are bun, gh, git, postgres, vercel, and node. They run bun --version, gh --version, git --version, pg_isready, vercel whoami, and node --version, respectively. A check name is not an installer. Optional built-in requirement text does not enforce a version constraint by itself. Use a command check when you need an exact assertion.
A command check requires kind: "command", a label, and a command. Checks need execution approval too; read their commands before running them.
Values resolve in this order, from lowest to highest priority: bundle default, account value, project value, workspace value. Only values declared by the effective profile enter the lifecycle environment.
Profiles name required secrets; they do not store secret material in the bundle. A project secret takes priority over an account secret of the same name. The account secret needs an explicit project grant that covers the current project space or workspace. Without either source, the requirement remains missing.

Terminal environment

The optional terminal section makes project tools available to the commands that run in a checkout: agent bash commands, services from .gitspace/services.json, and workspace terminals. Lifecycle scripts are unaffected. Once a project has an Environment revision, its Command environment replaces this section, even when the revision declares none.
FieldRules
pathUp to 64 directories. Each entry is checkout-relative, such as node_modules/.bin, or starts with ~/ for the machine user's home. Absolute paths, . or .. segments, empty segments, and : reject. Entries lead PATH in listed order, ahead of the inherited PATH; duplicates keep their first position
envPlain, non-secret string values. Names contain letters, digits, or underscores and do not start with a digit. PATH (use path), GITSPACE_* names, secret-like names, credential-looking values, and names declared in values or as profile secrets reject
With "path": ["node_modules/.bin"], a service can declare "command": "vite", and a bash command can run vite build without npx. Service env entries override terminal.env. Secrets keep using profiles and grants. If bundle.json is missing or invalid, commands still run with no additions.

Script paths and ordering

text
.gitspace/ bundle.json lifecycle/ cloud/ provision/ 10-adopt.preview.sh destroy/ 10-delete.preview.sh machine/ prepare/ 10-tools.sh workspace/ materialize/ 10-dependencies.sh 20-config.preview.sh dematerialize/ 10-flush.sh
The tree above shows allowed locations, not required files. Omit phases that have no work. In particular, do not add a destroy script for a shared resource just to fill out the tree.
Each filename has a numeric prefix, a hyphen, a lowercase name made of letters, digits, or hyphens, an optional .profile suffix, and .sh. Examples: 10-tools.sh, 20-config.preview.sh.
Unqualified scripts and .base.sh scripts run for every profile. A script suffixed with another declared profile runs only when that profile is selected. Unknown profiles and malformed filenames reject. Scripts sort by filename, not by numeric value: use equal-width prefixes such as 10, 20, and 30. Selected-profile scripts add to base scripts; they do not override a base file.
PhaseSuccessful-run identity
cloud/provisionDurable workspace identity. A prior success skips later requests unless the user explicitly requests a rerun, even if the profile or script hashes changed
machine/prepareAccount, project, verified machine, profile, and approved script hashes
workspace/materializeWorkspace checkout generation and phase. Profile or script changes do not repeat a completed phase without an explicit rerun
workspace/dematerializeWorkspace checkout generation and phase. Profile or script changes do not repeat a completed phase without an explicit rerun
cloud/destroyExplicit destruction request for the durable workspace's recorded resources
checks is a run phase for bundle checks, not a script directory. setup, select, remove, and pre are not executable lifecycle aliases.

Approvals and execution

Permission to edit configuration is separate from permission to execute it. The Environment controls approve the SHA-256 hash of a check command or script content at project or workspace scope. A changed command or script needs approval of its new content. Project approval takes precedence when both scopes contain the same hash.
The runtime checks approvals at execution and runs the approved script bytes. It does not treat approval as permission to execute a later file at the same path.
When an agent's run needs approval, the person sees an approval card in the agent's chat. The card shows the script content and offers approval for the project, for this workspace only, or not now. Approving from the card needs the same lifecycle-control authority as approving in Environment.
Approval permits repository code to run as the machine user, with access to that user's home configuration and available credentials. It is not a sandbox. Secret grants control GitSpace-injected secrets, not every credential a script can find on the machine. Hashing an entry script does not pin every helper, package install hook, executable, or remote payload it invokes. Review those dependencies and their effects too. Log redaction does not prevent a script from reading other files or sending data over the network.
When a machine attaches to a workspace, it runs the approved machine/prepare, checks, and workspace/materialize scripts in that order, each step within 30 minutes. A step whose content isn't approved waits for approval. A failure is recorded and leaves the workspace accessible; inspect the step results.
An explicit cloud/provision request runs approved machine/prepare, checks, cloud/provision, and workspace/materialize in that order, including for a local-only repository with no provisioning script. A failure stops later phases. An empty provisioning phase still records successful local-only setup. Creating or selecting a workspace runs nothing.
Cloud claims prevent concurrent effects. A failed or abandoned cloud attempt requires explicit recovery or rerun authorization. Do not turn an uncertain result into a retry loop. The recovery control only abandons a claim when the recorded machine has been confirmed destroyed. Offline or asleep is not proof that its process stopped. Recovery does not execute a new run.
Approval and recovery require a person. The workspace agent cannot grant itself content approval. An agent may run cloud/destroy for its own workspace, non-interactively and with approved content only. It deletes only the resources that workspace recorded as its own. GitSpace refuses an agent's cloud/destroy on the project's base workspace. Every ended cloud/destroy run adds an entry to the workspace journal that names the recorded resources and the outcome.
The cloud Pi runtime owns conversations and durable task records. The machine supervisor runs lifecycle scripts and owns their processes. Runtime recovery does not authorize replay of an unresolved effect; an offline machine is not evidence of process exit.

Interactive scripts

Prefer unattended scripts. Use explicit flags and configured values for ordinary setup questions. Reserve interactive execution for provider authentication or another decision that requires a person.
Declare an interactive script with this exact line in its leading comment header, before any executable command:
bash
#!/bin/bash # gitspace: interactive set -euo pipefail set +x aws configure mfa-login \ --profile staging-source \ --update-profile staging-session \ --duration-seconds 43200
This AWS example assumes the source IAM credentials and MFA device are already configured. The profile names are arbitrary. Set AWS_CONFIG_FILE and AWS_SHARED_CREDENTIALS_FILE to protected, ignored workspace-local paths if credentials should not use the machine's default AWS files. Add the ignore rule before writing credentials.
The declaration is part of the approved script content. Automatic preparation does not opt in: a run without a terminal executes the phase's unmarked scripts and skips each declared interactive script, recording skipped: <script> needs a terminal; run setup from a terminal to execute it in the run output. Skipped scripts are not part of the run's claimed executions. Choose Run in terminal in Environment and confirm the approved effects to execute them. The entire phase then uses a protected terminal, including any unmarked scripts in that phase. An explicit phase request can also set interactive: true; retries with the same run ID must preserve that choice.
The dedicated Environment terminal appears without taking keyboard focus. It lists scripts in execution order and keeps completed steps visible, even when they finish immediately. Execution waits for the first live browser attachment, within the run deadline.
On success or failure, input stops and the terminal keeps its bounded visible output in memory, including the final error. Closing the pane or reloading discards that output. A broken live connection also clears private output; reconnecting restores safe script progress, not earlier terminal text.
Closing the pane leaves a running process running. Reopening or reloading attaches to that same process without replay, so a prompt printed before reconnection may no longer be visible. Use cancellation when you need to stop, rather than rerunning a partially completed phase.
Interactive execution disables input echo and does not retain raw terminal input or output in run logs, Hub output, browser history caches, or terminal replay. It retains step start/end metadata, exit codes, run state, and validated resource bindings. Protected output and input require a browser session; MCP and agent log reads cannot retrieve the raw stream. The terminal ends with the script and never becomes an unrestricted shell.
This is supervised, machine-local authentication for lifecycle tools on Linux or macOS, not inference-provider login or central credential storage. Inference authentication and refresh use the cloud credential vault without a machine prerequisite. Ignored credential files do not travel in checkpoints. Moves and expired sessions can require lifecycle-tool authentication again. Checks remain noninteractive, and detached recovery checkouts cannot run interactive phases. Scripts must not daemonize or leave unmanaged background processes.
Approved scripts still receive their secrets and can intentionally write a .env or provider credential file. Use restrictive permissions and ignored paths. Protected terminal handling is not a sandbox and does not make arbitrary secret output safe.

Retire after the original machine is gone

Attach an authorized online machine to the workspace and select it in Environment before explicitly requesting cloud/destroy. The request requires its machineId; the cloud refuses a missing or unattached machine instead of choosing another runner.
The chosen cache provides the workspace checkout and repository helpers. In Environment, retirement needs a separate confirmation, and API/MCP clients need lifecycle-control authority. Selecting or resuming a cache does not authorize destruction or a cloud provisioning rerun.
A successful cloud/destroy clears the workspace's bindings, including each copy's: the next cloud/provision starts from none. The journal entry of that run keeps the list of what it deleted, and run logs remain available. A failed, cancelled, or interrupted destruction keeps the bindings needed to recover. To run cloud/destroy again after it succeeded, request it with rerun: true; without it the request is skipped.

Script inputs and outputs

The runner supplies these identity variables as strings:
VariableValue
GITSPACE_PROJECT_IDDurable project ID
GITSPACE_WORKSPACE_IDDurable workspace ID; use this for resource identity rather than a machine path
GITSPACE_MACHINE_IDAuthorized runner machine ID
GITSPACE_WORKSPACE_GENERATIONCurrent checkout generation
GITSPACE_ENVIRONMENT_PROFILESelected profile name
GITSPACE_MACHINE_TOOLSPrivate, stable machine tool directory; its bin directory takes precedence over tools on the inherited PATH in lifecycle scripts only. Agent commands, processes, services and terminals get neither the variable nor its bin
GITSPACE_PLATFORMThe machine's operating system: linux or darwin
GITSPACE_ARCHThe machine's architecture: x64 or arm64
GITSPACE_MACHINE_PLATFORMThe two joined, as the machine reports itself: linux-x64, linux-arm64, darwin-x64 or darwin-arm64. Agent commands, processes, services and terminals get the three platform variables too
GITSPACE_SERVICE_URL_<NAME>Workspace URL (https://…) of each http port of each service in .gitspace/services.json. <NAME> is the port's URL name upper-cased, other characters as _: GITSPACE_SERVICE_URL_WEB for service web's first http port, GITSPACE_SERVICE_URL_WEB_ADMIN for its port admin
GITSPACE_SERVICE_URLS_JSONThe same URLs as a JSON object keyed by URL name ({"web":"https://…","web-admin":"https://…"}); {} without declared http ports
GITSPACE_LIFECYCLE_INGRESScloud/provision and workspace/materialize only: where to write ingress.json (see Signed callers)
Services started from .gitspace/services.json receive the same two URL variables, with GITSPACE_SERVICE_NAME, PORT, GITSPACE_PORTS_JSON, and GITSPACE_PORT_<NAME>. A URL is not a secret: only an approved browser or a signed caller gets through it.
GITSPACE_LIFECYCLE_BINDINGS contains a JSON object of durable, non-secret resource bindings. Parse it as JSON; do not source or evaluate it as shell code.
GITSPACE_LIFECYCLE_OUTPUT is a file path supplied by the runner. Write JSON in this form:
json
{ "bindings": { "previewRepository": "example/preview-workspace", "previewRepositoryId": "123456789" } }
The runner observes the output file during execution and merges valid partial bindings into the cloud ledger. It also reads them when the phase finishes, including failure. Write each resource ID as soon as the provider returns it, using a temporary file and an atomic rename over the output path. The input bindings are a phase-start snapshot; later scripts in the same phase must also read the shared output file to see new IDs. Preserve its earlier bindings when adding another resource. A binding the output omits keeps its recorded value; to remove one (a resource the script deleted, or a stale value), write it as null, for example {"bindings": {"sourcePin": null}}. Keep the output file within 64 KiB. A resource created before its ID reaches the cloud still needs provider-side reconciliation after interruption.
Bindings are strings for resource IDs, URLs, or secret:NAME references. They are not a credential store. A secret reference names a secret; it does not turn the binding into the secret's plaintext value. Store it as a project secret or grant an account secret to the project, then declare the required name in the profile.
Binding names start with a letter and contain letters, digits, underscores, periods, or hyphens, up to 128 characters. Values can contain up to 4,096 characters. Credential-like binding names require a secret:NAME reference. Private keys and URLs with embedded credentials reject. These checks catch common mistakes, not every possible secret.
Scripts run on an authorized machine runner, not inside a Cloudflare Worker. They inherit the machine user's HOME, PATH, and ordinary environment. GitSpace prepends GITSPACE_MACHINE_TOOLS/bin to PATH; declared values and granted secrets override inherited values. Internal GITSPACE_* daemon bootstrap variables are excluded, and the runner supplies its own workspace metadata. Git uses the user's normal configuration; unattended runs disable its interactive prompting.
Other workspace commands start from a narrower environment. An agent's commands and the processes it starts get only the machine's PATH, HOME, USER, LOGNAME, SHELL, TMPDIR, TMP, TEMP, LANG, LC_ALL, TERM, TZ and XDG_* directories, GITSPACE_PROJECT_ID, GITSPACE_WORKSPACE_ID, the platform variables, and the project's Environment command path and variables. Services and terminals get the same over the machine's ordinary environment. None of them sees GITSPACE_MACHINE_TOOLS or has its bin on PATH: a tool a script installs there is for later lifecycle scripts.
Supervisor metadata and process descriptions store injected environment names, not their values. The running supervisor holds those values in memory for child starts and restarts. After the supervisor itself restarts, it cannot recover them from metadata or substitute ambient variables. Any surviving execution must stop before a new authorized start supplies fresh values. This does not authorize a lifecycle rerun.
Recovery removes legacy environment values from supervisor metadata. It does not erase old backups or credentials that scripts wrote elsewhere. Rotate credentials if those copies may have been exposed. Scripts must still avoid printing secrets.
Each run keeps its logs and output in a separate temporary directory. Cleanup removes that directory, not the user's home. Use checks to verify existing tool versions and machine/prepare to install missing tools. Inheritance uses the daemon's environment; it does not search for tools outside its PATH or source login dotfiles. A cloud machine uses its own home, not a copy of your personal machine.
Lifecycle .sh files execute their approved bytes with /bin/bash, without login startup files. Command checks use /bin/sh. The working directory is the checkout root; $0 is the script's path in that checkout. Use $0, not BASH_SOURCE, when locating helpers beside an entry script.
A cloud provisioning success remains separate from individual run attempts. A failed explicit rerun retains the last successful provision and any partial bindings. Closing or evicting the local checkout does not remove those records.

Signed callers

A workspace URL normally admits only a browser you approved: other requests are redirected to sign-in, and requests from other origins are refused. To let a webhook sender or another service call specific routes, declare them and register a credential from a lifecycle script. Signed callers apply to workspace URLs (<service>--<workspace>--<account>-srv) only; machine URLs never admit them.
A project with an Environment revision declares its routes there, one per line, and .gitspace/services.json routes are no longer read. A project without one declares them in .gitspace/services.json.
Each service may list up to 64 routes in ingress:
json
{ "services": [{ "name": "api", "command": "bun", "args": ["run", "start"], "ports": [{ "name": "http" }, { "name": "admin" }], "ingress": [ { "method": "POST", "path": "/webhooks/*" }, { "method": "GET", "path": "/status", "port": "admin" } ] }] }
FieldRules
methodGET, POST, PUT, PATCH, DELETE, or * for any method. A WebSocket upgrade is a GET
pathAn exact path (/status) or a prefix ending in /* (/webhooks/* matches /webhooks/ and every path below it, not /webhooks; /* matches every path). No .., ., empty segments, other wildcards, query, or /__gitspace paths
portAn http port of the service; defaults to its first. Each port is its own workspace URL
tokenstrue also admits the service's GitSpace-signed tokens on the route
The routes of every service form one Signed callers entry in Environment, approved by the SHA-256 of their canonical content like a script. Reordering routes keeps the approval; any other change needs a new one. The entry never runs. Until it is approved, nothing is registered.
A request whose method and path match a declared route never redirects: without a valid credential it is a 401 with {"error":"INGRESS_UNAUTHORIZED","reason":"…"}. A valid credential's header is removed and everything else (body, headers, query, WebSocket upgrades) reaches the service unchanged. Other paths on the same URL keep the browser sign-in.

Registering credentials

Only an approved cloud/provision or workspace/materialize script registers credentials, by writing JSON to the path in GITSPACE_LIFECYCLE_INGRESS (ingress.json in the run's output directory):
json
{ "credentials": [ { "kind": "oidc", "service": "api", "issuer": "https://broker.example.com", "subjects": ["webhooks/stripe", "webhooks/*"] }, { "kind": "jwt", "service": "api", "port": "admin", "issuer": "status-poller", "keys": { "keys": [{ "kty": "OKP", "crv": "Ed25519", "x": "…" }] }, "subjects": ["poller"] }, { "kind": "bearer", "service": "api", "secret": "STRIPE_FORWARD_TOKEN" } ] }
After the phase's scripts succeed, the machine checks the file (at most 64 KiB; each credential names a service and http port with declared routes; the routes are approved) and replaces the workspace's registrations with it. A phase that writes no file leaves the credentials unchanged; when an approved route sets tokens: true, it still registers the routes. An invalid file or unapproved routes fail the run. GitSpace keeps registrations with the workspace URL, apart from the machine serving it, and ends them when the workspace is archived or deleted. Agents cannot register: the account accepts a registration only from the machine running that approved phase, for approved routes.
KindChecked
oidcA JWT signed by the issuer's keys. GitSpace reads <issuer>/.well-known/openid-configuration (its issuer must equal the registered one) and its jwks_uri, over HTTPS on a public DNS name (no IP addresses, localhost, or GitSpace hosts), within 5 seconds and 64 KiB, cached about 10 minutes and refetched for an unknown kid at most every 30 seconds
jwtThe same JWT checks with the public keys given in keys (a JWKS; private key members reject)
bearerA static token equal to the named secret, which must be one of the profile's secrets. Only its SHA-256 leaves the machine. Rotating the secret and running the phase again keeps the previous token valid too, until the next rotation
A JWT must use EdDSA, ES256, or RS256 and carry iss equal to the issuer, aud equal to the workspace URL (https://<service>--<workspace>--<account>-srv.gssh.dev), exp, iat at most 5 minutes old, and a sub matching one of subjects (* matches any characters). When present, htm must equal the request method and htu the request URL without query.
The caller sends the token as Authorization: Bearer <token> or GitSpace-Ingress: <token>. Set "forwardAuthorization": true on an oidc or jwt credential when the service checks its own Authorization header; the caller then uses GitSpace-Ingress, and Authorization reaches the service. GitSpace counts admissions and refusals per workspace URL and keeps the last refusal's reason.

Service tokens

For apps that cannot use the browser sign-in (a dev phone build, a simulator app, a script), GitSpace signs the tokens itself: set "tokens": true on the routes they may call. Once those routes are approved and a cloud/provision or workspace/materialize run registers them, GitSpace keeps a P-256 signing key for the workspace and service. The private key never leaves GitSpace's credential vault; a key signs for 7 days and the tokens it signed stay valid 8 hours more. Scripts' credentials never replace it.
Get a token from the agent's environment tool (token), from gitspace service token <service> --sub <subject> [--ttl 30m] [--refresh] [--port <name>] in a workspace terminal or agent command (prints JSON), or from Copy app token in Environment (with a QR code). A token is an ES256 JWT whose sub names the caller, valid 8 hours unless a shorter ttl is given. Send it as GitSpace-Ingress: <token>; the app's own Authorization reaches the service. It is accepted only on routes that set tokens: true, and refused once it expires, once it is revoked, or once its key is rotated out (Environment's Rotate now ends every earlier key at once).
With a refresh token (7 days), an app gets a new pair before the access token expires:
sh
curl -X POST https://api--<workspace>--<account>-srv.gssh.dev/__gitspace/token \ -H 'content-type: application/json' -d '{"refresh_token":"…"}' # {"access_token":"…","token_type":"Bearer","expires_in":28800,"refresh_token":"…"}
Each refresh token works once. Presenting one that was already used revokes every token issued from it (the app must get a new token), and an invalid one answers 400 {"error":"invalid_grant"}. Environment lists the tokens issued for each service with their subject, expiry and last use; Revoke ends a token and its refresh chain.

Agent API and durable logs

Use the typed environment tool directly:
json
{ "args": { "method": "get" } }
Available methods are get, setProfile, putValue, deleteValue, runChecks, runPhase, cancelRun, runLog, and token. Arguments go inside args; all operations target the current workspace. A run request supplies runId, optional deadlineAt, and a phase for runPhase. A log request supplies runId and optional offset. A token request supplies service, subject, and optional port, ttlSeconds, and refresh (see Service tokens). Agent calls cannot request protected interactive execution.
An authorized phase request names one of the five canonical phases and can set rerun: true only for an explicitly authorized rerun. The agent surface runs noninteractively only, and refuses cloud/destroy on the project's base workspace. Content approval governs the runs GitSpace starts; an agent asked by the user to set up a workspace may run its scripts directly with bash.
The browser and MCP RPC contracts are separate from the agent tool: environment.runChecks({ spaceId, machineId, runId }) and environment.runPhase({ spaceId, machineId, runId, phase, rerun }) require an explicit attached machine ID. They accept the request in the cloud and dispatch only to the named ready or resumable cache. Keep the same machine ID and inputs when reconciling an existing run ID; attach a machine before requesting execution if none is available.
The environment view includes lifecycle, the cloud-owned record of profile, values, approvals, automatic policy, execution definitions and content, bindings, last successful provision, destruction time, and phase runs. Saved script content lets the human inspect what a closed workspace would execute; do not embed secrets in it. Run status is accepted, running, cancelling, succeeded, failed, cancelled, timed-out, or interrupted. The run stores its machine, profile, hashes, interaction mode, timestamps, results, and safe output preview.
Each script result has its own exitCode: zero means success, a nonzero value means failure, and null means no exit was recorded. A started script with no exit is running while the phase is active and interrupted after the phase ends. A script with no result has not started. Available startedAt and finishedAt timestamps describe that script, not the whole phase.
For unattended runs, full output lives in durable cloud log chunks, not in an artifact file inside the checkout. Interactive runs retain safe step metadata instead of raw terminal output. The environment tool's runLog method accepts runId and optional offset. It returns output, nextOffset, and cursor. Follow nextOffset while more stored chunks are available. A null nextOffset means caught up for now, not necessarily that a running script has finished; retain cursor, the first unread stored row, and use it as the next request's offset after a run update. Read subsequent chunks rather than treating the preview as the full log.
Closed or offline workspaces retain cloud lifecycle records and logs. Running scripts still requires an authorized online machine. These are account-private records, not public artifact links. The runner redacts known resolved secret values and the cloud applies further sanitization, but redaction is not a guarantee that arbitrary output contains no secrets. Never print credentials or enable shell tracing around them.
The runner also keeps a private, sanitized local spool until upload finishes. After an interrupted run is confirmed stopped, recovery uploads that spool before recording failure. Recovered output is labeled and may repeat lines that reached the cloud before the interruption.

Local-only example

This example assumes the machine already has Bun and the repository has a committed Bun lockfile. It does not create cloud resources or install machine-wide tools.
.gitspace/bundle.json:
json
{ "version": 1, "defaultProfile": "base", "profiles": { "base": { "checks": ["bun"] } }, "checks": { "bun": { "kind": "built-in", "check": "bun" } } }
.gitspace/lifecycle/workspace/materialize/10-dependencies.sh:
bash
#!/usr/bin/env bash set -euo pipefail bun install --frozen-lockfile
Review package install hooks before approving this script. If the repository needs a specific Bun version, add an explicit version assertion or an approved machine/prepare script based on its existing CI installation method.
Approve the check and script content, then explicitly initialize setup. No empty cloud hook is needed. On a fresh arrival, materialization recreates ignored dependencies. Close and move do not need a destroy script.

Cloud example: adopt an existing GitHub repository

Use this for a repository that already exists and may be shared. It performs a real provider lookup, records stable identity, and refuses an identity mismatch. It does not create, replace, or delete the repository.
Start from the local-only bundle above. Add a preview profile that names GH_TOKEN in secrets and PREVIEW_REPOSITORY in values. Add the value definition under top-level values:
json
{ "version": 1, "defaultProfile": "preview", "profiles": { "base": { "checks": ["bun"] }, "preview": { "secrets": ["GH_TOKEN"], "values": ["PREVIEW_REPOSITORY"] } }, "checks": { "bun": { "kind": "built-in", "check": "bun" } }, "values": { "PREVIEW_REPOSITORY": { "description": "Existing GitHub owner/repository" } } }
Set PREVIEW_REPOSITORY to the existing owner/repository in Environment. Store a GitHub token with access to read that repository as the project secret GH_TOKEN. Do not paste the token into a value, binding, or script.
.gitspace/lifecycle/cloud/provision/10-adopt.preview.sh:
bash
#!/usr/bin/env bash set -euo pipefail bun - <<'JS' import { rename } from 'node:fs/promises'; const output = process.env.GITSPACE_LIFECYCLE_OUTPUT; const token = process.env.GH_TOKEN; if (!token || !output) throw new Error('Run through the approved lifecycle runner'); const previous = await Bun.file(output).json(); const bindings = { ...JSON.parse(process.env.GITSPACE_LIFECYCLE_BINDINGS || '{}'), ...previous.bindings, }; const configured = process.env.PREVIEW_REPOSITORY; const repository = bindings.previewRepository || configured; if (!repository || !/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repository)) { throw new Error('Set PREVIEW_REPOSITORY to an existing owner/repository'); } if (bindings.previewRepository && configured && configured !== repository) { throw new Error('Configured repository differs from the recorded binding'); } const response = await fetch(`https://api.github.com/repos/${repository}`, { headers: { Accept: 'application/vnd.github+json', Authorization: `Bearer ${token}`, 'X-GitHub-Api-Version': '2022-11-28', 'User-Agent': 'gitspace-workspace-lifecycle', }, }); if (!response.ok) throw new Error(`Repository lookup failed: HTTP ${response.status}`); const resource = await response.json(); if (!Number.isSafeInteger(resource.id) || typeof resource.full_name !== 'string') { throw new Error('GitHub returned an invalid repository identity'); } if (bindings.previewRepositoryId && bindings.previewRepositoryId !== String(resource.id)) { throw new Error('Repository identity changed; inspect before recovery'); } const pendingOutput = `${output}.${crypto.randomUUID()}.tmp`; await Bun.write(pendingOutput, JSON.stringify({ bindings: { ...bindings, previewRepository: resource.full_name, previewRepositoryId: String(resource.id), }, })); await rename(pendingOutput, output); console.log(`Adopted repository ${resource.full_name} (${resource.id})`); JS
Keep the local materialization script from the previous example. Select preview, approve the final script content, and separately authorize setup. Later materialization reads the saved bindings rather than adopting or creating resources again.
There is intentionally no cloud/destroy script here. Adoption records a resource reference, not permission to delete a shared resource. For a dedicated workspace-owned resource, write a separately reviewed destroy script that verifies the provider resource ID against the recorded binding and deletes only that resource. Never search by a broad name prefix and delete every match. Content approval of a destroy script lets the workspace's agent run it, so approve it only for resources the workspace owns.