diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5683fc109..1b7cd318c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -163,6 +163,7 @@ jobs: if: matrix.part == 2 run: | python3 -I tools/install/test_install.py + python3 -I tools/install/test_phrase.py python3 -I tools/install/test_pull.py python3 -I tools/install/tests/public-release-security/baseline/test_baseline.py python3 -I tools/install/tests/public-release-security/test_candidate.py diff --git a/AGENTS.md b/AGENTS.md index 5fee40212..80faec940 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -8,6 +8,43 @@ OpenWiz runs coding agents in fleets: the user approves a plan, and agents build - Once per clone, `git config core.hooksPath .githooks`: the pre-push hook runs the privacy check. - The skills read the project's settings in [`docs/agents/`](docs/agents/). Change a skill in WizSkills and move the `wizskills.lock` pin, never here. +## Install OpenWiz + +The install instruction is exactly this phrase: + +> Install OpenWiz + +A person says that to their coding agent (Claude Code, Codex, Cursor or another). That phrase is enough to start. Ask only where your agents run, and for a yes before each change the install shows. The repository is https://github.com/openwizdev/OpenWiz. You need Python 3.9 or later, `git` and `gh`. + +1. Resolve the release: + +```sh +curl -sS --proto '=https' -o /dev/null -w '%{redirect_url}\n' https://github.com/openwizdev/OpenWiz/releases/latest +``` + +The printed URL ends in `/tag/`. `` is `` without the leading `v`. With no `/tag/` in the URL, GitHub has no Latest release: stop and say so. Use `` only when the whole value matches `v(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)`. Use `` only when the whole value matches `[0-9a-f]{40}`. Any other value stops the install, including one that starts with `-`. + +2. Read that release's install skill and follow it from the top in this session. Run the commands yourself. + - `0.1.0`: the skill is https://github.com/openwizdev/WizSkills/blob/33eef93ba30cd8db256f6fe270e3ed28747a79bd/skills/install/SKILL.md and the command reference is [the 0.1.0 steps](docs/install.md#openwiz-010). Clone tag `v0.1.0`. This release's skill is that commit, not the `commit` in that tag's `wizskills.lock`. When the skill URL cannot be read directly, recover the pinned skill by commit into a new private temporary directory (`wizskills=$(mktemp -d)`): + +```sh +wizskills=$(mktemp -d) +git init -q -- "$wizskills" +git -C "$wizskills" fetch -q --depth 1 -- https://github.com/openwizdev/WizSkills 33eef93ba30cd8db256f6fe270e3ed28747a79bd +git -C "$wizskills" switch -q --detach FETCH_HEAD +``` + + Verify `git -C "$wizskills" rev-parse HEAD` equals `33eef93ba30cd8db256f6fe270e3ed28747a79bd` and `git -C "$wizskills" rev-parse HEAD:skills/install` equals `30d1eaf27658efd8f781f98703fbbdb81bcd705d`, then follow `"$wizskills"/skills/install/SKILL.md` and [the 0.1.0 steps](docs/install.md#openwiz-010). If that fetch fails or either hash mismatches, stop and say so: never proceed to a restart on the 0.1.0 archive's packaged `install` skill (`version: 0.2.0`, which tells a restarted agent to run `install open`). + - Any other ``, including `v0.1.1`: set `$openwiz` to a new private temporary directory (`openwiz=$(mktemp -d)`), then clone that tag: + +```sh +git clone --depth 1 --branch "$tag" -- https://github.com/openwizdev/OpenWiz "$openwiz" +``` + + Read `wizskills.lock` in that clone. The skill is `https://github.com/openwizdev/WizSkills/blob//skills/install/SKILL.md`, where `` is the lock's `commit`. The lock's `version` is that WizSkills release. The command reference is `docs/install.md` in the clone. When the skill cannot be read, follow that file and run each command yourself. The clone is already at ``. When the clone has no `wizskills.lock`, or the lock has no `commit`, stop and say so. The numbered steps in that guide expect build identity `0.1.1`. When `` is not `0.1.1`, stop unless that guide expects ``. Check that selected `` before downloading or activating anything, pass `--version "$tag"` to `install download` so it fetches `` rather than GitHub's Latest release, and verify `download`'s reported `"version"` matches `` before running `install install` to activate it. + +CloudRoom is optional. Its install and sign-in run only when the person picks CloudRoom. + ## Public and private Everything on this repository is public; private records live in `jparker2006/ClosedWiz`. Before any public write, read the [public-writes card](docs/agents/public-writes.md); `python3 -I skills/launch-fleet/scripts/context.py ` prints it with your role's settings. Release, publishing, privacy-check and importer work also needs the full [open development contract](contracts/open-development.v1.md). diff --git a/README.md b/README.md index 2761d5bbe..90ca535ab 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,15 @@ You make the decisions: answer a few questions. The agents run the factory: they ## Quick start -You need Python 3.9 or later, `git`, and the GitHub CLI (`gh`). Then paste this line into your coding agent (Claude Code, Codex or another): +Tell your coding agent (Claude Code, Codex, Cursor or another): -> Install OpenWiz from github.com/openwizdev/OpenWiz +> Install OpenWiz -Your agent follows 0.1.0's [install skill](https://github.com/openwizdev/WizSkills/blob/33eef93ba30cd8db256f6fe270e3ed28747a79bd/skills/install/SKILL.md) (WizSkills `maint/0.2`). First it asks where your agents run: **this computer**, with the Claude Code or Codex you're signed in to; **boat.dev**; or **[CloudRoom](https://cloudroom.dev)**. CloudRoom is optional: the install never needs it, and its install and sign-in run only if you pick it. In 0.1.0 the automatic fleet runs in CloudRoom; without CloudRoom you plan, start each builder by hand on this computer or on boat.dev, and review its pull request yourself. +That phrase is the whole install instruction. The agent follows [Install OpenWiz](AGENTS.md#install-openwiz): it reads GitHub's Latest release and that release's install skill, then runs the install. Any release other than 0.1.0 is cloned only when the whole value of `` matches `v(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)`, using `git clone --depth 1 --branch "$tag" -- https://github.com/openwizdev/OpenWiz "$openwiz"`, and follows the `commit` in that clone's `wizskills.lock`. You need Python 3.9 or later, `git`, and the GitHub CLI (`gh`). It asks where your agents run: **this computer**, with the Claude Code or Codex you're signed in to; **boat.dev**; or **[CloudRoom](https://cloudroom.dev)**. CloudRoom is optional: the install never needs it, and its install and sign-in run only if you pick it. It checks your computer, installs the verified prebuilt release (no Rust or Node), puts OpenWiz's skills into your agents, and checks each connection. Nothing starts until you approve a plan. OpenWiz is free. Your model and host charges are your own. -It checks your computer, installs the verified prebuilt 0.1.0 release (no Rust or Node), puts OpenWiz's skills into your agents, and checks each connection. Nothing starts until you approve a plan. People: see the [install guide's 0.1.0 steps](docs/install.md#openwiz-010) for every step and command. OpenWiz is free. Your model and host charges are your own. +### OpenWiz 0.1.0 + +OpenWiz 0.1.0 ("OpenWiz 0.01") is the current release. Its commands are the [install guide's 0.1.0 steps](docs/install.md#openwiz-010). In 0.1.0 the automatic fleet runs in CloudRoom; without CloudRoom you plan, start each builder by hand on this computer or on boat.dev, and review its pull request yourself. ### OpenWiz 0.1.1 diff --git a/docs/evidence/2227/README.md b/docs/evidence/2227/README.md index 9f732998e..f10130c52 100644 --- a/docs/evidence/2227/README.md +++ b/docs/evidence/2227/README.md @@ -12,7 +12,7 @@ It reads `README.md` and `docs/install.md` and prints one line per failure: 2. **CloudRoom's install is conditional:** every line that runs `cloudroom.py install` says "only if you pick" CloudRoom, and no "Before you start" bullet lists CloudRoom without saying it is optional. 3. **The three hosts, this computer first:** each file has a line that names this computer, boat.dev and CloudRoom in that order and says "CloudRoom is optional". 4. **0.1.0 and 0.1.1 told apart:** each file has a sentence saying that on 0.1.0 the automatic fleet runs in CloudRoom, and one saying 0.1.1 runs it on this computer. -5. **The 0.1.1 path is the default (review R1):** each file has a section headed with 0.1.0; outside it, no `maint/0.2` link and a link to the install skill at WizSkills `v0.4.0`. The guide clones `v0.1.1`, expects build identity `0.1.1`, and has no `maint/0.2` overwrite step outside the 0.1.0 section. +5. **The release path (review R1):** each file has a section headed with 0.1.0; outside it, no `maint/0.2` link. README and the install guide both derive the skill from `wizskills.lock` and clone with `--branch "$tag" --` before the repository only after the whole tag matches `v` and three numeric parts with no leading zeros. Both refuse a hardcoded WizSkills `v0.4.0` pin and a `--branch v0.1.1` clone. The guide expects build identity `0.1.1` and has no `maint/0.2` overwrite step outside the 0.1.0 section. 6. **Intel Mac (R2):** no line says an Intel Mac installs only from 0.1.1. 7. **The heartbeat (R3):** nothing says it "wakes the fleet every ten minutes"; the guide says it checks every ten minutes and wakes only when work is due, that boat.dev fleets use it too, lists `jq`, and says a same-family review is marked. 8. **Removal (R4):** the guide's "Remove it" names `heartbeat.py pause`, `heartbeat.py remove` and `install remove`, and nothing says there is no remove command. diff --git a/docs/evidence/2227/check_docs.py b/docs/evidence/2227/check_docs.py index 257fb78c2..60f9141fe 100644 --- a/docs/evidence/2227/check_docs.py +++ b/docs/evidence/2227/check_docs.py @@ -68,8 +68,17 @@ def release_path(name, text): failures.append(f'{name}: no clearly marked 0.1.0 section (a heading naming 0.1.0)') if 'blob/maint/0.2/' in default: failures.append(f'{name}: the default path links the 0.1.0 maintenance skill (maint/0.2)') - if 'WizSkills/blob/v0.4.0/skills/install/SKILL.md' not in default: - failures.append(f'{name}: the default path does not link the 0.1.1 install skill at WizSkills v0.4.0') + if name in ('README.md', 'docs/install.md'): + if 'WizSkills/blob/v0.4.0/' in text or 'WizSkills 0.4.0' in text: + failures.append(f'{name}: pins WizSkills 0.4.0') + if '--branch v0.1.1' in text: + failures.append(f'{name}: clones the fixed v0.1.1 tag') + if 'wizskills.lock' not in default: + failures.append(f'{name}: the default path does not derive the skill from wizskills.lock') + if 'git clone --depth 1 --branch "$tag" -- https://github.com/openwizdev/OpenWiz' not in default: + failures.append(f'{name}: the default path does not clone the release tag with -- before the repository') + if 'v(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)' not in default: + failures.append(f'{name}: the default path does not check the whole tag against a strict pattern') if re.search(r'Intel Mac[^.]*from 0\.1\.1', text): failures.append(f'{name}: says an Intel Mac installs only from 0.1.1') if re.search(r'(?i)wakes the fleet every ten minutes', text): @@ -79,8 +88,6 @@ def release_path(name, text): if name == 'docs/install.md': if "'^version: 0.2.2$'" in default or '--branch maint/0.2' in default: failures.append(f'{name}: the default path still overwrites the install skill with maint/0.2') - if '--branch v0.1.1' not in default: - failures.append(f'{name}: preflight does not clone the v0.1.1 tag') if 'prints the version (`0.1.1`)' not in default: failures.append(f'{name}: the build identity check does not expect 0.1.1') flat = ' '.join(text.split()) diff --git a/docs/first-hour.md b/docs/first-hour.md index dee7643da..2fda6bc9f 100644 --- a/docs/first-hour.md +++ b/docs/first-hour.md @@ -12,8 +12,13 @@ Open `http://127.0.0.1:7370/#first-hour`. On a computer, **First hour** is also in the sidebar. On a phone, search for "Go to First hour". The page shows six steps, and each step shows only what OpenWiz has actually read: -1. **Install OpenWiz.** Paste the one install line into your coding agent; see - [Install OpenWiz](install.md). +1. **Install OpenWiz.** Tell your coding agent: + + > Install OpenWiz + + That phrase is the whole install instruction. The agent follows + [Install OpenWiz](../AGENTS.md#install-openwiz). Today's commands are the + [0.1.0 steps](install.md#openwiz-010). 2. **Connect your accounts.** **Open setup** goes to the setup page. Each connection is checked on its own, and CloudRoom's one sign-in screen is on the CloudRoom step. Setup checks your agent harness login. It does not check diff --git a/docs/grok-bot.md b/docs/grok-bot.md index 61436c108..bb3efbdd1 100644 --- a/docs/grok-bot.md +++ b/docs/grok-bot.md @@ -37,11 +37,11 @@ Every sign-in and connection below is your own click. OpenWiz never touches a lo ## Run a first fleet -Today a fleet starts from your computer, not from Grok Bot. In Claude Code or Codex, paste: +Today a fleet starts from your computer, not from Grok Bot. In Claude Code, Codex or Cursor, say: -> Install OpenWiz from github.com/openwizdev/OpenWiz +> Install OpenWiz -Then follow [Install OpenWiz](install.md) and [Your first hour](first-hour.md). The fleet runs on CloudRoom. Your Bot may be able to follow it through the same GitHub issues and pull requests, for example "Use where-are-we on my repository". Untested. +That phrase is the whole install instruction. The agent follows [Install OpenWiz](../AGENTS.md#install-openwiz). Today's commands are the [0.1.0 steps](install.md#openwiz-010), then [Your first hour](first-hour.md). The fleet runs on CloudRoom. Your Bot may be able to follow it through the same GitHub issues and pull requests, for example "Use where-are-we on my repository". Untested. ## What works today, in 0.1.1 and later diff --git a/docs/install.md b/docs/install.md index 2b341a885..2f224612d 100644 --- a/docs/install.md +++ b/docs/install.md @@ -1,10 +1,10 @@ # Install OpenWiz -Paste this one line into the coding agent you already use (Claude Code, Codex or another): +Tell your coding agent (Claude Code, Codex, Cursor or another): -> Install OpenWiz from github.com/openwizdev/OpenWiz +> Install OpenWiz -The agent follows the [install skill](https://github.com/openwizdev/WizSkills/blob/v0.4.0/skills/install/SKILL.md). This page says what it does, the commands it runs, what it may change, and how to recover or remove it. +That phrase is the whole install instruction. The agent follows [Install OpenWiz](../AGENTS.md#install-openwiz). The numbered steps below are the command reference for OpenWiz 0.1.1. `` in them is `v0.1.1`. They are not the steps for 0.1.0, and not the steps for a later release. This page says what that install does, the commands it runs, what it may change, and how to recover or remove it. Using Grok Bot? See [Grok Bot + OpenWiz](grok-bot.md). @@ -12,7 +12,7 @@ Using Grok Bot? See [Grok Bot + OpenWiz](grok-bot.md). ## Before you start -- **A supported computer:** macOS on Apple silicon or Intel, or Linux on x86_64 with glibc 2.34 or later (`ldd --version` shows it). Linux on ARM is not supported. **An Intel Mac installs with no CloudRoom,** on 0.1.1 and on 0.1.0 alike: preflight reads it ready. CloudRoom has no Intel Mac build, so on an Intel Mac, agents run on this computer or on boat.dev. On Linux older than glibc 2.39, `openwiz` may print a `GLIBC_2.39` warning and still work. +- **A supported computer:** macOS on Apple silicon or Intel, or Linux on x86_64 or ARM64 (aarch64) with glibc 2.34 or later (`ldd --version` shows it). **An Intel Mac installs with no CloudRoom,** on 0.1.1 and on 0.1.0 alike: preflight reads it ready. CloudRoom has no Intel Mac build and no ARM64 Linux build, so on an Intel Mac or on ARM64 Linux, agents run on this computer or on boat.dev. On x86_64 Linux older than glibc 2.39, `openwiz` may print a `GLIBC_2.39` warning and still work. On ARM64 Linux the package has to be built for glibc 2.34; a hard `GLIBC_2.39` requirement does not start. - **Python 3.9 or later, `git`, and the GitHub CLI** (`gh`, signed in with `gh auth login`). - **Where your agents run,** asked first, before anything else: this computer, boat.dev or CloudRoom. CloudRoom is optional: only the CloudRoom choice needs it installed. - **This computer:** the Claude Code or Codex you're signed in to, and your `gh` login. Nothing else to sign in to. @@ -24,20 +24,25 @@ Using Grok Bot? See [Grok Bot + OpenWiz](grok-bot.md). The agent runs each command itself and reads its JSON. `` is the install folder, by default `~/.local/lib/openwiz`: use a new or empty folder that holds nothing else, because the installer also accepts a folder that already has other files in it. If you give `install install` a separate `--state-root`, it too must be a new or empty folder used by OpenWiz alone, never one shared with another app. `` is `aarch64-apple-darwin`, `x86_64-apple-darwin`, `x86_64-unknown-linux-gnu` or `aarch64-unknown-linux-gnu`. -1. **Preflight.** It clones this repository at the `v0.1.1` tag into a private temporary folder as `$openwiz` (`git clone --depth 1 --branch v0.1.1 https://github.com/openwizdev/OpenWiz "$openwiz"`) and checks this computer: Python, a supported system, free disk space, and whether `room-cli`, `gh` and `git` are installed. It reads only; anything missing comes with its next step. A missing `room-cli` never stops it: it says CloudRoom is optional, needed only if you pick it. On an Intel Mac it reads ready and notes that agents run on this computer or on boat.dev. +1. **Preflight.** It clones this repository at `` into a private temporary folder as `$openwiz` (`git clone --depth 1 --branch "$tag" -- https://github.com/openwizdev/OpenWiz "$openwiz"`, and only after the whole value of `` matches `v(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)`) and checks this computer: Python, a supported system, free disk space, and whether `room-cli`, `gh` and `git` are installed. It reads only; anything missing comes with its next step. A missing `room-cli` never stops it: it says CloudRoom is optional, needed only if you pick it. On an Intel Mac it reads ready and notes that agents run on this computer or on boat.dev. ```sh python3 -I "$openwiz"/tools/install/install preflight ``` -2. **Verified download and install.** It downloads the release's checksum file, manifest and package from GitHub and checks the package's SHA-256 hash against the manifest before using it. No Rust, Node or source build is needed. A hash proves the files are the release's files; it is not a publisher signature. A failed check changes nothing, and an earlier install keeps working. +2. **Verified download and install.** Before downloading or activating anything, check that the selected `` is `v0.1.1` (`` is `0.1.1`, the version this guide expects); if not, stop without downloading or activating. Pass `--version "$tag"` so `download` fetches that exact release tag from GitHub (not GitHub's Latest release, which may have moved), checks the manifest against its checksum and the package's SHA-256 hash against the manifest and `SHA256SUMS`, and writes nothing to ``. No Rust, Node or source build is needed. A hash proves the files are the release's files; it is not a publisher signature. A failed check changes nothing, and an earlier install keeps working. + + ```sh + python3 -I "$openwiz"/tools/install/install download --target --dir --version "$tag" + ``` + + Check before activation that `download` printed `"outcome": "downloaded"` and `"version"` equal to `` (`0.1.1`), and that `/openwiz-.manifest.json` reports `"version"` equal to `` (`0.1.1`); if either differs, stop and do not run `install install`. Only after that check passes, activate the verified build: ```sh - python3 -I "$openwiz"/tools/install/install download --target --dir python3 -I "$openwiz"/tools/install/install install --assets --target --root ``` - `install` prints `"activated": true`, the version, and the `build` and `state_root` folders, written below as `` and ``. `download` reads GitHub's Latest release, which will be OpenWiz 0.1.1 once it is out; if it refuses with "could not be completed safely", check the [releases page](https://github.com/openwizdev/OpenWiz/releases). The same three files will be under `https://github.com/openwizdev/OpenWiz/releases/download/v0.1.1/` once 0.1.1 is out: `openwiz-.sha256`, `openwiz-.manifest.json` and `openwiz-0.1.1-.tar.gz`. Put them in a new private folder (mode 700, files 600) and run `install install --assets` on it; it checks every hash the same way. + `install` prints `"activated": true`, the version, and the `build` and `state_root` folders, written below as `` and ``. `download --version "$tag"` reads `https://github.com/openwizdev/OpenWiz/releases/download/$tag/` (`v0.1.1` once 0.1.1 is out); if it refuses with "could not be completed safely", check the [releases page](https://github.com/openwizdev/OpenWiz/releases). The same three files will be under `https://github.com/openwizdev/OpenWiz/releases/download/v0.1.1/` once 0.1.1 is out: `openwiz-.sha256`, `openwiz-.manifest.json` and `openwiz-0.1.1-.tar.gz`. Put them in a new private folder (mode 700, files 600), verify `openwiz-.manifest.json` names `"version": "0.1.1"` before activation, and run `install install --assets` on it; it checks every hash the same way. Then it proves the build: `/current/openwiz --build-identity` prints the version (`0.1.1`) and the source commit. The `openwiz` program lives there, not on your `PATH`: typing `openwiz` alone says "command not found". @@ -53,7 +58,7 @@ The agent runs each command itself and reads its JSON. `` is the install f - **GitHub:** `runtime/setup/github_login.py sign-in --state-dir ` reuses your existing `gh` login, or shows what GitHub's own browser sign-in will do and waits for your yes. You paste no token. - **`identity_unreadable`** (for `personal_github`): GitHub's answer could not be read just then. Wait a minute and run `check` again; it usually clears. -4. **Skills into your agents, then a restart.** Only now, with setup checked and the logins done, it copies OpenWiz's skills from the 0.1.1 package (WizSkills 0.4.0) into each agent found on this computer: `~/.claude/skills` (Claude Code), `~/.codex/skills` (Codex), `~/.cursor/skills` (Cursor), `~/.config/opencode/skills` (OpenCode) and `~/.grok/skills` (Grok). A skill of yours with the same name stops the step before anything is written. +4. **Skills into your agents, then a restart.** Only now, with setup checked and the logins done, it copies OpenWiz's skills from that release's package (the WizSkills release recorded by `wizskills.lock` on ``) into each agent found on this computer: `~/.claude/skills` (Claude Code), `~/.codex/skills` (Codex), `~/.cursor/skills` (Cursor), `~/.config/opencode/skills` (OpenCode) and `~/.grok/skills` (Grok). A skill of yours with the same name stops the step before anything is written. ```sh python3 -I "$openwiz"/tools/install/install skills --root @@ -91,7 +96,7 @@ Start a new session of your agent and say "continue the OpenWiz install": every Ask the agent to remove OpenWiz. It goes in this order: - **First, the heartbeat,** if a fleet runs on this computer or boat.dev. From the installed launch-fleet skill's folder (for example `~/.claude/skills/launch-fleet`), `python3 -I scripts/heartbeat.py status / ` shows the job. `heartbeat.py pause / ` stops it for now (`resume` brings it back). `heartbeat.py remove / ` takes down the schedule, stops the fleet's orchestrator and deletes the heartbeat's state. Remove each one before deleting OpenWiz's files, or the job keeps running. -- **Then the install:** `python3 -I "$openwiz"/tools/install/install remove --root ` (from a 0.1.1 clone, as in step 1; add `--state-root ` if you gave one) previews exactly what OpenWiz made: the `current` link, `channel.json`, `install.lock`, its marked skill copies in `/skills`, the verified builds and its settings in ``. With `--yes` it deletes exactly those, then removes each folder left empty. Anything else stays, links are never followed, and it refuses while an install or update is running. +- **Then the install:** `python3 -I "$openwiz"/tools/install/install remove --root ` (from the `` clone in step 1; add `--state-root ` if you gave one) previews exactly what OpenWiz made: the `current` link, `channel.json`, `install.lock`, its marked skill copies in `/skills`, the verified builds and its settings in ``. With `--yes` it deletes exactly those, then removes each folder left empty. Anything else stays, links are never followed, and it refuses while an install or update is running. - **The skill copies in your agents stay:** `install remove` lists, for each agent, a `path` (a shared folder such as `~/.claude/skills`) and the `names` of OpenWiz's skill folders inside it. Remove just those named folders inside each `path`, never the listed folder itself: it also holds your own skills. - Your repositories, branches, pull requests and CloudRoom threads are your work and are never deleted. @@ -104,6 +109,80 @@ Ask the agent to remove OpenWiz. It goes in this order: ## OpenWiz 0.1.0 -OpenWiz 0.1.0 ("OpenWiz 0.01") also installs with no CloudRoom, on Apple silicon, an Intel Mac or Linux on x86_64. Its steps differ: its [install skill](https://github.com/openwizdev/WizSkills/blob/33eef93ba30cd8db256f6fe270e3ed28747a79bd/skills/install/SKILL.md) (WizSkills `maint/0.2`, version 0.2.2) clones the `v0.1.0` tag, installs the 0.1.0 files (build identity `0.1.0`), and after `install skills` replaces each agent's packaged `install` skill with that fixed copy. On 0.1.0 the automatic fleet runs in CloudRoom; without CloudRoom you plan (grill, spec, tickets), start each builder by hand on this computer or on boat.dev, and review and merge its pull request yourself. 0.1.0 has no `install remove`: its install skill lists exactly what to delete. +OpenWiz 0.1.0 ("OpenWiz 0.01") also installs with no CloudRoom, on Apple silicon, an Intel Mac or Linux on x86_64. Its [install skill](https://github.com/openwizdev/WizSkills/blob/33eef93ba30cd8db256f6fe270e3ed28747a79bd/skills/install/SKILL.md) (WizSkills commit `33eef93ba30cd8db256f6fe270e3ed28747a79bd`, version 0.2.2) is that commit, not `v0.1.0`'s `wizskills.lock`. On 0.1.0 the automatic fleet runs in CloudRoom; without CloudRoom you plan (grill, spec, tickets), start each builder by hand on this computer or on boat.dev, and review and merge its pull request yourself. 0.1.0 has no `install remove`: its install skill lists exactly what to delete. + +When the skill URL cannot be read directly, recover it by commit first and follow it from the top, or run these complete 0.1.0 steps in order: + +1. **Recover and verify the pinned 0.1.0 install skill** (also needed in step 5 below): + + ```sh + wizskills=$(mktemp -d) + expected_commit=33eef93ba30cd8db256f6fe270e3ed28747a79bd + expected_tree=30d1eaf27658efd8f781f98703fbbdb81bcd705d + git init -q -- "$wizskills" + git -C "$wizskills" fetch -q --depth 1 -- https://github.com/openwizdev/WizSkills "$expected_commit" + git -C "$wizskills" switch -q --detach FETCH_HEAD + head_commit=$(git -C "$wizskills" rev-parse HEAD) + install_tree=$(git -C "$wizskills" rev-parse HEAD:skills/install) + ``` + + Verify `$head_commit` equals `33eef93ba30cd8db256f6fe270e3ed28747a79bd` and `$install_tree` equals `30d1eaf27658efd8f781f98703fbbdb81bcd705d`; if the fetch fails or either hash mismatches, stop and say so. When the skill URL could not be read, follow `"$wizskills"/skills/install/SKILL.md` from the top. + +2. **Preflight:** clone tag `v0.1.0` into a new private temporary folder and run preflight: + + ```sh + openwiz=$(mktemp -d) + git clone --depth 1 --branch v0.1.0 -- https://github.com/openwizdev/OpenWiz "$openwiz" + python3 -I "$openwiz"/tools/install/install preflight + ``` + +3. **Verified download and install:** 0.1.0's `install download` has no `--version` and reads GitHub's Latest release (which stops being 0.1.0 once 0.1.1 is released). Select 0.1.0 explicitly from `https://github.com/openwizdev/OpenWiz/releases/download/v0.1.0/` into a new private folder (mode 700, files 600), verify the manifest names `"version": "0.1.0"` before activation, then run `install install --assets` and prove `--build-identity`: + + ```sh + assets=$(mktemp -d) + chmod 700 "$assets" + umask 077 + for f in openwiz-.sha256 openwiz-.manifest.json openwiz-0.1.0-.tar.gz; do + curl -fsSL --proto '=https' -o "$assets/$f" "https://github.com/openwizdev/OpenWiz/releases/download/v0.1.0/$f" + done + python3 -I -c 'import json, sys; assert json.load(open(sys.argv[1]))["version"] == "0.1.0"' "$assets/openwiz-.manifest.json" + python3 -I "$openwiz"/tools/install/install install --assets "$assets" --target --root + /current/openwiz --build-identity + ``` + + `install` checks every hash and prints `"activated": true`, `` and ``, and `/current/openwiz --build-identity` reads `0.1.0`. + +4. **Setup and logins:** check connections from the installed 0.1.0 build and rerun `check` after each change: + + ```sh + OPENWIZ_STATE_DIR= python3 -I -B /runtime/setup/setup.py check --state-dir + OPENWIZ_STATE_DIR= python3 -I -B /runtime/setup/github_login.py sign-in --state-dir + ``` + + `github_login.py sign-in` reuses a verified `gh` login, or previews browser sign-in and completes with `--yes` on your yes. **CloudRoom,** only if you pick it (otherwise skip every `cloudroom_*` code): run `OPENWIZ_STATE_DIR= python3 -I -B /runtime/cloudroom/cloudroom.py status --state-dir `, `OPENWIZ_STATE_DIR= python3 -I -B /runtime/cloudroom/cloudroom.py install --state-dir ` (preview, then `--yes --operation ` on your yes; only if you pick CloudRoom), and `OPENWIZ_STATE_DIR= python3 -I -B /runtime/cloudroom/cloudroom.py sign-in --state-dir ` until `check` reads `cloudroom_login_verified`. + +5. **Skills and required `install` skill replacement:** run `install skills`, then overwrite each agent's packaged `install` skill from the verified `"$wizskills"/skills/install` folder before restarting. The 0.1.0 archive ships `install` skill `version: 0.2.0`, which tells a restarted agent to run `install open` — a command the `v0.1.0` installer rejects. + + ```sh + python3 -I "$openwiz"/tools/install/install skills --root + src="$wizskills/skills/install" + if [ "$(git -C "$wizskills" rev-parse HEAD)" != "$expected_commit" ] || [ "$(git -C "$wizskills" rev-parse HEAD:skills/install)" != "$expected_tree" ]; then + echo "SOURCE MISMATCH" >&2; false + else + failed=no + for d in "$HOME/.claude/skills" "$HOME/.codex/skills" ${CODEX_HOME:+"$CODEX_HOME/skills"} "$HOME/.cursor/skills" "$HOME/.config/opencode/skills" "$HOME/.grok/skills"; do + [ -f "$d/install/.openwiz-skill" ] || continue + cp -R "$src"/. "$d/install/" + same=yes + for f in $(cd "$src" && find . -type f); do cmp -s "$src/$f" "$d/install/$f" || same=no; done + if [ "$same" = yes ] && grep -q '^version: 0.2.2$' "$d/install/SKILL.md" && ! grep -q -e 'install ope[n] ' -e 'from the setup pag[e]' -e 'Restart the OpenWiz serve[r]' "$d/install/SKILL.md" "$d/install"/scripts/*.py; then + echo "ok: $d/install" + else + echo "STILL OLD: $d/install" >&2; failed=yes + fi + done + [ "$failed" = no ] + fi + ``` -Today 0.1.0 is GitHub's Latest release, so 0.1.0's `download` step fetches 0.1.0. Once 0.1.1 is the Latest release, that step fetches 0.1.1, and 0.1.0's installer has no `--version`. Then select 0.1.0 explicitly instead of running `download`: put its three files from `https://github.com/openwizdev/OpenWiz/releases/download/v0.1.0/` (`openwiz-.sha256`, `openwiz-.manifest.json` and `openwiz-0.1.0-.tar.gz`) in a new private folder (mode 700, files 600), then run `python3 -I "$openwiz"/tools/install/install install --assets --target --root ` from the `v0.1.0` clone. It checks every hash, and `/current/openwiz --build-identity` reads `0.1.0`. + If `SOURCE MISMATCH` or `STILL OLD` appears, stop before restarting and tell the user; never restart onto the 0.1.0 archive's `0.2.0` copy. Once every installed folder prints `ok:`, restart the agent and say `continue the OpenWiz install`. diff --git a/tools/install/install b/tools/install/install index 7be87d89a..063492172 100755 --- a/tools/install/install +++ b/tools/install/install @@ -17,6 +17,9 @@ sys.dont_write_bytecode = True DESCRIPTION = """OpenWiz's install entry (#1109): the commands the install skill runs. +The install instruction is: Install OpenWiz. Say that to a coding agent. These +commands are the reference that agent runs. + install preflight Reads this machine only: Python, the supported target, free disk space, on Linux the glibc version (from ldd --version; 2.34 or later), and diff --git a/tools/install/test_phrase.py b/tools/install/test_phrase.py new file mode 100644 index 000000000..7a5372cf4 --- /dev/null +++ b/tools/install/test_phrase.py @@ -0,0 +1,394 @@ +#!/usr/bin/env python3 +import importlib.machinery +import importlib.util +import io +import json +import re +import shlex +import sys +import unittest +from pathlib import Path + +sys.dont_write_bytecode = True +ROOT = Path(__file__).resolve().parents[2] +HERE = Path(__file__).resolve().parent +PHRASE = 'Install OpenWiz' +QUOTE = '> ' + PHRASE +SURFACES = ('README.md', 'AGENTS.md', 'docs/install.md', 'docs/first-hour.md', 'docs/grok-bot.md') +FORBIDDEN = 'Install OpenWiz from' +SKILL_010_COMMIT = '33eef93ba30cd8db256f6fe270e3ed28747a79bd' +SKILL_010_TREE = '30d1eaf27658efd8f781f98703fbbdb81bcd705d' +SKILL_010 = f'https://github.com/openwizdev/WizSkills/blob/{SKILL_010_COMMIT}/skills/install/SKILL.md' +SKILL_TEMPLATE = 'https://github.com/openwizdev/WizSkills/blob//skills/install/SKILL.md' +SKILL_TAG = re.compile(r'https://github\.com/openwizdev/WizSkills/blob/(v[0-9][^/\s)]*)/skills/install/SKILL\.md') +SKILL_COMMIT = re.compile(r'https://github\.com/openwizdev/WizSkills/blob/([0-9a-f]{40})/skills/install/SKILL\.md') +OPEN_RANGE = re.compile(r'\bv?\d+\.\d+\.\d+\s+(?:or later|or newer|and later|onward)\b') +NAMED_SKILL = re.compile(r'WizSkills (\d+\.\d+\.\d+)') +MISSING_LOCK = 'lock has no `commit`, stop and say so' +TAG_PATTERN = r'v(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)' +COMMIT_PATTERN = r'[0-9a-f]{40}' +REPO = 'https://github.com/openwizdev/OpenWiz' +SAFE_CLONE = 'git clone --depth 1 --branch "$tag" -- ' + REPO + ' "$openwiz"' +DOWNLOAD_PIN = '--version "$tag"' + + +def clone_argv(tag, directory): + if re.fullmatch(TAG_PATTERN, tag) is None: + raise ValueError('tag') + if (not isinstance(directory, str) or not directory or directory.startswith('-') + or '\n' in directory or '\x00' in directory): + raise ValueError('directory') + return ['git', 'clone', '--depth', '1', '--branch', tag, '--', REPO, directory] + + +def read_lock(text): + data = json.loads(text) + version, commit = data.get('version', ''), data.get('commit', '') + if not isinstance(version, str) or not re.fullmatch(r'[0-9]+\.[0-9]+\.[0-9]+', version): + raise ValueError('wizskills.lock version') + if not isinstance(commit, str) or not re.fullmatch(COMMIT_PATTERN, commit): + raise ValueError('wizskills.lock commit') + return version, commit + + +def lock_pin(): + return read_lock((ROOT / 'wizskills.lock').read_text(encoding='utf-8')) + + +def skill_url_for_lock(template, lock_text): + if template != SKILL_TEMPLATE: + raise ValueError('template') + _, commit = read_lock(lock_text) + return template.replace('', commit) + + +def section_010(guide): + match = re.search(r'^## OpenWiz 0\.1\.0\n(.*?)(?=^## |\Z)', guide, re.M | re.S) + return match.group(0) if match else '' + + +def load_entry(): + loader = importlib.machinery.SourceFileLoader('install_entry_phrase', str(HERE / 'install')) + spec = importlib.util.spec_from_loader(loader.name, loader) + module = importlib.util.module_from_spec(spec) + loader.exec_module(module) + return module + + +def pin_failures(section, guide, version): + failures = [] + if 'wizskills.lock' not in section or '' not in section: + failures.append('the agent section does not derive the skill from the release tag\'s wizskills.lock commit') + if MISSING_LOCK not in section: + failures.append('a release with no wizskills.lock commit does not stop') + if SAFE_CLONE not in section: + failures.append('the agent section clones without -- before the repository') + if TAG_PATTERN not in section or COMMIT_PATTERN not in section or 'whole value' not in section: + failures.append('the agent section does not require the whole tag and the whole commit') + if '--branch v0.1.1' in section: + failures.append('the agent section clones v0.1.1') + for tag in SKILL_TAG.findall(section): + failures.append('the agent section hardcodes %s instead of the lock commit' % tag) + for sha in SKILL_COMMIT.findall(section): + if sha != SKILL_010_COMMIT: + failures.append('the agent section hardcodes commit %s instead of ' % sha) + if OPEN_RANGE.search(section) and ('v0.4.0' in section or SKILL_TAG.search(section)): + failures.append('an open-ended range is pinned to one WizSkills tag') + if 'wizskills.lock' not in guide: + failures.append('the install guide does not name wizskills.lock') + if SAFE_CLONE not in guide or TAG_PATTERN not in guide or 'whole value' not in guide: + failures.append('the install guide clones without a whole-value tag check and --') + if '--branch v0.1.1' in guide: + failures.append('the install guide clones --branch v0.1.1') + for tag in SKILL_TAG.findall(guide): + failures.append('the install guide hardcodes %s; wizskills.lock is %s' % (tag, version)) + for sha in SKILL_COMMIT.findall(guide): + if sha != SKILL_010_COMMIT: + failures.append('the install guide hardcodes commit %s instead of ' % sha) + for named in NAMED_SKILL.findall(guide): + if named != version: + failures.append('the install guide names WizSkills %s while wizskills.lock is %s' % (named, version)) + return failures + + +def fallback_010_failures(section, guide): + failures = [why for needed, why in ( + (SKILL_010_COMMIT, 'agent 0.1.0 fallback omits the pinned WizSkills commit'), + (SKILL_010_TREE, 'agent 0.1.0 fallback omits the pinned skills/install tree OID'), + ('rev-parse HEAD:skills/install', 'agent 0.1.0 fallback does not verify the fetched skills/install tree'), + ('0.2.0', 'agent 0.1.0 fallback does not warn against restarting onto the packaged 0.2.0 skill'), + ) if needed not in section] + old = section_010(guide) + failures += [why for needed, why in ( + ('git clone --depth 1 --branch v0.1.0 -- ' + REPO + ' "$openwiz"', '0.1.0 runbook omits v0.1.0 clone'), + ('install preflight', '0.1.0 runbook omits preflight'), + ('releases/download/v0.1.0/', '0.1.0 runbook omits explicit v0.1.0 download'), + ('install install --assets', '0.1.0 runbook omits install install --assets'), + ('--build-identity', '0.1.0 runbook omits --build-identity'), + ('runtime/setup/setup.py check', '0.1.0 runbook omits setup.py check'), + ('runtime/setup/github_login.py sign-in', '0.1.0 runbook omits github_login.py sign-in'), + ('runtime/cloudroom/cloudroom.py', '0.1.0 runbook omits cloudroom.py commands'), + ('install skills --root', '0.1.0 runbook omits install skills'), + (SKILL_010_COMMIT, '0.1.0 runbook omits pinned WizSkills commit'), + (SKILL_010_TREE, '0.1.0 runbook omits pinned skills/install tree OID'), + ('rev-parse HEAD:skills/install', '0.1.0 runbook omits tree OID verification'), + ('.openwiz-skill', '0.1.0 runbook omits .openwiz-skill check'), + ('^version: 0.2.2$', '0.1.0 runbook omits version 0.2.2 check'), + ('install ope[n] ', '0.1.0 runbook omits rejecting 0.2.0 install open copy'), + ) if needed not in old] + return failures + + +def download_pin_failures(section, guide): + failures = [] + if DOWNLOAD_PIN not in section: + failures.append('the agent section does not pass --version "$tag" to install download') + if not re.search(r'before[^\n.]*activat', section, re.I): + failures.append('the agent section does not check the selected version before activation') + lines = [line.strip() for line in guide.splitlines() if 'tools/install/install download' in line] + if not lines or any(DOWNLOAD_PIN not in line for line in lines): + failures.append('the install guide download command omits --version "$tag"') + step2 = guide.split('2. **Verified download and install.**', 1) + body = step2[1].split('\n3. **', 1)[0] if len(step2) == 2 else '' + dl_at = body.find('tools/install/install download') + install_at = body.find('tools/install/install install --assets') + between = body[dl_at:install_at] if 0 <= dl_at < install_at else '' + if 'before activation' not in between.lower() or '"version"' not in between: + failures.append('the install guide does not check the downloaded version before running install install') + return failures + + +class InstallPhrase(unittest.TestCase): + def test_each_surface_quotes_the_phrase_alone(self): + for name in SURFACES: + text = (ROOT / name).read_text(encoding='utf-8') + lines = [line.strip() for line in text.splitlines()] + with self.subTest(name): + self.assertIn(QUOTE, lines) + self.assertNotIn(FORBIDDEN, text) + + def section(self): + text = (ROOT / 'AGENTS.md').read_text(encoding='utf-8') + parts = text.split('## Install OpenWiz', 1) + self.assertEqual(len(parts), 2, 'AGENTS.md has an Install OpenWiz section') + return parts[1].split('\n## ', 1)[0] + + def test_the_agent_section_is_enough_to_start(self): + section = self.section() + for needed in (QUOTE, 'That phrase is enough to start.', + 'https://github.com/openwizdev/OpenWiz/releases/latest', + 'https://github.com/openwizdev/OpenWiz', 'where your agents run', 'yes before each change'): + self.assertIn(needed, section, needed) + + def test_tag_and_commit_cannot_inject_clone_options(self): + loose = re.compile(r'v[0-9]+\.[0-9]+\.[0-9]+') + self.assertIsNotNone(loose.search('v0.1.1 --upload-pack=evil')) + self.assertEqual(clone_argv('v0.1.1', '/tmp/openwiz-synthetic'), + ['git', 'clone', '--depth', '1', '--branch', 'v0.1.1', '--', REPO, '/tmp/openwiz-synthetic']) + for bad in ('-c', '--upload-pack=evil', 'v0.1.1 --upload-pack=evil', + 'v0.1.1;rm', '', 'v01.2.3', 'v0.1.1-rc.1'): + with self.subTest(tag=bad): + with self.assertRaises(ValueError): + clone_argv(bad, '/tmp/openwiz-synthetic') + with self.assertRaises(ValueError): + clone_argv('v0.1.1', '--separate-git-dir=/tmp/openwiz-synthetic') + for bad in ('-deadbeef', '--upload-pack=evil', 'cf2abfe', '', + 'CF2ABFE13020661b47c47adb71afa993caaf16bf', + 'cf2abfe13020661b47c47adb71afa993caaf16bf extra'): + with self.subTest(commit=bad): + self.assertIsNone(re.fullmatch(COMMIT_PATTERN, bad)) + section = self.section() + guide = (ROOT / 'docs/install.md').read_text(encoding='utf-8') + for needed in (TAG_PATTERN, COMMIT_PATTERN, SAFE_CLONE): + self.assertIn(needed, section) + for needed in (TAG_PATTERN, SAFE_CLONE): + self.assertIn(needed, guide) + + def test_the_checkout_follows_the_lock(self): + version, commit = lock_pin() + section = self.section() + guide = (ROOT / 'docs/install.md').read_text(encoding='utf-8') + self.assertEqual(pin_failures(section, guide, version), []) + for needed in (SKILL_010, '`0.1.0`', 'docs/install.md#openwiz-010', '`v0.1.0`', MISSING_LOCK, + 'including `v0.1.1`', 'openwiz=$(mktemp -d)', + "not the `commit` in that tag's `wizskills.lock`", 'expect build identity `0.1.1`', + 'When `` is not `0.1.1`, stop unless that guide expects ``'): + self.assertIn(needed, section) + self.assertNotEqual(commit, SKILL_010_COMMIT) + self.assertNotIn('blob/%s/' % commit, section) + self.assertNotIn('blob/%s/' % commit, guide) + for needed in ('command reference for OpenWiz 0.1.1', 'ARM64 (aarch64)', + 'hard `GLIBC_2.39` requirement does not start'): + self.assertIn(needed, guide) + self.assertNotIn('command reference for that same tag', guide) + self.assertNotIn('Linux on ARM is not supported', guide) + self.assertIn('docs/install.md#openwiz-010', (ROOT / 'README.md').read_text(encoding='utf-8')) + + def test_documented_skill_url_derives_commit_from_lock(self): + version, commit = lock_pin() + section = self.section() + guide = (ROOT / 'docs/install.md').read_text(encoding='utf-8') + self.assertIn(SKILL_TEMPLATE, section) + raw_lock = (ROOT / 'wizskills.lock').read_text(encoding='utf-8') + self.assertEqual(skill_url_for_lock(SKILL_TEMPLATE, raw_lock), SKILL_TEMPLATE.replace('', commit)) + forged = 'a' * 40 + self.assertEqual(skill_url_for_lock(SKILL_TEMPLATE, raw_lock.replace(commit, forged)), + SKILL_TEMPLATE.replace('', forged)) + for bad in ('{"version":"0.5.0"}', '{"version":"0.5.0","commit":"-deadbeef"}', + '{"version":"0.5.0","commit":"deadbeef"}', '{"version":"0.5.0","commit":"' + 'A' * 40 + '"}'): + with self.subTest(bad=bad): + with self.assertRaises(ValueError): + skill_url_for_lock(SKILL_TEMPLATE, bad) + for sha in (commit, forged): + url = SKILL_TEMPLATE.replace('', sha) + self.assertTrue(any(sha in f for f in pin_failures(section + '\n' + url, guide, version))) + self.assertTrue(any(sha in f for f in pin_failures(section, guide + '\n' + url, version))) + + def test_010_fallback_recovers_pinned_skill_and_covers_setup_and_replacement(self): + section = self.section() + guide = (ROOT / 'docs/install.md').read_text(encoding='utf-8') + self.assertEqual(fallback_010_failures(section, guide), []) + self.assertTrue(fallback_010_failures(section.replace(SKILL_010_TREE, '0' * 40), guide)) + self.assertTrue(fallback_010_failures(section, guide.replace('runtime/setup/setup.py check', ''))) + self.assertTrue(fallback_010_failures(section, guide.replace('^version: 0.2.2$', ''))) + + def test_011_fallback_downloads_selected_tag_and_checks_version_before_activation(self): + section = self.section() + guide = (ROOT / 'docs/install.md').read_text(encoding='utf-8') + lines = [line.strip() for line in guide.splitlines() if 'tools/install/install download' in line] + self.assertEqual(len(lines), 1, lines) + sys.path.insert(0, str(HERE)) + import test_install as fixture + f = fixture.Bundles() + f.setUp() + self.addCleanup(f.doCleanups) + target = fixture.TARGETS[2] + def publish(ver, src): + arc = f'openwiz-{ver}-{target}.tar.gz' + b = f.bundle(target=target, source=src, version=ver, mutate=lambda m: m.__setitem__('archive', arc)) + raw, data = b[0].read_bytes(), b[1].read_bytes() + return {'sha': f'{fixture.sha(raw)} openwiz-{target}.manifest.json\n'.encode(), 'raw': raw, + 'arc_name': arc, 'arc': data, + 'sums': f'{fixture.sha(raw)} openwiz-{ver}-{target}.manifest.json\n{fixture.sha(data)} {arc}\n'.encode()} + releases = {'0.1.1': publish('0.1.1', '1' * 40), '0.1.2': publish('0.1.2', '2' * 40)} + urls = [] + def serve(latest_ver, v011_ver='0.1.1'): + def fetch(url, limit): + urls.append(url) + rel = releases[latest_ver] if '/releases/latest/' in url else ( + releases[v011_ver] if '/download/v0.1.1/' in url else releases['0.1.2']) + if url.endswith('.sha256'): + return rel['sha'] + if url.endswith('.manifest.json'): + return rel['raw'] + if url.endswith('SHA256SUMS'): + return rel['sums'] + if url.endswith(rel['arc_name']): + return rel['arc'] + raise AssertionError(url) + return fetch + dl = f.base / 'dl-011' + cmd = lines[0].replace('"$tag"', 'v0.1.1').replace('', target).replace('', shlex.quote(str(dl))) + argv = shlex.split(cmd)[3:] + entry = load_entry() + out = io.StringIO() + code = entry.main(argv, fetch=serve('0.1.2'), stdout=out) + self.assertEqual(code, 0, out.getvalue()) + self.assertEqual(json.loads(out.getvalue())['version'], '0.1.1') + self.assertFalse(any('/releases/latest/' in u for u in urls), urls) + out2 = io.StringIO() + code2 = entry.main(['install', '--assets', str(dl), '--target', target, '--root', str(f.root)], stdout=out2) + self.assertEqual((code2, json.loads(out2.getvalue())['version']), (0, '0.1.1')) + bad = io.StringIO() + bad_code = entry.main(['download', '--target', target, '--dir', str(f.base / 'dl-bad'), '--version', 'v0.1.1'], + fetch=serve('0.1.2', v011_ver='0.1.2'), stdout=bad) + self.assertEqual(bad_code, 5, bad.getvalue()) + self.assertFalse((f.base / 'dl-bad').exists()) + self.assertEqual(download_pin_failures(section, guide), []) + self.assertTrue(download_pin_failures(section.replace(DOWNLOAD_PIN, ''), guide)) + self.assertTrue(download_pin_failures(section.replace('activat', 'install'), guide)) + self.assertTrue(download_pin_failures(section, guide.replace(DOWNLOAD_PIN, ''))) + self.assertTrue(download_pin_failures(section, guide.replace('Check before activation', 'Afterwards check'))) + + def test_each_pin_failure_is_its_own_case(self): + version = '9.9.9' + whole = TAG_PATTERN + ' ' + COMMIT_PATTERN + ' whole value' + section = 'wizskills.lock ' + MISSING_LOCK + '\n' + SAFE_CLONE + '\n' + whole + guide = 'wizskills.lock ' + whole + '\n' + SAFE_CLONE + '\n' + self.assertEqual(pin_failures(section, guide, version), []) + python_only = section + '\nYou need Python 3.9 or later.\n' + self.assertEqual(pin_failures(python_only, guide, version), []) + cases = ( + (section.replace('wizskills.lock', 'lockfile'), guide, 'does not derive'), + (section.replace('', ''), guide, 'does not derive'), + (section.replace(MISSING_LOCK, 'GitHub has no Latest release: stop and say so'), guide, 'does not stop'), + (section.replace(SAFE_CLONE, 'git clone --branch "$tag" ' + REPO), guide, 'clones without'), + (section.replace(TAG_PATTERN, 'v[0-9]+'), guide, 'whole tag'), + (section.replace(COMMIT_PATTERN, '[0-9a-f]+'), guide, 'whole tag'), + (section.replace('whole value', 'a prefix'), guide, 'whole tag'), + (section + '\n--branch v0.1.1\n', guide, 'clones v0.1.1'), + (section + '\nhttps://github.com/openwizdev/WizSkills/blob/v9.9.9/skills/install/SKILL.md\n', + guide, 'hardcodes v9.9.9'), + (section + '\n0.1.1 or later https://github.com/openwizdev/WizSkills/blob/v1.2.3/skills/install/SKILL.md\n', + guide, 'open-ended range'), + (section, guide.replace('wizskills.lock', 'lockfile'), 'does not name wizskills.lock'), + (section, guide.replace(SAFE_CLONE, 'git clone --branch ' + REPO), 'whole-value'), + (section, guide.replace(TAG_PATTERN, 'v[0-9]+'), 'whole-value'), + (section, guide.replace('whole value', 'a prefix'), 'whole-value'), + (section, guide + '\n--branch v0.1.1\n', 'clones --branch v0.1.1'), + (section, guide + '\nhttps://github.com/openwizdev/WizSkills/blob/v1.2.3/skills/install/SKILL.md\n', + 'hardcodes v1.2.3'), + (section, guide + '\nWizSkills 1.2.3\n', 'names WizSkills 1.2.3'), + ) + for bad_section, bad_guide, needle in cases: + with self.subTest(needle=needle): + failures = pin_failures(bad_section, bad_guide, version) + self.assertTrue(any(needle in item for item in failures), failures) + same = pin_failures(section, guide + '\nWizSkills 9.9.9\n', version) + self.assertFalse(any('names WizSkills' in item for item in same), same) + + def test_a_stale_pin_fails_even_when_the_urls_are_present(self): + version, _ = lock_pin() + self.assertNotEqual(version, '0.4.0') + stale_section = ( + '- For `0.1.1` or later, the skill is ' + 'https://github.com/openwizdev/WizSkills/blob/v0.4.0/skills/install/SKILL.md ' + 'and the steps clone --branch v0.1.1.\n') + stale_guide = ( + 'follow https://github.com/openwizdev/WizSkills/blob/v0.4.0/skills/install/SKILL.md. ' + 'git clone --depth 1 --branch v0.1.1 https://github.com/openwizdev/OpenWiz "$openwiz" ' + '(WizSkills 0.4.0)\n') + failures = pin_failures(stale_section, stale_guide, version) + self.assertTrue(any('v0.4.0' in item for item in failures), failures) + self.assertTrue(any('v0.1.1' in item for item in failures), failures) + self.assertTrue(any(version in item for item in failures), failures) + + def test_readme_is_covered_by_the_release_pin_check(self): + path = ROOT / 'docs/evidence/2227/check_docs.py' + spec = importlib.util.spec_from_file_location('check_docs_2227', path) + check = importlib.util.module_from_spec(spec) + spec.loader.exec_module(check) + bare = '# Readme\n\n## OpenWiz 0.1.0\n\nSee docs/install.md#openwiz-010.\n' + failures = check.release_path('README.md', bare) + self.assertTrue(any('wizskills.lock' in item for item in failures), failures) + self.assertTrue(any('clone' in item for item in failures), failures) + self.assertTrue(any('pattern' in item for item in failures), failures) + real = check.release_path('README.md', (ROOT / 'README.md').read_text(encoding='utf-8')) + pin = [item for item in real if 'wizskills.lock' in item or 'clone' in item + or 'v0.4.0' in item or 'pattern' in item] + self.assertEqual(pin, []) + + def test_the_pages_point_at_the_agent_section(self): + for name in ('README.md', 'docs/install.md', 'docs/first-hour.md', 'docs/grok-bot.md'): + text = (ROOT / name).read_text(encoding='utf-8') + with self.subTest(name): + self.assertIn('AGENTS.md#install-openwiz', text) + + def test_install_help_names_the_phrase_and_keeps_the_commands(self): + text = (ROOT / 'tools/install/install').read_text(encoding='utf-8') + self.assertIn("OpenWiz's install entry (#1109): the commands the install skill runs.", text) + self.assertIn('The install instruction is: Install OpenWiz.', text) + + +if __name__ == '__main__': + unittest.main()