feat(quantecon): show qe-vN identifier in myst --version#42
Merged
Conversation
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>
There was a problem hiding this comment.
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.tsfromquantecon/VERSION.yml. - Updates the CLI version label to append
(<qeVersion>)when available. - Wires the new generator into
lint,test, andbuildscripts forpackages/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.
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>
4 tasks
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>
4 tasks
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
myst --versionnow printsv1.9.1 (qe-v6)instead of justv1.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.Design
quantecon/VERSION.ymlstays the single source of truth (it already recordsqe_version: qe-v6). A small build-time script reads it and writes a TS constant the CLI imports — mirroring the existingcopy:versionpattern for the upstream npm version.packages/mystmd/scripts/copy-qe-version.mjs— readsqe_versionfromquantecon/VERSION.yml, writessrc/qe-version.ts. Usesjs-yaml(already a devDep). Handles missing/unreadable VERSION.yml gracefully by writingnull.packages/mystmd/src/qe-version.ts— generated file, committed (parallel toversion.ts) so dev runs without a prebuild step still work. Type isstring | nullso 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 whenqeVersion === null.packages/mystmd/package.json—copy:qe-versionchained into the same hooks ascopy:version(build / lint / test).Test plan
node packages/mystmd/scripts/copy-qe-version.mjsgeneratesqe-version.tswith current valueqe-v6npm run buildregenerates and bakes it in:node dist/myst.cjs --version→v1.9.1 (qe-v6)v1.9.1(no parenthetical)npm run typecheckcleannpm run lint:formatcleannpm test— 54/54 mystmd package tests pass🤖 Generated with Claude Code