Repository navigation
Publish @hyperpolymath/affine-vscode to npm (eliminate vendoring) #104
Description
Problem
packages/affine-vscode/mod.js is the JS-side adapter for stdlib/Vscode.affine + stdlib/VscodeLanguageClient.affine. It maps each extern fn to a real vscode / vscode-languageclient/node call and maintains the handle table.
Today the package has no package.json — only mod.js, README.adoc, and deno.json. Consumers outside this repo (currently hyperpolymath/my-lang and hyperpolymath/standards rsr-certifier; soon every other AffineScript-authored VS Code extension) vendor the adapter by copying mod.js into src/affine-vscode-adapter.cjs in their own repo.
Vendoring works but has clear drawbacks:
- Drift risk. Every change to
mod.jshere requires manual re-sync in every consumer. The bindings PR (feat(vscode-bindings): expand surface for rsr-certifier port (#64) #102) added ~20 new functions; each consumer downstream had to remember to copy them across. - Update protocol is implicit. There's no machine-readable version to pin, no changelog the consumer can diff against, no tooling to surface "your vendored copy is N commits behind".
- Discoverability. New extension authors find the adapter only by reading existing extensions' source.
Proposed plan
Publish @hyperpolymath/affine-vscode to npm so consumers can npm install @hyperpolymath/affine-vscode and require() the adapter directly. The vendoring step in each extension's src/index.cjs collapses to:
const shim = require("../out/extension.cjs");
const makeVscodeBindings = require("@hyperpolymath/affine-vscode");
shim.extraImports = () => makeVscodeBindings(
require("vscode"),
require("vscode-languageclient/node"),
shim,
);
exports.activate = shim.activate;
exports.deactivate = shim.deactivate;Steps
- Add
packages/affine-vscode/package.jsonwithname: "@hyperpolymath/affine-vscode",main: "./mod.js", an MIT or PMPL license entry matching the repo,peerDependencies: { vscode: "*", "vscode-languageclient": "^9.0.0" }, and arepository.directoryfield pointing at this subdirectory. - Pick a version (
0.1.0is fine for the first published cut). - Confirm the publishing account / token. The
hyperpolymathorg doesn't currently have an npm presence — decide whether to publish under that scope (needs the npm org creating) or under a personal scope. npm publish --access publicfrompackages/affine-vscode/. Add the publish step to a GitHub Actions workflow guarded on a tag pattern so subsequent releases are tag-driven.- Update
hyperpolymath/my-lang's vscode-extension andhyperpolymath/standards's rsr-certifier to depend on@hyperpolymath/affine-vscodeinstead of vendoring; remove their localsrc/affine-vscode-adapter.cjsfiles. - Document the consumer pattern in
packages/affine-vscode/README.adoc(the existing Usage section already gets close — just needs the vendoring escape hatch removed and the npm-install path made primary).
Acceptance criteria
-
@hyperpolymath/affine-vscodeis resolvable vianpm view. - CI publishes new versions automatically on tag push (no manual
npm publishafter the first one). - my-lang vscode-extension and standards rsr-certifier depend on the published package; their local
affine-vscode-adapter.cjsfiles are removed. -
packages/affine-vscode/README.adocdocuments the npm-install consumer pattern as primary.
Out of scope
- Cutting a major version.
0.xis fine while the binding surface is still growing organically. - Replacing the current
module.exports = function (...)factory shape with ESM exports. CJS is what the vscode extension host loads.
Activity
feat(affine-vscode): npm package manifest + tag-driven publish (issue #…
affine-vscode: align docs with --vscode-extension + npm publish manif…
chore(affine-vscode): finish PMPL→MPL sweep + truth-up Status paragra…
test(vscode): in-editor smoke harness via @vscode/test-electron (Closes
chore(vscode-extension): un-vendor affine-vscode adapter (Refs hyperp…
hyperpolymath commentedon May 21, 2026
Status sweep 2026-05-21
Most of the work in this issue already shipped via earlier PRs. The remaining gap is the first npm publish + downstream un-vendoring. Current state vs the four acceptance bullets:
@hyperpolymath/affine-vscoderesolvable vianpm viewNPM_TOKENsecret + tag pushmain.github/workflows/affine-vscode-publish.yml(trigger:affine-vscode-v*).cjsremovedREADME.adocdocuments npm-install as primarymain(tightened)Owner action checklist to land the first publish
hyperpolymathat https://www.npmjs.com/org/create (free tier is fine for public packages — issue body §3 noted this org doesn't yet exist on npm).@hyperpolymathscope and add it as repo secretNPM_TOKENat https://github.com/hyperpolymath/affinescript/settings/secrets/actions.affine-vscode-v0.1.0to fireaffine-vscode-publish.yml:npm view @hyperpolymath/affine-vscode.Closes #104reference on whichever PR (likely standards#160) lands last, per the ISSUE-CLOSURE rule in CLAUDE.md.What the DRAFT consumer PRs contain
hyperpolymath/my-lang#66 (uses the
--vscode-extensioncodegen pattern):vscode-extension/package.json: drop--vscode-extension-adapter=../src/affine-vscode-adapter.cjsoverride fromcompile+vscode:prepublishscripts; add@hyperpolymath/affine-vscode@^0.1.0todependencies.vscode-extension/src/affine-vscode-adapter.cjs: deleted (-141 lines).vscode-extension/out/extension.cjsline 101:require("../src/affine-vscode-adapter.cjs")→require("@hyperpolymath/affine-vscode"). This is auto-generated--vscode-extensionglue; matches whatnpm run vscode:prepublishwill regenerate on first compile after publish.hyperpolymath/standards#160 (uses the manual-wiring pattern):
rhodium-standard-repositories/satellites/rsr-certifier/extensions/vscode/package.json: add the dep.extensions/vscode/src/index.cjsline 18:require("./affine-vscode-adapter.cjs")→require("@hyperpolymath/affine-vscode").extensions/vscode/src/affine-vscode-adapter.cjs: deleted (-463 lines).out/extension.cjsunchanged — this extension's compiled wasm shim doesn't reference the adapter directly.Per the ISSUE-CLOSURE rule, this comment does not self-close the issue.
chore(rsr-certifier/vscode): un-vendor affine-vscode (Refs hyperpolym…
Qa 139 vscode smoke (#320)
hyperpolymath commentedon May 21, 2026
Final session status 2026-05-21 (handover)
All three PRs landed earlier today merged successfully:
Verified at session-close:
npm view @hyperpolymath/affine-vscode→ 404; noaffine-vscode-v*tag on the repo; zero runs ofaffine-vscode-publish.yml.Consequence: both consumer extensions now declare
@hyperpolymath/affine-vscode@^0.1.0independenciesand have deleted their vendored adapters, sonpm installinhyperpolymath/my-lang/vscode-extension/andhyperpolymath/standards/.../rsr-certifier/extensions/vscode/will 404 until the publish lands.Blocked on owner action (2FA lockout)
Owner reports phone/2FA issues blocking the npm-side sequence, same pattern as the deferred VS Code Marketplace PAT lockout. When 2FA is restored:
hyperpolymathat https://www.npmjs.com/org/createNPM_TOKENat https://github.com/hyperpolymath/affinescript/settings/secrets/actionsgit tag -a affine-vscode-v0.1.0 origin/main -m "affine-vscode 0.1.0 — first npm publish (Closes #104)" git push origin affine-vscode-v0.1.0npm view @hyperpolymath/affine-vscoderesolves, this issue may be closed with a comment referencing the workflow run that published.Fallback option (if 2FA stays blocked indefinitely)
If the publish can't land soon and the broken-install state needs resolving first, a pair of hotfix PRs against my-lang + standards can restore the vendored adapter as a temporary fallback. Not opened — owner discretion.
Per ISSUE-CLOSURE in CLAUDE.md, this comment does not self-close.
fix(ci): mark vscode-smoke continue-on-error until adapter publishes (#…
fix(ci): three foundational unblocks for the main-branch baseline (PR…
fix(ci): mark vscode-smoke continue-on-error until adapter publishes (#…
fix(ci): unblock the PR queue — bench/dune + adapter-load + .res-fixt…
fix(vscode-smoke): SKIP cleanly when @hyperpolymath/affine-vscode is …
feat(codegen): embed affine-vscode adapter at compile time (root-caus…
feat(codegen): embed affine-vscode adapter at compile time (root-caus…
hyperpolymath commentedon May 30, 2026
Closing — Signal C (policy-superseded). npm publishing is contra-policy per the estate npm-avoidant direction (#67 lockfile elimination + #253 npm→Deno migration). The intent — eliminating vendoring of
packages/affine-vscode/mod.js— remains valid, but the canonical replacement is JSR via thepublish-jsr.ymlworkflow that landed today.If JSR publishing for affine-vscode needs its own narrow tracker, please refile under JSR scope rather than reopening this ticket (older tickets accumulate stale context).