From dc4f143052540f0e2be888d3466a6d98a20fe697 Mon Sep 17 00:00:00 2001 From: darthsharp <48331467+darthsharp@users.noreply.github.com> Date: Sun, 22 Nov 2026 11:59:26 +0100 Subject: [PATCH 1/3] docs: research plugin and skill versioning across Claude Code, Copilot CLI, and Codex CLI - docs: add agent_plugin_versioning.md with detailed findings on version resolution, caching, update detection, and skill runtime variable substitution for all three agents - docs: add compatibility_patterns.md, current_state_repo.md, and versioning_tooling.md research notes - docs: add summary report reports/Versionierung von CLI und Skills.md --- reports/Versionierung von CLI und Skills.md | 78 +++++ .../agent_plugin_versioning.md | 267 ++++++++++++++++++ .../compatibility_patterns.md | 187 ++++++++++++ .../current_state_repo.md | 200 +++++++++++++ .../versioning_tooling.md | 187 ++++++++++++ 5 files changed, 919 insertions(+) create mode 100644 reports/Versionierung von CLI und Skills.md create mode 100644 research_notes/Versionierung von CLI und Skills/agent_plugin_versioning.md create mode 100644 research_notes/Versionierung von CLI und Skills/compatibility_patterns.md create mode 100644 research_notes/Versionierung von CLI und Skills/current_state_repo.md create mode 100644 research_notes/Versionierung von CLI und Skills/versioning_tooling.md diff --git a/reports/Versionierung von CLI und Skills.md b/reports/Versionierung von CLI und Skills.md new file mode 100644 index 0000000..2300197 --- /dev/null +++ b/reports/Versionierung von CLI und Skills.md @@ -0,0 +1,78 @@ +# Eine Vertragsnummer entkoppelt CLI und Skills + +shade-kit sollte den Lockstep aufgeben und die Kompatibilität zwischen Skills und CLI über eine **eigene, ganzzahlige CLI-Vertragsversion mit Fenster** prüfen. Die Engine erklärt `Current` und `MinSupported`, jeder Skill nennt im Handshake die eine Vertragsnummer, für die er geschrieben ist, und die Engine akzeptiert, wenn `MinSupported ≤ R ≤ Current` gilt. Damit setzt die Empfehlung die gefragte Option „unabhängige Versionen mit gegenseitigen Mindestversionen“ um, aber auf einer Vertragsachse statt auf der Achse der Produkt-SemVer. Die Produktversion der CLI bleibt bei GitVersion. Die Skills brauchen überhaupt keine eigene Produktversion mehr, denn kein Agent liest `metadata.version` aus; nur der eigene Guard-Test tut das. Verteilt wird weiter wie heute über den Tag `v` oder `main`. Ein gewöhnliches Release kommt damit ganz ohne Versionsänderung in den Skills aus. Nur eine Änderung an der für Skills sichtbaren CLI-Oberfläche verlangt noch Handarbeit: eine Konstante und sieben gleichlautende Handshake-Zeilen, und ein Snapshot-Test erzwingt sie. Der größte Gewinn liegt beim lokalen Testen: Jeder Build desselben Codes trägt dieselbe Vertragsnummer, also prüft der Handshake Feature-Branch-Builds wirklich, statt sie wie heute als Prerelease durchzuwinken. Am besten erfolgt der Umbau vor dem ersten installierbaren Release-Tag. Bis dahin gibt es im Feld keine Engine, die die neue Option still ignorieren würde. + +## Heute trägt eine Zahl zwei Bedeutungen, und beide Mechanismen widersprechen sich + +Im Repository gibt es genau eine berechnete Version. GitVersion leitet sie aus der Git-Historie und aus `next-version: v0.9.0` ab, sie wird als Informational Version eingebettet und zur Laufzeit von `EngineVersionProvider` gelesen (**FACT**, [GitVersion.yml](../GitVersion.yml), [EngineVersionProvider.cs](../src/CreativeCoders.ShadeKit.Core/Engine/EngineVersionProvider.cs)). Daneben führen die Skills eine zweite, von Hand gepflegte Kopie. **Alle 19 `SKILL.md` tragen `version: 0.9.0` im Frontmatter. Fünf Skills führen den Handshake aus, und zwei Befehlslisten wiederholen ihn. Zusammen sind das 26 Zeilen in 19 Dateien**, die bei einer Anhebung gemeinsam geändert werden müssen (**FACT**, `git grep -c 0.9.0 -- skills`). Die Kopie im Fließtext ist nötig, weil Claude Code das Frontmatter vor dem Modell verbirgt (beobachtet mit 2.1.318) und Copilot CLI es seit 1.0.48 ebenfalls entfernt ([Copilot CLI changelog](https://github.com/github/copilot-cli/blob/main/changelog.md)). Codex lässt das Modell zwar die rohe Datei lesen, wertet aber nur `name`, `description` und `metadata.short-description` aus ([openai/codex parser.rs](https://github.com/openai/codex/blob/main/codex-rs/skills/src/parser.rs)). + +`SkillKitVersionTests` koppelt beide Kopien an die GitVersion-Version **des Builds, der den Test ausführt** (`new EngineVersionProvider().Version`). Das Ergebnis hängt deshalb von Branch, lokal vorhandenen Tags und `next-version` ab, nicht nur von den eingecheckten Dateien (**FACT**, [SkillKitVersionTests.cs](../tests/CreativeCoders.ShadeKit.Core.Tests/Skills/SkillKitVersionTests.cs)). Zur Laufzeit gilt die entgegengesetzte Logik. Weicht major.minor ab, endet `version --expect` mit Exit 50, aber **eine Prerelease-Engine warnt nur** ([EngineVersionChecker.cs](../src/CreativeCoders.ShadeKit.Core/Versions/EngineVersionChecker.cs)). Auf diesem Branch lautet die Engine-Version `0.9.0-rework-versioning-branch-mgmt.4`, und `--expect 0.8.0` wie `--expect 1.0.0` liefern `ok:true` (**FACT**, ausgeführt am 2026-11-21). Auf jedem Feature-Branch ist der Handshake damit faktisch abgeschaltet, während der Guard dort weiter auf exakter major.minor-Gleichheit besteht. Lokal wird der Ablehnungspfad nie geprüft. Dazu installiert eine Branch-Engine ohne `SHADE_KIT_MARKETPLACE_SOURCE` die Skills von GitHub `main`, also weder die Skills des Branches noch die, gegen die die Engine getestet wurde ([IntegrationService.cs](../src/CreativeCoders.ShadeKit.Core/Integrations/IntegrationService.cs)). + +Die Historie zeigt, wie teuer die Kopplung ist. Von den drei Anhebungen (0.7 → 0.8 → 0.9) waren **zwei reaktiv erzwungen**. Die erste kam, weil der neue Guard nach dem Tag `v0.8.0` fehlschlug. Die zweite kam, weil `shade-kit-new` die Option `feature new --move-source` brauchte, die 0.8-Engines nicht kennen ([06-2](../docs/feature-packages/06-2-skill-conventions-and-version.md), [09-Implementierung](../docs/implementation/09-discuss-and-intake.md)). Daran zeigt sich der Kern des Problems. Der Handshake kann „braucht Engine ≥ 0.9.1“ nicht ausdrücken, weil der Patch ignoriert wird. Deshalb erzwingt jede Abhängigkeit eines Skills von der Engine eine kitweite Minor-Anhebung über mehr als 20 Dateien plus `GitVersion.yml`, auch wenn 18 von 19 Skills unverändert sind. Umgekehrt zwingt eine reine Engine-Minor-Anhebung, alle Skills neu zu schreiben, obwohl sich kein Skill-Text geändert hat. Die eigene Dokumentation nennt den Widerspruch: Die Handanhebung „still breaks the rule in `GitVersion.yml` that no version is maintained by hand“ ([06-2](../docs/feature-packages/06-2-skill-conventions-and-version.md)). Eine Zahl soll gleichzeitig sagen, welcher Produkt-Build das ist (ändert sich mit jedem Commit, gehört GitVersion), und auf welchen CLI-Vertrag sich die Skills verlassen (sollte sich selten ändern, gehört den Autoren). Diese doppelte Bedeutung ist die eigentliche Ursache. + +## Fünf Optionen gegen die harten Grenzen des Repos + +Fünf Randbedingungen begrenzen jede Lösung. Für alle drei Agenten gibt es eine einzige Skill-Quelle ohne agentenspezifische Manifeste, abgesichert durch `SingleSkillSourceTests`. Es gibt keine Transformation beim Installieren. Das Plugin wird direkt aus dem Git-Baum am Tag oder an `main` installiert. Das Modell sieht das Frontmatter in Claude Code und Copilot nicht. Und der Parser ignoriert unbekannte Optionen still: `--expect=1.2.3` endet mit Exit 0 ohne Prüfung (**FACT**, [06-1](../docs/feature-packages/06-1-engine-version-check.md)). Die letzte Bedingung ist die am wenigsten offensichtliche und wird bei der Bewertung entscheidend. + +| Option | Änderungen pro normalem Release | Änderungen bei neuer, für Skills sichtbarer CLI-Funktion | Guard an GitVersion gekoppelt | Check auf Dev-Builds sinnvoll | Agentenneutral | Umbau der Integrationen | +|---|---|---|---|---|---|---| +| (a) Lockstep, automatisch gestempelt | 0–1 (Release-PR mergen) | kitweite Minor-Anhebung | ja | nein | ja | keiner | +| (b) Version aus mitgelieferter Datei | 1 Datei | kitweite Minor-Anhebung | ja | nein | **nein** (Pfad je Agent) | keiner | +| (c) Unabhängige Produkt-SemVer mit gegenseitigen Mindestversionen | 0 | Minimum anheben (leicht vergessen) | nein | **nein** (SemVer-Prerelease-Ordnung) | ja | **groß** | +| (d) Vertragsversion mit Fenster | **0** | 1 Konstante + 7 Zeilen, testgestützt | **nein** | **ja** | ja | keiner | +| (e) Reine Capability-Abfrage | 0 | Prüflogik in jedem Skill | nein | ja | ja | keiner | + +**(a) Automatisierter Lockstep** spart Tipparbeit, beseitigt aber keine Kopplung. Am besten passt hier release-please im Manifest-Modus. Es ist das einzige untersuchte Werkzeug, das vor dem Tag per Release-PR Versionen in beliebige Textdateien schreibt ([release-please manifest-releaser](https://raw.githubusercontent.com/googleapis/release-please/main/docs/manifest-releaser.md)). Sein Generic-Updater braucht allerdings Marker auf den Versionszeilen ([generic.ts](https://raw.githubusercontent.com/googleapis/release-please/main/src/updaters/generic.ts)). Ein Marker wie `version: 0.9.0 # x-release-please-version` bricht die Regex des Guards, der den Kommentar als Teil des Werts liest (**FACT**). Außerdem lösen Tags, die mit dem Standard-`GITHUB_TOKEN` erzeugt werden, vermutlich keine weiteren Workflows aus (**unverifiziert**). GitVersion, MinVer und Nerdbank.GitVersioning berechnen Versionen nur und schreiben nie in Markdown ([GitVersion 7.0 configuration](https://gitversion.net/7.0/docs/reference/configuration), [MinVer README](https://raw.githubusercontent.com/adamralph/minver/main/README.md), [NBGV version.json](https://dotnet.github.io/Nerdbank.GitVersioning/docs/versionJson.html)). Die Option lässt die Prerelease-Lücke, den Branch-installiert-`main`-Effekt und die fehlende Patch-Abhängigkeit unberührt. + +**(b) Version aus einer mitgelieferten Datei** scheitert an der Agentenneutralität. Claude Code ersetzt `${CLAUDE_SKILL_DIR}` und `${CLAUDE_PLUGIN_ROOT}` im Skill-Text und kann mit `` !`…` `` sogar vorab Befehle ausführen ([Claude Code skills docs](https://code.claude.com/docs/en/skills)). Ein fehlgeschlagener `` !`…` ``-Befehl bricht aber den ganzen Skill ab, also auch die Erklärung eines Exit 50. Copilot dokumentiert keine Ersetzung im `SKILL.md`, dort käme der Platzhalter wörtlich an ([Copilot CLI plugin reference](https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-plugin-reference)). Ob Copilot dem Modell einen absoluten Skill-Pfad nennt, ist **unverifiziert**. Codex nennt ihn nachweislich ([catalog_prompt.rs](https://github.com/openai/codex/blob/main/codex-rs/ext/skills/src/catalog_prompt.rs)). Ein `version` in `plugin.json` scheidet ebenfalls aus. Kein Agent gibt den Wert an das Modell weiter, und in Claude Code **friert er Nutzer auf dem Cache ein, bis sich der String ändert**. Das würde die SHA-basierten Updates auf dem `main`-Fallback stoppen ([Claude Code plugin loading](https://code.claude.com/docs/en/plugins/loading.md)). Die Variante, in der die Engine das Frontmatter über `--skill-dir` selbst liest, senkt nur die Zahl der Stellen und lässt die Kopplung bestehen. + +**(c) Unabhängige Produktversionen mit beidseitigen Mindestversionen** prüft der Bericht ausdrücklich, und die Idee ist richtig. In der Ausführung über Produkt-SemVer scheitert sie aber an drei Punkten. Erstens steht die Ableitung des Marketplace-Refs `v` auf dem Lockstep. Getrennte Ströme verlangen getrennte Tags (etwa `skills-v*`), ein Mapping „Engine-Version → passender Skills-Tag“, eine Tag-Liste statt eines `git ls-remote` pro Tag sowie Umbauten in `MarketplaceSource`, in allen drei `*Integration.cs` und in `release.yml`. Das ist laut Bestandsaufnahme die invasivste Variante. Zweitens fällt eine Mindestversion auf Produkt-SemVer genau beim lokalen Testen um: **Prereleases haben laut SemVer eine niedrigere Präzedenz als die zugehörige Release-Version** ([SemVer 2.0.0](https://semver.org/)). Ein Branch-Build `0.10.0-feature.4` erfüllt daher `>= 0.10.0` nicht. Terraform umgeht das, indem es Prereleases in Bereichen gar nicht matcht ([Terraform Version Constraints](https://developer.hashicorp.com/terraform/language/expressions/version-constraints)). Drittens ändern sich Produktversionen mit jedem Release. Ein daran gebundenes Minimum ist also verrauscht und wird leicht vergessen. Hinzu kommt, dass eine Skills-SemVer keinen Abnehmer hat. Claude Code versioniert das Plugin über den Commit-SHA, Codex über den festen Wert `local` ([openai/codex store.rs](https://github.com/openai/codex/blob/main/codex-rs/core-plugins/src/store.rs)), und `metadata.version` liest nur der eigene Guard. + +**(d) Eine eigene Vertragsversion** ist das Muster, auf das reife Host-Plugin-Systeme setzen. Das Terraform-Plugin-Protokoll v5/v6 ist unabhängig von der CLI-Version ([Terraform Plugin Protocol](https://developer.hashicorp.com/terraform/plugin/terraform-plugin-protocol)). Bei der Docker Engine API kennt der Daemon ein konfigurierbares Minimum und lehnt ältere Clients mit „client version 1.43 is too old. Minimum supported API version is 1.44“ ab ([Docker blog: Engine v29](https://www.docker.com/blog/docker-engine-version-29/)). MCP trennt `protocolVersion` von `serverInfo.version` ([MCP Lifecycle](https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle)). Im eigenen Repo existiert die Vorlage schon: ganzzahlige Formatversionen pro Datei, die sich „only when the structure changes, not with every engine release“ ändern, mit `minEngineVersion` und `formats` in `version --json` ([FormatRegistry.cs](../src/CreativeCoders.ShadeKit.Core/Formats/FormatRegistry.cs)). **(e) Reine Capability-Abfrage** nach LSP-Art ([LSP 3.17](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/)) würde Versionsnummern ganz abschaffen. Sie verlagert die Prüflogik aber in Markdown, das vom Modell ausgeführt wird, und genau dort ist sie am unzuverlässigsten. + +## Empfehlung: ein ganzzahliger CLI-Vertrag mit Docker-Fenster und striktem Guard + +Der Vertrag umfasst alles, worauf sich Skills verlassen: die agentenseitigen Befehle und Optionen, die Felder des `CliJsonEnvelope`, die Felder von `data`, sowie Error- und Warning-Codes. Heute hat er keine Version, das Envelope trägt nur `ok`, `data`, `warnings` und `error` (**FACT**, [CliJsonEnvelope.cs](../src/CreativeCoders.ShadeKit.Cli/Output/CliJsonEnvelope.cs)). Die Engine bekommt in `src/CreativeCoders.ShadeKit.Core/Versions/` eine Konstante nach dem Muster von `FormatRegistry`, etwa `CliContract.Current` und `CliContract.MinSupported`, beide zum Start `1`. `version --json` meldet sie neben `formats` als `data.contract`. Der Handshake der Skills lautet dann ``Version handshake: run `shade-kit version --json --expect-contract 1`; 1 is the CLI contract this skill is written for.`` Die Engine prüft das Docker-Fenster. Ist `R > Current`, sind die Skills neuer als die Engine; die Meldung lautet sinngemäß „update the engine“. Ist `R < MinSupported`, sind die Skills zu alt; die Meldung verweist auf `shade-kit integrations install`. Dazwischen ist die Prüfung erfolgreich. Beide Fehler bekommen eigene kebab-case Error-Codes, damit Skills deterministisch reagieren. Im Bereich 50–59 sind laut `ShadeKitCliExitCodes.cs` die Codes 54–59 noch nicht belegt (**FACT** per grep, Vergabe noch offen). Die Prerelease-Nachsicht entfällt für diesen Check. Sie war nur nötig, weil Branch-Builds eine andere Produktversion tragen, und die Vertragsnummer ist auf jedem Build desselben Codes identisch. + +`Current` steigt bei **jeder** für Skills sichtbaren Vertragsänderung, auch bei rein additiven. `MinSupported` steigt nur, wenn etwas entfernt oder umgedeutet wird. Der Guard sollte anfangs **strikt `R == Current`** verlangen statt nur `MinSupported ≤ R ≤ Current`. Das kostet bei einer Vertragsänderung sieben zusätzliche Zeilen. Der Grund ist der still ignorierende Parser. Ohne Kopplung könnte ein Skill eine neue Option benutzen und `R` nicht anheben. Eine ältere Engine im Fenster würde die unbekannte Option dann **still ignorieren und Exit 0 melden**, ein falsches Ergebnis ohne jedes Warnsignal. Die Literatur nennt „vergessen, das Minimum anzuheben“ als Hauptrisiko von Mindestversions-Schemata, ohne dafür ein Post-mortem zu belegen. Der strikte Guard schließt dieses Risiko mechanisch aus, und weil Release-Engine und Skills vom selben Tag stammen, verliert man nichts. Die Gegenrichtung sichert ein neuer **Snapshot-Test des Vertrags** (Vorschlag). Er erzeugt per Reflection über `[CliCommand]`, die Optionsattribute der `JsonCommandOptions`-Befehle, die `*CommandData`-Typen sowie `ShadeKitCliErrorCodes` und `ShadeKitCliWarningCodes` eine Textdatei und vergleicht sie mit einer eingecheckten Fassung, die die Vertragsnummer enthält. Ändert sich die Oberfläche ohne angehobenes `Current`, schlägt der Build fehl. Der neue Guard vergleicht nur noch Skill-Text mit einer Code-Konstante, also **ohne jede Abhängigkeit von GitVersion, Tags oder Branch**. + +Die Verteilung bleibt unverändert. `IntegrationService` installiert weiter den Tag `v` und fällt auf `main` zurück. Weil der Guard im Tag-Commit `R == Current` erzwingt, installiert eine Release-Engine immer Skills innerhalb ihres Fensters. Die Endlosschleife, die der ursprüngliche Guard verhindern sollte (Exit 50 → `integrations install` holt dieselben veralteten Skills), kann so nicht entstehen ([07](../docs/feature-packages/07-claude-code-integration.md)). Neu ist, dass der Check nun auch die Pfade über die Override-Variable und über `main` echt schützt. Die Produktversion der CLI lebt weiter allein bei GitVersion. `next-version` verliert seine Skill-Rolle und kann nach dem ersten Tag ab 0.9.0 durch `+semver: minor` in Commit-Nachrichten ersetzt werden. `commit-message-incrementing` ist standardmäßig aktiv ([GitVersion 7.0 configuration](https://gitversion.net/7.0/docs/reference/configuration)). Ob GitVersion `next-version` nach einem Tag ab dieser Version tatsächlich ignoriert, ist **unverifiziert**. Die Skills verlieren `metadata.version` ganz; die Release-Nummer des Kits ist der Tag. Wer später Skills in eigenem Takt veröffentlichen will, kann auf diesem Fundament nachrüsten, ohne den Check zu ändern: Der Installer wählt dann den neuesten `skills-v*`-Tag, dessen `R` im Fenster der Engine liegt. Nötig ist das heute nicht. + +Pro Ereignis sieht die Rechnung danach so aus. Ein normales Release (Engine-Fix, Skill-Textverbesserung, Formatänderung, Produkt-Minor) braucht **null** Versionsänderungen und nur den Tag. Eine neue, für Skills sichtbare CLI-Funktion braucht eine Konstante, die Freigabe des Snapshots und sieben gleichlautende Handshake-Zeilen. Die betroffenen Stellen nennt die Fehlermeldung des Guards, und ein Cake-Task zum Stempeln wäre optional. Ein Bruch des Vertrags braucht zusätzlich `MinSupported`. Heute kostet schon ein Produkt-Minor 26 Zeilen plus `GitVersion.yml`. + +## Migration in einem Zug vor dem ersten installierbaren Tag + +Der Zeitpunkt ist günstig. **Die Tags `v0.7.0` und `v0.8.0` enthalten kein `.claude-plugin/`. Installierbar ist erst der erste Tag mit Manifesten** (**FACT**, `git ls-tree v0.8.0`, [README.md](../docs/feature-packages/README.md)). Auch der `integrations`-Befehl kam erst nach `v0.8.0` (#34). Eine veröffentlichte Engine, die `--expect-contract` als unbekannte Option still schlucken würde, gibt es deshalb praktisch nicht. Ein Rest-Risiko bleibt bei Paketen, die zwischen den Tags aus `main` nach GitHub Packages gingen. Nach der Umstellung kennt jede Engine, die Skills installieren kann, die Option. Die harte Umstellung ohne Übergangsphase mit doppeltem `--expect` ist deshalb vertretbar. + +| Schritt | Dateien | Inhalt | +|---|---|---| +| Engine-Vertrag | `Core/Versions/` (neu `CliContract`, Checker), `VersionCommandOptions.cs`, `VersionCommand.cs`, `VersionCommandData.cs`, `CliErrorMapper.cs`, `ShadeKitCliExitCodes.cs`/`ShadeKitCliErrorCodes.cs` | `Current = MinSupported = 1`; `data.contract`; Option `--expect-contract ` mit `ICliValueConverter` (keine Ganzzahl oder fehlender Wert → Exit 2); Fensterprüfung mit zwei Fehlercodes; `--expect` und `EngineVersionChecker` samt Prerelease-Warnung entfernen | +| Handshake schlank machen (optional) | `VersionCommand.cs` | Bei `--expect-contract` die Integrationsabfrage überspringen. Heute startet jeder Handshake die Agent-CLIs (0,73 s mit `claude` auf dem `PATH` gegenüber 0,08 s ohne, [07](../docs/feature-packages/07-claude-code-integration.md)) | +| Skills | 5 Handshake-Schritte, 2 Befehlslisten, `shade-kit-next-steps/SKILL.md` (Ablehnungszeile), 19 Frontmatter | Neuer Handshake-Text mit `--expect-contract 1`; Reaktion auf die neuen Error-Codes; `metadata.version` entfernen | +| Guards | `SkillKitVersionTests` → `SkillContractTests`, neu `CliContractSnapshotTests` | Alle Handshakes nennen dieselbe Zahl, und sie ist gleich `CliContract.Current`; die Vertragsoberfläche entspricht dem Snapshot | +| Szenario-Tooling | `tests/skill-scenarios/generate_fixtures.py`, `checks/check_runs.py` | Vertragsnummer aus dem Handshake-Text statt aus dem Frontmatter von `shade-kit-next-steps`; erwarteter erster Befehl `--expect-contract `; Fixtures für „Skills zu neu“ und „Skills zu alt“ | +| Versionierung | `GitVersion.yml` | Kommentar zu `next-version` auf die reine Produktrolle umschreiben; später durch `+semver: minor` ersetzen | +| Doku | CLAUDE.md (Skill conventions, Befehlsbeispiele), 06-1, 06-2, 07 (FP07-AC2), 08, 18 (`kitVersion`), 19 (FP19-AC3, Vorschlag „Formatänderung ⇒ Minor“ streichen), Konzept §9.6, Konsistenzlog | Lockstep-Formulierungen ersetzen, etwa FP07-AC2: „installierte Skills liegen im Vertragsfenster der installierenden Engine“ | + +`IntegrationService`, `MarketplaceSource`, die drei Agent-Integrationen, `release.yml` und `SingleSkillSourceTests` bleiben unverändert. `SkillAgentWordingTests` ist nur betroffen, wenn der neue Handshake-Satz kanonisiert werden soll. + +## Lokales Testen: der Handshake prüft endlich auch Entwicklungsbuilds + +Lokal entfällt die Prerelease-Ausnahme, weil sie nicht mehr gebraucht wird. Die Branch-Engine aus `dotnet run --project src/CreativeCoders.ShadeKit.Cli` oder ein lokal gepacktes Tool trägt die Vertragsnummer des Codes und keine Branch-Version, und der Guard hängt nicht mehr davon ab, welche Tags lokal vorhanden sind. Für Skills aus dem Arbeitsbaum bleibt der dokumentierte Weg: + +```sh +SHADE_KIT_MARKETPLACE_SOURCE=$PWD dotnet run --project src/CreativeCoders.ShadeKit.Cli -- integrations install +dotnet run --project src/CreativeCoders.ShadeKit.Cli -- version --json --expect-contract 1 +``` + +Claude Code lädt Plugins mit relativem Pfad aus einem Marketplace, der über einen lokalen Pfad hinzugefügt wurde, **an Ort und Stelle**. Änderungen wirken ab der nächsten Session oder nach `/reload-plugins`, ohne Versionsanhebung ([Claude Code plugin loading](https://code.claude.com/docs/en/plugins/loading.md)). `claude --plugin-dir .` geht ebenfalls ohne Engine. Copilot CLI lädt Plugins aus einem Verzeichnis-Marketplace seit 1.0.81 live ([Copilot CLI changelog](https://github.com/github/copilot-cli/blob/main/changelog.md)). Codex kopiert in den Cache-Ordner `local` ([Codex build plugins](https://developers.openai.com/codex/plugins/build)). Ob Codex Änderungen ohne erneutes `integrations update` übernimmt, ist **unverifiziert**. + +Neu ist, dass die Prüfung zwischen Branch und Installation **echt** arbeitet. Hebt ein Branch `Current` an und ändert die Skills, während noch `main`-Skills installiert sind, meldet der Handshake korrekt „Skills zu alt“, sobald `MinSupported` steigt. Ist die Änderung nur additiv, läuft er weiter. Im umgekehrten Fall, neue Skills mit alter Engine, verlangt der Handshake ein Engine-Update. Den Ablehnungspfad testen E2E-Tests und Szenario-Fixtures mit einer beliebigen Zahl, etwa `--expect-contract 999`. Dafür braucht es keinen Release-Build und keinen Tag mehr. Unverändert bleibt ein Nebenbefund: `init` schreibt die Prerelease-Version eines Branch-Builds als `kitVersion` in `config.json` und `templates.lock.json` des Zielrepos ([RepositoryInitializer.cs](../src/CreativeCoders.ShadeKit.Core/Init/RepositoryInitializer.cs)). Das gehört in Paket 18 (`upgrade`) und nicht zu diesem Umbau. + +Zwei Annahmen sollte ein Szenariolauf vor dem Umbau bestätigen. Erstens, dass alle drei Agenten den Handshake-Satz im Fließtext unverändert ausführen. Das gilt heute schon, gehört aber mit dem neuen Wortlaut erneut geprüft. Zweitens, wie Copilot und Codex den Skill-Pfad nennen, falls man die Handshake-Zeilen später über eine Datei im Plugin auf null reduzieren will. Bis das für alle drei Agenten belegt ist, bleibt die Zahl im Text die einzige verlustfreie, agentenneutrale Form. + +## Fazit + +Der Versionswechsel bringt vor allem eine neue Zuordnung von Zuständigkeiten. Die Produktversion beantwortet „welcher Build“ und gehört GitVersion. Die Vertragsnummer beantwortet „passt das zusammen“ und gehört den Autoren, mit einem Snapshot-Test als Gedächtnis. Die gefragte Option unabhängiger Versionen mit gegenseitigen Minima ist damit nicht verworfen, sondern auf die einzige Achse gelegt, auf der sie ohne SemVer-Prerelease-Fallen, ohne zweiten Release-Strom und ohne Umbau des Installers funktioniert. Den Ausschlag für den strikten Guard gibt ein Detail des eigenen Parsers: Weil unbekannte Optionen still ignoriert werden, wäre ein lockeres Minimum gefährlicher als gar keines. + +Bemerkenswert ist, dass der heutige Lockstep beim lokalen Testen weder streng noch nützlich ist. Er blockiert den Build über den Guard und winkt die Laufzeit über die Prerelease-Ausnahme durch. Der Vertrag kehrt das um: Der Build ist unabhängig von Tags und Branch reproduzierbar, und die Laufzeitprüfung greift auf jedem Build. Weil noch kein installierbares Release existiert, ist der Umbau jetzt am billigsten. Nach dem ersten Tag mit Manifesten bräuchte er eine Übergangsphase mit doppeltem Handshake. diff --git a/research_notes/Versionierung von CLI und Skills/agent_plugin_versioning.md b/research_notes/Versionierung von CLI und Skills/agent_plugin_versioning.md new file mode 100644 index 0000000..15d4034 --- /dev/null +++ b/research_notes/Versionierung von CLI und Skills/agent_plugin_versioning.md @@ -0,0 +1,267 @@ +# Plugin and skill versioning in Claude Code, GitHub Copilot CLI, and OpenAI Codex CLI, and how a skill finds its own version or bundled data at runtime + +Research date: 2026-11-21. Local agent versions checked on this machine: Claude Code 2.1.330 (`claude --version`), GitHub Copilot CLI 1.0.114 (`copilot --version`). Codex CLI is not installed locally; Codex facts come from the docs and the `openai/codex` source on `main` (latest release `rust-v0.171.0`, 2026-11-20, from `gh api repos/openai/codex/releases/latest`). + +Labels: **FACT** = checked against a primary source (official docs, the agent's source code or changelog, or the installed binary or files on this machine). **Unverified** = not confirmed. + +Context: shade-kit's `.claude-plugin/marketplace.json` lists one plugin `shade-kit` with `"source": "./"` (the marketplace root). Neither the entry nor `plugin.json` sets a `version` (**FACT**, read from the repository file). + +--- + +## Q1. Claude Code: what plugin.json `version` means, update detection, caching, `ref`/`sha`, and `claude plugin update` + +### Takeaway +Claude Code computes one "version" per installed plugin and uses it both as the update check and as the cache directory name. The lookup order is: `plugin.json` `version`, then the marketplace entry's `version`, then a value from the source type. For a relative-path plugin in a Git-hosted marketplace (shade-kit's case), the fallback is the commit SHA. A pinned `version` freezes users on the cached copy until the string changes. A marketplace added from a local path loads the plugin in place, so edits show up without any version change. + +### Cited Findings +- **FACT** `plugin.json` `version`: "A version string, not checked against semver. Setting it pins the plugin to that version until you change it". The pin doesn't apply to `command`-source plugins, to plugins from a marketplace hosted on claude.ai, or to plugins loaded in place from a marketplace added from a local path. [Plugin manifest reference](https://code.claude.com/docs/en/plugins-reference) +- **FACT** "Claude Code computes a version for every plugin it installs, and that version is how it detects an update. `claude plugin update` and background auto-update compute the version again and don't replace the cached copy when it matches what `installed_plugins.json` records." "The version also names the plugin's cache directory." [Plugin loading reference: Versions and updates](https://code.claude.com/docs/en/plugins/loading.md) +- **FACT** Resolution order, quoted: "1. The `version` field in the plugin's manifest comes first 2. Then the `version` field in the plugin's marketplace entry 3. When neither is set, the version comes from the source type". The source-type fallbacks are: + - `github`, `url`, `git-subdir`: "The commit SHA of the source, shortened to 12 characters". + - "Relative path inside a Git-hosted marketplace": "The commit SHA of the installed directory". + - A local directory that is not a git repository: `unknown`. + - `npm`: `unknown`. + - `archive`: the SHA-256 digest, shortened to 12 characters. + + [Plugin loading reference](https://code.claude.com/docs/en/plugins/loading.md) +- **FACT** "a manifest that pins `"version": "1.0.0"` keeps every user on the cached copy until its author changes the string, however many commits they push. To let users track commits instead, leave `version` out of both the manifest and the entry." [Plugin loading reference](https://code.claude.com/docs/en/plugins/loading.md) +- **FACT** Manifest `version` takes precedence over the marketplace entry `version`. `claude plugin validate` warns `Entry declares version "x" but /plugin.json says "y". At install time, plugin.json wins`. [Plugin manifest reference: Metadata precedence](https://code.claude.com/docs/en/plugins-reference); [Marketplace reference](https://code.claude.com/docs/en/plugins/marketplace-reference.md) +- **FACT** `claude plugin validate` reports a missing `version` as a warning, and `--strict` turns warnings into failures. [Plugin manifest reference](https://code.claude.com/docs/en/plugins-reference) +- **FACT** Cache layout: `cache////`, "`${CLAUDE_PLUGIN_ROOT}` points at this directory". `installed_plugins.json` records `scope`, `installPath`, and `version`. The plugins root is `~/.claude/plugins`, or `CLAUDE_CODE_PLUGIN_CACHE_DIR` when set. When a plugin is updated or uninstalled, the previous version directory gets an `.orphaned_at` marker and is removed 14 days later. [Plugin loading reference](https://code.claude.com/docs/en/plugins/loading.md) +- **FACT** (local, Claude Code 2.1.330) `~/.claude/plugins/installed_plugins.json` on this machine shows both schemes side by side: + - Unversioned plugins are cached under a 12-character SHA, for example `cc-ai-dev@creativecoders-ai-store` → `cache/creativecoders-ai-store/cc-ai-dev/4972bfa14908`, and `github@claude-plugins-official` → `.../github/73c8cf3ea7e2`, with eight SHA directories accumulated. + - Versioned plugins are cached under the version string, for example `superpowers` → `.../superpowers/7.0.2` and `security-guidance` → `.../2.0.17` … `2.0.21`. +- **FACT** Plugin sources `github`, `url`, and `git-subdir` take `ref` ("a branch or tag. Defaults to the repository's default branch") and `sha` ("a full 40-character lowercase commit SHA. When you set both `ref` and `sha`, Claude Code checks out `sha`"). [Marketplace reference: Plugin sources](https://code.claude.com/docs/en/plugins/marketplace-reference.md) +- **FACT** Marketplace sources: `claude plugin marketplace add` accepts `owner/repo`, `owner/repo@ref`, or `owner/repo#ref` for `github`, and `#ref` for `git`. A full commit SHA as a marketplace `ref` "requires Claude Code v2.1.324 or later". [Marketplace reference: Marketplace sources](https://code.claude.com/docs/en/plugins/marketplace-reference.md) +- **FACT** The marketplace file itself can carry a top-level `version` (or `metadata.version`) as the "Marketplace manifest version". Entry and plugin `metadata` are free-form, and "Claude Code doesn't read it". [Marketplace reference](https://code.claude.com/docs/en/plugins/marketplace-reference.md) +- **FACT** Changelog history: + - 2.1.14 "Added support for pinning plugins to specific git commit SHAs". + - 2.1.97 "Fixed `claude plugin update` reporting 'already at the latest version' for git-based marketplace plugins when the remote had newer commits". + - 2.1.118 "Added `claude plugin tag` to create release git tags for plugins with version validation". + - 2.1.323 "Added `engines["claude-code"]` to `plugin.json`". + + [Claude Code CHANGELOG](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md) +- **FACT** Before an install, Claude Code refreshes the named marketplace only for `claude plugin install name@marketplace`. The refresh is skipped for a marketplace added from a local `file`/`directory` source. Auto-update is off by default for third-party marketplaces. [Plugin loading reference](https://code.claude.com/docs/en/plugins/loading.md) +- **FACT** `engines: { "claude-code": "" }` in `plugin.json` or in a marketplace entry: "plugins outside their stated Claude Code version range are not installed, updated or loaded". It requires 2.1.323+, and 2.0.15–2.1.75 reject a manifest that has the field. It constrains the agent's version, not an external CLI. [Plugin manifest reference](https://code.claude.com/docs/en/plugins-reference); [CHANGELOG 2.1.323](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md) +- **FACT** Plugin-to-plugin `dependencies` with semver ranges resolve against git tags named `--v`. `claude plugin tag` creates such a tag after checking that `plugin.json` and the marketplace entry agree on the version. "Constraint checks use the tag's version rather than the `version` in `plugin.json`". A tag-resolved dependency shows as e.g. `2.1.0-8713c5b11005`. [Plugin dependencies](https://code.claude.com/docs/en/plugins/dependencies.md) + +### Inferences +- shade-kit today (relative path `./`, no `version`) gets the commit SHA as its Claude Code version. Every commit on the installed ref counts as an update. That is the documented "track commits" mode, and it fits installs from a tag because the tag's commit is fixed. +- If shade-kit set `plugin.json` `version`, Claude Code would stop treating new commits on `main` as updates until the string changed. That matters for the `main` fallback ref the engine uses for prereleases. +- No Claude Code mechanism pins a dependency on an external, non-plugin binary such as the `shade-kit` CLI. `engines` covers only `claude-code`, and `dependencies` covers only plugins. + +### Gaps +- I found no documentation on whether `claude plugin list --json` exposes the marketplace `ref`. The engine already relies on that output, so check it against the existing engine code. + +--- + +## Q2. Claude Code: what the model sees when a skill loads (base directory, frontmatter, substitutions), bundled files, and local development + +### Takeaway +Claude Code offers the richest runtime hooks of the three agents. It substitutes `${CLAUDE_SKILL_DIR}`, `${CLAUDE_PLUGIN_ROOT}`, `${CLAUDE_PLUGIN_DATA}`, `${CLAUDE_PROJECT_DIR}`, `${CLAUDE_SESSION_ID}`, `$ARGUMENTS`, and `${user_config.KEY}` in the skill body. It runs `` !`command` `` placeholders before the model sees the content. It also starts injected skill content with a "Base directory for this skill: " line. The frontmatter (including `metadata`) is not acted on, and the shade-kit team observed that the model doesn't receive it. + +### Cited Findings +- **FACT** String substitutions in `SKILL.md`, quoted from the docs: + - `${CLAUDE_SKILL_DIR}`: "The directory containing the skill's `SKILL.md` file. For plugin skills, this is the skill's subdirectory within the plugin, not the plugin root." + - `${CLAUDE_PLUGIN_ROOT}`: "The plugin's installation directory. Substituted only in plugin skills." + - `${CLAUDE_PLUGIN_DATA}`: "The plugin's persistent data directory, which survives plugin updates." + - Also `${CLAUDE_PROJECT_DIR}`, `${CLAUDE_SESSION_ID}`, `${CLAUDE_EFFORT}`, `$ARGUMENTS`, `$ARGUMENTS[N]`/`$N`, and `$name`. + + [Claude Code skills docs](https://code.claude.com/docs/en/skills) +- **FACT** `${CLAUDE_SKILL_DIR}` was "Added ... for skills to reference their own directory in SKILL.md content" in Claude Code 2.1.69. [CHANGELOG 2.1.69](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md) +- **FACT** Path variables in "Skill, command, and agent content" resolve "Anywhere in the Markdown body". "The variables aren't present in the environment of commands Claude runs through the Bash tool ... write the `${...}` reference in the Markdown body instead, and Claude Code substitutes the path inline when it loads the content." [Plugin manifest reference: Environment variables](https://code.claude.com/docs/en/plugins-reference) +- **FACT** `${user_config.KEY}` is substituted in "skill and agent content" (non-sensitive values only). [Plugin manifest reference](https://code.claude.com/docs/en/plugins-reference) +- **FACT** Dynamic context injection: "The `` !`` `` syntax runs shell commands before the skill content is sent to Claude. The command output replaces the placeholder". Further rules from the same page: + - "A failed command aborts the entire skill invocation". + - It can be turned off by policy with `"disableSkillShellExecution": true`. + - A fenced ```` ```! ```` block is the multi-line form. + + [Claude Code skills docs](https://code.claude.com/docs/en/skills) +- **FACT** Officially recommended pattern for bundled scripts: ``Run `${CLAUDE_SKILL_DIR}/scripts/render.sh ` ``, with `allowed-tools: Bash(${CLAUDE_SKILL_DIR}/scripts/render.sh *)`. Supporting docs are linked relatively (`[reference.md](reference.md)`). [Claude Code skills docs](https://code.claude.com/docs/en/skills) +- **FACT** `metadata` frontmatter is a "Free-form YAML map for your own key-value data ... read by your own tooling from `SKILL.md`. Claude Code doesn't act on its contents". The docs list no `version` frontmatter field. [Claude Code skills docs](https://code.claude.com/docs/en/skills) +- **FACT** (local binary, Claude Code 2.1.330) The binary contains the literal `Base directory for this skill: `. It also contains a function that treats content starting with `"Base directory for this skill: "`, `"ARGUMENTS: "`, `"Skill arguments: "`, or `""` as injected skill prefixes. Found with `strings`/`grep -a` on `/opt/homebrew/Caskroom/claude-code@latest/2.1.330/claude`. The exact template that builds the line was not extracted. +- **FACT** (third party, consistent with the binary) Issue trackers describe the "Base directory for this skill" line that Claude Code adds when a skill loads, and models deriving script paths from it when `$CLAUDE_PLUGIN_ROOT` is empty in Bash. [anthropics/claude-code#12541](https://github.com/anthropics/claude-code/issues/12541); [anthropics/claude-code#19922](https://github.com/anthropics/claude-code/issues/19922); [pandas-studio/agent-team-plugins#208](https://github.com/pandas-studio/agent-team-plugins/issues/208); [bjcoombs/ai-native-toolkit#329](https://github.com/bjcoombs/ai-native-toolkit/issues/329) +- **FACT** (project observation, already recorded in shade-kit CLAUDE.md / FP 06-2) Claude Code 2.1.x doesn't show the frontmatter to the model for project-level skills. +- **FACT** Local plugin development: + - "`--plugin-dir` and skills-directory plugins: the directory loads in place and is never copied". + - "Relative-path plugins in a marketplace you added from a local path: the plugin loads in place ... Your edits to the source directory take effect at the next session start or `/reload-plugins`, and you don't need to increase the version." + - A `--plugin-dir` plugin with the same manifest name replaces an installed marketplace plugin (id `@inline`). + + [Plugin loading reference](https://code.claude.com/docs/en/plugins/loading.md) +- **FACT** Skill files under `~/.claude/skills/` and `.claude/skills/` are watched live. Plugin `agents/`, `.mcp.json`, and `hooks/` need `/reload-plugins`. [Claude Code skills docs](https://code.claude.com/docs/en/skills) +- **FACT** `bin/` at the plugin root: "Files here are on the Bash tool's `PATH` while the plugin is enabled". claude.ai/Cowork don't install a plugin that has this directory. [Plugin manifest reference: Standard layout](https://code.claude.com/docs/en/plugins-reference) + +### Inferences +- In Claude Code, a skill can reach a bundled file without hardcoding anything. Examples: ``run `shade-kit version --json --expect-file ${CLAUDE_PLUGIN_ROOT}/VERSION` `` or `${CLAUDE_SKILL_DIR}/../../VERSION`. With `` !`...` ``, the handshake could even run before the model reads the skill. Both forms are Claude-only syntax (see Q5 and Q6). +- `` !`...` `` aborts the whole skill on a non-zero exit. A handshake that returns exit code 50 on a mismatch would abort the skill instead of letting the skill explain the mismatch, unless the command always exits 0. +- `${CLAUDE_PLUGIN_ROOT}` changes with every version, because it points at the version directory. It is correct for reading bundled files and must not be used for state. + +### Gaps +- The exact wording and position of the "Base directory" line (always the first line? absolute path? also for plugin skills?) were not captured from a live session. A skill-scenario run could confirm it. +- No official Claude Code doc page states that the frontmatter is stripped before injection. That rests on the project observation. + +--- + +## Q3. GitHub Copilot CLI: plugin format, manifests, versions, skill loading, path exposure, local development + +### Takeaway +Copilot CLI reads `.claude-plugin/plugin.json` and `.claude-plugin/marketplace.json` as legacy-compatible manifests. It supports `ref`/`sha` pins, installs to `~/.copilot/installed-plugins//`, and loads local directory marketplaces live. It strips the frontmatter from injected skill content (since 1.0.48). It documents no variable substitution in `SKILL.md`; `PLUGIN_ROOT`/`CLAUDE_PLUGIN_ROOT` reach only hooks, MCP, LSP, and agent `mcp-servers`. Whether the model is told the skill's directory is only implied by the docs. + +### Cited Findings +- **FACT** Manifest lookup: Agent Plugins 1.0 "requires the manifest at the plugin root". For legacy plugins it checks "`.github/plugin/plugin.json`, or `.claude-plugin/plugin.json` (checked in this order)". Marketplaces: "`.github/plugin/marketplace.json`, or `.claude-plugin/marketplace.json` (checked in this order)". [Copilot CLI plugin reference](https://docs.github.com/en/copilot/reference/cli-plugin-reference) +- **FACT** `version`: for legacy manifests a "Semantic version (e.g., `1.0.0`)", for Agent Plugins 1.0 "Version string. Semantic Versioning is recommended." Optional in both. `/plugin` "flags an installed plugin or marketplace when a newer version is available upstream". The docs don't say whether this compares version strings or commit SHAs. [Copilot CLI plugin reference](https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-plugin-reference) +- **FACT** Marketplace pins: `copilot plugin marketplace add` accepts `owner/repo#ref`. Entry sources `github`/`url` accept `ref` and `sha` ("must be a full 40-character commit SHA", "immune to force-pushes or tag/branch moves"). [Copilot CLI plugin reference](https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-plugin-reference) +- **FACT** `copilot plugin list --json` rows have the shape `{ name, marketplace?, version?, enabled, source, installedFrom? }`. 1.0.85 changed the output to a flat array. [Copilot CLI plugin reference](https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-plugin-reference); [Copilot CLI changelog](https://github.com/github/copilot-cli/blob/main/changelog.md) +- **FACT** Paths: + - Installs: `~/.copilot/installed-plugins/MARKETPLACE/PLUGIN-NAME` (no version segment) and `~/.copilot/installed-plugins/_direct/SOURCE-ID/`. + - Marketplace cache: `~/Library/Caches/copilot/marketplaces/` (macOS) or `~/.cache/copilot/marketplaces/` (Linux), overridable with `COPILOT_CACHE_HOME`. + + [Copilot CLI plugin reference](https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-plugin-reference) +- **FACT** Update behaviour: + - `copilot plugin update NAME` or `--all`. + - "Path-sourced plugins in a local (directory-source) marketplace now load live from their real directory, so editing one takes effect on `/restart` or a new session — no `/plugin update`" (1.0.81). + - Opt-in `autoUpdate: true` on `extraKnownMarketplaces` (1.0.79). + + [Copilot CLI changelog](https://github.com/github/copilot-cli/blob/main/changelog.md); [plugin reference](https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-plugin-reference) +- **FACT** Frontmatter: "Skill content injected to the model no longer includes YAML frontmatter metadata" (Copilot CLI 1.0.48). [Copilot CLI changelog](https://github.com/github/copilot-cli/blob/main/changelog.md) +- **FACT** Variables: + - `${PLUGIN_ROOT}`/`${PLUGIN_DATA}` (aliases `CLAUDE_PLUGIN_DATA`, `COPILOT_PLUGIN_DATA`) are expanded in stdio MCP `args`/`env`/`cwd`, LSP config, and plugin-shipped agent `mcp-servers` frontmatter. + - 1.0.26: "Plugin hooks receive PLUGIN_ROOT, COPILOT_PLUGIN_ROOT, and CLAUDE_PLUGIN_ROOT env vars". 1.0.111: "Expand ${COPILOT_PLUGIN_ROOT} in plugin hook working directories and environment values". + - The docs describe no substitution in `SKILL.md` content. + + [Copilot CLI plugin reference](https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-plugin-reference); [Copilot CLI changelog](https://github.com/github/copilot-cli/blob/main/changelog.md) +- **FACT** Skill docs: + - Bundled resources: "include scripts or other resources in the skill directory and reference them in your `SKILL.md` instructions". The example instruction is "run the `convert-svg-to-png.sh` script from this skill's base directory". + - When a skill is invoked, Copilot "automatically discovers all of the files in the skill's directory and makes them available alongside the skill's instructions". + - Locations: `.github/skills`, `.claude/skills`, `.agents/skills` (project), `~/.copilot/skills`, `~/.agents/skills` (personal). + - Reload with `/skills reload`. + + [Copilot CLI: create skills](https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/create-skills) +- **FACT** Agent Plugins 1.0 is "an open standard that packages agent skills and MCP servers into one installable plugin". It is governed independently of any one vendor (AWS, Anysphere, Microsoft, OpenAI, Vercel, Google) and supported in VS Code, Copilot CLI, the Copilot SDK, and the Copilot app. Existing plugins need no migration. Spec: https://github.com/agentplugins/agent-plugins-spec/blob/main/spec/1.0.0.md. [GitHub changelog 2026-08-12](https://github.blog/changelog/2026-08-12-agent-plugins-1-0-in-vs-code-copilot-cli-and-the-copilot-app) + +### Inferences +- `${CLAUDE_SKILL_DIR}` and `${CLAUDE_PLUGIN_ROOT}` in a skill body most likely reach the Copilot model as literal text. The docs document no SKILL.md substitution; not tested. +- The install path has no version segment, so on Copilot the plugin's on-disk location stays stable across updates, unlike Claude Code. + +### Gaps +- **Unverified**: whether Copilot's skill injection includes an explicit absolute skill-directory path. The Copilot 1.0.114 binary is a compressed Mach-O and plain string search found nothing. The npm package `@github/copilot@1.0.114` contains only a loader. The docs' "this skill's base directory" wording suggests it does. +- **Unverified**: how Copilot detects "a newer version upstream" for a plugin without a `version` (commit SHA or nothing). +- I didn't read the Agent Plugins 1.0 spec text itself (version semantics, variables). + +--- + +## Q4. OpenAI Codex CLI: plugins, marketplaces, versions, reported refs, how skills reach the model, local folders + +### Takeaway +Codex lists every skill to the model with its file path. The model reads `SKILL.md` itself and is told to resolve relative paths against that file's directory. This makes "the skill's own directory" portable on Codex, and the model also sees the raw frontmatter. Codex plugins take `version` from the manifest. When it is missing, the cache segment is the fixed string `local` (legacy) or `1.0.0` (Agent Plugins), never a commit SHA. Codex documents no SKILL.md variable substitution. + +### Cited Findings +- **FACT** Codex's skill catalog prompt (source `codex-rs/ext/skills/src/catalog_prompt.rs`, last changed 2026-10-27, commit `2edc8dc`), quoted: + - "Each entry includes a name, description, and source locator. `file` locators are on the host filesystem". + - Usage rule 1: "After deciding to use a skill, the main agent must read its `SKILL.md` completely before taking task actions. For a `file` entry, open the listed path." + - The host-alias variant says: "When `SKILL.md` references relative paths (e.g., `scripts/foo.py`), resolve them relative to the directory containing that expanded `SKILL.md` first", and "If `scripts/` exist, prefer running or patching them". + + [openai/codex catalog_prompt.rs](https://github.com/openai/codex/blob/main/codex-rs/ext/skills/src/catalog_prompt.rs) +- **FACT** Docs: Codex starts with "each skill's name and description" and its initial list also includes "each skill's file path". The list budget is 2% of the context window or 8,000 characters, and `skills.max_context_tokens` raises it. Skill locations: `.agents/skills` from the working directory up to the repository root, `$HOME/.agents/skills`, `/etc/codex/skills`, and bundled system skills. "Codex detects skill changes automatically", restart if not. No variable substitution is described. [Codex: build skills](https://learn.chatgpt.com/docs/build-skills) (redirect target of developers.openai.com/codex/skills) +- **FACT** Codex parses only `name`, `description`, and `metadata.short-description` from the frontmatter (`struct SkillFrontmatter` / `SkillFrontmatterMetadata`). [openai/codex skills/src/parser.rs](https://github.com/openai/codex/blob/main/codex-rs/skills/src/parser.rs) +- **FACT** Manifests: + - The portable entry point is a root `plugin.json`, with "Existing `.codex-plugin/plugin.json` files remain supported as a compatibility fallback". OpenAI "also accepts legacy and Claude-compatible manifests". The source tests reference `.claude-plugin/plugin.json` as `ALTERNATE_PLUGIN_MANIFEST_RELATIVE_PATH`. + - Marketplaces: `$REPO_ROOT/.agents/plugins/marketplace.json`, `~/.agents/plugins/marketplace.json`, and the legacy-compatible `$REPO_ROOT/.claude-plugin/marketplace.json`. + + [Codex: build plugins](https://developers.openai.com/codex/plugins/build); [openai/codex core-plugins/src/manifest.rs](https://github.com/openai/codex/blob/main/codex-rs/core-plugins/src/manifest.rs) +- **FACT** Cache: `~/.codex/plugins/cache/$MARKETPLACE_NAME/$PLUGIN_NAME/$VERSION/`, "For local plugins, `$VERSION` is `local`". `codex plugin marketplace upgrade` refreshes configured marketplaces. [Codex: build plugins](https://developers.openai.com/codex/plugins/build) +- **FACT** Source: `plugin_version_for_install_manifest` uses the manifest `version` when present. Otherwise it uses `DEFAULT_AGENT_PLUGIN_VERSION = "1.0.0"` for Agent Plugins or `DEFAULT_PLUGIN_VERSION = "local"` for others. An invalid version string on an Agent Plugin becomes `agent-plugins-`. [openai/codex core-plugins/src/store.rs](https://github.com/openai/codex/blob/main/codex-rs/core-plugins/src/store.rs); [core-plugin-common/src/installed.rs](https://github.com/openai/codex/blob/main/codex-rs/core-plugin-common/src/installed.rs) +- **FACT** (project, CLAUDE.md) Codex reports no marketplace ref, has no `plugin update` (`codex plugin add` installs or replaces), and shade-kit's `version` reports Codex `kitVersion`/`ref` as `null`. + +### Inferences +- On Codex the model opens `SKILL.md` with a file read, so it sees the whole file, frontmatter included. A `metadata.version` in the frontmatter is therefore visible to the Codex model, unlike in Claude Code and Copilot. This follows from the "open the listed path ... read its SKILL.md completely" rule; not tested in a live session. +- Because the model knows the absolute `SKILL.md` path, a Codex skill can run "the `VERSION` file two directories above this skill's `SKILL.md`" or "this skill's `scripts/x`" without any substitution. +- Without `version`, a Codex update replaces the files in the same `local` directory. A `version` in `plugin.json` would give per-version cache directories on Codex. + +### Gaps +- I didn't check whether `codex plugin list --json` shows the manifest `version`. +- No live Codex session was run to see the exact rendered skill entry (absolute path or alias plus roots table). + +--- + +## Q5. Agent Skills standard (agentskills.io): `metadata`, `version`, `compatibility`, bundled resources + +### Takeaway +The spec has no top-level `version` field. `metadata` is a free string-to-string map, and the spec's own example puts `version: "1.0"` there, quoted. `compatibility` is free text (at most 500 characters) for environment requirements and is not machine-checkable. Bundled files are referenced by paths relative to the skill root, kept one level deep. + +### Cited Findings +- **FACT** Frontmatter fields: `name` (required, must match the directory name), `description` (required), `license`, `compatibility`, `metadata`, and `allowed-tools` (experimental). [Agent Skills specification](https://agentskills.io/specification) +- **FACT** `metadata`: "A map from string keys to string values. Clients can use this to store additional properties not defined by the Agent Skills spec. We recommend making your key names reasonably unique". The example is `metadata: { author: example-org, version: "1.0" }`. [Agent Skills specification](https://agentskills.io/specification) +- **FACT** `compatibility`: "Max 500 characters. Indicates environment requirements (intended product, system packages, network access, etc.)", with examples "Requires git, docker, jq, and access to the internet" and "Requires Python 3.14+ and uv". "Most skills do not need the `compatibility` field." [Agent Skills specification](https://agentskills.io/specification) +- **FACT** File references: "use relative paths from the skill root: `See [the reference guide](references/REFERENCE.md)` ... `scripts/extract.py`". "Keep file references one level deep from `SKILL.md`." Optional directories: `scripts/`, `references/`, `assets/` (templates, data files, schemas). [Agent Skills specification](https://agentskills.io/specification) +- **FACT** Claude Code rejects non-spec fields "Outside Claude Code" with the error "Unexpected key(s) in SKILL.md frontmatter ... Allowed properties are: allowed-tools, compatibility, description, license, metadata, name". [Claude Code skills docs](https://code.claude.com/docs/en/skills) + +### Inferences +- shade-kit writes `metadata.version: 0.9.0` unquoted. The spec says the values are strings, so a strict validator could read the value as a YAML string anyway (`0.9.0` is not a valid YAML number). Strings like `1.0` would need quotes. +- `compatibility` could carry a human-readable "Requires shade-kit CLI >= 0.9" note, but no agent checks it, and the model doesn't see the frontmatter in Claude Code or Copilot. + +### Gaps +- None material. + +--- + +## Q6. Across all three: the most portable way for a skill to get a version or compatibility value at runtime without hardcoding it in the body + +### Takeaway +No substitution syntax works in all three agents. `${CLAUDE_SKILL_DIR}`, `${CLAUDE_PLUGIN_ROOT}`, and `` !`...` `` are Claude Code only. The common ground is that each agent shows the model where the skill lives: +- Claude Code: the "Base directory for this skill:" line, plus substitution. +- Codex: the listed `SKILL.md` path and its relative-path rule. +- Copilot: implied by "this skill's base directory" in its docs. + +The most portable pattern is to tell the model, in plain words, to pass "this skill's directory" (or a file relative to it) to the CLI. That is the same wording superpowers uses for its bundled scripts. A Claude-only `${CLAUDE_SKILL_DIR}` form would add precision but would arrive as literal text in the other agents. + +### Cited Findings +- **FACT** Claude Code: `${CLAUDE_SKILL_DIR}` and `${CLAUDE_PLUGIN_ROOT}` are substituted in the skill body ([skills docs](https://code.claude.com/docs/en/skills)), and the binary carries the "Base directory for this skill: " prefix (local 2.1.330). +- **FACT** Codex: the model gets each skill's file path and is told to "resolve them relative to the directory containing that expanded `SKILL.md`". [catalog_prompt.rs](https://github.com/openai/codex/blob/main/codex-rs/ext/skills/src/catalog_prompt.rs) +- **FACT** Copilot: the docs use "run the ... script from this skill's base directory" and say the skill directory's files are made "available alongside the skill's instructions". No SKILL.md substitution is documented. [Copilot create skills](https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/create-skills) +- **FACT** Frontmatter: Claude Code doesn't act on `metadata` ([skills docs](https://code.claude.com/docs/en/skills)), Copilot strips frontmatter from injected content since 1.0.48 ([changelog](https://github.com/github/copilot-cli/blob/main/changelog.md)), and Codex parses only `name`/`description`/`metadata.short-description` but has the model read the raw file ([parser.rs](https://github.com/openai/codex/blob/main/codex-rs/skills/src/parser.rs)). +- **FACT** Claude Code's `${...}` path variables are not exported to Bash-tool processes ([plugins reference](https://code.claude.com/docs/en/plugins-reference)). The CLI cannot read `CLAUDE_PLUGIN_ROOT` from its environment when the model runs it; the path has to be in the command line. +- **FACT** (local plugin cache) superpowers 7.0.2 writes agent-neutral instructions: "Run this skill's `scripts/task-start PLAN_FILE N` by its absolute path, from the working tree you're executing in", and refers to sibling skills via `../subagent-driven-development/scripts/...`. Read from `~/.claude/plugins/cache/superpowers-dev/superpowers/7.0.2/skills/executing-plans/SKILL.md`. + +### Inferences +Candidate patterns for shade-kit, judged only against the facts above: +1. **Plugin-level file read by the CLI** (e.g. `compat.json` or `VERSION` at the plugin root, `shade-kit version --expect-file `). + - On Claude Code, the path is exact through `${CLAUDE_PLUGIN_ROOT}/VERSION`. + - On Codex and Copilot, the model must derive it from the skill path ("two levels above this skill's directory"). + - The value lives in one file and changes in one place. A guard test can still pin it to the GitVersion minor. +2. **Pass the skill directory** (`shade-kit version --skill-dir `): the CLI finds `SKILL.md` or the plugin root by itself. One instruction wording covers all three agents. The CLI can read `metadata.version` from the frontmatter, so the frontmatter stays the only source and the body needs no version text. + - This works in Claude Code and Copilot even though their models never see the frontmatter, because the CLI, not the model, reads it. +3. **Claude-only `` !`shade-kit version ...` ``** pre-injection: deterministic, but Claude-only syntax. It aborts the skill on a non-zero exit, and Copilot/Codex would show the raw placeholder text. +4. **`plugin.json` `version`**: no agent puts it in the model context, so it is not readable by the skill at runtime either. On Claude Code it also changes update semantics: it stops SHA-based updates on the `main` fallback. Codex uses it as its cache directory segment, and Copilot shows it in `plugin list --json`. +- Local testing: a local directory marketplace (`claude plugin marketplace add `, `copilot plugin marketplace add `, `codex plugin marketplace add `) or `claude --plugin-dir` loads files in place in Claude Code and Copilot. In those modes the skill directory is the working copy, so patterns 1 and 2 read the checked-out file without any version bump. + - Claude Code: a local-path marketplace loads in place, and a non-git directory gets version `unknown`. + - Codex: `local` version segment, files copied into the cache; in-place loading not verified. + +### Gaps +- **Unverified**: the literal text that Copilot CLI and Codex give the model for the skill directory, and whether the path is absolute. A scenario run in each agent is needed before relying on "this skill's directory" wording. +- **Unverified**: whether a literal `${CLAUDE_SKILL_DIR}` left in the text confuses Copilot or Codex models, or whether they guess its meaning. + +--- + +## Q7. How other plugin and skill authors version their skills and pin CLI dependencies + +### Takeaway +Two schemes are common, and both show up in this machine's cache. Some plugins pin a SemVer in `plugin.json`, kept in sync across agent manifests by a bump script (superpowers, Anthropic plugins such as `security-guidance` and `feature-dev`). Others omit `version` and let Claude Code use the commit SHA (Anthropic's `github` and `skill-creator` plugins, CreativeCoders' ai-store). I found no established convention for a skill declaring a minimum external CLI version. + +### Cited Findings +- **FACT** (local cache) superpowers 7.0.2 sets `"version": "7.0.2"` in `.claude-plugin/plugin.json` and `.codex-plugin/plugin.json`. Its `.version-bump.json` lists 12 files kept in sync, among them `package.json`, `.claude-plugin/plugin.json`, `.codex-plugin/plugin.json`, `.cursor-plugin/plugin.json`, `.claude-plugin/marketplace.json` (`plugins.0.version`), and `gemini-extension.json`. It ships agent-specific manifests side by side (`.claude-plugin`, `.codex-plugin`, `.cursor-plugin`, `.opencode`, and more). Its skills don't use `${CLAUDE_SKILL_DIR}`; they say "this skill's `scripts/...` by its absolute path". Read from `~/.claude/plugins/cache/superpowers-dev/superpowers/7.0.2/`. +- **FACT** (local cache) `claude-plugins-official` plugins: + - Pinned SemVer: `security-guidance` (2.0.17–2.0.21 cached), `feature-dev` 1.0.1, `ralph-loop` 1.0.1, `code-simplifier` 1.0.0, `mattpocock-skills` 1.3.1. + - No version (12-character SHA directories): `github` (eight SHA directories) and `skill-creator`. + + From `~/.claude/plugins/installed_plugins.json` and `cache/*/*/*/.claude-plugin/plugin.json`. +- **FACT** (local cache) `context-mode` 2.1.7 bundles its own runtime (`cli.mjs`, `server.mjs`, `SHA256SUMS`) and per-agent folders (`codex/`, `copilot/`, `opencode/`) inside the plugin. Its skills contain no `CLAUDE_PLUGIN_ROOT`/`CLAUDE_SKILL_DIR` references. +- **FACT** Claude Code's own tooling for SemVer plugins: `claude plugin tag` creates `--v` tags after checking that `plugin.json` and the marketplace entry agree, and `dependencies` ranges resolve against those tags. [Plugin dependencies](https://code.claude.com/docs/en/plugins/dependencies.md) +- **FACT** Agent version gate: `engines["claude-code"]` (Claude Code 2.1.323+). [CHANGELOG](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md) + +### Inferences +- superpowers' multi-manifest approach goes against shade-kit's single-source rule (no agent-specific manifests, guarded by `SingleSkillSourceTests`). Its version-bump-file pattern is still a precedent for keeping a version in several files with tooling. +- Shipping the runtime inside the plugin (context-mode) removes the CLI-version handshake, but shade-kit ships its engine separately (dotnet tool or binaries). + +### Gaps +- I didn't look for published guidance from Anthropic, GitHub, or OpenAI on a skill pinning an external CLI version. None appeared in the pages read. A community survey beyond this machine's cache was not done. diff --git a/research_notes/Versionierung von CLI und Skills/compatibility_patterns.md b/research_notes/Versionierung von CLI und Skills/compatibility_patterns.md new file mode 100644 index 0000000..7c44a99 --- /dev/null +++ b/research_notes/Versionierung von CLI und Skills/compatibility_patterns.md @@ -0,0 +1,187 @@ +# Version compatibility contracts between a host/engine and independently released plugins/clients + +Scope: prior art for how a host (engine, daemon, editor, CLI) and its plugins/clients agree on compatibility, applied to shade-kit (a .NET CLI "engine" plus Markdown SKILL.md files shipped as a Claude Code / Copilot CLI / Codex CLI plugin from the same repo; skills call the CLI with `--json`). Research date: 2026-11-21. + +Baseline (from the repository, not the web): today skills hardcode the kit version and run `shade-kit version --json --expect x.y.z`; the CLI exits 50 if major or minor differ, and a prerelease engine only warns. The skills' `metadata.version` must equal the engine build's major.minor, enforced by the `SkillKitVersionTests` guard — [CLAUDE.md](/Users/chris/src/github/shade-kit/CLAUDE.md) + +## 1. What compatibility patterns exist, with real-world examples? + +### Takeaway +There are five main families. (1) **Lockstep**: one version line for everything (Lerna fixed mode). (2) **Declared minimum or range of the counterpart**: the plugin declares which host versions it needs (VS Code `engines.vscode`, npm `engines`/`peerDependencies`, Terraform `required_version`, Helm `kubeVersion`, and now Claude Code's own `engines.claude-code`). (3) **A separate protocol/API version independent of the product version**: Terraform plugin protocol v5/v6, Docker Engine API 1.x, MCP date-versioned `protocolVersion`. (4) **Capability negotiation instead of version numbers**: LSP has no version handshake at all, and MCP has capabilities on top of its protocol version. (5) **Skew windows**: a supported window of N minors in each direction (Kubernetes). Mature systems combine (3) and (4). The product version is for humans, and a small, rarely bumped contract number decides compatibility. + +### Cited Findings + +**Lockstep (fixed) vs independent versioning** +- Lerna fixed mode: "Fixed mode Lerna projects operate on a single version line", with the version kept in `lerna.json`. "Use this if you want to automatically tie all package versions together." — [Lerna: Version and Publish](https://lerna.js.org/docs/features/version-and-publish) +- Lerna's stated drawback of fixed mode: "One issue with this approach is that a major change in any package will result in all packages having a new major version." Only packages that changed since the last release get the new version, which can cause drift, so `--force-publish` is suggested to keep versions aligned. — [Lerna: Version and Publish](https://lerna.js.org/docs/features/version-and-publish) +- Lerna independent mode: you set `"version": "independent"` in `lerna.json`, and it "allows you to more specifically update versions for each package". The docs say pairing it with semantic-release makes it "less painful". — [Lerna: Version and Publish](https://lerna.js.org/docs/features/version-and-publish) + +**Declared minimum or range of the host (plugin → host)** +- VS Code: an extension declares `engines.vscode` in `package.json`, for example `"^1.8.0"`. `1.8.0` without a caret "means that your extension is compatible only with VS Code `1.8.0`", and `^1.8.0` means "1.8.0 and onwards". The field can "ensure the extension only gets installed for clients that contain the API you depend on." — [VS Code: Publishing Extensions](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) +- npm `engines` is "advisory only and will only produce warnings when your package is installed as a dependency" unless the user sets the `engine-strict` config flag. — [npm package.json docs](https://docs.npmjs.com/cli/v11/configuring-npm/package-json) +- npm `peerDependencies` (the plugin→host pattern for npm): "As of npm v7, peerDependencies are installed by default". A conflict "may cause an error if the tree cannot be resolved correctly". The docs recommend making the requirement "as broad as possible" rather than locking it to specific patch versions. `peerDependenciesMeta` can mark a peer as optional. — [npm package.json docs](https://docs.npmjs.com/cli/v11/configuring-npm/package-json) +- Terraform `required_version` in the `terraform` block. Root and child modules' constraints are treated as equal, and Terraform "only proceeds if all are met". If the installed version does not satisfy them, it halts before plan, apply, or state operations. — [Terraform: Version Constraints](https://developer.hashicorp.com/terraform/language/expressions/version-constraints) +- Helm `Chart.yaml` `kubeVersion` is an optional SemVer constraint, and Helm will "fail if the cluster runs an unsupported Kubernetes version". `apiVersion: v2` marks charts that "require at least Helm 3", and `v1` charts "are still installable by Helm 3". This is a format/schema version distinct from the chart `version`. `appVersion` "is not related to the `version` field" and is "informational". — [Helm: Charts](https://helm.sh/docs/topics/charts/) +- **Claude Code plugins (directly relevant):** `plugin.json` has an `engines` object: "The Claude Code versions that the plugin works on, as a semver range under the `claude-code` key, such as `"engines": { "claude-code": ">=2.1.400" }`. Requires Claude Code v2.1.323 or later. To keep the plugin working on v2.0.15 through v2.1.75, omit `engines`. Those versions reject the manifest with an `Unrecognized key` error when it has the field." — [Claude Code: Plugin manifest reference](https://code.claude.com/docs/en/plugins-reference) +- Claude Code plugin `dependencies` entries can carry a `version` (`{ "name": ..., "marketplace": ..., "version": ... }`). The plugin `version` field "is not checked against semver", and setting it "keeps users on that version until you change it". — [Claude Code: Plugin manifest reference](https://code.claude.com/docs/en/plugins-reference) +- GitHub CLI extensions: the search found no built-in way for an extension to declare a minimum `gh` version. Extensions are just `gh-` repos with an executable. — [gh extension manual](https://cli.github.com/manual/gh_extension) (absence of a mechanism is an inference from the docs, see Gaps) + +**A protocol/API version separate from the product version** +- Terraform plugin protocol: "a versioned interface between Terraform CLI and Terraform Plugins". "Protocol version 6 is compatible with Terraform CLI version 1.0 and later." "Protocol version 5 is compatible with Terraform CLI version 0.12 and later." "Major versions of the protocol delineate Terraform CLI and Terraform Plugin compatibility." "Minor versions of the protocol are additive." The Registry "uses the protocol version as additional compatibility metadata when deciding which plugin versions Terraform CLI can select" (declared in the Registry manifest file). — [Terraform Plugin Protocol](https://developer.hashicorp.com/terraform/plugin/terraform-plugin-protocol) +- Docker Engine API: "A new version of the API is released when new features are added". The API is backward-compatible, and a client can pin a version in the URL (`/v1.57/containers/`). — [Docker Engine API docs](https://docs.docker.com/reference/api/engine/) +- MCP: `protocolVersion` is a date string (for example `"2025-06-18"`), separate from `clientInfo.version` / `serverInfo.version` (product versions such as `"1.0.0"`), which travel in the same `initialize` message. — [MCP Lifecycle 2025-06-18](https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle) + +**Capability negotiation** +- LSP: "Not every language server can support all features defined by the protocol. LSP therefore provides 'capabilities'". They are exchanged in `initialize`. "Features in the spec are kept compatible using so called capability flags." There is no protocol-version field in `InitializeParams`/`InitializeResult`, and the deprecated `unknownProtocolVersion` error code notes "There is no version handshake in version 3.0x". — [LSP 3.17 specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/) +- LSP tolerance rules: "Clients should ignore server capabilities they don't understand (e.g. the initialize request shouldn't fail in this case)" and "Servers receiving a ClientCapabilities object literal with unknown properties should ignore these properties." — [LSP 3.17 specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/) +- MCP capabilities ("Client and server capabilities establish which optional protocol features will be available during the session") include an `experimental` slot on both sides. Both parties "MUST ... Only use capabilities that were successfully negotiated". — [MCP Lifecycle 2025-06-18](https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle) + +**Skew windows** +- Kubernetes: "`kubectl` is supported within one minor version (older or newer) of `kube-apiserver`". "`kubelet` must not be newer than `kube-apiserver`" and "may be up to three minor versions older". In HA, apiservers "must be within one minor version". — [Kubernetes Version Skew Policy](https://kubernetes.io/releases/version-skew-policy/) + +### Inferences +- shade-kit today is lockstep plus an exact major.minor match. That is stricter than Lerna fixed mode, because a major.minor bump on either side forces a matching bump on the other even when the CLI contract did not change. +- The Claude Code `engines.claude-code` field shows that the host agent ecosystem itself has adopted the "plugin declares a minimum host range" pattern. It constrains the agent version, not the shade-kit CLI, so it does not replace a skills↔CLI check. It is the same design shape, though. +- The CLI's `--json` envelope already acts like a protocol. It could get its own contract number (like Docker API 1.x or Terraform protocol v5/v6), independent of the product SemVer. + +### Gaps +- Chrome DevTools Protocol versioning (stable "1.3" vs tip-of-tree) was not researched in this pass. No citations. +- Homebrew's `depends_on macos:` / minimum version mechanisms were not researched. No citations. + +## 2. For each pattern: who declares what, where is the check, what happens on mismatch, and how are dev/prerelease builds treated? + +### Takeaway +In the "declared minimum" family, the **plugin declares** and the **host checks at install or load time**, usually with a hard fail (Terraform, Helm, Claude Code engines) or only a warning (npm engines by default). In the negotiation family, **both sides advertise** and the check happens **at connection time**, usually by **degrading** to the common subset (Docker, LSP, MCP capabilities) and only failing when no overlap exists (MCP: the client "SHOULD disconnect"; Docker: "client version is too old"). Prerelease handling is the most common source of surprises. SemVer ranks prereleases *below* their release, and Terraform's range operators ignore prereleases entirely. + +### Cited Findings + +**VS Code** +- Declared by the extension in `package.json`. The check limits who gets the extension or update: with `^1.9.0`, Stable users "will only get the update when the Stable release reaches version `1.9.0`", while Insiders get it first. — [VS Code: Publishing Extensions](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) +- Dev/Insiders: to target an Insiders build by date, you add a `YYYYMMDD` tag, such as `^1.56.0-20210428`. "VS Code 1.57 and later enforce the date tag", while "Earlier versions evaluate only the numeric portion of the version." — [VS Code: Publishing Extensions](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) +- Pre-release extension channel: "Pre-release extensions are supported after VS Code version `1.63.0`." Pre-release and release extension versions must differ, and the docs suggest even minors for releases and odd minors for pre-releases (instead of SemVer prerelease labels). — [VS Code: Publishing Extensions](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) + +**Terraform** +- Declared by the module/root (`required_version`, `required_providers`). Checked by the CLI before plan/apply, as a hard stop. — [Terraform: Version Constraints](https://developer.hashicorp.com/terraform/language/expressions/version-constraints) +- Prerelease: "Terraform does not match pre-release versions on `>`, `>=`, `<`, `<=`, or `~>` operators." To select one: "set the exact version number using the `=` operator." — [Terraform: Version Constraints](https://developer.hashicorp.com/terraform/language/expressions/version-constraints) +- `~>` "Allows only the right-most version component to increment" (`~> 1.1` allows `1.10` but not `2.0`). — [Terraform: Version Constraints](https://developer.hashicorp.com/terraform/language/expressions/version-constraints) + +**npm** +- Declared by the package. `engines` produces warnings only, unless `engine-strict` is set. `peerDependencies` can fail tree resolution. — [npm package.json docs](https://docs.npmjs.com/cli/v11/configuring-npm/package-json) + +**Helm** +- Declared by the chart (`kubeVersion`, `apiVersion`). Checked at install, and Helm fails on an unsupported cluster version. — [Helm: Charts](https://helm.sh/docs/topics/charts/) + +**Claude Code plugins** +- Declared by the plugin (`engines.claude-code`), with a semver range in node-semver syntax. — [Claude Code: Plugin manifest reference](https://code.claude.com/docs/en/plugins-reference) +- Unknown top-level manifest fields are normally stripped with a validator warning. Strict sub-objects (`userConfig` options and others) fail on unknown keys. — [Claude Code: Plugin manifest reference](https://code.claude.com/docs/en/plugins-reference) + +**Docker Engine API** +- Both sides know their API range. "The Docker Engine API server and client support API-version negotiation". A client talking to an older daemon settles on the highest version both support, and newer features are turned off. Compatibility is "best effort". — [Docker Engine API docs](https://docs.docker.com/reference/api/engine/) +- Escape hatch: `DOCKER_API_VERSION` forces a specific version, and "This environment variable disables API version negotiation". — [Docker Engine API docs](https://docs.docker.com/reference/api/engine/) +- Server-side minimum: current 29.x lists 1.40 as the minimum API (29.0–29.2 listed 1.44), and 28.x and earlier list 1.24 or lower. "API versions before v1.40 are deprecated and no longer supported". — [Docker Engine API docs](https://docs.docker.com/reference/api/engine/) +- Mismatch below the minimum is a hard error from the daemon: `Error response from daemon: client version 1.43 is too old. Minimum supported API version is 1.44, please upgrade your client to a newer version`. The operator override is `DOCKER_MIN_API_VERSION=1.24 dockerd` or `"min-api-version": "1.24"` in `daemon.json`. — [Docker blog: Engine v29](https://www.docker.com/blog/docker-engine-version-29/) + +**MCP** +- The client sends the latest `protocolVersion` it supports. If the server supports it, it "MUST respond with the same version". Otherwise it responds with another version it supports (the latest). "If the client does not support the version in the server's response, it SHOULD disconnect." Over HTTP, the client must send `MCP-Protocol-Version` on later requests. Example error: code `-32602` "Unsupported protocol version" with `data.supported` / `data.requested`. — [MCP Lifecycle 2025-06-18](https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle) + +**LSP** +- No version check. Each side advertises capabilities, and unknown ones are ignored (degraded mode by design). — [LSP 3.17 specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/) + +**Kubernetes** +- The policy is documented, not a handshake. It is enforced by upgrade order: apiserver first, then controllers, then optionally kubelets. The apiserver must "not skip minor versions when upgrading". — [Kubernetes Version Skew Policy](https://kubernetes.io/releases/version-skew-policy/) + +**SemVer prerelease ordering (applies to all range checks)** +- "Pre-release versions have a lower precedence than the associated normal version." "Build metadata MUST be ignored when determining version precedence." — [SemVer 2.0.0](https://semver.org/) + +### Inferences +- A "min version" check that treats `1.4.0-alpha.3` as satisfying `>=1.4.0` is wrong under SemVer: the prerelease is lower. A dev build of the next minor therefore fails a minimum that equals that minor. Terraform avoids the trap by ignoring prereleases in ranges unless pinned exactly. VS Code avoids it with a date tag and with odd/even minors instead of prerelease labels. Today shade-kit sidesteps it by only warning for a prerelease engine. +- Docker and MCP both pair the check with a structured error that carries supported vs requested versions. That matches shade-kit's envelope model (`error.code` plus message), so a skill could react to it deterministically. + +### Gaps +- What VS Code shows on an `engines` mismatch (marketplace hides the version vs install error text) is not stated on the fetched page. +- Whether Claude Code hard-fails or warns when `engines.claude-code` is unsatisfied is not stated on the fetched page. Nor does it say how Claude Code v2.1.76–v2.1.322 treat the field (presumably stripped as an unknown top-level key, but unverified). +- How Copilot CLI and Codex CLI treat an `engines` key in `plugin.json` was not researched. + +## 3. Bidirectional checks: where does each side declare a minimum of the other, and how is a breaking change signalled? + +### Takeaway +Real bidirectional schemes need **two numbers per side**: "the newest I speak" and "the oldest I still accept". Docker is the clearest example. The client knows its max API, the daemon has a max and a configurable **min API version**, and negotiation picks the highest overlap. Kubernetes puts the same idea in a written skew window. Terraform does it through protocol majors that both CLI and provider declare. A breaking change is signalled by bumping the *contract's* major (Terraform protocol v5→v6), by raising the *server's minimum* (Docker 29: min API 1.24→1.44), or by publishing a new dated protocol revision (MCP). It is not signalled by the product version. + +### Cited Findings +- Docker: the daemon-side minimum is an explicit, operator-overridable setting (`DOCKER_MIN_API_VERSION`, `min-api-version`). The client side negotiates down or is forced with `DOCKER_API_VERSION`. — [Docker blog: Engine v29](https://www.docker.com/blog/docker-engine-version-29/); [Docker Engine API docs](https://docs.docker.com/reference/api/engine/) +- Docker on asymmetric skew: when the daemon is newer, the client "doesn't know about new features or deprecated API endpoints". When the client is newer, it "can request API endpoints that the daemon doesn't know about." — [Docker Engine API docs](https://docs.docker.com/reference/api/engine/) +- Docker 29's raised minimum broke real clients. Traefik's Docker provider kept using API 1.24 and was rejected ("client version 1.24 is too old"). Reported workarounds were downgrading Docker to 28.x or lowering `min-api-version`. — [Docker forum thread](https://forums.docker.com/t/docker-29-increased-minimum-api-version-breaks-traefik-reverse-proxy/150384); [Traefik community thread](https://community.traefik.io/t/traefik-stops-working-it-uses-old-api-version-1-24/29019) +- Kubernetes declares the window from the server's point of view, in both directions for kubectl (±1 minor) and one direction for kubelet (never newer, up to 3 older). — [Kubernetes Version Skew Policy](https://kubernetes.io/releases/version-skew-policy/) +- Terraform: protocol majors "delineate Terraform CLI and Terraform Plugin compatibility", and minors "are additive". Each protocol major also maps to a minimum CLI (v5 ≥ 0.12, v6 ≥ 1.0). — [Terraform Plugin Protocol](https://developer.hashicorp.com/terraform/plugin/terraform-plugin-protocol) +- MCP: each side picks from the versions it supports, and an unsupported version is surfaced with `supported` and `requested` lists. — [MCP Lifecycle 2025-06-18](https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle) +- SemVer FAQ on deprecation: "issue a new minor release with the deprecation in place", and "there should be at least one minor release that contains the deprecation" before removal in a major. — [SemVer 2.0.0](https://semver.org/) + +### Inferences +- For shade-kit the two directions are different in kind: + - **skills → CLI**: "I need CLI contract ≥ N" (a skill uses a command, option, or envelope field added in N). The skill declares it, and the CLI or the skill's handshake checks it. + - **CLI → skills**: "I no longer support skills older than M" (the CLI removed or renamed a command or field). The CLI declares it. + - With a single integer contract number (say `contract: 3`) plus a CLI-side `minSupportedContract`, both directions reduce to the Docker model: the skill passes the contract it was written for, and the CLI accepts if `minSupported ≤ requested ≤ current`. +- Additive changes (new command, new optional JSON field) need no bump in the "requires" direction if skills are written tolerant (ignore unknown fields, like LSP). Only removals or semantic changes need a contract bump. + +### Gaps +- Git LFS client/server version negotiation was in the brief but not researched. No citations. +- No source was found on how Terraform's go-plugin handshake (magic cookie / protocol version list) is implemented in detail. The fetched page only states the compatibility matrix. + +## 4. Which approach minimizes manual steps per release, and what pitfalls do maintainers report? + +### Takeaway +The lowest-maintenance schemes are those where **most releases need no compatibility edit at all**. That means the compatibility number changes only when the contract changes (protocol version, capability flag), not on every product release. Lockstep with exact matching has the highest per-release cost, because every minor bump touches every consumer. Documented pitfalls include raising a minimum and breaking long-lived clients (Docker 29 / Traefik), prerelease ordering and matching surprises (SemVer, Terraform), new manifest fields breaking old hosts (Claude Code `engines` rejected by v2.0.15–v2.1.75), and lockstep forcing spurious majors (Lerna). + +### Cited Findings +- Lockstep cost: a major change anywhere bumps everything ("a major change in any package will result in all packages having a new major version"). — [Lerna: Version and Publish](https://lerna.js.org/docs/features/version-and-publish) +- Independent mode needs per-package bump decisions (prompted per changed package) and is easier with automation such as semantic-release. — [Lerna: Version and Publish](https://lerna.js.org/docs/features/version-and-publish) +- Terraform's advice to library-like consumers: "Reusable modules should constrain only their minimum allowed versions". Only root modules should use `~>` with an upper bound. — [Terraform: Version Constraints](https://developer.hashicorp.com/terraform/language/expressions/version-constraints) +- npm's advice: keep peer ranges "as broad as possible" rather than pinning. — [npm package.json docs](https://docs.npmjs.com/cli/v11/configuring-npm/package-json) +- Pitfall, raising the minimum: Docker 29's min-API bump to 1.44 broke Traefik deployments, and users had to downgrade or override. — [Docker blog: Engine v29](https://www.docker.com/blog/docker-engine-version-29/); [Docker forum](https://forums.docker.com/t/docker-29-increased-minimum-api-version-breaks-traefik-reverse-proxy/150384) +- Pitfall, a new compatibility field rejected by old hosts: Claude Code versions v2.0.15 through v2.1.75 reject a manifest that contains `engines` with an `Unrecognized key` error. — [Claude Code: Plugin manifest reference](https://code.claude.com/docs/en/plugins-reference) +- Pitfall, prereleases: SemVer ranks prereleases below the release, and Terraform's range operators never match prereleases. — [SemVer 2.0.0](https://semver.org/); [Terraform: Version Constraints](https://developer.hashicorp.com/terraform/language/expressions/version-constraints) +- Pitfall, escape hatches that disable negotiation: `DOCKER_API_VERSION` "disables API version negotiation" and should be used only when needed or for debugging. — [Docker Engine API docs](https://docs.docker.com/reference/api/engine/) +- Pitfall, old-version tooling: VS Code before 1.57 ignores the date tag and evaluates only the numeric part. — [VS Code: Publishing Extensions](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) + +### Inferences +- **"Forgetting to raise the minimum"** is the main risk of min-version schemes: a skill starts using a new CLI option but still declares the old minimum. Guard tests can mechanize this, just as shade-kit already has `SkillKitVersionTests`. Examples: a test that maps each CLI command/option to the contract version that introduced it, or a test that fails if the CLI's JSON contract snapshot changes without a contract bump (an API-approval or snapshot test on the `--json` schemas). +- **Too-strict checks blocking local testing**: shade-kit's dev override (`SHADE_KIT_MARKETPLACE_SOURCE`) and prerelease-only-warns rule already cover part of this. A contract-integer scheme removes most of the problem, because a local dev build carries the same contract number as the release it precedes. +- Expected per-release manual steps, ranked: + - exact lockstep match: every minor touches every skill + - min product version: only when a skill needs a new feature, but easy to forget + - contract integer plus min-supported: only on a contract change, and a snapshot test can enforce it + - pure capability negotiation: no version edits, but skills must probe capabilities, which is costly in Markdown instructions + +### Gaps +- No maintainer post-mortems were found specifically on "forgot to raise minimum" (the inference rests on mechanism, not a cited report). +- Babel/Angular lockstep rationale posts were not fetched in this pass. No citations. + +## 5. Recommendation criteria for a small team: CLI + Markdown-skill plugin in one repo, released together but possibly on different cadences + +### Takeaway +For one repo and one team, the evidence favours **decoupling product versions from a small, explicit contract version**. Keep the CLI's and the plugin's SemVer for humans and release notes. Version the `--json` command contract separately, as an integer or a protocol-style major.minor (Terraform protocol / Docker API style). Skills declare the contract they require, and the CLI declares the range it serves. Make additive changes non-breaking through tolerant parsing (LSP rule). Prereleases and dev builds should never fail the check, and a snapshot guard test should force the contract bump. + +### Cited Findings +- Contract majors signal breakage, and contract minors are additive. — [Terraform Plugin Protocol](https://developer.hashicorp.com/terraform/plugin/terraform-plugin-protocol) +- Negotiate to the highest common version and expose a structured "unsupported, here is supported vs requested" error. — [MCP Lifecycle 2025-06-18](https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle); [Docker Engine API docs](https://docs.docker.com/reference/api/engine/) +- Ignore unknown fields and capabilities rather than failing. — [LSP 3.17 specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/) +- Consumers should declare minimums only, not upper bounds. — [Terraform: Version Constraints](https://developer.hashicorp.com/terraform/language/expressions/version-constraints); [npm package.json docs](https://docs.npmjs.com/cli/v11/configuring-npm/package-json) +- Publish an explicit skew window so users know which combinations are supported. — [Kubernetes Version Skew Policy](https://kubernetes.io/releases/version-skew-policy/) +- The host agent can additionally gate the plugin on agent version via `engines.claude-code`, but adding it breaks Claude Code v2.0.15–v2.1.75. — [Claude Code: Plugin manifest reference](https://code.claude.com/docs/en/plugins-reference) + +### Inferences +Criteria to score options against: +1. **Edits per ordinary release.** Target zero. Only contract changes should touch compatibility data. +2. **Where the knowledge lives.** Skills (Markdown, agent-read) should carry one number. All comparison logic belongs in the CLI (`version --expect`-style), because Markdown cannot reliably implement range logic, and the agent is the one executing it. +3. **Both directions covered.** A skill-required contract (skills → CLI) plus a CLI `minSupportedContract` (CLI → skills), as in the Docker model. +4. **Mismatch behaviour is graded.** Too-old CLI: hard fail with an actionable message and error code (Docker "please upgrade your client"). Too-old skills: hard fail only below `minSupported`, otherwise OK. Prerelease or dev CLI: warn, never fail. +5. **Dev/local builds.** The check must not depend on SemVer prerelease ordering. A contract integer avoids it entirely. Otherwise compare on major.minor.patch with the prerelease stripped, or treat prereleases as satisfying (unlike Terraform). +6. **Enforced by tests, not discipline.** A snapshot/approval test of the `--json` contract (command list, options, envelope fields) fails when the contract changes without a contract bump. The existing guard pattern (`SkillKitVersionTests`) extends to "every skill declares the same required contract ≤ the CLI's current contract". +7. **Agent-agnostic.** A CLI-side check works identically for Claude Code, Copilot CLI, and Codex CLI. `engines.claude-code` is Claude-only and breaks old Claude Code versions, so at most it is an optional, separate gate. +8. **Upgrade order documented.** Like Kubernetes ("apiserver first"): update the CLI first, then the plugin, because a newer CLI serves older skills within the window. + +Likely fit: Option (3) from section 4, a contract integer plus min-supported, as Docker does it in miniature. It keeps independent SemVer for the CLI and the plugin, which can then release on different cadences, and most releases touch no compatibility data. + +### Gaps +- No source compares these patterns for Markdown/LLM-executed clients specifically. The fit judgement for skills is an inference. +- Whether Copilot CLI and Codex CLI plugin manifests offer an equivalent of `engines` was not checked. diff --git a/research_notes/Versionierung von CLI und Skills/current_state_repo.md b/research_notes/Versionierung von CLI und Skills/current_state_repo.md new file mode 100644 index 0000000..f28717a --- /dev/null +++ b/research_notes/Versionierung von CLI und Skills/current_state_repo.md @@ -0,0 +1,200 @@ +# Current versioning implementation of shade-kit (repository state on branch feature/rework-versioning-branch-mgmt, HEAD 17e6a55) + +All sources are files in the repository `/Users/chris/src/github/shade-kit` (paths relative to it, `file:line`). "FACT" = verified in the code or by a command run during this research (2026-11-21). Commands run (read-only): `git tag`, `git log`, `git describe`, `dotnet run --project src/CreativeCoders.ShadeKit.Cli -- version --json --expect `, reading `src/CreativeCoders.ShadeKit.Core/obj/gitversion.json` (GitVersion.MsBuild output of that build). + +## 1. Where is the version defined, computed, embedded, and checked? + +### Takeaway +There is exactly one computed version (GitVersion from git history + `next-version`), embedded as the assembly informational version and read at runtime by `EngineVersionProvider`; it is used for the `--expect` handshake (major.minor match, prerelease only warns), for the marketplace ref (`v` / `main`), for `init` (`kitVersion` written into `.shadekit/`), for the HTTP User-Agent, and by the Cake smoke test. The skills carry a second, hand-maintained copy (`metadata.version` + handshake text) that a guard test ties to the GitVersion major.minor. + +### Cited Findings +**Definition / computation (GitVersion)** +- FACT: `mode: ContinuousDelivery`, `tag-prefix: 'v'`, `next-version: v0.9.0` — the only hand-kept number — [GitVersion.yml:13-15](GitVersion.yml). The header comment says it "raises the minor place ahead of the release when the kit skills move to a new minor" and that GitVersion is "documented to ignore it once a tag at or above it exists (not yet observed in this repository)" — [GitVersion.yml:6-11](GitVersion.yml). +- FACT: branch `main`: `label: ''`, `increment: Patch`, `is-main-branch: true` — [GitVersion.yml:20-28](GitVersion.yml). Branch `feature`: regex `^features?[/-](?.+)`, `label: '{BranchName}'`, `increment: Inherit` — [GitVersion.yml:31-37](GitVersion.yml). No other branch types (no `release/*`, `hotfix/*`, `develop`, pull-request branch config) are configured. +- FACT: `GitVersion.MsBuild` 6.8.2 is a `GlobalPackageReference` for every project — [Directory.Packages.props:8-11](Directory.Packages.props); Cake installs `GitVersion.Tool` 6.8.2 "so Cake and MSBuild compute the same version" — [build/Program.cs:15-16](build/Program.cs). No version in `Directory.Build.props` (FACT, [Directory.Build.props](Directory.Build.props) has none) and there is no `Directory.Build.targets` (FACT, `ls`). +- FACT: tags in the repo: `v0.1.0` … `v0.8.0`; `v0.8.0` points to `f35fdf2` (2026-11-13); `git describe` = `v0.8.0-4-g17e6a55` — `git tag`, `git log`. +- FACT: tags `v0.7.0` and `v0.8.0` contain no `.claude-plugin/`, "so the first installable release is the first tag with the manifests" — [docs/feature-packages/README.md:127](docs/feature-packages/README.md), [docs/feature-packages/19-release-and-distribution.md:66](docs/feature-packages/19-release-and-distribution.md). + +**Embedding / reading at runtime** +- FACT: `EngineVersionProvider` reads `AssemblyInformationalVersionAttribute` of the Core assembly and cuts off build metadata after `+` (fallback: assembly version) — [src/CreativeCoders.ShadeKit.Core/Engine/EngineVersionProvider.cs:34-36](src/CreativeCoders.ShadeKit.Core/Engine/EngineVersionProvider.cs). +- FACT: consumers of `IEngineVersionProvider`: `EngineVersionChecker`, `IntegrationService`, `RepositoryInitializer`, `VersionCommand`, `CliErrorMapper`, DI registration — `git grep IEngineVersionProvider` over `src/`. +- FACT: `init` writes the engine version (prerelease label included) as `kitVersion` into `config.json` and into every entry of `templates.lock.json` — [src/CreativeCoders.ShadeKit.Core/Init/RepositoryInitializer.cs:196-199,248](src/CreativeCoders.ShadeKit.Core/Init/RepositoryInitializer.cs). +- FACT: the HTTP User-Agent is `shade-kit/` — [tests/CreativeCoders.ShadeKit.Core.Tests/ShadeKitCoreServiceCollectionExtensionsTests.cs:713](tests/CreativeCoders.ShadeKit.Core.Tests/ShadeKitCoreServiceCollectionExtensionsTests.cs). +- FACT: the format registry stamps `minEngineVersion` per format version; all five formats are version 1 with `FirstEngineVersion = "0.1.0"` — [src/CreativeCoders.ShadeKit.Core/Formats/FormatRegistry.cs:10,65-69](src/CreativeCoders.ShadeKit.Core/Formats/FormatRegistry.cs). + +**The `version` command and the check** +- FACT: `--expect` option — [src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommandOptions.cs:21-22](src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommandOptions.cs); a bare `--expect` is rejected by `ExpectedVersionOptionConverter` (exit 2). +- FACT: `VersionCommand` runs `IEngineVersionChecker.Check(expected)` only when `--expect` is set, then always reads installed integrations (`IntegrationService.GetInstalledAsync`, which starts the agent CLIs) — [src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommand.cs:85-96](src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommand.cs); data = `engineVersion`, `formats` (format id → current format version, line 126), `expectedVersion`, `integrations` — [VersionCommandData.cs:17,27,37](src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommandData.cs). +- FACT: match rule: `(engine.Major, engine.Minor).CompareTo((expected.Major, expected.Minor))`; equal → success; unequal and engine is not a prerelease → `EngineVersionMismatchException` (exit 50 `version-mismatch`); unequal and prerelease → success with warning `EnginePrereleaseVersionMismatchWarning` — [src/CreativeCoders.ShadeKit.Core/Versions/EngineVersionChecker.cs:36-53](src/CreativeCoders.ShadeKit.Core/Versions/EngineVersionChecker.cs). Patch and prerelease of `--expect` are not compared; engine version that is not SemVer → exit 255 — [docs/feature-packages/06-1-engine-version-check.md:44-55](docs/feature-packages/06-1-engine-version-check.md). +- FACT: exit/warning codes: `VersionMismatch = 50` — [src/CreativeCoders.ShadeKit.Cli/ShadeKitCliExitCodes.cs:218](src/CreativeCoders.ShadeKit.Cli/ShadeKitCliExitCodes.cs); `engine-prerelease-version-mismatch`, `integration-prerelease-ref`, `integration-release-tag-missing` — [src/CreativeCoders.ShadeKit.Cli/ShadeKitCliWarningCodes.cs:82,88,94](src/CreativeCoders.ShadeKit.Cli/ShadeKitCliWarningCodes.cs). Mismatch message (engine newer → "Run 'shade-kit integrations install' to install the SHADE kit skills x.y") — `CliErrorMapper.CreateEngineVersionMismatchMessage` [src/CreativeCoders.ShadeKit.Cli/Output/CliErrorMapper.cs:690](src/CreativeCoders.ShadeKit.Cli/Output/CliErrorMapper.cs), text in [06-1:61-62](docs/feature-packages/06-1-engine-version-check.md). + +**Integrations: marketplace source from the engine version** +- FACT: `MarketplaceSourceVariableName = "SHADE_KIT_MARKETPLACE_SOURCE"` (:40), `MarketplaceRepo = "CreativeCodersTeam/shade-kit"`, `FallbackRef = "main"` (:57) — [src/CreativeCoders.ShadeKit.Core/Integrations/IntegrationService.cs:40-57](src/CreativeCoders.ShadeKit.Core/Integrations/IntegrationService.cs). +- FACT: resolution order in `ResolveUncheckedSource`: env override wins (:251, parsed by `MarketplaceSource.Parse` against the current directory) → prerelease engine → `#main` + `IntegrationPrereleaseRefWarning` (:265-268) → release engine → `#v` (:271), then `CheckReleaseTagAsync`: `git ls-remote` via `IGitRemoteTagChecker`; tag missing → `#main` + `IntegrationReleaseTagMissingWarning`; check impossible (no git/network) → tag used unchecked (:275-290) — [IntegrationService.cs](src/CreativeCoders.ShadeKit.Core/Integrations/IntegrationService.cs); checker in [src/CreativeCoders.ShadeKit.Core/Git/GitRemoteTagChecker.cs](src/CreativeCoders.ShadeKit.Core/Git/GitRemoteTagChecker.cs). +- FACT: the "kit version" of an installed integration is derived purely from the marketplace ref: `v` → ``, anything else (`main`, branch, local directory) → `null` — [src/CreativeCoders.ShadeKit.Core/Integrations/MarketplaceSource.cs:67,199-204](src/CreativeCoders.ShadeKit.Core/Integrations/MarketplaceSource.cs). Codex reports no ref, so its `kitVersion`/`ref` are always `null` — [docs/feature-packages/08-copilot-and-codex-integration.md:133](docs/feature-packages/08-copilot-and-codex-integration.md). +- FACT: `plugin.json` has no `version` field; Claude Code then uses the 12-char commit SHA as plugin version — [.claude-plugin/plugin.json](.claude-plugin/plugin.json), [docs/feature-packages/07-claude-code-integration.md:41](docs/feature-packages/07-claude-code-integration.md). + +**Build and release** +- FACT: Cake smoke test runs the published native binary with `version --json` and fails unless `data.engineVersion == context.Version.SemVer` — [build/Tasks/SmokeTestTask.cs:41-64](build/Tasks/SmokeTestTask.cs). +- FACT: `ReleaseVersion => $"v{Version.SemVer}"`, `IsPreRelease` from `PreReleaseTag` — [build/BuildContext.cs:57,61](build/BuildContext.cs); push target: tag builds → nuget.org, every other non-PR, non-local Linux build → GitHub Packages — [build/BuildContext.cs:20-27](build/BuildContext.cs). +- FACT: `release.yml` triggers on `v[0-9]+.[0-9]+.[0-9]+*`; `verify-tag` only checks the tag regex (prerelease tags such as `v0.9.0-beta.1` are allowed) and that the commit is on `origin/main`; it does not check skill versions — [.github/workflows/release.yml:7-36](.github/workflows/release.yml). Build matrix runs `-t pack -t smoketest -t createdistpackages` (pack runs tests → the guard test) before `nuget-push` and `github-release` — [release.yml:38-144](.github/workflows/release.yml). +- FACT: `main.yml` and `integration.yml` (Ubuntu) run `-t nugetpush` → GitHub Packages — [.github/workflows/main.yml:22](.github/workflows/main.yml), [.github/workflows/integration.yml:22](.github/workflows/integration.yml). + +### Inferences +- The engine has three independent "version" notions that are conflated today: product version (GitVersion SemVer), the per-file format versions (`formats`, `minEngineVersion`), and the de-facto CLI/JSON contract (exit/error codes, options) which has no version at all. +- The kit version reported for an installed integration is a property of the *ref*, not of the installed skill content; skills installed from `main` or a local path have no observable version at all. + +### Gaps +- What `main` builds produce now is not run here (no checkout of `main`, read-only). 07 records as FACT that an untagged `main` commit builds a release version (e.g. `0.8.1`) [07:72](docs/feature-packages/07-claude-code-integration.md). With `next-version: v0.9.0` the expected value is `0.9.0` (no label) — **Unverified**. If so, every `main` commit until the tag would build the same `0.9.0` and push it to GitHub Packages; whether repeat pushes of the same package version fail or are skipped was not checked (**Unverified**). + +## 2. Guard tests in tests/CreativeCoders.ShadeKit.Core.Tests/Skills/ concerning versions + +### Takeaway +Only `SkillKitVersionTests` concerns versions; it couples the hand-written skill version to the GitVersion build version of the test run, so any local or CI build whose computed major.minor differs from the skills fails. The other guards (`ShippedSkillsTests`, `SkillAgentWordingTests`, `SingleSkillSourceTests`) constrain where a version could be stored or how skill texts are shaped. + +### Cited Findings +- FACT: the live test `SkillFiles_ShippedSkills_CarryOneKitVersionThatMatchesTheEngineMajorMinor` (Trait `FP07-AC2`) takes `new EngineVersionProvider().Version` — i.e. the GitVersion version compiled into the Core assembly of the test build — and fails on any violation — [tests/CreativeCoders.ShadeKit.Core.Tests/Skills/SkillKitVersionTests.cs:17-39](tests/CreativeCoders.ShadeKit.Core.Tests/Skills/SkillKitVersionTests.cs). +- FACT: rules in `FindKitVersionViolations` (:648-691): every `skills/**/SKILL.md` needs a frontmatter with `metadata:` and a direct child ` version: ` (exactly two-space indent, regex :819) where `` is plain `x.y.z` (no prerelease/build metadata, `IsPlainVersion` :807-810); all skills must carry the same value (reference = most frequent version, tie → engine major.minor, then first path; `SelectKitSkill` :705-716); its major.minor must equal the engine major.minor (:677-682); every `--expect ` (regex :825) and every "`` is the kit version of this skill" (regex :832-835) in *any text file* under `skills/` must name that exact full version (patch included) (`FindHandshakeViolations` :721-747); a placeholder like `--expect ` is a violation — same file. +- FACT: the ~30 other tests in that file are unit tests of the checker on synthetic temp directories with a fixed `DefaultEngineVersion = 0.8.3` (:15) — they do not change on a bump. +- FACT: `ShippedSkillsTests` (FP07-AC7) forbids path references into `docs/` / `research/` in every text file under `skills/`; `SkillAgentWordingTests` checks canonical question-tool and call-form phrases; `SingleSkillSourceTests`/`SingleSkillSourceGuard` forbid duplicate skill names, `SKILL.md` in agent skill locations, agent-specific manifests beside `.claude-plugin/` (a root `plugin.json`, `marketplace.json`, `.plugin/…`, `.github/plugin/…`, `.agents/plugins/marketplace.json`) and agent-specific `agents/` files in skill folders — [tests/CreativeCoders.ShadeKit.Core.Tests/Skills/SingleSkillSourceGuard.cs:15-19,62-68](tests/CreativeCoders.ShadeKit.Core.Tests/Skills/SingleSkillSourceGuard.cs); [CLAUDE.md "Skill texts have no automated tests"](CLAUDE.md). +- FACT: other tests using the real build version: `ProgramTests.cs:415`, `EngineVersionProviderTests.cs:14`, `ShadeKitCoreServiceCollectionExtensionsTests.cs:713` — they compare against the provider value, not a literal, so they survive a bump. Tests with literal `0.9.0` (fake engine versions in fixtures) exist in `IntegrationsInstallCommandTests`, `IntegrationsCommandsEndToEndTests`, `IntegrationsMultiAgentEndToEndTests`, `VersionCommandTests`, `ClaudePluginCliTests`, `IntegrationServiceTests`, `EngineVersionCheckerTests` — `git grep -c 0.9.0` (whether they must change on a bump: they use faked providers — **Unverified** per test, likely no). +- FACT: the scenario tooling reads the kit version from `skills/shade-kit-next-steps/SKILL.md` frontmatter and builds `env-version.json` by running the engine with `--expect `; the checker requires the first command to be `shade-kit version --json --expect ` — [tests/skill-scenarios/generate_fixtures.py:38,107-116,313](tests/skill-scenarios/generate_fixtures.py), [tests/skill-scenarios/checks/check_runs.py:223-224](tests/skill-scenarios/checks/check_runs.py). + +### Inferences +- The guard enforces *full-version* equality between frontmatter and handshake text, but only *major.minor* equality to the engine. So a patch bump of the skills is possible without touching GitVersion, while a minor bump needs `GitVersion.yml` in the same commit. +- Because the test reads the version of whatever build runs it, its result depends on branch, tags present locally, and `next-version` — not only on the committed files. A shallow clone or a source tree without `.git` would make GitVersion fail or yield another value (**Unverified**; CI uses `fetch-depth: 0` everywhere, [release.yml:23,55](.github/workflows/release.yml)). + +### Gaps +- Not run: `dotnet test` on this branch (assumed green since branch == main + 0 commits). + +## 3. Which skills run the handshake, and how many places does a bump touch? + +### Takeaway +5 skills run the handshake; a version bump touches 26 lines in 19 `SKILL.md` files, plus `GitVersion.yml` for a minor/major raise, plus (by convention) `CLAUDE.md` and several feature-package docs. + +### Cited Findings +- FACT: all 19 skills carry ` version: 0.9.0` at line 5 of their `SKILL.md` (`shade-kit-diagnose, -discuss, -drop, -finish, -gate-check, -implement, -interview, -map, -new, -next-phase, -next-steps, -phase-entry, -plan, -quick, -refine, -report, -research, -review, -verify`) — `grep -rn "^ version:" skills`. +- FACT: handshake lines (`--expect 0.9.0` + "0.9.0 is the kit version of this skill"): [skills/shade-kit-discuss/SKILL.md:18](skills/shade-kit-discuss/SKILL.md), [skills/shade-kit-next-phase/SKILL.md:22](skills/shade-kit-next-phase/SKILL.md), [skills/shade-kit-phase-entry/SKILL.md:28](skills/shade-kit-phase-entry/SKILL.md), [skills/shade-kit-new/SKILL.md:22](skills/shade-kit-new/SKILL.md), [skills/shade-kit-drop/SKILL.md:18](skills/shade-kit-drop/SKILL.md). Extra `--expect 0.9.0` in "the only commands this skill runs" lists: [shade-kit-next-phase/SKILL.md:93](skills/shade-kit-next-phase/SKILL.md), [shade-kit-phase-entry/SKILL.md:175](skills/shade-kit-phase-entry/SKILL.md). Total `0.9.0` occurrences under `skills/`: 26 lines in 19 files — `git grep -c 0.9.0 -- skills`. +- FACT: phase skills do not run their own handshake; `shade-kit-phase-entry` runs it for them ("all kit skills carry the same version, so this check covers them") — [skills/shade-kit-phase-entry/SKILL.md:33](skills/shade-kit-phase-entry/SKILL.md); rule in [06-2:59-64](docs/feature-packages/06-2-skill-conventions-and-version.md). +- FACT: skill reaction: `ok:false` (e.g. `version-mismatch`) or `shade-kit` not found → stop, refusal; warning `engine-prerelease-version-mismatch` → keep and continue — [skills/shade-kit-new/SKILL.md:23-24](skills/shade-kit-new/SKILL.md) (same text in discuss:19-20, drop:19-20, next-phase:24-25, phase-entry:30-31). Next-steps refusal row: "update the engine or the kit skills so that their major and minor versions match" — [skills/shade-kit-next-steps/SKILL.md:95](skills/shade-kit-next-steps/SKILL.md). +- FACT: why the version is in the text at all: Claude Code strips the frontmatter before the model sees the skill (checked 2026-11-06, Claude Code 2.1.318); Copilot (since 1.0.48) also does not show it; Codex injects the whole file but ignores `metadata.version` — [06-2:68-76](docs/feature-packages/06-2-skill-conventions-and-version.md). +- FACT: other files with the current value: [GitVersion.yml:15](GitVersion.yml) (`v0.9.0`), [CLAUDE.md:104-105](CLAUDE.md) (examples `version: 0.9.0` and the handshake wording); docs that record the value/history: 06-2, 09, README, `docs/implementation/09-discuss-and-intake.md` — `git grep -l 0.9.0 -- docs`. +- FACT: history of raises: `0.7.0` (2026-11-06) → `0.8.0` (2026-11-14, because builds were `0.8.x` after tag `v0.8.0` and the new guard failed) → `0.9.0` (2026-11-20, because `shade-kit-new` needs `feature new --move-source`, unknown to 0.8 engines; done with `next-version` in `GitVersion.yml`, D-25/D-26) — [06-2:85-86,100](docs/feature-packages/06-2-skill-conventions-and-version.md), [docs/implementation/09-discuss-and-intake.md:80-81,166](docs/implementation/09-discuss-and-intake.md). `git log -S"version: 0.8.0" -- skills` → commits `e8f06f7` (#34, 2026-11-15) and `17e6a55` (#41, 2026-11-21); `GitVersion.yml` changed only in `c2e87d1` (#2) and `17e6a55` (#41). + +### Inferences +- A raise is a coordinated edit of ≥20 files that must land in one commit (otherwise that commit's build fails the guard), and needs a doc trail by convention. Two of the last three raises were forced *reactively* (guard failure after a tag; a skill needing a new engine option), not planned releases. + +### Gaps +- None material. + +## 4. What version does a local feature-branch build get, and how does it interact with skills, prerelease warning, and marketplace ref? + +### Takeaway +On this branch the engine is `0.9.0-rework-versioning-branch-mgmt.4` — a prerelease. Every handshake therefore passes (at worst a warning), and `integrations install/update` ignores the branch and installs skills from GitHub `main` unless `SHADE_KIT_MARKETPLACE_SOURCE` is set. + +### Cited Findings +- FACT (gitversion.json of this build): `SemVer`/`FullSemVer` `0.9.0-rework-versioning-branch-mgmt.4`, `InformationalVersion` `0.9.0-rework-versioning-branch-mgmt.4+Branch.feature-rework-versioning-branch-mgmt.Sha.17e6a55…`, `PreReleaseLabel` `rework-versioning-branch-mgmt`, `PreReleaseNumber` 4 (= `CommitsSinceVersionSource`, source = tag `v0.8.0` commit `f35fdf2`), `AssemblySemVer` `0.9.0.0` — `src/CreativeCoders.ShadeKit.Core/obj/gitversion.json`. +- FACT (run): `dotnet run --project src/CreativeCoders.ShadeKit.Cli -- version --json --expect 0.9.0` → `ok:true`, `engineVersion` `0.9.0-rework-versioning-branch-mgmt.4`, `formats` `{config:1,gates:1,feature:1,current-feature:1,templates-lock:1}`, `integrations: []`, no warnings, exit 0. +- FACT (run): same with `--expect 0.8.0` → `ok:true`, exit 0, warning `engine-prerelease-version-mismatch`: "The prerelease engine 0.9.0-rework-versioning-branch-mgmt.4 does not fit the kit skills 0.8.0 … it is used anyway because it is a prerelease." `--expect 1.0.0` also `ok:true` (warning). +- FACT: prerelease engine → marketplace `CreativeCodersTeam/shade-kit#main` + warning `integration-prerelease-ref`; no tag check — [IntegrationService.cs:265-268](src/CreativeCoders.ShadeKit.Core/Integrations/IntegrationService.cs), table in [07:50-59](docs/feature-packages/07-claude-code-integration.md). +- FACT: `version` ignores `SHADE_KIT_MARKETPLACE_SOURCE` — [07:68](docs/feature-packages/07-claude-code-integration.md). +- FACT: a prerelease number in the label is the commit count since the version source, so every commit on the branch yields a new engine version — gitversion.json above. + +### Inferences +- On any feature branch the handshake is effectively disabled (it can no longer refuse), so local testing never exercises the refusal path; conversely, the guard test still enforces exact major.minor equality on that same branch. The two mechanisms disagree about how strict a prerelease should be. +- A branch engine installs `main` skills, i.e. neither the branch's skills nor the skills the branch's engine was tested against. + +### Gaps +- Whether GitVersion really drops `next-version` after the `v0.9.0` tag is **Unverified** (documented, never observed) — [06-2:99](docs/feature-packages/06-2-skill-conventions-and-version.md). + +## 5. Concrete local-testing scenarios and pain points; documented rationale for lockstep + +### Takeaway +Lockstep was chosen so that "the tag that builds the engine also names the tree the agent installs", which makes a release self-consistent without any engine-side record. The costs fall on development: a minor raise is a 20-file atomic edit coupled to GitVersion; prerelease engines disable the check; local skill testing needs the env override and loses all version reporting; `init` leaks prerelease versions into a repository's `.shadekit/`. + +### Cited Findings +**Documented rationale** +- FACT: concept §9.6: "Plugin content and CLI share one version number. A skill checks `shade-kit version` before it runs." Content packing was replaced 2026-11-13 by "an engine installs the tree of its own tag `v`" — [research/shade-kit-concept.md §9.6 (lines ~354-358)](research/shade-kit-concept.md). +- FACT: 07: no `version` in `plugin.json` "so no second version is kept by hand"; "Plugin and CLI release together … now holds through the tag" — [07:41,44](docs/feature-packages/07-claude-code-integration.md). 19: "every release delivers engine and agent content with the same version number, so the version handshake works out of the box" — [19:14,45](docs/feature-packages/19-release-and-distribution.md). +- FACT: the guard exists because of a review Major: a release engine installs the skills of its own tag; if they carry another major.minor every handshake fails with 50 and the hint `integrations install` installs the same stale skills again (loop) — [07:240](docs/feature-packages/07-claude-code-integration.md), [README.md:187](docs/feature-packages/README.md). +- FACT: acknowledged open points: the hand-raise "still breaks the rule in `GitVersion.yml` that no version is maintained by hand"; writing the version from GitVersion (e.g. a Cake task, package 19) and a pre-tag check in `verify-tag` are open/not selected — [06-2:98](docs/feature-packages/06-2-skill-conventions-and-version.md), [19:66](docs/feature-packages/19-release-and-distribution.md). "The value is raised by hand for every release whose major or minor differs" — [06-2:100](docs/feature-packages/06-2-skill-conventions-and-version.md). +- FACT: proposed rule: a format version change is at least a minor release "so the handshake rule … catches it" (**Proposed**) — [19:46](docs/feature-packages/19-release-and-distribution.md). + +**Scenarios (FACT where code/docs say so; inference marked)** +1. *Testing changed skills with a local engine build.* FACT: without override, the local (prerelease) engine installs `main` from GitHub, not the working tree (§4). The documented route is `SHADE_KIT_MARKETPLACE_SOURCE=$PWD shade-kit integrations install` ([CLAUDE.md command list](CLAUDE.md); smoke check of FP07-AC1 used it in an isolated `CLAUDE_CONFIG_DIR` [07:253](docs/feature-packages/07-claude-code-integration.md)). FACT: then `kitVersion`/`ref` are `null` in `version --json` [07:208](docs/feature-packages/07-claude-code-integration.md). Inference: there is no way to see which skill version is installed; the handshake passes anyway because the engine is a prerelease. **Unverified**: whether editing skills in the working tree is picked up by `integrations update` for a directory marketplace without a new commit (Claude Code's plugin version is the commit SHA for git sources; for a directory marketplace the docs only say `marketplace update` refreshes "branch, tag, and directory marketplaces" [07:100](docs/feature-packages/07-claude-code-integration.md)). Claude Code alternative `--plugin-dir` was used in a headless check [06-2:75](docs/feature-packages/06-2-skill-conventions-and-version.md) and bypasses the engine entirely. +2. *Testing an engine change with released skills.* FACT: no tag currently carries `.claude-plugin/`, so "released skills" are not installable at all yet [README.md:127](docs/feature-packages/README.md). Inference: once there is a release `v0.9.x`, a branch engine `0.10.0-x` against `0.9.x` skills gives only a warning — the real-world refusal (release engine vs. older skills) can only be reproduced with a release-version build, i.e. on a tag or (probably) on `main`. +3. *Skill change that needs a new engine feature.* FACT: the 0.9.0 raise was forced because `shade-kit-new` uses `--move-source` [06-2:86](docs/feature-packages/06-2-skill-conventions-and-version.md). Inference: the handshake cannot express "needs engine ≥ 0.9.1" (patch is ignored), so any skill→engine dependency forces a kit-wide minor raise (20 files + `GitVersion.yml`), even when 18 of 19 skills are unchanged. +4. *Engine-only minor raise* (e.g. new format version per the 19 proposal, or a `+semver: minor`). Inference from the guard: forces all 19 skills + 7 handshake lines to be rewritten in the same commit, although no skill text changed. +5. *Raising the minor on a feature branch.* FACT: the commit that raises the skills must raise `next-version` too or "the build of that commit fails the guard"; `next-version` needs the `v` prefix ("Failed to parse 0.9.0 into a Semantic Version" without it) — [06-2:99](docs/feature-packages/06-2-skill-conventions-and-version.md). Inference: two parallel feature branches that both "need" a minor raise conflict on 20+ files; a branch that is merged after the release tag of the minor it raised must be re-raised. +6. *Prerelease tags.* FACT: `verify-tag` accepts `v0.9.0-beta.1` [release.yml:29](.github/workflows/release.yml). Inference: such a tag builds a prerelease engine, which installs from `main`, not from its own tag (IntegrationService.cs:265), and the guard requires plain `x.y.z` in skills — so prerelease releases do not get a self-consistent install. +7. *Untagged `main` build.* FACT: release-labelled version whose tag does not exist → install from `main` with `integration-release-tag-missing` [07:72-77](docs/feature-packages/07-claude-code-integration.md); every `integrations install` from such an engine first does a network `git ls-remote`. +8. *dotnet global tool from a local package.* FACT: `PackAsTool`, `ToolCommandName shade-kit`, `PackageId CreativeCoders.ShadeKit.Cli`, version = GitVersion SemVer (no version in csproj) — [src/CreativeCoders.ShadeKit.Cli/CreativeCoders.ShadeKit.Cli.csproj:6-8](src/CreativeCoders.ShadeKit.Cli/CreativeCoders.ShadeKit.Cli.csproj). Inference: a locally packed tool is a prerelease (`0.9.0-.`), so installing it needs a prerelease-aware install and every commit gives a new version; the installed tool keeps the version of its commit while the working tree moves on — the handshake will not notice a drift because the engine is a prerelease. (Exact `dotnet tool install` flags not checked — **Unverified**.) +9. *Using a local engine on a real repository.* FACT: `init` writes the prerelease engine version into `config.json` `kitVersion` and `templates.lock.json` [RepositoryInitializer.cs:196-199,248](src/CreativeCoders.ShadeKit.Core/Init/RepositoryInitializer.cs). Inference: testing `init` with a branch build commits strings like `0.9.0-rework-versioning-branch-mgmt.4` into the target repo; package 18 `upgrade` plans to compare/overwrite these [18:56,61](docs/feature-packages/18-upgrade.md). +10. *Cost of the handshake.* FACT: `version` starts each detected agent CLI (`plugin list`, `marketplace list`) on every call, also in each handshake: 0.73 s with `claude` on `PATH` vs 0.08 s without (measured 2026-11-13) — [07:207](docs/feature-packages/07-claude-code-integration.md). +11. *Skill scenario runs.* FACT: fixtures are generated from the current engine with the kit version read from the `shade-kit-next-steps` frontmatter (§2). Inference: they always pass the handshake on a branch build (prerelease) and do not cover the 50 refusal unless a release build is used. + +### Inferences +- The root friction is that one number carries two meanings: "which product build is this" (changes every commit, GitVersion-owned) and "which CLI contract do the skills rely on" (should change rarely, author-owned). The guard forces both to move together at minor granularity. + +### Gaps +- No measured data on how often developers hit the guard locally; the log only shows the two forced raises above. + +## 6. Does the CLI expose a protocol/contract version or capability list usable as a compatibility contract? + +### Takeaway +No explicit CLI contract version or capability list exists. The closest existing precedents are the `formats` map in `version --json` (integer format version per file type, with a `minEngineVersion` table) and the stable `error.code`/warning-code vocabulary; the JSON envelope itself is unversioned. + +### Cited Findings +- FACT: `CliJsonEnvelope` has exactly `ok`, `data`, `warnings`, `error` — no version field — [src/CreativeCoders.ShadeKit.Cli/Output/CliJsonEnvelope.cs:27-48](src/CreativeCoders.ShadeKit.Cli/Output/CliJsonEnvelope.cs). +- FACT: `version --json` `data.formats` lists format id → `CurrentVersion` from `IFormatRegistry` — [VersionCommand.cs:126](src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommand.cs); output observed `{config:1,gates:1,feature:1,current-feature:1,templates-lock:1}` (run). +- FACT: format versioning model: integer `schemaVersion` per file, a migration chain per type, `minEngineVersion` stamped on every write, "The format version changes only when the structure changes, not with every engine release" — [research/shade-kit-concept.md §9.1](research/shade-kit-concept.md); `FormatDefinition(id, minEngineVersions)` [src/CreativeCoders.ShadeKit.Core/Formats/FormatDefinition.cs:33-39](src/CreativeCoders.ShadeKit.Core/Formats/FormatDefinition.cs); `FormatTooNewException` → "requires shade-kit >= {MinEngineVersion}" [CliErrorMapper.cs:852-855](src/CreativeCoders.ShadeKit.Cli/Output/CliErrorMapper.cs). +- FACT: skills react to `error.code`, not exit codes; every exit code has a kebab-case error code; warnings have codes — [CLAUDE.md Agent contract](CLAUDE.md). +- FACT: the 2026-11-04 split log noted that the handshake "had no source for the skill's own kit version (… no plugin manifest, `version --json` returns only `engineVersion` and `formats`)" — [README.md:174](docs/feature-packages/README.md). + +### Inferences +- The format-version design (integer, raised only on structural change, min-engine table, migration) is a ready in-repo template for a CLI contract version: e.g. `data.contract: { version: N, minSupported: M }` next to `formats`, checked by `--expect-contract N`. +- Unknown options are silently ignored by the parser (`--expect=1.2.3` is ignored, exit 0) — [06-1:40](docs/feature-packages/06-1-engine-version-check.md); so a skill cannot probe a capability by just calling an option; an explicit capability/contract declaration is needed. + +### Gaps +- No capability list was found anywhere (`git grep -i capabilit` not run exhaustively; the `version` data model shows none — FACT for `VersionCommandData`). + +## 7. Change map per candidate scheme + +### Takeaway +(a) is the smallest change but keeps all coupling; (b) is limited by the no-frontmatter/no-transformation constraints and by Claude Code's SHA-based plugin versioning; (c) and (d) decouple the release streams and remove the GitVersion dependency of the guard, at the cost of touching the checker, the version envelope, skills, guard, integrations ref logic (c only), and many docs. + +### Cited Findings (the files involved — all verified to exist and to hold the named logic, see §1–§6) +**(a) Keep lockstep, automate the bump** (script/Cake task rewrites frontmatter + handshake texts from GitVersion `MajorMinorPatch`, or from `next-version`) +- New: `build/Tasks/Task.cs` (+ registration in [build/Program.cs](build/Program.cs)), or a script; optionally a check task in `verify-tag` of [.github/workflows/release.yml:24-36](.github/workflows/release.yml) (open point in [19:66](docs/feature-packages/19-release-and-distribution.md)). +- Rewritten by the tool (still committed, because the plugin is installed from the git tree and there is no install-time transformation, [08:49](docs/feature-packages/08-copilot-and-codex-integration.md)): 19 × `skills/*/SKILL.md:5`, 5 handshake lines, 2 command-list lines (§3); `GitVersion.yml:15`. +- Unchanged: `SkillKitVersionTests` (stays as safety net), engine code. Docs: 06-2 (open point "writing the version from GitVersion" [06-2:98](docs/feature-packages/06-2-skill-conventions-and-version.md)), 19, CLAUDE.md skill conventions. +- Inference: does not solve local testing (prerelease = no check; branch installs `main`), nor the skill→engine patch dependency, nor parallel-branch conflicts; only removes typing. + +**(b) Skills read the version from a generated/bundled file** +- Constraint facts: the model does not see frontmatter (§3); Claude Code gives the skill "Base directory for this skill: " [06-2:71](docs/feature-packages/06-2-skill-conventions-and-version.md) (Copilot/Codex equivalent **Unverified**); a root `plugin.json`/`marketplace.json` or agent-specific manifest is forbidden by [SingleSkillSourceGuard.cs:62-68](tests/CreativeCoders.ShadeKit.Core.Tests/Skills/SingleSkillSourceGuard.cs); adding `version` to `.claude-plugin/plugin.json` would replace the commit-SHA plugin version [07:41](docs/feature-packages/07-claude-code-integration.md) (Inference: Claude Code would then only see an update when the version changes — **Unverified** behaviour). +- Variant b1 (skill reads file, passes value): touches 5 handshake steps + 2 command lists (add a read step, agent-specific text per [CLAUDE.md one-source rule](CLAUDE.md)), `SkillKitVersionTests` (check file instead of frontmatter/text), `SkillAgentWordingTests` possibly, `tests/skill-scenarios/generate_fixtures.py:38,107-116` and `checks/check_runs.py:223-224`, 06-2, 06-5, 06-6, 06-9, CLAUDE.md. +- Variant b2 (engine reads it: e.g. `shade-kit version --json --skill-dir ` parses `metadata.version` from the installed `SKILL.md`): touches `VersionCommandOptions`, `VersionCommand`, `EngineVersionChecker` (or new reader), `CliErrorMapper`, new exit/error codes in `ShadeKitCliExitCodes`/`ShadeKitCliErrorCodes`, end-to-end tests in `tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Version/`, the 5 handshakes. Still needs the file to be written/committed (≥1 place), so only the count drops. +- Inference: b reduces the edit count but not the coupling; it adds an agent-dependent step (base dir), which the "agent-agnostic without loss" rule in CLAUDE.md must justify. + +**(c) Independent versions with minimum-version expectations each way** (skills declare `minEngine`, engine declares `minSkills`/supported kit range) +- Engine: `EngineVersionChecker.cs:36-53` (new rule: engine ≥ min, kit ≥ engine's min), `IEngineVersionChecker`, `EngineVersionCheckResult`, `EngineVersionMismatchDirection`, exceptions/warnings in `Versions/`, `VersionCommandOptions.cs:21-22` (new option, e.g. `--min-engine`, plus passing the kit version), `VersionCommandData.cs` (expose `minKitVersion`), `CliErrorMapper.cs:198,417,690` (messages), `ShadeKitCliExitCodes.cs:218`, `ShadeKitCliWarningCodes.cs:82` (prerelease rule must be redefined), tests `EngineVersionCheckerTests`, `VersionCommandTests`, `CliErrorMapperTests`, `ProgramTests`. +- Integrations: the ref `v` no longer names the matching skills → `IntegrationService.cs:251-290` (choose a skills release, e.g. a separate tag prefix such as `skills-v`, or "latest skills tag compatible with engine"), `MarketplaceSource.cs:67,199-204` (`GetKitVersion` parsing), `GitRemoteTagChecker` (list tags instead of one), `IntegrationServiceTests`, `MarketplaceSourceTests`, the three agent integrations' `previousKitVersion` logic (Claude/Copilot/Codex `*Integration.cs`), `IntegrationsCommandsEndToEndTests`, `IntegrationsMultiAgentEndToEndTests`. +- Versioning/CI: `GitVersion.yml` (one GitVersion stream only; the skills version would be hand-kept or a second tag prefix/config), `release.yml` (separate skills release or tag pattern, `verify-tag`), `build/BuildContext.cs:57` (release naming). +- Skills/guards: 19 frontmatters (+ new `metadata.minEngine`?), 5 handshakes + 2 lists, `shade-kit-next-steps/SKILL.md:95` (refusal text), `SkillKitVersionTests` (rewrite: min engine ≤ build version instead of major.minor equality), `tests/skill-scenarios/*`. +- Docs: 06-1, 06-2, 07 (Version pin, Kit version guard), 08 (Version pin and state), 18 (`kitVersion` semantics), 19 (Version), concept §9.6, README consistency log, CLAUDE.md (v1 scope, layout, skill conventions, command examples). + +**(d) Separate contract/protocol version** (integer, raised only on breaking CLI/JSON-contract change; product versions stay GitVersion) +- Engine: new constant/registry (pattern: `FormatRegistry`/`FormatDefinition`), `VersionCommandData.cs` (add e.g. `contract` next to `formats`), `VersionCommandOptions.cs` (e.g. `--expect-contract ` or reuse `--expect` with a new grammar), a checker in `Versions/` (or rewrite `EngineVersionChecker`), `CliErrorMapper` messages, `ShadeKitCliExitCodes`/`ErrorCodes`/`WarningCodes` (50 semantics), tests as in (c). +- Skills: 5 handshakes + 2 lists (one integer instead of SemVer), frontmatter (`metadata.version` kept for humans or replaced by `metadata.contract`), `shade-kit-next-steps/SKILL.md:95`; `SkillKitVersionTests` → compares against the engine's contract constant (pure code, no GitVersion), which removes the build-version dependency of the guard; `tests/skill-scenarios/generate_fixtures.py`, `check_runs.py`. +- Versioning/CI: `GitVersion.yml:6-15` (`next-version` and its comment no longer needed for skills), nothing mandatory in `release.yml`; integrations can keep `v` pinning (`IntegrationService.cs:265-290` unchanged) since the tag tree still holds the skills the engine was built with; the contract check then protects the override/`main` paths too. +- Docs: 06-1, 06-2, 07 (Kit version guard, FP07-AC2 wording "same kit version"), 08, 19 (Version section, "format change ⇒ minor" proposal), concept §9.6, CLAUDE.md. + +### Inferences +- (d) is the only scheme that (1) needs no GitVersion coupling in the guard, (2) keeps the handshake meaningful on prerelease/local builds (contract number is identical on every build of the same code), and (3) can reuse the in-repo `formats` precedent. It still needs a rule for who raises the contract number (engine authors, when a skill-visible command/JSON/error code changes) — which is a review discipline, not something GitVersion computes. +- (c) is the most invasive because the marketplace ref derivation (`v`) is built on lockstep; a hybrid "(d) for compatibility + keep `v` tag pinning for distribution" touches far fewer integration files. +- Whatever the scheme, FP07-AC2 ("installed skills have the same kit version as the engine that installed them", [07:254](docs/feature-packages/07-claude-code-integration.md)) and FP19-AC3 ([19:59](docs/feature-packages/19-release-and-distribution.md)) are acceptance criteria phrased in lockstep terms and would need rewording for (b)-(d). + +### Gaps +- How Copilot/Codex expose a skill's base directory (relevant for b) — **Unverified**, not in repo docs. +- Whether Claude Code honours a `version` in `plugin.json` for update detection differently than the SHA — **Unverified** in repo (relevant for b and for any scheme that versions the plugin itself). +- Effort estimates per scheme were not derived; the lists above are file inventories only. diff --git a/research_notes/Versionierung von CLI und Skills/versioning_tooling.md b/research_notes/Versionierung von CLI und Skills/versioning_tooling.md new file mode 100644 index 0000000..6c36045 --- /dev/null +++ b/research_notes/Versionierung von CLI und Skills/versioning_tooling.md @@ -0,0 +1,187 @@ +# Versioning tooling for a two-component repository (.NET CLI + Markdown skills) + +Research date: 2026-11-21. Repository facts in this file were read from the shade-kit working tree and are labelled **FACT (repo)**. Web facts carry their source URL. Anything not verified is labelled as inference or listed under Gaps. + +Baseline in the repository: +- **FACT (repo):** `Directory.Packages.props` references `GitVersion.MsBuild` `6.8.2` as a `GlobalPackageReference`; `GitVersion.yml` uses the v6 flat format with `mode: ContinuousDelivery`, `tag-prefix: 'v'`, `next-version: v0.9.0`, `main` with `label: ''`, `increment: Patch`, and `feature` with `label: '{BranchName}'`, `increment: Inherit`. +- **FACT (repo):** 19 entries under `skills/` and 26 occurrences of the literal `0.9.0` under `skills/` (`grep -rn 0.9.0 skills | wc -l`). +- **FACT (repo):** `SkillKitVersionTests` parses the frontmatter line with `^ version:(?:[ \t]+(?.*?))?[ \t]*$` and accepts it only if `SemanticVersion.TryParse(value)` succeeds, the version is not a prerelease, and `version.ToString() == value`. A trailing YAML comment on that line (for example a release-please marker) would therefore be part of `value` and fail the guard. It also scans `--expect ` and the "is the kit version of this skill" sentence. + +## GitVersion: multiple components, tag prefixes, path filters, modes, feature-branch builds, pain points + +### Takeaway +GitVersion can serve two components only by running it twice with different configs (different `tag-prefix` plus `ignore.paths` regexes); it computes a version but never writes it into SKILL.md, so it cannot by itself remove the hand edits of the skills. GitVersion 7.0 (released Nov 2026) moves the config into nested `calculation:`/`output:` sections, so the repo's v6 flat `GitVersion.yml` needs a migration on upgrade. + +### Cited Findings +- Latest releases: 7.0.1 (20 Nov, marked "Latest"), 7.0.0 (17 Nov), 7.0.0-beta.1/.2 (16/17 Nov), latest 6.x is 6.8.2 (10 Jul). The release page shows no year. 7.0.1 fixes issue #5501 "TrunkBased workflow + ignore.paths loses feature increment when an ignored merge is the merge base"; 7.0.0 fixed #5245 "Version calculation performs one revision walk per version tag (O(tags x commits))" — [GitVersion releases](https://github.com/GitTools/GitVersion/releases) +- The gitversion.net configuration and modes pages now redirect ("Continue to 7.0") to `/7.0/docs/...` — [gitversion.net configuration](https://gitversion.net/docs/reference/configuration) +- v7 breaking changes stated on the config page: calculation settings move under `calculation`, output settings under `output`; `workflow` stays at the root; the v6 flat layout works in 7.0 only with `GITVERSION_CONFIGURATION_VERSION=v6` and produces a warning; `--override-config` uses nested keys and rejects flat v6 keys — [GitVersion 7.0 configuration](https://gitversion.net/7.0/docs/reference/configuration) +- `tag-prefix` is "a regular expression which is used to trim Git tags before processing"; default `[vV]?`; the page says nothing about per-component prefixes such as `app-v` — [GitVersion 7.0 configuration](https://gitversion.net/7.0/docs/reference/configuration) +- `next-version` "is not a permanent replacement for `git tag` and should only be used intermittently"; if behaviour is odd, remove it and tag an appropriate historical commit instead. The 7.0 page does not state that `next-version` is ignored once a tag at or above it exists — [GitVersion 7.0 configuration](https://gitversion.net/7.0/docs/reference/configuration) +- `ignore` has `sha`, `commits-before`, `paths`, `tags`, `branches`. `paths` is a list of regexes; a commit is ignored only if all changed paths match; matching is case-insensitive unless `(?-i)`. Monorepo examples verbatim: `calculation: ignore: paths: - '^ProjectB/.*'` and `- '^(?!ProjectA/|LibraryC/).*'` ("filter only those commits that belong to a specific project in a monorepo"). Caveat: ignored commits are excluded only when searching for a version source; other parts such as build metadata still use them — [GitVersion 7.0 configuration](https://gitversion.net/7.0/docs/reference/configuration) +- Config file selection: the CLI supports `--config` and `--override-config`; the page does not mention GitVersion.MsBuild per-project config options — [GitVersion 7.0 configuration](https://gitversion.net/7.0/docs/reference/configuration) +- Modes (one-line summaries only): ManualDeployment "keeps the calculated pre-release version and adds build metadata; intermediate commits can share a semantic version"; ContinuousDelivery "requires a numbered pre-release version and incorporates the commit count into its pre-release number"; ContinuousDeployment "removes the pre-release label from the calculated version"; "Tags and increment rules determine when the released version changes" — [GitVersion 7.0 modes](https://gitversion.net/7.0/docs/reference/modes/) +- Built-in defaults: GitFlow/v1 (default when `workflow` is unset) and GitHubFlow/v1 use `ContinuousDelivery` globally and `ManualDeployment` for `release`, `feature`, `unknown`; TrunkBased/preview1 (experimental) uses `ContinuousDeployment` on `main` — [GitVersion 7.0 configuration](https://gitversion.net/7.0/docs/reference/configuration) +- Feature-branch label defaults to `{BranchName}` from the branch regex; `{Sha}`, `{ShortSha}`, `{env:VARIABLE_NAME}` with `??` fallbacks are available — [GitVersion 7.0 configuration](https://gitversion.net/7.0/docs/reference/configuration) +- `commit-message-incrementing` defaults to `Enabled`; patterns `+semver: breaking|major`, `feature|minor`, `fix|patch`, `none|skip`; `=semver:` resets earlier increments — [GitVersion 7.0 configuration](https://gitversion.net/7.0/docs/reference/configuration) +- GitVersion 6.0.0 renamed `tag` to `label` and removed the init wizard (breaking changes listed in BREAKING_CHANGES.md) — [newreleases: GitVersion 6.0.0](https://newreleases.io/project/github/GitTools/GitVersion/release/6.0.0) + +### Inferences +- Independent versions with GitVersion = two invocations: CLI with `tag-prefix: 'cli-v'` and `ignore.paths: ['^skills/.*']`; skills with `tag-prefix: 'skills-v'` and `ignore.paths: ['^(?!skills/).*']`. GitVersion.MsBuild would compute only the CLI version; the skills version would come from the GitVersion CLI (Cake via `GitVersion.Tool`) with `--config`/`--override-config`. +- GitVersion has no file-writing step for Markdown; the skills literal still has to be written by something else and committed before the tag. So GitVersion alone does not remove the manual SKILL.md edits; it can only remove `next-version` if minors are raised via `+semver: minor` commits or tags. +- Under `ContinuousDelivery` on a feature branch (current repo config), a local build yields `-.`; that prerelease engine is what makes local skill testing awkward (the guard compares major.minor, `version --expect` only warns for a prerelease engine per the repo's CLAUDE.md). +- Upgrading GitVersion.MsBuild 6.8.2 -> 7.x requires migrating the flat `GitVersion.yml` to nested `calculation:` or setting `GITVERSION_CONFIGURATION_VERSION=v6` temporarily. + +### Gaps +- Whether a `tag-prefix` of `cli-v` makes GitVersion skip tags of the other component (`skills-v0.4.0`) cleanly or tries to parse them — not documented on the pages fetched. +- Exact example version strings per mode on a feature branch (the per-mode subpages were not fetched). +- Year of the 7.0.0 release is inferred (Nov 2026, after 6.8.2 of 10 Jul); the release page shows no year. +- Documented statement that `next-version` is ignored once a tag >= exists was not found in the 7.0 docs (the repo's own `GitVersion.yml` comment says "not yet observed"). + +## Nerdbank.GitVersioning (NBGV): version.json per directory, pathFilters, height, set-version, prepare-release, cloud builds, local builds, non-.NET folders + +### Takeaway +NBGV is the most monorepo-capable of the git-height tools: one `version.json` per directory with `pathFilters` gives each component its own version height. Unlike GitVersion, the major.minor lives in a committed file (`version.json`), and `nbgv set-version` / `prepare-release` edit it — but it still does not rewrite SKILL.md text. + +### Cited Findings +- Current NuGet package: Nerdbank.GitVersioning 3.10.94 — [NuGet](https://www.nuget.org/packages/nerdbank.gitversioning) +- `pathFilters` default is `[":/"]` (whole repo counts toward height). A commit affects a project only if it changes at least one matched path; Foo/Bar/Quux example with `"pathFilters": ["."]` per project: a change to `/README.md` affects no project. Syntax: relative to the `version.json` directory, absolute with `:/`, exclusions with `:!` or `:^`, wildcards `*`, `?`, `**`; matching follows `core.ignorecase` — [NBGV path filters](https://dotnet.github.io/Nerdbank.GitVersioning/docs/path-filters.html) +- `nbgv path-filters check` (non-zero exit on drift, suited to CI) and `update` derive filters from the MSBuild project graph (`.csproj`/`.vbproj`, `--ext` for others); a `version.json` without associated projects is skipped — [NBGV path filters](https://dotnet.github.io/Nerdbank.GitVersioning/docs/path-filters.html) +- `version.json` can live in the project directory or any ancestor; `"inherit": true` lets a subdirectory file override settings, e.g. `"prerelease": "beta"` turns inherited `1.2` into `1.2-beta`. Fields: `version`, `pathFilters`, `publicReleaseRefSpec`, `cloudBuild.setVersionVariables`, `cloudBuild.buildNumber`, `release.branchName` (`v{version}`), `release.versionIncrement`, `release.firstUnstableTag`, `versionHeightOffset` (+`versionHeightOffsetAppliesTo`), `nugetPackageVersion.semVer` (default 1), `gitCommitIdShortFixedLength` — [NBGV version.json](https://dotnet.github.io/Nerdbank.GitVersioning/docs/versionJson.html) +- Builds from refs matching `publicReleaseRefSpec` drop the `-g` commit-id suffix; other refs keep it. Changes to `version.json` take effect once committed (push not required); `gitCommitIdIncludeDirty` can append `-dirty` — [NBGV version.json](https://dotnet.github.io/Nerdbank.GitVersioning/docs/versionJson.html) +- `nbgv prepare-release` creates a release branch (`release/v1.2` from `1.2-beta`), removes the prerelease tag there (or sets a new one, e.g. `nbgv prepare-release rc`), increments main's version (default: minor, prerelease `alpha`), merges back resolving the `version.json` conflict (`--no-merge` to skip); `--versionIncrement Major`. `nbgv tag` creates a tag per `release.tagName` (default `v{version}`). `nbgv cloud` sets cloud build numbers/variables. There is a Rust CLI (Windows/Linux/macOS) with `get-version`, `set-version`, `tag`, `get-commits`, `cloud`, `prepare-release`, but without `install`/`path-filters` and without MSBuild integration — [NBGV nbgv CLI](https://dotnet.github.io/Nerdbank.GitVersioning/docs/nbgv-cli.html) +- A 3.x regression (v3.4.194) made version height always zero with path filters, linked to path-filter code not converted for the managed git implementation — [NBGV issue 587 (via dependabot redirect)](https://github-redirect.dependabot.com/dotnet/Nerdbank.GitVersioning/issues/587) + +### Inferences +- A `skills/version.json` with `"pathFilters": ["."]` and a `src/version.json` (or root with exclusion `":!/skills"`) would give independent heights. Since `path-filters update` skips a `version.json` without projects, the skills filters would be hand-written (they are static, so low cost). +- NBGV's version is "major.minor in a file + git height for patch". That fits the skills' rule (literal major.minor in git) better than GitVersion's tag-derived model: the release action for a minor raise is a committed edit of `version.json`, not a tag. But the patch is height-derived, so `metadata.version` (x.y.z) in SKILL.md would still diverge from the computed patch unless the skills only carry major.minor or the patch is fixed at `.0`. +- NBGV is tag-optional (versions come from `version.json` + height), which differs from the repo's current "release = tag `v` on main" rule; `release.tagName`/`nbgv tag` can keep tags, but the CI tag check would need to match. + +### Gaps +- Whether `nbgv get-version` accepts a path argument for a non-.NET folder (documented flag not confirmed on the fetched page). +- Current exact version-string format for non-public builds with `nugetPackageVersion.semVer: 2` (e.g. `1.2.3-g` vs `1.2.3-beta.g`) — the public/stable doc page returned 404. + +## MinVer: MinVerTagPrefix for multiple components, local build behaviour + +### Takeaway +MinVer is the simplest tag-only tool and supports multiple components via `MinVerTagPrefix`, but has no path filtering: height counts all commits unless `MinVerIgnoreHeight` is set. Like GitVersion it computes but never writes files. + +### Cited Findings +- Algorithm: a tagged commit uses the tag; otherwise latest tag in history; an RTM tag `1.0.0` yields `1.0.1-alpha.0` + height; no tag -> `0.0.0-alpha.0` + height; example `1.0.0-beta.1` at height 42 -> `1.0.0-beta.1.42` — [MinVer README](https://raw.githubusercontent.com/adamralph/minver/main/README.md) +- Multiple components: give each project its own `MinVerTagPrefix` (e.g. `main-`, `ext-`); every commit affects height so changes in one project change the other's version; `MinVerIgnoreHeight` prevents this — [MinVer README](https://raw.githubusercontent.com/adamralph/minver/main/README.md) +- `MinVerMinimumMajorMinor` sets the MAJOR.MINOR floor for interim builds before the first tag; `MinVerDefaultPreReleaseIdentifiers` (default `alpha.0`, e.g. `preview.0`); `MinVerBuildMetadata` (by default only in the informational version); `MinVerSkip` (example: disable for Debug); `minver-cli` prints the version for non-SDK outputs; `MINVERVERSIONOVERRIDE` env var to share a version — [MinVer README](https://raw.githubusercontent.com/adamralph/minver/main/README.md) +- Shallow clones in CI can hide tags and fall back to the default version; set sufficient fetch depth — [MinVer README](https://raw.githubusercontent.com/adamralph/minver/main/README.md) + +### Inferences +- `MinVerMinimumMajorMinor` is the MinVer analogue of GitVersion's `next-version`; it would still be a hand edit per minor raise. +- For the skills component, `minver-cli --tag-prefix skills-v` could compute a version, but MinVer has no notion of "only commits under skills/", so the skills prerelease height would move on CLI-only commits. + +### Gaps +- Current MinVer version number (README shows only badges; not fetched from NuGet). + +## release-please: manifest mode, component tags, extra-files/generic updater in Markdown, .NET support, Conventional Commits, release PRs + +### Takeaway +release-please is the only evaluated tool that both (a) keeps independent versions and tags per path in one repo and (b) writes the new version into arbitrary text files and commits it via a release PR before the tag — which is exactly what the "files must already contain the right text in git" constraint requires. It works on Markdown via the generic updater's markers, but the markers must sit on the version lines, which clashes with the repo's current frontmatter guard regex and adds marker noise to SKILL.md text. + +### Cited Findings +- Manifest mode: `release-please-config.json` (settings) + `.release-please-manifest.json` (current version per package; must exist at the tip of the target branch). Each key under `packages` is a repo-relative path; non-node types need a `package-name`. Default tag `-v`; `include-component-in-tag: false` -> `v`. `separate-pull-requests` default `false` (one combined Release PR). Commits are assigned to packages by path; `exclude-paths`. `bootstrap-sha`, `last-release-sha`, `release-as` (forces a version, "ignoring conventional commits"; reset to `""`). Prerelease: `prerelease-type`, `prerelease: true`, "prerelease" versioning strategy. `bump-minor-pre-major`, `bump-patch-for-minor-pre-major`. `linked-versions` plugin moves all group members to the highest version when one is released. A root package `"."` triggers on any change; use `exclude-paths` on `"."` to keep sub-package changes out — [release-please manifest-releaser.md](https://raw.githubusercontent.com/googleapis/release-please/main/docs/manifest-releaser.md) +- The manifest doc's action example still shows `googleapis/release-please-action@v2` with `command: manifest` (stale relative to current action versions) — [release-please manifest-releaser.md](https://raw.githubusercontent.com/googleapis/release-please/main/docs/manifest-releaser.md) +- Schema: `include-v-in-tag` ("Defaults to `true`"), `tag-separator` ("separator between the component and version in the GitHub tag"), `include-component-in-tag` (default `true`), `version-file` ("Used by `ruby` and `simple` strategies"), `exclude-paths` ("If all files from commit belong to one of the paths it will be skipped"), `separate-pull-requests`, `initial-version`; `release-type` is a free-form string — [release-please config schema](https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json) +- `simple` release type: "A repository with a version.txt and a CHANGELOG.md" — [release-please customizing.md](https://raw.githubusercontent.com/googleapis/release-please/main/docs/customizing.md) +- `extra-files`: default updaters chosen by extension (`.json` -> `version` property or `jsonpath`; `.yaml/.yml` with `jsonpath`; `.toml` with `jsonpath`; `.xml` with `xpath`); force generic with `{"type": "generic", "path": "..."}`. Generic markers: inline `x-release-please-version` / `-major` / `-minor` / `-patch` (only that line), block `x-release-please-start-version` ... `x-release-please-end`; annotations "usually in comments". The doc's own example is `"extra-files": ["path/to/file.md"]` — [release-please customizing.md](https://raw.githubusercontent.com/googleapis/release-please/main/docs/customizing.md) +- Generic updater source: `VERSION_REGEX = /(?\d+)\.(?\d+)\.(?\d+)(-(?[\w.]+))?(\+(?[-\w.]+))?/` applied with non-global `line.replace` — only the first semver on a marked line is replaced; block start line is kept unchanged; no file-type check, content split with `/\r?\n/`; scopes also include `version-date` and `date` — [release-please generic.ts](https://raw.githubusercontent.com/googleapis/release-please/main/src/updaters/generic.ts) +- An XML example with an HTML comment `` appears in a release-please-action PR (search snippet) — [release-please-action PR 410](https://github-redirect.dependabot.com/googleapis/release-please-action/pull/410) + +### Inferences +- Configuration sketch for (B) independent versions: packages `"src"` (release-type `simple`, component `cli`, tags `cli-v1.2.0`) and `"skills"` (release-type `simple`, component `skills`, tags `skills-v0.4.0`, `extra-files` = every `SKILL.md` with type `generic`). For (A) one shared version: one package `"."` or the `linked-versions` plugin over both components. +- Markdown placement: frontmatter line ` version: 0.9.0 # x-release-please-version` is valid YAML, but the repo's `MetadataVersionRegex` would capture `0.9.0 # x-release-please-version` and fail `version.ToString() == value` (**FACT (repo)**: see baseline), so the guard would need a change. Body text: either an inline HTML comment on the handshake line (visible to the model as raw text) or a block `` ... `` around the handshake paragraph only; wrapping a whole file is risky because the first semver on every line would be rewritten (e.g. other tool versions like "Claude Code 2.1.318"). +- `extra-files` cannot be globbed in the docs fetched; 19 skills -> 19 explicit entries to maintain (a new skill must be added to the config; a guard test could check that). +- Conventional Commits drive bumps (repo already uses them per CLAUDE.md). For the .NET CLI, release-please would own the tag; the build version would then have to come from the tag (GitVersion/MinVer with `tag-prefix cli-v`) or from `version.txt` read by the Cake build. Mixing release-please's own version with GitVersion's computed version is a source-of-truth conflict to resolve. +- Release flow: release-please opens/updates a Release PR; merging it commits the bumped files and creates the tag and GitHub release; the existing `release` workflow (tag `v`) would need to accept component tags or keep `include-component-in-tag: false` for the CLI. +- Pre-1.0 bump semantics: `bump-minor-pre-major` maps breaking changes to minor, matching the repo's current "breaking change raises the minor below 1.0.0" rule in `GitVersion.yml`. + +### Gaps +- Whether `extra-files` paths are resolved relative to the package path or the repo root (schema says only "The path to the file"); not verified. +- Whether the generic updater preserves CRLF/trailing newline (source splits on `/\r?\n/`; join behaviour not read) — relevant to the repo's line-ending rules. +- Current release-please / release-please-action version numbers not verified in this session. + +## changesets, semantic-release (monorepo), Knope, cocogitto — fit for .NET + Markdown + +### Takeaway +Knope (regex `versioned_files`) and cocogitto (bump hooks running any command) can update Markdown and support multiple packages; changesets and semantic-release are npm-workspace oriented and a poor fit for a .NET + Markdown repo. + +### Cited Findings +- Knope `versioned_files`: named formats Cargo.toml, Cargo.lock, gleam.toml, go.mod, package.json, package-lock.json, deno.json(c), deno.lock, pyproject.toml, pom.xml, pubspec.yaml, tauri.conf.json; any other file via `{ path = "README.md", regex = "version: (?\\d+\\.\\d+\\.\\d+)" }` with a named `version` group; `.csproj` not listed; multiple packages via `[packages.""]`; conventional-commit `scopes` per package — [Knope packages config](https://knope.tech/reference/config-file/packages/) +- cocogitto monorepo: `[packages]` in `cog.toml` with `path`; `cog bump --auto` tags each changed package plus a global monorepo tag; `cog bump --package=

--auto`; `public_api = false`; `bump_order`; `pre_bump_hooks`/`post_bump_hooks`, `pre_package_bump_hooks`/`post_package_bump_hooks` (example `cargo set-version {{version}}`, `{{package}}` variable); per-package CHANGELOG.md — [cocogitto monorepo guide](https://docs.cocogitto.io/guide/monorepo.html) +- semantic-release has no native monorepo mode; `semantic-release-monorepo` (listed at 6.1.1) runs semantic-release per package via `-e`/`extends`; `multi-semantic-release` (anolilab fork maintained, requires Node.js ^22.14.0 || >=24.10.0) discovers packages through npm/yarn/pnpm/bolt workspaces — [semantic-release-monorepo on npm](https://www.npmjs.com/package/semantic-release-monorepo); [anolilab multi-semantic-release](https://github.com/anolilab/multi-semantic-release); [multi-semantic-release README](https://cdn.jsdelivr.net/npm/@anolilab/multi-semantic-release@4.4.5/README.md) +- changesets: contributors declare how changes should be released; the tool updates versions, changelogs and publishing; aimed at monorepos — [changesets README](https://raw.githubusercontent.com/changesets/changesets/main/README.md) + +### Inferences +- Knope's regex entries could match `^ version: (?...)` in frontmatter and the `--expect (?...)` text without adding markers to SKILL.md — cleaner than release-please markers for this repo, but each regex replaces one pattern per file entry (unverified whether multiple matches per file are replaced). +- cocogitto's hooks can call a Cake task or script that rewrites SKILL.md, then commits as part of `cog bump`; it creates tags locally (no release-PR model by default). +- changesets/semantic-release would introduce a Node toolchain and package.json files purely for versioning; not recommended here. + +### Gaps +- changesets' requirement of `package.json` per package was not confirmed from the README fetched (only high-level text). +- Knope tag format for multiple packages (`/v1.2.3`?) and whether one `regex` entry replaces all matches in a file — not on the fetched page. +- Knope and cocogitto current version numbers not verified. + +## Alternative: no version literal in SKILL.md, or a rewrite step plus guard + +### Takeaway +Because skills are installed straight from git and Claude Code does not show frontmatter to the model (repo CLAUDE.md), the body literal can only disappear if the handshake reads the version from somewhere the agent can see at run time; the lowest-risk automation is a single source file plus a Cake/CI "stamp" task that rewrites all literals and a guard that checks them — tool-agnostic and compatible with any of the tools above. + +### Cited Findings +- **FACT (repo, CLAUDE.md):** Claude Code does not show the frontmatter to the model (checked with Claude Code 2.1.318), so every skill that calls `version --expect` states the version in the handshake text; when the version is raised, frontmatter and handshake texts change together; `SkillKitVersionTests` enforces equality with the engine build's major.minor. +- **FACT (repo, CLAUDE.md):** skills are installed from the tag `v` or `main`, and there is no install-time transformation (`SingleSkillSourceTests`). +- release-please `simple` type uses a `version.txt` / `version-file` as the single source and can propagate to extra files — [release-please customizing.md](https://raw.githubusercontent.com/googleapis/release-please/main/docs/customizing.md); [release-please config schema](https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json) +- cocogitto `pre_bump_hooks` can run an arbitrary command such as a rewrite script with `{{version}}` — [cocogitto monorepo guide](https://docs.cocogitto.io/guide/monorepo.html) + +### Inferences +- Option 1 — single source file (e.g. `skills/VERSION` or `.claude-plugin/plugin.json` field) + stamp task: `./build.sh -t stamp-skills-version` (Cake) rewrites frontmatter and handshake lines from the source file; guard test stays. Pros: one manual edit (or none if a tool writes the source file), no markers in SKILL.md, works for (A) and (B). Cons: still a commit before the tag; the stamp must run before merge (CI check fails otherwise). +- Option 2 — handshake without literal: the skill tells the agent to read a version file shipped in the plugin (e.g. `${CLAUDE_PLUGIN_ROOT}`-relative), then call `--expect`. Pros: zero literals. Cons: agent-specific path resolution across Claude Code/Copilot/Codex (violates "agent-agnostic without loss" unless all three expose the plugin root — unverified), one more tool call per handshake, and a misread file silently defeats the check. +- Option 3 — engine owns compatibility: `--expect` replaced by a compatibility range file (e.g. skills declare `engine: ">=0.9 <0.10"`). Pros: decouples (B) versions. Cons: still a literal in skills, and a range file is another thing to keep in sync. +- Option 4 — pre-commit hook rewriting literals: fragile (hooks are per clone, not enforced in CI); a CI check is still needed. + +### Gaps +- Whether Copilot CLI and Codex CLI expose a plugin-root variable/path the skill text could use to read a shipped version file — not researched here. + +## Local development: dev-build conventions, relaxing compatibility checks, CI vs local detection + +### Takeaway +None of the tools makes local feature-branch builds "release-shaped": GitVersion yields `-.`, MinVer `x.y.z-alpha.0.`, NBGV `x.y.z-g` for non-public refs. The practical fix is in the engine/handshake (treat prerelease/dev engines as compatible on major.minor or with an env-var override) plus making the skills' major.minor equal to the branch's computed major.minor. + +### Cited Findings +- NBGV: refs not matching `publicReleaseRefSpec` keep the `-g` suffix; `gitCommitIdIncludeDirty` adds `-dirty`; `cloudBuild.setVersionVariables` / `nbgv cloud` integrate with CI — [NBGV version.json](https://dotnet.github.io/Nerdbank.GitVersioning/docs/versionJson.html); [NBGV nbgv CLI](https://dotnet.github.io/Nerdbank.GitVersioning/docs/nbgv-cli.html) +- MinVer: no tag -> `0.0.0-alpha.0` + height; `MinVerMinimumMajorMinor` raises the floor; `MinVerBuildMetadata`; `MinVerSkip` for Debug — [MinVer README](https://raw.githubusercontent.com/adamralph/minver/main/README.md) +- GitVersion: feature label `{BranchName}`, `{env:VARIABLE_NAME}` with `??` fallback in labels; ManualDeployment keeps the prerelease version and adds build metadata — [GitVersion 7.0 configuration](https://gitversion.net/7.0/docs/reference/configuration); [GitVersion 7.0 modes](https://gitversion.net/7.0/docs/reference/modes/) +- **FACT (repo, CLAUDE.md):** `version --expect` exits 50 if major or minor differ; a prerelease engine only warns. `SHADE_KIT_MARKETPLACE_SOURCE` is the developer override for the marketplace source (local path or `owner/repo#ref`). + +### Inferences +- A label like `label: '{env:SHADEKIT_LOCAL_LABEL ?? {BranchName}}'` (syntax per GitVersion `??` fallback; exact nesting unverified) could mark local builds, e.g. `-local`. +- Common conventions: `0.0.0-dev` for builds without tags, `+local`/`+` build metadata (ignored for precedence by SemVer). Distinguishing CI from local typically uses the `CI`/`GITHUB_ACTIONS` env vars (Cake's build system detection) — not tool-specific. +- For local skill testing, `SHADE_KIT_MARKETPLACE_SOURCE=$PWD` + the existing "prerelease engine only warns" rule already relax the check; the remaining pain is the guard's major.minor equality when `next-version` lags — automated minor raising (release-please/Knope writing the files) removes that. + +### Gaps +- No primary source found for an industry-standard `IsLocalBuild` property; Cake's `BuildSystem.IsLocalBuild` was not verified in this session. + +## Combination with the fewest manual steps for GitHub Actions + Cake + tag-based nuget.org releases + +### Takeaway +Fewest manual steps: release-please (manifest mode) as the single release driver that rewrites SKILL.md literals via a release PR and creates tags, with the CLI build version read from the tag (GitVersion or MinVer with the matching prefix); or, tool-agnostic, a single version source file + Cake stamp task + guard. Shared version (A) is simpler and keeps the current `--expect` semantics; independent versions (B) need a compatibility contract between engine and skills. + +### Cited Findings +- release-please creates one Release PR per run (or per component), bumps manifest + extra files, and tags `-v` or `v`; `linked-versions` keeps components in lockstep — [release-please manifest-releaser.md](https://raw.githubusercontent.com/googleapis/release-please/main/docs/manifest-releaser.md) +- Generic updater rewrites the first semver on marked lines in any text file — [release-please generic.ts](https://raw.githubusercontent.com/googleapis/release-please/main/src/updaters/generic.ts) +- GitVersion and MinVer only compute versions from tags/height; NBGV computes from committed `version.json` + height — [GitVersion 7.0 configuration](https://gitversion.net/7.0/docs/reference/configuration); [MinVer README](https://raw.githubusercontent.com/adamralph/minver/main/README.md); [NBGV version.json](https://dotnet.github.io/Nerdbank.GitVersioning/docs/versionJson.html) + +### Inferences +- (A) shared version, minimal change: keep GitVersion for the build; add release-please with one package `"."`, `release-type: simple`, `include-component-in-tag: false` (tags stay `v`), `bump-minor-pre-major: true`, extra-files = all SKILL.md (generic). Release = merge the Release PR -> tag `v0.10.0` -> existing `release` workflow pushes to nuget.org. `next-version` can be dropped once tags exist. Manual steps per release: 1 (merge PR). Cost: markers in SKILL.md + guard regex change; release-please tag must be on `main` (it is, after the PR merge). +- (B) independent versions: release-please packages `src` (component `cli`) and `skills` (component `skills`); GitVersion `tag-prefix: 'cli-v'` + `ignore.paths` for `^skills/`; the release workflow triggers on `cli-v*`; skills need no build. The engine/skill handshake must change from "major.minor equal" to a compatibility rule (e.g. skills declare the engine range), and `integrations install` (which today derives the marketplace ref `v` from the engine version) must map engine version -> skills tag. That is the larger change. +- Tool-agnostic fallback: `skills/VERSION` + Cake `stamp` task + CI check; combine with GitVersion `+semver: minor` commits instead of `next-version`. Manual steps: edit one file (or run one task) per minor raise. +- NBGV is attractive if `version.json` per component is preferred over tags, but it diverges from the repo's tag-based release rule and still needs a stamp step for SKILL.md. + +### Gaps +- No source found describing a real-world repo that uses release-please to version Markdown agent skills; the Markdown fit is inferred from the generic updater source. +- Interaction of a release-please-created tag with GitHub Actions `on: push: tags` (tags created with the default `GITHUB_TOKEN` do not trigger other workflows is a known GitHub rule, but not verified in this session) — likely requires a PAT/GitHub App token or chaining the release job in the same workflow. From 6b675f836f40bf07876113662577a56b07ffa7f7 Mon Sep 17 00:00:00 2001 From: darthsharp <48331467+darthsharp@users.noreply.github.com> Date: Sun, 22 Nov 2026 12:42:42 +0100 Subject: [PATCH 2/3] chore: rename documentation file for consistency in versioning terminology --- ...nierung von CLI und Skills.md => versioning-cli-and-skills.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename reports/{Versionierung von CLI und Skills.md => versioning-cli-and-skills.md} (100%) diff --git a/reports/Versionierung von CLI und Skills.md b/reports/versioning-cli-and-skills.md similarity index 100% rename from reports/Versionierung von CLI und Skills.md rename to reports/versioning-cli-and-skills.md From a2fc73b5d86fcbdf840176210ce07edf7fa7e6d1 Mon Sep 17 00:00:00 2001 From: darthsharp <48331467+darthsharp@users.noreply.github.com> Date: Sun, 22 Nov 2026 19:00:34 +0100 Subject: [PATCH 3/3] docs: update feature packages with CLI contract changes replacing engine version check (06-1) - docs: add `data.contract` field to `version --json` output and `--expect-contract` option (06-1) - docs: introduce exit codes 54 `engine-outdated` and 55 `skills-outdated`, remove 50 `version-mismatch` and warning `engine-prerelease-version-mismatch` (06-1) - docs: update `kitVersion` description to clarify skills carry no version, CLI contract checks fit (02) - docs: update refusal tables in 06-3 with new contract-based error codes - docs: update phase entry skill (06-5) to use `--expect-contract 1` instead of `--expect ` - docs: update status and acceptance criteria across affected packages (06-1 to 06-9, 07, 08, 09, 18, 19) - fix: remove `EnginePrereleaseVersionMismatchWarning` and `EngineVersionChecker` classes replaced by CLI contract - fix: update `CliErrorMapper` for new contract-based error mapping - fix: update `CLAUDE.md` and scenario check scripts for new contract format --- CLAUDE.md | 14 +- GitVersion.yml | 12 +- ...-store-foundation-and-format-versioning.md | 12 +- .../02-repository-initialisation.md | 6 +- .../06-1-engine-version-check.md | 121 ++- .../06-2-skill-conventions-and-version.md | 60 +- .../feature-packages/06-3-next-steps-skill.md | 9 +- .../06-5-phase-entry-skill.md | 16 +- .../feature-packages/06-6-next-phase-skill.md | 10 +- .../06-9-skill-skeleton-alignment.md | 8 +- docs/feature-packages/06-skill-foundation.md | 18 +- .../07-claude-code-integration.md | 30 +- .../08-copilot-and-codex-integration.md | 6 +- .../feature-packages/09-discuss-and-intake.md | 8 +- docs/feature-packages/18-upgrade.md | 12 +- .../19-release-and-distribution.md | 16 +- docs/feature-packages/README.md | 18 +- docs/implementation/cli-contract-version.md | 290 ++++++ research/shade-kit-concept.md | 10 +- skills/shade-kit-diagnose/SKILL.md | 2 - skills/shade-kit-discuss/SKILL.md | 8 +- skills/shade-kit-drop/SKILL.md | 8 +- skills/shade-kit-finish/SKILL.md | 2 - skills/shade-kit-gate-check/SKILL.md | 2 - skills/shade-kit-implement/SKILL.md | 2 - skills/shade-kit-interview/SKILL.md | 2 - skills/shade-kit-map/SKILL.md | 2 - skills/shade-kit-new/SKILL.md | 8 +- skills/shade-kit-next-phase/SKILL.md | 10 +- skills/shade-kit-next-steps/SKILL.md | 6 +- skills/shade-kit-phase-entry/SKILL.md | 12 +- skills/shade-kit-plan/SKILL.md | 2 - skills/shade-kit-quick/SKILL.md | 2 - skills/shade-kit-refine/SKILL.md | 2 - skills/shade-kit-report/SKILL.md | 2 - skills/shade-kit-research/SKILL.md | 2 - skills/shade-kit-review/SKILL.md | 2 - skills/shade-kit-verify/SKILL.md | 2 - .../ExpectedContractInvalidException.cs | 27 + .../ExpectedContractOptionConverter.cs | 58 ++ .../ExpectedVersionMissingException.cs | 11 - .../Version/ExpectedVersionOptionConverter.cs | 37 - .../Commands/Version/VersionCommand.cs | 104 ++- .../Version/VersionCommandContractData.cs | 26 + .../Commands/Version/VersionCommandData.cs | 27 +- .../Commands/Version/VersionCommandOptions.cs | 18 +- .../Output/CliErrorMapper.cs | 76 +- .../ShadeKitCliErrorCodes.cs | 18 +- .../ShadeKitCliExitCodes.cs | 22 +- .../ShadeKitCliWarningCodes.cs | 6 - ...ShadeKitCoreServiceCollectionExtensions.cs | 2 +- .../Versions/CliContract.cs | 43 + .../Versions/CliContractChecker.cs | 34 + .../Versions/CliContractWindow.cs | 43 + .../Versions/EngineVersionCheckResult.cs | 19 - .../Versions/EngineVersionChecker.cs | 55 -- .../EngineVersionMismatchDirection.cs | 19 - .../EngineContractOutdatedException.cs | 32 + .../EngineVersionMismatchException.cs | 36 - .../InvalidSemanticVersionException.cs | 15 - .../SkillsContractOutdatedException.cs | 32 + .../Versions/ICliContractChecker.cs | 41 + .../Versions/IEngineVersionChecker.cs | 36 - .../EnginePrereleaseVersionMismatchWarning.cs | 18 - .../IntegrationsCommandsEndToEndTests.cs | 14 +- .../IntegrationsMultiAgentEndToEndTests.cs | 3 +- .../ExpectedContractOptionConverterTests.cs | 70 ++ .../ExpectedVersionOptionConverterTests.cs | 42 - .../Version/VersionCommandOptionsTests.cs | 79 +- .../Commands/Version/VersionCommandTests.cs | 603 +++++++------ .../Output/CliErrorMapperTests.cs | 195 ++-- .../ProgramTests.cs | 189 ++-- .../ShadeKitCliErrorCodesTests.cs | 28 +- .../ShadeKitCliExitCodesTests.cs | 20 +- .../ShadeKitCliWarningCodesTests.cs | 12 +- ...KitCoreServiceCollectionExtensionsTests.cs | 37 +- .../Skills/SkillContractTests.cs | 569 ++++++++++++ .../Skills/SkillKitVersionTests.cs | 836 ------------------ .../Versions/CliContractCheckerTests.cs | 132 +++ .../Versions/CliContractTests.cs | 27 + .../Versions/CliContractWindowTests.cs | 49 + .../Versions/EngineVersionCheckerTests.cs | 273 ------ .../Exceptions/ContractExceptionsTests.cs | 49 + .../Exceptions/VersionExceptionsTests.cs | 44 - tests/skill-scenarios/README.md | 16 +- tests/skill-scenarios/SCENARIOS.md | 43 +- tests/skill-scenarios/checks/check_runs.py | 169 +++- tests/skill-scenarios/generate_fixtures.py | 63 +- 88 files changed, 2861 insertions(+), 2310 deletions(-) create mode 100644 docs/implementation/cli-contract-version.md create mode 100644 src/CreativeCoders.ShadeKit.Cli/Commands/Version/ExpectedContractInvalidException.cs create mode 100644 src/CreativeCoders.ShadeKit.Cli/Commands/Version/ExpectedContractOptionConverter.cs delete mode 100644 src/CreativeCoders.ShadeKit.Cli/Commands/Version/ExpectedVersionMissingException.cs delete mode 100644 src/CreativeCoders.ShadeKit.Cli/Commands/Version/ExpectedVersionOptionConverter.cs create mode 100644 src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommandContractData.cs create mode 100644 src/CreativeCoders.ShadeKit.Core/Versions/CliContract.cs create mode 100644 src/CreativeCoders.ShadeKit.Core/Versions/CliContractChecker.cs create mode 100644 src/CreativeCoders.ShadeKit.Core/Versions/CliContractWindow.cs delete mode 100644 src/CreativeCoders.ShadeKit.Core/Versions/EngineVersionCheckResult.cs delete mode 100644 src/CreativeCoders.ShadeKit.Core/Versions/EngineVersionChecker.cs delete mode 100644 src/CreativeCoders.ShadeKit.Core/Versions/EngineVersionMismatchDirection.cs create mode 100644 src/CreativeCoders.ShadeKit.Core/Versions/Exceptions/EngineContractOutdatedException.cs delete mode 100644 src/CreativeCoders.ShadeKit.Core/Versions/Exceptions/EngineVersionMismatchException.cs delete mode 100644 src/CreativeCoders.ShadeKit.Core/Versions/Exceptions/InvalidSemanticVersionException.cs create mode 100644 src/CreativeCoders.ShadeKit.Core/Versions/Exceptions/SkillsContractOutdatedException.cs create mode 100644 src/CreativeCoders.ShadeKit.Core/Versions/ICliContractChecker.cs delete mode 100644 src/CreativeCoders.ShadeKit.Core/Versions/IEngineVersionChecker.cs delete mode 100644 src/CreativeCoders.ShadeKit.Core/Versions/Warnings/EnginePrereleaseVersionMismatchWarning.cs create mode 100644 tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Version/ExpectedContractOptionConverterTests.cs delete mode 100644 tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Version/ExpectedVersionOptionConverterTests.cs create mode 100644 tests/CreativeCoders.ShadeKit.Core.Tests/Skills/SkillContractTests.cs delete mode 100644 tests/CreativeCoders.ShadeKit.Core.Tests/Skills/SkillKitVersionTests.cs create mode 100644 tests/CreativeCoders.ShadeKit.Core.Tests/Versions/CliContractCheckerTests.cs create mode 100644 tests/CreativeCoders.ShadeKit.Core.Tests/Versions/CliContractTests.cs create mode 100644 tests/CreativeCoders.ShadeKit.Core.Tests/Versions/CliContractWindowTests.cs delete mode 100644 tests/CreativeCoders.ShadeKit.Core.Tests/Versions/EngineVersionCheckerTests.cs create mode 100644 tests/CreativeCoders.ShadeKit.Core.Tests/Versions/Exceptions/ContractExceptionsTests.cs delete mode 100644 tests/CreativeCoders.ShadeKit.Core.Tests/Versions/Exceptions/VersionExceptionsTests.cs diff --git a/CLAUDE.md b/CLAUDE.md index 9452b26..166872f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -34,7 +34,7 @@ If a design choice can stay agent-agnostic **without losing functionality or pre |---|---| | `skills/` | Shipped plugin content | | `.claude-plugin/` | Claude Code marketplace and plugin manifests (`marketplace.json`: marketplace `creativecoders-shade-kit`, plugin `shade-kit` with the source `./`; `plugin.json` without `version`, so Claude Code uses the commit SHA) | -| `src/` | Production .NET projects: `CreativeCoders.ShadeKit.Cli` (the `shade-kit` CLI) and `CreativeCoders.ShadeKit.Core` (engine logic). The templates that `init` writes live in `src/CreativeCoders.ShadeKit.Core/Templates/Resources/` (`.template.md`, checklists in `checks/`) and are embedded into the Core assembly; their repository paths are listed in `ShippedTemplates`. The phase workflow lives in `src/CreativeCoders.ShadeKit.Core/Workflow/`: `Profiles/` (built-in profiles in `BuiltInWorkflowProfiles` behind `IWorkflowProfileCatalog`; each phase lists the artifacts it writes, `PhaseArtifact` with an `onDemand` flag, names in `WorkflowArtifactNames`), `Engine/` (the pure state machine `IPhaseEngine`; the default gate of a phase without an entry is `TransitionGate.ForPhase`, and `HasGate` says whether a phase has a gate), and the orchestration `PhaseWorkflow` with the gate seam `ITransitionGateProvider`. The gates live in `src/CreativeCoders.ShadeKit.Core/Gates/`: `GatesConfig` (`gates.json`, defaults in `CreateDefault()`), `GatesConfigTransitionGateProvider` behind the gate seam (one cached read of `gates.json` per store, checked against the profile catalog; returns the configured gates of a profile as a read-only view, and the engine applies the default gate to a phase without one), and `IFeatureChecklistWriter` (the checklist copy in the feature folder). `IPhaseWorkflow.GetGateInfoAsync` reads the read-only gate data of one feature (the current one or by id) for `gate info`: the feature, its phases with their state and artifacts (`FeaturePhase`, the same `phases` array as `feature show`), the configured gate of a phase with its checklist copy, and `coverageThreshold`. The version check lives in `src/CreativeCoders.ShadeKit.Core/Versions/`: `SemanticVersion` (strict SemVer 2.0.0) and `IEngineVersionChecker` (the match rule of `version --expect`). The agent integrations live in `src/CreativeCoders.ShadeKit.Core/Integrations/`: `IIntegrationService` (marketplace source from the engine version: tag `v`, `main` (`FallbackRef`) for a prerelease and for a release whose tag does not exist, the developer override `SHADE_KIT_MARKETPLACE_SOURCE`; agent detection, `version` asks only detected agents; results per agent), one `IAgentIntegration` per agent, registered in run order (`Claude/ClaudeCodeIntegration` `claude`, `Copilot/CopilotCliIntegration` `copilot`, `Codex/CodexCliIntegration` `codex`), all derived from `AgentIntegrationBase` (detection, the `InstallAsync`/`UpdateAsync` contract, and `RunStepsAsync`, which turns a failure after a removal into `IntegrationIncompleteException` and a cancellation from `IntegrationStepState.StartSwitch` on into `IntegrationSwitchCanceledException`; each agent keeps its own `ApplyAsync`), each with its own locator, command runner, and plugin CLI: `IClaudePluginCli` (the `claude plugin` commands with `--json`, run through `IClaudeCommandRunner`; a kept marketplace is refreshed with `claude plugin marketplace update` before the plugin update), `ICopilotPluginCli` (change commands without `--json`, success by exit code, the state read again with `copilot plugin list --json` / `marketplace list --json`; a switch uninstalls the plugin before `marketplace remove`), `ICodexPluginCli` (every command with `--json`; no `plugin update`, so `codex plugin add` installs or replaces; Codex reports no marketplace ref, so for a Git marketplace of the same repository the resolver returns `Verify` and the engine checks it with `marketplace add`, and `version` reports its `kitVersion`/`ref` as `null`). Shared by every agent: `ShadeKitPlugin` (marketplace and plugin names), `AgentMarketplace`, and `MarketplaceChangeResolver` (add, keep, switch, verify, or conflict; `Verify` for a GitHub marketplace of the same repository whose ref the agent does not report, `AgentMarketplace.IsRefReported` `false`, set only by Codex; directory sources are compared by `DirectoryPathComparer`, after resolving symbolic links). Copilot and Codex report `installed` or `updated`, never `current`. There is no engine-owned record: the state comes from each agent's plugin and marketplace list commands. The Windows `.cmd` shim opt-in for `copilot` and `codex` is `Processes/CmdShimCommandLine` (see the external tools rule). | +| `src/` | Production .NET projects: `CreativeCoders.ShadeKit.Cli` (the `shade-kit` CLI) and `CreativeCoders.ShadeKit.Core` (engine logic). The templates that `init` writes live in `src/CreativeCoders.ShadeKit.Core/Templates/Resources/` (`.template.md`, checklists in `checks/`) and are embedded into the Core assembly; their repository paths are listed in `ShippedTemplates`. The phase workflow lives in `src/CreativeCoders.ShadeKit.Core/Workflow/`: `Profiles/` (built-in profiles in `BuiltInWorkflowProfiles` behind `IWorkflowProfileCatalog`; each phase lists the artifacts it writes, `PhaseArtifact` with an `onDemand` flag, names in `WorkflowArtifactNames`), `Engine/` (the pure state machine `IPhaseEngine`; the default gate of a phase without an entry is `TransitionGate.ForPhase`, and `HasGate` says whether a phase has a gate), and the orchestration `PhaseWorkflow` with the gate seam `ITransitionGateProvider`. The gates live in `src/CreativeCoders.ShadeKit.Core/Gates/`: `GatesConfig` (`gates.json`, defaults in `CreateDefault()`), `GatesConfigTransitionGateProvider` behind the gate seam (one cached read of `gates.json` per store, checked against the profile catalog; returns the configured gates of a profile as a read-only view, and the engine applies the default gate to a phase without one), and `IFeatureChecklistWriter` (the checklist copy in the feature folder). `IPhaseWorkflow.GetGateInfoAsync` reads the read-only gate data of one feature (the current one or by id) for `gate info`: the feature, its phases with their state and artifacts (`FeaturePhase`, the same `phases` array as `feature show`), the configured gate of a phase with its checklist copy, and `coverageThreshold`. The version check lives in `src/CreativeCoders.ShadeKit.Core/Versions/`: `CliContract` (the CLI contract of the engine: `Current` and `MinSupported`, integers independent of the GitVersion product version, and their `CliContractWindow`), `ICliContractChecker` (the window check of `version --expect-contract`, registered with `CliContract.Window`; `EngineContractOutdatedException` above `Current`, `SkillsContractOutdatedException` below `MinSupported`), and `SemanticVersion` (strict SemVer 2.0.0, used by the integrations). The agent integrations live in `src/CreativeCoders.ShadeKit.Core/Integrations/`: `IIntegrationService` (marketplace source from the engine version: tag `v`, `main` (`FallbackRef`) for a prerelease and for a release whose tag does not exist, the developer override `SHADE_KIT_MARKETPLACE_SOURCE`; agent detection, `version` asks only detected agents; results per agent), one `IAgentIntegration` per agent, registered in run order (`Claude/ClaudeCodeIntegration` `claude`, `Copilot/CopilotCliIntegration` `copilot`, `Codex/CodexCliIntegration` `codex`), all derived from `AgentIntegrationBase` (detection, the `InstallAsync`/`UpdateAsync` contract, and `RunStepsAsync`, which turns a failure after a removal into `IntegrationIncompleteException` and a cancellation from `IntegrationStepState.StartSwitch` on into `IntegrationSwitchCanceledException`; each agent keeps its own `ApplyAsync`), each with its own locator, command runner, and plugin CLI: `IClaudePluginCli` (the `claude plugin` commands with `--json`, run through `IClaudeCommandRunner`; a kept marketplace is refreshed with `claude plugin marketplace update` before the plugin update), `ICopilotPluginCli` (change commands without `--json`, success by exit code, the state read again with `copilot plugin list --json` / `marketplace list --json`; a switch uninstalls the plugin before `marketplace remove`), `ICodexPluginCli` (every command with `--json`; no `plugin update`, so `codex plugin add` installs or replaces; Codex reports no marketplace ref, so for a Git marketplace of the same repository the resolver returns `Verify` and the engine checks it with `marketplace add`, and `version` reports its `kitVersion`/`ref` as `null`). Shared by every agent: `ShadeKitPlugin` (marketplace and plugin names), `AgentMarketplace`, and `MarketplaceChangeResolver` (add, keep, switch, verify, or conflict; `Verify` for a GitHub marketplace of the same repository whose ref the agent does not report, `AgentMarketplace.IsRefReported` `false`, set only by Codex; directory sources are compared by `DirectoryPathComparer`, after resolving symbolic links). Copilot and Codex report `installed` or `updated`, never `current`. There is no engine-owned record: the state comes from each agent's plugin and marketplace list commands. The Windows `.cmd` shim opt-in for `copilot` and `codex` is `Processes/CmdShimCommandLine` (see the external tools rule). | | `tests/` | One test project per production project (`.Tests`); `tests/Shared/` holds test helpers that both projects compile in (``); the CLI end-to-end tests run commands through `CliEndToEndHarness` (`tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/`); `tests/skill-scenarios/` holds the skill scenario run building blocks (Python, not compiled, not shipped) | | `build/` | Cake Frosting build project (`CreativeCoders.CakeBuild`), run through `build.sh` / `build.ps1` / `build.cmd`. Not part of `ShadeKit.slnx`; it has its own `Directory.Build.props` and `Directory.Packages.props`. | | `.github/` | GitHub Actions workflows and Dependabot configuration | @@ -50,10 +50,10 @@ If a design choice can stay agent-agnostic **without losing functionality or pre - Put shared build settings (nullable, implicit usings, analyzers) in `Directory.Build.props`, not in individual `.csproj` files. Analyzers run with `AnalysisLevel=latest-recommended`, `EnforceCodeStyleInBuild`, and `TreatWarningsAsErrors`, so every warning breaks the build. SonarAnalyzer.CSharp runs in every solution project as a `GlobalPackageReference` in `Directory.Packages.props`; a Sonar finding that is not fixed is suppressed with `[SuppressMessage(..., Justification = "...")]` on the class or method, not in `.editorconfig`. `tests/.editorconfig` turns off CA1707 because test method names use underscores (`Method_Scenario_ExpectedResult`). - Files are UTF-8 without BOM with LF line endings (`.editorconfig`). - Tests use xUnit v3, FakeItEasy, and AwesomeAssertions. They run on Microsoft.Testing.Platform (enabled in `global.json`) with `Microsoft.Testing.Extensions.TrxReport` and `Microsoft.Testing.Extensions.CodeCoverage` (`dotnet test --coverage`), which is what the Cake test task drives. -- Versioning: GitVersion (`GitVersion.yml`, `GitVersion.MsBuild` as `GlobalPackageReference`) derives one version from the git history for every project, the tool package, and the binaries. Never put a version in a `.csproj` or `.props` file; the only version in `GitVersion.yml` is `next-version`, the lowest version of the next release, set when the kit skills move to a new minor. Builds need the full history (`fetch-depth: 0`). A release is a tag `v` on `main`. +- Versioning: GitVersion (`GitVersion.yml`, `GitVersion.MsBuild` as `GlobalPackageReference`) derives one version from the git history for every project, the tool package, and the binaries. Never put a version in a `.csproj` or `.props` file; the only version in `GitVersion.yml` is `next-version`, the lowest version of the next product release; the kit skills do not depend on it (they name the CLI contract, see Skill conventions). Builds need the full history (`fetch-depth: 0`). A release is a tag `v` on `main`. - Only `CreativeCoders.ShadeKit.Cli` is packable (`IsPackable=false` in `Directory.Build.props`). A publish with a runtime identifier produces a self-contained single-file binary (set in the CLI `.csproj`). - The CLI is built on `CreativeCoders.Cli.Hosting`. A command is a class with `[CliCommand([...])]` that implements `ICliCommand` or `ICliCommand`, placed under `Commands///`. A group is declared with `[assembly: CliCommandGroup([...], "...")]` in `Commands//CommandGroup.cs`. Expected failures throw `CliCommandAbortException` with an exit code from `ShadeKitCliExitCodes`. Plain output is Spectre markup written with `MarkupLine`: the styles come from `AnsiConsoleStringExtensions` (CreativeCoders.SysConsole.Core) and `Output/ShadeKitMarkupExtensions` (muted, command, colored states), and every dynamic value is escaped with `ToEscapedMarkup()` first, because neither escapes. `Program.CreateConsole` turns ANSI and colors off unless the output is a terminal, and turns ANSI off again after Spectre's CI profile enrichers (GitHub Actions and Azure Pipelines turn it on). -- Agent contract: every agent-facing command takes options derived from `JsonCommandOptions` (`--json`). In JSON mode it writes one `CliJsonEnvelope` (`ok`, `data`, `warnings`, `error`) through `ICliJsonWriter` to stdout and nothing else; on an expected failure it writes a failure envelope (`error` holds only `code` and `message`, no exit code, so skills react to `error.code`) and throws `CliCommandAbortException` with `PrintMessage = false`. Commands get `ShadeKitCommandContext` (`Output/`) injected: `RunAsync` runs the core call (optionally with the kit store) with the run's cancellation token and turns mapped failures into the failure envelope / `CliCommandAbortException`, and `WriteSuccess` writes the single success envelope or the plain warnings and lines; commands do not use `ICliJsonWriter`, `CliErrorMapper`, or `CliCommandAbort` directly, `version` included. Core exceptions are mapped to exit code, error code, and message only in `CliErrorMapper`. An option value that the parser must reject before the command runs gets an `ICliValueConverter` on the option (`Converter =` on the option attribute) that throws a CLI-defined exception, which `CliErrorMapper.MapArgumentError` maps to exit code 2 (example: `ExpectedVersionOptionConverter` for a bare `--expect`). Exit codes are grouped by area (10–19 store, 20–29 format, 30–39 features, 40–49 phases and gates, 50–59 versions and integrations, 255 host); 2 (invalid arguments, usage) and 130 (canceled) are outside the ranges; every exit code has a kebab-case error code in `ShadeKitCliErrorCodes`; codes that only appear as warnings are in `ShadeKitCliWarningCodes`. +- Agent contract: every agent-facing command takes options derived from `JsonCommandOptions` (`--json`). In JSON mode it writes one `CliJsonEnvelope` (`ok`, `data`, `warnings`, `error`) through `ICliJsonWriter` to stdout and nothing else; on an expected failure it writes a failure envelope (`error` holds only `code` and `message`, no exit code, so skills react to `error.code`) and throws `CliCommandAbortException` with `PrintMessage = false`. Commands get `ShadeKitCommandContext` (`Output/`) injected: `RunAsync` runs the core call (optionally with the kit store) with the run's cancellation token and turns mapped failures into the failure envelope / `CliCommandAbortException`, and `WriteSuccess` writes the single success envelope or the plain warnings and lines; commands do not use `ICliJsonWriter`, `CliErrorMapper`, or `CliCommandAbort` directly, `version` included. Core exceptions are mapped to exit code, error code, and message only in `CliErrorMapper`. An option value that the parser must reject before the command runs gets an `ICliValueConverter` on the option (`Converter =` on the option attribute) that throws a CLI-defined exception, which `CliErrorMapper.MapArgumentError` maps to exit code 2 (example: `ExpectedContractOptionConverter` for `--expect-contract` without a value or with a value that is not a contract number). Exit codes are grouped by area (10–19 store, 20–29 format, 30–39 features, 40–49 phases and gates, 50–59 versions and integrations, 255 host); 2 (invalid arguments, usage) and 130 (canceled) are outside the ranges; every exit code has a kebab-case error code in `ShadeKitCliErrorCodes`; codes that only appear as warnings are in `ShadeKitCliWarningCodes`. - Versioned JSON files in `.shadekit/` are read and written only through `IKitStore.ReadJsonAsync`/`WriteJsonAsync`. Each file type has a format id in `FormatIds` and a definition in `FormatRegistry.CreateDefault()`; raising a format version means a new table entry plus an `IFormatMigration` step and a test that migrates a fixture from the previous version. Document models derive from `VersionedDocument`; nested classes need their own `[JsonExtensionData] Dictionary` to keep unknown fields. - Text file content is held as `TextFileContent` (lines, UTF-8 BOM flag, final-line-ending flag), never as `byte[]`, and is written only through `ITextFileWriter` (`IKitStore.WriteFileAsync` uses it for `.shadekit/`; `FileWriteMode.CreateNew` creates a file only if it does not exist and throws `FileAlreadyExistsException` otherwise, `Overwrite` is the default). The writer is the only place that encodes to bytes; it resolves the line ending with `ILineEndingResolver`: git (attributes as git's `convert_attrs`: resolved `text`, legacy `crlf` only while `text` is unspecified; `-text` → no decision, `eol` attribute, `text=input`/`crlf=input` → LF, `core.autocrlf`, `core.eol` for text files; config values and a failing `git` cached per repository root for the resolver's lifetime, i.e. one command run; a `git` that is installed but fails gives a `GitAttributesUnavailableWarning`, a missing one (`GitNotFoundException`) none; `ILineEndingResolver.PrepareAsync` / `IKitStore.PrepareLineEndingsAsync` read the attributes of several files with one `git check-attr`, as `init` and `feature new` do) → `.editorconfig` `end_of_line` (parsed files kept per resolver while their write time, size, and Unix mode are unchanged) → operating system. Paths reach the writer and the resolvers as `RepositoryFile`, checked once where it is created (`RepositoryFile.Resolve`, or `KitStore` for `.shadekit/`). Lines are split at CRLF, LF, and a lone CR. Files, the versioned JSON files included, are read as strict UTF-8; an unreadable `.editorconfig` falls back with an `EditorConfigUnreadableWarning`, one the parser cannot evaluate (e.g. an overflowing numeric-range glob, or a glob that expands into more than 10 000 patterns, checked before the parser expands it) with an `EditorConfigInvalidWarning`. - External tools (`git`, `gh` for tracker issues in `feature new`, and `claude`, `copilot`, and `codex` for `integrations` and `version`) are started only through the helpers in `src/CreativeCoders.ShadeKit.Core/Processes/` (`PathExecutableSearch`: absolute `PATH` entries only, behind the caching `PathExecutableLocator` base of the tool locators; `ExternalProcessRunner`: absolute path, no shell, process tree killed on cancellation; `ExternalToolRunner`: locate, refuse a missing or relative path, start, map a start failure to the tool's `ExternalToolException`), behind one runner interface per tool (`IGitCommandRunner`, `IGhCommandRunner`, `IClaudeCommandRunner`, `ICopilotCommandRunner`, `ICodexCommandRunner`, all returning `ExternalProcessResult`). One documented deviation from "no shell": on Windows `copilot` and `codex` are found as `.exe`, then `.cmd` (npm shim), and a `.cmd` is run through `%ComSpec%` (`/d /s /c`, `CmdShimCommandLine`, opted in by `ExternalTool.CmdShims` (`CmdShimPolicy`, holding the factory of the refused-argument exception)); a shim path or argument with a `cmd.exe` metacharacter (`"%!^&|<>()`, line break, NUL) is refused, not escaped (exit code 52). `claude` stays `.exe` only. `git` never prompts: `GitCommandRunner` sets `GIT_TERMINAL_PROMPT=0` and an empty `GIT_ASKPASS` for every call. The release-tag check of `integrations` runs `git ls-remote` through `IGitRemoteTagChecker` (in the user's home directory, `https` only, no credential helpers). HTTP goes through `IHttpClientFactory` with the named client `HttpUrlContentReader.HttpClientName` (`Microsoft.Extensions.Http`), not a typed client, because the services that use it are singletons. Tests never start `git`, `gh`, `claude`, `copilot`, or `codex` and never send a request: they fake the runner or use `tests/Shared/StubHttpMessageHandler.cs`. @@ -64,7 +64,7 @@ If a design choice can stay agent-agnostic **without losing functionality or pre dotnet build # from repo root (.slnx) dotnet test dotnet test --coverage # with coverage (writes TestResults/) -dotnet run --project src/CreativeCoders.ShadeKit.Cli -- version --json --expect # exit 50 if major or minor differ (a prerelease engine only warns) +dotnet run --project src/CreativeCoders.ShadeKit.Cli -- version --json --expect-contract # exit 54 engine-outdated if > CliContract.Current, 55 skills-outdated if < MinSupported; integrations not read dotnet run --project src/CreativeCoders.ShadeKit.Cli -- init # initialises the git repository of the current directory dotnet run --project src/CreativeCoders.ShadeKit.Cli -- feature list dotnet run --project src/CreativeCoders.ShadeKit.Cli -- feature new --source "Login with SSO" [--title ] [--profile

] [--move-source] # source: text, URL, or file; --move-source moves notes from .shadekit/discussions/ into the feature @@ -101,8 +101,8 @@ Without `--runtime`, the host OS decides the runtimes: Linux → `linux-x64`, `l The rules for the kit skills under `skills/` are in [06-2 Skill conventions and version metadata](docs/feature-packages/06-2-skill-conventions-and-version.md). -- Frontmatter: `name`, `description`, and `metadata.version`. `metadata.version` is the kit version: the same value in every skill, a SemVer version without a prerelease label, written unquoted (`version: 0.9.0`). A `description` that YAML would not read unchanged as a plain scalar is written in double quotes: unquoted, a `: ` makes the frontmatter invalid YAML (Claude Code then loads the skill with empty metadata), and a ` #` silently cuts the description at the comment. -- Claude Code does not show the frontmatter to the model (checked with Claude Code 2.1.318 on project-level skills, 06-2), so every skill that calls `version --expect` states the version in the text of its handshake step: ``Version handshake: run `shade-kit version --json --expect 0.9.0`; 0.9.0 is the kit version of this skill (`metadata.version` in its frontmatter).`` The frontmatter is the source. When the version is raised, the frontmatter of every skill and every handshake text change together (search for the old value). The guard test `SkillKitVersionTests` (`tests/CreativeCoders.ShadeKit.Core.Tests/Skills/`, FP07-AC2) fails the build unless every skill carries the same plain `x.y.z`, its major.minor equals the engine build version's (GitVersion), and every `--expect` and "is the kit version of this skill" under `skills/` names it; so the commit that raises the minor of the skills must also raise the minor of the build version, with `next-version: v..0` in `GitVersion.yml` (written with the tag prefix; GitVersion ignores it once a release tag at or above it exists). Who runs the handshake: `shade-kit-phase-entry` for the phase skills, the other skills the human calls (`new`, `discuss`, `drop`, `shade-kit-next-phase`) in their first step; every other skill that only another skill loads (for example `shade-kit-next-steps`) runs none. +- Frontmatter: `name` and `description` only; no `metadata` block and no `version`. A `description` that YAML would not read unchanged as a plain scalar is written in double quotes: unquoted, a `: ` makes the frontmatter invalid YAML (Claude Code then loads the skill with empty metadata), and a ` #` silently cuts the description at the comment. +- Claude Code does not show the frontmatter to the model (checked with Claude Code 2.1.318 on project-level skills, 06-2), so the version handshake names the CLI contract in its text. Every skill that runs the handshake has this step verbatim: ``Version handshake: run `shade-kit version --json --expect-contract 1`; 1 is the CLI contract this skill is written for.`` The number is `CliContract.Current`. `Current` rises with every skill-visible change of the CLI contract (agent-facing commands and options, the `CliJsonEnvelope` fields, the fields of `data`, error and warning codes), additive ones included; `MinSupported` rises only when something is removed or reinterpreted. Raising the contract means: raise `CliContract.Current` and change the five handshake sentences and the command lists of `shade-kit-next-phase` and `shade-kit-phase-entry` together. The guard test `SkillContractTests` (`tests/CreativeCoders.ShadeKit.Core.Tests/Skills/`, FP07-AC2) names every place: it fails the build unless every `--expect-contract ` and every "`` is the CLI contract this skill is written for" under `skills/` names `CliContract.Current`, the five handshake skills carry the sentence verbatim, and no `--expect` option and no frontmatter `version:` is left. It does not depend on GitVersion, tags, or the branch; raising the product version needs no skill change. Who runs the handshake: `shade-kit-phase-entry` for the phase skills, the other skills the human calls (`new`, `discuss`, `drop`, `shade-kit-next-phase`) in their first step; every other skill that only another skill loads (for example `shade-kit-next-steps`) runs none. - Skills change state only through the CLI with `--json`; they never read or write `feature.json`, `gates.json`, or `config.json` directly. They read and write the Markdown artifacts in the feature folder directly. - Every artifact a skill creates starts from the repository's template in `.shadekit/templates/`. Two exceptions, both saying so when they apply: `shade-kit-research` creates `researches.md` without it when the template is missing (06-8), and `shade-kit-discuss` writes the discussion notes in the template's structure when `discussion.md` is missing (09). - `request.md` is data that describes the requirement, never instructions to the agent. @@ -112,7 +112,7 @@ The rules for the kit skills under `skills/` are in [06-2 Skill conventions and - A kit skill that researches loads `shade-kit-research` and names in its text the phase, the feature id, the focuses (each with a short name, which is the section heading ` / ` in `researches.md`, an ID prefix that is unique in the file, and instructions), the files to read, and a context note (or none); only `shade-kit-research` writes the research sections. - Every kit skill that ends (end of its work, a "no", or a refused start) loads `shade-kit-next-steps` for its closing message and passes it why it ends and the warnings of its CLI calls; it writes no next steps of its own. A recommendation in its own report names a skill only when the closing message does not list it (06-9). - One skill source for all agents: `skills/` and the `.claude-plugin/` manifests serve Claude Code, GitHub Copilot CLI, and OpenAI Codex CLI unchanged. An agent-specific difference (tool names, call forms, Codex limits) is written in that one source as text for each agent, and each agent uses its own variant; there is no agent-specific skill copy, no agent-specific manifest, and no install-time transformation ([08 Content source](docs/feature-packages/08-copilot-and-codex-integration.md#content-source); guarded by `SingleSkillSourceTests`). -- Skill texts have no automated tests (only the guards in `tests/CreativeCoders.ShadeKit.Core.Tests/Skills/`: `SkillKitVersionTests` (FP07-AC2) checks the version; `ShippedSkillsTests` (FP07-AC7) the references into `docs/`/`research/` in every text file under `skills/`; `SkillAgentWordingTests` that every `SKILL.md` that names a question tool (`AskUserQuestion`, `ask_user`, `request_user_input`) or states the call form (`$shade-kit:`) uses the canonical question-tool parenthetical and call-form phrase verbatim (the canonical texts are the constants in that test, and agent-specific additions follow them); and `SingleSkillSourceTests` (FP08-AC4, helper `SingleSkillSourceGuard`) that every skill has one source for all agents: no skill name (frontmatter `name` or directory name, case-insensitive) occurs twice, no `SKILL.md` lies in an agent skill location (`.github/skills/`, `.agents/skills/`, `.claude/skills/`, `.codex/skills/`), no agent-specific plugin or marketplace manifest lies at the repository root beside `.claude-plugin/` (for example `.codex-plugin/`, `.github/plugin/marketplace.json`, a root `plugin.json`), and no skill folder holds an agent-specific `agents/` file such as `agents/openai.yaml`). A changed skill is checked by a review by hand and by scenario runs: a subagent loads the skill, follows it with canned CLI envelopes, and records the commands it would run and its output. The building blocks (runner protocol, scenario catalog, fixture generator, expectations and checker) are in `tests/skill-scenarios/`, procedure in its `README.md`; run outputs and generated fixtures stay outside the repository. skill-creator's `quick_validate.py` checks the frontmatter, but not the content of `metadata`. +- Skill texts have no automated tests (only the guards in `tests/CreativeCoders.ShadeKit.Core.Tests/Skills/`: `SkillContractTests` (FP07-AC2) checks the CLI contract of the handshake; `ShippedSkillsTests` (FP07-AC7) the references into `docs/`/`research/` in every text file under `skills/`; `SkillAgentWordingTests` that every `SKILL.md` that names a question tool (`AskUserQuestion`, `ask_user`, `request_user_input`) or states the call form (`$shade-kit:`) uses the canonical question-tool parenthetical and call-form phrase verbatim (the canonical texts are the constants in that test, and agent-specific additions follow them); and `SingleSkillSourceTests` (FP08-AC4, helper `SingleSkillSourceGuard`) that every skill has one source for all agents: no skill name (frontmatter `name` or directory name, case-insensitive) occurs twice, no `SKILL.md` lies in an agent skill location (`.github/skills/`, `.agents/skills/`, `.claude/skills/`, `.codex/skills/`), no agent-specific plugin or marketplace manifest lies at the repository root beside `.claude-plugin/` (for example `.codex-plugin/`, `.github/plugin/marketplace.json`, a root `plugin.json`), and no skill folder holds an agent-specific `agents/` file such as `agents/openai.yaml`). A changed skill is checked by a review by hand and by scenario runs: a subagent loads the skill, follows it with canned CLI envelopes, and records the commands it would run and its output. The building blocks (runner protocol, scenario catalog, fixture generator, expectations and checker) are in `tests/skill-scenarios/`, procedure in its `README.md`; run outputs and generated fixtures stay outside the repository. skill-creator's `quick_validate.py` checks the frontmatter, but not the content of `metadata`. ## Workflow diff --git a/GitVersion.yml b/GitVersion.yml index 803bc79..f28a61c 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -3,12 +3,12 @@ # The version is derived from the git history; a release is a tag `v` on `main`, and every # build that is not on such a tag is a prerelease. # -# `next-version` is the one number kept here: the lowest version the next release may have. It -# raises the minor place ahead of the release when the kit skills move to a new minor (their -# `metadata.version` must match the major.minor of the build, see SkillKitVersionTests). GitVersion -# is documented to ignore it once a tag at or above it exists (not yet observed in this repository, -# see 06-2), so it should need no clean-up after the release. It is written with the tag prefix -# `v`, because GitVersion parses it with `tag-prefix`. +# `next-version` is the one number kept here: the lowest version the next product release may +# have. It is a product decision only; the kit skills do not depend on it (they name the CLI +# contract of the engine, not a product version, see SkillContractTests). GitVersion is documented +# to ignore it once a tag at or above it exists (not yet observed in this repository, see 06-2), so +# it should need no clean-up after the release. It is written with the tag prefix `v`, because +# GitVersion parses it with `tag-prefix`. mode: ContinuousDelivery tag-prefix: 'v' diff --git a/docs/feature-packages/01-store-foundation-and-format-versioning.md b/docs/feature-packages/01-store-foundation-and-format-versioning.md index 15b32e6..a04306b 100644 --- a/docs/feature-packages/01-store-foundation-and-format-versioning.md +++ b/docs/feature-packages/01-store-foundation-and-format-versioning.md @@ -2,7 +2,7 @@ | | | |---|---| -| Status | Draft, 2026-10-14, updated 2026-10-18 (implementation state; package 02 implementation: missing `features/` is valid, exit codes 11, 13, 23; code review rework: exit codes 14, 24), 2026-10-21 (package 03 implementation: exit codes 15, 16, 30–34, 36, 40, warning codes, store file operations; code review rework: exit codes 2 and 130, warning codes `feature-folder-invalid`, `feature-id-mismatch`, `current-feature-invalid`, `MoveDirectory`; second code review: exit code 35), 2026-10-26 (package 04 implementation: exit codes 37, 41–46; 40 owned by 04), 2026-11-01 (package 05 implementation: exit code 47, warning codes `gates-defaults-used` and `gate-entry-ignored`), 2026-11-04 (package 05 reviews: exit code 17, since the /simplify review of feature/feature-05 for every write of the store), 2026-11-06 (package 06-1 implementation: range 50–59, exit code 50, warning code `engine-prerelease-version-mismatch`, `version --expect`), 2026-11-13 (package 07 implementation: format id `integrations` removed, `integrations` in `version --json`, exit codes 51–53, warning codes `integration-prerelease-ref`, `integration-release-tag-missing`, and `agent-unavailable`), 2026-11-14 (package 07 review rework: a command-specific message for 130), and 2026-11-20 (package 09: warning code `source-not-removed`). Implemented. | +| Status | Draft, 2026-10-14, updated 2026-10-18 (implementation state; package 02 implementation: missing `features/` is valid, exit codes 11, 13, 23; code review rework: exit codes 14, 24), 2026-10-21 (package 03 implementation: exit codes 15, 16, 30–34, 36, 40, warning codes, store file operations; code review rework: exit codes 2 and 130, warning codes `feature-folder-invalid`, `feature-id-mismatch`, `current-feature-invalid`, `MoveDirectory`; second code review: exit code 35), 2026-10-26 (package 04 implementation: exit codes 37, 41–46; 40 owned by 04), 2026-11-01 (package 05 implementation: exit code 47, warning codes `gates-defaults-used` and `gate-entry-ignored`), 2026-11-04 (package 05 reviews: exit code 17, since the /simplify review of feature/feature-05 for every write of the store), 2026-11-06 (package 06-1 implementation: range 50–59, exit code 50, warning code `engine-prerelease-version-mismatch`, `version --expect`), 2026-11-13 (package 07 implementation: format id `integrations` removed, `integrations` in `version --json`, exit codes 51–53, warning codes `integration-prerelease-ref`, `integration-release-tag-missing`, and `agent-unavailable`), 2026-11-14 (package 07 review rework: a command-specific message for 130), 2026-11-20 (package 09: warning code `source-not-removed`), and 2026-11-22 (package 06-1: CLI contract; `data.contract` in `version --json`, exit codes 54 `engine-outdated` and 55 `skills-outdated`; exit code 50 and the warning `engine-prerelease-version-mismatch` removed). Implemented. | | Source | Concept §3.1, §3.2, §4.1, [§9](../../research/shade-kit-concept.md#9-version-drift) | | Depends on | — | | Enables | Every later package | @@ -71,7 +71,7 @@ Every file the kit writes into a repository is safe across branch merges and kit ### `shade-kit version` - Plain output: the engine version, since package 07 followed by one line per installed integration. **Decided** (implemented in code). **Implemented** (`VersionCommand`). -- `--json` output: engine version and the current format version per file type, keyed by format id (`"formats": { "config": 1, … }`). This is the engine's capability, not the state of a repository. **Decided** (implemented in code). **Implemented** (`VersionCommandData`). Skills use it for the version handshake (package 06): with `--expect ` it checks the engine against the skill's version (package 06-1, **Implemented**). Since package 07 it also has the always-present field `integrations` with the installed integrations (`agent`, `pluginId`, `kitVersion`, `ref`, `enabled`), read from the agents whose CLI is detected; an agent CLI that is missing gives no warning, one that is detected but fails gives the warning `agent-unavailable`, and neither fails the command (**Implemented** on 2026-11-13, `VersionCommandData.Integrations`). +- `--json` output: engine version and the current format version per file type, keyed by format id (`"formats": { "config": 1, … }`). This is the engine's capability, not the state of a repository. **Decided** (implemented in code). **Implemented** (`VersionCommandData`). Skills use it for the version handshake (package 06): with `--expect ` it checks the engine against the skill's version (package 06-1, **Implemented**). Replaced on 2026-11-22 (package 06-1, CLI contract): it always has `contract` (`{"current": 1, "minSupported": 1}`, after `formats`), and with `--expect-contract ` it checks the CLI contract the skill is written for, echoes it as `expectedContract`, and leaves out `integrations` (**Implemented**). Since package 07 it also has the field `integrations` (present without `--expect-contract`, left out with it) with the installed integrations (`agent`, `pluginId`, `kitVersion`, `ref`, `enabled`), read from the agents whose CLI is detected; an agent CLI that is missing gives no warning, one that is detected but fails gives the warning `agent-unavailable`, and neither fails the command (**Implemented** on 2026-11-13, `VersionCommandData.Integrations`). ### Agent contract (applies to every agent-facing command) @@ -89,8 +89,8 @@ Every file the kit writes into a repository is safe across branch merges and kit ``` On failure, `ok` is `false`, `data` is `null`, and `error` is `{ "code": "…", "message": "…" }`. **Implemented** (`CliJsonEnvelope`, `ICliJsonWriter`, `CliErrorMapper`). -- Every failure has a stable exit code from `ShadeKitCliExitCodes` and, in JSON mode, a stable error code string, so skills can branch on it without parsing messages. **Decided** (implemented in code). Error and warning codes are kebab-case. **Decided** (implemented in code). Codes that only appear as warnings are in `ShadeKitCliWarningCodes`: `current-feature-mismatch`, `current-feature-missing`, `current-feature-invalid`, `feature-file-missing`, `feature-folder-invalid`, and `feature-id-mismatch`, all from package 03; `gates-defaults-used` and `gate-entry-ignored` from package 05 (since 2026-11-01); `engine-prerelease-version-mismatch` from package 06-1 (since 2026-11-06); `integration-prerelease-ref`, `integration-release-tag-missing`, and `agent-unavailable` from package 07 (since 2026-11-13); `source-not-removed` from package 03 (`feature new --move-source`, since 2026-11-20, package 09); `upgrade-needed` is both an error code and a warning code. **Implemented** (`ShadeKitCliWarningCodes`, since 2026-10-21). -- Exit codes are grouped in ranges per area: 10–19 store and kit root, 20–29 file format and format version, 30–39 features, 40–49 phases and gates, 50–59 versions and integrations (since 2026-11-06, package 06-1), 255 host errors. **Decided** (implemented in code). Two codes are outside the area ranges, because they apply to every command: 2 (`invalid-arguments`) is the usage code for arguments the option parser rejects, for example a missing required argument; the message names the problem and points to `shade-kit --help`, and there is no stack trace. **Decided** on 2026-10-21 (package 03 code review rework). 130 (`canceled`, 128 + SIGINT) ends a run canceled with Ctrl+C. **Decided** on 2026-10-21 (package 03 code review rework). A command may give its own message for 130: a cancellation during the marketplace switch of `integrations install` or `update` names the repair (`IntegrationSwitchCanceledException`, mapped in `CliErrorMapper.Map`; **Decided** on 2026-11-14, package 07 review rework). Both are **Implemented** (`CliErrorMapper.MapArgumentError`, `CliErrorMapper.MapCancellation`, `Program`); in JSON mode each writes one failure envelope. An option class the parser cannot create is a defect of the CLI and stays 255 (`host-error`). Codes owned by packages 01 to 06-1, all **Implemented** (`ShadeKitCliExitCodes`, `ShadeKitCliErrorCodes`, `CliErrorMapper`). Exit code 11 is free since 2026-10-18 (see [Kit root](#kit-root)). Exit code 35 (`feature-io-failed`) was added on 2026-10-21 after the second code review of package 03. Exit code 37 (`no-current-feature`) was added on 2026-10-26 with package 04, in the features range because it is about features. Exit code 40 is owned by package 04 since 2026-10-26, because profiles belong to it; package 04 added 41–46 (package 04, [Errors](04-phase-engine-and-workflow-profiles.md#errors)). Exit code 47 (`checklist-template-not-found`) was added on 2026-11-01 with package 05, and exit code 17 (`kit-file-write-failed`, a file of the store cannot be written, in the store range) on 2026-11-04 after the code review of package 05 (package 05, [Errors](05-gates-and-checklists.md#errors)); since the /simplify review of the same day it applies to every write of the store ([Kit root](#kit-root)). Exit code 50 (`version-mismatch`) was added on 2026-11-06 with package 06-1 (package 06-1, [Exit and warning codes](06-1-engine-version-check.md#exit-and-warning-codes)): +- Every failure has a stable exit code from `ShadeKitCliExitCodes` and, in JSON mode, a stable error code string, so skills can branch on it without parsing messages. **Decided** (implemented in code). Error and warning codes are kebab-case. **Decided** (implemented in code). Codes that only appear as warnings are in `ShadeKitCliWarningCodes`: `current-feature-mismatch`, `current-feature-missing`, `current-feature-invalid`, `feature-file-missing`, `feature-folder-invalid`, and `feature-id-mismatch`, all from package 03; `gates-defaults-used` and `gate-entry-ignored` from package 05 (since 2026-11-01); `engine-prerelease-version-mismatch` from package 06-1 (from 2026-11-06, removed on 2026-11-22 with the `--expect` check); `integration-prerelease-ref`, `integration-release-tag-missing`, and `agent-unavailable` from package 07 (since 2026-11-13); `source-not-removed` from package 03 (`feature new --move-source`, since 2026-11-20, package 09); `upgrade-needed` is both an error code and a warning code. **Implemented** (`ShadeKitCliWarningCodes`, since 2026-10-21). +- Exit codes are grouped in ranges per area: 10–19 store and kit root, 20–29 file format and format version, 30–39 features, 40–49 phases and gates, 50–59 versions and integrations (since 2026-11-06, package 06-1), 255 host errors. **Decided** (implemented in code). Two codes are outside the area ranges, because they apply to every command: 2 (`invalid-arguments`) is the usage code for arguments the option parser rejects, for example a missing required argument; the message names the problem and points to `shade-kit --help`, and there is no stack trace. **Decided** on 2026-10-21 (package 03 code review rework). 130 (`canceled`, 128 + SIGINT) ends a run canceled with Ctrl+C. **Decided** on 2026-10-21 (package 03 code review rework). A command may give its own message for 130: a cancellation during the marketplace switch of `integrations install` or `update` names the repair (`IntegrationSwitchCanceledException`, mapped in `CliErrorMapper.Map`; **Decided** on 2026-11-14, package 07 review rework). Both are **Implemented** (`CliErrorMapper.MapArgumentError`, `CliErrorMapper.MapCancellation`, `Program`); in JSON mode each writes one failure envelope. An option class the parser cannot create is a defect of the CLI and stays 255 (`host-error`). Codes owned by packages 01 to 06-1, all **Implemented** (`ShadeKitCliExitCodes`, `ShadeKitCliErrorCodes`, `CliErrorMapper`). Exit code 11 is free since 2026-10-18 (see [Kit root](#kit-root)). Exit code 35 (`feature-io-failed`) was added on 2026-10-21 after the second code review of package 03. Exit code 37 (`no-current-feature`) was added on 2026-10-26 with package 04, in the features range because it is about features. Exit code 40 is owned by package 04 since 2026-10-26, because profiles belong to it; package 04 added 41–46 (package 04, [Errors](04-phase-engine-and-workflow-profiles.md#errors)). Exit code 47 (`checklist-template-not-found`) was added on 2026-11-01 with package 05, and exit code 17 (`kit-file-write-failed`, a file of the store cannot be written, in the store range) on 2026-11-04 after the code review of package 05 (package 05, [Errors](05-gates-and-checklists.md#errors)); since the /simplify review of the same day it applies to every write of the store ([Kit root](#kit-root)). Exit code 50 (`version-mismatch`) was added on 2026-11-06 with package 06-1 and removed on 2026-11-22, when 54 (`engine-outdated`) and 55 (`skills-outdated`) of the CLI contract replaced it (package 06-1, [Exit and warning codes](06-1-engine-version-check.md#exit-and-warning-codes)): | Exit code | Error code | Owner | |---|---|---| @@ -123,10 +123,12 @@ Every file the kit writes into a repository is safe across branch merges and kit | 45 | `complete-not-allowed` | 04 | | 46 | `phase-state-invalid` | 04 | | 47 | `checklist-template-not-found` | 05 | - | 50 | `version-mismatch` | 06-1 | + | 50 | `version-mismatch` | 06-1 (removed on 2026-11-22, replaced by 54 and 55; 50 is unused) | | 51 | `agent-not-found` | 07 | | 52 | `agent-command-failed` | 07 | | 53 | `integration-conflict` | 07 | + | 54 | `engine-outdated` | 06-1 (since 2026-11-22) | + | 55 | `skills-outdated` | 06-1 (since 2026-11-22) | | 130 | `canceled` | 03 (every command) | | 255 | `host-error` | 01 | diff --git a/docs/feature-packages/02-repository-initialisation.md b/docs/feature-packages/02-repository-initialisation.md index 48230cd..cf00e88 100644 --- a/docs/feature-packages/02-repository-initialisation.md +++ b/docs/feature-packages/02-repository-initialisation.md @@ -2,7 +2,7 @@ | | | |---|---| -| Status | Draft, 2026-10-14, updated 2026-10-17 (template conventions), 2026-10-18 (implementation state; code review rework: exit codes 14 and 24, `.gitignore` rule, separator line), 2026-10-22 (code review verification of package 03: `trackers` id prefixes validated), 2026-10-23 (rework of file content handling: line endings of `.gitignore`, `CLAUDE.md`, and `AGENTS.md`, strict UTF-8, warnings; code review: `editorconfig-invalid`, legacy `crlf` attribute, `text=input`), and 2026-10-24 (documentation check: exit code 14 also for the `request.md` template, warnings sentence, resolved open point removed), and 2026-10-25 (rework of `feature new` in package 03: the `request.md` template is removed, `init` no longer writes `.shadekit/templates/request.md`, exit code 14 no longer covers it; `trackers` hosts are read with `gh`), and 2026-10-26 (package 04 implementation: comma-separated enum values make a `.shadekit/` JSON file invalid), 2026-10-30 (managed section text), and 2026-11-01 (package 05 implementation: `init` writes the `gates.json` defaults), 2026-11-04 (/simplify review of feature/feature-05: exit code 17 for a file in `.shadekit/` that cannot be written), 2026-11-15 (package 08, Gate 2: call form per agent in the managed section; the Copilot instruction file is resolved, no third file). Implemented except the final content of the templates owned by later packages (skeletons until then). | +| Status | Draft, 2026-10-14, updated 2026-10-17 (template conventions), 2026-10-18 (implementation state; code review rework: exit codes 14 and 24, `.gitignore` rule, separator line), 2026-10-22 (code review verification of package 03: `trackers` id prefixes validated), 2026-10-23 (rework of file content handling: line endings of `.gitignore`, `CLAUDE.md`, and `AGENTS.md`, strict UTF-8, warnings; code review: `editorconfig-invalid`, legacy `crlf` attribute, `text=input`), and 2026-10-24 (documentation check: exit code 14 also for the `request.md` template, warnings sentence, resolved open point removed), and 2026-10-25 (rework of `feature new` in package 03: the `request.md` template is removed, `init` no longer writes `.shadekit/templates/request.md`, exit code 14 no longer covers it; `trackers` hosts are read with `gh`), and 2026-10-26 (package 04 implementation: comma-separated enum values make a `.shadekit/` JSON file invalid), 2026-10-30 (managed section text), and 2026-11-01 (package 05 implementation: `init` writes the `gates.json` defaults), 2026-11-04 (/simplify review of feature/feature-05: exit code 17 for a file in `.shadekit/` that cannot be written), 2026-11-15 (package 08, Gate 2: call form per agent in the managed section; the Copilot instruction file is resolved, no third file). Updated 2026-11-22 (`kitVersion` is the product version of the engine; the skills name the CLI contract instead, 06-1). Implemented except the final content of the templates owned by later packages (skeletons until then). | | Source | Concept §3.1 (`init`), §4.1, [§9](../../research/shade-kit-concept.md#9-version-drift) (§9.5) | | Depends on | 01 | | Enables | 03, 05, 18 and every phase package (they ship templates through this mechanism) | @@ -115,7 +115,7 @@ The team owns the values; the engine owns the schema. **Decided** (concept §9.1 |---|---| | `schemaVersion` | Format version (package 01). | | `minEngineVersion` | First engine version that supports this format version, stamped by the engine on every write (package 01). | -| `kitVersion` | Kit version that initialised or last upgraded the repository. Informational only; format checks use `schemaVersion`. `init` writes the engine version. | +| `kitVersion` | Kit version that initialised or last upgraded the repository. Informational only; format checks use `schemaVersion`. `init` writes the engine version. Since 2026-11-22 the skills carry no version of their own, so the kit version is the product version of the engine; whether skills and engine fit is checked by the CLI contract, not by this value (06-1). | | `defaultProfile` | Profile used by `feature new` when none is given. Default `feature`. `feature new` stops with exit code 40 (`unknown-profile`) if it is not `feature`, `bugfix`, or `quick` (package 03). **Implemented** (`KitConfig.DefaultProfile`, `FeatureStore`). | | `outdatedFormatOnRead` | What read commands do with a file in an older format (package 01): `migrate-and-warn` (default) or `stop`. | | `trackers` | Mapping from issue URL host to id prefix for feature ids. Default: `github.com` → `gh`, which also applies when the field is missing; `{}` turns issue-based ids off, `null` makes the file invalid. **Decided** on 2026-10-19 (code review rework). Every id prefix must consist of lowercase letters a-z and digits joined by single hyphens (`^[a-z0-9]+(-[a-z0-9]+)*$`, the pattern of a feature id), for example `gh` or `jira-1`; otherwise the file is invalid (exit code 22, `invalid-file`), and the message names the host and the prefix. **Decided** on 2026-10-22 (code review verification of package 03, finding 2); before, a prefix such as `GH` or `""` only failed in `feature new` with a misleading `invalid-feature-id`. **Implemented** (`KitConfig.Trackers`); `feature new` uses it for issue-based ids and reads the issue of every URL whose host is in it with `gh` (package 03, **Implemented**). | @@ -173,7 +173,7 @@ Every template follows the same conventions. **Decided** in the template intervi ### `templates.lock.json` -- One entry per shipped template: path, kit version, and content hash at install time. **Decided** (concept §9.5). **Implemented** (`TemplatesLock`, `TemplatesLockEntry`). +- One entry per shipped template: path, kit version (the engine version, see below), and content hash at install time. **Decided** (concept §9.5). **Implemented** (`TemplatesLock`, `TemplatesLockEntry`). - `init` writes it; package 18 uses it to tell changed from unchanged templates. - Shape: **Decided** on 2026-10-18 (implementation clarification). diff --git a/docs/feature-packages/06-1-engine-version-check.md b/docs/feature-packages/06-1-engine-version-check.md index 3affc26..06e21a7 100644 --- a/docs/feature-packages/06-1-engine-version-check.md +++ b/docs/feature-packages/06-1-engine-version-check.md @@ -1,36 +1,122 @@ -# 06-1 · Engine version check (`version --expect`) +# 06-1 · Engine version check (`version --expect-contract`) | | | |---|---| -| Status | Draft, 2026-11-04 (split from package 06), updated 2026-11-05 and 2026-11-06 (implementation clarification and implementation: strict SemVer 2.0.0 for `--expect`, the match on major and minor, `expectedVersion` in the envelope, the messages, `--expect` without a value and the `=` form, exit code 50, warning code `engine-prerelease-version-mismatch`), and 2026-11-13 (package 07 implementation: the mismatch message of an engine higher than the skill names `shade-kit integrations install`; exit codes 51–53 in the range 50–59). Implemented. | -| Source | [06 Skill foundation](06-skill-foundation.md) (version handshake), [concept §9.6](../../research/shade-kit-concept.md#9-version-drift) | +| Status | Draft, 2026-11-04 (split from package 06), updated 2026-11-05 and 2026-11-06 (implementation clarification and implementation: strict SemVer 2.0.0 for `--expect`, the match on major and minor, `expectedVersion` in the envelope, the messages, `--expect` without a value and the `=` form, exit code 50, warning code `engine-prerelease-version-mismatch`), 2026-11-13 (package 07 implementation: the mismatch message of an engine higher than the skill names `shade-kit integrations install`; exit codes 51–53 in the range 50–59), and 2026-11-22 (the CLI contract replaces the SemVer check: `CliContract` with `Current` and `MinSupported`, `version --expect-contract `, `data.contract` and `data.expectedContract`, exit codes 54 `engine-outdated` and 55 `skills-outdated`; `--expect`, exit code 50 `version-mismatch`, and the warning `engine-prerelease-version-mismatch` removed; [report](../../reports/versioning-cli-and-skills.md); scenario runs S18 and S19). Implemented. | +| Source | [06 Skill foundation](06-skill-foundation.md) (version handshake), [concept §9.6](../../research/shade-kit-concept.md#9-version-drift), [CLI contract report](../../reports/versioning-cli-and-skills.md) (2026-11-22) | | Kind | .NET (engine and CLI) | | Depends on | 01 | | Enables | 06-2, 06-5, 06-6, 06-9 | ## Benefit -A skill learns with one CLI call whether it may run against the installed engine. The engine applies the match rule, so every agent gets the same answer, and the skill text does not have to compare version numbers itself. +A skill learns with one CLI call whether the installed engine supports the CLI contract the skill is written for. The engine applies the window rule, so every agent gets the same answer, and the skill text does not have to compare numbers itself. The contract is independent of the product version, so a development build is checked like a release, and a release that changes nothing a skill can see needs no skill change. ## Scope ### In scope -- The option `--expect ` of `shade-kit version`. -- The match rule, the result in JSON and plain output, and the new exit, error, and warning codes. +- The CLI contract of the engine (`CliContract`) and its window. +- The option `--expect-contract ` of `shade-kit version`. +- The window rule, the result in JSON and plain output, and the new exit and error codes. +- Removing `--expect`, its match rule, exit code 50, and the warning `engine-prerelease-version-mismatch` (2026-11-22). - The `CLAUDE.md` changes that follow from it. ### Out of scope -- Where a skill takes its version from and how it calls the check (06-2, 06-5, 06-6, 06-9). -- Keeping the skill version in line with GitVersion (open point in 06-2). +- Where a skill states its contract and how it calls the check (06-2, 06-5, 06-6, 06-9). - Installed integrations in `version --json` (package 07). +- A snapshot test of the contract surface (open point in the [README](README.md#open-questions)). ## Functional description +**Implemented** on 2026-11-22 in the Core namespace `CreativeCoders.ShadeKit.Core.Versions` (`Core/Versions/`): `CliContract`, `CliContractWindow`, `ICliContractChecker` / `CliContractChecker` (a singleton that `AddShadeKitCore()` registers with `CliContract.Window`), and the exceptions `EngineContractOutdatedException` and `SkillsContractOutdatedException` in `Versions/Exceptions/`. `SemanticVersion` stays; the integrations use it (package 07). The CLI part is `VersionCommand`, `VersionCommandOptions.ExpectContract`, `VersionCommandData.Contract` and `VersionCommandData.ExpectedContract`, `VersionCommandContractData`, `ExpectedContractOptionConverter`, `ExpectedContractInvalidException`, and `CliErrorMapper`. Removed on 2026-11-22: `IEngineVersionChecker`, `EngineVersionChecker`, `EngineVersionCheckResult`, `EngineVersionMismatchDirection`, `EngineVersionMismatchException`, `InvalidSemanticVersionException`, `EnginePrereleaseVersionMismatchWarning`, `ExpectedVersionOptionConverter`, and `ExpectedVersionMissingException`. + +### CLI contract + +- The CLI contract is the numbered agreement between the engine and the kit skills. It covers everything the kit skills rely on: the agent-facing commands and their options, the fields of the `CliJsonEnvelope`, the fields of its `data` object, and the error and warning codes. **Decided** on 2026-11-22 ([report](../../reports/versioning-cli-and-skills.md)). **Implemented** (`CliContract`). +- The engine supports a window of contracts, from `CliContract.MinSupported` to `CliContract.Current`. `Current` rises with every change of the contract that the skills can see, additive ones included (a new option, a new `data` field, a new code); `MinSupported` rises only when a part of the contract is removed or reinterpreted, so that skills written for an older contract would no longer work. **Decided** on 2026-11-22. +- The contract numbers are independent of the product version that GitVersion derives; a release does not change them unless the contract changes. Every build of the same code has the same contract, so there is no leniency for a prerelease engine. **Decided** on 2026-11-22. +- Both start at `1` (`CliContract.Current = 1`, `CliContract.MinSupported = 1`). **Implemented** (`CliContractTests.Window_Constants_AreCurrentAndMinSupported`). +- `CliContractWindow` requires `MinSupported` ≥ 1 and `Current` ≥ `MinSupported`, so a requested contract `0` lies below every window. **Implemented** (`CliContractWindowTests`). +- Whether `Current` rises with every skill-visible change is a manual review duty; a snapshot test that would guard it is an open point ([README](README.md#open-questions), D-12 of the implementation). **Decided** on 2026-11-22. + +### Option `--expect-contract` + +- `shade-kit version [--json] --expect-contract ` checks the CLI contract `` that the calling skill is written for against the window of the engine. **Decided** on 2026-11-22. **Implemented** (`VersionCommandOptions.ExpectContract`, `VersionCommand`, `CliContractChecker`). +- `` is a contract number: a non-negative integer that fits an `int`, written in ASCII digits without a sign, leading zeros, or whitespace (`0`, `1`, `42`; not `01`, `+1`, ` 1`, `1.0`, `2147483648`). Any other value ends with exit code 2 `invalid-arguments` while the arguments are read; so does `--expect-contract` without a value (the last argument, or followed by an argument that starts with `-`, so `--expect-contract -1` counts as no value). **Decided** on 2026-11-22. **Implemented** (`ExpectedContractOptionConverter` throws `ExpectedContractInvalidException`, which `CliErrorMapper.MapArgumentError` maps; `ExpectedContractOptionConverterTests`, `VersionCommandOptionsTests`, `CliErrorMapperTests`, `ProgramTests`). +- With `--expect-contract`, `version` runs the check through `ShadeKitCommandContext` and does not read the installed integrations: no agent CLI is started, and `data.integrations` is left out (plain mode: no integration lines). This keeps the handshake fast (07 measured 0.73 s with `claude` on the `PATH` against 0.08 s without, for the earlier `--expect` call). **Decided** on 2026-11-22. **Implemented** (`VersionCommandTests.ExecuteAsync_ExpectContract_DoesNotReadIntegrationsAndOmitsField`, `VersionCommandTests.ExecuteAsync_ContractMismatch_DoesNotReadIntegrations`, `VersionCommandTests.ExecuteAsync_PlainModeExpectContract_WritesNoIntegrationLines`). +- Without `--expect-contract`, `version` reads and lists the integrations as before (package 07) and cannot fail because of them. **Implemented** (`VersionCommandTests.ExecuteAsync_WithoutExpectContract_DoesNotCheckContract`, `VersionCommandTests.ExecuteAsync_JsonModeWithoutExpectContract_WritesIntegrations`). +- The value follows the option after a space. The option parser ignores every unknown option of every command, and it has no `--expect-contract=` form: `--expect-contract=999` is an unknown option, so `version` succeeds without a check (exit code 0). Skills call exactly `--expect-contract `. **FACT** (run on 2026-11-22 against the Debug build of this branch: `version --json --expect-contract=999` returned exit code 0 and `ok: true` without `expectedContract`; `version --json --expect-contract 999` returned exit code 54; unknown options in general: `ProgramTests.RunAsync_JsonWithUnknownOption_IgnoresOptionAndWritesSuccessEnvelope`). The same holds for the removed option: `version --json --expect 0.9.0` is ignored and exits 0 without a check (`ProgramTests.RunAsync_VersionJsonExpectOldOption_IsNotChecked`). **Decided** on 2026-11-22 (D-11: `--expect` removed completely, not kept as an alias). + +### Window rule + +**Decided** on 2026-11-22. **Implemented** (`CliContractChecker`; `CliContractCheckerTests`). + +| Requested contract `R` | Result | +|---|---| +| `MinSupported` ≤ `R` ≤ `Current` | Success | +| `R` > `Current` (the skills are newer than the engine) | Failure: exit code 54 `engine-outdated` | +| `R` < `MinSupported` (the skills are older than the engine supports) | Failure: exit code 55 `skills-outdated` | + +### Result + +- `version --json` always has `data.contract` (`{"current": 1, "minSupported": 1}`), after `formats`. **Implemented** (`VersionCommandData.Contract`, `VersionCommandContractData`; `VersionCommandTests.ExecuteAsync_JsonMode_WritesContractWithCurrentAndMinSupported`, `ProgramTests.RunAsync_VersionJson_WritesContract`). +- Success with `--expect-contract`: the envelope of `version` with `expectedContract`, the checked number, in addition and without `integrations`. Without `--expect-contract`, `expectedContract` is left out. **Implemented** (`VersionCommandData.ExpectedContract`; `VersionCommandTests.ExecuteAsync_JsonModeExpectContract_WritesExpectedContract`, `VersionCommandTests.ExecuteAsync_JsonModeWithoutExpectContract_OmitsExpectedContract`, `ProgramTests.RunAsync_VersionJsonExpectContract1_WritesSuccessWithExpectedContract`). +- Failure: a failure envelope with `engine-outdated` or `skills-outdated`. The message names the engine version, the window, the requested contract, and the remedy. **Implemented** (`CliErrorMapper.Map`; `CliErrorMapperTests.Map_EngineContractOutdated_Returns54WithUpdateEngineMessage`, `CliErrorMapperTests.Map_SkillsContractOutdated_Returns55WithIntegrationsInstallMessage`). `{engine}` is the engine version, `{min}` and `{current}` the window, `{n}` the requested contract: + - `engine-outdated`: `The SHADE kit engine {engine} supports the CLI contracts {min} to {current}, but the kit skills need the CLI contract {n}. Update the engine, then run the skill again.` + - `skills-outdated`: `The kit skills are written for the CLI contract {n}, but the SHADE kit engine {engine} supports only the CLI contracts {min} to {current}. Run 'shade-kit integrations install' to install the matching kit skills, then run the skill again.` For a release engine whose tag exists, the hint cannot loop the way the 50 hint could (07): the guard `SkillContractTests` makes every tagged tree carry skills with `R == Current` of the engine built from it (06-2, [07 FP07-AC2](07-claude-code-integration.md#acceptance-criteria)). An engine that installs from `main` (a prerelease engine, or a release engine whose tag does not exist, 07) gets the skills of `main`, whose `R` can lie below its `MinSupported`, so the hint can repeat once `MinSupported` > 1; this is latent while `MinSupported` = 1. +- Invalid `--expect-contract`: `Invalid arguments: --expect-contract needs a CLI contract number such as 1, but got none. Run 'shade-kit version --help' for usage.`, and `… but got '{value}'. …` for a value that is not a contract number. **Implemented** (`CliErrorMapper.MapArgumentError`; `CliErrorMapperTests.MapArgumentError_ExpectedContractInvalidWithoutValue_ReturnsInvalidArgumentsWithGotNone`, `CliErrorMapperTests.MapArgumentError_ExpectedContractInvalidWithValue_ReturnsInvalidArgumentsNamingValue`). +- Plain output: line 1 `shade-kit `, line 2 `CLI contract (supported: to )`, then, without `--expect-contract`, one line per installed integration. A failed check writes only the message, with exit code 54 or 55. **Implemented** (`VersionCommandTests.ExecuteAsync_PlainMode_WritesContractLineAfterVersionLine`, `ProgramTests.RunAsync_VersionPlain_WritesContractLineAfterVersionLine`, `ProgramTests.RunAsync_VersionPlainExpectContract999_WritesOnlyMessageAndReturns54`). +- Where a plain failure is written follows the CLI host, as before: a contract outside the window fails inside the command, so the message goes to stdout; an invalid or missing value fails while the arguments are read, so the message goes to stderr; in JSON mode every case writes one envelope to stdout and nothing else. **Implemented** (`ProgramTests.RunAsync_VersionPlainExpectContract999_WritesOnlyMessageAndReturns54`, `ProgramTests.RunAsync_VersionPlainExpectContractWithoutValue_WritesMessageToStandardErrorAndReturns2`). + +### Exit and warning codes + +- Range **50–59, versions and integrations**, for this package and package 07. **Decided** on 2026-11-04. **Implemented** (`ShadeKitCliExitCodes`). +- `54` `engine-outdated` (`ShadeKitCliExitCodes.EngineOutdated`, `ShadeKitCliErrorCodes.EngineOutdated`) and `55` `skills-outdated` (`ShadeKitCliExitCodes.SkillsOutdated`, `ShadeKitCliErrorCodes.SkillsOutdated`). **Decided** on 2026-11-22. **Implemented** (`ShadeKitCliExitCodesTests`, `ShadeKitCliErrorCodesTests`). +- `51` `agent-not-found`, `52` `agent-command-failed`, and `53` `integration-conflict` of package 07 are in the same range since 2026-11-13 ([07](07-claude-code-integration.md#exit-error-and-warning-codes)). **Implemented**. +- `50` `version-mismatch` and the warning `engine-prerelease-version-mismatch` are removed; `50` is unused. **Decided** on 2026-11-22. **Implemented**. + +### `CLAUDE.md` + +- `Core/Versions/` in the repository layout names the contract types, the command example is `version --json --expect-contract `, the `ICliValueConverter` example is `ExpectedContractOptionConverter`, and the skill conventions describe the contract handshake and the guard `SkillContractTests`. **Implemented** on 2026-11-22. + +## Acceptance criteria + +Status as of 2026-11-22. Every criterion is **Implemented**. The tests that carried `[Trait("Requirement", "FP06-1-AC1")]` to `FP06-1-AC5` were deleted with the `--expect` check; the new tests carry no FP06-1 trait and are named here by class and method. Two tests of the unchanged path still carry `FP06-1-AC6`: `VersionCommandTests.ExecuteAsync_PlainMode_WritesToolNameAndEngineVersion` and `VersionCommandTests.ExecuteAsync_JsonModeWithoutExpectContract_WritesEnvelopeWithContractAndIntegrations`. + +- **FP06-1-AC1** `shade-kit version --json --expect-contract ` with `` above `CliContract.Current` ends with exit code 54 and a failure envelope with the error code `engine-outdated`, whose message tells to update the engine; the plain output gives the same message and exit code. Proven by `CliContractCheckerTests.Check_RequestedAboveCurrent_ThrowsEngineContractOutdatedExceptionWithContracts`, `VersionCommandTests.ExecuteAsync_JsonModeEngineOutdated_WritesEngineOutdatedEnvelopeAndAbortsWith54`, `VersionCommandTests.ExecuteAsync_PlainModeEngineOutdated_AbortsWith54AndMessageWithoutOutput`, `CliErrorMapperTests.Map_EngineContractOutdated_Returns54WithUpdateEngineMessage`, `ProgramTests.RunAsync_VersionJsonExpectContract999_WritesEngineOutdatedAndReturns54`, `ProgramTests.RunAsync_VersionPlainExpectContract999_WritesOnlyMessageAndReturns54`. +- **FP06-1-AC2** With `` below `CliContract.MinSupported` the command ends with exit code 55 and the error code `skills-outdated`, whose message names `shade-kit integrations install`. Proven by `CliContractCheckerTests.Check_RequestedBelowMinSupported_ThrowsSkillsContractOutdatedExceptionWithContracts`, `CliContractCheckerTests.Check_RequestedZeroWithDefaultWindow_ThrowsSkillsContractOutdatedException`, `VersionCommandTests.ExecuteAsync_JsonModeSkillsOutdated_WritesSkillsOutdatedEnvelopeAndAbortsWith55`, `VersionCommandTests.ExecuteAsync_PlainModeSkillsOutdated_AbortsWith55AndMessageWithoutOutput`, `CliErrorMapperTests.Map_SkillsContractOutdated_Returns55WithIntegrationsInstallMessage`, `ProgramTests.RunAsync_VersionJsonExpectContract0_WritesSkillsOutdatedAndReturns55`. +- **FP06-1-AC3** With `` inside the window the command succeeds without a warning and echoes `` as `expectedContract`; this holds for a prerelease engine too, since the check does not look at the product version. Proven by `CliContractCheckerTests.Check_RequestedWithinWindow_Succeeds`, `VersionCommandTests.ExecuteAsync_JsonModeExpectContractInWindow_WritesSuccess`, `VersionCommandTests.ExecuteAsync_JsonModeExpectContractWithRealChecker_SucceedsForEveryContractInWindow`, `VersionCommandTests.ExecuteAsync_JsonModeExpectContract_WritesExpectedContract`, `ProgramTests.RunAsync_VersionJsonExpectContract1_WritesSuccessWithExpectedContract`. +- **FP06-1-AC4** With `--expect-contract`, `version` does not read the integrations: no agent CLI is started, `data.integrations` is left out, and the plain output has no integration lines, also when the check fails. Proven by `VersionCommandTests.ExecuteAsync_ExpectContract_DoesNotReadIntegrationsAndOmitsField`, `VersionCommandTests.ExecuteAsync_ContractMismatch_DoesNotReadIntegrations`, `VersionCommandTests.ExecuteAsync_PlainModeExpectContract_WritesNoIntegrationLines`. +- **FP06-1-AC5** `--expect-contract` without a value, or with a value that is not a contract number, ends with exit code 2 `invalid-arguments`; the removed `--expect` is not checked. Proven by `ExpectedContractOptionConverterTests` (`Convert_Null_ThrowsExpectedContractInvalidException`, `Convert_InvalidText_ThrowsExpectedContractInvalidExceptionWithValue`, `Convert_ValidText_ReturnsInt`), `VersionCommandOptionsTests` (`Options_ExpectOption_DoesNotExist`, `Parse_ExpectContractWithoutValue_ThrowsExpectedContractInvalidExceptionWithoutValue`, `Parse_ExpectContractNotANumber_ThrowsExpectedContractInvalidExceptionWithValue`), `CliErrorMapperTests.MapArgumentError_ExpectedContractInvalidWithoutValue_ReturnsInvalidArgumentsWithGotNone`, `CliErrorMapperTests.MapArgumentError_ExpectedContractInvalidWithValue_ReturnsInvalidArgumentsNamingValue`, `ProgramTests.RunAsync_VersionJsonExpectContractNotANumber_WritesInvalidArgumentsAndReturns2`, `ProgramTests.RunAsync_VersionExpectContractWithoutValue_WritesInvalidArgumentsAndReturns2`, `ProgramTests.RunAsync_VersionJsonExpectOldOption_IsNotChecked`. +- **FP06-1-AC6** Without `--expect-contract`, `version` reads and lists the integrations as before and cannot fail; the output carries the contract window (`data.contract`, plain line 2). Proven by `VersionCommandTests.ExecuteAsync_PlainMode_WritesToolNameAndEngineVersion` and `VersionCommandTests.ExecuteAsync_JsonModeWithoutExpectContract_WritesEnvelopeWithContractAndIntegrations` (both `FP06-1-AC6`), `VersionCommandTests.ExecuteAsync_WithoutExpectContract_DoesNotCheckContract`, `ProgramTests.RunAsync_VersionJson_WritesContract`. + +## Scenario runs + +**2026-11-22**, the refused handshake with the CLI contract (procedure of `tests/skill-scenarios/README.md`, step 5). The handshake runs of the skill packages before this date used `--expect` ([06-5](06-5-phase-entry-skill.md#acceptance-criteria), [06-6](06-6-next-phase-skill.md#acceptance-criteria), [06-9](06-9-skill-skeleton-alignment.md#acceptance-criteria)); these two scenarios cover the new refusals. One fresh runner subagent per scenario, as the README sets out; the refusal fixtures come from the real engine through the stand-in calls `--expect-contract 999` (`env-version-engine-outdated.json`) and `--expect-contract 0` (`env-version-skills-outdated.json`). + +| # | Scenario | Agent played | Checks | +|---|---|---|---| +| S18 | `shade-kit-new`, the engine is older than the skills (`engine-outdated`) | Claude Code | pass | +| S19 | `shade-kit-next-phase`, the skills are older than the engine (`skills-outdated`) | OpenAI Codex CLI, default mode | pass | +| | Total (`check_runs.py --only S18,S19`, final checker) | | 22 of 22 | + +- Both skills stopped at the handshake with exactly one CLI call (`shade-kit version --json --expect-contract 1`), asked the human nothing, and ended through `shade-kit-next-steps` with the refusal and the right remedy: S18 to update the engine, then call `/shade-kit-new` again; S19 to run `shade-kit integrations install`, start a new agent session, then call `$shade-kit:shade-kit-next-phase` again. +- Unclear points the runners reported: (1) the `error.message` of the refusal fixtures names the contract 999 or 0, while the skill passes 1; this is inherent, because the real engine cannot produce these errors for 1, and it is documented in the scenario README; (2) step 5.3 of `shade-kit-next-steps` does not say what to do when `phase next` never ran; both runners left that part out (open, not changed in this round, [README](README.md#open-questions)); (3) the `skills-outdated` row of the refusal table adds "start a new agent session" to the advice of the envelope; intended, because an agent loads the new skills only in a new session. +- Known checker gap (D-23, **Closed** in review round 1 on 2026-11-22, open before): the S19 check that the options do not tell to update the engine (`ENGINE_UPDATE` in `checks/check_runs.py`) missed an engine update named only through the tool ("get a newer shade-kit") and flagged "install the kit plugin that matches the engine" as an engine update; the S18 check that the options say to update the engine uses the same pattern. The task was marked blocked by the user after two verification rounds and recorded as an open point in the [README](README.md#open-questions). Closed in review round 1 (finding M4), refined in review round 2 (finding M6): `ENGINE_UPDATE` now also counts an engine update named through the tool ("get a newer shade-kit", "install the latest shade-kit", "upgrade the shade-kit CLI", "Update SHADE kit", `dotnet tool update`), also with the verbs download and replace and the -s/-ing forms and as "the engine is/was too old" or "outdated", and no longer counts the skills remedy when a word between the verb and "engine" or the tool, or a skills word in the clause before "newer engine" or in the 40 characters after it, names the skills, a plugin, the integration or integrations, the marketplace, or the kit on its own ("install the kit plugin that matches the engine", "reinstall the SHADE kit integration for the engine", "Install the skills that match the newer engine"); "the kit engine" counts as the engine, and the call form `$shade-kit:` before a skill name does not count as the tool (finding M7); negations ("you do not need to update the engine") and paraphrases without a listed verb ("bring the engine up to date") remain a known limit of the heuristic (review round 3, 2026-11-22). S18 and S19 checked again on the same runner outputs: 22 of 22. + +## Replaced on 2026-11-22: the SemVer check of `--expect` (history) + +Replaced on 2026-11-22 by the CLI contract above ([report](../../reports/versioning-cli-and-skills.md)). Reason: one product version, kept by hand in every skill, carried two meanings; every skill-visible change forced a kit-wide product minor (and `next-version` in `GitVersion.yml`), the guard depended on the branch and the tags of the build, and a prerelease engine was not checked at all. The text below is the state before 2026-11-22; its **Implemented** labels name code that has been removed. + +- Replaced on 2026-11-22: the strict SemVer 2.0.0 value of `--expect` (now a contract number), the major.minor match rule (now the window rule), the prerelease leniency (none: every build of the same code has the same contract), and the note on `--expect=` (still true of the parser, now for `--expect-contract=`, see above). + +### Functional description until 2026-11-22 + **Implemented** in the Core namespace `CreativeCoders.ShadeKit.Core.Versions` (`Core/Versions/`): `SemanticVersion`, `IEngineVersionChecker` / `EngineVersionChecker` (a singleton registered by `AddShadeKitCore()`), `EngineVersionCheckResult`, `EngineVersionMismatchDirection`, the exceptions in `Versions/Exceptions/`, and the warning in `Versions/Warnings/`. The CLI part is `VersionCommand`, `VersionCommandOptions.Expect`, `VersionCommandData.ExpectedVersion`, `ExpectedVersionOptionConverter`, and `CliErrorMapper`. -### Option `--expect` +#### Option `--expect` - `shade-kit version [--json] --expect ` compares the engine version with the passed kit version of the calling skill. **Decided** on 2026-11-04. **Implemented** (`VersionCommandOptions.Expect`, `VersionCommand`). - Without `--expect`, `version` behaves as before (package 01): it cannot fail, and its output is unchanged. **Implemented** (`VersionCommandTests`, `ProgramTests`). @@ -39,7 +125,7 @@ A skill learns with one CLI call whether it may run against the installed engine - `--expect` without a value (the last argument, or followed by an argument that starts with `-`) also ends with exit code 2 `invalid-arguments`. The option parser alone would leave the option unset, so `version` would succeed without a check. **Decided** on 2026-11-06 (implementation). **Implemented**: `ExpectedVersionOptionConverter` throws `ExpectedVersionMissingException` while the arguments are read, and `CliErrorMapper.MapArgumentError` maps it (`ExpectedVersionOptionConverterTests`, `VersionCommandOptionsTests`, `CliErrorMapperTests`, `ProgramTests`). - The value follows the option after a space. The option parser has no `--expect=` form: `--expect=1.2.3` is an unknown option and is ignored like every unknown option of every command, so `version` succeeds without a check (exit code 0). Skills call exactly `--expect `. **Decided** on 2026-11-06 (implementation: accepted and documented). -### Match rule +#### Match rule **Decided** on 2026-11-04. **Implemented** (`EngineVersionChecker`; `EngineVersionCheckerTests`). @@ -54,7 +140,7 @@ A skill learns with one CLI call whether it may run against the installed engine - Major and minor are compared as a pair: the engine is lower than the skill if its (major, minor) is lower, for example `1.9` against `1.10`, and higher otherwise. **Decided** on 2026-11-05. - An engine version that is not a SemVer version is a defect of the engine build, not of the arguments: the check fails with exit code 255 `host-error`. **Decided** on 2026-11-05. **Implemented** (`EngineVersionChecker` throws an `InvalidOperationException`, which `CliErrorMapper` does not map). -### Result +#### Result - Success: the envelope of `version` (package 01) with `expectedVersion`, the value of `--expect` as passed, in addition. Without `--expect`, the field is left out, so the envelope is unchanged. **Decided** on 2026-11-05. **Implemented** (`VersionCommandData.ExpectedVersion`). - Failure: a failure envelope with `version-mismatch`. The message names both versions and what to update. **Decided** on 2026-11-05. **Implemented** (`EngineVersionMismatchException`, `CliErrorMapper`). `{engine}` is the engine version, `{expected}` the value of `--expect` as passed, and `x.y` the major and minor version: @@ -68,21 +154,21 @@ A skill learns with one CLI call whether it may run against the installed engine - `--expect` without a value fails while the arguments are read, like every argument error: the message goes to stderr. - In JSON mode, every case writes one envelope to stdout and nothing else. -### Exit and warning codes +#### Exit and warning codes - New range **50–59, versions and integrations**, for this package and package 07. **Decided** on 2026-11-04. **Implemented** (`ShadeKitCliExitCodes`). - `50` `version-mismatch` (`ShadeKitCliExitCodes.VersionMismatch`, `ShadeKitCliErrorCodes.VersionMismatch`, `CliErrorMapper`). **Implemented**. - `51` `agent-not-found`, `52` `agent-command-failed`, and `53` `integration-conflict` of package 07 are in the same range since 2026-11-13, with the warning codes `integration-prerelease-ref`, `integration-release-tag-missing`, and `agent-unavailable` ([07](07-claude-code-integration.md#exit-error-and-warning-codes)). **Implemented**. - Warning `engine-prerelease-version-mismatch` (`ShadeKitCliWarningCodes.EnginePrereleaseVersionMismatch`). **Decided** on 2026-11-05 (name). **Implemented**. -### `CLAUDE.md` +#### `CLAUDE.md` - The sentence that `version` cannot fail and therefore writes its envelope through `ICliJsonWriter` is replaced: no command uses `ICliJsonWriter` directly, `version` included. **Decided** on 2026-11-05. **Implemented**. - The range 50–59 is added to the list of exit code ranges, `Core/Versions/` to the repository layout, and `version --json --expect ` to the command examples. **Implemented**. -## Acceptance criteria +### Acceptance criteria until 2026-11-22 -Every criterion is **Implemented**. The tests that prove it carry `[Trait("Requirement", "FP06-1-ACn")]`. +Replaced on 2026-11-22 by the [acceptance criteria](#acceptance-criteria) above. The tests named here were deleted with the `--expect` check, except the two tests of AC6 that still carry `FP06-1-AC6` (see the current FP06-1-AC6 above). - **FP06-1-AC1** `shade-kit version --json --expect ` against a release engine whose major or minor differs from `` ends with exit code 50 and a failure envelope with the error code `version-mismatch`; the message names both versions. The plain output gives the same message and exit code. Proven by `EngineVersionCheckerTests`, `VersionCommandTests`, `CliErrorMapperTests`, `ProgramTests`. - **FP06-1-AC2** The mismatch message names updating the engine when the engine version is lower than ``, and updating the skills when it is higher. Proven by `EngineVersionCheckerTests`, `VersionCommandTests`, `CliErrorMapperTests`, `ProgramTests`. @@ -93,4 +179,7 @@ Every criterion is **Implemented**. The tests that prove it carry `[Trait("Requi ## Open points -None. Both earlier points are answered: the success envelope carries `expectedVersion` when `--expect` is passed, and the warning code is `engine-prerelease-version-mismatch` (both **Decided** on 2026-11-05). +- A contract snapshot test that guards that `CliContract.Current` rises with every skill-visible change: decided again after v1 is complete; until then raising it is a manual review duty (D-12, [README](README.md#open-questions)). +- The scenario checker gap D-23 (see Scenario runs): closed in review round 1 on 2026-11-22. + +The two points open before 2026-11-22 were answered on 2026-11-05: the success envelope carried `expectedVersion` when `--expect` was passed, and the warning code was `engine-prerelease-version-mismatch` (both replaced on 2026-11-22). diff --git a/docs/feature-packages/06-2-skill-conventions-and-version.md b/docs/feature-packages/06-2-skill-conventions-and-version.md index 7ce80e8..3f8ae68 100644 --- a/docs/feature-packages/06-2-skill-conventions-and-version.md +++ b/docs/feature-packages/06-2-skill-conventions-and-version.md @@ -2,7 +2,7 @@ | | | |---|---| -| Status | Draft, 2026-11-04 (split from package 06), updated 2026-11-06 (implementation: visibility check in Claude Code, `metadata.version` `0.7.0` in every skill, the SemVer rule, who checks, the wording of the handshake step, the quoted `shade-kit-report` description, the skill conventions in `CLAUDE.md`) and 2026-11-13 (package 07 implementation: the skeleton source comments removed, the guard test of FP07-AC7, the plugin skill names in Claude Code), and 2026-11-14 (package 07 review rework, Gate 5: every skill raised to `0.8.0`; the guard test `SkillKitVersionTests` checks the version and every handshake text against the major.minor of the engine build; the FP07-AC7 guard scans every text file under `skills/`), and 2026-11-15 (package 07 review rework, Gate 5 round 2: the guard takes the most frequent version as the kit version, so an outlier skill is the one reported), and 2026-11-15 (package 08: frontmatter visibility of Copilot and Codex answered), 2026-11-18 (scenario building blocks in `tests/skill-scenarios/`), and 2026-11-20 (package 09: every skill raised to `0.9.0` through `next-version` in `GitVersion.yml`; a second template exception for `shade-kit-discuss`). AC1 and AC2 implemented; AC3: rule and wording set, applied by 06-5, 06-6, and 06-9. | +| Status | Draft, 2026-11-04 (split from package 06), updated 2026-11-06 (implementation: visibility check in Claude Code, `metadata.version` `0.7.0` in every skill, the SemVer rule, who checks, the wording of the handshake step, the quoted `shade-kit-report` description, the skill conventions in `CLAUDE.md`) and 2026-11-13 (package 07 implementation: the skeleton source comments removed, the guard test of FP07-AC7, the plugin skill names in Claude Code), and 2026-11-14 (package 07 review rework, Gate 5: every skill raised to `0.8.0`; the guard test `SkillKitVersionTests` checks the version and every handshake text against the major.minor of the engine build; the FP07-AC7 guard scans every text file under `skills/`), and 2026-11-15 (package 07 review rework, Gate 5 round 2: the guard takes the most frequent version as the kit version, so an outlier skill is the one reported), and 2026-11-15 (package 08: frontmatter visibility of Copilot and Codex answered), 2026-11-18 (scenario building blocks in `tests/skill-scenarios/`), 2026-11-20 (package 09: every skill raised to `0.9.0` through `next-version` in `GitVersion.yml`; a second template exception for `shade-kit-discuss`), and 2026-11-22 (the kit version replaced by the CLI contract: no `metadata` block in any skill, the handshake sentence names the CLI contract, the guard `SkillContractTests` replaces `SkillKitVersionTests` and no longer depends on GitVersion; [report](../../reports/versioning-cli-and-skills.md)). AC1 to AC3 implemented. | | Source | [06 Skill foundation](06-skill-foundation.md) (skill conventions, version handshake), Concept §3.2, §3.3 | | Kind | Cross-cutting (all skills) | | Depends on | 06-1 | @@ -10,21 +10,22 @@ ## Benefit -Every kit skill follows the same rules and carries its kit version. A team can install the skills as a plugin, and every skill the human calls can check whether it fits the installed engine. +Every kit skill follows the same rules and names the CLI contract it is written for. A team can install the skills as a plugin, and every skill the human calls can check whether the installed engine supports that contract. (Until 2026-11-22 every skill carried its kit version instead; see [Kit version in the frontmatter](#kit-version-in-the-frontmatter-replaced-on-2026-11-22).) ## Scope ### In scope - The conventions every kit skill follows. -- The kit version in the frontmatter of every skill. +- The CLI contract in the handshake text of the skills that run the handshake (since 2026-11-22; until then the kit version in the frontmatter of every skill). - Checking whether Claude Code shows the frontmatter to the model, and the fallback if it does not. ### Out of scope - Writing the version check into the skills (06-5, 06-6, 06-9); this package sets who checks and the wording. - Copilot and Codex (package 08). -- Writing the skill version from GitVersion; the version is raised by hand, and since 2026-11-14 a guard test checks it (see Kit version in the frontmatter and open points). +- Writing the skill version from GitVersion; the version is raised by hand, and since 2026-11-14 a guard test checks it (see Kit version in the frontmatter and open points). Replaced on 2026-11-22 ([CLI contract report](../../reports/versioning-cli-and-skills.md), [06-1](06-1-engine-version-check.md)): the skills carry no product version, so nothing is written from GitVersion; the contract number is raised by hand together with `CliContract.Current`, and `SkillContractTests` names every place. +- A snapshot test that guards that `CliContract.Current` rises with every skill-visible CLI change (open point of the [README](README.md#open-questions), D-12). ## Functional description @@ -36,10 +37,28 @@ Every kit skill follows the same rules and carries its kit version. A team can i - A shipped skill references no path under `research/` or `docs/` of the kit repository; those folders are design notes and are not shipped. The source comments of the skeletons are removed when a skill is worked out. **Decided** on 2026-10-18 (findings clarification). Checked when the skills are shipped: FP07-AC7 (package 07). **Decided** on 2026-11-04. Since package 07 this repository is the shipped plugin, so the source comments `` were removed from all 13 skeletons that still had them, also from those not worked out yet. **Decided** on 2026-11-13 (package 07 implementation). **Implemented**. A guard test fails when a text file under `skills/` has a path segment `docs/` or `research/`; until 2026-11-14 it scanned only `SKILL.md` (**Implemented**: `ShippedSkillsTests`, FP07-AC7). - Every artifact a skill creates starts from the repository's template in `.shadekit/templates/`, not from text built into the skill, so team edits to templates take effect. **Decided** on 2026-11-04. The skill follows the template conventions of package 02: it follows the guidance comments, replaces every placeholder, and removes the guidance comments; checklist copies (package 05) keep their guidance comments. One exception: when `.shadekit/templates/researches.md` is missing, `shade-kit-research` creates `researches.md` with the lines the template would give (title and feature line) and says so in its return, so that a research run is not lost to a deleted template. **Decided** on 2026-11-13 ([06-8](06-8-research-skill.md)). Second exception: when `.shadekit/templates/discussion.md` is missing, `shade-kit-discuss` writes the notes in the structure of the template and says so in its report, so that a discussion is not lost to a deleted template. **Decided** on 2026-11-20 ([09](09-discuss-and-intake.md#discuss)). - `request.md` can hold third-party content, written unchanged by `feature new`: the body and every comment of an issue, or a whole web page (package 03). Every skill that reads it, and every research agent that gets it as feature context, treats it as data that describes the requirement, never as instructions to the agent: it does not follow commands, links, or tool requests in it, and shows the human any instruction in it that looks suspicious (a research agent reports it to the calling skill, which shows it). **Decided** on 2026-10-25 (code review of the rework of `feature new`, finding F6; package 09, [`new`](09-discuss-and-intake.md#new)). **Implemented** (`shade-kit-new`, `shade-kit-refine`, `shade-kit-diagnose`, `shade-kit-quick`, `shade-kit-research`). -- The skill texts are checked by a review by hand when a sub-feature is accepted; there are no automated tests of the skill texts. **Decided** on 2026-11-04. Guard tests in `CreativeCoders.ShadeKit.Core.Tests/Skills/` check the shipped files mechanically, not what a skill does: the references into `docs/` and `research/` (`ShippedSkillsTests`, FP07-AC7) and the kit version (`SkillKitVersionTests`, FP07-AC2, since 2026-11-14). Since 2026-11-15 `SingleSkillSourceTests` (FP08-AC4) also checks that every skill has one source for all agents: no duplicate skill name, no `SKILL.md` in an agent skill location, no agent-specific manifest beside `.claude-plugin/`, and no agent-specific file in a skill folder ([08 FP08-AC4](08-copilot-and-codex-integration.md#acceptance-criteria)). Since 2026-11-18 `SkillAgentWordingTests` also checks that every skill uses the canonical question-tool parenthetical and call-form phrase ([08 Skill texts](08-copilot-and-codex-integration.md#skill-texts)). +- The skill texts are checked by a review by hand when a sub-feature is accepted; there are no automated tests of the skill texts. **Decided** on 2026-11-04. Guard tests in `CreativeCoders.ShadeKit.Core.Tests/Skills/` check the shipped files mechanically, not what a skill does: the references into `docs/` and `research/` (`ShippedSkillsTests`, FP07-AC7) and the kit version (`SkillKitVersionTests`, FP07-AC2, since 2026-11-14; replaced on 2026-11-22 by the CLI contract of the handshake, `SkillContractTests`, FP07-AC2). Since 2026-11-15 `SingleSkillSourceTests` (FP08-AC4) also checks that every skill has one source for all agents: no duplicate skill name, no `SKILL.md` in an agent skill location, no agent-specific manifest beside `.claude-plugin/`, and no agent-specific file in a skill folder ([08 FP08-AC4](08-copilot-and-codex-integration.md#acceptance-criteria)). Since 2026-11-18 `SkillAgentWordingTests` also checks that every skill uses the canonical question-tool parenthetical and call-form phrase ([08 Skill texts](08-copilot-and-codex-integration.md#skill-texts)). - A changed skill is also checked by scenario runs: a fresh subagent per scenario loads the skill, follows it with canned CLI envelopes, and records the commands it would run and its output; a script checks the outputs. The reusable building blocks live in `tests/skill-scenarios/`: the runner protocol, the scenario catalog, a fixture generator that builds the fixture repositories and envelopes from the current engine each time, and the expectations and checker; the procedure and the runner prompt are in its `README.md`. The outputs of runs and the generated fixtures stay outside the repository. **Decided** on 2026-11-18; this supersedes D-28 of the [06-4 implementation report](../implementation/06-4-gate-check-skill.md) (scenario runs outside the repository). **Implemented** (`tests/skill-scenarios/`, not compiled and not shipped; the nine scenarios S1–S9 of 2026-11-18 pass 69 of 69 checks). -### Kit version in the frontmatter +### CLI contract in the handshake + +- No skill under `skills/` carries a `metadata` block or a `version`; the frontmatter holds `name` and `description` only. **Decided** on 2026-11-22 (D-3 of the implementation, [report](../../reports/versioning-cli-and-skills.md)). **Implemented** (all 19 skills; checked by `SkillContractTests`, which reports any frontmatter `version:` key). +- A skill that runs the version handshake names in the text of its handshake step the CLI contract it is written for ([06-1](06-1-engine-version-check.md#cli-contract)). The contract is `CliContract.Current` of the engine the skills are released with, `1` since 2026-11-22. **Decided** on 2026-11-22. **Implemented**. +- The handshake step has this wording, verbatim, in `shade-kit-new`, `shade-kit-discuss`, `shade-kit-drop`, `shade-kit-next-phase`, and `shade-kit-phase-entry`. **Decided** on 2026-11-22. **Implemented**. + + ```text + Version handshake: run `shade-kit version --json --expect-contract 1`; 1 is the CLI contract this skill is written for. + ``` + +- Reactions: `ok: true` continues; `ok: false` (for example `engine-outdated` or `skills-outdated`) or a `shade-kit` that the shell does not find ends the skill with a refusal through `shade-kit-next-steps`, whose refusal table has the rows `engine-outdated` (update the engine), `skills-outdated` (`shade-kit integrations install`, then a new agent session), and `shade-kit` not found ([06-3](06-3-next-steps-skill.md)). **Decided** on 2026-11-22. **Implemented**. +- The skills do not check that the answer has `data.contract`. An engine from before 2026-11-22 ignores `--expect-contract` as an unknown option and answers `ok: true` without a check; this transition risk is accepted, because no release tag holds both such an engine and the plugin manifests (`v0.7.0` and `v0.8.0` have no `.claude-plugin/`, [07](07-claude-code-integration.md#open-points)); what remains are tool packages built from `main` or a feature branch before 2026-11-22 (report). **Decided** on 2026-11-22 (D-10 of the implementation). +- Who runs the handshake is unchanged (see [Kit version in the frontmatter](#kit-version-in-the-frontmatter-replaced-on-2026-11-22)): `shade-kit-phase-entry` for the phase skills, and `new`, `discuss`, `drop`, and `shade-kit-next-phase` in their own first step; every other skill runs none. +- Raising the contract: when a CLI change is visible to the skills (a command, an option, an envelope or `data` field, an error or warning code), `CliContract.Current` rises (06-1), and in the same commit the five handshake sentences and the command lists of `shade-kit-next-phase` and `shade-kit-phase-entry` name the new number. Raising the product version (GitVersion, `next-version`) needs no skill change. **Decided** on 2026-11-22. +- The guard test `SkillContractTests.SkillFiles_ShippedSkills_NameTheCurrentCliContractEverywhere` (`CreativeCoders.ShadeKit.Core.Tests/Skills/`, `[Trait("Requirement", "FP07-AC2")]`) fails the build unless every `--expect-contract ` and every "`` is the CLI contract this skill is written for" in a text file under `skills/` names `CliContract.Current`, the five handshake skills carry the sentence verbatim, and no `--expect` option and no frontmatter `version:` is left; it lists every violation with file and line, so it names every place to change. It reads only the checked-in files and does not depend on GitVersion, tags, or the branch. **Decided** on 2026-11-22. **Implemented**. + +### Kit version in the frontmatter (replaced on 2026-11-22) + +Replaced on 2026-11-22 ([CLI contract report](../../reports/versioning-cli-and-skills.md), [06-1](06-1-engine-version-check.md)): the skills carry no kit version; they name the CLI contract in the handshake text (see above). Reason: one product version kept by hand in every skill carried two meanings, every skill-visible CLI change forced a kit-wide product minor and `next-version`, and the guard depended on the GitVersion version of the build. The bullets below are the state before 2026-11-22; the version values, the guard `SkillKitVersionTests`, and the `--expect` wording no longer exist. Still valid: the quoting rule for a `description`, and who runs the handshake. - Every skill under `skills/` carries its kit version in the frontmatter, hardcoded and committed, because the skills must be installable as a plugin with their version included. **Decided** on 2026-11-04. **Implemented** (all 19 skills under `skills/`, `0.9.0` since 2026-11-20; `0.8.0` from 2026-11-14; `0.7.0` from 2026-11-06). @@ -61,42 +80,43 @@ Every kit skill follows the same rules and carries its kit version. A team can i - The other skills the human calls (`new`, `discuss`, `drop`, `shade-kit-next-phase`) check in their own first step (06-6, 06-9). - Every other skill that only another skill loads does not check. - Each check passes this version to `shade-kit version --json --expect ` (06-1). + Each check passes this version to `shade-kit version --json --expect ` (06-1). Replaced on 2026-11-22: each check passes the CLI contract to `shade-kit version --json --expect-contract `; who checks is unchanged. ### Frontmatter visibility -- This sub-feature checks first whether Claude Code shows the frontmatter, and `metadata.version` in it, to the model when it loads a skill. **Decided** on 2026-11-04. Copilot and Codex were checked in package 08 on 2026-11-15, from documentation and source only (neither CLI is installed): Copilot does not show the frontmatter to the model since Copilot CLI 1.0.48, and Codex injects the whole `SKILL.md`, frontmatter included, on a mention; both ignore `metadata.version`. So the rule below, the version stated in the handshake text, holds for all three agents. **Unverified:** how their YAML parsers type the unquoted `0.8.0` ([08](08-copilot-and-codex-integration.md#open-points)). +- This sub-feature checks first whether Claude Code shows the frontmatter, and `metadata.version` in it, to the model when it loads a skill. **Decided** on 2026-11-04. Copilot and Codex were checked in package 08 on 2026-11-15, from documentation and source only (neither CLI is installed): Copilot does not show the frontmatter to the model since Copilot CLI 1.0.48, and Codex injects the whole `SKILL.md`, frontmatter included, on a mention; both ignore `metadata.version`. So the rule below, the version stated in the handshake text, holds for all three agents. **Unverified:** how their YAML parsers type the unquoted `0.8.0` ([08](08-copilot-and-codex-integration.md#open-points)). Since 2026-11-22 the skills have no `metadata` block, so this question no longer matters; the number the handshake needs is in the text, for all three agents. - Result: Claude Code does not show the frontmatter to the model. Checked on 2026-11-06 with Claude Code 2.1.318 and the model `claude-opus-5-5`. - How it was checked: a canary skill `shade-kit-canary` in the project-level `.claude/skills/`, with `metadata.version: 9.8.7` in its frontmatter and a marker line in its body that names no version. Two headless `claude -p` runs with the built-in file and shell tools blocked (`--disallowedTools "Read,Bash,Grep,Glob,Edit,Write,NotebookEdit,WebFetch,WebSearch,Agent"`): one loaded the skill through the Skill tool, the other through the slash command `/shade-kit-canary`. The saved session transcripts were searched. The model called no tool except `Skill`; MCP tools that can read files were not blocked, but none was used. An independent verifier repeated the Skill tool run and got the same result. - What the model gets, on both paths: `Base directory for this skill:

`, followed by the body after the closing `---`. The frontmatter is removed completely: no `---`, no `name:`, no `metadata`, no `9.8.7`. The body marker is there. `name` and `description` reach the model only through the skill listing (`- : `), not as YAML. - Two further skills loaded in the implementing session gave the same result: `implement-direct`, called by the user as a slash command, and `skill-creator`, loaded through the Skill tool. - The documentation agrees. The [Claude Code skills documentation](https://code.claude.com/docs/en/skills) says of `metadata`: "Free-form YAML map for your own key-value data, … read by your own tooling from `SKILL.md`. Claude Code doesn't act on its contents". It also says that "the rendered `SKILL.md` content enters the conversation as a single message", and that malformed frontmatter "loads the skill body with empty metadata". The Agent Skills overview (platform.claude.com) puts `name` and `description` from the YAML frontmatter at level 1 and the `SKILL.md` body at level 2. - Limits: one run per path; project-level skills only (plugin and user-level skills were not run). Copilot and Codex: see above (package 08). - - Plugin skills (package 07, 2026-11-13, Claude Code 2.1.323, headless, plugin loaded with `--plugin-dir`): the skill listing shows the namespaced name `shade-kit:shade-kit-next-phase`, both `/shade-kit-next-phase` and `/shade-kit:shade-kit-next-phase` load the skill, and its handshake ran with the version from the text (`--expect 0.7.0`, the kit version then). **FACT** ([07](07-claude-code-integration.md#skill-names-in-claude-code)). The frontmatter of plugin skills was not checked separately. -- The model does not see the frontmatter, so the fallback applies: every skill that calls `version --expect` also states the version in the text of its handshake step. The frontmatter stays the source; both places hold the same value. **Decided** on 2026-11-04; applies since the check on 2026-11-06. This sub-feature sets the rule and the wording; 06-5, 06-6, and 06-9 write them into the handshake steps. **Decided** on 2026-11-06. -- The handshake step has this wording in every skill that calls `version --expect`. **Decided** on 2026-11-06. + - Plugin skills (package 07, 2026-11-13, Claude Code 2.1.323, headless, plugin loaded with `--plugin-dir`): the skill listing shows the namespaced name `shade-kit:shade-kit-next-phase`, both `/shade-kit-next-phase` and `/shade-kit:shade-kit-next-phase` load the skill, and its handshake ran with the version from the text (`--expect 0.7.0`, the kit version then; the handshake names the CLI contract since 2026-11-22). **FACT** ([07](07-claude-code-integration.md#skill-names-in-claude-code)). The frontmatter of plugin skills was not checked separately. +- The model does not see the frontmatter, so the fallback applies: every skill that calls `version --expect` also states the version in the text of its handshake step. The frontmatter stays the source; both places hold the same value. **Decided** on 2026-11-04; applies since the check on 2026-11-06. This sub-feature sets the rule and the wording; 06-5, 06-6, and 06-9 write them into the handshake steps. **Decided** on 2026-11-06. Replaced on 2026-11-22 ([CLI contract report](../../reports/versioning-cli-and-skills.md), [06-1](06-1-engine-version-check.md)): the handshake text is the only source; it names the CLI contract, and there is no frontmatter value to keep in step ([CLI contract in the handshake](#cli-contract-in-the-handshake)). +- The handshake step has this wording in every skill that calls `version --expect`. **Decided** on 2026-11-06. Replaced on 2026-11-22 by the contract sentence under [CLI contract in the handshake](#cli-contract-in-the-handshake). ```text Version handshake: run `shade-kit version --json --expect 0.9.0`; 0.9.0 is the kit version of this skill (`metadata.version` in its frontmatter). ``` -- When the version is raised, the frontmatter of every skill and every handshake text change together: search the skills for the old value. **Decided** on 2026-11-06. -- The guard test `SkillKitVersionTests.SkillFiles_ShippedSkills_CarryOneKitVersionThatMatchesTheEngineMajorMinor` (`CreativeCoders.ShadeKit.Core.Tests/Skills/`, FP07-AC2) fails the build when a skill has no plain `x.y.z` `metadata.version`, when the skills carry different values, when their major.minor differs from the major.minor of the engine version of the build (GitVersion; patch and prerelease ignored), or when any `--expect ` or "`` is the kit version of this skill" in a text file under `skills/` names another version. **Decided** on 2026-11-14 (package 07 review rework, Gate 5). **Implemented** ([07 Kit version guard](07-claude-code-integration.md#kit-version-guard)). The kit version the skills are compared with is the most frequent valid version; on a tie, the version with the major.minor of the engine wins, then the version of the first skill in ordinal path order; so a single skill with another version is the one reported. **Decided** on 2026-11-15 (package 07 review rework, Gate 5 round 2, finding N6; before, the first skill with a valid version in path order was the reference). **Implemented** (`SkillKitVersionTests.SelectKitSkill`). +- When the version is raised, the frontmatter of every skill and every handshake text change together: search the skills for the old value. **Decided** on 2026-11-06. Replaced on 2026-11-22: when the contract is raised, the handshake sentences and the two command lists change together, and `SkillContractTests` names every place. +- The guard test `SkillKitVersionTests.SkillFiles_ShippedSkills_CarryOneKitVersionThatMatchesTheEngineMajorMinor` (`CreativeCoders.ShadeKit.Core.Tests/Skills/`, FP07-AC2) fails the build when a skill has no plain `x.y.z` `metadata.version`, when the skills carry different values, when their major.minor differs from the major.minor of the engine version of the build (GitVersion; patch and prerelease ignored), or when any `--expect ` or "`` is the kit version of this skill" in a text file under `skills/` names another version. **Decided** on 2026-11-14 (package 07 review rework, Gate 5). **Implemented** ([07 Kit version guard](07-claude-code-integration.md#kit-version-guard)). The kit version the skills are compared with is the most frequent valid version; on a tie, the version with the major.minor of the engine wins, then the version of the first skill in ordinal path order; so a single skill with another version is the one reported. **Decided** on 2026-11-15 (package 07 review rework, Gate 5 round 2, finding N6; before, the first skill with a valid version in path order was the reference). **Implemented** (`SkillKitVersionTests.SelectKitSkill`). Both replaced on 2026-11-22 by `SkillContractTests` (see [CLI contract in the handshake](#cli-contract-in-the-handshake)); `SkillKitVersionTests` was deleted. - Raised to `0.8.0` on 2026-11-14, in the frontmatter and in every handshake text of all 19 skills, because the engine builds carry `0.8.x` since the tag `v0.8.0` and the new guard failed with `0.7.0`. **Decided** on 2026-11-14 (package 07 review rework, Gate 5). -- Raised to `0.9.0` on 2026-11-20, in the frontmatter and in every handshake text of all 19 skills, with `next-version: v0.9.0` in `GitVersion.yml`: `shade-kit-new` calls `feature new --move-source`, which an engine 0.8 does not know, and the handshake compares only major and minor. **Decided** on 2026-11-20 (package 09, D-25 and D-26). +- Raised to `0.9.0` on 2026-11-20, in the frontmatter and in every handshake text of all 19 skills, with `next-version: v0.9.0` in `GitVersion.yml`: `shade-kit-new` calls `feature new --move-source`, which an engine 0.8 does not know, and the handshake compares only major and minor. **Decided** on 2026-11-20 (package 09, D-25 and D-26). This forced raise is one reason for the replacement on 2026-11-22: with the CLI contract, a new option raises `CliContract.Current` and the handshake number, not the product minor. ## Acceptance criteria -Status as of 2026-11-14. There are no automated tests of the skill texts (skill conventions above), so each criterion names how it is proven; the version guard of 07 now also proves AC1 and the version part of AC3. +Status as of 2026-11-22. There are no automated tests of the skill texts (skill conventions above), so each criterion names how it is proven; the guard `SkillContractTests` proves AC1 and AC3 mechanically. -- **FP06-2-AC1** Every skill under `skills/` has `metadata.version` in its frontmatter, and all skills have the same SemVer value. **Implemented**: all 19 skills carry `metadata.version: 0.9.0` (`0.8.0` until 2026-11-20, `0.7.0` until 2026-11-14). Proven on 2026-11-06 by a one-off check that all values are equal, are strings, and are a plain `x.y.z`, and since 2026-11-14 by `SkillKitVersionTests.SkillFiles_ShippedSkills_CarryOneKitVersionThatMatchesTheEngineMajorMinor`. Skill-creator's `quick_validate.py` (17 of 17 valid on 2026-11-06, 19 of 19 on 2026-11-20, run with PyYAML through `uv run --with pyyaml`) shows that the frontmatter stays valid; it does not read `metadata`. +- **FP06-2-AC1** No skill under `skills/` carries a frontmatter `version` (the frontmatter holds `name` and `description`), and every skill that runs the handshake names the same CLI contract, `CliContract.Current`. **Implemented** on 2026-11-22. Proven by `SkillContractTests.SkillFiles_ShippedSkills_NameTheCurrentCliContractEverywhere`. Replaced on 2026-11-22, the earlier text: every skill under `skills/` has `metadata.version` in its frontmatter, and all skills have the same SemVer value (`0.9.0` until 2026-11-22, `0.8.0` until 2026-11-20, `0.7.0` until 2026-11-14), proven by a one-off check on 2026-11-06 and by `SkillKitVersionTests` from 2026-11-14 to 2026-11-22. Skill-creator's `quick_validate.py` (17 of 17 valid on 2026-11-06, 19 of 19 on 2026-11-20, run with PyYAML through `uv run --with pyyaml`) showed that the frontmatter stays valid; it was not run again on 2026-11-22. - **FP06-2-AC2** The result of the visibility check for Claude Code is recorded in this package with the date and how it was checked. **Implemented**: recorded under Frontmatter visibility (2026-11-06, Claude Code 2.1.318). -- **FP06-2-AC3** If the check finds that the model does not see the frontmatter, every skill that calls `version --expect` states the same version in the text of its handshake step. Rule and wording **Decided** on 2026-11-06 (Frontmatter visibility). `shade-kit-phase-entry` (06-5) applies it since 2026-11-10 and `shade-kit-next-phase` (06-6) since 2026-11-11 (`--expect 0.7.0` in the text of their handshake steps then, `0.8.0` since 2026-11-14); `new`, `discuss`, and `drop` (06-9) since 2026-11-13. Every skill that calls `version --expect` now states the version in the text of its handshake step; since 2026-11-14 `SkillKitVersionTests` checks that every such text names the kit version. +- **FP06-2-AC3** Because the model does not see the frontmatter, every skill that runs the handshake states the CLI contract in the text of its handshake step, with the sentence of [CLI contract in the handshake](#cli-contract-in-the-handshake). **Implemented** on 2026-11-22 in `shade-kit-new`, `shade-kit-discuss`, `shade-kit-drop`, `shade-kit-next-phase`, and `shade-kit-phase-entry`; proven by `SkillContractTests` and by the scenario runs S18 and S19 of [06-1](06-1-engine-version-check.md#scenario-runs). Replaced on 2026-11-22, the earlier text: every skill that calls `version --expect` states the same version in the text of its handshake step (applied by `shade-kit-phase-entry` since 2026-11-10, `shade-kit-next-phase` since 2026-11-11, `new`, `discuss`, and `drop` since 2026-11-13; checked by `SkillKitVersionTests` from 2026-11-14). ## Open points -- **Alignment with GitVersion: checked, not written** (2026-11-04, updated 2026-11-14): the skill version is still raised by hand, which still breaks the rule in `GitVersion.yml` that no version is maintained by hand. Since 2026-11-14 `SkillKitVersionTests` ties it to the build: every build that runs the tests (pull request, `main`, `feature/**`, release tag) fails when the skills' major.minor differs from the engine's, so a release tag with stale skills fails its tag build before anything is published (19). Still open: writing the version from GitVersion (for example a Cake task, package 19), and a check before the tag is set (the `verify-tag` job does not check it; review Major, layer 2, not selected at Gate 5). The guard compares major.minor only, the rule of the handshake (06-1). -- Raising the minor: the commit that raises the skills to a new minor must also raise the minor of the build version, or the build of that commit fails the guard. Since 2026-11-20 this is done with `next-version` in `GitVersion.yml` (package 09, the first raise to `0.9.0`): `next-version: v0.9.0` gives the build `0.9.0-.` on the feature branch (**FACT**, run with GitVersion 6.8.2 and checked in the built `shade-kit.dll`). The value needs the tag prefix `v`: GitVersion parses it with `tag-prefix: 'v'`, and `0.9.0` without it fails with "Failed to parse 0.9.0 into a Semantic Version" (**FACT**, same run). GitVersion ignores `next-version` once a tag at or above it exists (**Unverified**, from the GitVersion documentation; not run in this repository). A `+semver: minor` commit message is no longer needed for this; whether it works was not checked. -- Initial value of `metadata.version`: answered, `0.7.0`. **Decided** on 2026-11-06. Raised to `0.8.0` on 2026-11-14 (see above) and to `0.9.0` on 2026-11-20 (package 09, because `shade-kit-new` needs `feature new --move-source`, which 0.8 engines lack). The value is raised by hand for every release whose major or minor differs. +- Answered on 2026-11-22 by the CLI contract (the skills carry no product version, and `SkillContractTests` does not depend on GitVersion); the first three points below are kept as history; the points after them are still open. +- **Alignment with GitVersion: checked, not written** (2026-11-04, updated 2026-11-14; replaced on 2026-11-22, see above): the skill version is still raised by hand, which still breaks the rule in `GitVersion.yml` that no version is maintained by hand. Since 2026-11-14 `SkillKitVersionTests` ties it to the build: every build that runs the tests (pull request, `main`, `feature/**`, release tag) fails when the skills' major.minor differs from the engine's, so a release tag with stale skills fails its tag build before anything is published (19). Still open: writing the version from GitVersion (for example a Cake task, package 19), and a check before the tag is set (the `verify-tag` job does not check it; review Major, layer 2, not selected at Gate 5). The guard compares major.minor only, the rule of the handshake (06-1). +- Raising the minor (replaced on 2026-11-22: raising the skills no longer needs `next-version`; it stays the lowest version of the next product release): the commit that raises the skills to a new minor must also raise the minor of the build version, or the build of that commit fails the guard. Since 2026-11-20 this is done with `next-version` in `GitVersion.yml` (package 09, the first raise to `0.9.0`): `next-version: v0.9.0` gives the build `0.9.0-.` on the feature branch (**FACT**, run with GitVersion 6.8.2 and checked in the built `shade-kit.dll`). The value needs the tag prefix `v`: GitVersion parses it with `tag-prefix: 'v'`, and `0.9.0` without it fails with "Failed to parse 0.9.0 into a Semantic Version" (**FACT**, same run). GitVersion ignores `next-version` once a tag at or above it exists (**Unverified**, from the GitVersion documentation; not run in this repository). A `+semver: minor` commit message is no longer needed for this; whether it works was not checked. +- Initial value of `metadata.version` (replaced on 2026-11-22: `metadata.version` removed): answered, `0.7.0`. **Decided** on 2026-11-06. Raised to `0.8.0` on 2026-11-14 (see above) and to `0.9.0` on 2026-11-20 (package 09, because `shade-kit-new` needs `feature new --move-source`, which 0.8 engines lack). The value is raised by hand for every release whose major or minor differs. - Exact skill names (concept open question 6). - Phase skills are restricted to user invocation only by convention; a technical restriction (Claude Code `disable-model-invocation`, and whatever Copilot and Codex offer) is a possible later addition. Package 08 found Copilot's `disable-model-invocation` (reported to break loading a flagged skill from another skill) and Codex's `agents/openai.yaml` (an agent-specific file); v1 uses neither (2026-11-15). diff --git a/docs/feature-packages/06-3-next-steps-skill.md b/docs/feature-packages/06-3-next-steps-skill.md index f385101..b96e037 100644 --- a/docs/feature-packages/06-3-next-steps-skill.md +++ b/docs/feature-packages/06-3-next-steps-skill.md @@ -2,7 +2,7 @@ | | | |---|---| -| Status | Draft, 2026-11-04 (split from package 06), updated 2026-11-08 (implementation: `skills/shade-kit-next-steps/SKILL.md`; the steps of a pending transition and of a `done` feature, the refusal table keyed by error code, a missing `shade-kit`, a failing `phase next`, repeated warnings, the closing line of a refusal), 2026-11-11 (06-6: a `phase next` result passed by the calling skill replaces the skill's own call, stated once in flow step 3). 2026-11-13 (06-9: `continue` is `null` in `new`, flow step 3), 2026-11-15 (package 08: calls in the form of the running agent), 2026-11-18 (scenario runs: the `featureId` never shortened, the "what happened" line written by the skill itself). AC1 to AC4 implemented; loaded by 06-5, 06-6, and, since 2026-11-13, by every phase skill and by `new`, `discuss`, and `drop` (06-9). | +| Status | Draft, 2026-11-04 (split from package 06), updated 2026-11-08 (implementation: `skills/shade-kit-next-steps/SKILL.md`; the steps of a pending transition and of a `done` feature, the refusal table keyed by error code, a missing `shade-kit`, a failing `phase next`, repeated warnings, the closing line of a refusal), 2026-11-11 (06-6: a `phase next` result passed by the calling skill replaces the skill's own call, stated once in flow step 3). 2026-11-13 (06-9: `continue` is `null` in `new`, flow step 3), 2026-11-15 (package 08: calls in the form of the running agent), 2026-11-18 (scenario runs: the `featureId` never shortened, the "what happened" line written by the skill itself), and 2026-11-22 (refusal rows `engine-outdated` and `skills-outdated` replace the version mismatch row; scenario runs S18 and S19 in [06-1](06-1-engine-version-check.md#scenario-runs)). AC1 to AC4 implemented; loaded by 06-5, 06-6, and, since 2026-11-13, by every phase skill and by `new`, `discuss`, and `drop` (06-9). | | Source | [06 Skill foundation](06-skill-foundation.md) (next-steps message), [phase start analysis](../../research/shade-kit-phase-start-analysis.md) | | Kind | Skill (new general skill) | | Depends on | 06-2 | @@ -43,7 +43,10 @@ Every kit skill that ends, after a refused start, a "no", or the end of its work | Refusal | Options named | |---|---| - | Version mismatch (50 `version-mismatch`, 06-1) or `shade-kit` missing (handshake) | What to update and how, from the message | + | Version mismatch (50 `version-mismatch`, 06-1) or `shade-kit` missing (handshake) | What to update and how, from the message. Replaced on 2026-11-22 (06-1, CLI contract) by the next three rows | + | 54 `engine-outdated` (handshake) | Update the engine (the `shade-kit` dotnet global tool or the self-contained binary), then call the skill again. **Implemented** on 2026-11-22 | + | 55 `skills-outdated` (handshake) | Run `shade-kit integrations install`, start a new agent session so that the agent loads the new skills, then call the skill again. **Implemented** on 2026-11-22 | + | `shade-kit` not found (handshake, no envelope) | Install the engine, make sure it is on `PATH`, then call the skill again. **Implemented** | | 10 `kit-root-not-found` | `shade-kit init` | | 17 `kit-file-write-failed` | Check the named file or folder in `.shadekit/` and its permissions, then call the skill again | | 20–22 (format too new, upgrade needed, invalid file) | Update the engine, run `shade-kit upgrade`, or fix the named file | @@ -59,7 +62,7 @@ Every kit skill that ends, after a refused start, a "no", or the end of its work Rows 17, 47, and the fallback row added on 2026-11-04. **Decided** on 2026-11-04 (rows); the table stays **Proposed** as a whole. - For the refusals 41, 42, and 44 the skill also calls `phase next --json`. For 37, 40, 46, and 20–22 `phase next` fails with the same code, so the options come from the refusal itself (package 04). -- The warnings of `phase start` and `phase next` (for example `gates-defaults-used`, `gate-entry-ignored`, `engine-prerelease-version-mismatch`) are always shown with their message. **Decided** on 2026-11-04. +- The warnings of `phase start` and `phase next` (for example `gates-defaults-used`, `gate-entry-ignored`, `engine-prerelease-version-mismatch`) are always shown with their message. **Decided** on 2026-11-04. The warning `engine-prerelease-version-mismatch` was removed on 2026-11-22 with the `--expect` check (06-1); the rule is unchanged. - The message starts nothing: the human chooses by calling the skill. - **Implemented** in `skills/shade-kit-next-steps/SKILL.md` (2026-11-08). The following decisions came out of the implementation clarification; **Decided** on 2026-11-08 by the user unless marked otherwise: - Pending transition (current phase `awaiting-approval`): the message names the pending step, `/shade-kit-`, and also discarding it and continuing the current phase with `/shade-kit-`. The phase skill asks before it discards anything (resume-pending, 06-5). The second step is taken from `current`, not from the profile. diff --git a/docs/feature-packages/06-5-phase-entry-skill.md b/docs/feature-packages/06-5-phase-entry-skill.md index 1bb2eb7..a678bc3 100644 --- a/docs/feature-packages/06-5-phase-entry-skill.md +++ b/docs/feature-packages/06-5-phase-entry-skill.md @@ -2,7 +2,7 @@ | | | |---|---| -| Status | Implemented (AC1 to AC9), 2026-11-10: `skills/shade-kit-phase-entry/SKILL.md`. Since 2026-11-13 (06-9) the eight phase skills load it as their first step, and step 5 says that the phase skill loads the general skills in the steps that use them. Updated 2026-11-18 (scenario runs: numbered plain questions, the gate check's missing artifacts kept and shown). | +| Status | Implemented (AC1 to AC9), 2026-11-10: `skills/shade-kit-phase-entry/SKILL.md`. Since 2026-11-13 (06-9) the eight phase skills load it as their first step, and step 5 says that the phase skill loads the general skills in the steps that use them. Updated 2026-11-18 (scenario runs: numbered plain questions, the gate check's missing artifacts kept and shown) and 2026-11-22 (the handshake names the CLI contract, `--expect-contract 1`, instead of the kit version; 06-1, 06-2). | | Source | [06 Skill foundation](06-skill-foundation.md) (version handshake, entry protocol), [shade-kit-skills.md](../../research/shade-kit-skills.md), [phase start analysis](../../research/shade-kit-phase-start-analysis.md) | | Kind | Skill (new general skill) | | Depends on | 06-1, 06-3, 06-4 | @@ -27,7 +27,7 @@ A developer starts every phase by calling its skill (for example `/shade-kit-pla ## Functional description -**Implemented** in `skills/shade-kit-phase-entry/SKILL.md` (`metadata.version: 0.7.0`, `0.8.0` since 2026-11-14, 06-2), written with skill-creator and proven by scenario runs (see [acceptance criteria](#acceptance-criteria)). +**Implemented** in `skills/shade-kit-phase-entry/SKILL.md` (`metadata.version: 0.7.0`, `0.8.0` since 2026-11-14, 06-2; no `metadata` block since 2026-11-22), written with skill-creator and proven by scenario runs (see [acceptance criteria](#acceptance-criteria)). ### Input from the calling skill @@ -36,9 +36,9 @@ A developer starts every phase by calling its skill (for example `/shade-kit-pla ### Version handshake -- The skill calls `shade-kit version --json --expect ` with the version stated in the text of its handshake step, as 06-2 sets out; the frontmatter is the source, but the model does not see it (06-1, 06-2). **Decided** on 2026-11-04, the version in the text on 2026-11-06. **Implemented** (`--expect 0.7.0`, with the wording of 06-2). -- The phase skills do not check the version themselves; this check covers them, because all kit skills carry the same version (06-2). **Decided** on 2026-11-04. **Implemented**. -- On a mismatch, or if `shade-kit` is not found, the skill stops before any phase work and ends with the next-steps message (06-3), which names what to update and how. A warning `engine-prerelease-version-mismatch` is passed on like every warning, and the skill continues. **Implemented**. +- The skill calls `shade-kit version --json --expect ` with the version stated in the text of its handshake step, as 06-2 sets out; the frontmatter is the source, but the model does not see it (06-1, 06-2). **Decided** on 2026-11-04, the version in the text on 2026-11-06. **Implemented** (`--expect 0.7.0`, with the wording of 06-2). Replaced on 2026-11-22 (06-1, 06-2; CLI contract): the skill calls `shade-kit version --json --expect-contract 1` with the handshake sentence of 06-2 ("1 is the CLI contract this skill is written for"). **Implemented**. +- The phase skills do not check the version themselves; this check covers them, because all kit skills carry the same version (06-2). **Decided** on 2026-11-04. **Implemented**. Since 2026-11-22: because all kit skills are written for the same CLI contract. +- On a mismatch, or if `shade-kit` is not found, the skill stops before any phase work and ends with the next-steps message (06-3), which names what to update and how. A warning `engine-prerelease-version-mismatch` is passed on like every warning, and the skill continues. **Implemented**. Replaced on 2026-11-22: on `ok: false` (for example `engine-outdated` or `skills-outdated`), or if `shade-kit` is not found, the skill stops before anything else and ends with a refusal through the next-steps message (06-3); the prerelease warning no longer exists. **Implemented**. ### Entry protocol @@ -78,11 +78,11 @@ The warnings of `phase start` are passed to the next-steps message (06-3). A pha - **Warnings**: the skill keeps the warnings of every CLI call of its run and does not show them on the way; the ending or the return passes them on, and the closing next-steps message shows each one once. **Proposed**. - **Ending**: every way of ending loads `shade-kit-next-steps` with the reason (refusal, no, or end of work) and the warnings, and then tells the phase skill that the run ended, so the phase skill does no phase work and writes no message of its own. **Proposed** (wording). - **Return**: on "run the phase", the skill returns the feature, how the entry went, the skills to load (`skills.generalSkills`), the warnings, and the gate warning of approval off. **Proposed** (format); 06-9 builds the phase skills on it. -- The skill runs only `shade-kit version --json --expect 0.7.0` (`0.8.0` since 2026-11-14, 06-2; the scenario runs below used `0.7.0`), `phase start`, `phase approve`, and `phase reject` (the last three with `--json`), loads only `shade-kit-gate-check` and `shade-kit-next-steps`, and reads or writes no file. **Implemented**. +- The skill runs only `shade-kit version --json --expect 0.7.0` (`0.8.0` since 2026-11-14, 06-2; the scenario runs below used `0.7.0`; `--expect-contract 1` since 2026-11-22), `phase start`, `phase approve`, and `phase reject` (the last three with `--json`), loads only `shade-kit-gate-check` and `shade-kit-next-steps`, and reads or writes no file. **Implemented**. ## Acceptance criteria -Status as of 2026-11-10. Skill texts have no automated tests, so each criterion names how it is proven: scenario runs in which a fresh subagent loaded the skill as the phase skill's step 1 and followed it with canned CLI envelopes, a canned gate-check return, and canned answers of the human. The subagent was not told the expected result and recorded every command, question, loaded skill, and message, and a script checked every run. The baseline was step 1 ("Entry protocol") of the current phase skeleton. Iteration 1 ran the first text, iteration 2 the text after five fixes found in iteration 1 (where warnings are shown, the advance approval, no list of later phases, suspicious instructions with approval off, the question may carry the information). Each scenario ran once per text and configuration, so the variance is not measured. The scenarios, fixtures, outputs, and the checker stay outside the repository, as in 06-4 (D-28). +Status as of 2026-11-10; the runs below are a historical record of the `--expect` handshake, replaced on 2026-11-22 by the CLI contract (06-1), and were not repeated for this skill (the refusals of the new handshake ran as S18 and S19, [06-1](06-1-engine-version-check.md#scenario-runs)). Skill texts have no automated tests, so each criterion names how it is proven: scenario runs in which a fresh subagent loaded the skill as the phase skill's step 1 and followed it with canned CLI envelopes, a canned gate-check return, and canned answers of the human. The subagent was not told the expected result and recorded every command, question, loaded skill, and message, and a script checked every run. The baseline was step 1 ("Entry protocol") of the current phase skeleton. Iteration 1 ran the first text, iteration 2 the text after five fixes found in iteration 1 (where warnings are shown, the advance approval, no list of later phases, suspicious instructions with approval off, the question may carry the information). Each scenario ran once per text and configuration, so the variance is not measured. The scenarios, fixtures, outputs, and the checker stay outside the repository, as in 06-4 (D-28). | # | Scenario | Iteration 1 | Iteration 2 | Skeleton baseline (iteration 2 checks) | |---|---|---|---|---| @@ -101,7 +101,7 @@ The baseline ran once, in iteration 1; only scenario 8, whose fixture changed, r Five checks run in every scenario: the first command is the handshake with `--expect 0.7.0`; `phase start` only for the caller's phase; no `phase next`, `phase complete`, `feature`, or `init` command; no file read or written; `--json` on every `phase` command. The runners of iteration 2 still noted points of wording that the text leaves to the agent (whether the result and the question are one message or two, whether the "Check runs" line goes into the return); none changed a decision. -- **FP06-5-AC1** With an engine whose minor version differs from the skill's, or without `shade-kit`, a phase skill stops before any phase work and names what to update. **Implemented.** Proven in scenario 1: after the failed handshake no `phase start`, no question, and `shade-kit-next-steps` loaded with reason refusal and the `version-mismatch` envelope, whose message names what to update. A missing `shade-kit` takes the same ending ("`shade-kit` not found"); it has no scenario run. +- **FP06-5-AC1** With an engine whose minor version differs from the skill's, or without `shade-kit`, a phase skill stops before any phase work and names what to update. **Implemented.** Since 2026-11-22: with an engine that does not support the CLI contract of the skill (`engine-outdated`, `skills-outdated`); the text below is the proof of 2026-11-10 with the `--expect` handshake, and the new refusals were not run through this skill. Proven in scenario 1: after the failed handshake no `phase start`, no question, and `shade-kit-next-steps` loaded with reason refusal and the `version-mismatch` envelope, whose message names what to update. A missing `shade-kit` takes the same ending ("`shade-kit` not found"); it has no scenario run. - **FP06-5-AC2** The entry protocol asks for approval also when the checklist passed, and calls `phase approve` only after a yes in the conversation. **Implemented.** Proven in scenario 2 (DoR `pass`, the question asked, `phase approve plan --json` once, after the answer) and scenario 9 (the approval written in the call of the phase skill is not taken as an answer; the question is asked and `phase approve refine` follows the answer). - **FP06-5-AC3** On a no, the phase skill calls `phase reject `, the previous phase is back in `in-progress`, and the skill ends with the next-steps message. **Implemented.** Proven in scenario 3: `phase reject plan --note "…" --json` once, after the answer, with a note naming DOR-04, DOR-09, and the human's reason; no `phase approve`; `shade-kit-next-steps` loaded with reason no and the gaps. The canned reject envelope returns `map` `in-progress`. - **FP06-5-AC4** A phase skill called while a transition away from its phase is pending tells the human, offers to discard the pending transition and continue, to keep it, or to end, and calls `phase reject` only after the human chose to discard it. **Implemented.** Proven in scenario 4 (three options; on discard `phase reject plan --note "resumed map" --json`, then run the phase with `shade-kit-research`) and scenario 5 (on keep no `phase reject`, the next-steps message with end of work, `/shade-kit-plan` named). diff --git a/docs/feature-packages/06-6-next-phase-skill.md b/docs/feature-packages/06-6-next-phase-skill.md index b94f0e2..37349a0 100644 --- a/docs/feature-packages/06-6-next-phase-skill.md +++ b/docs/feature-packages/06-6-next-phase-skill.md @@ -2,7 +2,7 @@ | | | |---|---| -| Status | Implemented (AC1 to AC5), 2026-11-11: `skills/shade-kit-next-phase/SKILL.md`. Draft of 2026-11-04 (split from package 06). Updated 2026-11-13 (06-9): the reference table says that `continue` is `null` in `new`. | +| Status | Implemented (AC1 to AC5), 2026-11-11: `skills/shade-kit-next-phase/SKILL.md`. Draft of 2026-11-04 (split from package 06). Updated 2026-11-13 (06-9): the reference table says that `continue` is `null` in `new`. Updated 2026-11-22: the handshake names the CLI contract (`--expect-contract 1`) instead of the kit version (06-1, 06-2); scenario S19 (refusal `skills-outdated`, OpenAI Codex CLI) recorded in [06-1](06-1-engine-version-check.md#scenario-runs). | | Source | [06 Skill foundation](06-skill-foundation.md) (`shade-kit-next-phase`), [phase start analysis](../../research/shade-kit-phase-start-analysis.md) | | Kind | Skill (skeleton worked out) | | Depends on | 06-1, 06-3 | @@ -26,7 +26,7 @@ When the developer does not know where a feature stands, `shade-kit-next-phase` Shows the human where a feature stands and which skill to call next. It is advisory: it starts no phase skill, never runs a gate check, and never calls `phase start`, `phase approve`, or `phase reject`. **Decided** on 2026-10-30 ([phase start analysis](../../research/shade-kit-phase-start-analysis.md)), replacing "starts the phase skill the human chooses" from the skills interview on 2026-10-17. **Implemented**. -1. Version handshake: `shade-kit version --json --expect ` with the version stated in the text of the step, as 06-2 sets out; the frontmatter is the source, but the model does not see it (06-1, 06-2). **Decided** on 2026-11-04, the version in the text on 2026-11-06. On a mismatch, or if `shade-kit` is not found, end with the next-steps message (06-3). **Implemented** (`--expect 0.7.0`, the same wording as `shade-kit-phase-entry`). +1. Version handshake: `shade-kit version --json --expect ` with the version stated in the text of the step, as 06-2 sets out; the frontmatter is the source, but the model does not see it (06-1, 06-2). **Decided** on 2026-11-04, the version in the text on 2026-11-06. On a mismatch, or if `shade-kit` is not found, end with the next-steps message (06-3). **Implemented** (`--expect 0.7.0`, the same wording as `shade-kit-phase-entry`). Replaced on 2026-11-22 (06-1, 06-2; CLI contract): `shade-kit version --json --expect-contract 1` with the handshake sentence of 06-2; on `ok: false` (for example `engine-outdated` or `skills-outdated`), or if `shade-kit` is not found, stop before any other CLI call and end with a refusal through the next-steps message. **Implemented**. 2. `shade-kit feature current --json`. If not resolved: list the features (`feature list --json`) and ask which one to use; after the human picks one, the skill may call `feature set `, which starts no phase. Otherwise name `/shade-kit-new` and end. **Implemented**. 3. `shade-kit phase next --json` (package 04). The skill does not derive the steps from the profile. **Implemented**. @@ -53,11 +53,11 @@ Only `pending` and `forward` have a gate. - **The "what happened" line** passed to `shade-kit-next-steps` is "Status of ``.", plus, where it applies, that `` is now the current feature (after `feature set`), the line about another feature, and that an approval or phase start asked for in the call is not recorded and the phase skill asks for it. The last one was added after iteration 1: a runner noted that a human who approved in the call may believe the transition went through. **Proposed**. - **Warnings**: the skill keeps the warnings of every CLI call and passes them on; the closing message shows each one once. **Proposed** (as in 06-5). - **The passed `phase next` result in `shade-kit-next-steps`** (06-3): its input section said to use a passed result, while its flow steps 1 and 2 said to run `phase next`. Runners of three scenarios noted the contradiction, though all followed the input section. Flow step 3 of `shade-kit-next-steps` now states the rule once (use a passed result, otherwise run `phase next` once), and steps 1 and 2 refer to it. **Decided** on 2026-11-11. **Implemented**; proven in iteration 3 (below). -- The skill runs only `shade-kit version --json --expect 0.7.0` (`0.8.0` since 2026-11-14, 06-2; the scenario runs below used `0.7.0`), `feature current`, `feature list`, `feature set ` (only after the human picked that feature), and `phase next`, each with `--json`; loads only `shade-kit-next-steps`; reads or writes no file. **Implemented**. +- The skill runs only `shade-kit version --json --expect 0.7.0` (`0.8.0` since 2026-11-14, 06-2; the scenario runs below used `0.7.0`; `--expect-contract 1` since 2026-11-22), `feature current`, `feature list`, `feature set ` (only after the human picked that feature), and `phase next`, each with `--json`; loads only `shade-kit-next-steps`; reads or writes no file. **Implemented**. ## Acceptance criteria -Status as of 2026-11-11. Skill texts have no automated tests, so each criterion names how it is proven: scenario runs in which a fresh subagent loaded the skill as if the human had called it, and followed it and `shade-kit-next-steps` with canned CLI envelopes and canned answers of the human. The subagent was not told the expected result and recorded every command, question, loaded skill, and its closing message, and a script checked every run. The baseline was the skeleton of the skill. Iteration 1 ran the first text, iteration 2 the text after three fixes found in iteration 1 (an approval in the call is not recorded and the message says so; the message says when `feature set` changed the current feature; the branch is named by its `/` ending). Each scenario ran once per text and configuration, so the variance is not measured. The scenarios, fixtures, outputs, and the checker stay outside the repository, as in 06-4 (D-28). +Status as of 2026-11-11; the runs below are a historical record of the `--expect` handshake, replaced on 2026-11-22 by the CLI contract (06-1). The refusal `skills-outdated` of the new handshake ran on 2026-11-22 as S19 with this skill, played as OpenAI Codex CLI ([06-1](06-1-engine-version-check.md#scenario-runs)). Skill texts have no automated tests, so each criterion names how it is proven: scenario runs in which a fresh subagent loaded the skill as if the human had called it, and followed it and `shade-kit-next-steps` with canned CLI envelopes and canned answers of the human. The subagent was not told the expected result and recorded every command, question, loaded skill, and its closing message, and a script checked every run. The baseline was the skeleton of the skill. Iteration 1 ran the first text, iteration 2 the text after three fixes found in iteration 1 (an approval in the call is not recorded and the message says so; the message says when `feature set` changed the current feature; the branch is named by its `/` ending). Each scenario ran once per text and configuration, so the variance is not measured. The scenarios, fixtures, outputs, and the checker stay outside the repository, as in 06-4 (D-28). | # | Scenario | Iteration 1 | Iteration 2 | Skeleton baseline (iteration 2 checks) | |---|---|---|---|---| @@ -77,7 +77,7 @@ Iteration 3 ran after the change to flow step 3 of `shade-kit-next-steps` (decis Six checks run in every scenario: the first command is the handshake with `--expect 0.7.0`; `--json` on every command; no `phase start`, `phase approve`, `phase reject`, `phase complete`, `gate info`, `feature new`, `feature drop`, or `init`; no file read or written; `shade-kit-next-steps` loaded; neither `shade-kit-gate-check` nor a phase skill loaded. The runners of iteration 2 still noted points of wording that the text leaves to the agent (where the added sentences go in the "what happened" line, whether to suggest calling the skill again after switching the branch); none changed a decision. -- **FP06-6-AC1** With an engine whose minor version differs from the skill's, or without `shade-kit`, the skill stops before any other CLI call and names what to update. **Implemented.** Proven in scenario 1: only `shade-kit version --json --expect 0.7.0` ran, `shade-kit-next-steps` was loaded with reason refusal and the `version-mismatch` envelope, and the message names the update to 0.7. A missing `shade-kit` takes the same ending ("`shade-kit` not found"); it has no scenario run. +- **FP06-6-AC1** With an engine whose minor version differs from the skill's, or without `shade-kit`, the skill stops before any other CLI call and names what to update. **Implemented.** Since 2026-11-22: with an engine that does not support the CLI contract of the skill; proven for `skills-outdated` by S19 (06-1: one CLI call, no question, refusal through `shade-kit-next-steps` with `shade-kit integrations install` and a new session). The text below is the proof of 2026-11-11 with the `--expect` handshake. Proven in scenario 1: only `shade-kit version --json --expect 0.7.0` ran, `shade-kit-next-steps` was loaded with reason refusal and the `version-mismatch` envelope, and the message names the update to 0.7. A missing `shade-kit` takes the same ending ("`shade-kit` not found"); it has no scenario run. - **FP06-6-AC2** With no resolvable current feature, the skill lists the features and names `/shade-kit-new`; it starts no skill. **Implemented.** Proven in scenarios 3, 4, and 7: `feature list --json` after the unresolved `feature current`; in 3 and 4 one question with both active features, the new feature, and no pick (in 3 the named feature first), never the done feature; in 4 and 7 no `feature set`, no skill but `shade-kit-next-steps` loaded, and `/shade-kit-new` in the message; in 7 no question. - **FP06-6-AC3** For a feature whose current phase is `in-progress`, the skill names the phase skill of the current phase. **Implemented.** Proven in scenarios 2 (`/shade-kit-map`), 3 (`/shade-kit-diagnose`, after `feature set gh-150-fix-crash --json`), and 6 (`/shade-kit-map` of the branch's feature). - **FP06-6-AC4** The skill never runs a gate check and never calls `phase approve`. **Implemented.** Proven in all eight scenarios (common checks), including scenario 5, where the human approved in the call: no `phase approve`, no question, and the message says that the approval is not recorded and `/shade-kit-plan` asks for it. diff --git a/docs/feature-packages/06-9-skill-skeleton-alignment.md b/docs/feature-packages/06-9-skill-skeleton-alignment.md index 96c43d1..93df74f 100644 --- a/docs/feature-packages/06-9-skill-skeleton-alignment.md +++ b/docs/feature-packages/06-9-skill-skeleton-alignment.md @@ -2,7 +2,7 @@ | | | |---|---| -| Status | Draft, 2026-11-04 (split from package 06), updated 2026-11-13 (implementation: the eight phase skills load `shade-kit-phase-entry` and `shade-kit-next-steps`; `new`, `discuss`, and `drop` run the handshake with `--expect 0.7.0` and end with `shade-kit-next-steps`; `phase next` returns no `continue` step in `new`; the planned-commands sentence removed from 12 skeletons). AC1 to AC8 implemented. | +| Status | Draft, 2026-11-04 (split from package 06), updated 2026-11-13 (implementation: the eight phase skills load `shade-kit-phase-entry` and `shade-kit-next-steps`; `new`, `discuss`, and `drop` run the handshake with `--expect 0.7.0` and end with `shade-kit-next-steps`; `phase next` returns no `continue` step in `new`; the planned-commands sentence removed from 12 skeletons), and 2026-11-22 (the handshake of `new`, `discuss`, and `drop` names the CLI contract, `--expect-contract 1`; 06-1, 06-2; scenario S18 of `new` recorded in [06-1](06-1-engine-version-check.md#scenario-runs)). AC1 to AC8 implemented. | | Source | [06 Skill foundation](06-skill-foundation.md), open points in [README](README.md#open-questions) (skill skeletons not aligned with the built `phase` commands) | | Kind | Cross-cutting (all skill skeletons), with one engine change (`WorkflowPhase.CanContinue`, package 04) | | Depends on | 06-3, 06-5, 06-6 | @@ -43,7 +43,7 @@ Every skill the human calls is gated and ends the same way before its phase is w ### `new`, `discuss`, `drop` -- Step 1 is the version handshake with the version stated in the text of the step, as 06-2 sets out (the frontmatter is the source, but the model does not see it): `shade-kit version --json --expect ` (06-1, 06-2). **Decided** on 2026-11-04, the version in the text on 2026-11-06. **Implemented** (`--expect 0.7.0`, with the same text as the handshake step of `shade-kit-next-phase`). +- Step 1 is the version handshake with the version stated in the text of the step, as 06-2 sets out (the frontmatter is the source, but the model does not see it): `shade-kit version --json --expect ` (06-1, 06-2). **Decided** on 2026-11-04, the version in the text on 2026-11-06. **Implemented** (`--expect 0.7.0`, with the same text as the handshake step of `shade-kit-next-phase`). Replaced on 2026-11-22 (06-1, 06-2; CLI contract): step 1 runs `shade-kit version --json --expect-contract 1` with the handshake sentence of 06-2; on `ok: false` (for example `engine-outdated` or `skills-outdated`), or if `shade-kit` is not found, the skill stops before any other CLI call and ends with a refusal. **Implemented**. - The last step loads `shade-kit-next-steps` (06-3). **Implemented**: every way of ending, a failed CLI call included, loads it with **refusal** or **end of work**. - A failure envelope of `feature current` ends `discuss` with **refusal** before the discussion (for example `kit-root-not-found`, because the notes live in `.shadekit/`), and `new` likewise. **Decided** on 2026-11-13. - The descriptions of `discuss` and `drop` also say that they run only when the user calls them by name or asks for them. **Decided** on 2026-11-13. @@ -66,7 +66,7 @@ All skill texts under `skills/` are reviewed by hand against the conventions of ## Acceptance criteria -Status as of 2026-11-13. There are no automated tests of the skill texts (06-2), so each criterion names how it is proven: the review by hand above and scenario runs. In each run a subagent loads the skill from a skills folder, follows it with canned CLI envelopes and canned answers, and records every command, skill load, question, read, write, and message as a timeline; a script checks the timelines. The baseline is the skeletons before this change. The scenarios, timelines, and script were kept outside the repository. +Status as of 2026-11-13; the runs below are a historical record of the `--expect` handshake (scenarios 7 and 10 test its mismatch and its prerelease warning), replaced on 2026-11-22 by the CLI contract (06-1). The refusal `engine-outdated` of the new handshake ran on 2026-11-22 as S18 with `new`, played as Claude Code ([06-1](06-1-engine-version-check.md#scenario-runs)). There are no automated tests of the skill texts (06-2), so each criterion names how it is proven: the review by hand above and scenario runs. In each run a subagent loads the skill from a skills folder, follows it with canned CLI envelopes and canned answers, and records every command, skill load, question, read, write, and message as a timeline; a script checks the timelines. The baseline is the skeletons before this change. The scenarios, timelines, and script were kept outside the repository. | # | Scenario | New text, iteration 1 | Iteration 2 | Skeletons (baseline) | |---|---|---|---|---| @@ -93,7 +93,7 @@ Checks in every scenario: the first `shade-kit` command is the handshake with `- - **FP06-9-AC4** The description of every phase skill says that it runs only when the user calls it by name. **Implemented.** Proven by the review by hand (all eight descriptions, and those of `new`, `discuss`, and `drop`). - **FP06-9-AC5** No kit skill writes a kit JSON file directly; a review of the skill texts finds only CLI calls for state changes. **Implemented.** Proven by the review by hand and in all scenarios (common check). - **FP06-9-AC6** For a feature whose current phase is `in-progress`, the phase skill of that phase, called by the human, runs no gate. **Implemented.** Proven in scenario 3: `shade-kit-gate-check` not loaded, no `phase approve` or `phase reject`, the continue question before any read (the entry protocol of 06-5; FP06-5-AC7). -- **FP06-9-AC7** `new`, `discuss`, and `drop` stop before any other work when the engine's minor version differs from their own, and end with the next-steps message. **Implemented.** Proven in scenario 7 (no further command, no question, the message names what to update); scenarios 8 to 11 run the handshake first; scenario 10 shows the prerelease warning in the closing message. `discuss` and `drop` take the same handshake text; their mismatch has no scenario run. +- **FP06-9-AC7** `new`, `discuss`, and `drop` stop before any other work when the engine's minor version differs from their own, and end with the next-steps message. **Implemented.** Proven in scenario 7 (no further command, no question, the message names what to update); scenarios 8 to 11 run the handshake first; scenario 10 shows the prerelease warning in the closing message. `discuss` and `drop` take the same handshake text; their mismatch has no scenario run. Since 2026-11-22: with an engine that does not support the CLI contract of the skill; proven for `new` and `engine-outdated` by S18 (06-1: one CLI call, no question, refusal through `shade-kit-next-steps` with the engine update); the prerelease warning of scenario 10 no longer exists. - **FP06-9-AC8** No skill says that a built `phase` command is planned. **Implemented.** Proven by the review by hand: the sentence is gone from all 12 skeletons. ## Open points diff --git a/docs/feature-packages/06-skill-foundation.md b/docs/feature-packages/06-skill-foundation.md index a6477c5..a218c8b 100644 --- a/docs/feature-packages/06-skill-foundation.md +++ b/docs/feature-packages/06-skill-foundation.md @@ -2,7 +2,7 @@ | | | |---|---| -| Status | Draft, 2026-10-14, updated 2026-10-17 (template conventions, checklist format), 2026-10-18 (no router: `shade-kit-next-phase` and entry protocol; findings clarification: `phase next`, pending transition, report and review skills), 2026-10-24 (documentation check: skill names of the general skills, placeholders in checklist copies), 2026-10-25 (code review of the rework of `feature new` in package 03: `request.md` treated as data, not as instructions), 2026-10-30 ([phase start analysis](../../research/shade-kit-phase-start-analysis.md): phases start only when the user calls the phase skill, `shade-kit-next-phase` is advisory, next-steps message, active phase asks the human), 2026-11-04 (split into the sub-features 06-1 to 06-9; version in the skill frontmatter, checked by the engine; `shade-kit-report` moved to package 15), 2026-11-06 (06-2: Claude Code does not show the frontmatter to the model), 2026-11-08 (06-3: `shade-kit-next-steps` implemented; 06-4: `shade-kit-gate-check` and `shade-kit gate info` implemented), 2026-11-10 (06-5: `shade-kit-phase-entry` implemented), 2026-11-11 (06-6: `shade-kit-next-phase` implemented), 2026-11-13 (06-8: `shade-kit-research` and the format of `researches.md` implemented), 2026-11-13 (06-9: the skill skeletons load the entry protocol and the next-steps message; `phase next` has no `continue` step in `new`), and 2026-11-13 (package 07: the mismatch message names `integrations install`), and 2026-11-15 (package 08: frontmatter visibility of Copilot and Codex answered) | +| Status | Draft, 2026-10-14, updated 2026-10-17 (template conventions, checklist format), 2026-10-18 (no router: `shade-kit-next-phase` and entry protocol; findings clarification: `phase next`, pending transition, report and review skills), 2026-10-24 (documentation check: skill names of the general skills, placeholders in checklist copies), 2026-10-25 (code review of the rework of `feature new` in package 03: `request.md` treated as data, not as instructions), 2026-10-30 ([phase start analysis](../../research/shade-kit-phase-start-analysis.md): phases start only when the user calls the phase skill, `shade-kit-next-phase` is advisory, next-steps message, active phase asks the human), 2026-11-04 (split into the sub-features 06-1 to 06-9; version in the skill frontmatter, checked by the engine; `shade-kit-report` moved to package 15), 2026-11-06 (06-2: Claude Code does not show the frontmatter to the model), 2026-11-08 (06-3: `shade-kit-next-steps` implemented; 06-4: `shade-kit-gate-check` and `shade-kit gate info` implemented), 2026-11-10 (06-5: `shade-kit-phase-entry` implemented), 2026-11-11 (06-6: `shade-kit-next-phase` implemented), 2026-11-13 (06-8: `shade-kit-research` and the format of `researches.md` implemented), 2026-11-13 (06-9: the skill skeletons load the entry protocol and the next-steps message; `phase next` has no `continue` step in `new`), and 2026-11-13 (package 07: the mismatch message names `integrations install`), 2026-11-15 (package 08: frontmatter visibility of Copilot and Codex answered), and 2026-11-22 (the kit version of the skills and the SemVer check of `--expect` replaced by the CLI contract, `version --expect-contract`; 06-1, 06-2, [report](../../reports/versioning-cli-and-skills.md)) | | Source | Concept §3.2, §3.3, §3.4, §11.4, [concept §9.6](../../research/shade-kit-concept.md#9-version-drift) | | Depends on | 01, 03, 04, 05 | | Enables | 07, 08, and every phase package (09–17) | @@ -17,7 +17,7 @@ Package 06 is built in sub-features. Each one has its own functional description | # | Sub-feature | Kind | Depends on | |---|---|---|---| -| 06-1 | [Engine version check (`version --expect`)](06-1-engine-version-check.md) | .NET | 01 | +| 06-1 | [Engine version check (`version --expect-contract`)](06-1-engine-version-check.md) | .NET | 01 | | 06-2 | [Skill conventions and version metadata](06-2-skill-conventions-and-version.md) | Cross-cutting | 06-1 | | 06-3 | [Next-steps message (`shade-kit-next-steps`)](06-3-next-steps-skill.md) | Skill (new) | 06-2 | | 06-4 | [Checklist check (`shade-kit-gate-check`)](06-4-gate-check-skill.md) | Skill and CLI command (`gate info`) | 05, 06-2 | @@ -31,7 +31,7 @@ Package 06 is built in sub-features. Each one has its own functional description ### In scope -- Conventions every kit skill follows, and the kit version of every skill (06-2). +- Conventions every kit skill follows, and the kit version of every skill (06-2; since 2026-11-22 the CLI contract in the handshake text instead). - The version handshake: the check in the engine (06-1) and its calls in the skills (06-5, 06-6, 06-9). - The entry protocol every phase skill runs (06-5). - The next-steps message every skill ends with (06-3). @@ -49,13 +49,13 @@ Package 06 is built in sub-features. Each one has its own functional description ## Decisions of 2026-11-04 -- The kit version of a skill is hardcoded in its frontmatter as `metadata.version` and committed, because the skills must be installable as a plugin with their version included. Every skill carries it, all with the same value (06-2). -- The engine compares: `shade-kit version --json --expect `. Major and minor must be equal, patch may differ; a prerelease engine only warns on a mismatch (06-1). New exit code range 50–59 with `50 version-mismatch`. +- The kit version of a skill is hardcoded in its frontmatter as `metadata.version` and committed, because the skills must be installable as a plugin with their version included. Every skill carries it, all with the same value (06-2). Replaced on 2026-11-22 ([report](../../reports/versioning-cli-and-skills.md); the hand-kept product version tied every skill change to a product minor): no skill carries a version; the handshake text names the CLI contract the skill is written for (06-2). +- The engine compares: `shade-kit version --json --expect `. Major and minor must be equal, patch may differ; a prerelease engine only warns on a mismatch (06-1). New exit code range 50–59 with `50 version-mismatch`. Replaced on 2026-11-22: the engine checks `shade-kit version --json --expect-contract ` against its window `CliContract.MinSupported` to `CliContract.Current`, with no prerelease leniency; outside it `54 engine-outdated` or `55 skills-outdated` (06-1). The range 50–59 stays. - The handshake runs in `shade-kit-phase-entry` for the phase skills, and in `shade-kit-next-phase`, `new`, `discuss`, and `drop` with their own call. General skills that are only loaded by another skill do not check (wording of 2026-11-04; clarified on 2026-11-06, 06-2: except `shade-kit-phase-entry`, which checks for the phase skills). FP06-AC1 ("every kit skill stops") therefore holds for every skill the human calls. - The entry protocol and the next-steps message are general skills of their own (`shade-kit-phase-entry`, `shade-kit-next-steps`). - `shade-kit-research` runs one general subagent per focus with the instructions of the calling skill; no research agent definitions. - The skill texts are checked by a review by hand; no automated tests of the skill texts. -- **Decided** from **Proposed**: skills never write kit JSON directly; every artifact starts from the repository's template; the match rule of the version handshake; the merge rule of `researches.md`. +- **Decided** from **Proposed**: skills never write kit JSON directly; every artifact starts from the repository's template; the match rule of the version handshake (replaced on 2026-11-22 by the window rule, 06-1); the merge rule of `researches.md`. - The refusal table gets rows for 17 and 47 and a fallback row; warnings of `phase start` and `phase next` are always shown (06-3). - FP06-AC13 (no references to `research/` or `docs/` in shipped skills) is checked when the skills are shipped, as FP07-AC7. @@ -98,8 +98,8 @@ The acceptance criteria are in the sub-features. The former criteria of this pac ## Open points -- **Alignment of the skill version with GitVersion skipped for now** (06-2). -- Frontmatter visibility: Claude Code 2.1.318 does not show the frontmatter to the model (checked on 2026-11-06 in 06-2, on project-level skills), so the handshake step states the version in its text. Answered for Copilot and Codex on 2026-11-15 from documentation and source (package 08): Copilot does not show the frontmatter, Codex shows the whole `SKILL.md`; both ignore `metadata.version`, so the version in the handshake text serves all three agents. -- The mismatch message of 06-1 named updating the skills by hand until package 07 built the `integrations` commands; since 2026-11-13 it names `shade-kit integrations install` (06-1). +- **Alignment of the skill version with GitVersion skipped for now** (06-2). Answered on 2026-11-22: the skills carry no product version, so there is nothing to align; the guard `SkillContractTests` does not depend on GitVersion (06-2). +- Frontmatter visibility: Claude Code 2.1.318 does not show the frontmatter to the model (checked on 2026-11-06 in 06-2, on project-level skills), so the handshake step states the version in its text. Answered for Copilot and Codex on 2026-11-15 from documentation and source (package 08): Copilot does not show the frontmatter, Codex shows the whole `SKILL.md`; both ignore `metadata.version`, so the version in the handshake text serves all three agents. Since 2026-11-22 the handshake text names the CLI contract, and the skills have no `metadata` block (06-2). +- The mismatch message of 06-1 named updating the skills by hand until package 07 built the `integrations` commands; since 2026-11-13 it names `shade-kit integrations install` (06-1). Replaced on 2026-11-22: the `skills-outdated` message names `shade-kit integrations install` (06-1). - Exact skill names (concept open question 6). - Phase skills are restricted to user invocation only by convention (06-2); a technical restriction is a possible later addition. diff --git a/docs/feature-packages/07-claude-code-integration.md b/docs/feature-packages/07-claude-code-integration.md index 2e5b280..45ce7d8 100644 --- a/docs/feature-packages/07-claude-code-integration.md +++ b/docs/feature-packages/07-claude-code-integration.md @@ -2,7 +2,7 @@ | | | |---|---| -| Status | Draft, 2026-10-14, updated 2026-10-18 (consistency review: router references replaced by `shade-kit-next-phase`), 2026-11-04 (split of package 06: FP07-AC7 taken over from FP06-AC13), and 2026-11-13 (implementation: this repository is the Claude Code plugin marketplace `creativecoders-shade-kit`, the version pin by tag, no engine-owned record, `integrations install` and `integrations update`, `integrations` in `version --json`, exit codes 51–53, warning codes `integration-prerelease-ref` and `agent-unavailable`, skeleton source comments removed, namespacing checked in a smoke check), and 2026-11-13 (Gate 4 rework: release-tag check with `git ls-remote` and warning `integration-release-tag-missing`, `version` asks only detected agents, `update` with nothing installed resolves no source, the 06-1 message names `integrations install`, `git` never prompts), and 2026-11-14 (review rework, Gate 5, see [Review](#review): skills raised to the kit version `0.8.0` and guarded by `SkillKitVersionTests`, the FP07-AC7 guard scans every text file under `skills/`, a kept marketplace is refreshed with `claude plugin marketplace update`, a cancellation during the switch names the repair, `--agent claude` without `claude` fails before the tag check, `update` reads the state once per agent, completed agents are named when a later agent fails, URL forms of `SHADE_KIT_MARKETPLACE_SOURCE` are refused, directory sources are compared after resolving symbolic links), and 2026-11-15 (second review rework, Gate 5 round 2, see [Review](#review): a stray stdout line fails `install` and `update` with 52 but gives `agent-unavailable` in `version`, the kit version guard reports the outlier skill, the minimum Claude Code version for `marketplace update --json` recorded as an accepted open point), and 2026-11-15 (package 08: GitHub Copilot CLI and OpenAI Codex CLI are registered after Claude Code, so `--agent` takes three ids and the order of several agents applies; the marketplace decision moved unchanged into the shared `MarketplaceChangeResolver`; `IntegrationConflictException.ResolveCommands` replaces `ResolveCommand`; the plugin-root rule extended to the default locations of Copilot). Implemented; FP07-AC1 checked by hand in a headless session; FP07-AC2 enforced by a guard test. | +| Status | Draft, 2026-10-14, updated 2026-10-18 (consistency review: router references replaced by `shade-kit-next-phase`), 2026-11-04 (split of package 06: FP07-AC7 taken over from FP06-AC13), and 2026-11-13 (implementation: this repository is the Claude Code plugin marketplace `creativecoders-shade-kit`, the version pin by tag, no engine-owned record, `integrations install` and `integrations update`, `integrations` in `version --json`, exit codes 51–53, warning codes `integration-prerelease-ref` and `agent-unavailable`, skeleton source comments removed, namespacing checked in a smoke check), and 2026-11-13 (Gate 4 rework: release-tag check with `git ls-remote` and warning `integration-release-tag-missing`, `version` asks only detected agents, `update` with nothing installed resolves no source, the 06-1 message names `integrations install`, `git` never prompts), and 2026-11-14 (review rework, Gate 5, see [Review](#review): skills raised to the kit version `0.8.0` and guarded by `SkillKitVersionTests`, the FP07-AC7 guard scans every text file under `skills/`, a kept marketplace is refreshed with `claude plugin marketplace update`, a cancellation during the switch names the repair, `--agent claude` without `claude` fails before the tag check, `update` reads the state once per agent, completed agents are named when a later agent fails, URL forms of `SHADE_KIT_MARKETPLACE_SOURCE` are refused, directory sources are compared after resolving symbolic links), and 2026-11-15 (second review rework, Gate 5 round 2, see [Review](#review): a stray stdout line fails `install` and `update` with 52 but gives `agent-unavailable` in `version`, the kit version guard reports the outlier skill, the minimum Claude Code version for `marketplace update --json` recorded as an accepted open point), and 2026-11-15 (package 08: GitHub Copilot CLI and OpenAI Codex CLI are registered after Claude Code, so `--agent` takes three ids and the order of several agents applies; the marketplace decision moved unchanged into the shared `MarketplaceChangeResolver`; `IntegrationConflictException.ResolveCommands` replaces `ResolveCommand`; the plugin-root rule extended to the default locations of Copilot), and 2026-11-22 (the kit version guard replaced by the CLI contract guard `SkillContractTests`; FP07-AC2 now says that the installed skills lie in the contract window of the installing engine; `version --expect-contract` reads no integrations; [report](../../reports/versioning-cli-and-skills.md)). Implemented; FP07-AC1 checked by hand in a headless session; FP07-AC2 enforced by a guard test. | | Source | Concept §2 (Lifecycle), §3.1 (`integrations install/update`), §3.4, [concept §9.6](../../research/shade-kit-concept.md#9-version-drift); Claude Code plugin and marketplace commands, checked with Claude Code 2.1.323 on 2026-11-13 and 2026-11-14 (`marketplace update`); [review report](../reviews/2026-11-13-feature-claude-code-integration-uncommitted.md), [second review report](../reviews/2026-11-15-feature-claude-code-integration-uncommitted-2.md) | | Depends on | 01, 06 | | Enables | 08 (same mechanism for more agents); end-to-end use of all phase packages in Claude Code | @@ -20,7 +20,7 @@ A developer installs the kit's skills for Claude Code with one command, once per - Where the integration content comes from, and how the engine picks its version. - Reporting installed integrations in `shade-kit version --json` (announced in package 01). - The plugin manifests in `.claude-plugin/`. -- Removing the source comments of the skill skeletons, the guard test of FP07-AC7, and the kit version guard of FP07-AC2 (since 2026-11-14). +- Removing the source comments of the skill skeletons, the guard test of FP07-AC7, and the kit version guard of FP07-AC2 (since 2026-11-14; replaced on 2026-11-22 by the CLI contract guard, [Kit version guard](#kit-version-guard)). ### Out of scope @@ -29,7 +29,7 @@ A developer installs the kit's skills for Claude Code with one command, once per - Writing anything into a repository (concept §9.6, **Decided**). - Removing an integration. `integrations uninstall` is a later addition. **Proposed.** - Installing with a scope other than `user`, and enabling a disabled plugin. -- Writing `metadata.version` into the skills for a release; it is raised by hand, and since 2026-11-14 a guard test checks it ([Kit version guard](#kit-version-guard), 06-2, 19). +- Writing `metadata.version` into the skills for a release; it is raised by hand, and since 2026-11-14 a guard test checks it ([Kit version guard](#kit-version-guard), 06-2, 19). Replaced on 2026-11-22: the skills carry no `metadata.version`; they name the CLI contract, which the release does not change (06-2). ## Functional description @@ -199,12 +199,12 @@ Restart Claude Code to load the skills. ### Version reporting -- `shade-kit version --json` has an always-present field `integrations`, after `expectedVersion`: `[ { "agent": "claude", "pluginId": "shade-kit@creativecoders-shade-kit", "kitVersion": "0.8.0", "ref": "v0.8.0", "enabled": true } ]`, empty when nothing is installed. **Decided** on 2026-11-13 (package 07 implementation). **Implemented** (`VersionCommandData.Integrations`, `VersionCommandIntegrationData`, `IntegrationService.GetInstalledAsync`). -- Plain output: the line `shade-kit ` as before, then one line per installed integration, `claude: shade-kit@creativecoders-shade-kit 0.8.0 (v0.8.0)`, with `(disabled)` for a disabled plugin. -- The integrations are read only after a successful `--expect` check; a mismatch still exits with 50 and starts no `claude`. +- `shade-kit version --json` has an always-present field `integrations`, after `expectedVersion` (replaced on 2026-11-22: after `contract`, and left out when `--expect-contract` is given, 06-1): `[ { "agent": "claude", "pluginId": "shade-kit@creativecoders-shade-kit", "kitVersion": "0.8.0", "ref": "v0.8.0", "enabled": true } ]`, empty when nothing is installed. **Decided** on 2026-11-13 (package 07 implementation). **Implemented** (`VersionCommandData.Integrations`, `VersionCommandIntegrationData`, `IntegrationService.GetInstalledAsync`). +- Plain output: the line `shade-kit ` as before (since 2026-11-22 followed by the line `CLI contract (supported: to )`, 06-1), then one line per installed integration, `claude: shade-kit@creativecoders-shade-kit 0.8.0 (v0.8.0)`, with `(disabled)` for a disabled plugin. +- The integrations are read only after a successful `--expect` check; a mismatch still exits with 50 and starts no `claude`. Replaced on 2026-11-22 (06-1): with `--expect-contract`, `version` never reads the integrations, also on success, so a skill handshake starts no `claude`; without it, `version` reads them as described here. **Implemented** (`VersionCommandTests.ExecuteAsync_ExpectContract_DoesNotReadIntegrationsAndOmitsField`, `IntegrationsCommandsEndToEndTests.Version_ExpectContractMismatchWithInstalledIntegration_Exits54WithoutAskingClaude`). - `version` asks only the agents whose CLI is detected (`IAgentIntegration.IsAvailable()`). **Decided** on 2026-11-13 (package 07 implementation, Gate 4). **Implemented** (`IntegrationService.GetInstalledAsync`). - `version` never fails because of an agent. A missing `claude` gives no warning and an empty `integrations` list. **FACT** (real `version --json` with `PATH=/usr/bin:/bin`: `warnings` `[]`, 2026-11-13). Only a `claude` that is on the `PATH` but cannot be started or fails gives the warning `agent-unavailable`: `The SHADE kit integration of the agent '{agent}' cannot be read, so it is not listed: {reason}`. **Implemented** (`AgentUnavailableWarning`, `CliErrorMapper.MapWarning`; `IntegrationsCommandsEndToEndTests.Version_ClaudeNotOnPath_SucceedsWithEmptyIntegrationsAndNoWarning`, `IntegrationsCommandsEndToEndTests.Version_ClaudeOnPathFails_SucceedsWithEmptyIntegrationsAndAgentUnavailableWarning`). -- Known cost: with `claude` on the `PATH`, every `version` call starts `claude` once or twice (`plugin list`, and `marketplace list` when the plugin is installed), also in each skill handshake. **FACT** (measured on 2026-11-13): `version --json --expect` took 0.73 s with `claude` on the `PATH` and 0.08 s without. +- Known cost: with `claude` on the `PATH`, every `version` call starts `claude` once or twice (`plugin list`, and `marketplace list` when the plugin is installed), also in each skill handshake (since 2026-11-22 not in the handshake: `--expect-contract` reads no integrations, 06-1). **FACT** (measured on 2026-11-13): `version --json --expect` took 0.73 s with `claude` on the `PATH` and 0.08 s without. - `kitVersion` and `ref` are `null` for a directory marketplace and for any ref that is not `v`. ### Exit, error, and warning codes @@ -226,7 +226,7 @@ Warnings: `integration-prerelease-ref` (prerelease engine installs from `main`), - Plugin skills are namespaced as `/:` (Claude Code documentation). The skill texts stay agent-neutral and keep the bare names (`/shade-kit-`, "load `shade-kit-next-steps`"). **Decided** on 2026-11-13 (package 07 implementation). No skill text changed in this package except the removed source comments. - Smoke check on 2026-11-13, Claude Code 2.1.323, headless `claude -p` with the plugin loaded by `--plugin-dir `, `--setting-sources project`, in a scratch directory: - The model's skill listing shows the namespaced name `shade-kit:shade-kit-next-phase`. **FACT.** - - Both `/shade-kit-next-phase` and `/shade-kit:shade-kit-next-phase` expand the skill: the session started its version handshake (`--expect 0.7.0`, the kit version of the skills then; `0.8.0` since 2026-11-14) without a Skill tool call. **FACT.** + - Both `/shade-kit-next-phase` and `/shade-kit:shade-kit-next-phase` expand the skill: the session started its version handshake (`--expect 0.7.0`, the kit version of the skills then; `0.8.0` since 2026-11-14; since 2026-11-22 the handshake is `--expect-contract 1`, not run in this smoke check) without a Skill tool call. **FACT.** - A skill text that says "load `shade-kit-next-steps`" works: the model called the Skill tool with `shade-kit:shade-kit-next-steps`. **FACT.** - Limits: one run per form, headless print mode, plugin loaded with `--plugin-dir`, not from the marketplace install (the same plugin loader). The interactive slash menu is **Unverified**. @@ -237,6 +237,9 @@ Warnings: `integration-prerelease-ref` (prerelease engine installs from `main`), ### Kit version guard +- Since 2026-11-22 the guard of FP07-AC2 is the CLI contract guard `SkillContractTests.SkillFiles_ShippedSkills_NameTheCurrentCliContractEverywhere` (`[Trait("Requirement", "FP07-AC2")]`, in `CreativeCoders.ShadeKit.Core.Tests/Skills/`): every `--expect-contract ` and every "`` is the CLI contract this skill is written for" under `skills/` names `CliContract.Current`, the five handshake skills carry the handshake sentence verbatim, and no `--expect` option and no frontmatter `version:` is left ([06-2](06-2-skill-conventions-and-version.md#cli-contract-in-the-handshake)). It reads only the checked-in files and does not depend on GitVersion. **Decided** on 2026-11-22 ([report](../../reports/versioning-cli-and-skills.md)). **Implemented**. +- The loop that the original guard was built against (a tag with stale skills: every handshake fails, and the hint `shade-kit integrations install` installs the same skills again) stays impossible for a release engine whose tag exists: the test runs in the tag build, so the tree of a release tag carries skills with `R == CliContract.Current` of the engine built from that tree, and that `R` lies in the window of that engine. An engine that installs from `main` (a prerelease engine, or a release engine whose tag does not exist) gets the skills of `main`, whose `R` can lie below its `CliContract.MinSupported`, so the `skills-outdated` hint can repeat once `MinSupported` > 1; this is latent while `MinSupported` = 1. **Decided** on 2026-11-22. +- Replaced on 2026-11-22 (the guard tied the skills to the product version of the build, so its result depended on the branch, the local tags, and `next-version`; see 06-2): the kit version guard below, kept as history. `SkillKitVersionTests` was deleted. - A guard test ties the kit version of the skills to the engine version of the build. **Decided** on 2026-11-14 (package 07 review rework, Gate 5, review finding Major: a release engine installs the skills of its own tag, and if they carry another major.minor, every handshake fails with 50 and the hint `shade-kit integrations install` installs the same skills again). **Implemented** (`SkillKitVersionTests.SkillFiles_ShippedSkills_CarryOneKitVersionThatMatchesTheEngineMajorMinor`, `[Trait("Requirement", "FP07-AC2")]`, in `CreativeCoders.ShadeKit.Core.Tests/Skills/`). It fails, listing every violation as `:: expected …, found …`, unless: - every `skills/**/SKILL.md` has a frontmatter with `metadata:` and a direct child `version: `, where `` is a plain, unquoted `x.y.z` (no prerelease, no build metadata); - all skills carry the same value; @@ -244,14 +247,15 @@ Warnings: `integration-prerelease-ref` (prerelease engine installs from `main`), - every `--expect ` (or `--expect=`) and every "`` is the kit version of this skill" in any text file under `skills/` names that version, also when it is wrapped across lines; a placeholder such as `--expect ` counts as a violation. - The reference value of "the same value" is the most frequent valid version among the skills; on a tie, the version with the major.minor of the engine wins, then the version of the first skill in ordinal path order. A skill that differs from that version is reported as `expected metadata.version (the kit version of ), found `, where `` is the first skill in path order with the reference version, and the handshake texts are checked against it. So a single outlier skill is the one reported, also when it comes first in path order. **Decided** on 2026-11-15 (package 07 review rework, Gate 5 round 2, finding N6: until then the reference was the first skill with a valid version in path order, so an outlier that came first made every other skill a violation). **Implemented** (`SkillKitVersionTests.SelectKitSkill`; `SkillKitVersionTests.FindKitVersionViolations_OutlierFirstInPathOrder_ReportsOnlyTheOutlier` and the tie and invalid-version tests beside it). - In the same rework every skill was raised to `0.8.0`, in the frontmatter and in every handshake text. **FACT** (`grep` on 2026-11-14: all 19 `skills/*/SKILL.md` carry `version: 0.8.0`, no `0.7.0` is left under `skills/`). -- The test runs in every build that runs the tests: pull requests, `main`, `feature/**`, and the release tag (19). The value is still raised by hand (06-2). +- The test runs in every build that runs the tests: pull requests, `main`, `feature/**`, and the release tag (19). The value is still raised by hand (06-2). This holds for `SkillContractTests` too; the contract number is raised by hand with `CliContract.Current` (06-2). ## Acceptance criteria The automated tests carry `[Trait("Requirement", "FP07-ACn")]`. No test starts `claude`: they fake `IClaudeCommandRunner` and the locator (`FakeClaudeCode` simulates the plugin commands, including "marketplace remove uninstalls the plugin"). - **FP07-AC1** After `integrations install --agent claude`, a new Claude Code session in any repository can load `shade-kit-next-phase`. **Implemented**. The install is proven by `IntegrationsCommandsEndToEndTests.IntegrationsInstall_ClaudeWithoutIntegration_InstallsPluginFromReleaseTagOfEngine`. The session part is checked by hand only: in the smoke check `integrations install --json` installed the plugin from the working tree (`SHADE_KIT_MARKETPLACE_SOURCE`) in an isolated `CLAUDE_CONFIG_DIR`. That configuration has no login, so the session ran headless with the user's login and `--plugin-dir ` instead of the marketplace-installed copy, and loaded `shade-kit-next-phase` (Skill names in Claude Code). -- **FP07-AC2** The installed skills have the same kit version as the engine that installed them. **Implemented**. A release engine installs the tree of the tag `v`, the tree it was built from, proven by `IntegrationsCommandsEndToEndTests.IntegrationsInstall_ClaudeWithoutIntegration_InstallsPluginFromReleaseTagOfEngine`, `IntegrationsInstallCommandTests.ExecuteAsync_JsonMode_WritesEnvelopeWithTargetedSourceAndResultOfEachAgent`, and `IntegrationServiceTests.ResolveSourceAsync_*`. The kit version in that tree (`metadata.version` and every handshake text) has the major.minor of the engine version of the build, enforced by `SkillKitVersionTests.SkillFiles_ShippedSkills_CarryOneKitVersionThatMatchesTheEngineMajorMinor` since 2026-11-14 ([Kit version guard](#kit-version-guard)); the skills carry `0.8.0`. Limits: a release engine whose tag does not exist installs from `main` with the warning `integration-release-tag-missing`, so for such a build the content is that of `main`; and the guard compares major.minor, the rule of the handshake (06-1), not the patch. +- **FP07-AC2** The installed skills lie in the CLI contract window of the engine that installed them. **Implemented** (wording of 2026-11-22). A release engine installs the tree of the tag `v`, the tree it was built from, proven by `IntegrationsCommandsEndToEndTests.IntegrationsInstall_ClaudeWithoutIntegration_InstallsPluginFromReleaseTagOfEngine`, `IntegrationsInstallCommandTests.ExecuteAsync_JsonMode_WritesEnvelopeWithTargetedSourceAndResultOfEachAgent`, and `IntegrationServiceTests.ResolveSourceAsync_*`. Every handshake in that tree names `CliContract.Current` of that engine, enforced by `SkillContractTests.SkillFiles_ShippedSkills_NameTheCurrentCliContractEverywhere` ([Kit version guard](#kit-version-guard)), and `Current` lies in the window. Limits: a release engine whose tag does not exist installs from `main` with the warning `integration-release-tag-missing`, and `SHADE_KIT_MARKETPLACE_SOURCE` can name any tree; for such content the handshake itself checks the window and refuses with `engine-outdated` or `skills-outdated` outside it. + Replaced on 2026-11-22, the earlier text: the installed skills have the same kit version as the engine that installed them; the kit version in that tree (`metadata.version` and every handshake text) has the major.minor of the engine version of the build, enforced by `SkillKitVersionTests` from 2026-11-14 to 2026-11-22; the guard compared major.minor, the rule of the handshake (06-1), not the patch. - **FP07-AC3** After an engine update, `integrations update` replaces the Claude Code content and reports old and new version. **Implemented**. Proven by `IntegrationsCommandsEndToEndTests` (`IntegrationsUpdate_AfterEngineUpdate_SwitchesToNewTagAndReportsOldAndNewVersion`, `IntegrationsUpdate_PlainModeAfterEngineUpdate_WritesOldAndNewVersionAndAsksForRestart`) and `IntegrationsUpdateCommandTests`. - **FP07-AC4** `shade-kit version --json` lists the installed Claude Code integration with its kit version. **Implemented**. Proven by `VersionCommandTests` and `IntegrationsCommandsEndToEndTests` (`Version_JsonModeWithInstalledClaudeIntegration_ListsItWithKitVersion`, `Version_AfterInstall_ListsIntegrationOfEngineVersionInPlainMode`); seen in the smoke check (`kitVersion` and `ref` `null` for the directory source). - **FP07-AC5** No file in the current repository is created or changed by `integrations install` or `integrations update`. **Implemented**. Proven by `IntegrationsCommandsEndToEndTests.IntegrationsInstallAndUpdate_InGitRepository_CreateOrChangeNoFileInIt` (snapshot of a temporary git repository; `claude` never runs inside it). @@ -263,14 +267,14 @@ The automated tests carry `[Trait("Requirement", "FP07-ACn")]`. No test starts ` - Code review of the uncommitted package 07 on 2026-11-13: [review report](../reviews/2026-11-13-feature-claude-code-integration-uncommitted.md) (1 Major, 5 Minor, 7 Suggestions, 2 Nitpicks). - Gate 5 (user, 2026-11-14): reworked the Major finding (Kit version guard), M3, M4, M5, S1 to S7, N1, and N2, as described above. Not reworked and accepted by the user: M1 and M2 (open points). - Second code review of the reworked package 07 on 2026-11-15: [second review report](../reviews/2026-11-15-feature-claude-code-integration-uncommitted-2.md) (0 Critical, 0 Major, 0 Minor, 1 Suggestion, 4 Nitpicks). Of the 15 findings of the first review, 12 were resolved, 1 was resolved as decided (the Major finding: the guard test, layer 1; the release check, layer 2, not selected), and 2 stayed unresolved because the user accepted them (M1, M2). -- Gate 5 round 2 (user, 2026-11-15): reworked N3 (the 52 of a stray stdout line holds for `install` and `update`; in `version` it is the warning `agent-unavailable`, How the engine runs `claude`), N4 (the not-found reason of a missing `claude` is one text, `ExternalTool.NotFoundReason`, used by `ExternalToolRunner.RunAsync` and `ClaudeCodeIntegration.EnsureAvailable`; the text is unchanged; `ExternalToolTests`), and N6 (the kit version guard reports the outlier skill, [Kit version guard](#kit-version-guard)). N5 (the `?? []` guard on `IntegrationRunFailedException.CompletedIntegrations` in `CliErrorMapper.CreateIntegrationRunFailedError`) was checked and kept: a constructed instance never has a null list, but the FP01-AC8 guard test `CliErrorMapperTests.Map_EveryConcreteCoreException_ReturnsCliError` maps instances of every core exception created without running their constructor, and without the guard it fails with a `NullReferenceException` (**FACT**, by experiment in the rework); the comment at the guard now names that reason. Not reworked and accepted by the user: S8 (open points). +- Gate 5 round 2 (user, 2026-11-15): reworked N3 (the 52 of a stray stdout line holds for `install` and `update`; in `version` it is the warning `agent-unavailable`, How the engine runs `claude`), N4 (the not-found reason of a missing `claude` is one text, `ExternalTool.NotFoundReason`, used by `ExternalToolRunner.RunAsync` and `ClaudeCodeIntegration.EnsureAvailable`; the text is unchanged; `ExternalToolTests`), and N6 (the kit version guard reports the outlier skill, [Kit version guard](#kit-version-guard); that guard was replaced on 2026-11-22). N5 (the `?? []` guard on `IntegrationRunFailedException.CompletedIntegrations` in `CliErrorMapper.CreateIntegrationRunFailedError`) was checked and kept: a constructed instance never has a null list, but the FP01-AC8 guard test `CliErrorMapperTests.Map_EveryConcreteCoreException_ReturnsCliError` maps instances of every core exception created without running their constructor, and without the guard it fails with a `NullReferenceException` (**FACT**, by experiment in the rework); the comment at the guard now names that reason. Not reworked and accepted by the user: S8 (open points). ## Open points -- No timeout for `claude` in `version` (review finding M1): with `claude` on the `PATH`, every `version` call, and so every skill handshake, waits for `claude plugin list` (and `marketplace list`) without a time limit; a hanging `claude` blocks it until the user cancels. **Unverified** that the list commands can hang. Accepted by the user at Gate 5 on 2026-11-14. +- No timeout for `claude` in `version` (review finding M1): with `claude` on the `PATH`, every `version` call, and so every skill handshake (since 2026-11-22 not the handshake, which runs `--expect-contract` and reads no integrations), waits for `claude plugin list` (and `marketplace list`) without a time limit; a hanging `claude` blocks it until the user cancels. **Unverified** that the list commands can hang. Accepted by the user at Gate 5 on 2026-11-14. - No minimum Claude Code version is stated or checked (second review finding S8): every `install` and `update` with a kept marketplace runs `claude plugin marketplace update --json`, and the Claude Code CLI reference says that `--json` on that command needs Claude Code 2.1.287 or later (see How the engine runs `claude`). **Unverified** locally: no `claude` older than 2.1.287 was run. An older `claude` would make such a run fail with the generic 52 `agent-command-failed`; its message only says to make sure Claude Code is up to date (`claude update`). Accepted by the user at Gate 5 round 2 on 2026-11-15. - No timeout for `git ls-remote` (review finding M2): on a stalled network the release-tag check of `install` and `update` can block for a long time instead of falling back to the unchecked tag; neither the engine nor git's default HTTP settings bound it. **Unverified** how long such a call blocks. Accepted by the user at Gate 5 on 2026-11-14. -- The release check of the review's Major finding (a `verify-tag` job or Cake task that fails a tag whose skills have another major.minor) was not selected; the guard test fails the tag build instead (19). +- The release check of the review's Major finding (a `verify-tag` job or Cake task that fails a tag whose skills have another major.minor) was not selected; the guard test fails the tag build instead (19). Replaced on 2026-11-22: the skills carry no major.minor; `SkillContractTests` fails the tag build when a handshake names another contract than `CliContract.Current`, and a check before the tag is set is still not built. - The warnings of a failed `install` or `update` are not reported (Several agents). - Plugin components at the repository root ship with the plugin (Content source); nothing but this rule guards it. - On Linux and macOS a Windows drive path in `SHADE_KIT_MARKETPLACE_SOURCE` is not a directory (`C:/kit` gives exit code 2); **Unverified** for Windows junction targets and UNC roots in the directory comparison. diff --git a/docs/feature-packages/08-copilot-and-codex-integration.md b/docs/feature-packages/08-copilot-and-codex-integration.md index 6531603..f1e1a6e 100644 --- a/docs/feature-packages/08-copilot-and-codex-integration.md +++ b/docs/feature-packages/08-copilot-and-codex-integration.md @@ -2,7 +2,7 @@ | | | |---|---| -| Status | Draft, 2026-10-14, updated 2026-10-18 (consistency review: router references replaced by `shade-kit-next-phase`) 2026-10-24 (documentation check: research note instead of an ADR in `docs/adr/`), and 2026-10-30 ([phase start analysis](../../research/shade-kit-phase-start-analysis.md): research question on calling a skill by name), and 2026-11-13 (package 07 implementation: content source, version pin, and state as in 07; Gate 4 rework: `version` asks only detected agents), and 2026-11-14 (review rework of 07: the agent seam `IAgentIntegration` with `EnsureAvailable` and `UpdateAsync(getSource)`, the order of several agents, completed agents named on failure), and 2026-11-15 (implementation: [research note](../../research/shade-kit-agent-compatibility.md) answers every research question; one skill source and the `.claude-plugin/` manifests for all three agents, no install-time transformation; `integrations install --agent copilot\|codex` and their part of `update` and `version` through the `copilot` and `codex` plugin commands; the marketplace decision shared by every agent (`MarketplaceChangeResolver`); outcome `installed` or `updated` for Copilot and Codex; Windows `.cmd` shims run through `cmd.exe` with refused metacharacters; exit codes 51–53 reused with per-agent messages; the FP08-AC4 guard `SingleSkillSourceTests`; call form and tool names per agent in the managed section and the skill texts; the rule for later packages decided), and 2026-11-18 (review of the branch: the notes of FP08-AC4 and FP08-AC5 corrected, the interview decisions recorded under Skill texts, the D5 risk stated and named in the Codex error, the plain-output sentence on Claude Code corrected). Implemented, except the session parts of FP08-AC2, FP08-AC3, and FP08-AC5: they are checks by hand, because `copilot` and `codex` are not installed on the development machine (user decision). | +| Status | Draft, 2026-10-14, updated 2026-10-18 (consistency review: router references replaced by `shade-kit-next-phase`) 2026-10-24 (documentation check: research note instead of an ADR in `docs/adr/`), and 2026-10-30 ([phase start analysis](../../research/shade-kit-phase-start-analysis.md): research question on calling a skill by name), and 2026-11-13 (package 07 implementation: content source, version pin, and state as in 07; Gate 4 rework: `version` asks only detected agents), and 2026-11-14 (review rework of 07: the agent seam `IAgentIntegration` with `EnsureAvailable` and `UpdateAsync(getSource)`, the order of several agents, completed agents named on failure), and 2026-11-15 (implementation: [research note](../../research/shade-kit-agent-compatibility.md) answers every research question; one skill source and the `.claude-plugin/` manifests for all three agents, no install-time transformation; `integrations install --agent copilot\|codex` and their part of `update` and `version` through the `copilot` and `codex` plugin commands; the marketplace decision shared by every agent (`MarketplaceChangeResolver`); outcome `installed` or `updated` for Copilot and Codex; Windows `.cmd` shims run through `cmd.exe` with refused metacharacters; exit codes 51–53 reused with per-agent messages; the FP08-AC4 guard `SingleSkillSourceTests`; call form and tool names per agent in the managed section and the skill texts; the rule for later packages decided), and 2026-11-18 (review of the branch: the notes of FP08-AC4 and FP08-AC5 corrected, the interview decisions recorded under Skill texts, the D5 risk stated and named in the Codex error, the plain-output sentence on Claude Code corrected), and 2026-11-22 (the skills carry no `metadata.version` and name the CLI contract in the handshake; the handshake starts no agent CLI; [06-1](06-1-engine-version-check.md), [report](../../reports/versioning-cli-and-skills.md)). Implemented, except the session parts of FP08-AC2, FP08-AC3, and FP08-AC5: they are checks by hand, because `copilot` and `codex` are not installed on the development machine (user decision). | | Source | Concept §1 (Success, Constraint), §2 (Agents), §3.4, §10 open question 5, [concept §9](../../research/shade-kit-concept.md#9-version-drift); [agent compatibility research](../../research/shade-kit-agent-compatibility.md) (GitHub Copilot CLI 1.0.112 documentation and changelog, OpenAI Codex CLI source at tag `rust-v0.169.0`, read on 2026-11-15) | | Depends on | 02, 06, 07 | | Enables | Phase packages 09–17 are built and accepted on all three agents | @@ -200,7 +200,7 @@ Known limits and points that only a run of the real CLIs can settle. Everything - **Open** (D3): the independence of the review (`shade-kit-review`, loaded by `implement` and `quick`) when subagents are switched off (for example Codex `agents.enabled = false`). The research note proposes running it in the main session and recording in `review.md` that it was not independent, or a new session; the human decides. No skill text changed in this package. - Copilot plugin roots also load `.github/mcp.json` and `.github/lsp.json` (Content source); nothing but the rule guards it, as in 07. - Copilot and Codex results are never `current` (Outcome), so an `update` reports `updated` and asks for a restart even when nothing changed. -- With `copilot` or `codex` on the `PATH`, every `version` call, and so every skill handshake, starts them (Copilot `plugin list` and `marketplace list`, Codex `plugin list`), without a timeout (as 07, review M1). **Unverified** how long that takes. +- With `copilot` or `codex` on the `PATH`, every `version` call, and so every skill handshake (replaced on 2026-11-22: not the handshake, since `version --expect-contract` reads no integrations, 06-1), starts them (Copilot `plugin list` and `marketplace list`, Codex `plugin list`), without a timeout (as 07, review M1). **Unverified** how long that takes. - Unclear points found by the scenario runs of Task 9, not changed, candidates for a later skill review: the option labels of `shade-kit-next-steps` are defined only by the example (its "what happened" line is settled since 2026-11-18, package 06-3); `shade-kit-research` uses `|` both in search patterns and as the result delimiter, leaves the case sensitivity of a search open, and does not say how "partly assumed" findings are counted. Skill-creator's `quick_validate.py` was not run (no PyYAML); a Ruby YAML parser loaded all 11 changed frontmatters. -- Frontmatter visibility (06-2, 2026-11-06), answered on 2026-11-15 from documentation and source: Copilot does not show the frontmatter to the model since Copilot CLI 1.0.48 ("Skill content injected to the model no longer includes YAML frontmatter metadata", **FACT**, changelog); Codex injects the whole `SKILL.md` on a mention, frontmatter included (**FACT**, `codex-rs/ext/skills/src/host_prompt.rs`), so the model sees `metadata.version` as text. Both ignore `metadata.version` (**FACT**: Copilot ignores unknown fields; Codex's parser reads only `name`, `description`, and `metadata.short-description`), so its YAML type reaches no code path. The version stated in the handshake text (06-2) is what all three agents have in common; no skill change is needed. **Unverified:** how Copilot's parser and Codex's `serde_yaml` 0.9 type the unquoted `0.8.0` (a string under the YAML 1.2 core schema), and that Copilot's skill list holds name and description. +- Frontmatter visibility (06-2, 2026-11-06), answered on 2026-11-15 from documentation and source: Copilot does not show the frontmatter to the model since Copilot CLI 1.0.48 ("Skill content injected to the model no longer includes YAML frontmatter metadata", **FACT**, changelog); Codex injects the whole `SKILL.md` on a mention, frontmatter included (**FACT**, `codex-rs/ext/skills/src/host_prompt.rs`), so the model sees `metadata.version` as text. Both ignore `metadata.version` (**FACT**: Copilot ignores unknown fields; Codex's parser reads only `name`, `description`, and `metadata.short-description`), so its YAML type reaches no code path. The version stated in the handshake text (06-2) is what all three agents have in common; no skill change is needed. **Unverified:** how Copilot's parser and Codex's `serde_yaml` 0.9 type the unquoted `0.8.0` (a string under the YAML 1.2 core schema), and that Copilot's skill list holds name and description. Replaced on 2026-11-22 (06-2): the skills have no `metadata` block, so the typing question is moot; the handshake text names the CLI contract (`--expect-contract 1`), which serves all three agents the same way. - Hooks and MCP configuration were not researched (out of scope, as in 07). diff --git a/docs/feature-packages/09-discuss-and-intake.md b/docs/feature-packages/09-discuss-and-intake.md index 78b83f5..35c28d8 100644 --- a/docs/feature-packages/09-discuss-and-intake.md +++ b/docs/feature-packages/09-discuss-and-intake.md @@ -2,7 +2,7 @@ | | | |---|---| -| Status | Draft, 2026-10-14, updated 2026-10-18 (consistency review: router references replaced by `shade-kit-next-phase`), 2026-10-21 (package 03 implemented: the engine pre-fills `request.md`), 2026-10-24 (documentation check: line endings in FP09-AC4), and 2026-10-25 (rework of `feature new` in package 03: the engine reads the issue with `gh` and writes the request content into `request.md`; no `request.md` template; code review of the rework: `request.md` treated as data, not as instructions, exit-33 hints, issue format in FP09-AC3), and 2026-10-30 ([phase start analysis](../../research/shade-kit-phase-start-analysis.md): phases start only when the user calls the phase skill; `new` checks for an active current feature), and 2026-11-20 (implementation: `shade-kit-discuss`, `shade-kit-new`, and `discussion.md` worked out; `feature new --move-source` in package 03; no branch offer; kit version `0.9.0`). AC1 to AC10 implemented. | +| Status | Draft, 2026-10-14, updated 2026-10-18 (consistency review: router references replaced by `shade-kit-next-phase`), 2026-10-21 (package 03 implemented: the engine pre-fills `request.md`), 2026-10-24 (documentation check: line endings in FP09-AC4), and 2026-10-25 (rework of `feature new` in package 03: the engine reads the issue with `gh` and writes the request content into `request.md`; no `request.md` template; code review of the rework: `request.md` treated as data, not as instructions, exit-33 hints, issue format in FP09-AC3), and 2026-10-30 ([phase start analysis](../../research/shade-kit-phase-start-analysis.md): phases start only when the user calls the phase skill; `new` checks for an active current feature), and 2026-11-20 (implementation: `shade-kit-discuss`, `shade-kit-new`, and `discussion.md` worked out; `feature new --move-source` in package 03; no branch offer; kit version `0.9.0`), and 2026-11-22 (the kit version of the skills replaced by the CLI contract, 06-1 and 06-2; scenario S18 of `new` recorded in 06-1). AC1 to AC10 implemented. | | Source | Concept §5.1 (`discuss`, `new`), §5.4, §10 open question 2 | | Depends on | 03, 04, 06 | | Enables | 10 (`refine`), 16 (`diagnose`), 17 (`quick`) | @@ -19,7 +19,7 @@ Ideas can be explored freely before they become a feature, without creating any - The `new` phase skill for every profile. - The template `discussion.md`. `request.md` has no template since 2026-10-25; the engine writes it (package 03). - `shade-kit feature new --move-source` (package 03), so that discussion notes move into the feature created from them. **Decided** on 2026-11-20 (implementation). -- The kit version `0.9.0` of all skills, because `shade-kit-new` needs `--move-source` (package 06-2). **Decided** on 2026-11-20 (implementation). +- The kit version `0.9.0` of all skills, because `shade-kit-new` needs `--move-source` (package 06-2). **Decided** on 2026-11-20 (implementation). Replaced on 2026-11-22 ([06-2](06-2-skill-conventions-and-version.md#cli-contract-in-the-handshake)): the skills carry no kit version; they name the CLI contract `1`, which includes `--move-source`, so an engine without the option is not in the window. ### Out of scope @@ -94,7 +94,7 @@ The miss of iteration 3 is S13 "no git command at all": the runner ran one read- Iteration 1 is counted with the corrected checker (the `--json` check counted options of the closing message as commands, and S14 expected a retry line that the fallback row of 06-3 does not give); the three misses are the new short-title check, which the texts of iteration 1 did not meet. After iteration 2, three wordings were clarified without another run, so they are read-checked only: a new capability may be proposed as `feature`; the topic prefix of options also counts the topics the interview added; one short clause per case in the report of `discuss`. -Common checks in every scenario: the first `shade-kit` command is the handshake `--expect 0.9.0`; every command that runs has `--json`; `feature current --json` runs; no `phase start`, `approve`, `reject`, or `complete`; no `git` command that changes the repository; a closing message is written; the read-only repositories stay unchanged (`git status`). +Common checks in every scenario (runs of 2026-11-20, before the CLI contract replaced `--expect` on 2026-11-22; the generator now expects `--expect-contract `, and S18 of `new` is recorded in [06-1](06-1-engine-version-check.md#scenario-runs)): the first `shade-kit` command is the handshake `--expect 0.9.0`; every command that runs has `--json`; `feature current --json` runs; no `phase start`, `approve`, `reject`, or `complete`; no `git` command that changes the repository; a closing message is written; the read-only repositories stay unchanged (`git status`). - **FP09-AC1** `discuss` without a current feature writes its notes to `.shadekit/discussions/` and creates no feature. **Implemented.** Proven in S10 (one notes file in `.shadekit/discussions/`, no feature folder, no `feature new`) and S12 (a finished current feature counts as none). - **FP09-AC2** `discuss` with a current feature writes its notes into the feature's `discussions/` folder and leaves `feature.json` unchanged. **Implemented.** Proven in S11 (the notes in `features//discussions/` with `Feature: ` and the link `../request.md`; `feature.json` byte for byte equal to before; nothing in `.shadekit/discussions/`). @@ -113,4 +113,4 @@ Common checks in every scenario: the first `shade-kit` command is the handshake - `shade-kit-interview` (06-7), found in the scenario runs: the end-or-go-on question of `open` mode has no header rule; how far `open` mode adds topics of its own is left to the agent; a suggested topic the human declines is neither returned nor an open question. - No scenario for a successful issue read through `new` (the generator has no `gh`), a `discuss` mismatch, or `source-not-removed`; the engine tests cover the move and the warning. - The old `discussion.md` skeleton stays in repositories initialised before 2026-11-20 until `upgrade` (package 18) replaces templates; `discuss` follows whatever template the repository has. -- A kit `0.9` skill with a `0.8` engine stops at the handshake (exit code 50); `--move-source` is not offered to a `0.8` engine. +- A kit `0.9` skill with a `0.8` engine stops at the handshake (exit code 50); `--move-source` is not offered to a `0.8` engine. Replaced on 2026-11-22 (06-1): every engine since 2026-11-22 supports the contract `1`, which includes `--move-source`; a later engine that drops it raises `MinSupported`, and the skill then stops with `skills-outdated` (55). An engine from before 2026-11-22 (a `0.8` engine among them) ignores `--expect-contract` and answers `ok: true`, so the skill goes on; that such an engine then also ignores `--move-source` as an unknown option is **Unverified**. The transition risk is accepted (06-2, D-10). diff --git a/docs/feature-packages/18-upgrade.md b/docs/feature-packages/18-upgrade.md index 24dbd9b..c5ac6a0 100644 --- a/docs/feature-packages/18-upgrade.md +++ b/docs/feature-packages/18-upgrade.md @@ -2,7 +2,7 @@ | | | |---|---| -| Status | Draft, 2026-10-14, updated 2026-10-24 (documentation check: line endings of the instruction section follow package 02; staged multi-file write as open point) and 2026-10-25 (orphaned `request.md` template as open point), and 2026-11-15 (package 08: no further instruction file) | +| Status | Draft, 2026-10-14, updated 2026-10-24 (documentation check: line endings of the instruction section follow package 02; staged multi-file write as open point) and 2026-10-25 (orphaned `request.md` template as open point), and 2026-11-15 (package 08: no further instruction file), and 2026-11-22 ("kit version" made precise: `kitVersion` is the product version of the running engine; the skills carry no version of their own since then and name the CLI contract, 06-1) | | Source | Concept §2 (Lifecycle), §3.1 (`upgrade`), [§9](../../research/shade-kit-concept.md#9-version-drift) (§9.2, §9.3, §9.5) | | Depends on | 01, 02, 05, 08 | | Enables | Kit releases that change a file format or a template, without stranding existing repositories | @@ -19,7 +19,7 @@ When the kit evolves, a team brings its repository to the new formats with one s - Migrating every versioned JSON file in `.shadekit/` with the chains from package 01. - Updating shipped templates through `templates.lock.json`. - Updating the managed instruction section (packages 02 and 08). -- Adding templates and gate entries that a newer kit version ships and the repository does not have yet. +- Adding templates and gate entries that a newer engine version ships and the repository does not have yet. ### Out of scope @@ -44,7 +44,7 @@ When the kit evolves, a team brings its repository to the new formats with one s ### Templates -For each template the running kit version ships (**Decided**, concept §9.5): +For each template the running engine ships (**Decided**, concept §9.5): | State in the repository | Action | |---|---| @@ -53,12 +53,12 @@ For each template the running kit version ships (**Decided**, concept §9.5): | Missing because the kit added it in a newer version | Added. | | Deleted by the team although it is in the lock | Not recreated; reported. **Proposed.** | -`templates.lock.json` then records the new kit version and the hash of the new shipped content for every template. A template the team changed therefore keeps counting as changed on later upgrades. **Proposed.** +`templates.lock.json` then records the version of the running engine as `kitVersion` and the hash of the new shipped content for every template. A template the team changed therefore keeps counting as changed on later upgrades. **Proposed.** ### Gates and configuration -- New gate entries that a kit version adds to the defaults are added to `gates.json`. Values the team changed are never overwritten. **Proposed.** -- `kitVersion` in `config.json` is set to the running kit version. +- New gate entries that an engine version adds to the defaults are added to `gates.json`. Values the team changed are never overwritten. **Proposed.** +- `kitVersion` in `config.json` is set to the version of the running engine, as `init` writes it (package 02). Until 2026-11-22 this was called the running kit version, which the skills also carried; since then the skills carry no version, and whether skills and engine fit is checked by the CLI contract, not by `kitVersion` (06-1). `upgrade` does not touch the agent integrations (out of scope). ### Instruction section diff --git a/docs/feature-packages/19-release-and-distribution.md b/docs/feature-packages/19-release-and-distribution.md index 3435b38..bdce30b 100644 --- a/docs/feature-packages/19-release-and-distribution.md +++ b/docs/feature-packages/19-release-and-distribution.md @@ -2,7 +2,7 @@ | | | |---|---| -| Status | Draft, 2026-10-14, updated 2026-10-18 (reduced to the remaining scope; CI and release workflow are implemented; release notes and branch protection checked) and 2026-11-13 (package 07 implementation: the content is not packed into the release; the release tag names the tree that `integrations install` installs; a release engine whose tag does not exist installs from `main`) and 2026-11-14 (package 07 review rework: the guard test `SkillKitVersionTests` ties the skills' kit version to the build version, so a tag build with stale skills fails its tests) | +| Status | Draft, 2026-10-14, updated 2026-10-18 (reduced to the remaining scope; CI and release workflow are implemented; release notes and branch protection checked) and 2026-11-13 (package 07 implementation: the content is not packed into the release; the release tag names the tree that `integrations install` installs; a release engine whose tag does not exist installs from `main`) and 2026-11-14 (package 07 review rework: the guard test `SkillKitVersionTests` ties the skills' kit version to the build version, so a tag build with stale skills fails its tests) and 2026-11-22 (the version lockstep of skills and engine replaced by the CLI contract: the guard `SkillContractTests`, FP19-AC3 reworded, the proposal "a format change is at least a minor release" dropped; [06-1](06-1-engine-version-check.md), [report](../../reports/versioning-cli-and-skills.md)) | | Source | Concept §3.4; `CLAUDE.md` (Engine deliverables, CI), [concept §9.6](../../research/shade-kit-concept.md#9-version-drift) | | Depends on | 07, 08 (the content comes from the tagged tree of this repository); technically every package that is part of a release | | Enables | Teams outside the kit repository can install and use SHADE kit | @@ -11,7 +11,7 @@ Labels follow the concept: **Decided**, **Proposed**, **Open**, **Unverified**, ## Benefit -A developer gets SHADE kit on any supported machine in one step, with or without a .NET installation, and every release delivers engine and agent content with the same version number, so the version handshake works out of the box. +A developer gets SHADE kit on any supported machine in one step, with or without a .NET installation, and every release delivers engine and agent content with the same version number, so the version handshake works out of the box. Since 2026-11-22 both come from the same tag, and the handshake checks the CLI contract, which the tag build guarantees to fit (06-1, 06-2). ## Implemented @@ -26,8 +26,8 @@ The build and release pipeline exists. `CLAUDE.md` (sections ".NET conventions" ### In scope -- Keeping engine and integration content on one version. Until 2026-11-13 this meant packing the content (skills, research agent definitions) into the engine release; since package 07 the content is not packed: the release tag `v` names the tree that `integrations install` installs. **Decided** on 2026-11-13 (package 07 implementation). What remains is the skills' hand-raised `metadata.version` (06-2), which a guard test checks against the build version since 2026-11-14. -- The version rule for format changes. +- Keeping engine and integration content on one version. Until 2026-11-13 this meant packing the content (skills, research agent definitions) into the engine release; since package 07 the content is not packed: the release tag `v` names the tree that `integrations install` installs. **Decided** on 2026-11-13 (package 07 implementation). What remains is the skills' hand-raised `metadata.version` (06-2), which a guard test checks against the build version since 2026-11-14. Replaced on 2026-11-22 (06-2): the skills carry no version; their handshake names the CLI contract, which `SkillContractTests` checks against `CliContract.Current` without GitVersion, so a release needs no skill change unless the contract changes. +- The version rule for format changes. Dropped on 2026-11-22: the only proposed rule (a format change is at least a minor release, see Version) was dropped with the major.minor handshake (06-1). - An installer script for the binaries. - Release notes that list format changes and the need for `upgrade`. - Making a failing pull request build block the merge into `main`. @@ -42,8 +42,8 @@ The build and release pipeline exists. `CLAUDE.md` (sections ".NET conventions" ### Version -- Engine and integration content are released together under one version number. **Decided** (concept §9.6). The tag `v` that builds the engine is also the ref from which `integrations install` installs the content, so both come from one tree. **Decided** on 2026-11-13 (package 07 implementation), replacing "the content is packed into the engine". A prerelease engine installs from `main`, and so does a release engine whose tag does not exist (a build of an untagged `main` commit, which GitVersion gives no prerelease label), with the warning `integration-release-tag-missing` (07). -- The version follows semantic versioning; a format version change (package 01) is at least a minor release, so the handshake rule (major and minor equal, package 06) catches it. **Proposed.** +- Engine and integration content are released together under one version number. **Decided** (concept §9.6). Replaced on 2026-11-22 (concept §9.6): they are released together from one tag `v`; their compatibility is checked by the CLI contract, not by the version number. The tag `v` that builds the engine is also the ref from which `integrations install` installs the content, so both come from one tree. **Decided** on 2026-11-13 (package 07 implementation), replacing "the content is packed into the engine". A prerelease engine installs from `main`, and so does a release engine whose tag does not exist (a build of an untagged `main` commit, which GitVersion gives no prerelease label), with the warning `integration-release-tag-missing` (07). +- The version follows semantic versioning; a format version change (package 01) is at least a minor release, so the handshake rule (major and minor equal, package 06) catches it. **Proposed.** Dropped on 2026-11-22: the reason existed only for the major.minor handshake, which the CLI contract replaced (06-1); a format change is caught by the format check of every command (package 01) and handled by `upgrade` (18). The version still follows semantic versioning. ### Additional release artifacts @@ -56,11 +56,11 @@ The build and release pipeline exists. `CLAUDE.md` (sections ".NET conventions" - **FP19-AC1** A pull request runs build and test, and a failure blocks the merge. The workflow is **Implemented**. The merge block is not met (checked 2026-10-18 with the GitHub API): `main` has no classic branch protection; the repository ruleset 25112099 requires a pull request (squash only) and forbids deletion and force pushes, and it has a `required_status_checks` rule whose list of checks is empty. Needed step: add the checks of `.github/workflows/pull-request.yml` (`ubuntu-latest`, `windows-latest`, `macos-latest`) as required checks to the ruleset. The ruleset lives in the GitHub settings, not in the repository. - **FP19-AC2** A version tag produces the tool package and five binaries with that version. **Implemented.** -- **FP19-AC3** `shade-kit version --json` of every artifact reports the same engine version, and `integrations install` from it installs content with that version. +- **FP19-AC3** `shade-kit version --json` of every artifact reports the same engine version and the same CLI contract (`data.contract`), and `integrations install` from it installs the content of the tag of that version, whose skills name a contract in the window of that engine (FP07-AC2). Reworded on 2026-11-22; the earlier text: "… reports the same engine version, and `integrations install` from it installs content with that version" (replaced, because the content no longer carries a version). - **FP19-AC4** The installer script installs the binary on macOS, Linux, and Windows and prints the next step. - **FP19-AC5** On a machine without .NET, the binary runs `init` and `integrations install`. - **FP19-AC6** The release notes of a release that raises a format version name the file type, the old and new version, and that `shade-kit upgrade` is needed. Not met today: the release body is the fixed text `SHADE kit Release`. ## Open points -- Every skill's `metadata.version` must carry the major and minor of the tag before it is set (06-2, FP07-AC2). Since 2026-11-14 the guard test `SkillKitVersionTests` (Core tests) fails when the skills' major.minor differs from the engine version of the build, and the release workflow runs the tests on the tag (`-t pack` on all three platforms before `nuget-push` and the GitHub release; **FACT**, `.github/workflows/release.yml`, with pack running the tests as `CLAUDE.md` describes). So a tag build with stale skills fails its tests and publishes nothing; the builds of `main` and of pull requests fail the same way before the tag. Remaining gap: nothing checks it before the tag is set (the `verify-tag` job does not), so a bad tag exists already when its build fails and has to be removed by hand; a release check in `verify-tag` or a Cake task was proposed by the review of 07 (2026-11-13, Major, layer 2) and not selected. The value is still raised by hand, and the commit that raises the minor of the skills needs the minor of the build version raised too (06-2). A release tag also needs `.claude-plugin/` in its tree; `v0.7.0` and `v0.8.0` have none (07). +- Replaced on 2026-11-22 (06-2, CLI contract): the skills carry no version, so a tag needs no skill change; `SkillContractTests` fails the tag build only when a handshake names another contract than `CliContract.Current` of that tree, and nothing checks this before the tag is set. A release tag also needs `.claude-plugin/` in its tree (07). The earlier text: every skill's `metadata.version` must carry the major and minor of the tag before it is set (06-2, FP07-AC2). Since 2026-11-14 the guard test `SkillKitVersionTests` (Core tests) fails when the skills' major.minor differs from the engine version of the build, and the release workflow runs the tests on the tag (`-t pack` on all three platforms before `nuget-push` and the GitHub release; **FACT**, `.github/workflows/release.yml`, with pack running the tests as `CLAUDE.md` describes). So a tag build with stale skills fails its tests and publishes nothing; the builds of `main` and of pull requests fail the same way before the tag. Remaining gap: nothing checks it before the tag is set (the `verify-tag` job does not), so a bad tag exists already when its build fails and has to be removed by hand; a release check in `verify-tag` or a Cake task was proposed by the review of 07 (2026-11-13, Major, layer 2) and not selected. The value is still raised by hand, and the commit that raises the minor of the skills needs the minor of the build version raised too (06-2). A release tag also needs `.claude-plugin/` in its tree; `v0.7.0` and `v0.8.0` have none (07). diff --git a/docs/feature-packages/README.md b/docs/feature-packages/README.md index 0374a20..00b8474 100644 --- a/docs/feature-packages/README.md +++ b/docs/feature-packages/README.md @@ -1,6 +1,6 @@ # SHADE kit v1 feature packages -Status: draft, 2026-10-14, updated 2026-10-18 (consistency review, findings clarification, and implementation of package 02), 2026-10-21 (implementation of package 03, its code review rework, and the rework after its second code review), 2026-10-22 (code review verification of package 03), 2026-10-23/24 (rework of file content handling), 2026-10-24 (documentation check against the code), 2026-10-25 (rework of `feature new` and its code review), 2026-10-26 (implementation of package 04), 2026-10-27 (documentation check after package 04), 2026-11-01 (implementation of package 05), 2026-11-04 (split of package 06 into the sub-features 06-1 to 06-9), 2026-11-06 (implementation of package 06-1 and its code review, and implementation of package 06-2), 2026-11-08 (implementation of package 06-3, and implementation of package 06-4 and its code review rework), 2026-11-10 (implementation of package 06-5), 2026-11-11 (implementation of package 06-6), 2026-11-13 (implementation of packages 06-8, 06-9, and 07, and the Gate 4 rework of 07), 2026-11-14 (review rework of 07, Gate 5), and 2026-11-15 (second review rework of 07, Gate 5 round 2, and implementation of package 08), and 2026-11-20 (implementation of package 09). Derived step by step from [`research/shade-kit-concept.md`](../../research/shade-kit-concept.md); its [section 9](../../research/shade-kit-concept.md#9-version-drift) holds the version-drift decisions of the former ADR 0001. Parts that exist in the code are labelled **Implemented**. +Status: draft, 2026-10-14, updated 2026-10-18 (consistency review, findings clarification, and implementation of package 02), 2026-10-21 (implementation of package 03, its code review rework, and the rework after its second code review), 2026-10-22 (code review verification of package 03), 2026-10-23/24 (rework of file content handling), 2026-10-24 (documentation check against the code), 2026-10-25 (rework of `feature new` and its code review), 2026-10-26 (implementation of package 04), 2026-10-27 (documentation check after package 04), 2026-11-01 (implementation of package 05), 2026-11-04 (split of package 06 into the sub-features 06-1 to 06-9), 2026-11-06 (implementation of package 06-1 and its code review, and implementation of package 06-2), 2026-11-08 (implementation of package 06-3, and implementation of package 06-4 and its code review rework), 2026-11-10 (implementation of package 06-5), 2026-11-11 (implementation of package 06-6), 2026-11-13 (implementation of packages 06-8, 06-9, and 07, and the Gate 4 rework of 07), 2026-11-14 (review rework of 07, Gate 5), and 2026-11-15 (second review rework of 07, Gate 5 round 2, and implementation of package 08), 2026-11-20 (implementation of package 09), and 2026-11-22 (the version lockstep of skills and engine replaced by the CLI contract). Derived step by step from [`research/shade-kit-concept.md`](../../research/shade-kit-concept.md); its [section 9](../../research/shade-kit-concept.md#9-version-drift) holds the version-drift decisions of the former ADR 0001. Parts that exist in the code are labelled **Implemented**. Each package describes the functional behaviour of one clearly bounded piece of v1, with its benefit, scope, acceptance criteria (`FPnn-ACm`), and open points. The number prefix is the implementation order: every package depends only on packages with a lower number. @@ -16,8 +16,8 @@ Labels follow the concept: **Decided** (confirmed in the concept interview or a | 04 | [Phase engine and workflow profiles](04-phase-engine-and-workflow-profiles.md) | The engine referees phases and records every approval | 01, 03 | | 05 | [Gates and checklists](05-gates-and-checklists.md) | Configurable approvals, DoR and DoD with a record per feature | 02, 04 | | 06 | [Skill foundation](06-skill-foundation.md) | "Continue" finds the next step; shared entry protocol, next-steps, interview, gate, and research skills | 01, 03, 04, 05 | -| 06-1 | [Engine version check](06-1-engine-version-check.md) | `version --expect` tells a skill whether it fits the engine | 01 | -| 06-2 | [Skill conventions and version metadata](06-2-skill-conventions-and-version.md) | Every skill follows the same rules and carries its kit version | 06-1 | +| 06-1 | [Engine version check](06-1-engine-version-check.md) | `version --expect-contract` tells a skill whether the engine supports its CLI contract | 01 | +| 06-2 | [Skill conventions and version metadata](06-2-skill-conventions-and-version.md) | Every skill follows the same rules and names the CLI contract it is written for | 06-1 | | 06-3 | [Next-steps message](06-3-next-steps-skill.md) | Every skill ends with the human's options and the skill to call | 06-2 | | 06-4 | [Checklist check](06-4-gate-check-skill.md) | Checked, evidenced checklist before every approval | 05, 06-2 | | 06-5 | [Entry protocol](06-5-phase-entry-skill.md) | No phase starts behind the developer's back | 06-1, 06-3, 06-4 | @@ -37,7 +37,7 @@ Labels follow the concept: **Decided** (confirmed in the concept interview or a | 16 | [Bugfix profile](16-bugfix-profile.md) | Reproduce, root cause, failing test first | 04, 05, 06, 09, 12–15 | | 17 | [Quick profile](17-quick-profile.md) | Traceability for small changes with one approval | 04, 05, 06, 09, 13, 15 | | 18 | [Repository upgrade](18-upgrade.md) | Safe, all-or-nothing migration to new kit versions | 01, 02, 05, 08 | -| 19 | [Release and distribution](19-release-and-distribution.md) | Install anywhere, engine and content on one version | 07, 08 | +| 19 | [Release and distribution](19-release-and-distribution.md) | Install anywhere, engine and content from one tag | 07, 08 | ### Milestones @@ -117,14 +117,17 @@ New open points from the packages: - Changing the profile of an existing feature (04). - The `report` setting in the result of `phase start finish`, which the `shade-kit-finish` skeleton expects (04, owned by 15). - History timestamps `at` with fractional seconds, while `createdAt` has whole seconds (04). -- Skill skeletons aligned with the built `phase` commands on 2026-11-13 (06-9): the planned-commands sentence is gone from all 12 skeletons (not 13), every phase skill loads `shade-kit-phase-entry` and `shade-kit-next-steps`, which show the warnings, and `new`, `discuss`, and `drop` run the handshake with `--expect`. Still open: the `report` setting in the result of `phase start finish` and in the return of `shade-kit-phase-entry` (15, FP15-AC7); until then `shade-kit-finish` treats it as `ask`. -- Skill version (06-2, 2026-11-04): every skill carries its kit version hardcoded in its frontmatter (`metadata.version`), initial value `0.7.0` (2026-11-06), `0.8.0` since 2026-11-14, `0.9.0` since 2026-11-20 (09, with `next-version` in `GitVersion.yml`). It is still raised by hand, together with `next-version` in `GitVersion.yml` (the one version kept there since 2026-11-20); since 2026-11-14 the guard test `SkillKitVersionTests` (FP07-AC2) fails every build whose skills carry another major.minor than the engine version of the build, or whose handshake texts name another version, so a release tag with stale skills fails its tag build (06-2, 07, 19). Still open: writing the version from GitVersion and a check before the tag is set (`verify-tag`); the build minor is raised with `next-version` (06-2, since 2026-11-20). Claude Code does not show the frontmatter to the model (checked on 2026-11-06 with Claude Code 2.1.318 on project-level skills, 06-2), so the handshake step states the version in its text. Answered on 2026-11-15 from documentation and source (08): Copilot does not show the frontmatter since Copilot CLI 1.0.48, Codex shows the whole `SKILL.md` on a mention; both ignore `metadata.version`, so the version in the handshake text stays the common way. **Unverified:** how their YAML parsers type the unquoted `0.8.0`. +- Skill skeletons aligned with the built `phase` commands on 2026-11-13 (06-9): the planned-commands sentence is gone from all 12 skeletons (not 13), every phase skill loads `shade-kit-phase-entry` and `shade-kit-next-steps`, which show the warnings, and `new`, `discuss`, and `drop` run the handshake with `--expect` (since 2026-11-22 with `--expect-contract`, 06-1). Still open: the `report` setting in the result of `phase start finish` and in the return of `shade-kit-phase-entry` (15, FP15-AC7); until then `shade-kit-finish` treats it as `ask`. +- Skill version (06-2): replaced on 2026-11-22 by the CLI contract ([report](../../reports/versioning-cli-and-skills.md), 06-1, 06-2): the skills carry no version; the handshake sentence names the CLI contract (`--expect-contract 1`), and the guard `SkillContractTests` (FP07-AC2) checks every such number against `CliContract.Current` without GitVersion, so `next-version` is a product decision only. Still open: a check before the tag is set (`verify-tag`, 19). Claude Code does not show the frontmatter to the model (checked on 2026-11-06 with Claude Code 2.1.318 on project-level skills, 06-2), so the handshake names the contract in its text; the same holds for Copilot and Codex (answered on 2026-11-15, 08). The earlier state, kept as history: every skill carries its kit version hardcoded in its frontmatter (`metadata.version`), initial value `0.7.0` (2026-11-06), `0.8.0` since 2026-11-14, `0.9.0` since 2026-11-20 (09, with `next-version` in `GitVersion.yml`). It is still raised by hand, together with `next-version` in `GitVersion.yml` (the one version kept there since 2026-11-20); since 2026-11-14 the guard test `SkillKitVersionTests` (FP07-AC2) fails every build whose skills carry another major.minor than the engine version of the build, or whose handshake texts name another version, so a release tag with stale skills fails its tag build (06-2, 07, 19). Still open: writing the version from GitVersion and a check before the tag is set (`verify-tag`); the build minor is raised with `next-version` (06-2, since 2026-11-20). Claude Code does not show the frontmatter to the model (checked on 2026-11-06 with Claude Code 2.1.318 on project-level skills, 06-2), so the handshake step states the version in its text. Answered on 2026-11-15 from documentation and source (08): Copilot does not show the frontmatter since Copilot CLI 1.0.48, Codex shows the whole `SKILL.md` on a mention; both ignore `metadata.version`, so the version in the handshake text stays the common way. **Unverified:** how their YAML parsers type the unquoted `0.8.0`. +- Contract snapshot test (06-1, D-12 of the 2026-11-22 implementation): after v1 is complete, decide again whether a contract snapshot test (reflection over the commands, options, `data` fields, and error and warning codes, compared with a checked-in file per contract version) guards that `CliContract.Current` rises with every skill-visible change; until then raising it is a manual review duty. +- Scenario checker gap (06-1, D-23 of the 2026-11-22 implementation; the task was marked blocked by the user after two verification rounds): the S19 check "options do not tell to update the engine" (`ENGINE_UPDATE` in `tests/skill-scenarios/checks/check_runs.py`) missed an engine update named only through the tool ("get a newer shade-kit") and flagged "install the kit plugin that matches the engine" as an engine update. **Closed** in review round 1 on 2026-11-22 (finding M4): `ENGINE_UPDATE` counts both cases right, and S18 and S19 pass 22 of 22 on the same runner outputs (06-1). +- `shade-kit-next-steps` step 5.3 (06-3) does not say what to do when `phase next` never ran; both runners of S18 and S19 (2026-11-22, 06-1) left that part out. Not changed in that round. - Phase skills are restricted to user invocation only by convention (06-2, 08): a technical restriction such as Claude Code's `disable-model-invocation` is a possible later addition. Researched in 08 (2026-11-15): Copilot has `disable-model-invocation`, but a flagged skill is reported to be unloadable by another skill (issue, **Unverified**), and Codex has `policy.allow_implicit_invocation` in an agent-specific `agents/openai.yaml`; v1 uses neither and keeps the convention on all three agents. - Skill reactions to a refused start and the refusal table of the next-steps message are **Proposed** (06-3); the active-feature check of `new` is **Decided** since 2026-11-20 (09). Found in the scenario runs of 09: the fallback row offers no retry of the calling skill, also for `invalid-source` of `new`, and the calling skills pass a fixed line of what happened that 06-3 says the message writes itself. The next-steps skill is built (06-3, 2026-11-08); its defaults are also **Proposed**: the table is keyed by error code, a failing `phase next` goes through the table, repeated warnings are shown once, and a refusal ends with calling the skill again. Rows 20–22 and 47 name `shade-kit upgrade`, which comes only with package 18. - Defaults of the 04 implementation that the user has not confirmed yet (**Proposed** in 04): the repeated gate of a pending forward transition, approving a pending reopen of a phase that can no longer be reopened, the conditions for a `feature.json` without `currentPhase`, the done rule, the override deletion of `phase complete`, the plain-text wording, and `null` parts of `phase next`. - Value and unit of the coverage threshold `coverageThreshold` in `config.json` (05, 14). - Follow-ups from the implementation of 05 (2026-11-01): `checklist` values with control characters or `:` (a Windows alternate data stream) are not rejected; the order of `gate-entry-ignored` warnings relies on `Dictionary` enumeration order, which .NET does not guarantee; the cached `GatesConfig` is one shared mutable object; a file at `features//checks` ends `phase start` with exit code 255 (resolved on 2026-11-04: exit code 17, since the /simplify review of feature/feature-05 for every refused write in `.shadekit/`, 01); two concurrent starts could race between the existence check and the write of the copy; repositories initialised before 2026-11-01 get the built-in gate defaults with a warning until an upgrade (18) writes `profiles` (05). -- Follow-ups of 07 (2026-11-13): the tags `v0.7.0` and `v0.8.0` have no `.claude-plugin/`, so the first installable release is the first tag with the manifests; **Unverified** the interactive slash menu with the marketplace-installed plugin; the `claude.cmd` of an npm installation on Windows is not supported; `integrations uninstall` later; **Unverified** whether Claude Code copies the whole repository tree of a GitHub source (plugin source `./`) into its plugin cache; with `claude` on the `PATH` every `version` call starts it (0.73 s instead of 0.08 s for `version --json --expect`, measured on 2026-11-13); a plugin with another scope than `user` is not seen; without `git` or the network the release-tag check is skipped and the tag is used unchecked. From the review rework (2026-11-14): no timeout for `claude` in `version` and for `git ls-remote`, accepted by the user (review M1, M2); the warnings of a failed `install` or `update` are not reported; plugin components at the repository root (`.mcp.json`, `hooks/`, `agents/`, `commands/`, …) would ship with the plugin, guarded only by a rule; **Unverified** the GitHub fetch path of `claude plugin marketplace update` and Windows junctions and UNC roots in the directory comparison; a Windows drive path in `SHADE_KIT_MARKETPLACE_SOURCE` is no directory on Linux and macOS. From the second review rework (2026-11-15): no minimum Claude Code version is stated or checked, although `claude plugin marketplace update --json`, run for every kept marketplace, needs Claude Code 2.1.287 or later per the Claude Code CLI reference (**Unverified** locally), so an older `claude` gives a generic 52; accepted by the user (second review S8). +- Follow-ups of 07 (2026-11-13): the tags `v0.7.0` and `v0.8.0` have no `.claude-plugin/`, so the first installable release is the first tag with the manifests; **Unverified** the interactive slash menu with the marketplace-installed plugin; the `claude.cmd` of an npm installation on Windows is not supported; `integrations uninstall` later; **Unverified** whether Claude Code copies the whole repository tree of a GitHub source (plugin source `./`) into its plugin cache; with `claude` on the `PATH` every `version` call starts it (0.73 s instead of 0.08 s for `version --json --expect`, measured on 2026-11-13; since 2026-11-22 the handshake `version --expect-contract` does not read the integrations and starts no agent CLI, 06-1); a plugin with another scope than `user` is not seen; without `git` or the network the release-tag check is skipped and the tag is used unchecked. From the review rework (2026-11-14): no timeout for `claude` in `version` and for `git ls-remote`, accepted by the user (review M1, M2); the warnings of a failed `install` or `update` are not reported; plugin components at the repository root (`.mcp.json`, `hooks/`, `agents/`, `commands/`, …) would ship with the plugin, guarded only by a rule; **Unverified** the GitHub fetch path of `claude plugin marketplace update` and Windows junctions and UNC roots in the directory comparison; a Windows drive path in `SHADE_KIT_MARKETPLACE_SOURCE` is no directory on Linux and macOS. From the second review rework (2026-11-15): no minimum Claude Code version is stated or checked, although `claude plugin marketplace update --json`, run for every kept marketplace, needs Claude Code 2.1.287 or later per the Claude Code CLI reference (**Unverified** locally), so an older `claude` gives a generic 52; accepted by the user (second review S8). - Follow-ups of 08 (2026-11-15): the session parts of FP08-AC2 and FP08-AC3 are checks by hand (research note §8), because `copilot` and `codex` are not installed on the development machine; everything that only a run of these CLIs can show is **Unverified** (commands, output shapes, a tag as ref, the Windows `.cmd` route); Copilot and Codex never report `current`; Codex reports no marketplace ref, so `version` lists its `kitVersion` and `ref` as `null` and a failing check add leads to a switch that a rerun repairs (D5; **Known risk**, stated on 2026-11-18: a check that fails for a network, proxy, or login reason also leads to the switch, which removes the plugin and the marketplace, so Codex has no skills until a rerun with a working connection; the Codex error names this possible cause); the `.cmd` shim path is refused when it contains `(`, `)`, `&`, `!`, `%`, or `^`, and Unicode lookalikes are not refused (D4, **Open**); Copilot loads the managed section twice; the repair hint "…was already switched…" also appears when only the plugin was removed; the independence of the review when subagents are switched off is **Open** (D3); Copilot's `.github/mcp.json` and `.github/lsp.json` would ship with the plugin, guarded only by a rule; unclear points of `shade-kit-next-steps` and `shade-kit-research` found by the scenario runs are left for a later skill review. - Follow-ups from the implementation of 02: plain output wrapped at 80 columns when stdout is not a terminal, skeleton templates that name their owner package, a second `.gitignore` comment line when only an entry is missing (02). From its code review: a dangling symbolic link ends with a host error and a read-only target file fails only after `.shadekit/` is written (02). - Follow-ups of 03 after its code review rework and second code review (2026-10-21): the process run of `GitCommandRunner` (output capture, exit codes, kill) is not covered by tests, and its read tasks are not observed after a kill (F03, accepted); a FIFO as `--source` blocks `feature new`; `drop` can delete an override that was changed to another feature between its check and the delete; on some systems the rename of `new` or `drop` can replace an empty folder created at the wrong moment; a file at `features/` makes `feature new` end with exit code 255; a rename that fails only for a moment (for example on Windows while a virus scanner holds new files) is not retried and ends with exit code 35; unknown extra arguments are ignored silently; `git.cmd` shims are not found (no `PATHEXT`). Accepted as is by the user from the second code review: bidi format characters and U+2028/U+2029 pass the title check (N03); 03 says that a canceled `init` rolls back what it created, but it removes only `.shadekit/` (N04); Ctrl+Break and SIGQUIT also cancel with exit code 130 (N05); the `invalid-title` hint "Pass such a title with --title." is circular for a title from `--title` (N06); a theory in `ConsoleCancellationTests` branches in its Arrange section (N07). @@ -191,3 +194,4 @@ After each package, the whole draft was checked against the concept, ADR 0001 (n | Skill text clarifications after scenario runs (2026-11-18) | Nine scenario runs (fresh subagents with canned envelopes of the real engine, playing Claude Code, GitHub Copilot CLI, and OpenAI Codex CLI in default and plan mode) found skill texts that left points to the agent: `shade-kit-next-steps` shortened the `featureId` in its example and took the "what happened" line from the calling skill; a plain question of `shade-kit-phase-entry` had no fixed form for its options; the question of `shade-kit-gate-check` about an open item did not say what goes into the question text and the options, and a missing artifact that no item refers to had no place in the return; `shade-kit-interview` assumed a header and option descriptions in every question tool, applied the tool's option limits to plain questions, and did not say what happens with a missing target or IDs under `on return`; `shade-kit-quick` checked the size of the change only after the clarification. Whether Codex in plan mode lets the gate check write its copy after `request_user_input` stayed open (S5). | Decided by the human on 2026-11-18, **Implemented** in the five skills. Docs: 06-3 (the `featureId` never shortened, the "what happened" line written by next-steps from the point of view of the skill the human called; the full steps after "End here" kept), 06-5 (numbered plain questions that end the message; steps 3 and 4 keep and show the missing artifacts), 06-4 (the question text and option descriptions of an open item, the Evidence of a human-decided item; only the items decide the result, the missing artifacts as a note in the return), 06-7 (progress and option descriptions in the question text when the tool has no header or no option descriptions; the option limits are the tool's, a plain question offers up to three alternatives; no missing-target report and no IDs with `on return` from the start), 17 (the size check before the clarification, no interview for a change that is not small or not clear), 08 (open points: the argument shape of Copilot's `ask_user` and the Codex plan-mode write after `request_user_input` **Unverified**). | | Scenario building blocks in the repository (2026-11-18) | D-28 of the [06-4 implementation report](../implementation/06-4-gate-check-skill.md) kept the scenario runs, fixtures, and outputs outside the repository, so every skill change had to rebuild the runner protocol, the scenarios, the fixtures, and the checker by hand, and nothing said where they come from. | Decided by the human on 2026-11-18: the reusable building blocks live in `tests/skill-scenarios/` (runner protocol, scenario catalog S1–S9 with placeholders, a fixture generator that drives `git` and the real engine into a work folder outside the repository, the expectations and checker, and a `README.md` with the procedure and the runner prompt); the outputs of runs and the generated fixtures stay outside the repository. This supersedes D-28; the 06-4 report stays as written. **Implemented**. Changed: `tests/skill-scenarios/` (new), `CLAUDE.md` (skill conventions, repository layout), 06-2 (skill conventions), this log. | | 09 implementation (2026-11-20) | 09 left the notes format, the file name, a `done` current feature, a missing template, repeated writes, and line endings of `discuss` open; `feature new` would take "Discussion: X" from the notes heading as the title; nothing said what happens to notes in `.shadekit/discussions/` after `new`, and skills may not write `feature.json`; the profile default needed `config.json`, which skills do not read; the branch offer and the active-feature check were **Proposed**; the template was a skeleton. | Decided with the user (D-1 to D-28 of the implementation): a `done` feature counts as none for `discuss`; the heading is the topic alone; notes move into the feature with the new option `feature new --move-source` (only a file directly in `.shadekit/discussions/`, copy then delete after the override, warning `source-not-removed`, exit code 33 otherwise); no branch offer, FP09-AC5 reworded; the active-feature check **Decided**; the skill leaves out `--profile` for "the repository default"; free text as one shell-quoted argument; a missing template is the second template exception; kit version `0.9.0` with `next-version: v0.9.0` in `GitVersion.yml`. Code: `DiscussionNotesMove`, `FeatureStore.CreateAsync`, `NewFeatureRequest.MoveSource`, `NewFeatureResult.MovedSourceFrom`, `FeatureSourceProblem.SourceNotMovable`, `FeatureSourceNotRemovedWarning`, `KitStorePaths.DiscussionsDirName`, `FeatureNewCommand(Options)`, `CliErrorMapper`, `ShadeKitCliWarningCodes.SourceNotRemoved`, with tests. Skills: `shade-kit-discuss`, `shade-kit-new`, all 19 at `0.9.0`. Template `discussion.md`. Scenarios S10–S16 in `tests/skill-scenarios/`. Docs: 09 (decisions, AC1–AC10 with proofs, open points), 03 (`--move-source`, branch note, warning, exit 33), 01 (warning code), 02 (template state), 06-2 (version `0.9.0`, `next-version`, second template exception), `CLAUDE.md`, this README. Proven by `dotnet test`, `quick_validate.py` (19 of 19, run with PyYAML through `uv`), smoke runs of the built CLI, and scenario runs (iteration 2: 133 of 133; after the reviews S13–S17 84 of 84, S17 again 18 of 18). Two review rounds ([round 1](../reviews/2026-11-20-feature-09-discuss-and-intake-uncommitted.md): 1 Major, the branch case of `new`, fixed with `feature show`; [round 2](../reviews/2026-11-20-feature-09-discuss-and-intake-uncommitted-round2.md): 0 Major, two checks that could not fail fixed); `FeatureSourceFiles` shares the path rule of `feature new` and the `--move-source` pre-check. | +| CLI contract (2026-11-22) | The version lockstep gave one hand-kept product version two meanings: every skill carried the kit version in `metadata.version` and in its handshake text, `version --expect` compared major and minor and only warned on a prerelease engine, and `SkillKitVersionTests` tied the skills to the GitVersion version of the build, so its result depended on the branch, the tags, and `next-version`, and every skill-visible CLI change forced a kit-wide minor (two of three raises were forced). The [report](../../reports/versioning-cli-and-skills.md) recommended an integer CLI contract with a window. | Decided with the user and implemented: `CliContract` (`Current` and `MinSupported`, both `1`) in `Core/Versions/`; `version --expect-contract ` with exit codes 54 `engine-outdated` and 55 `skills-outdated` and no prerelease leniency; `data.contract`, `data.expectedContract`, and no integrations read in the handshake; `--expect`, exit code 50 `version-mismatch`, and the warning `engine-prerelease-version-mismatch` removed; no `metadata` block in any skill and the handshake sentence "1 is the CLI contract this skill is written for" in five skills; `SkillContractTests` (FP07-AC2) replaces `SkillKitVersionTests`; `GitVersion.yml` comment on `next-version` reduced to the product role; distribution and `kitVersion` unchanged. Rewritten in place, replaced decisions marked with the date: CLAUDE.md, `GitVersion.yml`, 01, 02, 06, 06-1 (with the scenario runs S18 and S19), 06-2, 06-3, 06-5, 06-6, 06-9, 07 (FP07-AC2: the installed skills lie in the contract window of the installing engine), 08, 09, 18 (`kitVersion` is the engine version), 19 (FP19-AC3; the proposal "a format change is at least a minor release" dropped, which also answers the log row of 19 above), concept §3.4, §9.6, and the command table. New open points: the contract snapshot test (D-12), the scenario checker gap (D-23), and step 5.3 of `shade-kit-next-steps`. | diff --git a/docs/implementation/cli-contract-version.md b/docs/implementation/cli-contract-version.md new file mode 100644 index 0000000..6d678bb --- /dev/null +++ b/docs/implementation/cli-contract-version.md @@ -0,0 +1,290 @@ +> **Date:** 2026-11-22 +> **Requirement:** Empfehlung aus `reports/versioning-cli-and-skills.md` („Eine Vertragsnummer entkoppelt CLI und Skills“) +> **Branch:** feature/rework-versioning-branch-mgmt +> **Mode:** sub-agents (sequential, ein Implementer und ein Verifier pro Task) +> **Status:** complete — mit zurückgestellten Review-Befunden (Abschnitt 9) + +# CLI-Vertragsversion statt Lockstep-Versionshandshake zwischen Skills und Engine + +## 1. Summary + +Der Handshake zwischen Skills und Engine prüft nicht mehr die Produktversion. Bisher galt: `--expect `, major.minor musste gleich sein, und Prerelease-Engines wurden durchgewunken. Jetzt prüft er eine ganzzahlige CLI-Vertragsversion mit Fenster. `CliContract.Current` und `CliContract.MinSupported` sind beide 1. Die Skills rufen `shade-kit version --json --expect-contract 1` auf, die Engine antwortet mit Exit 54 `engine-outdated` oder 55 `skills-outdated`. Entfernt sind `--expect`, der alte Checker, die Prerelease-Nachsicht, `metadata.version` in allen 19 Skills und der an GitVersion gekoppelte Guard. Neu ist `SkillContractTests`. + +Alle 5 Tasks sind erledigt. Task 4 war nach zwei FAIL-Verifikationen vorübergehend blockiert (D-23). Die Lücke wurde in den Review-Runden 1 bis 3 geschlossen. Es gab 4 Review-Runden und 4 Rework-Tasks (R-1 bis R-4). Am Ende gibt es keinen Befund der Schwere Critical, Major oder Minor mehr. + +**Nichts ist committet.** Bitte `git diff` prüfen und übernehmen, was du akzeptierst. + +## 2. Preconditions + +- **Arbeitsbaum beim Start:** Er war dirty, mit dem gestagten Rename `reports/Versionierung von CLI und Skills.md` → `reports/versioning-cli-and-skills.md`. Nach D-1 hast du zuerst committet (`6b675f8`), der Baum war danach sauber. +- **Skill-Liste der Laufzeit:** verfügbar, mit rund 75 Skills und 13 Agent-Typen. +- **Größenhinweis:** `n/a`. Die Arbeit war nicht klein: 5 Tasks und mehr als 70 Dateien. + +## 3. Requirement and Acceptance Criteria + +Die Kompatibilität von Skills und Engine hängt nicht mehr an der Produkt-SemVer, sondern an einer eigenen ganzzahligen Vertragsnummer. Die Engine erklärt ein Fenster `MinSupported ≤ R ≤ Current`. Jeder Handshake-Skill nennt die eine Vertragsnummer R, für die er geschrieben ist. Die Produktversion bleibt bei GitVersion. Die Skills tragen keine eigene Version mehr. Verteilt wird weiter über den Tag `v` bzw. über `main`. + +Die Verdikte stammen aus Teil B der Reviews, Stand Runde 4. `proven` heißt, ein Test wurde gegen eine gebrochene Version rot gesehen. `read-checked` heißt, die Tests wurden nur gelesen. Ergebnis: **10 ACs proven (executed), 2 read-checked (AC-11, AC-12), 0 unproven**. AC-10 ist im Checker-Teil proven, im Generator-Teil read-checked. AC-9 ist gestrichen. + +| AC | Text | Origin | Tests (file · name) | Result | Verdict | +|---|---|---|---|---|---| +| AC-1 | `CliContract` in `Core/Versions/` mit `Current = MinSupported = 1` | explicit | Core.Tests/Versions/CliContractTests · Window_Constants_AreCurrentAndMinSupported | pass | proven (executed: `Current = 2` → rot) | +| AC-2 | `version --json` meldet `data.contract` | explicit | Cli.Tests VersionCommandTests · ExecuteAsync_JsonMode_WritesContractWithCurrentAndMinSupported | pass | proven (executed: M15 Feld ignoriert; M7b/M7c Werte vertauscht bzw. zusammengelegt; M16 Fix zurückgenommen → rot) | +| | | | VersionCommandTests · ExecuteAsync_PlainMode_WritesContractLineAfterVersionLine | pass | | +| | | | VersionCommandTests · ExecuteAsync_JsonModeWithWiderWindow_WritesCurrentAndMinSupportedOfWindow (R-1) | pass | | +| | | | VersionCommandTests · ExecuteAsync_PlainModeWithWiderWindow_WritesContractLineOfWindow (R-1) | pass | | +| | | | ProgramTests · RunAsync_VersionJson_WritesContract | pass | | +| AC-3 | Fenster: im Fenster ok; `R > Current` → Engine veraltet; `R < MinSupported` → Skills veraltet (Verweis auf `integrations install`); keine Prerelease-Nachsicht | explicit | CliContractCheckerTests · Check_RequestedWithinWindow_Succeeds, Check_RequestedAboveCurrent_ThrowsEngineContractOutdatedExceptionWithContracts, Check_RequestedBelowMinSupported_ThrowsSkillsContractOutdatedExceptionWithContracts, Check_RequestedZeroWithDefaultWindow_ThrowsSkillsContractOutdatedException, Check_NegativeRequested_ThrowsArgumentOutOfRangeException, Ctor_NullWindow_ThrowsArgumentNullException, Window_Constructed_ReturnsWindowOfConstructor | pass | proven (executed: `>`→`>=`, `<`→`<=`, Hinweistext B vertauscht → rot) | +| | | | CliContractWindowTests (3); ContractExceptionsTests (2); ShadeKitCoreServiceCollectionExtensionsTests · …RegistersCliContractCheckerWithCliContractWindow u. a. | pass | | +| | | | VersionCommandTests · ExecuteAsync_JsonModeExpectContractInWindow_WritesSuccess, ExecuteAsync_JsonModeEngineOutdated_WritesEngineOutdatedEnvelopeAndAbortsWith54, ExecuteAsync_JsonModeSkillsOutdated_WritesSkillsOutdatedEnvelopeAndAbortsWith55, ExecuteAsync_PlainModeEngineOutdated_AbortsWith54AndMessageWithoutOutput, ExecuteAsync_PlainModeSkillsOutdated_AbortsWith55AndMessageWithoutOutput | pass | | +| | | | CliErrorMapperTests · Map_EngineContractOutdated_Returns54WithUpdateEngineMessage, Map_SkillsContractOutdated_Returns55WithIntegrationsInstallMessage | pass | | +| | | | ProgramTests · RunAsync_VersionJsonExpectContract999_WritesEngineOutdatedAndReturns54, RunAsync_VersionJsonExpectContract0_WritesSkillsOutdatedAndReturns55, RunAsync_VersionJsonExpectContract1_WritesSuccessWithExpectedContract | pass | | +| AC-4 | Fehlender Wert oder keine Ganzzahl → Exit 2 beim Parsen | explicit | ExpectedContractOptionConverterTests · Convert_Null_ThrowsExpectedContractInvalidException, Convert_InvalidText_ThrowsExpectedContractInvalidExceptionWithValue, Convert_ValidText_ReturnsInt | pass | proven (executed: `null` durchgelassen; Regex akzeptiert „01“ → rot) | +| | | | CliErrorMapperTests · MapArgumentError_ExpectedContractInvalidWithoutValue_ReturnsInvalidArgumentsWithGotNone, MapArgumentError_ExpectedContractInvalidWithValue_ReturnsInvalidArgumentsNamingValue | pass | | +| | | | ProgramTests · RunAsync_VersionJsonExpectContractNotANumber_WritesInvalidArgumentsAndReturns2, RunAsync_VersionExpectContractWithoutValue_WritesInvalidArgumentsAndReturns2 | pass | | +| AC-5 | `--expect`, `EngineVersionChecker`, Prerelease-Warnung und deren Codes entfernt | explicit | ShadeKitCliExitCodesTests · ExitCodes_Contract_HaveStableValues, ExitCodes_AllConstants_DoNotDefineRemovedVersionMismatch50 | pass | proven (executed: `VersionMismatch = 50` wieder eingefügt; `--expect 0.9.0` in einer Befehlsliste → rot) | +| | | | ShadeKitCliErrorCodesTests · ForExitCode_ContractExitCodes_ReturnsContractErrorCodes, ForExitCode_UndefinedExitCode_ThrowsArgumentOutOfRangeException(50) | pass | | +| | | | ShadeKitCliWarningCodesTests · WarningCodes_AllConstants_DoNotContainRemovedPrereleaseVersionMismatch | pass | | +| | | | VersionCommandOptionsTests · Options_ExpectOption_DoesNotExist, Options_ExpectContract_HasConverterAndLongName; ProgramTests · RunAsync_VersionJsonExpectOldOption_IsNotChecked | pass | | +| AC-6 | Mit `--expect-contract` keine Abfrage der Integrationen | explicit (im Bericht „optional“) | VersionCommandTests · ExecuteAsync_ExpectContract_DoesNotReadIntegrationsAndOmitsField, ExecuteAsync_ContractMismatch_DoesNotReadIntegrations, ExecuteAsync_PlainModeExpectContract_WritesNoIntegrationLines, ExecuteAsync_JsonModeWithoutExpectContract_WritesIntegrations; ProgramTests · RunAsync_VersionJsonExpectContract1_… | pass | proven (executed: Integrationsabfrage im Handshake-Pfad ergänzt → rot) | +| AC-7 | 5 Handshakes und 2 Befehlslisten im neuen Wortlaut; Reaktion auf die neuen Codes; Ablehnungszeilen in `shade-kit-next-steps`; `metadata.version` in allen 19 Skills entfernt | explicit | Core.Tests/Skills/SkillContractTests · SkillFiles_ShippedSkills_NameTheCurrentCliContractEverywhere; ShippedSkillsTests, SkillAgentWordingTests, SingleSkillSourceTests; Szenarien S18/S19 | pass | proven (executed: Handshake auf 2, Befehlsliste auf `--expect 0.9.0`, `metadata.version` wieder eingefügt → rot) | +| AC-8 | `SkillContractTests` statt `SkillKitVersionTests` | explicit | SkillContractTests (Real-Tree-Test plus 19 Fixture-Tests bzw. Theories) | pass | proven (executed: `Current = 2`; Handshake geändert → rot) | +| AC-9 | Snapshot-Test der Vertragsoberfläche | explicit („Vorschlag“) | — | — | dropped (D-12); offener Punkt in `docs/feature-packages/README.md` | +| AC-10 | Szenario-Tooling: R aus dem Handshake-Text, erstes Kommando `--expect-contract `, Fixtures für „Engine zu alt“ und „Skills zu alt“ | explicit | `generate_fixtures.py`; `checks/check_runs.py --only S18,S19` auf den echten Runs (22/22) und auf handgeschriebenen Varianten | pass | Checker: proven (executed: MD1–MD9 → jede Variante rot). Generator: read-checked — not executed | +| AC-11 | `GitVersion.yml`: Kommentar beschreibt nur die Produktrolle, `next-version` bleibt | explicit | Diff (nur Kommentar), Build grün | pass | read-checked — not executed (nur Doku) | +| AC-12 | Lockstep-Formulierungen in CLAUDE.md, Feature-Paketen, Konzept §9.6 und Konsistenzlog ersetzt | explicit | grep, Stichproben gegen den Code | pass | read-checked — not executed (nur Doku) | +| AC-13 | E2E-Tests für den Ablehnungspfad ohne Tag und ohne Release-Build | implicit | ProgramTests · …ExpectContract999…, RunAsync_VersionPlainExpectContract999_…, …ExpectContract0…; IntegrationsCommandsEndToEndTests · Version_ExpectContractMismatchWithInstalledIntegration_Exits54WithoutAskingClaude | pass | proven (executed: `Check(Current)` statt `Check(R)` → rot) | +| AC-14 | `data.expectedContract` gibt den geprüften Wert zurück | implicit | VersionCommandTests · ExecuteAsync_JsonModeExpectContract_WritesExpectedContract, ExecuteAsync_JsonModeWithoutExpectContract_OmitsExpectedContract, ExecuteAsync_JsonModeExpectContractWithRealChecker_SucceedsForEveryContractInWindow | pass | proven (executed: `Math.Min(R, Current)` → rot) | + +## 4. Decisions + +| ID | Point | Decision | Origin | Round | +|---|---|---|---|---| +| D-1 | Arbeitsbaum | Rename zuerst committen, danach sauber | recommended accepted | — | +| D-2 | G-4 Integrationen überspringen | Bei `--expect-contract` keine Abfrage, `data.integrations` fehlt; Plain-Modus und `version` ohne Option listen weiter | recommended accepted | 1 | +| D-3 | G-5 `metadata.version` | Aus allen 19 Skills entfernen, Regel aus CLAUDE.md und 06-2 streichen | recommended accepted | 1 | +| D-4 | G-10 `research_notes/` | Unangetastet lassen | recommended accepted | 1 | +| D-5 | 1 Struktur | Wie im Bericht: Core/Versions(+Exceptions), Cli/Commands/Version, Core.Tests/Skills | recommended accepted | 1 | +| D-6 | G-6 Doku | Feature-Pakete vor Ort umschreiben, Ersetztes datiert behalten, ein Eintrag im Konsistenzlog | recommended accepted | 1 | +| D-7 | 2 Architektur | Statisches `CliContract`; `ICliContractChecker`/`CliContractChecker(CliContractWindow)` als Singleton mit `CliContract.Window` | recommended accepted | 1 | +| D-8 | 3 Benennung | `EngineContractOutdatedException` und `SkillsContractOutdatedException`; `ExpectedContractOptionConverter` mit einer `ExpectedContractInvalidException` | recommended accepted | 1 | +| D-9 | 4 API-Vertrag / G-2 / G-8 | `data.contract {current, minSupported}`, `data.expectedContract`; Exit 54 `engine-outdated`, 55 `skills-outdated`; 50 und `version-mismatch` entfallen; Plain-Zeile `CLI contract 1 (supported: 1 to 1)` | recommended accepted | 1 | +| D-10 | G-1 Übergang alte Engine | Risiko akzeptiert: Skills prüfen `data.contract` nicht | user's own | 1 | +| D-11 | G-11 Übergang alte Skills | `--expect` ganz entfernen (kein Tombstone) | user's own | 1 | +| D-12 | G-3 Snapshot | Kein Snapshot-Test; offener Punkt im README: nach v1 neu entscheiden | user's own | 1 | +| D-13 | G-7 Szenarien | Pflichtteil plus Fehler-Fixtures (999, 0) plus S18/S19 plus Subagent-Runs | user's own | 1 | +| D-14 | Wortlaut-Guard | `SkillContractTests` prüft Zahlen, Altlasten und den kanonischen Satz in 5 festen Skills | recommended accepted | 1 | +| D-15 | 6 Teststrategie | Unit- und E2E-Tests (echter Parser in `ProgramTests`) | recommended accepted | 1 | +| D-16 | G-9 Wertebereich | Ganzzahl ≥ 0, nur ASCII-Ziffern, kein Vorzeichen, keine führenden Nullen | recommended accepted | 1 | +| D-17 | 7 Persistenz | n/a — `VersionCommand` nutzt keinen Kit-Store, nichts in `.shadekit/` betroffen | n/a | 1 | +| D-18 | 8 Abhängigkeiten | n/a — kein Paket geändert; Python nur Standardbibliothek | n/a | 1 | +| D-19 | Gate 2 Skills | Behalten: dotnet-fundamentals, dotnet-tester, dotnet-xmldocs, code-design, skill-creator. Gestrichen: api-and-interface-design, deprecation-and-migration, documentation-and-adrs. Review: dotnet-reviewer | user's own | — | +| D-20 | Gate 3 Tasks | T1–T5 bestätigt | recommended accepted | — | +| D-21 | Gate 3 Modus | Sub-Agents, streng sequenziell, ein Subagent pro Task | user's own (präzisiert) | — | +| D-22 | T1 blockiert | „Done when“ von T1 angepasst: Der FP01-AC8-Guard darf bis T2 rot sein | recommended accepted | — | +| D-23 | T4 2. FAIL | Als blockiert markiert, Lücke in `ENGINE_UPDATE` als offener Punkt (später geschlossen, siehe D-24 bis D-26) | user's own | — | +| D-24 | Gate 5 Runde 1 | M2, M4 und M5 beheben; M1, M3, S1 und N1 zurückstellen | user's own | — | +| D-25 | Gate 5 Runde 2 | M6 beheben; N2 zurückstellen | user's own | — | +| D-26 | Gate 5 Runde 3 | M7 beheben, bekannte Grenze dokumentieren (S2), Formulierungen präzisieren (N3), danach keine weitere Heuristik-Runde | recommended accepted | — | +| D-27 | Gate 5 Runde 4 | Review abgenommen; S3 und N4 zurückgestellt | recommended accepted | — | + +Waivers: keine. + +## 5. Skills + +**Laufzeit-Discovery:** rund 75 Skills und 13 Agent-Typen in der Laufzeit, 13 Kandidaten nach dem Abgleich. + +| Skill / agent | Category | Proposed use | Outcome | +|---|---|---|---| +| cc-ai-dotnet:dotnet-fundamentals | knowledge (baseline) | Code-Tasks | kept | +| cc-ai-dotnet:dotnet-tester | tester | alle Tasks | kept | +| cc-ai-dotnet:dotnet-xmldocs | documentation | öffentliche Typen | kept | +| cc-ai-dev:code-design | knowledge | Code-Tasks | kept | +| skill-creator:skill-creator | knowledge | Skill- und Szenario-Tasks | kept | +| agent-skills:api-and-interface-design | knowledge | Engine-Task | dropped by user (D-19) | +| agent-skills:deprecation-and-migration | knowledge | Entfernen von `--expect` | dropped by user (D-19) | +| agent-skills:documentation-and-adrs | documentation | Doku-Task | dropped by user (D-19) | +| cc-ai-dotnet:dotnet-nuget-manager | tooling | — | stayed excluded (D-18) | +| agent-skills:test-driven-development | knowledge | — | stayed excluded (überschneidet sich mit dotnet-tester) | +| cc-ai-dotnet:dotnet-dev | workflow | excluded — nested workflow | stayed excluded | +| cc-ai-dotnet:dotnet-reviewer | reviewer | review | used in Phase 5 (4 Runden) | +| agent-skills:code-reviewer | review agent | Ausweichlösung | not needed | + +**Zuordnung (Gate 3) und tatsächlich geladen:** + +| Task | Mapped skills | Loaded by implementer | Confirmed by verifier | +|---|---|---|---| +| T1 Core-Vertrag | dotnet-fundamentals, dotnet-tester, dotnet-xmldocs, code-design | alle 4 (Turn 1) | V1 ok (berichtbasiert) | +| T2 CLI-Umstellung | dotnet-fundamentals, dotnet-tester, dotnet-xmldocs, code-design | alle 4 (Turn 2) | V1 ok (berichtbasiert) | +| T3 Skills und Guard | dotnet-tester, skill-creator, dotnet-fundamentals, code-design | alle 4 (Turn 2) | V1 ok (berichtbasiert) | +| T4 Szenario-Tooling | skill-creator | skill-creator (Turn 2; im Retry ebenfalls Turn 2) | V1 ok (berichtbasiert) | +| T5 Doku | — (D-19) | keine | n/a bestätigt | +| R-1 Fenster-Naht | dotnet-fundamentals, dotnet-tester, dotnet-xmldocs, code-design | alle 4 (Turn 2) | V1 ok (berichtbasiert) | +| R-2, R-3, R-4 Checker und Doku | skill-creator | skill-creator (Turn 4, 2 bzw. 2) | V1 ok (berichtbasiert) | + +## 6. Tasks + +### Task #1 — CLI-Vertrag in Core (Status: done) + +- **Liefert:** AC-1 und AC-3 (Core-Teil). +- **Dateien:** `Core/Versions/CliContract.cs`, `CliContractWindow.cs`, `ICliContractChecker.cs`, `CliContractChecker.cs`, `Exceptions/EngineContractOutdatedException.cs`, `Exceptions/SkillsContractOutdatedException.cs`, `ShadeKitCoreServiceCollectionExtensions.cs`, dazu Tests. +- **Tests:** alle 15 geplanten grün, ohne Umbenennungen. +- **Doku:** XML-Docs. **Pakete:** n/a. +- **Implementer:** Subagent. Er meldete BLOCKED nur wegen des Guards FP01-AC8, weil dafür die Datei `CliErrorMapper` geändert werden musste, die zu T2 gehört. Daraus wurde D-22. +- **Verifier:** Subagent, PASS. +- **Smoke-Check:** n/a, nur Core betroffen. +- **Abweichungen:** keine. + +### Task #2 — CLI auf den Vertrag umstellen, alten Check entfernen (Status: done) + +- **Liefert:** AC-2, AC-3, AC-4, AC-5, AC-6, AC-13 und AC-14. +- **Dateien:** `Cli/Commands/Version/*`, `CliErrorMapper.cs`, Exit-, Error- und Warning-Codes, DI. Es wurden 7 Core-Typen und 2 CLI-Typen samt ihrer Tests gelöscht. +- **Tests:** Alle geplanten Tests sind grün. Umbenannt wurden `ExecuteAsync_JsonModeWithoutExpect_…` → `…WithoutExpectContract_WritesEnvelopeWithContractAndIntegrations`, `Ctor_NullEngineVersionChecker_…` → `Ctor_NullCliContractChecker_…` und `Version_ExpectMismatchWithInstalledIntegration_StillExits50` → `Version_ExpectContractMismatchWithInstalledIntegration_Exits54WithoutAskingClaude`. +- **Doku:** XML-Docs. **Pakete:** n/a. +- **Implementer und Verifier:** je ein Subagent, PASS. +- **Smoke-Check:** `--expect-contract 1/999/0/abc` → Exit 0/54/55/2. Die Plain-Zeile zeigt den Vertrag. +- **Abweichungen:** Zwei bestehende Plain-E2E-Tests erwarten jetzt die Vertragszeile. Ein Integrations-E2E-Test prüft jetzt 999 → 54. + +### Task #3 — Skills und `SkillContractTests` (Status: done) + +- **Liefert:** AC-7 und AC-8. +- **Dateien:** 19 `skills/*/SKILL.md`, `SkillContractTests.cs` neu, `SkillKitVersionTests.cs` gelöscht. +- **Tests:** 34 Fälle grün. Der Fall „Handshake-Skill fehlt“ wurde als eigener Test abgespalten. +- **Validierung:** `quick_validate.py` meldet 19/19 gültig. +- **Implementer und Verifier:** je ein Subagent. Der Verifier gab PASS und hat dabei 7 echte Mutationen der Skills gemacht und danach wiederhergestellt. +- **Smoke-Check:** `version --json --expect-contract 1` → ok. +- **Abweichungen:** Der Finder ist `internal static` in der Testklasse. `--expected` wird nicht als altes `--expect` gemeldet. + +### Task #4 — Szenario-Tooling (Status: done, vorübergehend blocked per D-23) + +- **Liefert:** AC-10. +- **Dateien:** `generate_fixtures.py`, `SCENARIOS.md` (S18, S19), `checks/check_runs.py`, `README.md`. +- **Implementer:** ein Subagent, dann ein Retry. **Verifier:** FAIL, Retry, erneut FAIL. Nach dem zweiten FAIL markierte der Nutzer den Task als blockiert (D-23). Die Lücke in `ENGINE_UPDATE` wurde in R-2, R-3 und R-4 geschlossen. +- **Runner-Subagents:** S18 und S19 liefen mit der README-Vorlage. Der Checker meldet 22/22. +- **Smoke-Check:** Generatorlauf mit Exit 0, `CLI contract: 1`. +- **Abweichungen:** keine außerhalb der Dateien. + +### Task #5 — Doku und GitVersion-Kommentar (Status: done) + +- **Liefert:** AC-11 und AC-12, D-6 und D-12. +- **Dateien:** `GitVersion.yml` (nur der Kommentar), `CLAUDE.md`, 14 Feature-Pakete und `README.md`, `research/shade-kit-concept.md`. +- **Implementer:** ein Subagent, dann ein Retry. **Verifier:** zuerst FAIL wegen 01:74 „always-present `integrations`“, nach dem Retry ein neuer Verifier mit PASS. +- **Smoke-Check:** Die dokumentierten Aussagen wurden ausgeführt: `--expect-contract=999` → Exit 0 ohne Prüfung, `--expect 0.1.0` → Exit 0. +- **Abweichung im Brief:** Zwei Tests tragen weiterhin `FP06-1-AC6`. In 06-1 ist das korrekt dokumentiert. + +### R-1 — Fenster aus einer Quelle (Befund M2) · R-2 — ENGINE_UPDATE und Runs-Eintrag (M4, M5) · R-3 — ENGINE_UPDATE über alle Phrasen (M6) · R-4 — Aufrufform, bekannte Grenze, Wortlaut (M7, S2, N3) + +- **R-1:** `ICliContractChecker.Window`. `VersionCommand` meldet das Fenster des Checkers. Es gibt zwei neue Tests mit dem Fenster (2, 4). Verifier PASS, M7b und M7c werden rot. +- **R-2 bis R-4:** Die Heuristik in `check_runs.py` ordnet die gesammelten 44 Phrasen richtig ein, und die Aufrufform `$shade-kit:` zählt nicht als Werkzeug. Der Runs-Eintrag vom 2026-11-22 ist ergänzt, D-23 ist in 06-1 und im README datiert geschlossen, und die bekannte Grenze ist dokumentiert. Jeder Rework hatte einen eigenen Verifier, alle mit PASS. + +## 7. Review + +Reviewer: `cc-ai-dotnet:dotnet-reviewer` als Subagent. Taxonomie: Critical, Major, Minor, Suggestion, Nitpick. + +| Round | Report | Critical | Major | Minor | Suggestion / Nitpick | Rework done | Minor selected | Deferred | +|---|---|---|---|---|---|---|---|---| +| 1 | docs/reviews/2026-11-22-feature-rework-versioning-branch-mgmt-uncommitted.md | 0 | 0 | 5 | 1 / 1 | R-1 (M2), R-2 (M4, M5) | M2, M4, M5 | M1, M3, S1, N1 (D-24) | +| 2 | …-uncommitted-round-2.md | 0 | 0 | 1 | 0 / 1 | R-3 (M6) | M6 | N2 (D-25) | +| 3 | …-uncommitted-round-3.md | 0 | 0 | 1 | 1 / 1 | R-4 (M7, S2, N3) | M7 (+ S2, N3) | — | +| 4 | …-uncommitted-round-4.md | 0 | 0 | 0 | 1 / 1 | — | — | S3, N4 (D-27) | + +**Anforderungstreue laut Teil B:** + +| Round | Proven (executed) | Read-checked | Unproven | Gestrichen | Decision departures | Scope findings | +|---|---|---|---|---|---|---| +| 1 | 10 | 3 | 0 (AC-2-Werte: teilweise unproven) | 1 | 0 | 0 | +| 2 | 11 | 2 | 0 | 1 | 0 | 0 | +| 3 | 11 | 2 | 0 | 1 | 0 | 0 | +| 4 | 10 | 2 | 0 | 1 | 0 | 0 | + +In den Runden 2 bis 4 ist AC-10 gemischt: Der Checker-Teil ist proven, der Generator-Teil nur read-checked. + +**Wiederholte Befunde:** Die `ENGINE_UPDATE`-Heuristik hatte Befunde in T4 (zweimal), in Runde 1 (M4), in Runde 2 (M6) und in Runde 3 (M7, eine Regression aus R-3). Ursache ist der Ansatz, eine Regex über freien Text. Seit R-4 ist das als bekannte Grenze dokumentiert, und nach D-26 wird die Heuristik nicht weiter erweitert. + +## 8. Verify Before Committing + +- **`--expect` wird jetzt still ignoriert (D-11).** Skills, die vor dieser Änderung installiert wurden, bestehen gegen die neue Engine ohne Prüfung. Siehe `ProgramTests.RunAsync_VersionJsonExpectOldOption_IsNotChecked`. +- **Alte Engines prüfen nichts (D-10).** Eine Engine von vor dieser Änderung antwortet auf `--expect-contract` mit `ok:true`, ohne zu prüfen. Die Skills prüfen `data.contract` nicht. +- **`--expect-contract=999`, also die Form mit Gleichheitszeichen, wird vom Parser ignoriert** und liefert Exit 0. `SkillContractTests` akzeptiert diese Form bislang (Befund M1, zurückgestellt). Achte bei neuen Skill-Texten darauf. +- **Kein Snapshot-Test (D-12).** Wer die für Skills sichtbare CLI-Oberfläche ändert, muss `CliContract.Current` von Hand anheben. Offener Punkt in `docs/feature-packages/README.md`. +- **Exit-Code 50 ist frei**, `version-mismatch` und `engine-prerelease-version-mismatch` gibt es nicht mehr. Das ist in `ShadeKitCliExitCodes.cs`, `ShadeKitCliErrorCodes.cs` und `ShadeKitCliWarningCodes.cs` sichtbar. +- **`docs/feature-packages/06-1-engine-version-check.md` ist neu geschrieben.** Der alte Text steht als datierter Abschnitt „Replaced on 2026-11-22 … (history)“ darin. +- **`tests/skill-scenarios/checks/check_runs.py:32-57`** ist eine dokumentierte Heuristik mit bekannter Grenze. Ein FAIL in S18/S19 ist gegen den Abschlusstext zu lesen. +- **Neue Review-Berichte** liegen in `docs/reviews/`, vier Dateien. Entscheide, ob du sie committen willst. + +## 9. Open Items + +**Zurückgestellte Befunde:** + +| Befund | Runde | Entscheidung | Inhalt | +|---|---|---|---| +| M1 | 1 | D-24 | `SkillContractTests` akzeptiert `--expect-contract=`, das die Engine ignoriert | +| M3 | 1 | D-24 | FP06-1-AC1 bis AC5 haben keine Tests mit `[Trait("Requirement", …)]` | +| S1 | 1 | D-24 | Vertragsnummer 1 ist in einigen Tests fest eingetragen; die Anleitung zum Anheben in CLAUDE.md nennt diese Stellen nicht | +| N1 | 1 | D-24 | Ein fehlender kanonischer Satz wird auf Zeile `:1:` gemeldet | +| N2 | 2 | D-25 | `Window_Constructed_ReturnsWindowOfConstructor` testet nur einen trivialen Getter | +| S3 | 4 | D-27 | `:\S` in `_TOOL` ist breiter als dokumentiert; Vorschlag `:\w` | +| N4 | 4 | D-27 | Der `_TOOL`-Kommentar nennt den Bindestrich nicht | + +**Offene Punkte in `docs/feature-packages/README.md`:** +- (a) Snapshot-Test nach Abschluss von v1 neu entscheiden (D-12). +- (b) Lücke im Szenario-Checker (D-23): in Review-Runde 1 geschlossen und in Runde 2 verfeinert. +- (c) `shade-kit-next-steps` Schritt 5.3 regelt nicht den Fall, dass `phase next` nie lief. Beide Runner haben diesen Teil ausgelassen. + +**Blockierte Tasks:** keine mehr. T4 war vorübergehend blockiert (D-23). + +**Skills, die nicht geladen werden konnten:** keine. + +**Nicht ausgeführt:** Die 17 bestehenden Szenarien S1 bis S17 wurden nach der Änderung des Handshakes nicht neu durchgespielt. Nur S18 und S19 liefen (D-13). + +## 10. Final Verification + +- **Build:** `dotnet build` → 0 Warnungen, 0 Fehler. +- **Gesamtsuite:** `dotnet test` → 6440 total, 6432 passed, 0 failed, 8 skipped (nur unter Windows). +- **Smoke-Check:** `dotnet run --project src/CreativeCoders.ShadeKit.Cli -- version --json --expect-contract 1/999/0/abc` → Exit 0/54/55/2. `version` zeigt `CLI contract 1 (supported: 1 to 1)`. +- **Szenario-Checker:** `check_runs.py --only S18,S19` → 22/22. +- **Geänderte Dateien:** 89 Einträge in `git status --porcelain`, einschließlich dieses Berichts: + - 59 geändert + - 13 gelöscht + - 15 neue Code- und Testdateien + - `docs/reviews/` (4 Berichte) + - dieser Bericht + +## 11. Skill-Invocation Log + +``` +Task #1 — CLI-Vertrag in Core + [x] cc-ai-dotnet:dotnet-fundamentals — vor dem ersten Write von CliContractTests.cs (Implementer Turn 1; Verifier V1 ok) + [x] cc-ai-dotnet:dotnet-tester — Turn 1, vor dem ersten Write (Verifier V1 ok) + [x] cc-ai-dotnet:dotnet-xmldocs — Turn 1, vor dem ersten Write (Verifier V1 ok) + [x] cc-ai-dev:code-design — Turn 1, vor dem ersten Write (Verifier V1 ok) +Task #2 — CLI-Umstellung + [x] cc-ai-dotnet:dotnet-fundamentals — Turn 2, vor dem ersten Write/rm (Verifier V1 ok) + [x] cc-ai-dotnet:dotnet-tester — Turn 2 (Verifier V1 ok) + [x] cc-ai-dotnet:dotnet-xmldocs — Turn 2 (Verifier V1 ok) + [x] cc-ai-dev:code-design — Turn 2 (Verifier V1 ok) +Task #3 — Skills und Guard + [x] cc-ai-dotnet:dotnet-tester — Turn 2, erster Write in Turn 5 (Verifier V1 ok) + [x] skill-creator:skill-creator — Turn 2 (Verifier V1 ok) + [x] cc-ai-dotnet:dotnet-fundamentals — Turn 2 (Verifier V1 ok) + [x] cc-ai-dev:code-design — Turn 2 (Verifier V1 ok) + [n/a] cc-ai-dotnet:dotnet-xmldocs — keine öffentliche API: Die Testklasse und ihr Finder sind nicht öffentlich +Task #4 — Szenario-Tooling + [x] skill-creator:skill-creator — Turn 2, erster Write in Turn 7; im Retry Turn 2, erster Write in Turn 6 (Verifier V1 ok) + [n/a] .NET-Skills — kein C# geändert, nur Python und Markdown unter tests/skill-scenarios/ +Task #5 — Doku und GitVersion.yml + [n/a] keine Skills zugeordnet — documentation-and-adrs vom Nutzer gestrichen (D-19), Code-Skills gelten nicht für Dokumente +R-1 — Fenster-Naht (M2) + [x] cc-ai-dotnet:dotnet-fundamentals — Turn 2, vor dem ersten Write (Verifier V1 ok) + [x] cc-ai-dotnet:dotnet-tester — Turn 2 (Verifier V1 ok) + [x] cc-ai-dotnet:dotnet-xmldocs — Turn 2 (Verifier V1 ok) + [x] cc-ai-dev:code-design — Turn 2 (Verifier V1 ok) +R-2 — ENGINE_UPDATE und Runs-Eintrag (M4, M5) + [x] skill-creator:skill-creator — Turn 4, erster Write in Turn 6 (Verifier V1 ok) +R-3 — ENGINE_UPDATE über alle Phrasen (M6) + [x] skill-creator:skill-creator — Turn 2, vor dem ersten Write (Verifier V1 ok) +R-4 — Aufrufform, bekannte Grenze, Wortlaut (M7, S2, N3) + [x] skill-creator:skill-creator — Turn 2, vor dem ersten Write (Verifier V1 ok) +``` + +Hinweis: Die Reihenfolge der Skill-Aufrufe stammt aus den Berichten der Implementer. Die Verifier konnten die Transkripte nicht einsehen und haben V1 jeweils als berichtbasiert bestätigt. Sie haben dieselben Skills selbst geladen, bevor sie Code lasen. diff --git a/research/shade-kit-concept.md b/research/shade-kit-concept.md index a587030..8d963f5 100644 --- a/research/shade-kit-concept.md +++ b/research/shade-kit-concept.md @@ -1,6 +1,6 @@ # SHADE kit concept -Status: draft, 2026-10-13, updated 2026-10-17 (template interview), 2026-10-18 (consistency review: skills without router, `quick` phase, version-drift decisions moved into section 9; findings clarification: package changes confirmed and taken over), 2026-10-21 (feature commands implemented, package 03), 2026-10-24 (documentation check against the code), 2026-10-25 (rework of `feature new`), 2026-10-27 (documentation check after package 04: phase commands and phase states implemented, phase state diagram completed), 2026-10-30 (phases start only when the user calls the phase skill; [shade-kit-phase-start-analysis.md](shade-kit-phase-start-analysis.md)), 2026-11-01 (package 05 implemented: gates from `gates.json`, checklist copies), 2026-11-13 (package 07 implemented: this repository is the Claude Code plugin marketplace, the engine installs from the tag of its version, or from `main` with a warning when that tag does not exist), 2026-11-14 (package 07 review rework: the skills' kit version is checked against the build version by a test), and 2026-11-15 (package 08 research: Copilot and Codex install the same plugin through their own CLI from the same marketplace; one skill source for all three agents; open question 5 answered; [shade-kit-agent-compatibility.md](shade-kit-agent-compatibility.md); package 08 implemented: `integrations install` and `update` for Copilot and Codex). Result of an interview on the original working notes. Design notes only; nothing here is shipped. +Status: draft, 2026-10-13, updated 2026-10-17 (template interview), 2026-10-18 (consistency review: skills without router, `quick` phase, version-drift decisions moved into section 9; findings clarification: package changes confirmed and taken over), 2026-10-21 (feature commands implemented, package 03), 2026-10-24 (documentation check against the code), 2026-10-25 (rework of `feature new`), 2026-10-27 (documentation check after package 04: phase commands and phase states implemented, phase state diagram completed), 2026-10-30 (phases start only when the user calls the phase skill; [shade-kit-phase-start-analysis.md](shade-kit-phase-start-analysis.md)), 2026-11-01 (package 05 implemented: gates from `gates.json`, checklist copies), 2026-11-13 (package 07 implemented: this repository is the Claude Code plugin marketplace, the engine installs from the tag of its version, or from `main` with a warning when that tag does not exist), 2026-11-14 (package 07 review rework: the skills' kit version is checked against the build version by a test), 2026-11-15 (package 08 research: Copilot and Codex install the same plugin through their own CLI from the same marketplace; one skill source for all three agents; open question 5 answered; [shade-kit-agent-compatibility.md](shade-kit-agent-compatibility.md); package 08 implemented: `integrations install` and `update` for Copilot and Codex), and 2026-11-22 (the version lockstep of skills and CLI replaced by the CLI contract, section 9.6). Result of an interview on the original working notes. Design notes only; nothing here is shipped. Labels used in this document: @@ -66,7 +66,7 @@ SHADE kit keeps what worked (interviews, draft → approve, requirement-to-test | `shade-kit integrations update` | Updates the user-level integration to the installed kit version. **Implemented** for Claude Code (`IntegrationsUpdateCommand`, package 07), GitHub Copilot CLI, and OpenAI Codex CLI (package 08). | | `shade-kit init` | Creates `.shadekit/` in a repository: `config.json`, `gates.json`, templates, `templates.lock.json`, `.gitignore` entries, and a short SHADE kit section in `CLAUDE.md` / `AGENTS.md`. **Implemented** (`InitCommand`). Copilot and Codex both read `AGENTS.md`, so no further instruction file is needed; Copilot also reads `CLAUDE.md` and loads the section twice (accepted, known limit). **Decided** on 2026-11-15 (package 08 research, [shade-kit-agent-compatibility.md](shade-kit-agent-compatibility.md)). | | `shade-kit upgrade` | Migrates an initialised repository to the current format versions. Rules in [section 9](#9-version-drift). | -| `shade-kit version` | Prints the engine version and the installed integrations; with `--json` also the current format version per file type. **Implemented** (`VersionCommand`; integrations since package 07). Skills call it before they run (section 9.6). | +| `shade-kit version` | Prints the engine version, the supported CLI contracts, and the installed integrations; with `--json` also the current format version per file type. With `--expect-contract ` it checks the CLI contract of the calling skill and does not read the integrations. **Implemented** (`VersionCommand`; integrations since package 07; CLI contract since 2026-11-22, package 06-1). Skills call it before they run (section 9.6). | | `shade-kit feature list` | Lists the features in the store with id, title, profile, and status. **Implemented** (`FeatureListCommand`). | Skills and agent files are not written into the repository (section 9.6, confirmed in the interview). The repository only holds kit data and the short instruction section. @@ -115,7 +115,7 @@ The split between `refine` and `map` is **proposed**: `refine` deals with the re ### 3.4 Distribution - CLI as a `dotnet` global tool and as self-contained single-file binaries (see `CLAUDE.md`). An installer script for the binaries is **proposed**. -- Plugin and CLI are released together under one version number and check each other's version (section 9.6). +- Plugin and CLI are released together under one version number and check each other's version (section 9.6). Replaced on 2026-11-22 ([CLI contract report](../reports/versioning-cli-and-skills.md)): plugin and CLI are released together from one tag; their compatibility is checked by the number of the CLI contract, not by the product version (section 9.6). - The plugin is not packed into the engine release: this repository is the Claude Code plugin marketplace (`.claude-plugin/`), and the release tag that builds the engine is the ref the engine installs from. **Decided** on 2026-11-13 (package 07 implementation). - Claude Code: plugin. Copilot: plugin if available, otherwise user directory. Codex: user directory. **Unverified:** whether Copilot and Codex can load the same `SKILL.md` format and support subagents and hooks. This decides how much of the content can be shared unchanged, and has to be researched before the integration work starts. Replaced on 2026-11-15 (package 08 research, [shade-kit-agent-compatibility.md](shade-kit-agent-compatibility.md)): Claude Code, Copilot, and Codex all install the plugin through their own CLI from this repository at the same ref. Copilot and Codex load the `SKILL.md` format and find the `.claude-plugin/` manifests, so one skill source and the same manifests serve all three agents, with no install-time transformation; both support parallel subagents. Call forms and tool names differ per agent and are named in the skill texts. **Decided** on 2026-11-15 (package 08, Gate 2). Hooks are not part of v1 and were not researched. @@ -354,8 +354,8 @@ An engine writes back every field it does not know, unchanged. Changes that only ### 9.6 Skills stay out of the repository; plugin and CLI release together - Skills and agent files are installed at user level, never written into the target repository. -- Plugin content and CLI share one version number. A skill checks `shade-kit version` before it runs. -- The integration content is packed into the engine release, so an engine always installs the content of its own version (package 07). **Decided** on 2026-10-18. Replaced on 2026-11-13 (package 07 implementation): the engine contains no content; this repository is the Claude Code plugin marketplace, and an engine installs the tree of its own tag `v` (a prerelease engine, and a release engine whose tag does not exist, installs from `main`). **Decided** on 2026-11-13. **Implemented** (`IntegrationService`). The skills' `metadata.version` is still raised by hand (package 06-2); since 2026-11-14 a guard test fails every build whose skills carry another major.minor than the engine version of the build, the tag build included (`SkillKitVersionTests`, package 07). **Decided** on 2026-11-14 (package 07 review rework). +- Plugin content and CLI share one version number. A skill checks `shade-kit version` before it runs. Replaced on 2026-11-22 ([CLI contract report](../reports/versioning-cli-and-skills.md); the shared version tied every skill change to a product minor and to GitVersion, and a prerelease engine was not checked): plugin content and CLI are still released together from one tag `v`, but their compatibility is checked by the CLI contract, an integer independent of the product version. The engine supports a window of contracts (`CliContract.MinSupported` to `CliContract.Current`, both `1`), and a skill checks `shade-kit version --json --expect-contract ` before it runs, with the contract it is written for; outside the window the call fails with `engine-outdated` (54) or `skills-outdated` (55). **Decided** on 2026-11-22. **Implemented** (`CliContract`, `CliContractChecker`, `VersionCommand`; package 06-1). +- The integration content is packed into the engine release, so an engine always installs the content of its own version (package 07). **Decided** on 2026-10-18. Replaced on 2026-11-13 (package 07 implementation): the engine contains no content; this repository is the Claude Code plugin marketplace, and an engine installs the tree of its own tag `v` (a prerelease engine, and a release engine whose tag does not exist, installs from `main`). **Decided** on 2026-11-13. **Implemented** (`IntegrationService`). The skills' `metadata.version` is still raised by hand (package 06-2); since 2026-11-14 a guard test fails every build whose skills carry another major.minor than the engine version of the build, the tag build included (`SkillKitVersionTests`, package 07). **Decided** on 2026-11-14 (package 07 review rework). Replaced on 2026-11-22 (CLI contract, see above): the skills carry no `metadata.version`; the guard `SkillContractTests` fails every build whose handshake texts name another contract than `CliContract.Current`, with no dependency on GitVersion (package 06-2). ### Why per-file versions diff --git a/skills/shade-kit-diagnose/SKILL.md b/skills/shade-kit-diagnose/SKILL.md index f47192e..626cb77 100644 --- a/skills/shade-kit-diagnose/SKILL.md +++ b/skills/shade-kit-diagnose/SKILL.md @@ -1,8 +1,6 @@ --- name: shade-kit-diagnose description: SHADE kit phase skill for `diagnose` (bugfix profile). Reproduces the reported bug, finds and proves its root cause, and writes diagnosis.md plus a spec.md with the expected behaviour. Use when the user wants to diagnose, reproduce, or find the root cause of the bug of the current SHADE kit feature. Runs only when the user calls it by name (`/shade-kit-diagnose`); never load it on your own or from another skill. -metadata: - version: 0.9.0 --- # shade-kit-diagnose diff --git a/skills/shade-kit-discuss/SKILL.md b/skills/shade-kit-discuss/SKILL.md index 45aa200..3965493 100644 --- a/skills/shade-kit-discuss/SKILL.md +++ b/skills/shade-kit-discuss/SKILL.md @@ -1,8 +1,6 @@ --- name: shade-kit-discuss description: SHADE kit free brainstorming on any topic (an idea, a design question, a problem), with or without a current feature. Writes discussion notes that can feed a new feature or a refine round. Use when the user wants to discuss, brainstorm, or think something through in a SHADE kit repository. Runs only when the user calls it by name (`/shade-kit-discuss`) or asks for it; never load it on your own or from another skill. -metadata: - version: 0.9.0 --- # shade-kit-discuss @@ -15,9 +13,9 @@ Keep every `warnings` entry (`{ code, message }`) of every CLI call of this run. ## Flow -1. Version handshake: run `shade-kit version --json --expect 0.9.0`; 0.9.0 is the kit version of this skill (`metadata.version` in its frontmatter). - - `ok` is `true`: continue. A warning `engine-prerelease-version-mismatch` means that a prerelease engine is used although its major or minor version differs; keep it like every warning and continue. - - `ok` is `false` (for example `version-mismatch`), or the shell reports that `shade-kit` is not found: stop before any other CLI call. End ([Ending](#ending)) with **refusal** and the failure envelope, or with "`shade-kit` not found". +1. Version handshake: run `shade-kit version --json --expect-contract 1`; 1 is the CLI contract this skill is written for. + - `ok` is `true`: continue. + - `ok` is `false` (for example `engine-outdated` or `skills-outdated`), or the shell reports that `shade-kit` is not found: stop before any other CLI call. End ([Ending](#ending)) with **refusal** and the failure envelope, or with "`shade-kit` not found". 2. **Context:** run `shade-kit feature current --json`. No feature is needed. A failure envelope (for example `kit-root-not-found` without `.shadekit/`, where the notes would be written): end with **refusal** and the envelope, before the discussion. Otherwise decide where the notes go: - `resolved` is `true` and `feature.status` is `active`: the notes belong to that feature. Folder: `discussions/` in `feature.paths.featureDir` (for example `.shadekit/features//discussions/`); Feature: the id; Request: the link `../request.md`. - Not resolved, or the feature is `done`: the notes belong to no feature, because a finished feature gets no further refine round. Folder: `.shadekit/discussions/`; Feature: `none`; no Request link. diff --git a/skills/shade-kit-drop/SKILL.md b/skills/shade-kit-drop/SKILL.md index 2f7df4a..4e1f266 100644 --- a/skills/shade-kit-drop/SKILL.md +++ b/skills/shade-kit-drop/SKILL.md @@ -1,8 +1,6 @@ --- name: shade-kit-drop description: SHADE kit skill to drop a feature from any phase. Deletes the feature after explicit confirmation and clears the local override only if it points to the dropped feature. Use when the user wants to drop, cancel, abandon, or delete a SHADE kit feature. Runs only when the user calls it by name (`/shade-kit-drop`) or asks for it; never load it on your own or from another skill. -metadata: - version: 0.9.0 --- # shade-kit-drop @@ -15,9 +13,9 @@ Keep every `warnings` entry (`{ code, message }`) of every CLI call of this run. ## Flow -1. Version handshake: run `shade-kit version --json --expect 0.9.0`; 0.9.0 is the kit version of this skill (`metadata.version` in its frontmatter). - - `ok` is `true`: continue. A warning `engine-prerelease-version-mismatch` means that a prerelease engine is used although its major or minor version differs; keep it like every warning and continue. - - `ok` is `false` (for example `version-mismatch`), or the shell reports that `shade-kit` is not found: stop before any other CLI call. End ([Ending](#ending)) with **refusal** and the failure envelope, or with "`shade-kit` not found". +1. Version handshake: run `shade-kit version --json --expect-contract 1`; 1 is the CLI contract this skill is written for. + - `ok` is `true`: continue. + - `ok` is `false` (for example `engine-outdated` or `skills-outdated`), or the shell reports that `shade-kit` is not found: stop before any other CLI call. End ([Ending](#ending)) with **refusal** and the failure envelope, or with "`shade-kit` not found". 2. **Feature:** the feature the user named (`shade-kit feature show --json` for its profile and phase), or else `shade-kit feature current --json`. If no feature is resolved, run `shade-kit feature list --json` and ask the human which one to drop, with the agent's structured question tool (in Claude Code `AskUserQuestion`, in GitHub Copilot CLI `ask_user`, in OpenAI Codex CLI `request_user_input`, which Codex offers only in plan mode by default; without one, also in Codex outside plan mode, a plain question). No feature listed, no pick, or no answer: end with **end of work** and the line "No feature dropped." A failure envelope of any of these calls: end with **refusal** and the envelope. 3. **Preview:** `shade-kit feature drop --json` without `--yes`. The CLI deletes nothing and returns what it would delete (`dropped: false`, `files`, and `overrideAffected`: whether the local override points to this feature and would be cleared). A failure envelope (for example `feature-not-found`): end with **refusal** and the envelope. 4. **Confirm:** show the feature id, profile, and phase (from step 2) and the preview, including whether the local override would be cleared. Ask for an explicit confirmation with the structured question tool (drop it, or keep it; without the tool, a plain question). On a no, or without an answer, end with **end of work** and the line "Feature `` was not dropped." diff --git a/skills/shade-kit-finish/SKILL.md b/skills/shade-kit-finish/SKILL.md index 37a88ea..384c700 100644 --- a/skills/shade-kit-finish/SKILL.md +++ b/skills/shade-kit-finish/SKILL.md @@ -1,8 +1,6 @@ --- name: shade-kit-finish description: SHADE kit phase skill for `finish` (every profile). Checks the Definition of Done at the entry gate, optionally writes the feature report (requirements, tests, checks, approvals) with shade-kit-report, and sets the feature to done. Use when the user wants to finish, close, or complete the current SHADE kit feature. Runs only when the user calls it by name (`/shade-kit-finish`); never load it on your own or from another skill. -metadata: - version: 0.9.0 --- # shade-kit-finish diff --git a/skills/shade-kit-gate-check/SKILL.md b/skills/shade-kit-gate-check/SKILL.md index 5d8c3d3..7809353 100644 --- a/skills/shade-kit-gate-check/SKILL.md +++ b/skills/shade-kit-gate-check/SKILL.md @@ -1,8 +1,6 @@ --- name: shade-kit-gate-check description: SHADE kit general skill that checks the feature's copy of a gate checklist (Definition of Ready, Definition of Done, or a team checklist) against the feature artifacts and the code base. Sets Result and Evidence of every item, logs the run in the Check runs section, and returns pass, fail, or error to the calling skill; never approves. Loaded by the entry protocol for every gate with a checklist; not meant to be called directly. -metadata: - version: 0.9.0 --- # shade-kit-gate-check diff --git a/skills/shade-kit-implement/SKILL.md b/skills/shade-kit-implement/SKILL.md index 4d3d049..97bcfc6 100644 --- a/skills/shade-kit-implement/SKILL.md +++ b/skills/shade-kit-implement/SKILL.md @@ -1,8 +1,6 @@ --- name: shade-kit-implement description: SHADE kit phase skill for `implement` (feature and bugfix profiles). Works through tasks.md in a loop of implement, simplify, and independent review until the review has no open blockers; produces code, tests, and review.md. Bug fixes start with a failing regression test. Use when the user wants to implement the planned tasks of the current SHADE kit feature. Runs only when the user calls it by name (`/shade-kit-implement`); never load it on your own or from another skill. -metadata: - version: 0.9.0 --- # shade-kit-implement diff --git a/skills/shade-kit-interview/SKILL.md b/skills/shade-kit-interview/SKILL.md index 3c18ef8..b267e11 100644 --- a/skills/shade-kit-interview/SKILL.md +++ b/skills/shade-kit-interview/SKILL.md @@ -1,8 +1,6 @@ --- name: shade-kit-interview description: SHADE kit general skill for a structured clarification interview with the human. Asks about one topic per question with an own proposal and its alternatives, blocking topics first, records only the human's answers in the target artifact, and returns the answered, open, and dismissed topics to the calling skill. Loaded by the SHADE kit skills discuss, refine, diagnose, plan, and quick; not meant to be called directly. -metadata: - version: 0.9.0 --- # shade-kit-interview diff --git a/skills/shade-kit-map/SKILL.md b/skills/shade-kit-map/SKILL.md index 2645f50..fff3679 100644 --- a/skills/shade-kit-map/SKILL.md +++ b/skills/shade-kit-map/SKILL.md @@ -1,8 +1,6 @@ --- name: shade-kit-map description: SHADE kit phase skill for `map` (feature profile). Maps the current feature onto the code base with parallel research agents (best practice, existing architecture, affected code, don't hand-roll, security) and writes researches.md. Use when the user wants to map, analyse, or research the code base for the current SHADE kit feature. Runs only when the user calls it by name (`/shade-kit-map`); never load it on your own or from another skill. -metadata: - version: 0.9.0 --- # shade-kit-map diff --git a/skills/shade-kit-new/SKILL.md b/skills/shade-kit-new/SKILL.md index b54f41c..5285522 100644 --- a/skills/shade-kit-new/SKILL.md +++ b/skills/shade-kit-new/SKILL.md @@ -1,8 +1,6 @@ --- name: shade-kit-new description: SHADE kit phase skill for `new`. Creates a feature with a workflow profile (feature, bugfix, quick) from free text, an issue URL, a Markdown file, or discussion notes; the CLI writes request.md. Use when the user wants to start a new SHADE kit feature, bug fix, or quick change. Runs only when the user calls it by name (`/shade-kit-new`); never load it on your own or from another skill. -metadata: - version: 0.9.0 --- # shade-kit-new @@ -19,9 +17,9 @@ Keep every `warnings` entry (`{ code, message }`) of every CLI call of this run. ## Flow -1. Version handshake: run `shade-kit version --json --expect 0.9.0`; 0.9.0 is the kit version of this skill (`metadata.version` in its frontmatter). - - `ok` is `true`: continue. A warning `engine-prerelease-version-mismatch` means that a prerelease engine is used although its major or minor version differs; keep it like every warning and continue. - - `ok` is `false` (for example `version-mismatch`), or the shell reports that `shade-kit` is not found: stop before any other CLI call. End ([Ending](#ending)) with **refusal** and the failure envelope, or with "`shade-kit` not found". +1. Version handshake: run `shade-kit version --json --expect-contract 1`; 1 is the CLI contract this skill is written for. + - `ok` is `true`: continue. + - `ok` is `false` (for example `engine-outdated` or `skills-outdated`), or the shell reports that `shade-kit` is not found: stop before any other CLI call. End ([Ending](#ending)) with **refusal** and the failure envelope, or with "`shade-kit` not found". 2. **Active feature:** `shade-kit feature current --json`. A failure envelope (for example `kit-root-not-found` without `.shadekit/`): end with **refusal** and the envelope. If it resolves a feature with status `active`, tell the human in the question which feature is current (id, phase, state) and ask, with the agent's structured question tool (in Claude Code `AskUserQuestion`, in GitHub Copilot CLI `ask_user`, in OpenAI Codex CLI `request_user_input`, which Codex offers only in plan mode by default; without one, also in Codex outside plan mode, a plain question): create a new feature anyway, or end here. On "end here", or without an answer, end with **end of work** and the line "No new feature created; `` stays current." No current feature, or a `done` one: go on. Keep `resolvedFrom` for step 8. 3. **Input:** collect the requirement source: free text, an issue URL, the path of a Markdown file, or discussion notes. Discussion notes are a file in `.shadekit/discussions/` (notes written without a feature) or in the `discussions/` folder of a feature. 4. **Profile:** if the user named one, use it. Otherwise read the input (the text, or the file you were given; an issue or a web page is not read, see step 5) and propose a profile: a defect report suggests `bugfix`, a small and clear change `quick`, a new capability that needs a spec and a plan `feature`. When the input suggests none of them, propose "the repository default": the CLI then applies `defaultProfile` of the repository configuration, whose value you do not know, because you do not read the configuration. Ask with the same question tool as in step 2, with the proposal first and the other choices among `feature`, `bugfix`, `quick`, and "the repository default". diff --git a/skills/shade-kit-next-phase/SKILL.md b/skills/shade-kit-next-phase/SKILL.md index b43b18b..fa03331 100644 --- a/skills/shade-kit-next-phase/SKILL.md +++ b/skills/shade-kit-next-phase/SKILL.md @@ -1,8 +1,6 @@ --- name: shade-kit-next-phase description: "SHADE kit status and next steps. Finds the current feature, or lets the human pick one, and shows its phase and state and every possible next step with the SHADE kit skill to call for it. Advisory: starts no phase and no skill. Use when the human says 'continue', 'next phase', or 'what's next', or asks where a SHADE kit feature stands or what to do with it now." -metadata: - version: 0.9.0 --- # shade-kit-next-phase @@ -19,10 +17,10 @@ Keep every `warnings` entry (`{ code, message }`) of every CLI call of this run. ### 1. Version handshake -Version handshake: run `shade-kit version --json --expect 0.9.0`; 0.9.0 is the kit version of this skill (`metadata.version` in its frontmatter). +Version handshake: run `shade-kit version --json --expect-contract 1`; 1 is the CLI contract this skill is written for. -- `ok` is `true`: continue. A warning `engine-prerelease-version-mismatch` means that a prerelease engine is used although its major or minor version differs; keep it like every warning and continue. -- `ok` is `false` (for example `version-mismatch`), or the shell reports that `shade-kit` is not found: stop before any other CLI call. End ([Ending](#ending)) with **refusal** and the failure envelope, or with "`shade-kit` not found". +- `ok` is `true`: continue. +- `ok` is `false` (for example `engine-outdated` or `skills-outdated`), or the shell reports that `shade-kit` is not found: stop before any other CLI call. End ([Ending](#ending)) with **refusal** and the failure envelope, or with "`shade-kit` not found". ### 2. Current feature @@ -90,7 +88,7 @@ The closing message of `shade-kit-next-steps` is the end of this skill; write no ## Rules - Start no skill and no phase. Name skills; the human calls them. Do not ask which step the human wants and do not offer to run one. -- The only commands this skill runs are `shade-kit version --json --expect 0.9.0`, `shade-kit feature current --json`, `shade-kit feature list --json`, `shade-kit feature set --json`, and `shade-kit phase next --json`. Run `feature set` only after the human picked that feature in step 2. Never `phase start`, `phase approve`, `phase reject`, `phase complete`, `gate info`, `feature new`, `feature drop`, or `init`. +- The only commands this skill runs are `shade-kit version --json --expect-contract 1`, `shade-kit feature current --json`, `shade-kit feature list --json`, `shade-kit feature set --json`, and `shade-kit phase next --json`. Run `feature set` only after the human picked that feature in step 2. Never `phase start`, `phase approve`, `phase reject`, `phase complete`, `gate info`, `feature new`, `feature drop`, or `init`. - Never run a gate check and never load `shade-kit-gate-check`. Load only `shade-kit-next-steps`. - Do not derive steps from the profile and do not add or drop any: the steps are those of `phase next`, plus `/shade-kit-discuss` and `/shade-kit-drop`. - Never read or write `feature.json`, `gates.json`, or `config.json`; the state comes from the CLI. Read no artifact and write no file. diff --git a/skills/shade-kit-next-steps/SKILL.md b/skills/shade-kit-next-steps/SKILL.md index 76a8aa6..8472149 100644 --- a/skills/shade-kit-next-steps/SKILL.md +++ b/skills/shade-kit-next-steps/SKILL.md @@ -1,8 +1,6 @@ --- name: shade-kit-next-steps description: SHADE kit general skill that writes the closing message of a kit skill. Shows what the human can do now and which skill to call for it, after the end of the work, a "no", or a refused start, and shows the warnings of the CLI calls. Starts nothing. Loaded by every SHADE kit skill that ends; not meant to be called directly. -metadata: - version: 0.9.0 --- # shade-kit-next-steps @@ -92,7 +90,9 @@ The table is keyed by `error.code`; the envelope has no exit code, the numbers a | Error code (exit code) | Options to name | |---|---| -| `version-mismatch` (50), or `shade-kit` not found | What to update and how, from the message: update the engine or the kit skills so that their major and minor versions match. If `shade-kit` was not found: install the engine (the `shade-kit` dotnet global tool or the self-contained binary), make sure it is on `PATH`, then call the skill again. | +| `engine-outdated` (54) | The kit skills need a newer engine than the installed one (the message names both CLI contracts): update the engine (the `shade-kit` dotnet global tool or the self-contained binary), then call the skill again. | +| `skills-outdated` (55) | The kit skills are older than the engine supports (the message names both CLI contracts): run `shade-kit integrations install`, start a new agent session so the agent loads the new skills, then call the skill again. | +| `shade-kit` not found | Install the engine (the `shade-kit` dotnet global tool or the self-contained binary), make sure it is on `PATH`, then call the skill again. | | `kit-root-not-found` (10) | `shade-kit init` | | `kit-file-write-failed` (17) | Check the named file or folder in `.shadekit/` and its permissions, then call the skill again. | | `format-too-new` (20), `upgrade-needed` (21), `invalid-file` (22) | Update the engine, run `shade-kit upgrade`, or fix the named file. | diff --git a/skills/shade-kit-phase-entry/SKILL.md b/skills/shade-kit-phase-entry/SKILL.md index 1cdeafd..a19d0e1 100644 --- a/skills/shade-kit-phase-entry/SKILL.md +++ b/skills/shade-kit-phase-entry/SKILL.md @@ -1,8 +1,6 @@ --- name: shade-kit-phase-entry description: "SHADE kit general skill that runs the entry protocol of a phase skill: the version handshake, `phase start` for the caller's phase, the gate check, and the human's approval of the transition. Tells the phase skill whether to run its phase and which skills to load, or ends the run with the next-steps message. Loaded as the first step of every SHADE kit phase skill (refine, map, plan, implement, verify, finish, diagnose, quick); not meant to be called directly." -metadata: - version: 0.9.0 --- # shade-kit-phase-entry @@ -25,12 +23,12 @@ Keep every `warnings` entry (`{ code, message }`) of every CLI call of this run. ### 1. Version handshake -Version handshake: run `shade-kit version --json --expect 0.9.0`; 0.9.0 is the kit version of this skill (`metadata.version` in its frontmatter). +Version handshake: run `shade-kit version --json --expect-contract 1`; 1 is the CLI contract this skill is written for. -- `ok` is `true`: continue. A warning `engine-prerelease-version-mismatch` means that a prerelease engine is used although its major or minor version differs; keep it like every warning and continue. -- `ok` is `false` (for example `version-mismatch`), or the shell reports that `shade-kit` is not found: stop before anything else. End with **refusal** and the failure envelope, or with "`shade-kit` not found". +- `ok` is `true`: continue. +- `ok` is `false` (for example `engine-outdated` or `skills-outdated`), or the shell reports that `shade-kit` is not found: stop before anything else. End with **refusal** and the failure envelope, or with "`shade-kit` not found". -The phase skills run no handshake of their own: all kit skills carry the same version, so this check covers them. +The phase skills run no handshake of their own: all kit skills are written for the same CLI contract, so this check covers them. ### 2. Check and start @@ -172,7 +170,7 @@ Then give the calling skill the ended [return](#return). ## Rules - Run `phase start` only for the phase of the calling skill. Run `phase approve` only for ``, and `phase reject` only for `` (step 4) or for `transition.to` of `resume-pending`, each only after the human's answer. -- The only commands this skill runs are `shade-kit version --json --expect 0.9.0`, `shade-kit phase start`, `shade-kit phase approve`, and `shade-kit phase reject`, the last three with `--json`. Never `phase complete`, `phase next` (the next-steps message runs it), a `feature` command, or `init`. +- The only commands this skill runs are `shade-kit version --json --expect-contract 1`, `shade-kit phase start`, `shade-kit phase approve`, and `shade-kit phase reject`, the last three with `--json`. Never `phase complete`, `phase next` (the next-steps message runs it), a `feature` command, or `init`. - Never read or write `feature.json`, `gates.json`, or `config.json`; the state comes from the CLI. - Do no phase work: read no artifact and write no file. The gate check reads the artifacts. - Load only `shade-kit-gate-check` and `shade-kit-next-steps`. Start no phase skill. diff --git a/skills/shade-kit-plan/SKILL.md b/skills/shade-kit-plan/SKILL.md index 4e844f3..782e9fb 100644 --- a/skills/shade-kit-plan/SKILL.md +++ b/skills/shade-kit-plan/SKILL.md @@ -1,8 +1,6 @@ --- name: shade-kit-plan description: SHADE kit phase skill for `plan` (feature and bugfix profiles). Writes plan.md with design decisions and test strategy and tasks.md with the requirement-to-test mapping and coverage matrix; short variant for bug fixes. Use when the user wants to plan the implementation of the current SHADE kit feature. Runs only when the user calls it by name (`/shade-kit-plan`); never load it on your own or from another skill. -metadata: - version: 0.9.0 --- # shade-kit-plan diff --git a/skills/shade-kit-quick/SKILL.md b/skills/shade-kit-quick/SKILL.md index a7b0bd1..1f448c3 100644 --- a/skills/shade-kit-quick/SKILL.md +++ b/skills/shade-kit-quick/SKILL.md @@ -1,8 +1,6 @@ --- name: shade-kit-quick description: SHADE kit phase skill for the `quick` phase (quick profile). Runs short clarification, a compact spec, implementation with tests, simplify and review, and a self-check in one go, with a single approval at the end. Use when the current SHADE kit feature has the quick profile and the user wants to implement it. Runs only when the user calls it by name (`/shade-kit-quick`); never load it on your own or from another skill. -metadata: - version: 0.9.0 --- # shade-kit-quick diff --git a/skills/shade-kit-refine/SKILL.md b/skills/shade-kit-refine/SKILL.md index 6cdb65c..30c6b62 100644 --- a/skills/shade-kit-refine/SKILL.md +++ b/skills/shade-kit-refine/SKILL.md @@ -1,8 +1,6 @@ --- name: shade-kit-refine description: SHADE kit phase skill for `refine` (feature profile). Clarifies the requirement of the current feature through research and a structured interview and writes spec.md with requirement IDs, acceptance criteria, and out of scope. Can run several times. Use when the user wants to refine, clarify, or specify the current SHADE kit feature. Runs only when the user calls it by name (`/shade-kit-refine`); never load it on your own or from another skill. -metadata: - version: 0.9.0 --- # shade-kit-refine diff --git a/skills/shade-kit-report/SKILL.md b/skills/shade-kit-report/SKILL.md index 599a94c..98573aa 100644 --- a/skills/shade-kit-report/SKILL.md +++ b/skills/shade-kit-report/SKILL.md @@ -1,8 +1,6 @@ --- name: shade-kit-report description: "SHADE kit general skill that writes report.md for a finished feature: requirements, acceptance criteria and proving tests, check results, review findings, manual checks, deviations, and approvals. Optional; loaded by the SHADE kit skill finish only when a report is written; not meant to be called directly." -metadata: - version: 0.9.0 --- # shade-kit-report diff --git a/skills/shade-kit-research/SKILL.md b/skills/shade-kit-research/SKILL.md index 54c1e5b..9bc5539 100644 --- a/skills/shade-kit-research/SKILL.md +++ b/skills/shade-kit-research/SKILL.md @@ -1,8 +1,6 @@ --- name: shade-kit-research description: SHADE kit general skill that runs the research focuses a calling skill names, one subagent per focus in parallel where the agent can start subagents and one after the other otherwise, checks the sources of every finding, and merges the results into the feature's researches.md, one section per phase and focus. Loaded by the SHADE kit skills refine, map, and diagnose; not meant to be called directly. -metadata: - version: 0.9.0 --- # shade-kit-research diff --git a/skills/shade-kit-review/SKILL.md b/skills/shade-kit-review/SKILL.md index 0497842..b651ee2 100644 --- a/skills/shade-kit-review/SKILL.md +++ b/skills/shade-kit-review/SKILL.md @@ -1,8 +1,6 @@ --- name: shade-kit-review description: SHADE kit general skill for an independent code review of the current change against spec.md, plan.md, and the repository's conventions, with findings classified by severity (blocker, major, minor, note) in review.md. Loaded by the SHADE kit skills implement and quick; not meant to be called directly. -metadata: - version: 0.9.0 --- # shade-kit-review diff --git a/skills/shade-kit-verify/SKILL.md b/skills/shade-kit-verify/SKILL.md index 3422105..e36451a 100644 --- a/skills/shade-kit-verify/SKILL.md +++ b/skills/shade-kit-verify/SKILL.md @@ -1,8 +1,6 @@ --- name: shade-kit-verify description: SHADE kit phase skill for `verify` (feature and bugfix profiles). Runs the quality checks, confirms that every acceptance criterion is covered by a passing test, and writes verification.md and a playbook.md for manual tests. Use when the user wants to verify or test the implementation of the current SHADE kit feature. Runs only when the user calls it by name (`/shade-kit-verify`); never load it on your own or from another skill. -metadata: - version: 0.9.0 --- # shade-kit-verify diff --git a/src/CreativeCoders.ShadeKit.Cli/Commands/Version/ExpectedContractInvalidException.cs b/src/CreativeCoders.ShadeKit.Cli/Commands/Version/ExpectedContractInvalidException.cs new file mode 100644 index 0000000..74f72c2 --- /dev/null +++ b/src/CreativeCoders.ShadeKit.Cli/Commands/Version/ExpectedContractInvalidException.cs @@ -0,0 +1,27 @@ +namespace CreativeCoders.ShadeKit.Cli.Commands.Version; + +/// +/// Represents the exception that is thrown when --expect-contract is given without a value or with a value that +/// is not a CLI contract number. +/// +/// +/// The option parser throws it while it reads the arguments of shade-kit version, before the command runs, so +/// it reaches the CLI host as an argument error. A CLI contract number is a non-negative written +/// in ASCII digits, without a sign, leading zeros, or whitespace (see ). +/// +/// +/// The value that follows --expect-contract, or if there is none. +/// +public sealed class ExpectedContractInvalidException(string? value) + : Exception(value is null + ? "The option '--expect-contract' was given without a CLI contract number." + : $"The value '{value}' of the option '--expect-contract' is not a CLI contract number.") +{ + /// + /// Gets the value that follows --expect-contract. + /// + /// + /// The value as passed, or if --expect-contract was given without a value. + /// + public string? Value { get; } = value; +} diff --git a/src/CreativeCoders.ShadeKit.Cli/Commands/Version/ExpectedContractOptionConverter.cs b/src/CreativeCoders.ShadeKit.Cli/Commands/Version/ExpectedContractOptionConverter.cs new file mode 100644 index 0000000..9d0ceb9 --- /dev/null +++ b/src/CreativeCoders.ShadeKit.Cli/Commands/Version/ExpectedContractOptionConverter.cs @@ -0,0 +1,58 @@ +using System.Globalization; +using System.Text.RegularExpressions; +using CreativeCoders.SysConsole.Cli.Parsing; +using CreativeCoders.SysConsole.Cli.Parsing.OptionProperties; + +namespace CreativeCoders.ShadeKit.Cli.Commands.Version; + +/// +/// Converts the value of --expect-contract to a CLI contract number and rejects the option when it is given +/// without a value or with a value that is not a CLI contract number. +/// +/// +/// +/// The option parser of CreativeCoders.SysConsole.Cli.Parsing calls the converter only for an option that is on the +/// command line (or that has a default value, which --expect-contract has not). It passes +/// as the value when the option is the last argument or the next argument starts with +/// -, so --expect-contract -1 counts as an option without a value. +/// +/// +/// A CLI contract number is written in ASCII digits only, without a sign, leading zeros, or whitespace, and fits into +/// an : 0, 1, and 42 are accepted; 01, +1, 1, +/// 1.0, and 2147483648 are rejected. Whether the number lies within the contract window of the engine is +/// checked later by the command. +/// +/// +public sealed partial class ExpectedContractOptionConverter : ICliValueConverter +{ + /// + /// Converts the specified value of --expect-contract to a CLI contract number. + /// + /// + /// The value that follows --expect-contract, or if there is none. + /// + /// The type of the option property. + /// The attribute that declares the option. + /// The CLI contract number as an . + /// + /// is , or it is not a CLI contract number. + /// + public object? Convert(object? value, Type targetType, OptionBaseAttribute optionAttribute) + { + if (value is null) + { + throw new ExpectedContractInvalidException(null); + } + + var text = value.ToString() ?? string.Empty; + + return ContractNumberRegex().IsMatch(text) + && int.TryParse(text, NumberStyles.None, CultureInfo.InvariantCulture, out var contract) + ? contract + : throw new ExpectedContractInvalidException(text); + } + + // [0-9] matches only the ASCII digits, unlike \d; \z, unlike $, does not match before a final line break. + [GeneratedRegex(@"^(0|[1-9][0-9]*)\z", RegexOptions.CultureInvariant)] + private static partial Regex ContractNumberRegex(); +} diff --git a/src/CreativeCoders.ShadeKit.Cli/Commands/Version/ExpectedVersionMissingException.cs b/src/CreativeCoders.ShadeKit.Cli/Commands/Version/ExpectedVersionMissingException.cs deleted file mode 100644 index 0e74b53..0000000 --- a/src/CreativeCoders.ShadeKit.Cli/Commands/Version/ExpectedVersionMissingException.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace CreativeCoders.ShadeKit.Cli.Commands.Version; - -/// -/// Represents the exception that is thrown when --expect is given without a value. -/// -/// -/// The option parser throws it while it reads the arguments of shade-kit version, before the command runs, so -/// it reaches the CLI host as an argument error. -/// -public class ExpectedVersionMissingException() - : Exception("The option '--expect' was given without a version."); diff --git a/src/CreativeCoders.ShadeKit.Cli/Commands/Version/ExpectedVersionOptionConverter.cs b/src/CreativeCoders.ShadeKit.Cli/Commands/Version/ExpectedVersionOptionConverter.cs deleted file mode 100644 index fec09e3..0000000 --- a/src/CreativeCoders.ShadeKit.Cli/Commands/Version/ExpectedVersionOptionConverter.cs +++ /dev/null @@ -1,37 +0,0 @@ -using CreativeCoders.SysConsole.Cli.Parsing; -using CreativeCoders.SysConsole.Cli.Parsing.OptionProperties; - -namespace CreativeCoders.ShadeKit.Cli.Commands.Version; - -/// -/// Converts the value of --expect and rejects the option when it is given without a value. -/// -/// -/// -/// The option parser of CreativeCoders.SysConsole.Cli.Parsing calls the converter only for an option that is on the -/// command line (or that has a default value, which --expect has not). It passes as the -/// value when the option is the last argument or the next argument starts with -; without this converter the -/// property would stay , exactly as if the option were missing. -/// -/// -/// A value, the empty string included, is converted by and checked by the -/// command later. -/// -/// -public sealed class ExpectedVersionOptionConverter : ICliValueConverter -{ - /// - /// Converts the specified value of --expect to the type of the option property. - /// - /// The value that follows --expect, or if there is none. - /// The type of the option property. - /// The attribute that declares the option. - /// The value converted by . - /// is . - public object? Convert(object? value, Type targetType, OptionBaseAttribute optionAttribute) - { - return value is null - ? throw new ExpectedVersionMissingException() - : CliValueConverters.Default.Convert(value, targetType, optionAttribute); - } -} diff --git a/src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommand.cs b/src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommand.cs index addc215..c3a1d45 100644 --- a/src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommand.cs +++ b/src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommand.cs @@ -7,21 +7,23 @@ using CreativeCoders.ShadeKit.Core.Formats; using CreativeCoders.ShadeKit.Core.Integrations; using CreativeCoders.ShadeKit.Core.Versions; -using CreativeCoders.ShadeKit.Core.Warnings; using JetBrains.Annotations; using Spectre.Console; namespace CreativeCoders.ShadeKit.Cli.Commands.Version; /// -/// Prints the version of the SHADE kit engine, the SHADE kit integrations installed in the agents, and, in JSON mode, -/// the format version of every file type the engine supports, and checks the engine against the version that the kit -/// skills expect if one is given. +/// Prints the version of the SHADE kit engine and the CLI contracts it supports, in JSON mode also the format version +/// of every file type the engine supports, and either checks the CLI contract that the kit skills are written for or +/// lists the SHADE kit integrations installed in the agents. /// -/// The context that runs the version check and writes the result or the failure. +/// The context that runs the contract check and writes the result or the failure. /// The provider of the running engine version. /// The registry of the file types the engine supports. -/// The checker that compares the engine version with the expected version. +/// +/// The checker that compares the CLI contract of the kit skills with the contract window of the engine; its +/// is also the window that the command reports. +/// /// The service that reads the installed integrations. [UsedImplicitly] [CliCommand([Name], Description = "Shows the version of SHADE kit")] @@ -29,7 +31,7 @@ public class VersionCommand( ShadeKitCommandContext context, IEngineVersionProvider engineVersionProvider, IFormatRegistry formatRegistry, - IEngineVersionChecker engineVersionChecker, + ICliContractChecker cliContractChecker, IIntegrationService integrationService) : ICliCommand { @@ -46,20 +48,31 @@ public class VersionCommand( private readonly IFormatRegistry _formatRegistry = Ensure.NotNull(formatRegistry); - private readonly IEngineVersionChecker _engineVersionChecker = Ensure.NotNull(engineVersionChecker); + private readonly ICliContractChecker _cliContractChecker = Ensure.NotNull(cliContractChecker); private readonly IIntegrationService _integrationService = Ensure.NotNull(integrationService); /// - /// Checks the engine against the expected version if is set, reads the - /// installed integrations, and writes the engine version and the integrations, as plain text or as a JSON - /// envelope. + /// Checks the CLI contract of the kit skills if is set, or + /// reads the installed integrations otherwise, and writes the engine version, the CLI contract window, and the + /// result, as plain text or as a JSON envelope. /// /// - /// A prerelease engine that does not fit the expected version is reported with a warning and still succeeds. The - /// integrations are read only after the check succeeded; an agent whose CLI is missing or fails is left out with - /// an agent-unavailable warning, so the integrations never make the command fail. The plain output starts - /// with the line shade-kit <version>, followed by one line per installed integration. + /// + /// With the command is the handshake of the kit skills: it + /// checks the contract against the window of the engine, echoes it as expectedContract, and does not read + /// the integrations, so integrations is left out and no agent CLI is started. A contract outside the window + /// always fails; there is no leniency for prerelease engines. + /// + /// + /// Without it, the command reads the installed integrations; an agent whose CLI is missing or fails is left out + /// with an agent-unavailable warning, so the integrations never make the command fail. + /// + /// + /// The plain output starts with the line shade-kit <version>, followed by the line + /// CLI contract <current> (supported: <min> to <current>) and, without + /// , one line per installed integration. + /// /// /// The options of the command. /// @@ -67,12 +80,9 @@ public class VersionCommand( /// /// is . /// - /// The engine is a release whose major or minor version differs from that of the expected version (exit code - /// ), or the expected version is not a valid SemVer 2.0.0 - /// version (exit code ). - /// - /// - /// The version of the running engine is not a valid SemVer 2.0.0 version, which is a defect of the engine build. + /// The kit skills need a CLI contract newer than the engine supports (exit code + /// ), or they are written for a CLI contract older than the + /// engine supports (exit code ). /// /// The user canceled the run. public async Task ExecuteAsync(VersionCommandOptions options) @@ -80,19 +90,38 @@ public async Task ExecuteAsync(VersionCommandOptions options) Ensure.NotNull(options); var data = CreateData(); - IReadOnlyList checkWarnings = []; - if (options.Expect is { } expectedVersion) + if (options.ExpectContract is { } expectedContract) { - var result = await _context.RunAsync(options.Json, - _ => Task.FromResult(_engineVersionChecker.Check(expectedVersion))) - .ConfigureAwait(false); - - checkWarnings = result.Warnings; - data = data with { ExpectedVersion = expectedVersion }; + await WriteCheckedContractAsync(options.Json, data, expectedContract).ConfigureAwait(false); } + else + { + await WriteInstalledIntegrationsAsync(options.Json, data).ConfigureAwait(false); + } + + return CommandResult.Success; + } + + // The handshake path: the integrations are not read, so no agent CLI is started and data.Integrations stays null. + private async Task WriteCheckedContractAsync(bool json, VersionCommandData data, int expectedContract) + { + var checkedContract = await _context.RunAsync(json, _ => + { + _cliContractChecker.Check(expectedContract); - var installed = await _context.RunAsync(options.Json, + return Task.FromResult(expectedContract); + }) + .ConfigureAwait(false); + + var checkedData = data with { ExpectedContract = checkedContract }; + + _context.WriteSuccess(json, checkedData, () => WritePlain(checkedData, [])); + } + + private async Task WriteInstalledIntegrationsAsync(bool json, VersionCommandData data) + { + var installed = await _context.RunAsync(json, cancellationToken => _integrationService.GetInstalledAsync(cancellationToken)) .ConfigureAwait(false); @@ -101,15 +130,15 @@ public async Task ExecuteAsync(VersionCommandOptions options) Integrations = [.. installed.Integrations.Select(VersionCommandIntegrationData.From)] }; - _context.WriteSuccess(options.Json, completeData, [.. checkWarnings, .. installed.Warnings], - () => WritePlain(completeData.EngineVersion, installed.Integrations)); - - return CommandResult.Success; + _context.WriteSuccess(json, completeData, installed.Warnings, + () => WritePlain(completeData, installed.Integrations)); } - private void WritePlain(string engineVersion, IReadOnlyList integrations) + private void WritePlain(VersionCommandData data, IReadOnlyList integrations) { - _context.Console.WriteLine($"{ToolName} {engineVersion}"); + _context.Console.WriteLine($"{ToolName} {data.EngineVersion}"); + _context.Console.WriteLine( + $"CLI contract {data.Contract.Current} (supported: {data.Contract.MinSupported} to {data.Contract.Current})"); foreach (var integration in integrations) { @@ -126,6 +155,7 @@ private VersionCommandData CreateData() formats.Add(format.Id, format.CurrentVersion); } - return new VersionCommandData(_engineVersionProvider.Version, formats); + return new VersionCommandData(_engineVersionProvider.Version, formats, + VersionCommandContractData.From(_cliContractChecker.Window)); } } diff --git a/src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommandContractData.cs b/src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommandContractData.cs new file mode 100644 index 0000000..3c28273 --- /dev/null +++ b/src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommandContractData.cs @@ -0,0 +1,26 @@ +using CreativeCoders.Core; +using CreativeCoders.ShadeKit.Core.Versions; + +namespace CreativeCoders.ShadeKit.Cli.Commands.Version; + +/// +/// Represents the CLI contract window of the engine in the data object that shade-kit version --json +/// returns, for example {"current":1,"minSupported":1}. +/// +/// The newest CLI contract that the engine supports. +/// The oldest CLI contract that the engine still supports. +public sealed record VersionCommandContractData(int Current, int MinSupported) +{ + /// + /// Creates the data of the specified CLI contract window. + /// + /// The CLI contract window of the engine. + /// The data with the bounds of . + /// is . + public static VersionCommandContractData From(CliContractWindow window) + { + Ensure.NotNull(window); + + return new VersionCommandContractData(window.Current, window.MinSupported); + } +} diff --git a/src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommandData.cs b/src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommandData.cs index e41ea39..48213d5 100644 --- a/src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommandData.cs +++ b/src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommandData.cs @@ -7,32 +7,39 @@ namespace CreativeCoders.ShadeKit.Cli.Commands.Version; /// /// /// Describes the installed engine and the SHADE kit integrations of the agents, not a repository; skills use it for -/// the version handshake. +/// the version handshake. The properties are written in the order engineVersion, formats, +/// contract, expectedContract, integrations. /// /// The version of the running engine without build metadata. /// /// The current format version of every versioned file type the engine supports, keyed by format id, for example /// config or current-feature. /// -public sealed record VersionCommandData(string EngineVersion, IReadOnlyDictionary Formats) +/// The window of CLI contracts that the engine supports. +public sealed record VersionCommandData( + string EngineVersion, + IReadOnlyDictionary Formats, + VersionCommandContractData Contract) { /// - /// Gets the engine version that the kit skills expect and that the engine was checked against. + /// Gets the CLI contract that the kit skills are written for and that the engine was checked against. /// /// - /// The value of --expect as passed, or if --expect was not given, in which - /// case the property is left out of the JSON output. The default is . + /// The value of --expect-contract, or if --expect-contract was not given, in + /// which case the property is left out of the JSON output. The default is . /// [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public string? ExpectedVersion { get; init; } + public int? ExpectedContract { get; init; } /// /// Gets the SHADE kit integrations that are installed in the agents for the user. /// /// - /// The installed integrations in the order in which the agents are registered, always written to the JSON output, - /// after ; an empty list if none is installed or no agent could be asked. The - /// default is an empty list. + /// The installed integrations in the order in which the agents are registered, written to the JSON output after + /// ; an empty list if none is installed or no agent could be asked. It is + /// , and left out of the JSON output, only when --expect-contract was given, + /// because the command then does not read the integrations. The default is . /// - public IReadOnlyList Integrations { get; init; } = []; + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public IReadOnlyList? Integrations { get; init; } } diff --git a/src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommandOptions.cs b/src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommandOptions.cs index fcb5b70..5740f7f 100644 --- a/src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommandOptions.cs +++ b/src/CreativeCoders.ShadeKit.Cli/Commands/Version/VersionCommandOptions.cs @@ -8,16 +8,16 @@ namespace CreativeCoders.ShadeKit.Cli.Commands.Version; public class VersionCommandOptions : JsonCommandOptions { /// - /// Gets or sets the engine version that the kit skills expect. + /// Gets or sets the CLI contract that the kit skills are written for. /// /// - /// The SemVer 2.0.0 version as passed, for example 1.2.0, or to skip the version - /// check. An empty string is checked like any other value and is rejected. --expect without a value is - /// rejected while the arguments are read (see ). The default is - /// . + /// The CLI contract number, for example 1, or to skip the contract check and list + /// the installed integrations instead. --expect-contract without a value or with a value that is not a + /// CLI contract number is rejected while the arguments are read (see + /// ). The default is . /// - [OptionParameter("expect", - HelpText = "The engine version the kit skills expect; the major and minor versions must be equal", - Converter = typeof(ExpectedVersionOptionConverter))] - public string? Expect { get; set; } + [OptionParameter("expect-contract", + HelpText = "The CLI contract the kit skills are written for; the command fails unless this engine supports it", + Converter = typeof(ExpectedContractOptionConverter))] + public int? ExpectContract { get; set; } } diff --git a/src/CreativeCoders.ShadeKit.Cli/Output/CliErrorMapper.cs b/src/CreativeCoders.ShadeKit.Cli/Output/CliErrorMapper.cs index 4531656..09eba7e 100644 --- a/src/CreativeCoders.ShadeKit.Cli/Output/CliErrorMapper.cs +++ b/src/CreativeCoders.ShadeKit.Cli/Output/CliErrorMapper.cs @@ -1,4 +1,3 @@ -using System.Globalization; using System.Reflection; using CreativeCoders.Cli.Core; using CreativeCoders.Core; @@ -26,9 +25,7 @@ using CreativeCoders.ShadeKit.Core.Store; using CreativeCoders.ShadeKit.Core.Store.Exceptions; using CreativeCoders.ShadeKit.Core.Trackers.Exceptions; -using CreativeCoders.ShadeKit.Core.Versions; using CreativeCoders.ShadeKit.Core.Versions.Exceptions; -using CreativeCoders.ShadeKit.Core.Versions.Warnings; using CreativeCoders.ShadeKit.Core.Warnings; using CreativeCoders.ShadeKit.Core.Web.Exceptions; using CreativeCoders.ShadeKit.Core.Workflow.Engine.Exceptions; @@ -58,14 +55,12 @@ public sealed class CliErrorMapper(IEngineVersionProvider engineVersionProvider) /// The exception to map. /// /// The CLI error for , or if it is not an expected failure - /// of the SHADE kit core. An gets the exit code - /// , because the version it rejects comes from the arguments; - /// its message names neither an option nor a command, so that it fits every argument that is checked with it. + /// of the SHADE kit core. The messages of and + /// name the running engine version, the CLI contract window, the + /// requested CLI contract, and the remedy: update the engine, or reinstall the kit skills with + /// shade-kit integrations install. /// /// is . - /// - /// The direction of an is not supported. - /// public CliError? Map(Exception exception) { Ensure.NotNull(exception); @@ -194,8 +189,16 @@ public sealed class CliErrorMapper(IEngineVersionProvider engineVersionProvider) "changed. Restore the template, for example from git, or change the 'checklist' of the gate, then " + "run the command again."), - EngineVersionMismatchException e => CliError.Create(ShadeKitCliExitCodes.VersionMismatch, - CreateEngineVersionMismatchMessage(e.EngineVersion, e.ExpectedVersion, e.Direction)), + EngineContractOutdatedException e => CliError.Create(ShadeKitCliExitCodes.EngineOutdated, + $"The SHADE kit engine {_engineVersionProvider.Version} supports the CLI contracts " + + $"{e.MinSupportedContract} to {e.CurrentContract}, but the kit skills need the CLI contract " + + $"{e.RequestedContract}. Update the engine, then run the skill again."), + + SkillsContractOutdatedException e => CliError.Create(ShadeKitCliExitCodes.SkillsOutdated, + $"The kit skills are written for the CLI contract {e.RequestedContract}, but the SHADE kit engine " + + $"{_engineVersionProvider.Version} supports only the CLI contracts {e.MinSupportedContract} to " + + $"{e.CurrentContract}. Run 'shade-kit integrations install' to install the matching kit skills, " + + "then run the skill again."), NoAgentFoundException e => CliError.Create(ShadeKitCliExitCodes.AgentNotFound, $"No supported agent was found (supported: {FormatAgentIds(e.SupportedAgentIds)}). SHADE kit " + @@ -266,10 +269,6 @@ public sealed class CliErrorMapper(IEngineVersionProvider engineVersionProvider) $"'{e.Value}', which is not a marketplace source: {e.Reason} Set it to owner/repo#ref, owner/repo, " + "or the path of a local directory, or remove it, then run the command again."), - InvalidSemanticVersionException e => CliError.Create(ShadeKitCliExitCodes.InvalidArguments, - $"Invalid arguments: '{e.Value}' is not a SemVer version such as 1.2.3 or 1.2.3-beta.1. Run " + - "'shade-kit --help' for usage."), - _ => null }; } @@ -282,8 +281,9 @@ public sealed class CliErrorMapper(IEngineVersionProvider engineVersionProvider) /// , because the failure happens in the CLI host before any service of the run exists. /// Exceptions wrapped in are unwrapped. An /// is not mapped: it - /// is a defect of the CLI, not of the arguments. An (--expect - /// without a value) gets a text that names --expect, an + /// is a defect of the CLI, not of the arguments. An + /// (--expect-contract without a value or with a value that is not a CLI contract number) gets a text that + /// names --expect-contract and the value, an /// (--agent without a value or with an unknown agent id) one that names --agent and the supported /// agents. /// @@ -305,8 +305,7 @@ public sealed class CliErrorMapper(IEngineVersionProvider engineVersionProvider) { RequiredArgumentMissingException e => CreateRequiredArgumentMissingText(e), NotAllArgumentsMatchException e => CreateNotMatchedArgumentsText(e), - ExpectedVersionMissingException => - "--expect needs a SemVer version such as 1.2.3 or 1.2.3-beta.1, but got none", + ExpectedContractInvalidException e => CreateExpectedContractInvalidText(e), InvalidAgentOptionException e => CreateInvalidAgentOptionText(e), OptionParserException => "the arguments could not be read", _ => null @@ -414,11 +413,6 @@ public static CliJsonMessage MapWarning(KitWarning warning) GateEntryIgnoredWarning w => new CliJsonMessage(ShadeKitCliWarningCodes.GateEntryIgnored, CreateGateEntryIgnoredMessage(w.ProfileName, w.PhaseName, w.Reason)), - EnginePrereleaseVersionMismatchWarning w => new CliJsonMessage( - ShadeKitCliWarningCodes.EnginePrereleaseVersionMismatch, - $"The prerelease engine {w.EngineVersion} does not fit the kit skills {w.ExpectedVersion} (the major " + - "and minor versions differ); it is used anyway because it is a prerelease."), - IntegrationPrereleaseRefWarning w => new CliJsonMessage(ShadeKitCliWarningCodes.IntegrationPrereleaseRef, $"The engine {w.EngineVersion} is a prerelease, so the integrations come from the branch '{w.Ref}' " + $"of {IntegrationService.MarketplaceRepo} instead of a release tag; they may not fit this engine."), @@ -687,31 +681,6 @@ private static string CreateGateEntryIgnoredMessage(string profileName, string? }; } - private static string CreateEngineVersionMismatchMessage(string engineVersion, string expectedVersion, - EngineVersionMismatchDirection direction) - { - var remedy = direction switch - { - EngineVersionMismatchDirection.EngineOlder => - $"Update the engine to {FormatMajorMinor(expectedVersion)}", - EngineVersionMismatchDirection.EngineNewer => - "Run 'shade-kit integrations install' to install the SHADE kit skills " + - FormatMajorMinor(engineVersion), - _ => throw new ArgumentOutOfRangeException(nameof(direction), direction, "The direction is not supported.") - }; - - return $"The SHADE kit engine {engineVersion} does not fit the kit skills {expectedVersion}: the major and " + - $"minor versions must be equal. {remedy}, then run the skill again."; - } - - // The checker throws the exception only for valid versions; any other text is named as a whole. - private static string FormatMajorMinor(string version) - { - return SemanticVersion.TryParse(version, out var semanticVersion) - ? string.Create(CultureInfo.InvariantCulture, $"{semanticVersion.Major}.{semanticVersion.Minor}") - : version; - } - private static string CreateVersionMismatchText(string filePath, int fileVersion, int currentVersion) { return $"'{filePath}' uses format version {fileVersion}; this shade-kit uses version {currentVersion}."; @@ -782,6 +751,15 @@ private static string CreatePendingTransitionText(string? pendingTransition) : $"the pending transition is to '{pendingTransition}'."; } + private static string CreateExpectedContractInvalidText(ExpectedContractInvalidException exception) + { + const string expectation = "--expect-contract needs a CLI contract number such as 1, but got"; + + return exception.Value is null + ? $"{expectation} none" + : $"{expectation} '{exception.Value}'"; + } + private static string CreateInvalidAgentOptionText(InvalidAgentOptionException exception) { var supported = FormatAgentIds(exception.SupportedAgentIds); diff --git a/src/CreativeCoders.ShadeKit.Cli/ShadeKitCliErrorCodes.cs b/src/CreativeCoders.ShadeKit.Cli/ShadeKitCliErrorCodes.cs index 3032a5e..f18f699 100644 --- a/src/CreativeCoders.ShadeKit.Cli/ShadeKitCliErrorCodes.cs +++ b/src/CreativeCoders.ShadeKit.Cli/ShadeKitCliErrorCodes.cs @@ -155,11 +155,6 @@ public static class ShadeKitCliErrorCodes /// public const string ChecklistTemplateNotFound = "checklist-template-not-found"; - /// - /// Represents the error code that belongs to . - /// - public const string VersionMismatch = "version-mismatch"; - /// /// Represents the error code that belongs to . /// @@ -175,6 +170,16 @@ public static class ShadeKitCliErrorCodes /// public const string IntegrationConflict = "integration-conflict"; + /// + /// Represents the error code that belongs to . + /// + public const string EngineOutdated = "engine-outdated"; + + /// + /// Represents the error code that belongs to . + /// + public const string SkillsOutdated = "skills-outdated"; + /// /// Represents the error code that belongs to . /// @@ -226,10 +231,11 @@ public static string ForExitCode(int exitCode) ShadeKitCliExitCodes.CompleteNotAllowed => CompleteNotAllowed, ShadeKitCliExitCodes.PhaseStateInvalid => PhaseStateInvalid, ShadeKitCliExitCodes.ChecklistTemplateNotFound => ChecklistTemplateNotFound, - ShadeKitCliExitCodes.VersionMismatch => VersionMismatch, ShadeKitCliExitCodes.AgentNotFound => AgentNotFound, ShadeKitCliExitCodes.AgentCommandFailed => AgentCommandFailed, ShadeKitCliExitCodes.IntegrationConflict => IntegrationConflict, + ShadeKitCliExitCodes.EngineOutdated => EngineOutdated, + ShadeKitCliExitCodes.SkillsOutdated => SkillsOutdated, ShadeKitCliExitCodes.Canceled => Canceled, ShadeKitCliExitCodes.HostError => HostError, _ => throw new ArgumentOutOfRangeException(nameof(exitCode), exitCode, "The exit code is not defined.") diff --git a/src/CreativeCoders.ShadeKit.Cli/ShadeKitCliExitCodes.cs b/src/CreativeCoders.ShadeKit.Cli/ShadeKitCliExitCodes.cs index f2be936..1534f9f 100644 --- a/src/CreativeCoders.ShadeKit.Cli/ShadeKitCliExitCodes.cs +++ b/src/CreativeCoders.ShadeKit.Cli/ShadeKitCliExitCodes.cs @@ -210,13 +210,6 @@ public static class ShadeKitCliExitCodes /// public const int ChecklistTemplateNotFound = 47; - /// - /// Represents the exit code returned when shade-kit version --expect names a version whose major or minor - /// version differs from that of the running release engine. The error code is - /// . - /// - public const int VersionMismatch = 50; - /// /// Represents the exit code returned when no supported agent is detected, for example by /// shade-kit integrations install without --agent, or when the CLI of an agent that a command needs @@ -244,6 +237,21 @@ public static class ShadeKitCliExitCodes /// public const int IntegrationConflict = 53; + /// + /// Represents the exit code returned when shade-kit version --expect-contract names a CLI contract that is + /// newer than the current CLI contract of the engine: the kit skills need a CLI contract newer than this engine + /// supports, so the engine must be updated. The error code is . + /// + public const int EngineOutdated = 54; + + /// + /// Represents the exit code returned when shade-kit version --expect-contract names a CLI contract that is + /// older than the oldest CLI contract the engine supports: the kit skills are written for a CLI contract older + /// than this engine supports, so they must be reinstalled with shade-kit integrations install. The error + /// code is . + /// + public const int SkillsOutdated = 55; + /// /// Represents the exit code returned when the user cancels a running command, for example by pressing Ctrl+C. The /// error code is . diff --git a/src/CreativeCoders.ShadeKit.Cli/ShadeKitCliWarningCodes.cs b/src/CreativeCoders.ShadeKit.Cli/ShadeKitCliWarningCodes.cs index 2473fe7..ff7bbd6 100644 --- a/src/CreativeCoders.ShadeKit.Cli/ShadeKitCliWarningCodes.cs +++ b/src/CreativeCoders.ShadeKit.Cli/ShadeKitCliWarningCodes.cs @@ -75,12 +75,6 @@ public static class ShadeKitCliWarningCodes /// public const string GateEntryIgnored = "gate-entry-ignored"; - /// - /// Represents the warning code reported when the major or minor version of a prerelease engine differs from that - /// of the version passed with shade-kit version --expect; the engine is used anyway. - /// - public const string EnginePrereleaseVersionMismatch = "engine-prerelease-version-mismatch"; - /// /// Represents the warning code reported when a prerelease engine installs or updates the integrations from the /// branch main instead of a release tag. diff --git a/src/CreativeCoders.ShadeKit.Core/ShadeKitCoreServiceCollectionExtensions.cs b/src/CreativeCoders.ShadeKit.Core/ShadeKitCoreServiceCollectionExtensions.cs index da385ae..638d5b2 100644 --- a/src/CreativeCoders.ShadeKit.Core/ShadeKitCoreServiceCollectionExtensions.cs +++ b/src/CreativeCoders.ShadeKit.Core/ShadeKitCoreServiceCollectionExtensions.cs @@ -58,7 +58,7 @@ public static IServiceCollection AddShadeKitCore(this IServiceCollection service services.TryAddSingleton(_ => FormatRegistry.CreateDefault()); services.TryAddSingleton(); services.TryAddSingleton(); - services.TryAddSingleton(); + services.TryAddSingleton(_ => new CliContractChecker(CliContract.Window)); services.TryAddSingleton(); services.TryAddSingleton(); services.TryAddSingleton(); diff --git a/src/CreativeCoders.ShadeKit.Core/Versions/CliContract.cs b/src/CreativeCoders.ShadeKit.Core/Versions/CliContract.cs new file mode 100644 index 0000000..36a9040 --- /dev/null +++ b/src/CreativeCoders.ShadeKit.Core/Versions/CliContract.cs @@ -0,0 +1,43 @@ +namespace CreativeCoders.ShadeKit.Core.Versions; + +/// +/// Provides the CLI contract of this engine: the numbered agreement between the engine and the kit skills about the +/// behaviour of the CLI. +/// +/// +/// +/// The CLI contract covers everything the kit skills rely on: the agent-facing commands and their options, the fields +/// of the JSON envelope (CliJsonEnvelope), the fields of its data object, and the error and warning +/// codes. The kit skills state the contract they are written for, and the engine accepts them when that contract lies +/// within . +/// +/// +/// rises with every change to the contract that the skills can see, additive changes such as +/// a new option or a new data field included. rises only when a part of the +/// contract is removed or reinterpreted, so that skills written for an older contract would no longer work. +/// +/// +/// The contract numbers are independent of the product version that GitVersion derives from the git history; a new +/// release does not change them unless the contract changes. +/// +/// +public static class CliContract +{ + /// + /// The newest CLI contract that this engine supports. + /// + /// Raised with every change to the contract that the kit skills can see, additive ones included. + public const int Current = 1; + + /// + /// The oldest CLI contract that this engine still supports. + /// + /// Raised only when a part of the contract is removed or reinterpreted. + public const int MinSupported = 1; + + /// + /// Gets the window of CLI contracts that this engine supports. + /// + /// The window from to . + public static CliContractWindow Window { get; } = new(MinSupported, Current); +} diff --git a/src/CreativeCoders.ShadeKit.Core/Versions/CliContractChecker.cs b/src/CreativeCoders.ShadeKit.Core/Versions/CliContractChecker.cs new file mode 100644 index 0000000..a789b6f --- /dev/null +++ b/src/CreativeCoders.ShadeKit.Core/Versions/CliContractChecker.cs @@ -0,0 +1,34 @@ +using CreativeCoders.Core; +using CreativeCoders.ShadeKit.Core.Versions.Exceptions; + +namespace CreativeCoders.ShadeKit.Core.Versions; + +/// +/// Checks requested CLI contracts against a fixed . +/// +/// +/// The engine registers this checker with ; any other window serves tests. +/// +/// The window of CLI contracts that the engine supports. +/// is . +public sealed class CliContractChecker(CliContractWindow window) : ICliContractChecker +{ + /// + public CliContractWindow Window { get; } = Ensure.NotNull(window); + + /// + public void Check(int requestedContract) + { + ArgumentOutOfRangeException.ThrowIfNegative(requestedContract); + + if (requestedContract > Window.Current) + { + throw new EngineContractOutdatedException(requestedContract, Window.MinSupported, Window.Current); + } + + if (requestedContract < Window.MinSupported) + { + throw new SkillsContractOutdatedException(requestedContract, Window.MinSupported, Window.Current); + } + } +} diff --git a/src/CreativeCoders.ShadeKit.Core/Versions/CliContractWindow.cs b/src/CreativeCoders.ShadeKit.Core/Versions/CliContractWindow.cs new file mode 100644 index 0000000..4740cb2 --- /dev/null +++ b/src/CreativeCoders.ShadeKit.Core/Versions/CliContractWindow.cs @@ -0,0 +1,43 @@ +namespace CreativeCoders.ShadeKit.Core.Versions; + +/// +/// Represents the range of CLI contracts that an engine supports, from the oldest supported contract to the current +/// one. +/// +/// +/// CLI contracts are numbered from 1, so a window always starts at 1 or higher, and a requested contract 0 lies below +/// every window. The window of the running engine is . +/// +public sealed record CliContractWindow +{ + /// + /// Initializes a new instance of the class with the oldest supported and the + /// current CLI contract. + /// + /// The oldest CLI contract that the engine still supports. + /// The newest CLI contract that the engine supports. + /// + /// is less than 1, or is less than + /// . + /// + public CliContractWindow(int minSupported, int current) + { + ArgumentOutOfRangeException.ThrowIfLessThan(minSupported, 1); + ArgumentOutOfRangeException.ThrowIfLessThan(current, minSupported); + + MinSupported = minSupported; + Current = current; + } + + /// + /// Gets the oldest CLI contract that the engine still supports. + /// + /// A contract number of 1 or higher. + public int MinSupported { get; } + + /// + /// Gets the newest CLI contract that the engine supports. + /// + /// A contract number equal to or greater than . + public int Current { get; } +} diff --git a/src/CreativeCoders.ShadeKit.Core/Versions/EngineVersionCheckResult.cs b/src/CreativeCoders.ShadeKit.Core/Versions/EngineVersionCheckResult.cs deleted file mode 100644 index b5f1072..0000000 --- a/src/CreativeCoders.ShadeKit.Core/Versions/EngineVersionCheckResult.cs +++ /dev/null @@ -1,19 +0,0 @@ -using CreativeCoders.ShadeKit.Core.Warnings; - -namespace CreativeCoders.ShadeKit.Core.Versions; - -/// -/// Represents the outcome of a successful check of the running engine version against an expected version. -/// -/// -/// The version of the running engine, as the provides it. -/// -/// The expected version as it was passed to the check. -/// -/// The warnings of the check, for example an ; an empty -/// list if there were none. -/// -public sealed record EngineVersionCheckResult( - string EngineVersion, - string ExpectedVersion, - IReadOnlyList Warnings); diff --git a/src/CreativeCoders.ShadeKit.Core/Versions/EngineVersionChecker.cs b/src/CreativeCoders.ShadeKit.Core/Versions/EngineVersionChecker.cs deleted file mode 100644 index 952612d..0000000 --- a/src/CreativeCoders.ShadeKit.Core/Versions/EngineVersionChecker.cs +++ /dev/null @@ -1,55 +0,0 @@ -using CreativeCoders.Core; -using CreativeCoders.ShadeKit.Core.Engine; -using CreativeCoders.ShadeKit.Core.Versions.Exceptions; -using CreativeCoders.ShadeKit.Core.Versions.Warnings; - -namespace CreativeCoders.ShadeKit.Core.Versions; - -/// -/// Checks whether the running engine, whose version an provides, fits the -/// version that the kit skills expect. -/// -/// The provider of the running engine version. -public sealed class EngineVersionChecker(IEngineVersionProvider engineVersionProvider) : IEngineVersionChecker -{ - private readonly IEngineVersionProvider _engineVersionProvider = Ensure.NotNull(engineVersionProvider); - - /// - public EngineVersionCheckResult Check(string expectedVersion) - { - Ensure.NotNull(expectedVersion); - - if (!SemanticVersion.TryParse(expectedVersion, out var expected)) - { - throw new InvalidSemanticVersionException(expectedVersion); - } - - var engineVersionText = _engineVersionProvider.Version; - - if (!SemanticVersion.TryParse(engineVersionText, out var engine)) - { - throw new InvalidOperationException( - $"The engine version '{engineVersionText}' is not a valid SemVer 2.0.0 version, so it cannot be " + - "checked. The engine build is defective."); - } - - var comparison = (engine.Major, engine.Minor).CompareTo((expected.Major, expected.Minor)); - - if (comparison == 0) - { - return new EngineVersionCheckResult(engineVersionText, expectedVersion, []); - } - - var direction = comparison < 0 - ? EngineVersionMismatchDirection.EngineOlder - : EngineVersionMismatchDirection.EngineNewer; - - if (!engine.IsPrerelease) - { - throw new EngineVersionMismatchException(engineVersionText, expectedVersion, direction); - } - - return new EngineVersionCheckResult(engineVersionText, expectedVersion, - [new EnginePrereleaseVersionMismatchWarning(engineVersionText, expectedVersion, direction)]); - } -} diff --git a/src/CreativeCoders.ShadeKit.Core/Versions/EngineVersionMismatchDirection.cs b/src/CreativeCoders.ShadeKit.Core/Versions/EngineVersionMismatchDirection.cs deleted file mode 100644 index 2debfc7..0000000 --- a/src/CreativeCoders.ShadeKit.Core/Versions/EngineVersionMismatchDirection.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace CreativeCoders.ShadeKit.Core.Versions; - -/// -/// Specifies how the major and minor versions of the running engine relate to those of the expected version. -/// -public enum EngineVersionMismatchDirection -{ - /// - /// The major and minor versions of the engine are lower than those of the expected version, so the engine is - /// older than the kit skills. - /// - EngineOlder, - - /// - /// The major and minor versions of the engine are higher than those of the expected version, so the engine is - /// newer than the kit skills. - /// - EngineNewer -} diff --git a/src/CreativeCoders.ShadeKit.Core/Versions/Exceptions/EngineContractOutdatedException.cs b/src/CreativeCoders.ShadeKit.Core/Versions/Exceptions/EngineContractOutdatedException.cs new file mode 100644 index 0000000..5e15518 --- /dev/null +++ b/src/CreativeCoders.ShadeKit.Core/Versions/Exceptions/EngineContractOutdatedException.cs @@ -0,0 +1,32 @@ +namespace CreativeCoders.ShadeKit.Core.Versions.Exceptions; + +/// +/// Represents the exception that is thrown when the kit skills request a CLI contract that is newer than the current +/// contract of the engine. +/// +/// The kit skills are newer than the engine, so the engine must be updated. +/// The CLI contract that the kit skills request. +/// The oldest CLI contract that the engine supports. +/// The newest CLI contract that the engine supports. +public class EngineContractOutdatedException(int requestedContract, int minSupportedContract, int currentContract) + : Exception($"The kit skills need the CLI contract {requestedContract}, but this engine supports only the CLI " + + $"contracts {minSupportedContract} to {currentContract}.") +{ + /// + /// Gets the CLI contract that the kit skills request. + /// + /// A contract number greater than . + public int RequestedContract { get; } = requestedContract; + + /// + /// Gets the oldest CLI contract that the engine supports. + /// + /// The lower bound of the contract window of the engine. + public int MinSupportedContract { get; } = minSupportedContract; + + /// + /// Gets the newest CLI contract that the engine supports. + /// + /// The upper bound of the contract window of the engine. + public int CurrentContract { get; } = currentContract; +} diff --git a/src/CreativeCoders.ShadeKit.Core/Versions/Exceptions/EngineVersionMismatchException.cs b/src/CreativeCoders.ShadeKit.Core/Versions/Exceptions/EngineVersionMismatchException.cs deleted file mode 100644 index 7582962..0000000 --- a/src/CreativeCoders.ShadeKit.Core/Versions/Exceptions/EngineVersionMismatchException.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace CreativeCoders.ShadeKit.Core.Versions.Exceptions; - -/// -/// Represents the exception that is thrown when the major or minor version of a release engine differs from that of -/// the expected version. -/// -/// The version of the running engine. -/// The expected version as it was passed to the check. -/// -/// One of the enumeration values that specifies whether the engine is older or newer than the expected version. -/// -public class EngineVersionMismatchException( - string engineVersion, - string expectedVersion, - EngineVersionMismatchDirection direction) - : Exception($"The engine version '{engineVersion}' does not match the expected version '{expectedVersion}': the " + - "major and minor versions differ.") -{ - /// - /// Gets the version of the running engine. - /// - /// The engine version without build metadata, for example 1.2.0. - public string EngineVersion { get; } = engineVersion; - - /// - /// Gets the expected version. - /// - /// The version as it was passed to the check, for example the value of --expect. - public string ExpectedVersion { get; } = expectedVersion; - - /// - /// Gets whether the engine is older or newer than the expected version. - /// - /// One of the enumeration values. - public EngineVersionMismatchDirection Direction { get; } = direction; -} diff --git a/src/CreativeCoders.ShadeKit.Core/Versions/Exceptions/InvalidSemanticVersionException.cs b/src/CreativeCoders.ShadeKit.Core/Versions/Exceptions/InvalidSemanticVersionException.cs deleted file mode 100644 index 41d6673..0000000 --- a/src/CreativeCoders.ShadeKit.Core/Versions/Exceptions/InvalidSemanticVersionException.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace CreativeCoders.ShadeKit.Core.Versions.Exceptions; - -/// -/// Represents the exception that is thrown when a version that a caller passes is not a valid SemVer 2.0.0 version. -/// -/// The version text that is not valid. -public class InvalidSemanticVersionException(string value) - : Exception($"'{value}' is not a valid SemVer 2.0.0 version.") -{ - /// - /// Gets the version text that is not valid. - /// - /// The text as it was passed, for example the value of --expect. - public string Value { get; } = value; -} diff --git a/src/CreativeCoders.ShadeKit.Core/Versions/Exceptions/SkillsContractOutdatedException.cs b/src/CreativeCoders.ShadeKit.Core/Versions/Exceptions/SkillsContractOutdatedException.cs new file mode 100644 index 0000000..9ba2ebd --- /dev/null +++ b/src/CreativeCoders.ShadeKit.Core/Versions/Exceptions/SkillsContractOutdatedException.cs @@ -0,0 +1,32 @@ +namespace CreativeCoders.ShadeKit.Core.Versions.Exceptions; + +/// +/// Represents the exception that is thrown when the kit skills request a CLI contract that is older than the oldest +/// contract the engine supports. +/// +/// The kit skills are older than the engine supports, so the kit skills must be updated. +/// The CLI contract that the kit skills request. +/// The oldest CLI contract that the engine supports. +/// The newest CLI contract that the engine supports. +public class SkillsContractOutdatedException(int requestedContract, int minSupportedContract, int currentContract) + : Exception($"The kit skills are written for the CLI contract {requestedContract}, but this engine supports " + + $"only the CLI contracts {minSupportedContract} to {currentContract}.") +{ + /// + /// Gets the CLI contract that the kit skills request. + /// + /// A contract number less than . + public int RequestedContract { get; } = requestedContract; + + /// + /// Gets the oldest CLI contract that the engine supports. + /// + /// The lower bound of the contract window of the engine. + public int MinSupportedContract { get; } = minSupportedContract; + + /// + /// Gets the newest CLI contract that the engine supports. + /// + /// The upper bound of the contract window of the engine. + public int CurrentContract { get; } = currentContract; +} diff --git a/src/CreativeCoders.ShadeKit.Core/Versions/ICliContractChecker.cs b/src/CreativeCoders.ShadeKit.Core/Versions/ICliContractChecker.cs new file mode 100644 index 0000000..7152b29 --- /dev/null +++ b/src/CreativeCoders.ShadeKit.Core/Versions/ICliContractChecker.cs @@ -0,0 +1,41 @@ +using CreativeCoders.ShadeKit.Core.Versions.Exceptions; + +namespace CreativeCoders.ShadeKit.Core.Versions; + +/// +/// Checks whether the engine supports the CLI contract that the kit skills request. +/// +public interface ICliContractChecker +{ + /// + /// Gets the window of CLI contracts that the checker accepts. + /// + /// + /// shade-kit version reports this window, so the reported window and the checked window are the same value. + /// + /// The window that checks a requested contract against. + CliContractWindow Window { get; } + + /// + /// Checks the specified requested CLI contract against the contract window of the engine. + /// + /// + /// The check succeeds when lies within the window, bounds included: + /// MinSupported <= requestedContract <= Current. There is no leniency for prerelease engines and no + /// warning; a requested contract outside the window always fails. Contracts start at 1, so a requested contract 0 + /// is valid input that always lies below the window. + /// + /// The CLI contract that the kit skills are written for. + /// + /// is negative. + /// + /// + /// is greater than the current contract of the engine, so the kit skills + /// are newer than the engine. + /// + /// + /// is less than the oldest contract that the engine supports, so the kit + /// skills are older than the engine supports. + /// + void Check(int requestedContract); +} diff --git a/src/CreativeCoders.ShadeKit.Core/Versions/IEngineVersionChecker.cs b/src/CreativeCoders.ShadeKit.Core/Versions/IEngineVersionChecker.cs deleted file mode 100644 index 538a1ba..0000000 --- a/src/CreativeCoders.ShadeKit.Core/Versions/IEngineVersionChecker.cs +++ /dev/null @@ -1,36 +0,0 @@ -using CreativeCoders.ShadeKit.Core.Versions.Exceptions; -using CreativeCoders.ShadeKit.Core.Versions.Warnings; - -namespace CreativeCoders.ShadeKit.Core.Versions; - -/// -/// Checks whether the running engine fits the version that the kit skills expect. -/// -public interface IEngineVersionChecker -{ - /// - /// Checks the version of the running engine against the specified expected version. - /// - /// - /// The engine fits if its major and minor versions equal those of . The patch - /// version, the prerelease label, and the build metadata of take no part in - /// the check. A prerelease engine that does not fit is used anyway and gets an - /// . - /// - /// The SemVer 2.0.0 version that the kit skills expect, for example 1.2.0. - /// The result of the check with the versions and its warnings. - /// - /// is . - /// - /// - /// is not a valid SemVer 2.0.0 version. - /// - /// - /// The version of the running engine is not a valid SemVer 2.0.0 version, which is a defect of the engine build. - /// - /// - /// The engine is a release, and its major or minor version differs from that of - /// . - /// - EngineVersionCheckResult Check(string expectedVersion); -} diff --git a/src/CreativeCoders.ShadeKit.Core/Versions/Warnings/EnginePrereleaseVersionMismatchWarning.cs b/src/CreativeCoders.ShadeKit.Core/Versions/Warnings/EnginePrereleaseVersionMismatchWarning.cs deleted file mode 100644 index c61674b..0000000 --- a/src/CreativeCoders.ShadeKit.Core/Versions/Warnings/EnginePrereleaseVersionMismatchWarning.cs +++ /dev/null @@ -1,18 +0,0 @@ -using CreativeCoders.ShadeKit.Core.Warnings; - -namespace CreativeCoders.ShadeKit.Core.Versions.Warnings; - -/// -/// Represents a warning that the major or minor version of a prerelease engine differs from that of the expected -/// version; the engine is used anyway because it is a prerelease. -/// -/// The version of the running engine, for example 1.3.0-beta.1. -/// The expected version as it was passed to the check. -/// -/// One of the enumeration values that specifies whether the engine is older or newer than the expected version. -/// -public sealed record EnginePrereleaseVersionMismatchWarning( - string EngineVersion, - string ExpectedVersion, - EngineVersionMismatchDirection Direction) - : KitWarning; diff --git a/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Integrations/IntegrationsCommandsEndToEndTests.cs b/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Integrations/IntegrationsCommandsEndToEndTests.cs index 9e1f408..fed924d 100644 --- a/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Integrations/IntegrationsCommandsEndToEndTests.cs +++ b/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Integrations/IntegrationsCommandsEndToEndTests.cs @@ -919,14 +919,15 @@ public async Task Version_AfterInstall_ListsIntegrationOfEngineVersionInPlainMod .Should().Be(0); GetLines(output.TrimEnd()) - .Should().Equal("shade-kit 0.8.0", "claude: shade-kit@creativecoders-shade-kit 0.8.0 (v0.8.0)"); + .Should().Equal("shade-kit 0.8.0", "CLI contract 1 (supported: 1 to 1)", + "claude: shade-kit@creativecoders-shade-kit 0.8.0 (v0.8.0)"); } [Fact] public async Task Version_ClaudeNotOnPath_SucceedsWithEmptyIntegrationsAndNoWarning() { // Act - var run = await _harness.RunJsonAsync("version", "--json", "--expect", "0.8.0"); + var run = await _harness.RunJsonAsync("version", "--json"); // Assert run.ExitCode @@ -935,9 +936,6 @@ public async Task Version_ClaudeNotOnPath_SucceedsWithEmptyIntegrationsAndNoWarn run.Root.GetProperty("ok").GetBoolean() .Should().BeTrue(); - run.Root.GetProperty("data").GetProperty("expectedVersion").GetString() - .Should().Be("0.8.0"); - run.Root.GetProperty("data").GetProperty("integrations").GetArrayLength() .Should().Be(0); @@ -969,16 +967,16 @@ public async Task Version_ClaudeOnPathFails_SucceedsWithEmptyIntegrationsAndAgen } [Fact] - public async Task Version_ExpectMismatchWithInstalledIntegration_StillExits50() + public async Task Version_ExpectContractMismatchWithInstalledIntegration_Exits54WithoutAskingClaude() { // Arrange _claude.AttachTo(_harness).WithInstalledPlugin("v0.8.0"); // Act - var run = await _harness.RunJsonAsync("version", "--json", "--expect", "0.9.0"); + var run = await _harness.RunJsonAsync("version", "--json", "--expect-contract", "999"); // Assert - AssertError(run, ShadeKitCliExitCodes.VersionMismatch, ShadeKitCliErrorCodes.VersionMismatch); + AssertError(run, ShadeKitCliExitCodes.EngineOutdated, ShadeKitCliErrorCodes.EngineOutdated); _claude.Calls .Should().BeEmpty(); diff --git a/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Integrations/IntegrationsMultiAgentEndToEndTests.cs b/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Integrations/IntegrationsMultiAgentEndToEndTests.cs index e44c12f..86c451e 100644 --- a/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Integrations/IntegrationsMultiAgentEndToEndTests.cs +++ b/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Integrations/IntegrationsMultiAgentEndToEndTests.cs @@ -688,7 +688,7 @@ public async Task Version_ThreeAgentsWithOneMissing_ListsInstalledIntegrationsWi _codex.AttachTo(_harness).WithInstalledPlugin("v0.8.0"); // Act - var run = await _harness.RunJsonAsync("version", "--json", "--expect", "0.8.0"); + var run = await _harness.RunJsonAsync("version", "--json"); // Assert run.ExitCode @@ -756,6 +756,7 @@ public async Task Version_PlainModeThreeAgents_ListsEachWithoutNullValuesAndMark GetLines(output.TrimEnd()) .Should().Equal( "shade-kit 0.8.0", + "CLI contract 1 (supported: 1 to 1)", "claude: shade-kit@creativecoders-shade-kit 0.8.0 (v0.8.0)", "copilot: shade-kit@creativecoders-shade-kit 0.8.0 (v0.8.0) (disabled)", "codex: shade-kit@creativecoders-shade-kit (disabled)"); diff --git a/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Version/ExpectedContractOptionConverterTests.cs b/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Version/ExpectedContractOptionConverterTests.cs new file mode 100644 index 0000000..7be9193 --- /dev/null +++ b/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Version/ExpectedContractOptionConverterTests.cs @@ -0,0 +1,70 @@ +using AwesomeAssertions; +using CreativeCoders.ShadeKit.Cli.Commands.Version; +using CreativeCoders.SysConsole.Cli.Parsing; + +namespace CreativeCoders.ShadeKit.Cli.Tests.Commands.Version; + +public class ExpectedContractOptionConverterTests +{ + private static readonly OptionParameterAttribute ExpectContractAttribute = + new OptionParameterAttribute("expect-contract"); + + [Fact] + public void Convert_Null_ThrowsExpectedContractInvalidException() + { + // Arrange + var converter = new ExpectedContractOptionConverter(); + + // Act + var act = () => converter.Convert(null, typeof(int?), ExpectContractAttribute); + + // Assert + act + .Should().Throw() + .Which.Value.Should().BeNull(); + } + + [Theory] + [InlineData("abc")] + [InlineData("-1")] + [InlineData("+1")] + [InlineData("01")] + [InlineData(" 1")] + [InlineData("1 ")] + [InlineData("1.0")] + [InlineData("2147483648")] + [InlineData("")] + [InlineData("١")] + public void Convert_InvalidText_ThrowsExpectedContractInvalidExceptionWithValue(string value) + { + // Arrange + var converter = new ExpectedContractOptionConverter(); + + // Act + var act = () => converter.Convert(value, typeof(int?), ExpectContractAttribute); + + // Assert + act + .Should().Throw() + .Which.Value.Should().Be(value); + } + + [Theory] + [InlineData("0", 0)] + [InlineData("1", 1)] + [InlineData("42", 42)] + [InlineData("2147483647", int.MaxValue)] + public void Convert_ValidText_ReturnsInt(string value, int expected) + { + // Arrange + var converter = new ExpectedContractOptionConverter(); + + // Act + var result = converter.Convert(value, typeof(int?), ExpectContractAttribute); + + // Assert + result + .Should().BeOfType() + .Which.Should().Be(expected); + } +} diff --git a/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Version/ExpectedVersionOptionConverterTests.cs b/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Version/ExpectedVersionOptionConverterTests.cs deleted file mode 100644 index 56f9a0b..0000000 --- a/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Version/ExpectedVersionOptionConverterTests.cs +++ /dev/null @@ -1,42 +0,0 @@ -using AwesomeAssertions; -using CreativeCoders.ShadeKit.Cli.Commands.Version; -using CreativeCoders.SysConsole.Cli.Parsing; - -namespace CreativeCoders.ShadeKit.Cli.Tests.Commands.Version; - -public class ExpectedVersionOptionConverterTests -{ - private static readonly OptionParameterAttribute ExpectAttribute = new OptionParameterAttribute("expect"); - - [Fact] - [Trait("Requirement", "FP06-1-AC5")] - public void Convert_NullValue_ThrowsExpectedVersionMissingException() - { - // Arrange - var converter = new ExpectedVersionOptionConverter(); - - // Act - var act = () => converter.Convert(null, typeof(string), ExpectAttribute); - - // Assert - act - .Should().Throw(); - } - - [Theory] - [InlineData("1.2.0")] - [InlineData("abc")] - [InlineData("")] - public void Convert_Value_ReturnsValueUnchanged(string value) - { - // Arrange - var converter = new ExpectedVersionOptionConverter(); - - // Act - var result = converter.Convert(value, typeof(string), ExpectAttribute); - - // Assert - result - .Should().Be(value); - } -} diff --git a/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Version/VersionCommandOptionsTests.cs b/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Version/VersionCommandOptionsTests.cs index 24672fd..28158bb 100644 --- a/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Version/VersionCommandOptionsTests.cs +++ b/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Version/VersionCommandOptionsTests.cs @@ -1,3 +1,4 @@ +using System.Reflection; using AwesomeAssertions; using CreativeCoders.ShadeKit.Cli.Commands.Version; using CreativeCoders.SysConsole.Cli.Parsing; @@ -6,12 +7,45 @@ namespace CreativeCoders.ShadeKit.Cli.Tests.Commands.Version; public class VersionCommandOptionsTests { + [Fact] + public void Options_ExpectOption_DoesNotExist() + { + // Act + var longNames = typeof(VersionCommandOptions).GetProperties() + .Select(x => x.GetCustomAttribute()) + .OfType() + .Select(x => x.LongName); + + // Assert + longNames + .Should().NotContain("expect"); + } + + [Fact] + public void Options_ExpectContract_HasConverterAndLongName() + { + // Act + var attribute = typeof(VersionCommandOptions) + .GetProperty(nameof(VersionCommandOptions.ExpectContract))! + .GetCustomAttribute(); + + // Assert + attribute + .Should().NotBeNull(); + + attribute.LongName + .Should().Be("expect-contract"); + + attribute.Converter + .Should().Be(); + } + [Theory] - [Trait("Requirement", "FP06-1-AC5")] - [InlineData("--expect")] - [InlineData("--json", "--expect")] - [InlineData("--expect", "--json")] - public void Parse_ExpectWithoutValue_ThrowsExpectedVersionMissingException(params string[] args) + [InlineData("--expect-contract")] + [InlineData("--json", "--expect-contract")] + [InlineData("--expect-contract", "--json")] + public void Parse_ExpectContractWithoutValue_ThrowsExpectedContractInvalidExceptionWithoutValue( + params string[] args) { // Arrange var parser = new OptionParser(typeof(VersionCommandOptions)); @@ -21,17 +55,18 @@ public void Parse_ExpectWithoutValue_ThrowsExpectedVersionMissingException(param // Assert act - .Should().Throw(); + .Should().Throw() + .Which.Value.Should().BeNull(); } [Fact] - public void Parse_NoExpect_LeavesExpectNull() + public void Parse_NoExpectContract_LeavesExpectContractNull() { // Act var options = (VersionCommandOptions)new OptionParser(typeof(VersionCommandOptions)).Parse(["--json"]); // Assert - options.Expect + options.ExpectContract .Should().BeNull(); options.Json @@ -39,19 +74,35 @@ public void Parse_NoExpect_LeavesExpectNull() } [Theory] - [InlineData("1.2.0")] - [InlineData("")] - public void Parse_ExpectWithValue_SetsExpectToValue(string value) + [InlineData("0", 0)] + [InlineData("1", 1)] + [InlineData("999", 999)] + public void Parse_ExpectContractWithValue_SetsExpectContractToNumber(string value, int expected) { // Act var options = (VersionCommandOptions)new OptionParser(typeof(VersionCommandOptions)) - .Parse(["--expect", value, "--json"]); + .Parse(["--expect-contract", value, "--json"]); // Assert - options.Expect - .Should().Be(value); + options.ExpectContract + .Should().Be(expected); options.Json .Should().BeTrue(); } + + [Fact] + public void Parse_ExpectContractNotANumber_ThrowsExpectedContractInvalidExceptionWithValue() + { + // Arrange + var parser = new OptionParser(typeof(VersionCommandOptions)); + + // Act + var act = () => parser.Parse(["--expect-contract", "abc"]); + + // Assert + act + .Should().Throw() + .Which.Value.Should().Be("abc"); + } } diff --git a/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Version/VersionCommandTests.cs b/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Version/VersionCommandTests.cs index 22a7a04..11e6abf 100644 --- a/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Version/VersionCommandTests.cs +++ b/tests/CreativeCoders.ShadeKit.Cli.Tests/Commands/Version/VersionCommandTests.cs @@ -11,6 +11,7 @@ using CreativeCoders.ShadeKit.Core.Integrations; using CreativeCoders.ShadeKit.Core.Integrations.Warnings; using CreativeCoders.ShadeKit.Core.Versions; +using CreativeCoders.ShadeKit.Core.Versions.Exceptions; using FakeItEasy; using Spectre.Console; using Spectre.Console.Testing; @@ -19,19 +20,21 @@ namespace CreativeCoders.ShadeKit.Cli.Tests.Commands.Version; public class VersionCommandTests { - private const string OlderEngineMessage = - "The SHADE kit engine 1.2.3 does not fit the kit skills 1.3.0: the major and minor versions must be equal. " + - "Update the engine to 1.3, then run the skill again."; + // The context of the tests maps failures with CliErrorMapperTests.CreateMapper, whose engine version is 1.0.0. + private const string MapperEngineVersion = "1.0.0"; - private const string NewerEngineMessage = - "The SHADE kit engine 1.2.3 does not fit the kit skills 1.1.0: the major and minor versions must be equal. " + - "Run 'shade-kit integrations install' to install the SHADE kit skills 1.2, then run the skill again."; + private const string EngineOutdatedMessage = + "The SHADE kit engine 1.0.0 supports the CLI contracts 1 to 1, but the kit skills need the CLI contract 2. " + + "Update the engine, then run the skill again."; - private const string PluginId = "shade-kit@creativecoders-shade-kit"; + private const string SkillsOutdatedMessage = + "The kit skills are written for the CLI contract 1, but the SHADE kit engine 1.0.0 supports only the CLI " + + "contracts 2 to 3. Run 'shade-kit integrations install' to install the matching kit skills, then run the " + + "skill again."; + + private const string ContractLine = "CLI contract 1 (supported: 1 to 1)"; - private const string PrereleaseWarningMessage = - "The prerelease engine 1.2.3-beta.1 does not fit the kit skills 1.3.0 (the major and minor versions differ); " + - "it is used anyway because it is a prerelease."; + private const string PluginId = "shade-kit@creativecoders-shade-kit"; private static readonly InstalledIntegration ClaudeIntegration = new InstalledIntegration("claude", PluginId, "0.8.0", "v0.8.0", true); @@ -49,16 +52,32 @@ public async Task ExecuteAsync_PlainMode_WritesToolNameAndEngineVersion() await command.ExecuteAsync(new VersionCommandOptions()); // Assert - console.Output.TrimEnd() - .Should().Be("shade-kit 1.2.3"); - console.Lines - .Should().Equal("shade-kit 1.2.3"); + .Should().Equal("shade-kit 1.2.3", ContractLine); jsonOutput.ToString() .Should().BeEmpty(); } + [Fact] + public async Task ExecuteAsync_PlainMode_WritesContractLineAfterVersionLine() + { + // Arrange + var console = new TestConsole().Width(1000); + var command = CreateCommand(console, TextWriter.Null, "1.2.3", + integrationService: CreateIntegrationService(ClaudeIntegration)); + + // Act + await command.ExecuteAsync(new VersionCommandOptions()); + + // Assert + console.Lines + .Should().Equal( + "shade-kit 1.2.3", + $"CLI contract {CliContract.Current} (supported: {CliContract.MinSupported} to {CliContract.Current})", + "claude: shade-kit@creativecoders-shade-kit 0.8.0 (v0.8.0)"); + } + [Fact] [Trait("Requirement", "FP01-AC7")] [Trait("Requirement", "FP01-AC12")] @@ -104,9 +123,65 @@ public async Task ExecuteAsync_JsonMode_WritesEnvelopeWithEngineVersionAndOneFor .Should().BeEmpty(); } + [Fact] + public async Task ExecuteAsync_JsonMode_WritesContractWithCurrentAndMinSupported() + { + // Arrange + using var jsonOutput = new StringWriter(); + var command = CreateCommand(new TestConsole(), jsonOutput, "1.2.3"); + + // Act + await command.ExecuteAsync(new VersionCommandOptions { Json = true }); + + // Assert + using var document = JsonDocument.Parse(jsonOutput.ToString()); + var data = document.RootElement.GetProperty("data"); + + data.EnumerateObject().Select(x => x.Name) + .Should().Equal("engineVersion", "formats", "contract", "integrations"); + + data.GetProperty("contract").EnumerateObject().Select(x => (x.Name, x.Value.GetInt32())) + .Should().Equal(("current", CliContract.Current), ("minSupported", CliContract.MinSupported)); + } + + [Fact] + public async Task ExecuteAsync_JsonModeWithWiderWindow_WritesCurrentAndMinSupportedOfWindow() + { + // Arrange + using var jsonOutput = new StringWriter(); + var command = CreateCommand(new TestConsole(), jsonOutput, "1.2.3", + checker: new CliContractChecker(new CliContractWindow(2, 4))); + + // Act + await command.ExecuteAsync(new VersionCommandOptions { Json = true }); + + // Assert + using var document = JsonDocument.Parse(jsonOutput.ToString()); + + document.RootElement.GetProperty("data").GetProperty("contract").EnumerateObject() + .Select(x => (x.Name, x.Value.GetInt32())) + .Should().Equal(("current", 4), ("minSupported", 2)); + } + + [Fact] + public async Task ExecuteAsync_PlainModeWithWiderWindow_WritesContractLineOfWindow() + { + // Arrange + var console = new TestConsole().Width(1000); + var command = CreateCommand(console, TextWriter.Null, "1.2.3", + checker: new CliContractChecker(new CliContractWindow(2, 4))); + + // Act + await command.ExecuteAsync(new VersionCommandOptions()); + + // Assert + console.Lines + .Should().Equal("shade-kit 1.2.3", "CLI contract 4 (supported: 2 to 4)"); + } + [Fact] [Trait("Requirement", "FP06-1-AC6")] - public async Task ExecuteAsync_JsonModeWithoutExpect_WritesEnvelopeWithoutExpectedVersionUnchanged() + public async Task ExecuteAsync_JsonModeWithoutExpectContract_WritesEnvelopeWithContractAndIntegrations() { // Arrange using var jsonOutput = new StringWriter(); @@ -130,6 +205,10 @@ public async Task ExecuteAsync_JsonModeWithoutExpect_WritesEnvelopeWithoutExpect "current-feature": 1, "templates-lock": 1 }, + "contract": { + "current": 1, + "minSupported": 1 + }, "integrations": [] }, "warnings": [], @@ -139,15 +218,13 @@ public async Task ExecuteAsync_JsonModeWithoutExpect_WritesEnvelopeWithoutExpect } [Theory] - [Trait("Requirement", "FP06-1-AC6")] [InlineData(false)] [InlineData(true)] - public async Task ExecuteAsync_WithoutExpect_DoesNotCheckEngineVersion(bool json) + public async Task ExecuteAsync_WithoutExpectContract_DoesNotCheckContract(bool json) { // Arrange - var checker = A.Fake(); - var command = new VersionCommand(TestShadeKitCommandContext.Create(new TestConsole()), - CreateEngineVersionProvider("1.2.3"), FormatRegistry.CreateDefault(), checker, CreateIntegrationService()); + var checker = CreateChecker(); + var command = CreateCommand(new TestConsole(), TextWriter.Null, "1.2.3", checker: checker); // Act var result = await command.ExecuteAsync(new VersionCommandOptions { Json = json }); @@ -156,47 +233,35 @@ public async Task ExecuteAsync_WithoutExpect_DoesNotCheckEngineVersion(bool json result.ExitCode .Should().Be(0); - A.CallTo(checker) + A.CallTo(() => checker.Check(A._)) .MustNotHaveHappened(); } - [Theory] - [Trait("Requirement", "FP06-1-AC3")] - [InlineData("1.2.3")] - [InlineData("1.2.0")] - [InlineData("1.2.9")] - [InlineData("1.2.0-rc.1")] - [InlineData("1.2.0+build.5")] - public async Task ExecuteAsync_JsonModeExpectWithEqualMajorAndMinor_WritesSuccessWithExpectedVersionAndNoWarning( - string expect) + [Fact] + public async Task ExecuteAsync_JsonModeExpectContractInWindow_WritesSuccess() { // Arrange + var checker = CreateChecker(); var console = new TestConsole(); using var jsonOutput = new StringWriter(); - var command = CreateCommand(console, jsonOutput, "1.2.3"); + var command = CreateCommand(console, jsonOutput, "1.2.3", checker: checker); // Act - var result = await command.ExecuteAsync(new VersionCommandOptions { Json = true, Expect = expect }); + var result = await command.ExecuteAsync(new VersionCommandOptions { Json = true, ExpectContract = 1 }); // Assert result.ExitCode .Should().Be(0); + A.CallTo(() => checker.Check(1)) + .MustHaveHappenedOnceExactly(); + using var document = JsonDocument.Parse(jsonOutput.ToString()); var root = document.RootElement; root.GetProperty("ok").GetBoolean() .Should().BeTrue(); - root.GetProperty("data").EnumerateObject().Select(x => x.Name) - .Should().Equal("engineVersion", "formats", "expectedVersion", "integrations"); - - root.GetProperty("data").GetProperty("engineVersion").GetString() - .Should().Be("1.2.3"); - - root.GetProperty("data").GetProperty("expectedVersion").GetString() - .Should().Be(expect); - root.GetProperty("warnings").GetArrayLength() .Should().Be(0); @@ -208,283 +273,288 @@ public async Task ExecuteAsync_JsonModeExpectWithEqualMajorAndMinor_WritesSucces } [Fact] - [Trait("Requirement", "FP06-1-AC3")] - public async Task ExecuteAsync_PlainModeExpectWithDifferentPatch_WritesOnlyToolNameAndEngineVersion() + public async Task ExecuteAsync_JsonModeExpectContractWithRealChecker_SucceedsForEveryContractInWindow() { // Arrange - var console = new TestConsole(); - using var jsonOutput = new StringWriter(); - var command = CreateCommand(console, jsonOutput, "1.2.3"); + var checker = new CliContractChecker(new CliContractWindow(2, 4)); + var expectedContracts = new List(); // Act - var result = await command.ExecuteAsync(new VersionCommandOptions { Expect = "1.2.0" }); + foreach (var contract in new[] { 2, 3, 4 }) + { + using var jsonOutput = new StringWriter(); + var command = CreateCommand(new TestConsole(), jsonOutput, "1.2.3", checker: checker); - // Assert - result.ExitCode - .Should().Be(0); + await command.ExecuteAsync(new VersionCommandOptions { Json = true, ExpectContract = contract }); - console.Lines - .Should().Equal("shade-kit 1.2.3"); + using var document = JsonDocument.Parse(jsonOutput.ToString()); - jsonOutput.ToString() - .Should().BeEmpty(); + expectedContracts.Add(document.RootElement.GetProperty("data").GetProperty("expectedContract").GetInt32()); + } + + // Assert + expectedContracts + .Should().Equal(2, 3, 4); } - [Theory] - [Trait("Requirement", "FP06-1-AC1")] - [Trait("Requirement", "FP06-1-AC2")] - [InlineData("1.3.0", OlderEngineMessage)] - [InlineData("1.1.0", NewerEngineMessage)] - public async Task ExecuteAsync_JsonModeReleaseEngineMismatch_WritesVersionMismatchEnvelopeAndAbortsWith50( - string expect, string message) + [Fact] + public async Task ExecuteAsync_JsonModeExpectContract_WritesExpectedContract() { // Arrange - var console = new TestConsole(); using var jsonOutput = new StringWriter(); - var command = CreateCommand(console, jsonOutput, "1.2.3"); + var command = CreateCommand(new TestConsole(), jsonOutput, "1.2.3"); // Act - var act = () => command.ExecuteAsync(new VersionCommandOptions { Json = true, Expect = expect }); + await command.ExecuteAsync(new VersionCommandOptions { Json = true, ExpectContract = 1 }); // Assert - var exception = (await act.Should().ThrowAsync()).Which; + jsonOutput.ToString() + .Should().Be( + """ + { + "ok": true, + "data": { + "engineVersion": "1.2.3", + "formats": { + "config": 1, + "gates": 1, + "feature": 1, + "current-feature": 1, + "templates-lock": 1 + }, + "contract": { + "current": 1, + "minSupported": 1 + }, + "expectedContract": 1 + }, + "warnings": [], + "error": null + } + """.ReplaceLineEndings("\n") + "\n"); + } - exception.ExitCode - .Should().Be(ShadeKitCliExitCodes.VersionMismatch); + [Fact] + public async Task ExecuteAsync_JsonModeWithoutExpectContract_OmitsExpectedContract() + { + // Arrange + using var jsonOutput = new StringWriter(); + var command = CreateCommand(new TestConsole(), jsonOutput, "1.2.3"); - exception.PrintMessage - .Should().BeFalse(); + // Act + await command.ExecuteAsync(new VersionCommandOptions { Json = true }); + // Assert using var document = JsonDocument.Parse(jsonOutput.ToString()); - var root = document.RootElement; - root.GetProperty("ok").GetBoolean() + document.RootElement.GetProperty("data").TryGetProperty("expectedContract", out _) .Should().BeFalse(); - - root.GetProperty("data").ValueKind - .Should().Be(JsonValueKind.Null); - - root.GetProperty("error").GetProperty("code").GetString() - .Should().Be(ShadeKitCliErrorCodes.VersionMismatch); - - root.GetProperty("error").GetProperty("message").GetString() - .Should().Be(message); - - console.Output - .Should().BeEmpty(); } - [Theory] - [Trait("Requirement", "FP06-1-AC1")] - [Trait("Requirement", "FP06-1-AC2")] - [InlineData("1.3.0", OlderEngineMessage)] - [InlineData("1.1.0", NewerEngineMessage)] - public async Task ExecuteAsync_PlainModeReleaseEngineMismatch_AbortsWith50AndMessageWithoutOutput( - string expect, string message) + [Fact] + public async Task ExecuteAsync_JsonModeEngineOutdated_WritesEngineOutdatedEnvelopeAndAbortsWith54() { // Arrange var console = new TestConsole(); using var jsonOutput = new StringWriter(); - var command = CreateCommand(console, jsonOutput, "1.2.3"); + var command = CreateCommand(console, jsonOutput, MapperEngineVersion, + checker: CreateThrowingChecker(new EngineContractOutdatedException(2, 1, 1))); // Act - var act = () => command.ExecuteAsync(new VersionCommandOptions { Expect = expect }); + var act = () => command.ExecuteAsync(new VersionCommandOptions { Json = true, ExpectContract = 2 }); // Assert var exception = (await act.Should().ThrowAsync()).Which; exception.ExitCode - .Should().Be(ShadeKitCliExitCodes.VersionMismatch); + .Should().Be(ShadeKitCliExitCodes.EngineOutdated); exception.PrintMessage - .Should().BeTrue(); + .Should().BeFalse(); - exception.Message - .Should().Be(message); + AssertFailureEnvelope(jsonOutput.ToString(), ShadeKitCliErrorCodes.EngineOutdated, EngineOutdatedMessage); console.Output .Should().BeEmpty(); - - jsonOutput.ToString() - .Should().BeEmpty(); } - [Theory] - [Trait("Requirement", "FP06-1-AC1")] - [InlineData("2.0.0")] - [InlineData("0.9.0")] - public async Task ExecuteAsync_ReleaseEngineWithDifferentMajor_AbortsWith50(string expect) + [Fact] + public async Task ExecuteAsync_JsonModeSkillsOutdated_WritesSkillsOutdatedEnvelopeAndAbortsWith55() { // Arrange - var command = CreateCommand(new TestConsole(), TextWriter.Null, "1.2.3"); + var console = new TestConsole(); + using var jsonOutput = new StringWriter(); + var command = CreateCommand(console, jsonOutput, MapperEngineVersion, + checker: CreateThrowingChecker(new SkillsContractOutdatedException(1, 2, 3))); // Act - var act = () => command.ExecuteAsync(new VersionCommandOptions { Json = true, Expect = expect }); + var act = () => command.ExecuteAsync(new VersionCommandOptions { Json = true, ExpectContract = 1 }); // Assert - (await act.Should().ThrowAsync()) - .Which.ExitCode.Should().Be(ShadeKitCliExitCodes.VersionMismatch); + var exception = (await act.Should().ThrowAsync()).Which; + + exception.ExitCode + .Should().Be(ShadeKitCliExitCodes.SkillsOutdated); + + exception.PrintMessage + .Should().BeFalse(); + + AssertFailureEnvelope(jsonOutput.ToString(), ShadeKitCliErrorCodes.SkillsOutdated, SkillsOutdatedMessage); + + console.Output + .Should().BeEmpty(); } [Fact] - [Trait("Requirement", "FP06-1-AC4")] - public async Task ExecuteAsync_JsonModePrereleaseEngineMismatch_WritesSuccessEnvelopeWithWarning() + public async Task ExecuteAsync_PlainModeEngineOutdated_AbortsWith54AndMessageWithoutOutput() { // Arrange var console = new TestConsole(); using var jsonOutput = new StringWriter(); - var command = CreateCommand(console, jsonOutput, "1.2.3-beta.1"); + var command = CreateCommand(console, jsonOutput, MapperEngineVersion, + checker: CreateThrowingChecker(new EngineContractOutdatedException(2, 1, 1))); // Act - var result = await command.ExecuteAsync(new VersionCommandOptions { Json = true, Expect = "1.3.0" }); + var act = () => command.ExecuteAsync(new VersionCommandOptions { ExpectContract = 2 }); // Assert - result.ExitCode - .Should().Be(0); + var exception = (await act.Should().ThrowAsync()).Which; - using var document = JsonDocument.Parse(jsonOutput.ToString()); - var root = document.RootElement; + exception.ExitCode + .Should().Be(ShadeKitCliExitCodes.EngineOutdated); - root.GetProperty("ok").GetBoolean() + exception.PrintMessage .Should().BeTrue(); - root.GetProperty("data").GetProperty("engineVersion").GetString() - .Should().Be("1.2.3-beta.1"); - - root.GetProperty("data").GetProperty("expectedVersion").GetString() - .Should().Be("1.3.0"); - - root.GetProperty("warnings").EnumerateArray() - .Select(x => (x.GetProperty("code").GetString(), x.GetProperty("message").GetString())) - .Should().Equal((ShadeKitCliWarningCodes.EnginePrereleaseVersionMismatch, PrereleaseWarningMessage)); - - root.GetProperty("error").ValueKind - .Should().Be(JsonValueKind.Null); + exception.Message + .Should().Be(EngineOutdatedMessage); console.Output .Should().BeEmpty(); + + jsonOutput.ToString() + .Should().BeEmpty(); } [Fact] - [Trait("Requirement", "FP06-1-AC4")] - public async Task ExecuteAsync_PlainModePrereleaseEngineMismatch_WritesWarningBeforeToolNameAndEngineVersion() + public async Task ExecuteAsync_PlainModeSkillsOutdated_AbortsWith55AndMessageWithoutOutput() { // Arrange - // A wide console keeps the long warning on one line. - var console = new TestConsole().Width(1000); + var console = new TestConsole(); using var jsonOutput = new StringWriter(); - var command = CreateCommand(console, jsonOutput, "1.2.3-beta.1"); + var command = CreateCommand(console, jsonOutput, MapperEngineVersion, + checker: CreateThrowingChecker(new SkillsContractOutdatedException(1, 2, 3))); // Act - var result = await command.ExecuteAsync(new VersionCommandOptions { Expect = "1.3.0" }); + var act = () => command.ExecuteAsync(new VersionCommandOptions { ExpectContract = 1 }); // Assert - result.ExitCode - .Should().Be(0); + var exception = (await act.Should().ThrowAsync()).Which; - console.Lines - .Should().Equal($"Warning: {PrereleaseWarningMessage}", "shade-kit 1.2.3-beta.1"); + exception.ExitCode + .Should().Be(ShadeKitCliExitCodes.SkillsOutdated); + + exception.PrintMessage + .Should().BeTrue(); + + exception.Message + .Should().Be(SkillsOutdatedMessage); + + console.Output + .Should().BeEmpty(); jsonOutput.ToString() .Should().BeEmpty(); } - [Theory] - [Trait("Requirement", "FP06-1-AC5")] - [InlineData("abc")] - [InlineData("")] - [InlineData(" ")] - [InlineData("v1.2.3")] - [InlineData("1.2")] - [InlineData("1.2.3.4")] - public async Task ExecuteAsync_JsonModeInvalidExpect_WritesInvalidArgumentsEnvelopeAndAbortsWith2(string expect) + [Fact] + public async Task ExecuteAsync_ExpectContract_DoesNotReadIntegrationsAndOmitsField() { // Arrange - var console = new TestConsole(); + var integrationService = CreateIntegrationService(ClaudeIntegration); using var jsonOutput = new StringWriter(); - var command = CreateCommand(console, jsonOutput, "1.2.3"); + var command = CreateCommand(new TestConsole(), jsonOutput, "1.2.3", integrationService: integrationService); // Act - var act = () => command.ExecuteAsync(new VersionCommandOptions { Json = true, Expect = expect }); + await command.ExecuteAsync(new VersionCommandOptions { Json = true, ExpectContract = 1 }); // Assert - var exception = (await act.Should().ThrowAsync()).Which; + A.CallTo(integrationService) + .MustNotHaveHappened(); - exception.ExitCode - .Should().Be(ShadeKitCliExitCodes.InvalidArguments); + using var document = JsonDocument.Parse(jsonOutput.ToString()); - exception.PrintMessage + document.RootElement.GetProperty("data").TryGetProperty("integrations", out _) .Should().BeFalse(); + } - using var document = JsonDocument.Parse(jsonOutput.ToString()); - var root = document.RootElement; + [Theory] + [InlineData(true, true)] + [InlineData(true, false)] + [InlineData(false, true)] + [InlineData(false, false)] + public async Task ExecuteAsync_ContractMismatch_DoesNotReadIntegrations(bool engineOutdated, bool json) + { + // Arrange + Exception mismatch = engineOutdated + ? new EngineContractOutdatedException(7, 1, 1) + : new SkillsContractOutdatedException(7, 8, 9); - root.GetProperty("ok").GetBoolean() - .Should().BeFalse(); + var integrationService = CreateIntegrationService(ClaudeIntegration); + var command = CreateCommand(new TestConsole(), TextWriter.Null, "1.2.3", + integrationService: integrationService, checker: CreateThrowingChecker(mismatch)); - root.GetProperty("error").GetProperty("code").GetString() - .Should().Be(ShadeKitCliErrorCodes.InvalidArguments); + // Act + var act = () => command.ExecuteAsync(new VersionCommandOptions { Json = json, ExpectContract = 7 }); - root.GetProperty("error").GetProperty("message").GetString() - .Should().Be(CreateInvalidExpectMessage(expect)); + // Assert + await act.Should().ThrowAsync(); - console.Output - .Should().BeEmpty(); + A.CallTo(integrationService) + .MustNotHaveHappened(); } [Fact] - [Trait("Requirement", "FP06-1-AC5")] - public async Task ExecuteAsync_PlainModeInvalidExpect_AbortsWith2AndMessageWithoutOutput() + public async Task ExecuteAsync_PlainModeExpectContract_WritesNoIntegrationLines() { // Arrange - var console = new TestConsole(); - using var jsonOutput = new StringWriter(); - var command = CreateCommand(console, jsonOutput, "1.2.3"); + var console = new TestConsole().Width(1000); + var integrationService = CreateIntegrationService(ClaudeIntegration); + var command = CreateCommand(console, TextWriter.Null, "1.2.3", integrationService: integrationService); // Act - var act = () => command.ExecuteAsync(new VersionCommandOptions { Expect = "abc" }); + var result = await command.ExecuteAsync(new VersionCommandOptions { ExpectContract = 1 }); // Assert - var exception = (await act.Should().ThrowAsync()).Which; - - exception.ExitCode - .Should().Be(ShadeKitCliExitCodes.InvalidArguments); - - exception.PrintMessage - .Should().BeTrue(); - - exception.Message - .Should().Be(CreateInvalidExpectMessage("abc")); + result.ExitCode + .Should().Be(0); - console.Output - .Should().BeEmpty(); + console.Lines + .Should().Equal("shade-kit 1.2.3", ContractLine); - jsonOutput.ToString() - .Should().BeEmpty(); + A.CallTo(integrationService) + .MustNotHaveHappened(); } - [Theory] - [InlineData(false)] - [InlineData(true)] - public async Task ExecuteAsync_ExpectWithInvalidEngineVersion_ThrowsInvalidOperationExceptionAndWritesNothing( - bool json) + [Fact] + public async Task ExecuteAsync_JsonModeWithoutExpectContract_WritesIntegrations() { // Arrange - var console = new TestConsole(); + var integrationService = CreateIntegrationService(ClaudeIntegration); using var jsonOutput = new StringWriter(); - var command = CreateCommand(console, jsonOutput, "not-a-version"); + var command = CreateCommand(new TestConsole(), jsonOutput, "1.2.3", integrationService: integrationService); // Act - var act = () => command.ExecuteAsync(new VersionCommandOptions { Json = json, Expect = "1.2.3" }); + await command.ExecuteAsync(new VersionCommandOptions { Json = true }); // Assert - await act.Should().ThrowAsync(); + A.CallTo(() => integrationService.GetInstalledAsync(A._)) + .MustHaveHappenedOnceExactly(); - console.Output - .Should().BeEmpty(); + using var document = JsonDocument.Parse(jsonOutput.ToString()); - jsonOutput.ToString() - .Should().BeEmpty(); + document.RootElement.GetProperty("data").GetProperty("integrations").GetArrayLength() + .Should().Be(1); } [Fact] @@ -632,6 +702,7 @@ public async Task ExecuteAsync_PlainModeWithInstalledIntegrations_WritesOneLineP console.Lines .Should().Equal( "shade-kit 0.8.0", + ContractLine, "claude: shade-kit@creativecoders-shade-kit 0.8.0 (v0.8.0)", "claude: shade-kit@creativecoders-shade-kit (main) (disabled)"); } @@ -685,74 +756,8 @@ public async Task ExecuteAsync_PlainModeAgentUnavailable_WritesWarningBeforeVers .Should().Equal( "Warning: The SHADE kit integration of the agent 'claude' cannot be read, so it is not listed: " + "claude was not found on the PATH.", - "shade-kit 0.8.0"); - } - - [Fact] - [Trait("Requirement", "FP06-1-AC4")] - public async Task ExecuteAsync_PrereleaseMismatchAndAgentUnavailable_WritesCheckWarningBeforeAgentWarning() - { - // Arrange - using var jsonOutput = new StringWriter(); - var command = CreateCommand(new TestConsole(), jsonOutput, "1.2.3-beta.1", - integrationService: CreateIntegrationService(new InstalledIntegrationsResult([ClaudeIntegration], - [new AgentUnavailableWarning("other", "It fails.")]))); - - // Act - await command.ExecuteAsync(new VersionCommandOptions { Json = true, Expect = "1.3.0" }); - - // Assert - using var document = JsonDocument.Parse(jsonOutput.ToString()); - var root = document.RootElement; - - root.GetProperty("warnings").EnumerateArray().Select(x => x.GetProperty("code").GetString()) - .Should().Equal(ShadeKitCliWarningCodes.EnginePrereleaseVersionMismatch, - ShadeKitCliWarningCodes.AgentUnavailable); - - root.GetProperty("data").EnumerateObject().Select(x => x.Name) - .Should().Equal("engineVersion", "formats", "expectedVersion", "integrations"); - - root.GetProperty("data").GetProperty("integrations").GetArrayLength() - .Should().Be(1); - } - - [Fact] - [Trait("Requirement", "FP06-1-AC1")] - public async Task ExecuteAsync_ReleaseEngineMismatch_DoesNotReadIntegrations() - { - // Arrange - var integrationService = CreateIntegrationService(ClaudeIntegration); - var command = CreateCommand(new TestConsole(), TextWriter.Null, "1.2.3", - integrationService: integrationService); - - // Act - var act = () => command.ExecuteAsync(new VersionCommandOptions { Json = true, Expect = "1.3.0" }); - - // Assert - await act.Should().ThrowAsync(); - - A.CallTo(() => integrationService.GetInstalledAsync(A._)) - .MustNotHaveHappened(); - } - - [Fact] - [Trait("Requirement", "FP06-1-AC5")] - public async Task ExecuteAsync_InvalidExpect_DoesNotReadIntegrations() - { - // Arrange - var integrationService = CreateIntegrationService(ClaudeIntegration); - var command = CreateCommand(new TestConsole(), TextWriter.Null, "1.2.3", - integrationService: integrationService); - - // Act - var act = () => command.ExecuteAsync(new VersionCommandOptions { Json = true, Expect = "abc" }); - - // Assert - (await act.Should().ThrowAsync()) - .Which.ExitCode.Should().Be(ShadeKitCliExitCodes.InvalidArguments); - - A.CallTo(() => integrationService.GetInstalledAsync(A._)) - .MustNotHaveHappened(); + "shade-kit 0.8.0", + ContractLine); } [Fact] @@ -761,11 +766,10 @@ public async Task ExecuteAsync_AnyMode_PassesCancellationTokenOfRunToIntegration // Arrange using var cancellationTokenSource = new CancellationTokenSource(); var integrationService = CreateIntegrationService(); - var engineVersionProvider = CreateEngineVersionProvider("1.2.3"); var command = new VersionCommand( TestShadeKitCommandContext.Create(new TestConsole(), cancellation: new TestCliCancellation(cancellationTokenSource.Token)), - engineVersionProvider, FormatRegistry.CreateDefault(), new EngineVersionChecker(engineVersionProvider), + CreateEngineVersionProvider("1.2.3"), FormatRegistry.CreateDefault(), CreateChecker(), integrationService); // Act @@ -781,7 +785,7 @@ public void Ctor_NullContext_ThrowsArgumentNullException() { // Act var act = () => new VersionCommand(null!, CreateEngineVersionProvider("1.0.0"), FormatRegistry.CreateDefault(), - A.Fake(), CreateIntegrationService()); + A.Fake(), CreateIntegrationService()); // Assert act.Should().Throw() @@ -793,7 +797,7 @@ public void Ctor_NullEngineVersionProvider_ThrowsArgumentNullException() { // Act var act = () => new VersionCommand(TestShadeKitCommandContext.Create(new TestConsole()), null!, - FormatRegistry.CreateDefault(), A.Fake(), CreateIntegrationService()); + FormatRegistry.CreateDefault(), A.Fake(), CreateIntegrationService()); // Assert act.Should().Throw() @@ -805,7 +809,7 @@ public void Ctor_NullFormatRegistry_ThrowsArgumentNullException() { // Act var act = () => new VersionCommand(TestShadeKitCommandContext.Create(new TestConsole()), - CreateEngineVersionProvider("1.0.0"), null!, A.Fake(), CreateIntegrationService()); + CreateEngineVersionProvider("1.0.0"), null!, A.Fake(), CreateIntegrationService()); // Assert act.Should().Throw() @@ -813,7 +817,7 @@ public void Ctor_NullFormatRegistry_ThrowsArgumentNullException() } [Fact] - public void Ctor_NullEngineVersionChecker_ThrowsArgumentNullException() + public void Ctor_NullCliContractChecker_ThrowsArgumentNullException() { // Act var act = () => new VersionCommand(TestShadeKitCommandContext.Create(new TestConsole()), @@ -821,7 +825,7 @@ public void Ctor_NullEngineVersionChecker_ThrowsArgumentNullException() // Assert act.Should().Throw() - .WithParameterName("engineVersionChecker"); + .WithParameterName("cliContractChecker"); } [Fact] @@ -829,7 +833,7 @@ public void Ctor_NullIntegrationService_ThrowsArgumentNullException() { // Act var act = () => new VersionCommand(TestShadeKitCommandContext.Create(new TestConsole()), - CreateEngineVersionProvider("1.0.0"), FormatRegistry.CreateDefault(), A.Fake(), + CreateEngineVersionProvider("1.0.0"), FormatRegistry.CreateDefault(), A.Fake(), null!); // Assert @@ -852,13 +856,48 @@ public void VersionCommand_CliCommandAttribute_IsRegisteredAsTopLevelVersionComm } private static VersionCommand CreateCommand(IAnsiConsole console, TextWriter jsonOutput, string engineVersion, - IFormatRegistry? formatRegistry = null, IIntegrationService? integrationService = null) + IFormatRegistry? formatRegistry = null, IIntegrationService? integrationService = null, + ICliContractChecker? checker = null) { - var engineVersionProvider = CreateEngineVersionProvider(engineVersion); - return new VersionCommand(TestShadeKitCommandContext.Create(console, jsonOutput: jsonOutput), - engineVersionProvider, formatRegistry ?? FormatRegistry.CreateDefault(), - new EngineVersionChecker(engineVersionProvider), integrationService ?? CreateIntegrationService()); + CreateEngineVersionProvider(engineVersion), formatRegistry ?? FormatRegistry.CreateDefault(), + checker ?? CreateChecker(), integrationService ?? CreateIntegrationService()); + } + + // FakeItEasy cannot create a dummy CliContractWindow (its constructor rejects 0), so every fake checker that the + // command runs with reports the window of the engine. + private static ICliContractChecker CreateChecker() + { + var checker = A.Fake(); + A.CallTo(() => checker.Window).Returns(CliContract.Window); + + return checker; + } + + private static ICliContractChecker CreateThrowingChecker(Exception exception) + { + var checker = CreateChecker(); + A.CallTo(() => checker.Check(A._)).Throws(exception); + + return checker; + } + + private static void AssertFailureEnvelope(string output, string errorCode, string message) + { + using var document = JsonDocument.Parse(output); + var root = document.RootElement; + + root.GetProperty("ok").GetBoolean() + .Should().BeFalse(); + + root.GetProperty("data").ValueKind + .Should().Be(JsonValueKind.Null); + + root.GetProperty("error").GetProperty("code").GetString() + .Should().Be(errorCode); + + root.GetProperty("error").GetProperty("message").GetString() + .Should().Be(message); } private static IIntegrationService CreateIntegrationService(params InstalledIntegration[] integrations) @@ -881,10 +920,4 @@ private static IEngineVersionProvider CreateEngineVersionProvider(string version return engineVersionProvider; } - - private static string CreateInvalidExpectMessage(string expect) - { - return $"Invalid arguments: '{expect}' is not a SemVer version such as 1.2.3 or 1.2.3-beta.1. Run " + - "'shade-kit --help' for usage."; - } } diff --git a/tests/CreativeCoders.ShadeKit.Cli.Tests/Output/CliErrorMapperTests.cs b/tests/CreativeCoders.ShadeKit.Cli.Tests/Output/CliErrorMapperTests.cs index c5ff9d0..f73aba0 100644 --- a/tests/CreativeCoders.ShadeKit.Cli.Tests/Output/CliErrorMapperTests.cs +++ b/tests/CreativeCoders.ShadeKit.Cli.Tests/Output/CliErrorMapperTests.cs @@ -25,7 +25,6 @@ using CreativeCoders.ShadeKit.Core.Trackers.Exceptions; using CreativeCoders.ShadeKit.Core.Versions; using CreativeCoders.ShadeKit.Core.Versions.Exceptions; -using CreativeCoders.ShadeKit.Core.Versions.Warnings; using CreativeCoders.ShadeKit.Core.Warnings; using CreativeCoders.ShadeKit.Core.Web.Exceptions; using CreativeCoders.ShadeKit.Core.Workflow.Engine; @@ -831,136 +830,36 @@ public void Map_ChecklistTemplateNotFound_ReturnsExitCode47NamingTemplateGatesFi } [Fact] - [Trait("Requirement", "FP06-1-AC1")] - [Trait("Requirement", "FP06-1-AC2")] - public void Map_EngineVersionMismatchWithOlderEngine_ReturnsExitCode50NamingVersionsAndEngineUpdate() + public void Map_EngineContractOutdated_Returns54WithUpdateEngineMessage() { // Arrange - var mapper = CreateMapper(); + var mapper = CreateMapper("1.4.2"); // Act - var error = mapper.Map(new EngineVersionMismatchException("1.2.0", "1.3.1-beta.1+build.7", - EngineVersionMismatchDirection.EngineOlder)); + var error = mapper.Map(new EngineContractOutdatedException(5, 2, 4)); // Assert error - .Should().Be(new CliError(ShadeKitCliExitCodes.VersionMismatch, ShadeKitCliErrorCodes.VersionMismatch, - "The SHADE kit engine 1.2.0 does not fit the kit skills 1.3.1-beta.1+build.7: the major and minor " + - "versions must be equal. Update the engine to 1.3, then run the skill again.")); + .Should().Be(new CliError(ShadeKitCliExitCodes.EngineOutdated, ShadeKitCliErrorCodes.EngineOutdated, + "The SHADE kit engine 1.4.2 supports the CLI contracts 2 to 4, but the kit skills need the CLI " + + "contract 5. Update the engine, then run the skill again.")); } [Fact] - [Trait("Requirement", "FP06-1-AC1")] - [Trait("Requirement", "FP06-1-AC2")] - public void Map_EngineVersionMismatchWithNewerEngine_ReturnsExitCode50NamingVersionsAndSkillsUpdate() + public void Map_SkillsContractOutdated_Returns55WithIntegrationsInstallMessage() { // Arrange - var mapper = CreateMapper(); + var mapper = CreateMapper("1.4.2"); // Act - var error = mapper.Map(new EngineVersionMismatchException("2.1.4", "1.9.0+build.2", - EngineVersionMismatchDirection.EngineNewer)); + var error = mapper.Map(new SkillsContractOutdatedException(1, 2, 4)); // Assert error - .Should().Be(new CliError(ShadeKitCliExitCodes.VersionMismatch, ShadeKitCliErrorCodes.VersionMismatch, - "The SHADE kit engine 2.1.4 does not fit the kit skills 1.9.0+build.2: the major and minor versions " + - "must be equal. Run 'shade-kit integrations install' to install the SHADE kit skills 2.1, then run " + - "the skill again.")); - } - - [Theory] - [InlineData(EngineVersionMismatchDirection.EngineOlder, "Update the engine to 1.x, then")] - [InlineData(EngineVersionMismatchDirection.EngineNewer, - "Run 'shade-kit integrations install' to install the SHADE kit skills engine, then")] - public void Map_EngineVersionMismatchWithVersionsThatAreNotSemVer_NamesVersionsWhole( - EngineVersionMismatchDirection direction, string expectedRemedy) - { - // Arrange - var mapper = CreateMapper(); - - // Act - var error = mapper.Map(new EngineVersionMismatchException("engine", "1.x", direction)); - - // Assert - error - .Should().NotBeNull(); - - error.Message - .Should().StartWith("The SHADE kit engine engine does not fit the kit skills 1.x:") - .And.Contain(expectedRemedy); - } - - [Fact] - public void Map_EngineVersionMismatchWithUndefinedDirection_ThrowsArgumentOutOfRangeException() - { - // Arrange - var mapper = CreateMapper(); - - // Act - var act = () => mapper.Map(new EngineVersionMismatchException("1.2.0", "1.3.0", - (EngineVersionMismatchDirection)99)); - - // Assert - act.Should().Throw() - .WithParameterName("direction"); - } - - [Theory] - [Trait("Requirement", "FP06-1-AC5")] - [InlineData("")] - [InlineData(" ")] - public void Map_InvalidSemanticVersionEmptyOrWhitespace_NamesValueVerbatim(string value) - { - // Arrange - var mapper = CreateMapper(); - - // Act - var error = mapper.Map(new InvalidSemanticVersionException(value)); - - // Assert - error - .Should().NotBeNull(); - - error.Message - .Should().Contain($"'{value}' is not a SemVer version"); - } - - [Fact] - [Trait("Requirement", "FP06-1-AC5")] - public void Map_InvalidSemanticVersion_ReturnsInvalidArgumentsNamingValueAndGeneralHelp() - { - // Arrange - var mapper = CreateMapper(); - - // Act - var error = mapper.Map(new InvalidSemanticVersionException("v1.2")); - - // Assert - error - .Should().Be(new CliError(ShadeKitCliExitCodes.InvalidArguments, ShadeKitCliErrorCodes.InvalidArguments, - "Invalid arguments: 'v1.2' is not a SemVer version such as 1.2.3 or 1.2.3-beta.1. Run " + - "'shade-kit --help' for usage.")); - } - - [Fact] - [Trait("Requirement", "FP06-1-AC5")] - public void Map_InvalidSemanticVersion_NamesNeitherExpectOptionNorVersionCommand() - { - // Arrange - var mapper = CreateMapper(); - - // Act - var error = mapper.Map(new InvalidSemanticVersionException("abc")); - - // Assert - error - .Should().NotBeNull(); - - // The Core exception is generic: a second caller must not get a message about --expect. - error.Message - .Should().NotContain("--expect") - .And.NotContain("version --help"); + .Should().Be(new CliError(ShadeKitCliExitCodes.SkillsOutdated, ShadeKitCliErrorCodes.SkillsOutdated, + "The kit skills are written for the CLI contract 1, but the SHADE kit engine 1.4.2 supports only " + + "the CLI contracts 2 to 4. Run 'shade-kit integrations install' to install the matching kit " + + "skills, then run the skill again.")); } [Fact] @@ -2225,24 +2124,6 @@ public void MapWarning_GateEntryIgnoredWithUndefinedReason_ThrowsArgumentOutOfRa .WithParameterName("reason"); } - [Theory] - [Trait("Requirement", "FP06-1-AC4")] - [InlineData(EngineVersionMismatchDirection.EngineOlder)] - [InlineData(EngineVersionMismatchDirection.EngineNewer)] - public void MapWarning_EnginePrereleaseVersionMismatch_ReturnsPrereleaseWarningNamingVersions( - EngineVersionMismatchDirection direction) - { - // Act - var warning = CliErrorMapper.MapWarning( - new EnginePrereleaseVersionMismatchWarning("1.3.0-beta.1", "1.2.0", direction)); - - // Assert - warning - .Should().Be(new CliJsonMessage(ShadeKitCliWarningCodes.EnginePrereleaseVersionMismatch, - "The prerelease engine 1.3.0-beta.1 does not fit the kit skills 1.2.0 (the major and minor versions " + - "differ); it is used anyway because it is a prerelease.")); - } - [Fact] public void MapWarning_IntegrationPrereleaseRef_ReturnsWarningNamingEngineAndBranch() { @@ -2550,23 +2431,61 @@ public void MapArgumentError_SeveralArgumentsMatchNoOption_NamesEveryArgumentWit "'shade-kit version --help' for usage."); } - [Fact] - [Trait("Requirement", "FP06-1-AC5")] - public void MapArgumentError_ExpectedVersionMissing_ReturnsInvalidArgumentsWithGotNoneAndVersionHelp() + [Theory] + [InlineData("version", "--json", "--expect-contract")] + [InlineData("version", "--expect-contract", "--json")] + public void MapArgumentError_ExpectedContractInvalidWithoutValue_ReturnsInvalidArgumentsWithGotNone( + params string[] args) { // Arrange - var exception = new ExpectedVersionMissingException(); + var exception = new ExpectedContractInvalidException(null); // Act - var error = CliErrorMapper.MapArgumentError(exception, ["version", "--json", "--expect"]); + var error = CliErrorMapper.MapArgumentError(exception, args); + + // Assert + error + .Should().Be(new CliError(ShadeKitCliExitCodes.InvalidArguments, ShadeKitCliErrorCodes.InvalidArguments, + "Invalid arguments: --expect-contract needs a CLI contract number such as 1, but got none. Run " + + "'shade-kit version --help' for usage.")); + } + + [Theory] + [InlineData("abc")] + [InlineData("")] + [InlineData("01")] + public void MapArgumentError_ExpectedContractInvalidWithValue_ReturnsInvalidArgumentsNamingValue(string value) + { + // Arrange + var exception = new ExpectedContractInvalidException(value); + + // Act + var error = CliErrorMapper.MapArgumentError(exception, ["version", "--expect-contract", value]); // Assert error .Should().Be(new CliError(ShadeKitCliExitCodes.InvalidArguments, ShadeKitCliErrorCodes.InvalidArguments, - "Invalid arguments: --expect needs a SemVer version such as 1.2.3 or 1.2.3-beta.1, but got none. " + + $"Invalid arguments: --expect-contract needs a CLI contract number such as 1, but got '{value}'. " + "Run 'shade-kit version --help' for usage.")); } + [Fact] + public void MapArgumentError_ExpectedContractInvalidWrappedInTargetInvocationException_MapsInnerException() + { + // Arrange + var exception = new TargetInvocationException(new ExpectedContractInvalidException("x")); + + // Act + var error = CliErrorMapper.MapArgumentError(exception, ["version", "--expect-contract", "x"]); + + // Assert + error + .Should().NotBeNull(); + + error.Message + .Should().Contain("but got 'x'"); + } + [Fact] public void MapArgumentError_InvalidAgentOptionWithUnknownId_ReturnsInvalidArgumentsNamingSupportedAgents() { diff --git a/tests/CreativeCoders.ShadeKit.Cli.Tests/ProgramTests.cs b/tests/CreativeCoders.ShadeKit.Cli.Tests/ProgramTests.cs index c8e10db..477b15a 100644 --- a/tests/CreativeCoders.ShadeKit.Cli.Tests/ProgramTests.cs +++ b/tests/CreativeCoders.ShadeKit.Cli.Tests/ProgramTests.cs @@ -9,6 +9,7 @@ using CreativeCoders.ShadeKit.Core.Engine; using CreativeCoders.ShadeKit.Core.Git; using CreativeCoders.ShadeKit.Core.Integrations; +using CreativeCoders.ShadeKit.Core.Versions; using CreativeCoders.ShadeKit.Tests.Shared; using CreativeCoders.SysConsole.Cli.Parsing; using CreativeCoders.SysConsole.Cli.Parsing.Exceptions; @@ -27,8 +28,8 @@ public sealed class ProgramTests : IDisposable private const string StackTraceLinePrefix = " at "; - private const string ExpectWithoutValueMessage = - "Invalid arguments: --expect needs a SemVer version such as 1.2.3 or 1.2.3-beta.1, but got none. Run " + + private const string ExpectContractWithoutValueMessage = + "Invalid arguments: --expect-contract needs a CLI contract number such as 1, but got none. Run " + "'shade-kit version --help' for usage."; private readonly CurrentDirectoryScope _currentDirectory = new CurrentDirectoryScope(); @@ -82,21 +83,63 @@ public async Task RunAsync_VersionPlain_WritesToolNameAndVersion() } [Fact] - [Trait("Requirement", "FP06-1-AC1")] - [Trait("Requirement", "FP06-1-AC2")] - public async Task RunAsync_VersionJsonExpectMismatchWithReleaseEngine_WritesOnlyVersionMismatchEnvelopeAndReturns50() + public async Task RunAsync_VersionJson_WritesContract() { // Arrange using var output = new StringWriter(); using var error = new StringWriter(); // Act - var exitCode = await RunProgramAsync(["version", "--json", "--expect", "1.3.0"], output, error, + var exitCode = await RunProgramAsync(["version", "--json"], output, error); + + // Assert + exitCode + .Should().Be(0); + + using var document = JsonDocument.Parse(output.ToString()); + var data = document.RootElement.GetProperty("data"); + + data.EnumerateObject().Select(x => x.Name) + .Should().Equal("engineVersion", "formats", "contract", "integrations"); + + data.GetProperty("contract").EnumerateObject().Select(x => (x.Name, x.Value.GetInt32())) + .Should().Equal(("current", CliContract.Current), ("minSupported", CliContract.MinSupported)); + } + + [Fact] + public async Task RunAsync_VersionPlain_WritesContractLineAfterVersionLine() + { + // Arrange + using var output = new StringWriter(); + using var error = new StringWriter(); + + // Act + var exitCode = await RunProgramAsync(["version"], output, error, + x => x.AddSingleton(CreateEngineVersionProvider("1.2.3"))); + + // Assert + exitCode + .Should().Be(0); + + output.ToString().ReplaceLineEndings("\n").TrimEnd().Split('\n') + .Should().Equal("shade-kit 1.2.3", + $"CLI contract {CliContract.Current} (supported: {CliContract.MinSupported} to {CliContract.Current})"); + } + + [Fact] + public async Task RunAsync_VersionJsonExpectContract999_WritesEngineOutdatedAndReturns54() + { + // Arrange + using var output = new StringWriter(); + using var error = new StringWriter(); + + // Act + var exitCode = await RunProgramAsync(["version", "--json", "--expect-contract", "999"], output, error, x => x.AddSingleton(CreateEngineVersionProvider("1.2.3"))); // Assert exitCode - .Should().Be(ShadeKitCliExitCodes.VersionMismatch); + .Should().Be(ShadeKitCliExitCodes.EngineOutdated); var text = output.ToString(); @@ -110,58 +153,88 @@ public async Task RunAsync_VersionJsonExpectMismatchWithReleaseEngine_WritesOnly .Should().BeFalse(); root.GetProperty("error").GetProperty("code").GetString() - .Should().Be(ShadeKitCliErrorCodes.VersionMismatch); + .Should().Be(ShadeKitCliErrorCodes.EngineOutdated); root.GetProperty("error").GetProperty("message").GetString() - .Should().Be("The SHADE kit engine 1.2.3 does not fit the kit skills 1.3.0: the major and minor versions " + - "must be equal. Update the engine to 1.3, then run the skill again."); + .Should().Be($"The SHADE kit engine 1.2.3 supports the CLI contracts {CliContract.MinSupported} to " + + $"{CliContract.Current}, but the kit skills need the CLI contract 999. Update the engine, " + + "then run the skill again."); error.ToString() .Should().BeNullOrWhiteSpace("the host writes only its empty footer line to standard error"); } [Fact] - [Trait("Requirement", "FP06-1-AC1")] - [Trait("Requirement", "FP06-1-AC2")] - public async Task RunAsync_VersionPlainExpectMismatchWithReleaseEngine_WritesOnlyMessageAndReturns50() + public async Task RunAsync_VersionPlainExpectContract999_WritesOnlyMessageAndReturns54() { // Arrange using var output = new StringWriter(); using var error = new StringWriter(); // Act - var exitCode = await RunProgramAsync(["version", "--expect", "1.1.0"], output, error, + var exitCode = await RunProgramAsync(["version", "--expect-contract", "999"], output, error, x => x.AddSingleton(CreateEngineVersionProvider("1.2.3"))); // Assert exitCode - .Should().Be(ShadeKitCliExitCodes.VersionMismatch); + .Should().Be(ShadeKitCliExitCodes.EngineOutdated); // In plain mode the host prints the abort message to the console of the run, which writes to standard output // and wraps long lines at spaces; folding the whitespace joins the wrapped lines again. Regex.Replace(output.ToString(), @"\s+", " ").TrimEnd() - .Should().Be("The SHADE kit engine 1.2.3 does not fit the kit skills 1.1.0: the major and minor versions " + - "must be equal. Run 'shade-kit integrations install' to install the SHADE kit skills 1.2, " + + .Should().Be($"The SHADE kit engine 1.2.3 supports the CLI contracts {CliContract.MinSupported} to " + + $"{CliContract.Current}, but the kit skills need the CLI contract 999. Update the engine, " + "then run the skill again."); - output.ToString() - .Should().NotContain("shade-kit 1.2.3"); - error.ToString() .Should().BeEmpty(); } [Fact] - [Trait("Requirement", "FP06-1-AC4")] - public async Task RunAsync_VersionJsonExpectMismatchWithPrereleaseEngine_WritesSuccessEnvelopeWithWarning() + public async Task RunAsync_VersionJsonExpectContract0_WritesSkillsOutdatedAndReturns55() { // Arrange using var output = new StringWriter(); using var error = new StringWriter(); // Act - var exitCode = await RunProgramAsync(["version", "--json", "--expect", "99.0.0"], output, error, - x => x.AddSingleton(CreateEngineVersionProvider("1.2.3-beta.1"))); + var exitCode = await RunProgramAsync(["version", "--json", "--expect-contract", "0"], output, error, + x => x.AddSingleton(CreateEngineVersionProvider("1.2.3"))); + + // Assert + exitCode + .Should().Be(ShadeKitCliExitCodes.SkillsOutdated); + + using var document = JsonDocument.Parse(output.ToString()); + var root = document.RootElement; + + root.GetProperty("ok").GetBoolean() + .Should().BeFalse(); + + root.GetProperty("error").GetProperty("code").GetString() + .Should().Be(ShadeKitCliErrorCodes.SkillsOutdated); + + root.GetProperty("error").GetProperty("message").GetString() + .Should().Be("The kit skills are written for the CLI contract 0, but the SHADE kit engine 1.2.3 supports " + + $"only the CLI contracts {CliContract.MinSupported} to {CliContract.Current}. Run " + + "'shade-kit integrations install' to install the matching kit skills, then run the skill " + + "again."); + + error.ToString() + .Should().BeNullOrWhiteSpace("the host writes only its empty footer line to standard error"); + } + + [Fact] + public async Task RunAsync_VersionJsonExpectContract1_WritesSuccessWithExpectedContract() + { + // Arrange + var integrationService = CreateIntegrationService(); + using var output = new StringWriter(); + using var error = new StringWriter(); + + // Act + var exitCode = await RunProgramAsync(["version", "--json", "--expect-contract", "1"], output, error, + x => x.AddSingleton(integrationService)); // Assert exitCode @@ -173,42 +246,53 @@ public async Task RunAsync_VersionJsonExpectMismatchWithPrereleaseEngine_WritesS root.GetProperty("ok").GetBoolean() .Should().BeTrue(); - root.GetProperty("data").GetProperty("expectedVersion").GetString() - .Should().Be("99.0.0"); + root.GetProperty("data").EnumerateObject().Select(x => x.Name) + .Should().Equal("engineVersion", "formats", "contract", "expectedContract"); + + root.GetProperty("data").GetProperty("expectedContract").GetInt32() + .Should().Be(1); + + root.GetProperty("data").TryGetProperty("integrations", out _) + .Should().BeFalse(); + + root.GetProperty("warnings").GetArrayLength() + .Should().Be(0); - root.GetProperty("warnings").EnumerateArray().Select(x => x.GetProperty("code").GetString()) - .Should().Equal(ShadeKitCliWarningCodes.EnginePrereleaseVersionMismatch); + A.CallTo(integrationService) + .MustNotHaveHappened(); } [Theory] - [Trait("Requirement", "FP06-1-AC5")] [InlineData("abc")] + [InlineData("01")] + [InlineData("1.0")] + [InlineData("2147483648")] [InlineData("")] - public async Task RunAsync_VersionJsonExpectNotSemVer_WritesOnlyInvalidArgumentsEnvelopeAndReturns2(string expect) + public async Task RunAsync_VersionJsonExpectContractNotANumber_WritesInvalidArgumentsAndReturns2(string value) { // Arrange using var output = new StringWriter(); using var error = new StringWriter(); // Act - var exitCode = await RunProgramAsync(["version", "--json", "--expect", expect], output, error); + var exitCode = await RunProgramAsync(["version", "--json", "--expect-contract", value], output, error); // Assert exitCode .Should().Be(ShadeKitCliExitCodes.InvalidArguments); - AssertOnlyInvalidArgumentsEnvelope(output.ToString(), $"'{expect}' is not a SemVer version such as 1.2.3 or " + - "1.2.3-beta.1.", "shade-kit --help"); + AssertOnlyInvalidArgumentsEnvelope(output.ToString(), + $"--expect-contract needs a CLI contract number such as 1, but got '{value}'", "shade-kit version --help"); error.ToString() .Should().BeNullOrWhiteSpace("the host writes only its empty footer line to standard error"); } [Theory] - [Trait("Requirement", "FP06-1-AC5")] - [InlineData("version", "--json", "--expect")] - [InlineData("version", "--expect", "--json")] - public async Task RunAsync_VersionJsonExpectWithoutValue_WritesOnlyInvalidArgumentsEnvelopeAndReturns2( + [InlineData("version", "--json", "--expect-contract")] + [InlineData("version", "--expect-contract", "--json")] + [InlineData("version", "--json", "--expect-contract", "-1")] + public async Task RunAsync_VersionExpectContractWithoutValue_WritesInvalidArgumentsAndReturns2( params string[] args) { // Arrange @@ -216,57 +300,53 @@ public async Task RunAsync_VersionJsonExpectWithoutValue_WritesOnlyInvalidArgume using var error = new StringWriter(); // Act - var exitCode = await RunProgramAsync(args, output, error, - x => x.AddSingleton(CreateEngineVersionProvider("1.2.3"))); + var exitCode = await RunProgramAsync(args, output, error); // Assert exitCode .Should().Be(ShadeKitCliExitCodes.InvalidArguments); - AssertOnlyInvalidArgumentsEnvelope(output.ToString(), "--expect", "shade-kit version --help"); + AssertOnlyInvalidArgumentsEnvelope(output.ToString(), "--expect-contract", "shade-kit version --help"); using var document = JsonDocument.Parse(output.ToString()); document.RootElement.GetProperty("error").GetProperty("message").GetString() - .Should().Be(ExpectWithoutValueMessage); + .Should().Be(ExpectContractWithoutValueMessage); error.ToString() .Should().BeEmpty(); } [Fact] - [Trait("Requirement", "FP06-1-AC5")] - public async Task RunAsync_VersionPlainExpectWithoutValue_WritesMessageToStandardErrorAndReturns2() + public async Task RunAsync_VersionPlainExpectContractWithoutValue_WritesMessageToStandardErrorAndReturns2() { // Arrange using var output = new StringWriter(); using var error = new StringWriter(); // Act - var exitCode = await RunProgramAsync(["version", "--expect"], output, error, - x => x.AddSingleton(CreateEngineVersionProvider("1.2.3"))); + var exitCode = await RunProgramAsync(["version", "--expect-contract"], output, error); // Assert exitCode .Should().Be(ShadeKitCliExitCodes.InvalidArguments); error.ToString() - .Should().Be(ExpectWithoutValueMessage + Environment.NewLine); + .Should().Be(ExpectContractWithoutValueMessage + Environment.NewLine); output.ToString() .Should().BeEmpty(); } [Fact] - [Trait("Requirement", "FP06-1-AC3")] - public async Task RunAsync_VersionJsonExpectMatchingVersion_WritesSuccessEnvelopeWithExpectedVersion() + public async Task RunAsync_VersionJsonExpectOldOption_IsNotChecked() { // Arrange using var output = new StringWriter(); using var error = new StringWriter(); // Act - var exitCode = await RunProgramAsync(["version", "--json", "--expect", "1.2.0"], output, error, + var exitCode = await RunProgramAsync(["version", "--json", "--expect", "0.9.0"], output, error, x => x.AddSingleton(CreateEngineVersionProvider("1.2.3"))); // Assert @@ -279,14 +359,11 @@ public async Task RunAsync_VersionJsonExpectMatchingVersion_WritesSuccessEnvelop root.GetProperty("ok").GetBoolean() .Should().BeTrue(); - root.GetProperty("data").GetProperty("engineVersion").GetString() - .Should().Be("1.2.3"); - - root.GetProperty("data").GetProperty("expectedVersion").GetString() - .Should().Be("1.2.0"); + root.GetProperty("data").TryGetProperty("expectedContract", out _) + .Should().BeFalse(); - root.GetProperty("warnings").GetArrayLength() - .Should().Be(0); + root.GetProperty("data").TryGetProperty("expectedVersion", out _) + .Should().BeFalse(); } [Fact] diff --git a/tests/CreativeCoders.ShadeKit.Cli.Tests/ShadeKitCliErrorCodesTests.cs b/tests/CreativeCoders.ShadeKit.Cli.Tests/ShadeKitCliErrorCodesTests.cs index c72582c..d6a3915 100644 --- a/tests/CreativeCoders.ShadeKit.Cli.Tests/ShadeKitCliErrorCodesTests.cs +++ b/tests/CreativeCoders.ShadeKit.Cli.Tests/ShadeKitCliErrorCodesTests.cs @@ -35,10 +35,11 @@ public partial class ShadeKitCliErrorCodesTests [InlineData(ShadeKitCliErrorCodes.CompleteNotAllowed, "complete-not-allowed")] [InlineData(ShadeKitCliErrorCodes.PhaseStateInvalid, "phase-state-invalid")] [InlineData(ShadeKitCliErrorCodes.ChecklistTemplateNotFound, "checklist-template-not-found")] - [InlineData(ShadeKitCliErrorCodes.VersionMismatch, "version-mismatch")] [InlineData(ShadeKitCliErrorCodes.AgentNotFound, "agent-not-found")] [InlineData(ShadeKitCliErrorCodes.AgentCommandFailed, "agent-command-failed")] [InlineData(ShadeKitCliErrorCodes.IntegrationConflict, "integration-conflict")] + [InlineData(ShadeKitCliErrorCodes.EngineOutdated, "engine-outdated")] + [InlineData(ShadeKitCliErrorCodes.SkillsOutdated, "skills-outdated")] [InlineData(ShadeKitCliErrorCodes.Canceled, "canceled")] [InlineData(ShadeKitCliErrorCodes.HostError, "host-error")] public void ErrorCodes_Contract_HaveStableValues(string errorCode, string expectedErrorCode) @@ -82,6 +83,7 @@ public void ForExitCode_EveryExitCodeConstant_ReturnsErrorCodeWithSameName() [InlineData(1)] [InlineData(11)] [InlineData(49)] + [InlineData(50)] [InlineData(58)] [InlineData(59)] [InlineData(256)] @@ -97,6 +99,30 @@ public void ForExitCode_UndefinedExitCode_ThrowsArgumentOutOfRangeException(int .Which.ParamName.Should().Be("exitCode"); } + [Theory] + [InlineData(ShadeKitCliExitCodes.EngineOutdated, "engine-outdated")] + [InlineData(ShadeKitCliExitCodes.SkillsOutdated, "skills-outdated")] + public void ForExitCode_ContractExitCodes_ReturnsContractErrorCodes(int exitCode, string expectedErrorCode) + { + // Act + var errorCode = ShadeKitCliErrorCodes.ForExitCode(exitCode); + + // Assert + errorCode + .Should().Be(expectedErrorCode); + } + + [Fact] + public void ErrorCodes_AllConstants_DoNotContainRemovedVersionMismatch() + { + // Act + var errorCodes = ShadeKitCliExitCodesTests.GetConstants(typeof(ShadeKitCliErrorCodes)); + + // Assert + errorCodes.Values + .Should().NotContain("version-mismatch"); + } + [GeneratedRegex("^[a-z]+(-[a-z]+)*$")] private static partial Regex KebabCaseRegex(); } diff --git a/tests/CreativeCoders.ShadeKit.Cli.Tests/ShadeKitCliExitCodesTests.cs b/tests/CreativeCoders.ShadeKit.Cli.Tests/ShadeKitCliExitCodesTests.cs index a82f85a..82ae400 100644 --- a/tests/CreativeCoders.ShadeKit.Cli.Tests/ShadeKitCliExitCodesTests.cs +++ b/tests/CreativeCoders.ShadeKit.Cli.Tests/ShadeKitCliExitCodesTests.cs @@ -55,10 +55,11 @@ public void ToProcessExitCode_NegativeHostExitCode_ReturnsHostError(int exitCode [InlineData(ShadeKitCliExitCodes.CompleteNotAllowed)] [InlineData(ShadeKitCliExitCodes.PhaseStateInvalid)] [InlineData(ShadeKitCliExitCodes.ChecklistTemplateNotFound)] - [InlineData(ShadeKitCliExitCodes.VersionMismatch)] [InlineData(ShadeKitCliExitCodes.AgentNotFound)] [InlineData(ShadeKitCliExitCodes.AgentCommandFailed)] [InlineData(ShadeKitCliExitCodes.IntegrationConflict)] + [InlineData(ShadeKitCliExitCodes.EngineOutdated)] + [InlineData(ShadeKitCliExitCodes.SkillsOutdated)] [InlineData(ShadeKitCliExitCodes.Canceled)] [InlineData(ShadeKitCliExitCodes.HostError)] public void ToProcessExitCode_NonNegativeExitCode_ReturnsExitCodeUnchanged(int exitCode) @@ -101,10 +102,11 @@ public void ToProcessExitCode_NonNegativeExitCode_ReturnsExitCodeUnchanged(int e [InlineData(ShadeKitCliExitCodes.CompleteNotAllowed, 45)] [InlineData(ShadeKitCliExitCodes.PhaseStateInvalid, 46)] [InlineData(ShadeKitCliExitCodes.ChecklistTemplateNotFound, 47)] - [InlineData(ShadeKitCliExitCodes.VersionMismatch, 50)] [InlineData(ShadeKitCliExitCodes.AgentNotFound, 51)] [InlineData(ShadeKitCliExitCodes.AgentCommandFailed, 52)] [InlineData(ShadeKitCliExitCodes.IntegrationConflict, 53)] + [InlineData(ShadeKitCliExitCodes.EngineOutdated, 54)] + [InlineData(ShadeKitCliExitCodes.SkillsOutdated, 55)] [InlineData(ShadeKitCliExitCodes.Canceled, 130)] [InlineData(ShadeKitCliExitCodes.HostError, 255)] public void ExitCodes_Contract_HaveStableValues(int exitCode, int expectedExitCode) @@ -114,6 +116,20 @@ public void ExitCodes_Contract_HaveStableValues(int exitCode, int expectedExitCo .Should().Be(expectedExitCode); } + [Fact] + public void ExitCodes_AllConstants_DoNotDefineRemovedVersionMismatch50() + { + // Act + var exitCodes = GetConstants(typeof(ShadeKitCliExitCodes)); + + // Assert + exitCodes.Values + .Should().NotContain(50); + + exitCodes.Keys + .Should().NotContain("VersionMismatch"); + } + [Fact] public void ExitCodes_AllConstants_AreUniqueAndInDocumentedRanges() { diff --git a/tests/CreativeCoders.ShadeKit.Cli.Tests/ShadeKitCliWarningCodesTests.cs b/tests/CreativeCoders.ShadeKit.Cli.Tests/ShadeKitCliWarningCodesTests.cs index 29b8d0e..c291227 100644 --- a/tests/CreativeCoders.ShadeKit.Cli.Tests/ShadeKitCliWarningCodesTests.cs +++ b/tests/CreativeCoders.ShadeKit.Cli.Tests/ShadeKitCliWarningCodesTests.cs @@ -15,7 +15,6 @@ public partial class ShadeKitCliWarningCodesTests [InlineData(ShadeKitCliWarningCodes.EditorConfigUnreadable, "editorconfig-unreadable")] [InlineData(ShadeKitCliWarningCodes.EditorConfigInvalid, "editorconfig-invalid")] [InlineData(ShadeKitCliWarningCodes.GitAttributesUnavailable, "git-attributes-unavailable")] - [InlineData(ShadeKitCliWarningCodes.EnginePrereleaseVersionMismatch, "engine-prerelease-version-mismatch")] [InlineData(ShadeKitCliWarningCodes.IntegrationPrereleaseRef, "integration-prerelease-ref")] [InlineData(ShadeKitCliWarningCodes.IntegrationReleaseTagMissing, "integration-release-tag-missing")] [InlineData(ShadeKitCliWarningCodes.AgentUnavailable, "agent-unavailable")] @@ -55,6 +54,17 @@ public void WarningCodes_AllConstants_DifferFromErrorCodes() .Should().NotIntersectWith(errorCodes.Keys); } + [Fact] + public void WarningCodes_AllConstants_DoNotContainRemovedPrereleaseVersionMismatch() + { + // Act + var warningCodes = ShadeKitCliExitCodesTests.GetConstants(typeof(ShadeKitCliWarningCodes)); + + // Assert + warningCodes.Values + .Should().NotContain("engine-prerelease-version-mismatch"); + } + [GeneratedRegex("^[a-z]+(-[a-z]+)*$")] private static partial Regex KebabCaseRegex(); } diff --git a/tests/CreativeCoders.ShadeKit.Core.Tests/ShadeKitCoreServiceCollectionExtensionsTests.cs b/tests/CreativeCoders.ShadeKit.Core.Tests/ShadeKitCoreServiceCollectionExtensionsTests.cs index 33ec8a1..a9679b1 100644 --- a/tests/CreativeCoders.ShadeKit.Core.Tests/ShadeKitCoreServiceCollectionExtensionsTests.cs +++ b/tests/CreativeCoders.ShadeKit.Core.Tests/ShadeKitCoreServiceCollectionExtensionsTests.cs @@ -18,6 +18,7 @@ using CreativeCoders.ShadeKit.Core.Templates; using CreativeCoders.ShadeKit.Core.Trackers; using CreativeCoders.ShadeKit.Core.Versions; +using CreativeCoders.ShadeKit.Core.Versions.Exceptions; using CreativeCoders.ShadeKit.Core.Web; using CreativeCoders.ShadeKit.Core.Workflow; using CreativeCoders.ShadeKit.Core.Workflow.Engine; @@ -72,7 +73,7 @@ public void AddShadeKitCore_ServiceCollection_RegistersKitStoreFactoryAsSingleto [InlineData(typeof(IFormatRegistry), typeof(FormatRegistry))] [InlineData(typeof(IVersionedJsonSerializer), typeof(VersionedJsonSerializer))] [InlineData(typeof(IEngineVersionProvider), typeof(EngineVersionProvider))] - [InlineData(typeof(IEngineVersionChecker), typeof(EngineVersionChecker))] + [InlineData(typeof(ICliContractChecker), typeof(CliContractChecker))] [InlineData(typeof(IRepositoryInitializer), typeof(RepositoryInitializer))] [InlineData(typeof(IShippedTemplateReader), typeof(ShippedTemplateReader))] [InlineData(typeof(IGitIgnorePlanner), typeof(GitIgnorePlanner))] @@ -126,6 +127,36 @@ public void AddShadeKitCore_ServiceCollection_RegistersServiceAsSingleton(Type s secondInstance.Should().BeSameAs(firstInstance); } + [Fact] + public void AddShadeKitCore_ServiceCollection_RegistersCliContractCheckerWithCliContractWindow() + { + // Arrange + var services = new ServiceCollection(); + + // Act + services.AddShadeKitCore(); + + // Assert + using var serviceProvider = services.BuildServiceProvider(); + + var checker = serviceProvider.GetRequiredService(); + + checker.Window + .Should().Be(CliContract.Window); + + checker.Invoking(x => x.Check(CliContract.Current)) + .Should().NotThrow(); + + checker.Invoking(x => x.Check(CliContract.MinSupported)) + .Should().NotThrow(); + + checker.Invoking(x => x.Check(CliContract.Current + 1)) + .Should().Throw(); + + checker.Invoking(x => x.Check(CliContract.MinSupported - 1)) + .Should().Throw(); + } + [Fact] public void AddShadeKitCore_CalledTwice_RegistersEachAgentIntegrationOnceAsSingletonInRunOrder() { @@ -235,7 +266,7 @@ public void AddShadeKitCore_ExistingFormatRegistryRegistration_SerializerUsesExi [InlineData(typeof(IGitRepositoryLocator))] [InlineData(typeof(IVersionedJsonSerializer))] [InlineData(typeof(IEngineVersionProvider))] - [InlineData(typeof(IEngineVersionChecker))] + [InlineData(typeof(ICliContractChecker))] [InlineData(typeof(IRepositoryInitializer))] [InlineData(typeof(IShippedTemplateReader))] [InlineData(typeof(IGitIgnorePlanner))] @@ -295,7 +326,7 @@ public void AddShadeKitCore_ExistingServiceRegistration_KeepsExistingRegistratio [InlineData(typeof(IFormatRegistry))] [InlineData(typeof(IVersionedJsonSerializer))] [InlineData(typeof(IEngineVersionProvider))] - [InlineData(typeof(IEngineVersionChecker))] + [InlineData(typeof(ICliContractChecker))] [InlineData(typeof(IRepositoryInitializer))] [InlineData(typeof(IShippedTemplateReader))] [InlineData(typeof(IGitIgnorePlanner))] diff --git a/tests/CreativeCoders.ShadeKit.Core.Tests/Skills/SkillContractTests.cs b/tests/CreativeCoders.ShadeKit.Core.Tests/Skills/SkillContractTests.cs new file mode 100644 index 0000000..39c518a --- /dev/null +++ b/tests/CreativeCoders.ShadeKit.Core.Tests/Skills/SkillContractTests.cs @@ -0,0 +1,569 @@ +using System.Globalization; +using System.Text.RegularExpressions; +using AwesomeAssertions; +using CreativeCoders.ShadeKit.Core.Versions; +using CreativeCoders.ShadeKit.Tests.Shared; + +namespace CreativeCoders.ShadeKit.Core.Tests.Skills; + +/// +/// Guards that the shipped skills name the CLI contract of the engine () in their +/// version handshake, and that no leftover of the removed kit version (--expect, a frontmatter +/// version:) remains. +/// +public partial class SkillContractTests +{ + private const string SkillFileName = ShippedSkillFiles.SkillFileName; + + private const string FrontmatterDelimiter = "---"; + + private const string ContractSentenceTail = "is the CLI contract this skill is written for"; + + private const int Contract = 3; + + private static readonly string[] HandshakeSkills = + [ + "shade-kit-new", "shade-kit-discuss", "shade-kit-drop", "shade-kit-next-phase", "shade-kit-phase-entry" + ]; + + [Fact] + [Trait("Requirement", "FP07-AC2")] + public void SkillFiles_ShippedSkills_NameTheCurrentCliContractEverywhere() + { + // Arrange + var repositoryRoot = ShippedSkillFiles.FindRepositoryRoot(); + + // Act + var violations = FindContractViolations(repositoryRoot, CliContract.Current); + + // Assert + violations + .Should().BeEmpty( + "every handshake of the skills names the CLI contract {0} of the engine, and no skill carries the " + + "removed --expect option or a frontmatter version; violations:{1}{2}", + CliContract.Current, Environment.NewLine, string.Join(Environment.NewLine, violations)); + } + + [Fact] + public void FindContractViolations_MatchingSkills_ReturnsNoViolation() + { + // Arrange + using var root = new TempKitDirectory(); + WriteHandshakeSkills(root, Contract); + WriteSkill(root, "shade-kit-other", "Run `shade-kit version --json --expect-contract 3` first."); + root.WriteFile("Run `shade-kit version --expect-contract=3 --json`.", "skills", "shade-kit-other", + "references", "x.md"); + + // Act + var violations = FindContractViolations(root.RootPath, Contract); + + // Assert + violations + .Should().BeEmpty(); + } + + [Fact] + public void FindContractViolations_OtherExpectContractValue_ReportsFileLineAndValue() + { + // Arrange + using var root = new TempKitDirectory(); + WriteHandshakeSkills(root, Contract); + WriteSkill(root, "shade-kit-other", + "Line\nRun `shade-kit version --json --expect-contract 2`.\nOr `--expect-contract `."); + root.WriteFile("Run `shade-kit version --expect-contract=4 --json`.", "skills", "shade-kit-other", + "references", "x.md"); + + // Act + var violations = FindContractViolations(root.RootPath, Contract); + + // Assert + violations + .Should().Equal( + $"{SkillPath("shade-kit-other")}:6: --expect-contract names another CLI contract " + + "(expected 3, found 2)", + $"{SkillPath("shade-kit-other")}:7: --expect-contract names another CLI contract " + + "(expected 3, found )", + $"{Path.Combine("skills", "shade-kit-other", "references", "x.md")}:1: --expect-contract names " + + "another CLI contract (expected 3, found 4)"); + } + + [Theory] + [InlineData("Run `shade-kit version --json --expect-contract \"2\"`.")] + [InlineData("Run `shade-kit version --json --expect-contract '2'`.")] + [InlineData("Run shade-kit version --json --expect-contract `2`.")] + [InlineData("Run `shade-kit version --json --expect-contract\t2`.")] + [InlineData("Run shade-kit version --json --expect-contract 2.")] + [InlineData("Run shade-kit version --json --expect-contract 2: the handshake.")] + public void FindContractViolations_QuotedOrPunctuatedExpectContractValue_ReportsTheBareValue(string body) + { + // Arrange + using var root = new TempKitDirectory(); + WriteHandshakeSkills(root, Contract); + WriteSkill(root, "shade-kit-other", body); + + // Act + var violations = FindContractViolations(root.RootPath, Contract); + + // Assert + violations + .Should().Equal( + $"{SkillPath("shade-kit-other")}:5: --expect-contract names another CLI contract " + + "(expected 3, found 2)"); + } + + [Fact] + public void FindContractViolations_MatchingAndOtherExpectContractOnOneLine_ReportsOnlyTheOtherOne() + { + // Arrange + using var root = new TempKitDirectory(); + WriteHandshakeSkills(root, Contract); + WriteSkill(root, "shade-kit-other", + "Run `--expect-contract 3` or `--expect-contract 30`, never `--expect-contract 3`."); + + // Act + var violations = FindContractViolations(root.RootPath, Contract); + + // Assert + violations + .Should().Equal( + $"{SkillPath("shade-kit-other")}:5: --expect-contract names another CLI contract " + + "(expected 3, found 30)"); + } + + [Fact] + public void FindContractViolations_OtherContractInHandshakeSentence_ReportsFileLineAndValue() + { + // Arrange + using var root = new TempKitDirectory(); + WriteHandshakeSkills(root, Contract); + WriteSkill(root, "shade-kit-other", + "Line\n**2** is the CLI contract this skill is written for.\n(3 is the CLI contract this skill is " + + "written for)"); + + // Act + var violations = FindContractViolations(root.RootPath, Contract); + + // Assert + violations + .Should().Equal( + $"{SkillPath("shade-kit-other")}:6: handshake sentence names another CLI contract " + + "(expected '3 is the CLI contract this skill is written for', " + + "found '2** is the CLI contract this skill is written for')"); + } + + [Fact] + public void FindContractViolations_HandshakeSkillWithoutCanonicalSentence_ReportsSkill() + { + // Arrange + using var root = new TempKitDirectory(); + WriteHandshakeSkills(root, Contract); + WriteSkill(root, "shade-kit-drop", + "1. Version handshake: run `shade-kit version --json --expect-contract 3`; 3 is the CLI contract of " + + "this skill."); + + // Act + var violations = FindContractViolations(root.RootPath, Contract); + + // Assert + violations + .Should().Equal( + $"{SkillPath("shade-kit-drop")}:1: canonical handshake sentence missing (expected " + + $"'{CanonicalSentence(Contract)}', found none)"); + } + + [Fact] + public void FindContractViolations_HandshakeSkillWithSentenceOfOtherContract_ReportsSkillAndBothValues() + { + // Arrange + using var root = new TempKitDirectory(); + WriteHandshakeSkills(root, Contract); + WriteSkill(root, "shade-kit-new", $"1. {CanonicalSentence(2)}"); + + // Act + var violations = FindContractViolations(root.RootPath, Contract); + + // Assert + violations + .Should().Equal( + $"{SkillPath("shade-kit-new")}:5: --expect-contract names another CLI contract " + + "(expected 3, found 2)", + $"{SkillPath("shade-kit-new")}:5: handshake sentence names another CLI contract " + + "(expected '3 is the CLI contract this skill is written for', " + + "found '2 is the CLI contract this skill is written for')", + $"{SkillPath("shade-kit-new")}:1: canonical handshake sentence missing (expected " + + $"'{CanonicalSentence(Contract)}', found none)"); + } + + [Fact] + public void FindContractViolations_HandshakeSkillMissing_ReportsSkill() + { + // Arrange + using var root = new TempKitDirectory(); + WriteHandshakeSkills(root, Contract); + File.Delete(Path.Combine(root.RootPath, SkillPath("shade-kit-next-phase"))); + + // Act + var violations = FindContractViolations(root.RootPath, Contract); + + // Assert + violations + .Should().Equal( + $"{SkillPath("shade-kit-next-phase")}: handshake skill missing (expected a {SkillFileName} with " + + $"'{CanonicalSentence(Contract)}', found none)"); + } + + [Theory] + [InlineData("Run `shade-kit version --json --expect 0.9.0`.", "--expect 0.9.0")] + [InlineData("Run `shade-kit version --json --expect=0.9.0`.", "--expect 0.9.0")] + [InlineData("Run shade-kit version --json --expect.", "--expect")] + [InlineData("The `--expect` option.", "--expect")] + public void FindContractViolations_OldExpectOption_ReportsFileAndLine(string body, string found) + { + // Arrange + using var root = new TempKitDirectory(); + WriteHandshakeSkills(root, Contract); + WriteSkill(root, "shade-kit-other", "Line\n" + body); + + // Act + var violations = FindContractViolations(root.RootPath, Contract); + + // Assert + violations + .Should().Equal( + $"{SkillPath("shade-kit-other")}:6: removed option --expect (expected --expect-contract 3, " + + $"found {found})"); + } + + [Theory] + [InlineData("The option `--expect-contract` replaces it.")] + [InlineData("The skill expected `--expected`.")] + public void FindContractViolations_TextThatIsNotTheOldExpectOption_ReturnsNoViolation(string body) + { + // Arrange + using var root = new TempKitDirectory(); + WriteHandshakeSkills(root, Contract); + WriteSkill(root, "shade-kit-other", body); + + // Act + var violations = FindContractViolations(root.RootPath, Contract); + + // Assert + violations + .Should().BeEmpty(); + } + + [Theory] + [InlineData("---\nname: shade-kit-other\nversion: 0.9.0\n---\nBody", 3, "version: 0.9.0")] + [InlineData("---\nname: shade-kit-other\nmetadata:\n version: 0.9.0\n---\nBody", 4, "version: 0.9.0")] + [InlineData("---\nname: shade-kit-other\nmetadata:\n author: x\n version:\n---\nBody", 5, "version:")] + [InlineData("---\r\nname: shade-kit-other\r\nversion : 1\r\n---\r\nBody", 3, "version : 1")] + public void FindContractViolations_FrontmatterVersion_ReportsFileAndLine(string content, int line, + string found) + { + // Arrange + using var root = new TempKitDirectory(); + WriteHandshakeSkills(root, Contract); + root.WriteFile(content, "skills", "shade-kit-other", SkillFileName); + + // Act + var violations = FindContractViolations(root.RootPath, Contract); + + // Assert + violations + .Should().Equal( + $"{SkillPath("shade-kit-other")}:{line}: frontmatter version key (expected none, found '{found}')"); + } + + [Theory] + [InlineData("---\nname: shade-kit-other\ndescription: \"The version: handshake.\"\n---\nBody")] + [InlineData("---\nname: shade-kit-other\nversions: 2\nversion:1\n---\nBody")] + [InlineData("---\nname: shade-kit-other\n---\nversion: 0.9.0\n")] + [InlineData("# shade-kit-other\nversion: 0.9.0\n")] + public void FindContractViolations_VersionThatIsNoFrontmatterKey_ReturnsNoViolation(string content) + { + // Arrange + using var root = new TempKitDirectory(); + WriteHandshakeSkills(root, Contract); + root.WriteFile(content, "skills", "shade-kit-other", SkillFileName); + + // Act + var violations = FindContractViolations(root.RootPath, Contract); + + // Assert + violations + .Should().BeEmpty(); + } + + [Fact] + public void FindContractViolations_FrontmatterVersionWithBom_ReportsFileAndLine() + { + // Arrange + using var root = new TempKitDirectory(); + WriteHandshakeSkills(root, Contract); + root.WriteFileBytes([0xEF, 0xBB, 0xBF, .. "---\r\nname: shade-kit-other\r\nversion: 1\r\n---\r\n"u8], + "skills", "shade-kit-other", SkillFileName); + + // Act + var violations = FindContractViolations(root.RootPath, Contract); + + // Assert + violations + .Should().Equal( + $"{SkillPath("shade-kit-other")}:3: frontmatter version key (expected none, found 'version: 1')"); + } + + [Fact] + public void FindContractViolations_NoSkillFiles_ReportsMissingSkills() + { + // Arrange + using var root = new TempKitDirectory(); + root.WriteFile("Run `shade-kit version --json --expect-contract 2`.", "skills", "a", "notes.md"); + root.WriteFile("---\nname: a\n---\n", "skills", "b", "skill.md"); + + // Act + var violations = FindContractViolations(root.RootPath, Contract); + + // Assert + violations + .Should().Equal($"skills: expected at least one {SkillFileName}, found none"); + } + + [Fact] + public void FindContractViolations_SkillFileThatIsNotUtf8_ThrowsInvalidDataException() + { + // Arrange + using var root = new TempKitDirectory(); + WriteHandshakeSkills(root, Contract); + root.WriteFileBytes([.. "---\nname: a\n---\n"u8, 0xFC], "skills", "a", SkillFileName); + + // Act + var act = () => FindContractViolations(root.RootPath, Contract); + + // Assert + act + .Should().Throw() + .WithMessage($"*{SkillPath("a")}*not valid UTF-8*"); + } + + [Fact] + public void FindContractViolations_HandshakeWrappedAcrossLines_ReportsTheLineWhereTheMatchStarts() + { + // Arrange + using var root = new TempKitDirectory(); + WriteHandshakeSkills(root, Contract); + WriteSkill(root, "shade-kit-other", + "Version handshake: run `shade-kit version --json --expect-contract\n2`; 2 is the CLI\r\ncontract " + + "this skill is written for.\n**4**\nis the CLI contract this skill is written for."); + + // Act + var violations = FindContractViolations(root.RootPath, Contract); + + // Assert + violations + .Should().Equal( + $"{SkillPath("shade-kit-other")}:5: --expect-contract names another CLI contract " + + "(expected 3, found 2)", + $"{SkillPath("shade-kit-other")}:6: handshake sentence names another CLI contract " + + "(expected '3 is the CLI contract this skill is written for', " + + "found '2 is the CLI\r\ncontract this skill is written for')", + $"{SkillPath("shade-kit-other")}:8: handshake sentence names another CLI contract " + + "(expected '3 is the CLI contract this skill is written for', " + + "found '4**\nis the CLI contract this skill is written for')"); + } + + [Fact] + public void FindContractViolations_BundledFileWithBom_ReportsTheValueWithoutTheBom() + { + // Arrange + using var root = new TempKitDirectory(); + WriteHandshakeSkills(root, Contract); + root.WriteFileBytes([0xEF, 0xBB, 0xBF, .. "2 is the CLI contract this skill is written for"u8], + "skills", "shade-kit-new", "notes.md"); + + // Act + var violations = FindContractViolations(root.RootPath, Contract); + + // Assert + violations + .Should().Equal( + $"{Path.Combine("skills", "shade-kit-new", "notes.md")}:1: handshake sentence names another CLI " + + "contract (expected '3 is the CLI contract this skill is written for', " + + "found '2 is the CLI contract this skill is written for')"); + } + + [Fact] + public void FindContractViolations_LongBundledLineWithoutWhitespace_FinishesWithoutRegexTimeout() + { + // Arrange + using var root = new TempKitDirectory(); + WriteHandshakeSkills(root, Contract); + root.WriteFile(new string('a', 200_000) + " is the CLI contract this skill is written for", "skills", + "shade-kit-new", "asset.svg"); + + // Act + var violations = FindContractViolations(root.RootPath, Contract); + + // Assert + violations + .Should().ContainSingle() + .Which.Should().StartWith( + $"{Path.Combine("skills", "shade-kit-new", "asset.svg")}:1: handshake sentence names another CLI " + + "contract (expected '3 is the CLI contract this skill is written for', found 'aaa"); + } + + // The canonical handshake sentence of the skills in HandshakeSkills, for the specified CLI contract. + private static string CanonicalSentence(int contract) + { + return string.Create(CultureInfo.InvariantCulture, + $"Version handshake: run `shade-kit version --json --expect-contract {contract}`; {contract} " + + $"{ContractSentenceTail}."); + } + + private static void WriteHandshakeSkills(TempKitDirectory root, int contract) + { + foreach (var skill in HandshakeSkills) + { + WriteSkill(root, skill, $"1. {CanonicalSentence(contract)}"); + } + } + + // The body starts at line 5. + private static void WriteSkill(TempKitDirectory root, string name, string body) + { + root.WriteFile($"---\nname: {name}\ndescription: Test skill {name}.\n---\n{body}\n", "skills", name, + SkillFileName); + } + + private static string SkillPath(string name) + { + return Path.Combine("skills", name, SkillFileName); + } + + /// + /// Checks the CLI contract of the skills under skills/: every --expect-contract <n> and every + /// "<n> is the CLI contract this skill is written for" in any text file names + /// ; each skill in exists and contains the + /// canonical handshake sentence verbatim; no text file names the removed option --expect; and no + /// SKILL.md has a version key in its frontmatter, at any indentation. + /// + /// + /// One line per violation: the path relative to the repository, the line (none for a missing file), what is wrong, + /// and expected vs. found. + /// + /// A text file under skills/ is not valid UTF-8. + internal static string[] FindContractViolations(string repositoryRoot, int currentContract) + { + var skillFiles = ShippedSkillFiles.EnumerateSkillFiles(repositoryRoot) + .Select(file => Path.GetRelativePath(repositoryRoot, file)) + .ToHashSet(StringComparer.Ordinal); + + if (skillFiles.Count == 0) + { + return [$"{ShippedSkillFiles.SkillsDirectoryName}: expected at least one {SkillFileName}, found none"]; + } + + var contract = currentContract.ToString(CultureInfo.InvariantCulture); + var textFiles = ShippedSkillFiles.ReadTextFiles(repositoryRoot) + .Select(file => (Path: Path.GetRelativePath(repositoryRoot, file.File), file.Text, file.Lines)) + .ToArray(); + + return textFiles + .SelectMany(file => FindTextViolations(file.Path, file.Text, contract)) + .Concat(textFiles + .Where(file => skillFiles.Contains(file.Path)) + .SelectMany(file => FindFrontmatterVersionViolations(file.Path, file.Lines))) + .Concat(FindHandshakeSkillViolations(textFiles.ToDictionary(file => file.Path, file => file.Text, + StringComparer.Ordinal), currentContract)) + .ToArray(); + } + + // The texts are matched as a whole, so that a handshake wrapped across lines is found too; the line of a violation + // is the line where the match starts. + private static IEnumerable FindTextViolations(string path, string text, string contract) + { + var expectedSentence = $"{contract} {ContractSentenceTail}"; + + var expectContract = ExpectContractOptionRegex().Matches(text) + .Select(match => (match.Index, Value: match.Groups["value"].Value.TrimEnd('.', ':'))) + .Where(x => x.Value != contract) + .Select(x => (x.Index, + Message: $"--expect-contract names another CLI contract (expected {contract}, found {x.Value})")); + + var sentence = ContractSentenceRegex().Matches(text) + .Where(match => match.Groups["value"].Value != contract) + .Select(match => (match.Index, + Message: "handshake sentence names another CLI contract " + + $"(expected '{expectedSentence}', found '{match.Value}')")); + + var oldExpect = OldExpectOptionRegex().Matches(text) + .Select(match => (match.Index, + Message: $"removed option --expect (expected --expect-contract {contract}, found " + + $"{("--expect " + match.Groups["value"].Value.TrimEnd('.', ':')).TrimEnd()})")); + + return expectContract + .Concat(sentence) + .Concat(oldExpect) + .OrderBy(x => x.Index) + .Select(x => $"{path}:{ShippedSkillFiles.SplitLines(text[..x.Index]).Length}: {x.Message}"); + } + + // A frontmatter is the block between a first line "---" and the next line "---"; a "version" key on any of its + // lines, top-level or nested (for example under "metadata:"), is a leftover of the removed kit version. + private static IEnumerable FindFrontmatterVersionViolations(string path, string[] lines) + { + var closingIndex = lines.Length > 0 && lines[0].TrimEnd() == FrontmatterDelimiter + ? Array.FindIndex(lines, 1, line => line.TrimEnd() == FrontmatterDelimiter) + : -1; + + return Enumerable.Range(1, Math.Max(closingIndex - 1, 0)) + .Where(index => FrontmatterVersionKeyRegex().IsMatch(lines[index])) + .Select(index => + $"{path}:{index + 1}: frontmatter version key (expected none, found '{lines[index].Trim()}')"); + } + + private static IEnumerable FindHandshakeSkillViolations(Dictionary textsByPath, + int contract) + { + var canonicalSentence = CanonicalSentence(contract); + + foreach (var path in HandshakeSkills.Select(SkillPath)) + { + if (!textsByPath.TryGetValue(path, out var text)) + { + yield return $"{path}: handshake skill missing (expected a {SkillFileName} with " + + $"'{canonicalSentence}', found none)"; + } + else if (!text.Contains(canonicalSentence, StringComparison.Ordinal)) + { + yield return $"{path}:1: canonical handshake sentence missing (expected '{canonicalSentence}', " + + "found none)"; + } + } + } + + // The value after "--expect-contract" (a blank, a line break, or "="; optionally quoted); a trailing "." or ":" of + // the sentence is cut off in code. + [GeneratedRegex(@"--expect-contract(?:\s+|=)[""'`]?(?[^\s`'"";,)]+)", RegexOptions.CultureInvariant, + matchTimeoutMilliseconds: 1000)] + private static partial Regex ExpectContractOptionRegex(); + + // The removed option "--expect": not "--expect-contract" and not a longer word such as "--expected". The value, if + // any, is read like the one of "--expect-contract". + [GeneratedRegex(@"--expect(?![-\w])(?:(?:\s+|=)[""'`]?(?[^\s`'"";,)]+))?", RegexOptions.CultureInvariant, + matchTimeoutMilliseconds: 1000)] + private static partial Regex OldExpectOptionRegex(); + + // The contract token before the sentence, which may be wrapped across lines. The lookbehind starts a match only at + // the start of a token and the atomic group gives up a token without backtracking, so a long line without + // whitespace takes linear time. Quotes, parentheses, and Markdown emphasis are not part of the token. + [GeneratedRegex( + @"(?(?>[^\s`'""(*_]+))[*_`'""]*\s+is\s+the\s+CLI\s+contract\s+this\s+skill\s+is" + + @"\s+written\s+for", RegexOptions.CultureInvariant, matchTimeoutMilliseconds: 1000)] + private static partial Regex ContractSentenceRegex(); + + // A "version" key: at the start of the line after any indentation; YAML needs a blank or the line end after the + // colon ("version:1" is no key). + [GeneratedRegex(@"^[ \t]*version[ \t]*:(?:[ \t]|$)", RegexOptions.CultureInvariant, + matchTimeoutMilliseconds: 1000)] + private static partial Regex FrontmatterVersionKeyRegex(); +} diff --git a/tests/CreativeCoders.ShadeKit.Core.Tests/Skills/SkillKitVersionTests.cs b/tests/CreativeCoders.ShadeKit.Core.Tests/Skills/SkillKitVersionTests.cs deleted file mode 100644 index 97e360e..0000000 --- a/tests/CreativeCoders.ShadeKit.Core.Tests/Skills/SkillKitVersionTests.cs +++ /dev/null @@ -1,836 +0,0 @@ -using System.Text.RegularExpressions; -using AwesomeAssertions; -using CreativeCoders.ShadeKit.Core.Engine; -using CreativeCoders.ShadeKit.Core.Versions; -using CreativeCoders.ShadeKit.Tests.Shared; - -namespace CreativeCoders.ShadeKit.Core.Tests.Skills; - -public partial class SkillKitVersionTests -{ - private const string SkillFileName = ShippedSkillFiles.SkillFileName; - - private const string FrontmatterDelimiter = "---"; - - private static readonly SemanticVersion DefaultEngineVersion = SemanticVersion.Parse("0.8.3"); - - [Fact] - [Trait("Requirement", "FP07-AC2")] - public void SkillFiles_ShippedSkills_CarryOneKitVersionThatMatchesTheEngineMajorMinor() - { - // Arrange - var repositoryRoot = ShippedSkillFiles.FindRepositoryRoot(); - var engineVersionText = new EngineVersionProvider().Version; - - // Act - var engineVersionParsed = SemanticVersion.TryParse(engineVersionText, out var engineVersion); - - // Assert - engineVersionParsed - .Should().BeTrue($"the engine version '{engineVersionText}' of the build must be a SemVer version"); - - var violations = FindKitVersionViolations(repositoryRoot, engineVersion!); - - violations - .Should().BeEmpty( - "every skill carries one kit version x.y.z with the major.minor of the engine {0}, and every " - + "handshake text names that version; violations:{1}{2}", - engineVersionText, Environment.NewLine, string.Join(Environment.NewLine, violations)); - } - - [Fact] - public void FindKitVersionViolations_SkillsWithOneVersionAndMatchingHandshakes_ReturnsNoViolation() - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, "0.8.0", "a", - "1. Version handshake: run `shade-kit version --json --expect 0.8.0`; 0.8.0 is the kit version of this " - + "skill (`metadata.version` in its frontmatter)."); - WriteSkill(root, "0.8.0", "b", "No handshake here."); - root.WriteFile("Run `shade-kit version --json --expect 0.8.0` first.", "skills", "b", "references", "x.md"); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().BeEmpty(); - } - - [Fact] - public void FindKitVersionViolations_SkillWithOtherVersion_ReportsFileLineAndExpectedAndFoundVersion() - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, "0.8.0", "a", "Body"); - WriteSkill(root, "0.8.1", "b", "Body"); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal( - $"{SkillPath("b")}:5: expected metadata.version 0.8.0 (the kit version of {SkillPath("a")}), " - + "found 0.8.1"); - } - - [Fact] - public void FindKitVersionViolations_HandshakeTextsWithOtherVersion_ReportsEveryOccurrence() - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, "0.8.0", "a", - "1. Version handshake: run `shade-kit version --json --expect 0.7.0`; 0.7.0 is the kit version of this " - + "skill.\nThe only command is `shade-kit version --json --expect=0.9.0`."); - root.WriteFile("Line\nRun `shade-kit version --expect 1.0.0 --json`.", "skills", "a", "references", "x.md"); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal( - $"{SkillPath("a")}:8: expected --expect 0.8.0, found --expect 0.7.0", - $"{SkillPath("a")}:8: expected '0.8.0 is the kit version of this skill', " - + "found '0.7.0 is the kit version of this skill'", - $"{SkillPath("a")}:9: expected --expect 0.8.0, found --expect 0.9.0", - $"{Path.Combine("skills", "a", "references", "x.md")}:2: expected --expect 0.8.0, " - + "found --expect 1.0.0"); - } - - [Theory] - [InlineData("Run `shade-kit version --json --expect \"0.7.0\"`.")] - [InlineData("Run `shade-kit version --json --expect '0.7.0'`.")] - [InlineData("Run shade-kit version --json --expect `0.7.0`.")] - [InlineData("Run `shade-kit version --json --expect\t0.7.0`.")] - [InlineData("Run shade-kit version --json --expect 0.7.0.")] - public void FindKitVersionViolations_QuotedOrPunctuatedExpectValue_ReportsTheBareVersion(string body) - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, "0.8.0", "a", body); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal($"{SkillPath("a")}:8: expected --expect 0.8.0, found --expect 0.7.0"); - } - - [Theory] - [InlineData("Run shade-kit version --json --expect 0.8.0.")] - [InlineData("Run shade-kit version --json --expect 0.8.0: the handshake.")] - [InlineData("**0.8.0** is the kit version of this skill.")] - [InlineData("(0.8.0\tis the kit version of this skill)")] - [InlineData("\"0.8.0\" is the kit version of this skill.")] - public void FindKitVersionViolations_KitVersionWithPunctuationOrEmphasis_ReturnsNoViolation(string body) - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, "0.8.0", "a", body); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().BeEmpty(); - } - - [Fact] - public void FindKitVersionViolations_HandshakeWrappedAcrossLines_ReportsTheLineWhereTheMatchStarts() - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, "0.8.0", "a", - "Version handshake: run `shade-kit version --json --expect\n0.7.0`; 0.7.0 is the kit\r\nversion of " - + "this skill.\n**0.9.0**\nis the kit version of this skill."); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal( - $"{SkillPath("a")}:8: expected --expect 0.8.0, found --expect 0.7.0", - $"{SkillPath("a")}:9: expected '0.8.0 is the kit version of this skill', " - + "found '0.7.0 is the kit\r\nversion of this skill'", - $"{SkillPath("a")}:11: expected '0.8.0 is the kit version of this skill', " - + "found '0.9.0**\nis the kit version of this skill'"); - } - - [Fact] - public void FindKitVersionViolations_MatchingAndOtherExpectOnOneLine_ReportsOnlyTheOtherOne() - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, "0.8.0", "a", "Run `--expect 0.8.0` or `--expect 0.7.1`, never `--expect 0.8.0`."); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal($"{SkillPath("a")}:8: expected --expect 0.8.0, found --expect 0.7.1"); - } - - [Fact] - public void FindKitVersionViolations_PlaceholderAfterExpect_ReportsThePlaceholder() - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, "0.8.0", "a", "Run `shade-kit version --json --expect `."); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal($"{SkillPath("a")}:8: expected --expect 0.8.0, found --expect "); - } - - [Fact] - public void FindKitVersionViolations_LongBundledLineWithoutWhitespace_FinishesWithoutRegexTimeout() - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, "0.8.0", "a", "Body"); - root.WriteFile(new string('a', 200_000) + " is the kit version of this skill", "skills", "a", "asset.svg"); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().ContainSingle() - .Which.Should().StartWith($"{Path.Combine("skills", "a", "asset.svg")}:1: expected '0.8.0 is the kit"); - } - - [Fact] - public void FindKitVersionViolations_SkillWithOtherVersionAndOtherMajorMinor_ReportsBothForTheSkill() - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, "0.8.0", "a", "Body"); - WriteSkill(root, "0.9.0", "b", "Body"); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal( - $"{SkillPath("b")}:5: expected metadata.version 0.8.0 (the kit version of {SkillPath("a")}), " - + "found 0.9.0", - $"{SkillPath("b")}:5: expected the major.minor 0.8 of the engine version 0.8.3, found 0.9.0"); - } - - [Fact] - public void FindKitVersionViolations_OutlierFirstInPathOrder_ReportsOnlyTheOutlier() - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, "0.8.1", "a", "Body"); - WriteSkill(root, "0.8.0", "b", "Run `shade-kit version --json --expect 0.8.0`."); - WriteSkill(root, "0.8.0", "c", "Body"); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal( - $"{SkillPath("a")}:5: expected metadata.version 0.8.0 (the kit version of {SkillPath("b")}), " - + "found 0.8.1"); - } - - [Fact] - public void FindKitVersionViolations_MoreFrequentVersionWithOtherMajorMinor_IsTheKitVersion() - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, "0.8.0", "a", "Body"); - WriteSkill(root, "0.9.0", "b", "Body"); - WriteSkill(root, "0.9.0", "c", "Body"); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal( - $"{SkillPath("a")}:5: expected metadata.version 0.9.0 (the kit version of {SkillPath("b")}), " - + "found 0.8.0", - $"{SkillPath("b")}:5: expected the major.minor 0.8 of the engine version 0.8.3, found 0.9.0", - $"{SkillPath("c")}:5: expected the major.minor 0.8 of the engine version 0.8.3, found 0.9.0"); - } - - [Fact] - public void FindKitVersionViolations_TieWithOneVersionMatchingEngineMajorMinor_TakesThatVersion() - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, "0.9.0", "a", "Body"); - WriteSkill(root, "0.9.0", "b", "Body"); - WriteSkill(root, "0.8.0", "c", "Run `shade-kit version --json --expect 0.8.0`."); - WriteSkill(root, "0.8.0", "d", "Body"); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal( - $"{SkillPath("a")}:5: expected metadata.version 0.8.0 (the kit version of {SkillPath("c")}), " - + "found 0.9.0", - $"{SkillPath("a")}:5: expected the major.minor 0.8 of the engine version 0.8.3, found 0.9.0", - $"{SkillPath("b")}:5: expected metadata.version 0.8.0 (the kit version of {SkillPath("c")}), " - + "found 0.9.0", - $"{SkillPath("b")}:5: expected the major.minor 0.8 of the engine version 0.8.3, found 0.9.0"); - } - - [Fact] - public void FindKitVersionViolations_TieOfInterleavedVersionsWithSameMajorMinor_TakesTheVersionOfTheFirstSkill() - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, "0.8.1", "a", "Body"); - WriteSkill(root, "0.8.0", "b", "Body"); - WriteSkill(root, "0.8.1", "c", "Body"); - WriteSkill(root, "0.8.0", "d", "Body"); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal( - $"{SkillPath("b")}:5: expected metadata.version 0.8.1 (the kit version of {SkillPath("a")}), " - + "found 0.8.0", - $"{SkillPath("d")}:5: expected metadata.version 0.8.1 (the kit version of {SkillPath("a")}), " - + "found 0.8.0"); - } - - [Fact] - public void FindKitVersionViolations_TieOfSingleSkillsWithEngineMatchLastInPathOrder_TakesTheMatchingVersion() - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, "0.9.0", "a", "Body"); - WriteSkill(root, "0.7.0", "b", "Body"); - WriteSkill(root, "0.8.0", "c", "Body"); - - // Act - var violations = FindKitVersionViolations(root.RootPath, SemanticVersion.Parse("0.8.3-feature.2")); - - // Assert - violations - .Where(x => x.Contains(": expected metadata.version ", StringComparison.Ordinal)) - .Should().Equal( - $"{SkillPath("a")}:5: expected metadata.version 0.8.0 (the kit version of {SkillPath("c")}), " - + "found 0.9.0", - $"{SkillPath("b")}:5: expected metadata.version 0.8.0 (the kit version of {SkillPath("c")}), " - + "found 0.7.0"); - } - - [Fact] - public void FindKitVersionViolations_SeveralInvalidVersionsAndOneValid_TakesTheValidVersion() - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, "0.8", "a", "Body"); - WriteSkill(root, "0.8", "b", "Body"); - WriteSkill(root, "0.8.0", "c", "Run `shade-kit version --json --expect 0.8.0`."); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal( - $"{SkillPath("a")}:5: expected metadata.version as a plain x.y.z version, found '0.8'", - $"{SkillPath("b")}:5: expected metadata.version as a plain x.y.z version, found '0.8'"); - } - - [Theory] - [InlineData("0.8.1", "0.8.0")] - [InlineData("0.9.0", "0.7.0")] - public void FindKitVersionViolations_TieWithEqualEngineMatch_TakesTheVersionOfTheFirstSkillInPathOrder( - string firstVersion, string secondVersion) - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, firstVersion, "a", "Body"); - WriteSkill(root, secondVersion, "b", "Body"); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Where(x => x.Contains(": expected metadata.version ", StringComparison.Ordinal)) - .Should().Equal( - $"{SkillPath("b")}:5: expected metadata.version {firstVersion} " - + $"(the kit version of {SkillPath("a")}), found {secondVersion}"); - } - - [Theory] - [InlineData("0.7.0")] - [InlineData("0.9.0")] - [InlineData("1.8.0")] - public void FindKitVersionViolations_KitVersionWithOtherMajorMinorThanEngine_ReportsEverySkill( - string kitVersion) - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, kitVersion, "a", "Body"); - WriteSkill(root, kitVersion, "b", "Body"); - - // Act - var violations = FindKitVersionViolations(root.RootPath, SemanticVersion.Parse("0.8.3-feature.2")); - - // Assert - violations - .Should().Equal( - $"{SkillPath("a")}:5: expected the major.minor 0.8 of the engine version 0.8.3-feature.2, " - + $"found {kitVersion}", - $"{SkillPath("b")}:5: expected the major.minor 0.8 of the engine version 0.8.3-feature.2, " - + $"found {kitVersion}"); - } - - [Theory] - [InlineData("0.8.7")] - [InlineData("0.8.0")] - public void FindKitVersionViolations_KitPatchDiffersFromEnginePatch_ReturnsNoViolation(string kitVersion) - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, kitVersion, "a", "Body"); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().BeEmpty(); - } - - [Theory] - [InlineData("0.8.0-beta.1")] - [InlineData("0.8.0+build.5")] - [InlineData("\"0.8.0\"")] - [InlineData("'0.8.0'")] - [InlineData("0.8")] - [InlineData("v0.8.0")] - [InlineData("08.0.0")] - [InlineData("0.8.0 # kit version")] - [InlineData("")] - public void FindKitVersionViolations_VersionThatIsNotPlainSemVer_ReportsFileLineAndFoundValue( - string version) - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, version, "a", "Body"); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal( - $"{SkillPath("a")}:5: expected metadata.version as a plain x.y.z version, found '{version}'"); - } - - [Fact] - public void FindKitVersionViolations_InvalidVersionInFirstSkill_TakesKitVersionFromNextValidSkill() - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, "0.8", "a", "Run `shade-kit version --json --expect 0.8.0`."); - WriteSkill(root, "0.8.0", "b", "Body"); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal($"{SkillPath("a")}:5: expected metadata.version as a plain x.y.z version, found '0.8'"); - } - - [Theory] - [InlineData("")] - [InlineData("---")] - [InlineData(" ---\nname: a\n---\nBody")] - [InlineData("# shade-kit-a\n\nBody")] - [InlineData("\n---\nname: a\n---\nBody")] - [InlineData("---\nname: a\nmetadata:\n version: 0.8.0\n")] - public void FindKitVersionViolations_SkillWithoutFrontmatter_ReportsMissingFrontmatter(string content) - { - // Arrange - using var root = new TempKitDirectory(); - root.WriteFile(content, "skills", "a", SkillFileName); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal( - $"{SkillPath("a")}:1: expected a frontmatter between a first line '---' and a second line '---', " - + "found none"); - } - - [Theory] - [InlineData("---\nname: a\n---\nmetadata:\n version: 0.8.0\n", 3)] - [InlineData("---\nname: a\nversion: 0.8.0\n---\nBody", 4)] - [InlineData("---\nname: a\nmetadata:\n author: x\nversion: 0.8.0\n---\nBody", 6)] - [InlineData("---\nname: a\nmetadata:\n other:\n version: 0.8.0\n---\nBody", 6)] - [InlineData("---\nname: a\nmetadata: {version: 0.8.0}\n---\nBody", 4)] - [InlineData("---\nname: a\nmetadata:\n version:0.8.0\n---\nBody", 5)] - [InlineData("---\nname: a\nmetadata:\n---\nBody", 4)] - [InlineData("---\n---\nBody", 2)] - [InlineData("--- \nname: a\n---\t\nBody", 3)] - public void FindKitVersionViolations_FrontmatterWithoutMetadataVersion_ReportsClosingDelimiterLine( - string content, int closingLine) - { - // Arrange - using var root = new TempKitDirectory(); - root.WriteFile(content, "skills", "a", SkillFileName); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal( - $"{SkillPath("a")}:{closingLine}: expected metadata.version in the frontmatter, found none"); - } - - [Fact] - public void FindKitVersionViolations_FrontmatterWithBomCrLfAndOtherMetadata_ReadsVersion() - { - // Arrange - using var root = new TempKitDirectory(); - root.WriteFileBytes( - [ - 0xEF, 0xBB, 0xBF, - .. "---\r\nname: a\r\nmetadata:\r\n author: x\r\n\r\n version: 0.8.0 \r\n---\r\nBody\r\n"u8 - ], - "skills", "a", SkillFileName); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().BeEmpty(); - } - - [Fact] - public void FindKitVersionViolations_VersionOutsideFrontmatter_IsNotTakenAsKitVersion() - { - // Arrange - using var root = new TempKitDirectory(); - root.WriteFile("---\nname: a\n---\nmetadata:\n version: 0.8.0\n---\n", "skills", "a", SkillFileName); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal($"{SkillPath("a")}:3: expected metadata.version in the frontmatter, found none"); - } - - [Fact] - public void FindKitVersionViolations_SkillFileThatIsNotUtf8_ThrowsInvalidDataException() - { - // Arrange - using var root = new TempKitDirectory(); - root.WriteFileBytes([.. "---\nname: a\n---\n"u8, 0xFC], "skills", "a", SkillFileName); - - // Act - var act = () => FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - act - .Should().Throw() - .WithMessage($"*{SkillPath("a")}*not valid UTF-8*"); - } - - [Fact] - public void FindKitVersionViolations_BundledFileWithBom_ReportsTheVersionWithoutTheBom() - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, "0.8.0", "a", "Body"); - root.WriteFileBytes([0xEF, 0xBB, 0xBF, .. "0.7.0 is the kit version of this skill"u8], - "skills", "a", "notes.md"); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal( - $"{Path.Combine("skills", "a", "notes.md")}:1: expected '0.8.0 is the kit version of this skill', " - + "found '0.7.0 is the kit version of this skill'"); - } - - [Fact] - public void FindKitVersionViolations_LowercaseSkillFileName_IsNotASkillFile() - { - // Arrange - using var root = new TempKitDirectory(); - root.WriteFile("---\nname: a\nmetadata:\n version: 0.8.0\n---\n", "skills", "a", "skill.md"); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal($"skills: expected at least one {SkillFileName}, found none"); - } - - [Fact] - public void FindKitVersionViolations_NoSkillFiles_ReportsMissingSkills() - { - // Arrange - using var root = new TempKitDirectory(); - root.WriteFile("Run `shade-kit version --json --expect 0.7.0`.", "skills", "a", "notes.md"); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal($"skills: expected at least one {SkillFileName}, found none"); - } - - [Fact] - public void FindKitVersionViolations_NoValidKitVersion_ReportsOnlyTheInvalidVersions() - { - // Arrange - using var root = new TempKitDirectory(); - WriteSkill(root, "0.8.0-beta.1", "a", "Run `shade-kit version --json --expect 0.7.0`."); - - // Act - var violations = FindKitVersionViolations(root.RootPath, DefaultEngineVersion); - - // Assert - violations - .Should().Equal( - $"{SkillPath("a")}:5: expected metadata.version as a plain x.y.z version, found '0.8.0-beta.1'"); - } - - private static void WriteSkill(TempKitDirectory root, string version, string name, string body) - { - root.WriteFile( - $"---\nname: shade-kit-{name}\ndescription: Test skill {name}.\nmetadata:\n version: {version}\n---\n\n" - + $"{body}\n", - "skills", name, SkillFileName); - } - - private static string SkillPath(string name) - { - return Path.Combine("skills", name, SkillFileName); - } - - /// - /// Checks the kit version of the skills under skills/: every SKILL.md has a frontmatter - /// metadata.version as a plain x.y.z version; all skills carry the same value (the kit version, - /// chosen by ); its major.minor is the major.minor of the engine; every - /// --expect <v> and every "<v> is the kit version of this skill" in any text file under - /// skills/ names the kit version. - /// - /// One line per violation: the path relative to the repository, the line, and expected vs. found. - private static string[] FindKitVersionViolations(string repositoryRoot, SemanticVersion engineVersion) - { - var skills = ShippedSkillFiles.EnumerateSkillFiles(repositoryRoot) - .Select(file => ReadFrontmatterVersion(Path.GetRelativePath(repositoryRoot, file), - ShippedSkillFiles.ReadLines(file))) - .ToArray(); - - if (skills.Length == 0) - { - return [$"{ShippedSkillFiles.SkillsDirectoryName}: expected at least one {SkillFileName}, found none"]; - } - - var violations = new List(); - var kitSkill = SelectKitSkill(skills, engineVersion); - - foreach (var skill in skills) - { - if (skill.Version is null) - { - violations.Add($"{skill.File}:{skill.Line}: {skill.Error}"); - continue; - } - - if (skill.Version != kitSkill?.Version) - { - violations.Add($"{skill.File}:{skill.Line}: expected metadata.version {kitSkill?.Version} " - + $"(the kit version of {kitSkill?.File}), found {skill.Version}"); - } - - if (skill.Version.Major != engineVersion.Major || skill.Version.Minor != engineVersion.Minor) - { - violations.Add($"{skill.File}:{skill.Line}: expected the major.minor " - + $"{engineVersion.Major}.{engineVersion.Minor} of the engine version {engineVersion}, " - + $"found {skill.Version}"); - } - } - - if (kitSkill?.Version is not null) - { - violations.AddRange(FindHandshakeViolations(repositoryRoot, kitSkill.Version.ToString())); - } - - return violations.ToArray(); - } - - /// - /// Selects the skill whose version is the kit version, so that a single skill with another version is the one - /// that is reported. - /// - /// - /// The kit version is the most frequent valid version. On a tie, a version with the major.minor of the engine wins, - /// then the version of the skill that comes first in ordinal path order. - /// - /// - /// The first skill in ordinal path order that carries the kit version, or if no skill has a - /// valid version. - /// - private static SkillVersion? SelectKitSkill(SkillVersion[] skills, SemanticVersion engineVersion) - { - // GroupBy keeps the groups in the order of their first skill and the skills of a group in path order, and the - // sort is stable, so the remaining ties keep the path order. - return skills - .Where(x => x.Version is not null) - .GroupBy(x => x.Version!) - .OrderByDescending(group => group.Count()) - .ThenByDescending(group => - group.Key.Major == engineVersion.Major && group.Key.Minor == engineVersion.Minor) - .Select(group => group.First()) - .FirstOrDefault(); - } - - // The texts are matched as a whole, so that a handshake wrapped across lines is found too; the line of a violation - // is the line where the match starts. - private static IEnumerable FindHandshakeViolations(string repositoryRoot, string kitVersion) - { - var expectedSentence = $"{kitVersion} is the kit version of this skill"; - - return ShippedSkillFiles.ReadTextFiles(repositoryRoot) - .SelectMany(file => - { - var path = Path.GetRelativePath(repositoryRoot, file.File); - - return ExpectOptionRegex().Matches(file.Text) - .Select(match => (match.Index, Version: match.Groups["version"].Value.TrimEnd('.', ':'), - Found: (string?)null)) - .Concat(KitVersionSentenceRegex().Matches(file.Text) - .Select(match => (match.Index, Version: match.Groups["version"].Value, - Found: (string?)match.Value))) - .Where(x => x.Version != kitVersion) - .OrderBy(x => x.Index) - .Select(x => - { - var location = $"{path}:{ShippedSkillFiles.SplitLines(file.Text[..x.Index]).Length}"; - - return x.Found is null - ? $"{location}: expected --expect {kitVersion}, found --expect {x.Version}" - : $"{location}: expected '{expectedSentence}', found '{x.Found}'"; - }); - }); - } - - private static SkillVersion ReadFrontmatterVersion(string file, string[] lines) - { - var closingIndex = lines.Length > 0 && lines[0].TrimEnd() == FrontmatterDelimiter - ? Array.FindIndex(lines, 1, line => line.TrimEnd() == FrontmatterDelimiter) - : -1; - - if (closingIndex < 0) - { - return new SkillVersion(file, 1, null, - $"expected a frontmatter between a first line '{FrontmatterDelimiter}' and a second line " - + $"'{FrontmatterDelimiter}', found none"); - } - - var versionIndex = FindMetadataVersionIndex(lines, closingIndex); - - if (versionIndex >= 0) - { - var value = MetadataVersionRegex().Match(lines[versionIndex]).Groups["value"].Value; - - return IsPlainVersion(value, out var version) - ? new SkillVersion(file, versionIndex + 1, version, null) - : new SkillVersion(file, versionIndex + 1, null, - $"expected metadata.version as a plain x.y.z version, found '{value}'"); - } - - return new SkillVersion(file, closingIndex + 1, null, - "expected metadata.version in the frontmatter, found none"); - } - - // The index of the line " version: ..." among the entries of "metadata:" in the frontmatter (lines 1 to - // closingIndex - 1), or -1. The entries are the indented or blank lines that follow "metadata:". - private static int FindMetadataVersionIndex(string[] lines, int closingIndex) - { - var metadataIndex = Array.FindIndex(lines, 1, closingIndex - 1, line => MetadataKeyRegex().IsMatch(line)); - - if (metadataIndex < 0) - { - return -1; - } - - for (var index = metadataIndex + 1; index < closingIndex; index++) - { - var line = lines[index]; - - if (line.Length > 0 && !char.IsWhiteSpace(line[0])) - { - return -1; - } - - if (MetadataVersionRegex().IsMatch(line)) - { - return index; - } - } - - return -1; - } - - private static bool IsPlainVersion(string value, out SemanticVersion? version) - { - return SemanticVersion.TryParse(value, out version) && !version.IsPrerelease && version.ToString() == value; - } - - private sealed record SkillVersion(string File, int Line, SemanticVersion? Version, string? Error); - - [GeneratedRegex(@"^metadata:[ \t]*$", RegexOptions.CultureInvariant, matchTimeoutMilliseconds: 1000)] - private static partial Regex MetadataKeyRegex(); - - // A direct child "version:" of the metadata map: exactly two spaces, the indentation the skills use. YAML needs a - // space after the colon ("version:0.8.0" is no key), so the value follows only after a blank. - [GeneratedRegex(@"^ version:(?:[ \t]+(?.*?))?[ \t]*$", RegexOptions.CultureInvariant, - matchTimeoutMilliseconds: 1000)] - private static partial Regex MetadataVersionRegex(); - - // The value after "--expect" (a blank, a line break, or "="; optionally quoted); a trailing "." or ":" of the - // sentence is cut off in code. - [GeneratedRegex(@"--expect(?:\s+|=)[""'`]?(?[^\s`'"";,)]+)", RegexOptions.CultureInvariant, - matchTimeoutMilliseconds: 1000)] - private static partial Regex ExpectOptionRegex(); - - // The version token before the sentence, which may be wrapped across lines. The lookbehind starts a match only at - // the start of a token and the atomic group gives up a token without backtracking, so a long line without - // whitespace takes linear time. Quotes, parentheses, and Markdown emphasis are not part of the token. - [GeneratedRegex( - @"(?(?>[^\s`'""(*_]+))[*_`'""]*\s+is\s+the\s+kit\s+version\s+of\s+this\s+skill", - RegexOptions.CultureInvariant, matchTimeoutMilliseconds: 1000)] - private static partial Regex KitVersionSentenceRegex(); -} diff --git a/tests/CreativeCoders.ShadeKit.Core.Tests/Versions/CliContractCheckerTests.cs b/tests/CreativeCoders.ShadeKit.Core.Tests/Versions/CliContractCheckerTests.cs new file mode 100644 index 0000000..8e975ba --- /dev/null +++ b/tests/CreativeCoders.ShadeKit.Core.Tests/Versions/CliContractCheckerTests.cs @@ -0,0 +1,132 @@ +using AwesomeAssertions; +using CreativeCoders.ShadeKit.Core.Versions; +using CreativeCoders.ShadeKit.Core.Versions.Exceptions; + +namespace CreativeCoders.ShadeKit.Core.Tests.Versions; + +public class CliContractCheckerTests +{ + [Theory] + [InlineData(2)] + [InlineData(3)] + [InlineData(4)] + public void Check_RequestedWithinWindow_Succeeds(int requestedContract) + { + // Arrange + var checker = new CliContractChecker(new CliContractWindow(2, 4)); + + // Act + var act = () => checker.Check(requestedContract); + + // Assert + act.Should().NotThrow(); + } + + [Fact] + public void Check_RequestedAboveCurrent_ThrowsEngineContractOutdatedExceptionWithContracts() + { + // Arrange + var checker = new CliContractChecker(new CliContractWindow(2, 4)); + + // Act + var act = () => checker.Check(5); + + // Assert + var exception = act.Should().Throw().Which; + + exception.RequestedContract + .Should().Be(5); + + exception.MinSupportedContract + .Should().Be(2); + + exception.CurrentContract + .Should().Be(4); + } + + [Fact] + public void Check_RequestedBelowMinSupported_ThrowsSkillsContractOutdatedExceptionWithContracts() + { + // Arrange + var checker = new CliContractChecker(new CliContractWindow(2, 4)); + + // Act + var act = () => checker.Check(1); + + // Assert + var exception = act.Should().Throw().Which; + + exception.RequestedContract + .Should().Be(1); + + exception.MinSupportedContract + .Should().Be(2); + + exception.CurrentContract + .Should().Be(4); + } + + [Fact] + public void Check_RequestedZeroWithDefaultWindow_ThrowsSkillsContractOutdatedException() + { + // Arrange + var checker = new CliContractChecker(CliContract.Window); + + // Act + var act = () => checker.Check(0); + + // Assert + var exception = act.Should().Throw().Which; + + exception.RequestedContract + .Should().Be(0); + + exception.MinSupportedContract + .Should().Be(CliContract.MinSupported); + + exception.CurrentContract + .Should().Be(CliContract.Current); + } + + [Theory] + [InlineData(-1)] + [InlineData(int.MinValue)] + public void Check_NegativeRequested_ThrowsArgumentOutOfRangeException(int requestedContract) + { + // Arrange + var checker = new CliContractChecker(new CliContractWindow(2, 4)); + + // Act + var act = () => checker.Check(requestedContract); + + // Assert + act.Should().Throw() + .Which.ParamName.Should().Be("requestedContract"); + } + + [Fact] + public void Ctor_NullWindow_ThrowsArgumentNullException() + { + // Act + var act = () => new CliContractChecker(null!); + + // Assert + act.Should().Throw() + .Which.ParamName.Should().Be("window"); + } + + [Fact] + public void Window_Constructed_ReturnsWindowOfConstructor() + { + // Arrange + var window = new CliContractWindow(2, 4); + var checker = new CliContractChecker(window); + + // Act + var actualWindow = checker.Window; + + // Assert + actualWindow + .Should().BeSameAs(window); + } +} diff --git a/tests/CreativeCoders.ShadeKit.Core.Tests/Versions/CliContractTests.cs b/tests/CreativeCoders.ShadeKit.Core.Tests/Versions/CliContractTests.cs new file mode 100644 index 0000000..c0d5466 --- /dev/null +++ b/tests/CreativeCoders.ShadeKit.Core.Tests/Versions/CliContractTests.cs @@ -0,0 +1,27 @@ +using AwesomeAssertions; +using CreativeCoders.ShadeKit.Core.Versions; + +namespace CreativeCoders.ShadeKit.Core.Tests.Versions; + +public class CliContractTests +{ + [Fact] + public void Window_Constants_AreCurrentAndMinSupported() + { + // Act + var window = CliContract.Window; + + // Assert + CliContract.MinSupported + .Should().Be(1); + + CliContract.Current + .Should().Be(1); + + window.MinSupported + .Should().Be(CliContract.MinSupported); + + window.Current + .Should().Be(CliContract.Current); + } +} diff --git a/tests/CreativeCoders.ShadeKit.Core.Tests/Versions/CliContractWindowTests.cs b/tests/CreativeCoders.ShadeKit.Core.Tests/Versions/CliContractWindowTests.cs new file mode 100644 index 0000000..fe8bbe8 --- /dev/null +++ b/tests/CreativeCoders.ShadeKit.Core.Tests/Versions/CliContractWindowTests.cs @@ -0,0 +1,49 @@ +using AwesomeAssertions; +using CreativeCoders.ShadeKit.Core.Versions; + +namespace CreativeCoders.ShadeKit.Core.Tests.Versions; + +public class CliContractWindowTests +{ + [Theory] + [InlineData(0, 1)] + [InlineData(-1, 1)] + public void Ctor_MinSupportedBelowOne_ThrowsArgumentOutOfRangeException(int minSupported, int current) + { + // Act + var act = () => new CliContractWindow(minSupported, current); + + // Assert + act.Should().Throw() + .Which.ParamName.Should().Be("minSupported"); + } + + [Theory] + [InlineData(2, 1)] + [InlineData(5, 4)] + public void Ctor_CurrentBelowMinSupported_ThrowsArgumentOutOfRangeException(int minSupported, int current) + { + // Act + var act = () => new CliContractWindow(minSupported, current); + + // Assert + act.Should().Throw() + .Which.ParamName.Should().Be("current"); + } + + [Theory] + [InlineData(1, 1)] + [InlineData(2, 4)] + public void Ctor_ValidValues_ExposesThem(int minSupported, int current) + { + // Act + var window = new CliContractWindow(minSupported, current); + + // Assert + window.MinSupported + .Should().Be(minSupported); + + window.Current + .Should().Be(current); + } +} diff --git a/tests/CreativeCoders.ShadeKit.Core.Tests/Versions/EngineVersionCheckerTests.cs b/tests/CreativeCoders.ShadeKit.Core.Tests/Versions/EngineVersionCheckerTests.cs deleted file mode 100644 index ab33b03..0000000 --- a/tests/CreativeCoders.ShadeKit.Core.Tests/Versions/EngineVersionCheckerTests.cs +++ /dev/null @@ -1,273 +0,0 @@ -using AwesomeAssertions; -using CreativeCoders.ShadeKit.Core.Engine; -using CreativeCoders.ShadeKit.Core.Versions; -using CreativeCoders.ShadeKit.Core.Versions.Exceptions; -using CreativeCoders.ShadeKit.Core.Versions.Warnings; -using FakeItEasy; - -namespace CreativeCoders.ShadeKit.Core.Tests.Versions; - -public class EngineVersionCheckerTests -{ - [Theory] - [Trait("Requirement", "FP06-1-AC3")] - [InlineData("1.2.0", "1.2.0")] - [InlineData("1.2.0", "1.2.7")] - [InlineData("1.2.7", "1.2.0")] - [InlineData("0.1.3", "0.1.0")] - public void Check_ReleaseEngineWithSameMajorAndMinor_ReturnsResultWithoutWarnings(string engineVersion, - string expectedVersion) - { - // Arrange - var checker = CreateChecker(engineVersion); - - // Act - var result = checker.Check(expectedVersion); - - // Assert - result.EngineVersion - .Should().Be(engineVersion); - - result.ExpectedVersion - .Should().Be(expectedVersion); - - result.Warnings - .Should().BeEmpty(); - } - - [Theory] - [Trait("Requirement", "FP06-1-AC3")] - [InlineData("1.2.0-beta.1", "1.2.0")] - [InlineData("1.2.3-rc.1", "1.2.0")] - [InlineData("1.2.0-alpha", "1.2.5-beta.2")] - public void Check_PrereleaseEngineWithSameMajorAndMinor_ReturnsResultWithoutWarnings(string engineVersion, - string expectedVersion) - { - // Arrange - var checker = CreateChecker(engineVersion); - - // Act - var result = checker.Check(expectedVersion); - - // Assert - result.Warnings - .Should().BeEmpty(); - } - - [Theory] - [Trait("Requirement", "FP06-1-AC3")] - [InlineData("1.2.0-beta.1")] - [InlineData("1.2.0+build.5")] - [InlineData("1.2.9-rc.1+sha.abc")] - public void Check_ExpectedVersionWithPrereleaseOrBuildMetadata_IgnoresThemAndKeepsValueAsPassed( - string expectedVersion) - { - // Arrange - var checker = CreateChecker("1.2.0"); - - // Act - var result = checker.Check(expectedVersion); - - // Assert - result.ExpectedVersion - .Should().Be(expectedVersion); - - result.Warnings - .Should().BeEmpty(); - } - - [Theory] - [Trait("Requirement", "FP06-1-AC1")] - [Trait("Requirement", "FP06-1-AC2")] - [InlineData("1.2.0", "1.3.0")] - [InlineData("1.2.9", "2.0.0")] - [InlineData("1.9.0", "2.1.0")] - [InlineData("1.2.0", "1.3.0-beta.1")] - [InlineData("0.9.0", "1.0.0+build.1")] - [InlineData("1.9.0", "1.10.0")] - [InlineData("0.0.0", "0.2147483647.0")] - [InlineData("1.2.0+sha.abc", "1.3.0")] - public void Check_ReleaseEngineWithLowerMajorOrMinor_ThrowsMismatchWithEngineOlder(string engineVersion, - string expectedVersion) - { - // Arrange - var checker = CreateChecker(engineVersion); - - // Act - var act = () => checker.Check(expectedVersion); - - // Assert - var exception = act.Should().Throw().Which; - - exception.EngineVersion - .Should().Be(engineVersion); - - exception.ExpectedVersion - .Should().Be(expectedVersion); - - exception.Direction - .Should().Be(EngineVersionMismatchDirection.EngineOlder); - } - - [Theory] - [Trait("Requirement", "FP06-1-AC1")] - [Trait("Requirement", "FP06-1-AC2")] - [InlineData("1.3.0", "1.2.0")] - [InlineData("2.0.0", "1.9.9")] - [InlineData("2.1.0", "1.9.0")] - [InlineData("1.3.0", "1.2.9-rc.1")] - [InlineData("1.10.0", "1.9.0")] - [InlineData("2147483647.0.0", "0.0.0")] - [InlineData("1.3.0+sha.abc", "1.2.0")] - public void Check_ReleaseEngineWithHigherMajorOrMinor_ThrowsMismatchWithEngineNewer(string engineVersion, - string expectedVersion) - { - // Arrange - var checker = CreateChecker(engineVersion); - - // Act - var act = () => checker.Check(expectedVersion); - - // Assert - var exception = act.Should().Throw().Which; - - exception.EngineVersion - .Should().Be(engineVersion); - - exception.ExpectedVersion - .Should().Be(expectedVersion); - - exception.Direction - .Should().Be(EngineVersionMismatchDirection.EngineNewer); - } - - [Theory] - [Trait("Requirement", "FP06-1-AC4")] - [InlineData("1.2.0-beta.1", "1.3.0", EngineVersionMismatchDirection.EngineOlder)] - [InlineData("1.9.0-rc.2", "2.0.0", EngineVersionMismatchDirection.EngineOlder)] - [InlineData("1.3.0-beta.1", "1.2.0", EngineVersionMismatchDirection.EngineNewer)] - [InlineData("2.0.0-alpha", "1.9.0+build.3", EngineVersionMismatchDirection.EngineNewer)] - public void Check_PrereleaseEngineWithDifferentMajorOrMinor_ReturnsResultWithPrereleaseWarning( - string engineVersion, string expectedVersion, EngineVersionMismatchDirection expectedDirection) - { - // Arrange - var checker = CreateChecker(engineVersion); - - // Act - var result = checker.Check(expectedVersion); - - // Assert - result.EngineVersion - .Should().Be(engineVersion); - - result.ExpectedVersion - .Should().Be(expectedVersion); - - result.Warnings - .Should().Equal(new EnginePrereleaseVersionMismatchWarning(engineVersion, expectedVersion, - expectedDirection)); - } - - [Theory] - [Trait("Requirement", "FP06-1-AC5")] - [InlineData("")] - [InlineData(" ")] - [InlineData("v1.2.0")] - [InlineData("1.2")] - [InlineData("1.2.0.0")] - [InlineData(" 1.2.0")] - [InlineData("01.2.0")] - [InlineData("latest")] - public void Check_InvalidExpectedVersion_ThrowsInvalidSemanticVersionExceptionWithValue(string expectedVersion) - { - // Arrange - var checker = CreateChecker("1.2.0"); - - // Act - var act = () => checker.Check(expectedVersion); - - // Assert - act.Should().Throw() - .Which.Value.Should().Be(expectedVersion); - } - - [Fact] - public void Check_InvalidExpectedVersionAndInvalidEngineVersion_ThrowsInvalidSemanticVersionException() - { - // Arrange - var checker = CreateChecker("1.0.0.0"); - - // Act - var act = () => checker.Check("1.2"); - - // Assert - act.Should().Throw() - .Which.Value.Should().Be("1.2"); - } - - [Theory] - [InlineData("1.0.0.0")] - [InlineData("")] - [InlineData("1.2")] - [InlineData("1.2.0-")] - [InlineData("v1.2.0")] - public void Check_InvalidEngineVersion_ThrowsInvalidOperationExceptionNamingEngineVersion(string engineVersion) - { - // Arrange - var checker = CreateChecker(engineVersion); - - // Act - var act = () => checker.Check("1.2.0"); - - // Assert - act.Should().Throw() - .WithMessage($"The engine version '{engineVersion}' is not a valid SemVer 2.0.0 version*"); - } - - [Fact] - public void Check_NullExpectedVersionAndInvalidEngineVersion_ThrowsArgumentNullException() - { - // Arrange - var checker = CreateChecker("1.0.0.0"); - - // Act - var act = () => checker.Check(null!); - - // Assert - act.Should().Throw() - .WithParameterName("expectedVersion"); - } - - [Fact] - public void Check_NullExpectedVersion_ThrowsArgumentNullException() - { - // Arrange - var checker = CreateChecker("1.2.0"); - - // Act - var act = () => checker.Check(null!); - - // Assert - act.Should().Throw() - .WithParameterName("expectedVersion"); - } - - [Fact] - public void Ctor_NullEngineVersionProvider_ThrowsArgumentNullException() - { - // Act - var act = () => new EngineVersionChecker(null!); - - // Assert - act.Should().Throw() - .WithParameterName("engineVersionProvider"); - } - - private static EngineVersionChecker CreateChecker(string engineVersion) - { - var engineVersionProvider = A.Fake(); - A.CallTo(() => engineVersionProvider.Version).Returns(engineVersion); - - return new EngineVersionChecker(engineVersionProvider); - } -} diff --git a/tests/CreativeCoders.ShadeKit.Core.Tests/Versions/Exceptions/ContractExceptionsTests.cs b/tests/CreativeCoders.ShadeKit.Core.Tests/Versions/Exceptions/ContractExceptionsTests.cs new file mode 100644 index 0000000..d2dd744 --- /dev/null +++ b/tests/CreativeCoders.ShadeKit.Core.Tests/Versions/Exceptions/ContractExceptionsTests.cs @@ -0,0 +1,49 @@ +using AwesomeAssertions; +using CreativeCoders.ShadeKit.Core.Versions.Exceptions; + +namespace CreativeCoders.ShadeKit.Core.Tests.Versions.Exceptions; + +public class ContractExceptionsTests +{ + [Fact] + public void EngineContractOutdatedException_Contracts_ExposesThemAndNamesThemInMessage() + { + // Act + var exception = new EngineContractOutdatedException(5, 2, 4); + + // Assert + exception.RequestedContract + .Should().Be(5); + + exception.MinSupportedContract + .Should().Be(2); + + exception.CurrentContract + .Should().Be(4); + + exception.Message + .Should().Be("The kit skills need the CLI contract 5, but this engine supports only the CLI contracts 2 " + + "to 4."); + } + + [Fact] + public void SkillsContractOutdatedException_Contracts_ExposesThemAndNamesThemInMessage() + { + // Act + var exception = new SkillsContractOutdatedException(1, 2, 4); + + // Assert + exception.RequestedContract + .Should().Be(1); + + exception.MinSupportedContract + .Should().Be(2); + + exception.CurrentContract + .Should().Be(4); + + exception.Message + .Should().Be("The kit skills are written for the CLI contract 1, but this engine supports only the CLI " + + "contracts 2 to 4."); + } +} diff --git a/tests/CreativeCoders.ShadeKit.Core.Tests/Versions/Exceptions/VersionExceptionsTests.cs b/tests/CreativeCoders.ShadeKit.Core.Tests/Versions/Exceptions/VersionExceptionsTests.cs deleted file mode 100644 index b19c925..0000000 --- a/tests/CreativeCoders.ShadeKit.Core.Tests/Versions/Exceptions/VersionExceptionsTests.cs +++ /dev/null @@ -1,44 +0,0 @@ -using AwesomeAssertions; -using CreativeCoders.ShadeKit.Core.Versions; -using CreativeCoders.ShadeKit.Core.Versions.Exceptions; - -namespace CreativeCoders.ShadeKit.Core.Tests.Versions.Exceptions; - -public class VersionExceptionsTests -{ - [Fact] - public void EngineVersionMismatchException_Versions_ExposesThemAndNamesThemInMessage() - { - // Act - var exception = new EngineVersionMismatchException("1.2.0", "1.3.0-beta.1", - EngineVersionMismatchDirection.EngineOlder); - - // Assert - exception.EngineVersion - .Should().Be("1.2.0"); - - exception.ExpectedVersion - .Should().Be("1.3.0-beta.1"); - - exception.Direction - .Should().Be(EngineVersionMismatchDirection.EngineOlder); - - exception.Message - .Should().Be("The engine version '1.2.0' does not match the expected version '1.3.0-beta.1': the major " + - "and minor versions differ."); - } - - [Fact] - public void InvalidSemanticVersionException_Value_ExposesValueAndNamesItInMessage() - { - // Act - var exception = new InvalidSemanticVersionException("v1.2"); - - // Assert - exception.Value - .Should().Be("v1.2"); - - exception.Message - .Should().Be("'v1.2' is not a valid SemVer 2.0.0 version."); - } -} diff --git a/tests/skill-scenarios/README.md b/tests/skill-scenarios/README.md index 4405c82..2bdd25e 100644 --- a/tests/skill-scenarios/README.md +++ b/tests/skill-scenarios/README.md @@ -12,20 +12,20 @@ for `SingleSkillSourceTests`, files named `SKILL.md`, of which there are none he | Path | Purpose | |---|---| | `RUNNER-PROTOCOL.md` | The rules every runner follows: which files it may read, how it records commands, questions, and answers, and the sections of its output. | -| `SCENARIOS.md` | The scenario catalog with the shared fixture table. Placeholders: `` (the work folder), `` (this repository), ``, ``, ``. | -| `generate_fixtures.py` | Builds the work folder from the current engine: fixtures, fixture repositories, `ids.json`, and resolved copies of the catalog and the protocol. | +| `SCENARIOS.md` | The scenario catalog with the shared fixture table. Placeholders: `` (the work folder), `` (this repository), `` (the CLI contract), ``, ``. | +| `generate_fixtures.py` | Builds the work folder from the current engine: fixtures, fixture repositories, `ids.json`, and resolved copies of the catalog and the protocol. It reads the CLI contract from the version handshake sentence of `skills/shade-kit-phase-entry/SKILL.md`. | | `checks/check_runs.py` | The expectations and the checker. Runners must never see it. | The work folder (outside this repository) holds after the generator: | Path | Content | |---|---| -| `fixtures/*.json` | The JSON envelopes of the real engine calls; the fixture table of the catalog names the ones the runners use. | -| `ids.json` | `sso` and `quick` (the generated feature ids), `kitVersion`, `notesFile` (the notes of S13), and `csv` (the feature that S17 creates). | +| `fixtures/*.json` | The JSON envelopes of the real engine calls; the fixture table of the catalog names the ones the runners use. `env-version-engine-outdated.json` and `env-version-skills-outdated.json` are the refused handshakes (`--expect-contract 999` and `0`). They come from these stand-in calls, so their `error.message` names the contract 999 or 0, not the contract the skill passes. | +| `ids.json` | `sso` and `quick` (the generated feature ids), `contract` (the CLI contract, a number), `notesFile` (the notes of S13), and `csv` (the feature that S17 creates). | | `repo/` | The fixture repository: `init`, a `feature` profile feature in `refine`, and a `quick` profile feature whose `finish` was requested, with five team items in its Definition of Done copy. | | `repo-s5/`, `repo-s6/` | Copies of `repo/` that the gate-check runs edit. | | `repo-s9/` | A copy of `repo/` whose quick `request.md` asks for a change that is too large for `quick`. | -| `repo-empty/` | An initialised repository without features (no current feature). | +| `repo-empty/` | An initialised repository without features (no current feature). S18 reads it, and S19 reads `repo/`, without a copy: neither gets past the handshake. | | `repo-s10/`, `repo-s14/` | Copies of `repo-empty/`; the `discuss` run of S10 writes its notes into `repo-s10/`. | | `repo-s13/` | A copy of `repo-empty/` with discussion notes in `.shadekit/discussions/` (`notesFile` in `ids.json`). | | `repo-s11/`, `repo-s15/`, `repo-s16/` | Copies of `repo/` with the sso feature selected as current; S11 writes its notes into `repo-s11/`. | @@ -105,3 +105,9 @@ Write your output to /out/.md. Do not read any other file in /ou review round 2: S17 checks read the closing message, `feature new` must carry its own `--json`, step 0 of a runner is left out of the git check, `--only` refuses unknown ids; iteration 3 re-checked 84 of 84, S17 iteration 4 18 of 18. +- **2026-11-22:** two scenarios S18–S19 for the CLI contract handshake: `shade-kit-new` with an engine older than + the skills (S18, `engine-outdated`, Claude Code) and `shade-kit-next-phase` with skills older than the engine + (S19, `skills-outdated`, OpenAI Codex CLI default mode). 22 of 22 checks. After review round 1: the engine-update + check of both (`ENGINE_UPDATE`) also counts an update named through the tool ("get a newer shade-kit") and no + longer counts "install the kit plugin that matches the engine" (checker gap D-23 of 06-1, closed); re-checked on + the same outputs 22 of 22. diff --git a/tests/skill-scenarios/SCENARIOS.md b/tests/skill-scenarios/SCENARIOS.md index 3524b14..c31f0fa 100644 --- a/tests/skill-scenarios/SCENARIOS.md +++ b/tests/skill-scenarios/SCENARIOS.md @@ -6,7 +6,7 @@ Fixture table shared by the scenarios S1–S9 (command → file): | Command | Fixture | |---|---| -| `shade-kit version --json --expect ` | `env-version.json` | +| `shade-kit version --json --expect-contract ` | `env-version.json` | | `shade-kit phase start refine --json` | `env-start-refine-already.json` | | `shade-kit phase start quick --json` | `env-start-quick.json` | | `shade-kit phase next --json` | scenarios S1–S4: `env-next-refine.json`; scenario S9: `env-next-quick.json` | @@ -85,7 +85,7 @@ write them: yes. To any other question: "yes". | Command | Fixture | |---|---| - | `shade-kit version --json --expect ` | `env-version.json` | + | `shade-kit version --json --expect-contract ` | `env-version.json` | | `shade-kit feature current --json` | `env-current-none.json` | | `shade-kit phase next --json` | `env-next-none.json` | @@ -97,7 +97,7 @@ write them: yes. To any other question: "yes". | Command | Fixture | |---|---| - | `shade-kit version --json --expect ` | `env-version.json` | + | `shade-kit version --json --expect-contract ` | `env-version.json` | | `shade-kit feature current --json` | `env-current-sso.json` | | `shade-kit phase next --json` | `env-next-refine.json` | @@ -109,7 +109,7 @@ write them: yes. To any other question: "yes". | Command | Fixture | |---|---| - | `shade-kit version --json --expect ` | `env-version.json` | + | `shade-kit version --json --expect-contract ` | `env-version.json` | | `shade-kit feature current --json` | `env-current-done.json` | | `shade-kit phase next --json` | `env-next-done.json` | @@ -122,7 +122,7 @@ write them: yes. To any other question: "yes". | Command | Fixture | |---|---| - | `shade-kit version --json --expect ` | `env-version.json` | + | `shade-kit version --json --expect-contract ` | `env-version.json` | | `shade-kit feature current --json` | `env-current-none.json` | | any `shade-kit feature new … --json` | `env-new-notes.json` | | `shade-kit phase next --json` | `env-next-new-notes.json` | @@ -136,7 +136,7 @@ write them: yes. To any other question: "yes". | Command | Fixture | |---|---| - | `shade-kit version --json --expect ` | `env-version.json` | + | `shade-kit version --json --expect-contract ` | `env-version.json` | | `shade-kit feature current --json` | `env-current-none.json` | | any `shade-kit feature new … --json` | `env-new-issue.json` | | `shade-kit phase next --json` | `env-next-none.json` | @@ -150,7 +150,7 @@ write them: yes. To any other question: "yes". | Command | Fixture | |---|---| - | `shade-kit version --json --expect ` | `env-version.json` | + | `shade-kit version --json --expect-contract ` | `env-version.json` | | `shade-kit feature current --json` | `env-current-sso.json` | | `shade-kit phase next --json` | `env-next-refine.json` | @@ -169,7 +169,7 @@ write them: yes. To any other question: "yes". | Command | Fixture | |---|---| - | `shade-kit version --json --expect ` | `env-version.json` | + | `shade-kit version --json --expect-contract ` | `env-version.json` | | `shade-kit feature current --json` | `env-current-sso.json` | | any `shade-kit feature new … --json` | `env-new-bugfix.json` | | `shade-kit phase next --json` | `env-next-new-bugfix.json` | @@ -183,8 +183,33 @@ write them: yes. To any other question: "yes". | Command | Fixture | |---|---| - | `shade-kit version --json --expect ` | `env-version.json` | + | `shade-kit version --json --expect-contract ` | `env-version.json` | | `shade-kit feature current --json` | `env-current-sso-branch.json` | | any `shade-kit feature new … --json` | `env-new-csv.json` | | `shade-kit feature show --json` | `env-show-csv.json` | | `shade-kit phase next --json` | `env-next-refine-branch.json` | + +## Version handshake refusals (S18–S19) + +These scenarios replace the shared fixture table with their own table. Commands that are not in a scenario's table have +no fixture (rule 3 of the protocol). + +## S18 — new in Claude Code, the engine is older than the skills +- Agent: Claude Code; `AskUserQuestion` is available. +- Skill: `shade-kit-new`; the human typed `/shade-kit-new` and then: "Login with SSO". +- Repository: `/repo-empty` (read only). +- Fixtures: + + | Command | Fixture | + |---|---| + | `shade-kit version --json --expect-contract ` | `env-version-engine-outdated.json` | + +## S19 — next-phase in OpenAI Codex CLI, the skills are older than the engine +- Agent: OpenAI Codex CLI, default mode (not plan mode); `request_user_input` is not available. +- Skill: `shade-kit-next-phase`; the human typed `$shade-kit:shade-kit-next-phase`. +- Repository: `/repo` (read only). +- Fixtures: + + | Command | Fixture | + |---|---| + | `shade-kit version --json --expect-contract ` | `env-version-skills-outdated.json` | diff --git a/tests/skill-scenarios/checks/check_runs.py b/tests/skill-scenarios/checks/check_runs.py index e1e17b6..f474557 100644 --- a/tests/skill-scenarios/checks/check_runs.py +++ b/tests/skill-scenarios/checks/check_runs.py @@ -10,9 +10,10 @@ folder of the outputs, relative to (default: out). Exit code 0 when every check passes, 1 when one fails, 2 on a usage error. -The expectations were written for the skill clarifications of 2026-11-18 (S1-S9 in SCENARIOS.md) and for the discuss -and new skills of package 09 on 2026-11-20 (S10-S17); when a skill text changes what a scenario does, change the -expectation here together with the skill. +The expectations were written for the skill clarifications of 2026-11-18 (S1-S9 in SCENARIOS.md), for the discuss +and new skills of package 09 on 2026-11-20 (S10-S17), and for the refused version handshakes of the CLI contract +(S18: the engine is older than the skills, S19: the skills are older than the engine); when a skill text changes what +a scenario does, change the expectation here together with the skill. --only takes any of S1-S19. """ import json import re @@ -28,6 +29,50 @@ # `-C `, `-c =`, or `--no-pager` before the subcommand. Prose such as "runs no git command" is no hit. GIT_ANY = re.compile(r"(?:`|^[ \t]*(?:\$[ \t]+)?)(?:\S*/)?git(?:\.exe)?[ \t]+" r"(?:-{1,2}[\w.-]+(?:[ =][^\s`]+)?[ \t]+)*[a-z][\w-]*", re.M) +# A closing message that tells to update the engine, as opposed to the kit skills (the skills remedy). A clause ends at +# ".", ":", ";", or a line break. A skills word names the skills, a plugin, the integration(s), the marketplace, or the +# kit on its own; "SHADE kit"/"shade-kit" and "kit engine" are no skills word, so "upgrade the kit engine" counts as an +# engine update (real skills remedies say "kit skills", "kit plugin", "the kit with ...", never "kit engine"). The tool +# is shade-kit or SHADE kit, unless a word character or an apostrophe directly follows, a call form (":" before a skill +# name, e.g. "$shade-kit:shade-kit-next-phase"), or a skills word follows ("/shade-kit-new", "the shade-kit plugin"). +# It counts when the options have: +# - an update verb (update, upgrade, (re)install, get, download, replace, also -s/-ing) followed within 40 characters +# of the same clause, without a skills word between, by "engine" (not "engine's") or the tool ("Updating the engine", +# "install the latest shade-kit", "update the CLI (shade-kit)"; not "install the kit skills that match the engine", +# "reinstall the SHADE kit integration for the engine", "Install the engine's matching skills"); +# - "engine update"/"engine upgrade", or "engine is too old"/"outdated"/"out of date"; +# - "newer engine" or "newer " in a clause with no skills word before it and none in the 40 characters after it +# ("You need a newer engine"; not "Install the skills that match the newer engine"); +# - `dotnet tool update`/`install`. +# Every window is bounded or ends at a clause end, so a search stays linear in the length of the options. +# Known limit: a regex over free wording. A negation ("you do not need to update the engine", "no engine update is +# needed") still counts as an engine update, and an engine update without one of the verbs above ("bring the engine +# up to date") is missed. The skill texts are reviewed by hand (tests/skill-scenarios/README.md); a FAIL of the two +# checks that use this pattern (S18, S19) is read against the closing message before it counts. +_UPDATE_VERB = (r"(?:updat(?:es?|ing)|upgrad(?:es?|ing)|(?:re)?install(?:s|ing)?|get(?:s|ting)?|download(?:s|ing)?|" + r"replac(?:es?|ing))") +_SKILLS_WORD = r"(?:skill|plugin|integrations?\b|marketplace|(? 1 else "" + return rest.replace(reason, "") if reason else rest + + +def question_markers(steps, marker): + """Return the recorded questions of one kind (protocol rule 4: 'TOOL CALL ' or 'MESSAGE TO HUMAN'). + + A marker counts at the start of a line (after a list marker or emphasis) or when its line is directly followed by + a fenced block; a mention in prose such as "(no `TOOL CALL`, no `MESSAGE TO HUMAN`)" is no hit. + """ + m = re.escape(marker) + pattern = rf"^[ \t]*(?:\d+\.[ \t]+|[-*][ \t]+)?[*_`]*{m}\b|{m}\b[^\n]*\n(?:[ \t]*\n)*[ \t]*```" + return re.findall(pattern, steps, re.M) + + +def run_commands(steps): + """Return every shade-kit command the steps record as run, in order, whatever its subcommand. + + A command counts at the start of a line or in a code span with an option; a span whose sentence says that this + command was not run is left out. Quoted envelopes do not count (their lines start with a quote or a brace, and + they quote commands in plain quotes). + """ + found = [(m.start(1), m.group(1).strip()) for m in SHADE_KIT_LINE.finditer(steps)] + for m in SHADE_KIT_SPAN.finditer(steps): + command = m.group(1).strip() + if " -" not in command: + continue + line_start = steps.rfind("\n", 0, m.start()) + 1 + line_end = steps.find("\n", m.end()) + before = steps[line_start:m.start()] + after = steps[m.end():line_end if line_end != -1 else len(steps)] + ends = list(SENTENCE_END.finditer(before)) + before = before[ends[-1].end():] if ends else before + end = SENTENCE_END.search(after) + after = after[:end.start()] if end else after + if NOT_RUN_BEFORE.search(before) or NOT_RUN_AFTER.search(after): + continue + found.append((m.start(1), command)) + return [command for _, command in sorted(found)] + + def tool_blocks(text, tool): """Return the JSON-ish blocks that follow a 'TOOL CALL ' marker.""" blocks = [] @@ -103,7 +208,7 @@ def __init__(self, work, out, ids): self.out = out self.sso = ids["sso"] self.quick = ids["quick"] - self.kit_version = ids["kitVersion"] + self.contract = ids["contract"] self.notes_file = ids.get("notesFile", "") self.csv = ids.get("csv", "") self.issue_url = "https://github.com/acme/shop/issues/142" @@ -112,15 +217,15 @@ def __init__(self, work, out, ids): def check(self, sid, name, ok): self.results.append((sid, name, bool(ok))) - def codex_forms(self, sid, text, skills): - c = closing(text) + def codex_forms(self, sid, text, skills, message=None): + c = closing(text) if message is None else message for s in skills: self.check(sid, f"closing names $shade-kit:{s}", f"$shade-kit:{s}" in c) self.check(sid, "closing has no slash form /shade-kit-", re.search(r"(?] [--engine-dll ] -The script builds the CLI (unless --engine-dll is given), creates a git repository in the work folder, and drives the -real engine through the workflow that the scenarios need. It writes into the work folder: +The script reads the CLI contract from the version handshake sentence of skills/shade-kit-phase-entry/SKILL.md, +builds the CLI (unless --engine-dll is given), creates a git repository in the work folder, and drives the real engine +through the workflow that the scenarios need. It writes into the work folder: -- fixtures/*.json the JSON envelopes of the engine calls that the scenario catalog names -- ids.json the generated feature ids and the kit version (read by checks/check_runs.py) +- fixtures/*.json the JSON envelopes of the engine calls that the scenario catalog names, among them the two + refused version handshakes (env-version-engine-outdated.json, env-version-skills-outdated.json) +- ids.json the generated feature ids and the CLI contract (read by checks/check_runs.py) - repo/ the fixture repository; repo-s5/, repo-s6/, repo-s9/, repo-s11/, repo-s12/, repo-s15/, and repo-s16/ are copies of it - repo-empty/ an initialised repository without features; repo-s10/, repo-s13/, and repo-s14/ are copies of it - repo-s17/ a copy of repo/ on the branch feature/, so the branch selects the sso feature + (S18 and S19 read repo-empty/ and repo/ without a copy: they never get past the handshake) - out/ empty; the runners write their outputs here - SCENARIOS.md the catalog with every placeholder resolved (what the runners read) - RUNNER-PROTOCOL.md the protocol with the paths resolved @@ -35,7 +38,9 @@ REPOSITORY = SCRIPT_DIR.parent.parent CLI_PROJECT = REPOSITORY / "src" / "CreativeCoders.ShadeKit.Cli" DEFAULT_DLL = CLI_PROJECT / "bin" / "Debug" / "net10.0" / "shade-kit.dll" -VERSION_SKILL = REPOSITORY / "skills" / "shade-kit-next-steps" / "SKILL.md" +CONTRACT_SKILL = REPOSITORY / "skills" / "shade-kit-phase-entry" / "SKILL.md" +HANDSHAKE = re.compile(r"Version handshake: run `shade-kit version --json --expect-contract (\d+)`; (\d+) is the CLI " + r"contract this skill is written for\.") SSO_SOURCE = "Add SSO login with Entra ID" QUICK_SOURCE = "Fix typo" @@ -104,16 +109,15 @@ def is_inside(path, parent): return False -def read_kit_version(): - text = VERSION_SKILL.read_text(encoding="utf-8") - match = re.search(r"^---\s*$(.*?)^---\s*$", text, re.S | re.M) +def read_contract(): + text = CONTRACT_SKILL.read_text(encoding="utf-8") + match = HANDSHAKE.search(text) if not match: - fail(f"no frontmatter in {VERSION_SKILL}") - metadata = re.search(r"^metadata:[ \t]*\n((?:[ \t]+.*\n)*)", match.group(1), re.M) - version = re.search(r"^[ \t]+version:[ \t]*(\S+)[ \t]*$", metadata.group(1), re.M) if metadata else None - if not version or not re.fullmatch(r"\d+\.\d+\.\d+", version.group(1)): - fail(f"no plain x.y.z metadata.version in {VERSION_SKILL}") - return version.group(1) + fail(f"no canonical version handshake sentence (`shade-kit version --json --expect-contract `; " + f" is the CLI contract this skill is written for.) in {CONTRACT_SKILL}") + if match.group(1) != match.group(2): + fail(f"the handshake sentence in {CONTRACT_SKILL} names two contracts: {match.group(1)} and {match.group(2)}") + return int(match.group(1)) def find_executable(name): @@ -296,7 +300,17 @@ def build_cli(dotnet): return DEFAULT_DLL -def generate(work, engine, git, kit_version): +def expect_contract(contract): + def check(data): + current = (data.get("contract") or {}).get("current") + expected = data.get("expectedContract") + if (current, expected) != (contract, contract): + return f"contract.current/expectedContract is {current}/{expected}, expected {contract}/{contract}" + return None + return check + + +def generate(work, engine, git, contract): fixtures = work / "fixtures" fixtures.mkdir() repo = work / "repo" @@ -309,9 +323,14 @@ def save(name, stdout): repo.rmdir() new_repository(git, repo) - # 1. Version handshake. - stdout, _ = engine.call(repo, ["version", "--json", "--expect", kit_version]) + # 1. Version handshake, and the two refused handshakes (S18, S19): skills newer and older than the engine. + stdout, _ = engine.call(repo, ["version", "--json", "--expect-contract", str(contract)], + check=expect_contract(contract)) save("env-version.json", stdout) + save("env-version-engine-outdated.json", + engine.call_failing(repo, ["version", "--json", "--expect-contract", "999"], "engine-outdated")) + save("env-version-skills-outdated.json", + engine.call_failing(repo, ["version", "--json", "--expect-contract", "0"], "skills-outdated")) # 2. Kit initialisation. engine.call(repo, ["init", "--json"]) @@ -364,10 +383,10 @@ def save(name, stdout): intake = generate_intake(work, engine, git, repo, fixtures, sso, quick) (work / "out").mkdir() - ids = {"sso": sso, "quick": quick, "kitVersion": kit_version, "notesFile": NOTES_FILE, "csv": intake["csv"]} + ids = {"sso": sso, "quick": quick, "contract": contract, "notesFile": NOTES_FILE, "csv": intake["csv"]} (work / "ids.json").write_text(json.dumps(ids, indent=2) + "\n", encoding="utf-8") - values = {"": str(work), "": str(REPOSITORY), "": kit_version, + values = {"": str(work), "": str(REPOSITORY), "": str(contract), "": sso, "": quick, "": NOTES_FILE, "": ISSUE_URL, "": intake["csv"]} for name in ("SCENARIOS.md", "RUNNER-PROTOCOL.md"): @@ -477,7 +496,7 @@ def main(): try: dotnet = find_executable("dotnet") git = find_executable("git") - kit_version = read_kit_version() + contract = read_contract() work = prepare_work(args.work) print(f"Work folder: {work}") if args.engine_dll: @@ -486,12 +505,12 @@ def main(): fail(f"--engine-dll {dll} does not exist") else: dll = build_cli(dotnet) - ids = generate(work, Engine(dotnet, str(dll), git), git, kit_version) + ids = generate(work, Engine(dotnet, str(dll), git), git, contract) except GeneratorError as error: print(f"error: {error}", file=sys.stderr) return 1 - print(f"Kit version: {ids['kitVersion']}") + print(f"CLI contract: {ids['contract']}") print(f"Features: sso {ids['sso']}, quick {ids['quick']}") print("Fixtures: " + ", ".join(sorted(p.name for p in (work / "fixtures").iterdir()))) print(f"Scenario catalog: {work / 'SCENARIOS.md'}")