Skip to content

feat(image): add node capability module with first-scaffold npm recipes - #1042

Merged
c-vigo merged 6 commits into
devfrom
feature/1027-node-capability-module
Jul 14, 2026
Merged

c-vigo merged 6 commits into
devfrom
feature/1027-node-capability-module

Conversation

@c-vigo

@c-vigo c-vigo commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the node/typescript capability module per the design decision recorded on the issue (module = v1 shell contract; scaffold statics via #1024/#1025; release bundling via #1029).

node capability module (v1 contract)

  • modules = [ "node" ] puts nodejs (bundles npm) in the dev shell — replaces the hand-wired extraPackages = [ pkgs.nodejs ] every TS-action consumer copied.
  • Lands the per-module-options mechanism the ADR deferred (this is "the first module that needs it"): a modules entry may be { name = "node"; version = 22; } alongside plain strings — additive, no break for the string form. Modules are now uniformly pkgs -> options -> contribution; unknown option names, malformed entries, and unavailable Node majors all fail at eval time with clear messages.
  • PATH nuance (flagged for review): the toolchain SSoT (nix/devtools.nix) already ships nodejs for @devcontainers/cli, and the ADR orders devTools before module packages — so a pinned module node would be shadowed. When (and only when) an explicit version is given, the module prepends its node in shellHook (a v1-contract fragment, same pattern as native's CC/CXX exports). Documented in the module and docs/NIX.md.
  • nodejs_20 (the Actions runtime major the issue mentions) is EOL/insecure in the pinned nixpkgs — pinning it surfaces nixpkgs' own error unless the consumer opts into permittedInsecurePackages; the versioned test uses maintained LTS 22.
  • Zero-module invariant intact: modules = [ ] drvPath byte-identity and the parity suite pass untouched. checks.<system>.module-node is registry-generated.

First-scaffold npm recipes

Node-detected consumers (package.json, via #1024's DETECTED_LANGUAGES) get justfile.project seeded from assets/justfile.d/node.justfile.project at first scaffold only — sync=npm ci, lint/format/test/test-cov, build (tsc), bundle (ncc) — so the CI contract (just sync/just test) and the #1029 release bundle probe work out of the box. Guarded on JUSTFILE_PROJECT_PREEXISTED: an existing consumer-owned file is never touched. Full replacement, not append (appending would redeclare recipe names).

Out of scope (per the recorded decision)

eslint/prettier hooks (#883 seam), gitignore/codeql (landed via #1035), release bundle step (landed via #1033).

TDD: two failing-test → implementation commit pairs + a docs commit.

Test evidence

  • uv run pytest tests/test_flake_modules.py → 6 passed (node/npm resolve; version = 22 pins 22.x; unknown option rejected)
  • bats tests/bats/init-workspace.bats → 174 ok / 0 failed (5 new seeding tests; re-run after merging dev)
  • Zero-module drvPath parity → passed; flake checks module-node, deadnix, statix build
  • prek run --all-files → green (re-verified independently before push)

Closes #1027
Refs: #884, #1024, #1029

c-vigo added 6 commits July 14, 2026 10:26
Add a `node` capability module (nix/modules/node.nix) contributing `nodejs`
(which bundles npm) to the dev-shell, opt-in via `modules = [ "node" ]`. This
also lands the per-module-options mechanism the ADR deferred: mkProjectShell
now parses a `modules` entry as either a plain name string or an attrset
`{ name = "<name>"; <options> }`, and calls each module as
`pkgs -> options -> contribution` (native updated to the two-arg form).

The node module recognizes one option, `version` (a Node major -> pkgs.nodejs_
<major>; unset -> nixpkgs default); unknown keys and unavailable/insecure majors
throw at eval time. Because the toolchain SSoT already ships `nodejs` and the
ADR orders devTools before module packages, a pinned version is prepended in the
module shellHook so it actually wins PATH.

`modules = [ ]` is unchanged (zero-module drvPath parity holds).

Refs: #1027
On the first scaffold of a Node consumer (package.json detected, no existing
justfile.project) init-workspace.sh now replaces the freshly-copied uv/pyproject
template with a Node seed (assets/justfile.d/node.justfile.project): `sync` =
`npm ci`, plus lint/test/build (tsc)/bundle (ncc), so the CI-contract recipe
names ci.yml calls work in a Node repo. The seed is placed before the
placeholder substitution pass so its {{SHORT_NAME}} token resolves.

Guarded on JUSTFILE_PROJECT_PREEXISTED: an existing consumer-owned
justfile.project is never touched. A full replacement (not an append like the
.gitignore fragments), since appending onto the uv template would redeclare
recipe names and break `just`.

Refs: #1027
@c-vigo
c-vigo merged commit ab2fdd6 into dev Jul 14, 2026
15 checks passed
@c-vigo
c-vigo deleted the feature/1027-node-capability-module branch July 14, 2026 09:01
c-vigo added a commit that referenced this pull request Jul 14, 2026
## Summary

Implements #1036 as specified: every comment-capable file the scaffold
ships now opens with a two-line provenance banner — managed
("regenerated on upgrade; local edits are lost") or preserved ("yours to
edit; upgrades never overwrite") — plus the issues-URL pointer. **94
files bannered** (86 managed + 8 preserved).

- **Generated, never hand-written:** a `Banner` transform in
`scripts/transforms.py`, applied by `scripts/sync_manifest.py` on every
sync. The variant derives from `PRESERVE_FILES` in `init-workspace.sh`
(parsed as the SSoT), so classification drift is structurally
impossible; the `sync-manifest` pre-commit hook regenerates banners and
**fails the commit on a tampered or missing banner** (verified with a
tampered `ci.yml` — hook fails, restores).
- **No version string** — banners are byte-stable across releases
(`.vig-os` stays the version SSoT).
- **Placement-aware:** after shebangs, YAML `---` document starts, and
markdown front-matter (MD041-clean on SKILL.md files); `#` style for
yaml/toml/sh/justfiles/githooks/.gitignore/.envrc/CODEOWNERS, HTML
comments for markdown.
- **`justfile.devc` banner fixed:** the stale "vigOS devcontainer …
customizations go in root justfile" box (which pointed at an overwritten
file) is replaced by the generated managed banner pointing at
`justfile.project`.
- **Explicit, documented skip-list** in `_BANNER_SKIP`: strict JSON (no
comments); **JSONC files** (deviation from the issue text: the active
`check-json` hook parses them strictly with no exclude, so a `//` banner
fails the suite both upstream and downstream — bannering them requires a
`nix/hooks.nix` exclude, flagged as follow-up);
`.pre-commit-config.yaml` (rendered from `nix/hooks.nix`, drift-gated);
changelogs (release-diff churn); `.vig-os`, `.gitmessage`, `LICENSE`,
`flake.nix`, `justfile.local`.

### Follow-up candidates surfaced (not in this diff)
1. JSONC banner coverage via a `check-json` exclude in `nix/hooks.nix`.
2. `justfile.local`'s shipped header claims preservation but the file is
absent from `PRESERVE_FILES` — reclassification decision.
3. The #1027 node seed (`assets/justfile.d/node.justfile.project`, PR
#1042) lives outside `assets/workspace/`, so consumers seeded from it
won't carry the preserved banner — small alignment once both PRs land.

TDD: two failing-test → implementation commit pairs; 25 tests in
`tests/test_transforms.py`.

## Test evidence
- `uv run pytest tests/test_transforms.py` → 25 passed;
`tests/test_flake_hooks.py` → 17 passed (drift gate green)
- Tamper test: hand-edited banner → `sync-manifest ... Failed / files
were modified by this hook`
- Convergence: full `prek run --all-files` twice back-to-back → 0
failures, 0 modifications (re-verified independently after merging dev)

Closes #1036
Refs: #878, #913
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