# Spec Delta ## Purpose The installer adds the Context Flywheel to a target repository and upgrades it, without overwriting anything the repository owns. ## ADDED Requirements ### Requirement: Flywheel-owned files are copied The installer SHALL copy the six flywheel skills, the three flywheel agents, the CLI, and the templates into the target, and SHALL record each copied file with a content hash in the install manifest `.flywheel/install-manifest.json`. #### Scenario: Fresh install - **GIVEN** an empty target directory - **WHEN** `flywheel.py install ` runs - **THEN** the target has `.claude/skills/context-flywheel/SKILL.md`, `.claude/agents/flywheel-judge.md`, `.flywheel/bin/flywheel.py`, and `.flywheel/install-manifest.json`, and `flywheel.py check` passes in the target ### Requirement: Upgrades replace only unchanged copies On a later run the installer SHALL replace an existing flywheel-owned file only when it is identical to the new copy or unchanged since the last install (its hash matches the manifest). It MUST NOT replace a file the repository wrote itself (a file at the same path that the manifest does not list) or a copy edited since the last install; it SHALL skip each such file, name it and the reason in the output, install everything else, and exit with code 1. #### Scenario: Unedited copy is upgraded - **GIVEN** a target where `.flywheel/bin/flywheel.py` still matches the hash in the manifest and the source has a newer version - **WHEN** the installer runs again - **THEN** the file is replaced with the newer version and the exit code is 0 #### Scenario: Repository's own skill with the same name - **GIVEN** a target with its own `.claude/skills/evaluate/SKILL.md` that the flywheel did not install - **WHEN** `flywheel.py install ` runs - **THEN** that file is unchanged, the output reports it as not installed by the flywheel, and the exit code is 1 #### Scenario: Locally edited copy - **GIVEN** a target where an installed flywheel skill was edited after the install - **WHEN** the installer runs again - **THEN** the edited file is unchanged, the output reports it as edited since the last install, and the exit code is 1 ### Requirement: Forced replacement keeps a backup With `--force` the installer SHALL replace the files it would otherwise skip, after saving each old file as `.bak` next to it. #### Scenario: Force over a repository's own skill - **GIVEN** a target with its own `.claude/skills/evaluate/SKILL.md` - **WHEN** `flywheel.py install --force` runs - **THEN** the file holds the flywheel copy, `.claude/skills/evaluate/SKILL.md.bak` holds the old content, and the exit code is 0 ### Requirement: Repository-owned files are seeded once The installer SHALL create `.flywheel/config.json`, `.flywheel/memory/MEMORY.md`, and `constitution.md` only when they do not exist, and MUST NOT modify them on later runs. #### Scenario: Re-install keeps the constitution - **GIVEN** a target whose `constitution.md` was edited after the first install - **WHEN** the installer runs again - **THEN** `constitution.md` is unchanged ### Requirement: Marked block in AGENTS.md and imports in CLAUDE.md The installer SHALL insert the flywheel block into `AGENTS.md` between start and end markers, replacing the block on later runs instead of duplicating it, and SHALL add the missing imports of `AGENTS.md`, `constitution.md`, and the memory index to `CLAUDE.md`. When `AGENTS.md` has a start marker without an end marker (or the reverse) or more than one start marker, the installer MUST NOT change `AGENTS.md`; it SHALL report the unbalanced markers and exit with code 2. #### Scenario: Installed twice - **GIVEN** a target installed once - **WHEN** the installer runs a second time - **THEN** `AGENTS.md` contains exactly one flywheel block and `CLAUDE.md` has each import once #### Scenario: Unbalanced markers - **GIVEN** a target whose `AGENTS.md` has a flywheel start marker and no end marker - **WHEN** `flywheel.py install ` runs - **THEN** `AGENTS.md` is unchanged, the output reports unbalanced markers, and the exit code is 2 ### Requirement: OpenSpec configuration The installer SHALL write `openspec/config.yaml` from the template only when OpenSpec is initialized and the existing config has no custom settings. A config that is still exactly the template it seeded SHALL be left alone without a note; any other config SHALL be left unchanged with a merge note. #### Scenario: Seeded OpenSpec config on re-install - **GIVEN** a target whose `openspec/config.yaml` was written by an earlier install and not edited - **WHEN** the installer runs again - **THEN** the file is unchanged and the output has no merge note #### Scenario: Custom OpenSpec config - **GIVEN** a target whose `openspec/config.yaml` already has a `context` section - **WHEN** the installer runs - **THEN** the file is unchanged and the output tells the user to merge the template by hand ### Requirement: Dry run With `--dry-run` the installer SHALL print every action and MUST NOT write any file. #### Scenario: Dry run on an empty target - **GIVEN** an empty target directory - **WHEN** `flywheel.py install --dry-run` runs - **THEN** actions are printed and the directory stays empty