Repository navigation
Install lines name the newest runtime; analytics on an old or mismatched runtime fail loudly - #96
Merged
Merged
Conversation
…ched chunk npm's `latest` is still 0.2.2, so a bare `npm install @genclass/runtime` or `npx @genclass/runtime init` gives an app the line without the token, dashboard, analytics, visual checks or agent link, and 0.2.x ignores `analytics: true` without a word. - CLI: init/login/connect print their version and the dist-tag they came from, ask npm's dist-tags once (3 s, never with --dry-run, --no-network, --no-token, --no-telemetry or offline) and say when a newer release exists; an older @genclass/runtime in the project is upgraded instead of kept; every printed command names @beta while the version is a prerelease. - Runtime: the analytics stub warns once when its chunk does not load and passes its version to the chunk, which warns once on a mismatch (+48 B gzip /auto for this, +67 B with the @beta console hints). - Dashboard: Visitors empty state and Connect panel name 0.3.0-beta.1 and the install line (and the app's older runtimes); SNIPPET_RUNTIME and RUNTIME_ON_NPM 0.3.0-beta.1. - genclass_setup, Nuxt/Astro peer ranges (>=0.3.0-beta.1), templates (^0.3.0-beta.1), READMEs, docs and pinned script tags put the newest line first; AGENTS.md convention keeps it so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ad under the CI limit) CI measured /auto at 108.6025 KB against the 108.6 KB limit. The warning now reads "[GenClass] analytics <version> did not load; nothing is recorded." once per failed load, without a flag: first-load growth +52 B gzip on /auto (was +67 B), +47 B on the main entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # packages/mcp/CHANGELOG.md # packages/runtime/CHANGELOG.md
# Conflicts: # packages/runtime/CHANGELOG.md # packages/runtime/README.md # packages/runtime/bin/lib/init.mjs
… not the first load After PR 98 (+34 B) the branch's +52 B put /auto over bundle.test.ts's owner-approved 108.6 KB limit in CI. The ESM entries cannot mix releases (the bundler ships the chunk with its runtime), so the version pass and the load-failure warning move to src/cdn/analytics-loader.ts, used by the script tag only; src/analytics/start.ts is main's again. First-load growth over main: +16 B /auto, +13 B main entry (the @beta console hints). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # packages/runtime/CHANGELOG.md # packages/runtime/src/analytics/index.ts # packages/runtime/test/analytics.test.ts # telemetry-worker/src/pages.ts # telemetry-worker/test/pages.test.ts
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.
The owner asked that coding agents and users always end up on the newest runtime: "The most recent, most advanced version should ALWAYS be used." Today npm's
latestis0.2.2, so a barenpm install @genclass/runtimeornpx @genclass/runtime initinstalls the line with no token, dashboard, analytics, visual checks or agent link. This PR makes every path a user or agent copies name the newest line. It also makesanalytics: truefail loudly wherever code from the newest line can see the problem.The one command that ends this for good (not run)
Once 0.3.0 is stable, push the tag
v0.3.0(withpackages/runtime/package.jsonat0.3.0).release.ymlpublishes a non-prerelease straight tolatest, so no hand step is needed forlatest. Then run the one hand step the release comment now lists, so the@betalines never resolve to an older prerelease:If you decide to make the current beta the default before 0.3.0 ships, the existing step in the
release.ymlcomment ("the owner moveslatest") is:After either one, drop
@betafrom the install lines in a single change (the new AGENTS.md convention). SetSNIPPET_RUNTIME/RUNTIME_PKGintelemetry-worker/src/pages.tsandRUNTIME_ON_NPMinwrangler.toml, then deploy the worker. I ran neither command, and nothing here publishes.Also for you, outside this PR: npm's
genclass-runtimealias is still at0.1.0-beta.3, and no workflow publishes it, sonpx genclass-runtime initruns that old CLI. Its README now points tonpx @genclass/runtime@beta inituntil the alias is published again.The analytics bug, reproduced on 0.2.2
I installed
@genclass/runtime@0.2.2in a temp dir and ranGenClass.init({ analytics: true })in jsdom, with and without a token. It throws nothing, prints no warning (only the telemetry notice), creates noruntime.analyticsand sends nothing. TypeScript apps get a type error for the unknown option, because 0.2.2's types have noanalytics.0.3.0-beta.0has no analytics either. Neither release can change, so the newest line says it everywhere its code runs:src/cdn/analytics-loader.ts,src/analytics/index.ts): the script tag loadsdist/analytics/index.jsby URL, so a self-hosteddist/can lack it or mix releases (the ESM entries can't: the bundler ships the chunk with its runtime). The tag's loader warns once per failed load:[GenClass] analytics: <url> (@genclass/runtime <version>) did not load; nothing is recorded. Serve every file of this version's dist/.(reason: "error", as before). It passes the tag's version to the chunk, which warns once per page when its own differs, naming both versions and the install line, and still records. The stub (src/analytics/start.ts) is unchanged from main, so the ESM first load carries none of this. Measured first-load growth over main, all from the@betaconsole hints below: +16 B gzip on/auto, +13 B on the main entry, undertest/bundle.test.ts's owner-approved limits. An earlier version of this PR put the warning in the stub and went over them after PR 98.telemetry-worker/src/pages.ts): the Visitors view is now always shown. For an app without interaction data it has an empty state: analytics need 0.3.0-beta.1 or later, the app's older runtime versions from its ownruntimebreakdown, andnpm install @genclass/runtime@betaplusGenClass.init({ token, analytics: true }). The Connect panel says the same.genclass_setup: covered below.docs/runtime/ANALYTICS.mdsection 4.1, the runtime README, API.md and theanalyticsJSDoc.The CLI on the newest line (
bin/lib/version.mjs, new)init,loginandconnectprintVersion @genclass/runtime 0.3.0-beta.1 (npm dist-tag beta).npm view @genclass/runtime dist-tags --jsononce, with a 3 s timeout. They skip it with--dry-run, the new--no-network,--no-tokenor--no-telemetry(keeping the README's "no token, no network" promise), and whennpm_config_offlineis set or npm fails. When any dist-tag points at a newer version they sayNewer ... 0.3.0-beta.2 is on npm (dist-tag beta): run npx @genclass/runtime@beta init instead. This also covers a@betatag left behind after 0.3.0 ships.initskipped the install wheneverpackage.jsonlisted the package, so an app set up by 0.2.2'sinitstayed on 0.2.2 even afternpx @genclass/runtime@beta init. The version is read fromnode_modulesfirst, then from the declared range. The upgrade appears in the diff and the question.npx @genclass/runtime@betawhile its own version is a prerelease (derived frompackage.json, so it drops@betaon its own at 0.3.0). The same goes for the console messages that name a command (invalid token, blocked model, mode and token hints). The "install it by hand" hint now includes the version.npx @genclass/runtime initresolves to today (npm'slatest, 0.2.2). That is the command above.Files whose install line or pin changed
@0.3.0-beta.1:packages/runtime/README.md(the unpinned script-tag example),telemetry-worker/README.md(was@beta),packages/runtime/test/install/INSTALL-README-SNIPPET.md, thesrc/cdn/global.tsheader.@betaon npm/npx lines:README.mdandpackages/runtime/README.md(the two-line explanation now puts the newest first, with 0.2.x as the exception; new "Which version" section)packages/runtime/TELEMETRY.md,packages/runtime/INTERCEPTION.md,PRIVACY.mddocs/runtime/API.md,docs/runtime/THREAT-MODEL.mddocs/adoption/listings/svelte.md,sveltesociety.md,vue-and-angular.mdtemplates/{angular,astro,nextjs,nuxt,react-router,react-vite,sveltekit,vue-vite}/README.mdpackages/sv/README.md,packages/nuxt/README.md,packages/astro/README.mdpackages/nuxt/src/source.tsandpackages/astro/src/index.ts(JSDoc),packages/playwright/README.mdandsrc/install.ts(error message)packages/mcp/README.md,packages/genclass-runtime/README.md,packages/runtime-model/README.mdtelemetry-worker/README.md,demos/src/site/landing.tssrc/index.ts,src/token.ts,src/model/blocked.ts,src/runtime.ts, plussrc/types.ts(JSDoc) and thesrc/cdn/sinks.tscommentnpm view: both resolve to0.3.0-beta.1):package.json:^0.2.0→^0.3.0-beta.1packages/nuxtandpackages/astropeer:>=0.2.0 || ^0.3.0-beta.0→>=0.3.0-beta.1, withpackage-lock.jsonsynced; npm's auto-installed peer was 0.2.2 beforegenclass_setup(packages/mcp/src/tools.ts): printsnpm install @genclass/runtime@betafor 0.2.x, for*/latest/empty ranges (which npm resolves to 0.2.2; before, these counted as "installed"), and for an older copy innode_modules.SNIPPET_RUNTIME0.3.0-beta.0→0.3.0-beta.1, newANALYTICS_RUNTIME.RUNTIME_ON_NPM0.3.0-beta.0→0.3.0-beta.1inwrangler.tomlandwrangler.selfhost.toml, with therelease.ymlnote.Deliberately unchanged:
SECURITY.mdandCONTRIBUTING.md(@<version>placeholders)initand the sv add-on write into users' files (it describes the file; sv's tests pin it byte for byte)compat/evaluation apps, whose harness swaps in the packed runtimellms-install.mdalready said@beta.Checks
npm run typecheck -w @genclass/runtimeandnpm run build -w @genclass/runtime: clean.test/review-perf.test.ts --retry=2: 3/4. "redux-style dispatch on a normalized store with 5,000 entities" went 17 → 8 → 1.3 ms against a 1 ms budget on a machine running several other sessions. No file in that path changed; CI reports this step without blocking.packages/mcp: typecheck, build, vitest 130 passed (manifests included).telemetry-workervitest 297 passed.node packages/runtime/test/first-load-size.mjsagainst a build of origin/main (with PR 98): +16 B gzip (/auto), +13 B (main).Not run (AGENTS.md says ask first, or they need the network/browsers): the install suite (
test/install/run-all.sh), the model Playwright suite, the sv/playwright/mcp e2e runs,compat/templates-check.mjs. I did run the realnpm viewdist-tag lookup once by hand: it answered in about 1 s and printed(npm dist-tag beta). No model-visible text changed (situation-v2.3). Nothing was published, and no dist-tag was changed.🤖 Generated with Claude Code