Skip to content

feat(quantecon): show qe-vN identifier in myst --version#42

Merged
mmcky merged 3 commits into
mainfrom
feat/cli-show-qe-version
May 22, 2026
Merged

feat(quantecon): show qe-vN identifier in myst --version#42
mmcky merged 3 commits into
mainfrom
feat/cli-show-qe-version

Conversation

@mmcky
Copy link
Copy Markdown

@mmcky mmcky commented May 22, 2026

Summary

myst --version now prints v1.9.1 (qe-v6) instead of just v1.9.1, so book-dp1 / book-dp2 maintainers can answer the "which fork build am I running?" question at a glance when debugging enumerator parity.

$ myst --version
v1.9.1 (qe-v6)

Design

quantecon/VERSION.yml stays the single source of truth (it already records qe_version: qe-v6). A small build-time script reads it and writes a TS constant the CLI imports — mirroring the existing copy:version pattern for the upstream npm version.

  • packages/mystmd/scripts/copy-qe-version.mjs — reads qe_version from quantecon/VERSION.yml, writes src/qe-version.ts. Uses js-yaml (already a devDep). Handles missing/unreadable VERSION.yml gracefully by writing null.
  • packages/mystmd/src/qe-version.ts — generated file, committed (parallel to version.ts) so dev runs without a prebuild step still work. Type is string | null so consumers can detect the upstream-only case.
  • packages/mystmd/src/index.ts — appends (qe-vN) to the version string when present; falls back to upstream-only form when qeVersion === null.
  • packages/mystmd/package.jsoncopy:qe-version chained into the same hooks as copy:version (build / lint / test).

Test plan

  • node packages/mystmd/scripts/copy-qe-version.mjs generates qe-version.ts with current value qe-v6
  • npm run build regenerates and bakes it in: node dist/myst.cjs --versionv1.9.1 (qe-v6)
  • Fallback: temporarily removed VERSION.yml, re-ran script + esbuild → output is v1.9.1 (no parenthetical)
  • npm run typecheck clean
  • npm run lint:format clean
  • npm test — 54/54 mystmd package tests pass

🤖 Generated with Claude Code

Adds the fork's `qe_version` (read from `quantecon/VERSION.yml` at
build time) to the CLI's version output: `v1.9.1 (qe-v6)` instead of
just `v1.9.1`. Answers the "which fork build am I running?" question
that book-dp1 / book-dp2 maintainers hit when debugging enumerator
parity issues.

Mechanics mirror the existing `copy:version` pattern: a small
`scripts/copy-qe-version.mjs` reads `quantecon/VERSION.yml`, writes
`src/qe-version.ts`, and is chained into build/lint/test. VERSION.yml
stays the single source of truth — the generated file is regenerated
on every build, but committed so dev runs without a prebuild step
still work.

Falls back to upstream-only form (`v1.9.1`) when VERSION.yml is
missing — keeps the script a no-op on a hypothetical upstream-only
checkout.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 22, 2026 06:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds QuantEcon fork build identification (qe-vN) to the myst --version output by baking the value from quantecon/VERSION.yml into the CLI at build/lint/test time.

Changes:

  • Introduces a build-time script to generate packages/mystmd/src/qe-version.ts from quantecon/VERSION.yml.
  • Updates the CLI version label to append (<qeVersion>) when available.
  • Wires the new generator into lint, test, and build scripts for packages/mystmd.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/mystmd/src/qe-version.ts Adds generated qeVersion constant for consumption by the CLI.
packages/mystmd/src/index.ts Appends the QuantEcon build identifier to myst --version output when present.
packages/mystmd/scripts/copy-qe-version.mjs New script to read qe_version from quantecon/VERSION.yml and generate src/qe-version.ts.
packages/mystmd/package.json Hooks copy:qe-version into lint/test/build workflows.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/mystmd/scripts/copy-qe-version.mjs Outdated
mmcky and others added 2 commits May 22, 2026 17:09
Per Copilot review on PR #42: the ad-hoc single-quote .replace() only
handles one escape case. `JSON.stringify` is the canonical safe
primitive for converting a JS value to its TS source-text literal —
handles strings and null in one call, escapes everything correctly,
and collapses the ternary into one line.

No behavior change for `qe-vN` values (which is all VERSION.yml will
ever contain), but the script is now robust if the schema ever
admits more exotic strings. Regenerated qe-version.ts now uses
double-quoted literal (also valid TS); CLI output unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…gify

CI lint:format failed: JSON.stringify emits double-quoted strings, but
the project prettier config is `singleQuote: true`, so the regenerated
qe-version.ts no longer conformed.

Reconcile by pushing the safety concern (Copilot review on PR #42) to
the *input* layer: validate `qe_version` matches `/^qe-v\d+$/` on read
and reject anything else as `null`. Generated literal becomes
trivially safe to embed as a single-quoted string with no escape
handling — matches the codebase's existing trust model for
`copy:version` (which interpolates `npm_package_version` unescaped on
the same assumption that the input schema is well-formed) and gets
prettier conformance for free.

Strictly safer than the original `.replace(/'/g, "\\'")` because no
hostile/exotic value can pass the regex in the first place.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mmcky mmcky merged commit 95494e4 into main May 22, 2026
5 checks passed
@mmcky mmcky deleted the feat/cli-show-qe-version branch May 22, 2026 07:23
mmcky added a commit that referenced this pull request May 22, 2026
Records PR #42 (`myst --version` now prints `v1.9.1 (qe-v6)`) as id 7
with squash SHA 95494e4 and `tag: null`. Fork-only tooling — no
UPSTREAM-PRS.yml entry, no upstream story (the qe-version field has
no meaning on a non-fork build). Holding `qe_version: qe-v6` for now;
will cut qe-v7 standalone or batched with the next feature.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
mmcky added a commit that referenced this pull request May 22, 2026
Bumps `qe_version: qe-v6` → `qe-v7` and sets `tag: qe-v7` on the
previously-untagged id 7 entry. Also regenerates the committed
`packages/mystmd/src/qe-version.ts` so anyone who `cat`s either file
at the qe-v7 tag sees self-consistent state (qe_version matches the
tag and the CLI prints `v1.9.1 (qe-v7)` without rebuilding).

qe-v7 is a one-feature checkpoint — covers just PR #42 (fork-only
build tooling). Per VERSION.yml's preamble, the tag will be cut on
the squash-merged commit of this PR after it lands.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants