Skip to content

Repo polish: Node-compatible ESM build, shared scoring engine, CI, docs and licenses - #4

Merged
ya-luotao merged 5 commits into
mainfrom
chore/repo-polish
Oct 10, 2026
Merged

ya-luotao merged 5 commits into
mainfrom
chore/repo-polish

Conversation

@ya-luotao

@ya-luotao ya-luotao commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What

A pass over packaging, code structure, CI and documentation so the package is publishable as @openjung/core and the repository reads like a maintained open-source project. No scoring result changes; the 212 existing tests pass with no assertion changes (only import extensions and Prettier formatting), with 24 added.

Build and packaging

  • dist/index.js could not be loaded by Node ESM (extensionless relative imports under moduleResolution: bundler). Switched to NodeNext with .js extensions. CI now smoke-imports the built package under Node.
  • tsc failed on node:crypto in a test and compiled *.test.ts into dist/. Added tsconfig.build.json, @types/node, and excluded tests from the tarball.
  • exports lists types first, adds default and ./package.json; sideEffects: false, engines, publishConfig with provenance. publint and @arethetypeswrong/cli pass.
  • Prettier + .editorconfig + .node-version; .claude/settings.local.json untracked.

Code

  • One internal scoring engine (src/scale.ts) replaces three copies of the sum / threshold / percentage logic. Each test is a ScaleSpec (question IDs, range, pole letters).
  • New: SUPPORTED_LOCALES, PURRJUNG_LOCALES, DEFAULT_LOCALE, Locale, getLocalizedText(). MultilingualText replaces BilingualText (kept as a deprecated alias). quickTestQuestionIds is typed DimensionQuestions.
  • New tests: locale coverage on every question, PurrJung scoring (previously untested), and a pinned public export list.

Repo

  • CI workflow on Node 20/22/24: typecheck, format, test, build, ESM smoke test, package lint.
  • Publish workflow triggers on a published release, verifies the tag matches package.json, and no longer bumps or pushes from CI.
  • Dependabot, issue forms (bug, translation correction), PR template.
  • LICENSE (MIT) so GitHub detects it, LICENSE-DATA for the CC BY-NC-SA questionnaire content, CONTRIBUTING.md with the contracts that must not change silently, CHANGELOG.md, README rewrite covering every public API area.

Contracts

  • Question IDs, dimension membership and left/right direction are unchanged
  • Every previously exported name still exports (see src/index.test.ts)
  • npm run check passes locally

Notes for review

  • openjung.org consumes this repo as a git submodule and runs npm run build then npm test --workspace=@openjung/core; both scripts keep their names and dist/index.js / dist/index.d.ts stay where they were.
  • Formatting with Prettier touches src/questions.ts and src/purrjungQuestions.ts (one-line objects become multi-line). This will conflict with feat: weighted question scoring with deterministic tie-breaking #2; that PR needs a rebase either way.
  • @openjung/core has never been published to npm. The first publish needs an npm login with rights on the @openjung scope and the NPM_TOKEN secret; see the Releasing section of CONTRIBUTING.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FGXjqn5CZbnVLNtHjkp45t

ya-luotao and others added 5 commits October 10, 2026 06:11
…rball

The build used moduleResolution "bundler" with extensionless relative
imports, so dist/index.js failed to load under Node ESM
(ERR_MODULE_NOT_FOUND) and only worked through a bundler. Switch to
NodeNext and add .js extensions.

tsc also compiled *.test.ts into dist/ and failed on node:crypto for
lack of @types/node. Split the emitting config into tsconfig.build.json
(excludes tests), add @types/node, and add typecheck/format/check:package
scripts with Prettier, publint and @arethetypeswrong/cli.

package.json: list "types" first in exports, add "default", expose
./package.json, mark sideEffects false, exclude tests from "files",
declare engines and publishConfig. Stop tracking .claude/settings.local.json.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FGXjqn5CZbnVLNtHjkp45t
scoring.ts and purrjungScoring.ts carried three copies of the same
sum / threshold / percentage logic that differed only in question IDs,
score range and pole letters. Move that into an internal scale.ts and
express each test as a ScaleSpec. Results are unchanged; the existing
212 tests pass without modification.

Add SUPPORTED_LOCALES, PURRJUNG_LOCALES, DEFAULT_LOCALE, the Locale type
and getLocalizedText() so consumers stop hand-maintaining the locale list.
Rename BilingualText to MultilingualText and keep the old name as a
deprecated alias. Type quickTestQuestionIds as DimensionQuestions.

New tests: locale coverage on every question, PurrJung scoring (it had
none), and a pinned list of public runtime exports so removals are loud.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FGXjqn5CZbnVLNtHjkp45t
CI runs typecheck, Prettier, tests, build, a Node ESM import smoke test
and publint/attw on Node 20, 22 and 24 for every push and PR.

The publish workflow now triggers on a published release (not a created
draft), refuses to publish when the tag does not match package.json, and
no longer bumps versions or pushes to main from CI. prepublishOnly runs
the full check.

Issue forms: bug report and translation correction (the fields
TRANSLATIONS.md asks reporters for). PR template carries the contract
checklist.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FGXjqn5CZbnVLNtHjkp45t
…E-DATA

README now documents every public area (full, quick, single-dimension,
quality metrics, locales, PurrJung) with a scoring-model table that makes
the PurrJung TF inversion explicit, and carries CI/license badges.

LICENSE is plain MIT so GitHub detects it; LICENSE-DATA restates the
CC BY-NC-SA 4.0 terms on the questionnaire content. CONTRIBUTING lists
the contracts that must not change silently and the release steps.
CHANGELOG seeds Unreleased with everything since @openmbti/core@1.0.1.

TRANSLATIONS.md and the skill docs are only reformatted by Prettier.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FGXjqn5CZbnVLNtHjkp45t
…de 20

TRANSLATIONS.md only says the five original locales were unchanged by
the 39-locale expansion, not that they were reviewed. Say "original"
instead. Node 18 is EOL and untested here; engines now says >=20 to
match the CI matrix. Date the TF Q2 fix to 1.0.1 (published one minute
after that commit).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FGXjqn5CZbnVLNtHjkp45t
@ya-luotao
ya-luotao merged commit 4d7917d into main Oct 10, 2026
3 checks passed
@ya-luotao
ya-luotao deleted the chore/repo-polish branch October 10, 2026 00:49
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.

1 participant