iii-cloud
v0.2.2Take any project to iii cloud from your harness — sign in, check the cloud plan and run the app here the way the cloud runs it, keep secret values out of the agent's context, merge and deploy pinned to the plan you saw, and follow the deploy to Ready.
Install
iii call compose::add worker=iii-cloudRun in your project with the iii engine running. Exact versions are immutable and digest-pinned.
skill doc
Onboarding a project to iii cloud
Plan first. Before you call anything, tell the person the steps, who does each, and that you only need them for two browser moments: the device approval and the GitHub authorization. Then do each step and say when you are done with it.
Keep the page open beside the chat:
ade::workspace::open {screen: "ext:iii-cloud"}A chat message with the marker iii-cloud hand-off <id8> comes from the page. Call iii-cloud::handoff::brief {handoff_id}, read its kind (ready, deploy_fix, import or pull_request), and continue at the step it names.
1. Connect
Call iii-cloud::status. When connection.status is connected, go on.
Otherwise call iii-cloud::connect {method: "browser"}. The answer has
device.user_code. Tell the person to type it at the cloud's device page. Never
build a link with the code in it. Then wait for the sign-in:
harness::observe {function_id: "iii-cloud::on-change",
filters: {"input.kind": {"$eq": "connection"}, "input.terminal": {"$eq": true}},
lifecycle: {expires_in_ms: 600000}}When it expires, observe again.
With BROWSER_SIGN_IN_UNAVAILABLE, the cloud is too old for browser sign-in.
Offer an API key. The person saves it on the page. Then call
iii-cloud::connect {method: "api_key", secret: "<the secret's name>"}. The
worker finds the team and the environment from the key. A key cannot import a
project or change settings, so tell the person what it cannot do.
2. Resolve the project
Call iii-cloud::project::resolve {path} with the project's folder. Read
project, environment and importable.
- Found: go to step 3.
- Several teams and no match:
teamis null. Ask the person which team. - Not imported,
github_accessfalse: ask the person to connect GitHub to the team in the iii cloud console. This is the GitHub authorization. Resolve again after. (iii-cloud::apionly reads: you cannot start it.) - Not imported,
importableset: the person imports it on the page, choosing the environment name, whether it is production (production deploys by pull request; any other environment gets an assisted deploy), and one of the listedmanifests. Wait for the project to show inproject::resolve: observeiii-cloud::on-changekindprojectwith an expiry, and when it fires or expires callproject::resolveagain; never import it yourself. When several were detected, recommend one with the cloud'ssuggested_environment. Each environment has one manifest; see "Several compose files" iniii-cloud.
3. Use a worktree
Call iii-cloud::project::use {path, environment_id, mode: "worktree"}.
Recommend the worktree. It holds commits only: when the checkout has
uncommitted changes, they stay in the person's folder until they commit them.
Unpushed commits do not come along. Tell the person.
Then move the session:
ade::working-directory::propose {path: "<project.workspace.path>"}Work in that directory from now on. A worktree from an earlier run is reused: it is reset when its commits were merged, and otherwise picks a new branch name.
4. Check, and fix
Call iii-cloud::check. Read plan, here and every problem.
- Ask first (see the profile): each blocking
personproblem and each warning that is not about a variable or secret, in one sentence with your recommendation, in one card, before the first edit. - When the environment's compose file also serves another deploy (a
Dockerfile, a CI workflow, tests), recommend a separate compose file next to
it for iii cloud, left out of the other deploy, and check it with
iii-cloud::check {manifest: "<that file>"}, naming it in every check. Never change the environment's setting: the person's deploy switches it. - Then fix each problem whose
ownerisagent. The fix is iniii-cloud/plan-codes. - Work in groups, quick fixes first and app-code changes last, and call
check {}after each commit. See the "Fix loop" ofiii-cloud. - Check again after each round. The cloud plan stops at its first blocking step, so more problems can show up.
5. Write the cloud: block
Put web, build, release and healthcheck in the production compose
file, so they are versioned with the code. The block needs the iii version iii cloud's engine runs on this machine:
iii 0.26 refuses it. LOCAL_ENGINE_VERSION says when it is the wrong one.
Only iii cloud's plan checks the block's content.
6. The web part
Read plan.web_candidates. Explain each option in one sentence, recommend
one, and let the person choose. Write cloud.web and cloud.healthcheck, then
check again. Every WEB_* code is the person's answer, not yours. Also ask
if the environment is public or team only, and which path is the health path.
7. Secrets
A database URL is not a secret. Follow the "Databases" rule of iii-cloud: add the database worker and bind DATABASE_URL: ${DATABASE_PRIMARY_URL}. Never ask for it (DATABASE_FROM_CLOUD).
Values are the person's, set on the page (Secrets and variables, and its
"values need you" row). Do not ask for them or list them: say in one sentence that the page waits for values. A secret the person types goes to iii cloud and
to the local .env; you only see set, left_empty or failed.
With an API key, secret::provide answers NEEDS_BROWSER_SIGN_IN and the state stays waiting: the person signs in with the browser on the page, or sets the value on iii cloud's website. local: "skipped" means nothing was written to the .env: git tracks it, or the cloud took the value and the compose file does not read ${NAME}; a multi-line value is stored in iii cloud and skips the .env too. Never ask for a value in chat, even when the person offers, and never repeat one.
8. The local run
Call iii-cloud::check {run: true}. It installs, builds, runs the release
command, starts the compose file with the cloud's engine, waits for every
worker and the routes, and calls the healthcheck. It waits for the run itself (up to 240 s). When the call returns with
run.status: "running", wake on that run, never sleep, with an expiry near run_timeout_s:
harness::observe {function_id: "iii-cloud::on-change",
filters: {"input.kind": {"$eq": "run"}, "input.id": {"$eq": "<run id>"},
"input.terminal": {"$eq": true}},
lifecycle: {expires_in_ms: 900000}}On a failed stage, read run.error and run.log_tail, and the code in iii-cloud/plan-codes ("Local run failures"). Fix in the worktree and run again. The run copy moves every engine, http and ade port to a free one, and never uses 3111, 3112, 3113 or 49134. One run per workspace: a run of the same environment and inputs attaches to the going one, and any other answers RUN_BUSY ("A local run (run <id>) is going since HH:MM. Wait for it, or stop it on the page."): wait for it, you cannot stop it.
9. Commit, push, and for production open the pull request
git add <the files you changed> && git commit -m "<message>"
git push --force-with-lease -u origin HEAD
gh pr create --base <environment branch> --head <fix branch> \
--title "<title>" --body "<check.report>
Changes: <one line of what you changed>"Run it from the worktree. The fix branch is worktree.branch of the brief
(project.workspace.branch).
An environment that is not production (pushes_directly in the brief) has no
pull request: it gets an assisted deploy. Push only your fix branch, check and
run, and stop there. The person's deploy on the page sends the checked commit to
the environment's own branch (its first one creates iii-cloud/<env>; the
default branch is never pushed). Never push a branch an environment deploys
from yourself.
A check is ready only when its base commit is in the branch's history, the worktree is clean, and the run's commit equals the check's commit. A run of uncommitted files has a commit ending in +dirty, and it does not count. Commit first, then check and run. Use the report of the ready check as the body. gh uses the person's
own GitHub login. Run iii-cloud::status {refresh: true} to see the pull request.
10. Hand over the deploy
Your job ends when check {run: true} passed on the commit. Tell the person
to review and deploy on the page: the "Merge and deploy…" button for production
(its dialog merges and deploys), "Deploy <commit> to <env>" for any other
environment (an assisted deploy). Only the person deploys, merges, confirms a
waiting deployment, rolls back, or writes variables and settings:
iii-cloud::deploy and iii-cloud::api::write are denied to you, and you
never do it another way (gh pr merge, raw HTTP), even when asked. The merge
is pinned to what you checked: the merged tree must equal the checked commit's
tree, and its first parent must be the base. If the person merges on GitHub
instead, tell them to confirm the waiting deployment on the page ("Confirm
deploy"). When the page reports MAIN_MOVED, PR_HEAD_CHANGED,
SOURCE_CHANGED or PLAN_CHANGED, the plan is old: check again. PUSH_STILL_RUNNING means the
plan changed but iii cloud could not cancel the merged commit's deployment:
watch it.
11. Watch the deployment
harness::observe {function_id: "iii-cloud::on-change",
filters: {"input.kind": {"$eq": "deploy"}, "input.id": {"$eq": "<deploy id>"},
"input.terminal": {"$eq": true}},
lifecycle: {expires_in_ms: 1800000}}When it expires, observe again. Use the id of the person's deployment (status.deploys). When iii-cloud's own confirmed
deployment replaces it, that is not the end. When a deployment iii-cloud did
not create replaces it (a push by someone else), the deployment ends with
outcome: "replaced" and replaced_by: <id>. iii-cloud follows the
successor: tell the person, and observe the new id.
A needs_action event carries the id of the push's deployment, not yours, so
that filter never sees it. Observe it for the environment instead, without the id:
harness::observe {function_id: "iii-cloud::on-change",
filters: {"input.kind": {"$eq": "deploy"}, "input.record.status": {"$eq": "needs_action"}}}When it fires, tell the person to confirm it on the page ("Confirm deploy").
On ready, tell the person the URL and what the local run did not cover. On a
failure, including no_route, read the stage, the code and the log lines in
the event. Fix in the worktree, run check {run: true}, and open a new pull
request. The previous release keeps serving. A rollback is the person's: it is
one click on the iii cloud page, which you can't take for them.