fix(vscode): make the packaged .vsix actually load (Refs #62)#63
Merged
Conversation
Building the .vsix per #62 surfaced a wiring defect: PR #58 switched the compile to `--vscode-extension` codegen, whose auto-glue emits a top-level `require("@hyperpolymath/affine-vscode")` — an unpublished npm package — while the repo still routed activation through the hand-written `src/index.cjs` + vendored `src/affine-vscode-adapter.cjs`. Result: VS Code loaded `src/index.cjs` -> `require("../out/extension.cjs")` -> MODULE_NOT_FOUND on `@hyperpolymath/affine-vscode`; the extension crashed on activation. Fix, using the mechanism affinescript already provides: - `compile`/`vscode:prepublish`: pass `--vscode-extension-adapter=../src/affine-vscode-adapter.cjs` so the auto-glue requires the already-vendored adapter by relative path (no npm package, resolves offline). `affinescript compile --help` documents this flag precisely for "vendoring a custom adapter". - `main`: `./src/index.cjs` -> `./out/extension.cjs` — the directly-loadable entry the `--vscode-extension` codegen is designed to produce (#58/#105's stated end-state). `src/index.cjs` is now dead and removed. - `vscode:prepublish`: no longer shells through `npm run` (repo CLAUDE.md bans npm) — it is the affinescript invocation directly. - Add `.vscodeignore` so lockfiles/build noise stay out of the .vsix. - `.gitignore`: ignore bun/deno lockfiles and the built `*.vsix` (distributed via GitHub Release, not git), extending the #57 policy. Verified: `out/extension.cjs` loads standalone; from the packaged .vsix's bundled tree `extraImports()` returns {Vscode, VscodeLanguageClient} with only host-provided `vscode` stubbed; `activate`/`deactivate` present. `my-lang-0.3.0.vsix` (324 files) now packages as a *functional* artifact. Refs #62 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
🔍 Hypatia Security ScanFindings: 35 issues detected
View findings[
{
"reason": "Issue in quality.yml",
"type": "missing_workflow",
"file": "quality.yml",
"action": "create",
"rule_module": "workflow_audit",
"severity": "high"
},
{
"reason": "Issue in security-policy.yml",
"type": "missing_workflow",
"file": "security-policy.yml",
"action": "create",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Action hyperpolymath/standards/.github/workflows/governance-reusable.yml@main needs attention",
"type": "unpinned_action",
"file": "governance.yml",
"action": "pin_sha",
"rule_module": "workflow_audit",
"severity": "high"
},
{
"reason": "unwrap_or(0) with dangerous default (1 occurrences, CWE-754)",
"type": "unwrap_dangerous_default",
"file": "/home/runner/work/my-lang/my-lang/_exploratory/me-scaffolding/crates/parser/src/lib.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "critical"
},
{
"reason": "expect() in hot path (80 occurrences, CWE-754)",
"type": "expect_in_hot_path",
"file": "/home/runner/work/my-lang/my-lang/_exploratory/me-scaffolding/crates/parser/src/lib.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "medium"
},
{
"reason": "unwrap() without prior check -- DoS via panic (1 occurrences, CWE-754)",
"type": "unwrap_without_check",
"file": "/home/runner/work/my-lang/my-lang/my-ssg/src/generator.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "high"
},
{
"reason": "expect() in hot path (5 occurrences, CWE-754)",
"type": "expect_in_hot_path",
"file": "/home/runner/work/my-lang/my-lang/crates/my-mir/src/lib.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "medium"
},
{
"reason": "unwrap() without prior check -- DoS via panic (26 occurrences, CWE-754)",
"type": "unwrap_without_check",
"file": "/home/runner/work/my-lang/my-lang/crates/my-fmt/src/lib.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "high"
},
{
"reason": "unwrap() without prior check -- DoS via panic (1 occurrences, CWE-754)",
"type": "unwrap_without_check",
"file": "/home/runner/work/my-lang/my-lang/crates/my-hir/src/lib.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "high"
},
{
"reason": "unwrap() without prior check -- DoS via panic (3 occurrences, CWE-754)",
"type": "unwrap_without_check",
"file": "/home/runner/work/my-lang/my-lang/crates/my-llvm/src/lib.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "high"
}
]Powered by Hypatia Neurosymbolic CI/CD Intelligence |
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.
Why
Executing #62 ("package & publish the .vsix") surfaced that the premise — "everything that could be done is done; just run
vsce package" — was wrong. The build produced a non-functional.vsix.Root cause: PR #58 switched the compile to
--vscode-extensioncodegen, whose auto-glue emits a top-levelrequire("@hyperpolymath/affine-vscode")(an unpublished npm package — see the vendored adapter's own header), while the repo still routed activation through the hand-writtensrc/index.cjs+ vendoredsrc/affine-vscode-adapter.cjs. So VS Code loadedsrc/index.cjs→require("../out/extension.cjs")→MODULE_NOT_FOUND: @hyperpolymath/affine-vscode→ crash on activation.Fix (uses affinescript's documented mechanism, no affinescript change)
compile/vscode:prepublishnow pass--vscode-extension-adapter=../src/affine-vscode-adapter.cjs.affinescript compile --helpdocuments this flag exactly for "vendoring a custom adapter"; the auto-glue now requires the already-vendored adapter by relative path (resolves offline, no npm package).main→./out/extension.cjs: the directly-loadable entry the--vscode-extensioncodegen is designed to produce (fix(vscode-ext): correct affinescript compile invocation + document build #58/#105's stated end-state). The now-redundantsrc/index.cjsis removed.vscode:prepublish: no longer shells throughnpm run(repo CLAUDE.md bans npm) — it is theaffinescriptinvocation directly..vscodeignoreadded;.gitignoreextended to ignore bun/deno lockfiles and the built*.vsix(Release artefact, not git), consistent with chore: gitignore package-lock.json (mirror Cargo.lock policy) #57.Verification
out/extension.cjsloads standalone (no MODULE_NOT_FOUND)..vsix's bundled tree,extraImports()returns{Vscode, VscodeLanguageClient}with only host-providedvscodestubbed;newLanguageClient/registerCommandare functions;activate/deactivatepresent.my-lang-0.3.0.vsix(324 files, 466 KB) packages with the fullvscode-languageclienttransitive closure bundled and Node-resolvable.Build was done with bun (Deno's
.deno/-nestednode_modulesis structurally incompatible with the flat, Node-resolvable tree a.vsixrequires — a legitimate fall-through in the Deno→bun→… package-manager policy).Refs #62
🤖 Generated with Claude Code