Skip to content

The design language that makes your AI harness better at design.

JavaScript

Fix: --version prints the installed skill's version (#1028) (#1032)

Abdul Wahab5a8382e40964
diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs
index ee21c7117..76879d897 100644
--- a/crates/cli/src/main.rs
+++ b/crates/cli/src/main.rs
@@ -37,7 +37,12 @@ fn run(args: &[String], io: &mut Io) -> i32 {
0
}
"--version" | "-v" => {
- io.out(&format!("{CLI_VERSION}\n"));
+ // The installed skill's version, the number `npx impeccable update` moves;
+ // the npm shim answers --version itself, so this reaches direct runs only.
+ let cwd = io.cwd.to_string_lossy().into_owned();
+ let version = impeccable_context::context_cli::installed_skill_version(&io.env, &cwd)
+ .unwrap_or_else(|| format!("{VERSION}+engine"));
+ io.out(&format!("{version}\n"));
0
}
// Launcher handshake: a cheap discriminator so the launchers can tell
@@ -115,10 +120,6 @@ fn run(args: &[String], io: &mut Io) -> i32 {
}
}
-/// The npm `impeccable` package version `cli.js --version` prints (its
-/// `package.json`), tracked separately from the crate version.
-pub const CLI_VERSION: &str = "4.0.0";
-
/// The engines wired into `impeccable detect`: the static HTML engine
/// (crates/html). The browser engine (crates/browser) plugs in here once it
/// lands; until then URL scans report the puppeteer message.
diff --git a/crates/context/src/context_cli.rs b/crates/context/src/context_cli.rs
index 7a0e835e7..543b2e6c4 100644
--- a/crates/context/src/context_cli.rs
+++ b/crates/context/src/context_cli.rs
@@ -478,6 +478,12 @@ pub(crate) fn read_local_skill_version(provider: &Provider) -> Option<String> {
parse_skill_frontmatter_version(&content)
}
+/// The installed skill's SKILL.md frontmatter version, resolving the skill
+/// dir the way every verb does (`IMPECCABLE_SKILL_DIR`, else the binary's path).
+pub fn installed_skill_version(env: &Env, cwd: &str) -> Option<String> {
+ read_local_skill_version(&crate::provider::detect(env, cwd))
+}
+
fn update_cache_path(env: &Env) -> String {
match env.get("IMPECCABLE_UPDATE_CACHE").filter(|v| !v.is_empty()) {
Some(p) => p.clone(),
diff --git a/crates/context/src/telemetry.rs b/crates/context/src/telemetry.rs
index 9aeb4a2f1..072901313 100644
--- a/crates/context/src/telemetry.rs
+++ b/crates/context/src/telemetry.rs
@@ -136,7 +136,7 @@ fn version_token(v: &str) -> bool {
/// The channel is `IMPECCABLE_TELEMETRY_CHANNEL` when it is 1 to 16 lowercase
/// letters (`test` in this repo's tests and CI), else absent.
pub fn client_header(env: &Env, cwd: &str) -> String {
- let skill = crate::context_cli::read_local_skill_version(&crate::provider::detect(env, cwd)).filter(|v| version_token(v));
+ let skill = crate::context_cli::installed_skill_version(env, cwd).filter(|v| version_token(v));
let version = skill.unwrap_or_else(|| format!("{}+engine", env!("CARGO_PKG_VERSION")));
let channel = env
.get("IMPECCABLE_TELEMETRY_CHANNEL")
diff --git a/docs/CLI-CONTRACT.md b/docs/CLI-CONTRACT.md
index 885d73609..ebc6ec559 100644
--- a/docs/CLI-CONTRACT.md
+++ b/docs/CLI-CONTRACT.md
@@ -60,7 +60,7 @@ Notation: `stdout>` / `stderr>` are literal writes; `exit N`; template strings u
Compatibility:
impeccable skills <command> Legacy namespace; still supported.
```
- 2. `--version` / `-v` → `console.log(pkg.version)` read from `<cli/bin>/../../package.json`; `exit 0`.
+ 2. `--version` / `-v` → `console.log(pkg.version)` read from `<cli/bin>/../../package.json`; `exit 0`. The binary run directly (the skill launcher's path) prints the installed skill's `SKILL.md` frontmatter version instead (skill dir from `IMPECCABLE_SKILL_DIR`, else the binary's path), else `<engine version>+engine`.
3. `detect` → `process.argv = [argv0, argv1, ...args.slice(1)]`; dynamic-import `../engine/detect-antipatterns.mjs`, `await detectCli()`.
4. `ignores` or `ignore` → `./commands/ignores.mjs` `run(args.slice(1))`.
5. `skills` → `./commands/skills.mjs` `run(args.slice(1))` (legacy namespace).
diff --git a/tests/oracle/DELTAS.md b/tests/oracle/DELTAS.md
index 1dd07f3ef..ab2cc8f46 100644
--- a/tests/oracle/DELTAS.md
+++ b/tests/oracle/DELTAS.md
@@ -163,7 +163,7 @@ The npm shim answers `--version` / `-v` itself from its own `package.json`
installed. The binary's `CLI_VERSION` moves from `3.6.0` to `4.0.0` with the
CLI 4.0.0 release; it is what the binary prints when run directly.
-- `cli-version`.
+- Accepted until 2026-10-15 (#1028): `cli-version`.
## Recorded 2026-09-12: the URL scan reads the page after the reveal sweep
@@ -7064,3 +7064,7 @@ Re-recorded from the binary and reviewed by hand. The organic-clip-path fixture'
The directory sweeps (`detect-dir-json-all-fixtures`, `detect-dir-text-all-fixtures`, `detect-dir-quiet-all-fixtures`) and the no-advisory sweeps (`detect-no-advisory-json`, `detect-no-advisory-text`) carry exactly those five findings, the two organic-clip-path findings and the three on `gradient-text-one-colour.html` in path order, and the failure count moves from 945 to 950; the advisory count and exit codes did not move. They were recorded again after the merge with main (#1004, #1005, #1006 and the rest), and the diff of each against main's golden is those five findings and the count, nothing else.
Review round, same day. Three review fixes move no golden: the CLI tells the browser engine which rules it removes after the scan (`ignoreRules`, and every rule outside a requested `--scope`; `low-contrast` declares no scope), so a `low-contrast` finding the report will drop does not take an element's size findings with it; gray-on-color's class form stops counting `bg-<hue>-50` and `bg-<hue>-100` as the coloured fill, where the computed form already reads them as off-white; and the stylesheet gradient-text form does not stand down on a neighbour's one-colour gradient when the declaration's own ramp opened before its 200-character window.
+
+## Recorded 2026-10-15: --version prints the installed skill's version (#1028)
+
+The binary printed a hard-coded npm package version that stayed `4.0.0` after 4.5.2 shipped, so the skill launcher's `--version` read as a failed update. `--version` / `-v` now prints the installed skill's `SKILL.md` frontmatter version (skill dir from `IMPECCABLE_SKILL_DIR`, else the binary's path), else `<engine>+engine`, the same fallback token the telemetry client header uses. The npm shim still answers from its own `package.json`. The `cli-version` case stages a fixture `SKILL.md` at 9.9.9, so its golden is `9.9.9` and does not move with a skill or engine release. Re-recorded from the binary and reviewed by hand. The 2026-09-04 history line no longer starts with the case id, so the case is checked.
diff --git a/tests/oracle/cases/detect.mjs b/tests/oracle/cases/detect.mjs
index 0ece34b36..e5b752df2 100644
--- a/tests/oracle/cases/detect.mjs
+++ b/tests/oracle/cases/detect.mjs
@@ -163,7 +163,12 @@ function Thumb({ url }: { url?: string }) {
{ id: 'detect-unknown-flag', verb: 'detect', args: ['--bogus', `<REPO>/tests/fixtures/antipatterns/blinking-cursor.html`], isolateHome: false },
{ id: 'detect-bad-viewport', verb: 'detect', args: ['--viewport', 'wide', `<REPO>/tests/fixtures/antipatterns/blinking-cursor.html`], isolateHome: false },
{ id: 'cli-help', verb: 'cli-help', args: [] },
- { id: 'cli-version', verb: 'cli-version', args: [] },
+ {
+ id: 'cli-version', verb: 'cli-version', args: [],
+ // A fixture skill dir keeps the golden off every release cadence.
+ setup: (ws) => fs.writeFileSync(path.join(ws, 'SKILL.md'), '---\nname: impeccable\nversion: 9.9.9\n---\n'),
+ env: { IMPECCABLE_SKILL_DIR: '<WS>' },
+ },
// Project config, DESIGN.md, inline ignores (detect-config workspace)
{ id: 'detect-config-page-json', verb: 'detect', workspace: 'detect-config', args: ['--json', 'src/page.html'] },
diff --git a/tests/oracle/golden/cli-version.json b/tests/oracle/golden/cli-version.json
index 7c958a359..6b06ba0a5 100644
--- a/tests/oracle/golden/cli-version.json
+++ b/tests/oracle/golden/cli-version.json
@@ -1,5 +1,5 @@
{
- "stdout": "4.0.0\n",
+ "stdout": "9.9.9\n",
"stderr": "",
"exit": 0,
"signal": null,