Skip to content

Add the NODESPACE_SKILL_EXTENSIONS build input to core's skill build - #3404

Merged
mstomar125 merged 4 commits into
mainfrom
issue-3369-skill-extensions-input
Oct 1, 2026
Merged

mstomar125 merged 4 commits into
mainfrom
issue-3369-skill-extensions-input

Conversation

@mstomar125

@mstomar125 mstomar125 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds ADR-082 §5's build-time skill-content input. NODESPACE_SKILL_EXTENSIONS names a directory whose references/*.md are staged beside core's references and whose SKILL.md fragment is appended to the staged SKILL.md. Unset or empty, which is every core build and test run, the staged skill is byte-identical to before this PR. Core's release workflow refuses the variable.

Closes #3369

Changes

scripts/build-skill.ts

  • readSkillExtensions(env = process.env, coreReferencesDir?) returns undefined for an unset or empty variable. Otherwise it returns { dir, references: Map<name, absPath>, fragment? }. A relative path resolves against the directory the build runs from.
  • It throws NODESPACE_SKILL_EXTENSIONS (<dir>): <problem> for:
    • a missing directory, or a path that is not a directory;
    • any root entry other than SKILL.md and references;
    • an empty SKILL.md, or a SKILL.md that is not a regular file;
    • a references that is not a directory, a subdirectory under it, a non-regular file (a symlink) or a non-.md file;
    • a reference named like one of packages/skill/references/, compared without case, because CLI.md would overwrite cli.md on a case-insensitive filesystem.
  • Dot-entries such as .DS_Store and .gitkeep are skipped at both levels and never staged. A symlinked references/ is reported as a symlink.
  • It reads entries in name order, so the log line and the first error do not depend on the filesystem.
  • syncTreeByContent is replaced by syncFilesByContent(files: Map<rel, {from} | {bytes}>, destRoot), which keeps the byte-compare, delete-what-is-gone and kind-flip self-heal behaviour. treeSources(root) builds the map for a plain tree. The old function's tests now go through a local helper.
  • stagedSources(entry, skillDir, extensions?) builds each entry's file map:
    • references is the union of core's files and the extension's, and refuses to replace one of core's;
    • SKILL.md is core's bytes, then \n and the fragment;
    • every other entry is core's alone.
  • stageSkillResources(skillDir, resourceDir, extensions?) is the staging loop, moved out of main() so it can be tested. A plain run after an extension run removes the additions, and a repeated run of either kind rewrites nothing.
  • main() reads the extension before tsc runs and logs one line, for example Skill extensions from <dir>: adding references/fixture-guide.md, a SKILL.md fragment.

scripts/fixtures/skill-extension/: a one-line SKILL.md fragment pointing at references/fixture-guide.md, and a neutral references/fixture-guide.md. Neither names a product.

.github/workflows/release.yml: the existing Refuse injected extensions guard step now checks both NODESPACE_EXTENSIONS and NODESPACE_SKILL_EXTENSIONS. It moved ahead of Build and stage skill resources in both build-tauri-macos-arm and build-tauri; it previously ran after the skill staging and before the Tauri build.

scripts/release-workflow-extensions-guard.test.ts now covers both variables:

  • Every job that stages the skill has the guard earlier in the same job, under bash, with no if: and no continue-on-error. Such jobs are found by scanning for any command that stages the skill, and are pinned to the two known jobs. A test also pins the matcher. The matcher covers:

    • build:skill, or tauri:build, which runs build:skill, from any --cwd;
    • the root build, build:macos, build:windows and build:windows:quick;
    • scripts/build-skill.ts.

    It does not cover Bun's bundler (bun build), bunx tauri build, or another package's build.

  • The extracted guard script exits 1 when either variable is set, including empty, and exits 0 when both are unset.

  • No env block anywhere sets either variable.

packages/skill/src/tests/installer.test.ts: installs from a package root shaped like an extension-staged skill (core's references plus fixture-guide.md, with a fragment at the end of SKILL.md). It checks that the added reference is installed and recorded, and that uninstall removes it along with the install directory.

Extension API: no bump, EXTENSION_API_VERSION stays at 1.0. The new input is additive (ADR-082 §7), but the version policy is not in force yet:

So this input and fixture ship as part of 1.0, like the sibling extension-point PRs #3392, #3398, #3402 and #3405. I asked #3321 to add NODESPACE_SKILL_EXTENSIONS and scripts/fixtures/skill-extension/ to its watched fixtures, so later changes to them require a bump.

Deviations from the issue

  • Release guard. The issue offered a test -z step, or extending the existing guard if one had landed. The guard from the build-entry PR exists, so this PR extends it. It uses printenv, which also fails on a set-but-empty value, matching the existing check.
  • Guard test location. The guard test is in the existing scripts/release-workflow-extensions-guard.test.ts, alongside the NODESPACE_EXTENSIONS checks, instead of a new file next to update-homebrew-cask.test.ts. Both are in scripts/ and DOM-free.
  • Extra rejections. readSkillExtensions also rejects the cases listed above beyond the issue's list (empty or non-regular SKILL.md, non-directory references, symlinks, case-only clashes). A build that quietly ignored a misplaced file would ship less guidance than its author meant. These match the installer's own filter, so nothing passes the build only to be skipped at install.
  • Dot-entries are ignored, not rejected. This was taken from review. The issue says to reject anything other than SKILL.md and references/*.md, but Finder recreates .DS_Store in any folder it opens. Rejecting it would fail every dev:tauri of a guidance checkout on macOS. Dot-entries are never staged, so nothing beyond SKILL.md and references/*.md can reach the skill.
  • No version bump. The issue says to bump the minor version if EXTENSION_API_VERSION exists, or to explain why not. It stays at 1.0, for the reason in the "Extension API" note above. An earlier revision bumped it to 1.1; that was reverted to main's values, so this PR no longer touches packages/desktop-app.
  • Fixture gate. Enforce EXTENSION_API_VERSION: Rust matches TypeScript, fixture changes bump it #3321's FIXTURE_FILES currently lists only the Rust fixture files. I asked there for scripts/fixtures/skill-extension/ to be added to the files it watches.

Pro boundary ratchet

bun run scripts/check-pro-boundary.ts exits 0, and --changed reports 0 hits for every marker in this PR's files (delta 0). BASELINES is untouched.

Tests

  • bun test scripts/build-skill.test.ts scripts/release-workflow-extensions-guard.test.ts: 99 pass (81 and 18).
  • bun run test:skill: 132 pass.
  • bun run test:changed: passed every tier, because release.yml is an unrecognized path. Those tiers were the skill tsc, the frontend, the scripts, the skill package, the browser and the Rust workspace nextest. It was re-run after each rebase; the branch is now on Add daemon-ready tasks and channel-rebuilt hooks to AppExtensions #3405.
  • cargo clippy -p nodespace-app-lib --all-targets -- -D warnings -D clippy::unused-async: clean. cargo fmt -p nodespace-app-lib: no changes. After the revert, extension_api_version_is_one_zero passes.
  • bun run quality:scripts:fix, bun run --cwd packages/skill quality:fix and bun run --cwd packages/desktop-app quality:fix are clean (svelte-check 0 errors, 0 warnings).

Mutation check: 53 runs of 52 distinct mutations, all killed, re-run after the review fixes. Each mutation was applied on its own, the named suite was run, and the file was restored.

  • readSkillExtensions (18 mutants):
    • unset or empty handling;
    • relative-path resolution;
    • each rejection check removed;
    • the clash compared with case;
    • core names not lowercased;
    • the fragment or references dropped;
    • entries not sorted.
  • describeSkillExtensions (3): the "nothing" wording, the fragment omitted, the directory omitted.
  • Staging (6): references not merged, the staging clash guard removed, the fragment separator dropped, the fragment not appended, the extension not passed to staging, the extension merged into every entry.
  • syncFilesByContent (5): always rewrites, never deletes, a bytes source never written, the kind-flip self-heal removed or inverted.
  • Release workflow (6): the guard removed from job 1, the skill-variable check exiting 0, the guard skippable through if:, the variable set in a job env, the build moved before the guard in job 2, the skill-variable check dropped from job 2.
  • Installer (3): references limited to the pre-record list, killed both by the suite and by the new test alone; uninstall skipping added references, killed by the new test alone.
  • Review rounds (12):
    • the files.size > 0 guard removed;
    • dot-entries not skipped at the root, or under references/;
    • dot-entries staged as references;
    • the symlinked-references check removed;
    • the skill-build matcher with tauri:build dropped, build:macos dropped, --cwd disallowed, --cwd allowed before build (which flags build-headless), bun build accepted, reverted to the literal build:skill, or without its end anchor (which matches build:skill-repo).

Manual verification (bun run build:skill in the worktree)

  1. A plain run: the staged tree's sha256 list is identical to one staged from origin/main, and the run reports "nothing rewritten".
  2. NODESPACE_SKILL_EXTENSIONS=scripts/fixtures/skill-extension: logs the added files, updates 2 staged files, adds references/fixture-guide.md, and SKILL.md ends with the fragment.
  3. A plain run afterwards updates 2 files, and the sha256 list again matches the origin/main staging.
  4. A second plain run reports "Staged resources already current — nothing rewritten."
  5. A stray notes.txt, a missing directory and a references/cli.md clash each fail with error: NODESPACE_SKILL_EXTENSIONS (<dir>): <problem>.
  6. After the review fixes, I ran an extension directory with .DS_Store at the root and under references/. It staged only the fixture's two files, and no .DS_Store reached staging. A plain run then restored the origin/main sha256 list, and a second plain run rewrote nothing.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Automated pragmatic code review (medium depth)

Review Type: Initial Review (PR #3404 @ 83fbb979)

What was checked

Requirements Check

# Criterion Status Notes
1 Unset: the staged skill is byte-identical ✅ Without extensions, stagedSources(entry, dir) is exactly treeSources(dir/entry).
2 Fixture: core's references plus fixture-guide.md, and SKILL.md ends with the fragment ✅ Checked on the real package.
3 A plain run after a fixture run restores core's staging, and an unchanged run rewrites nothing ✅ Real package: repeated fixture run 0 writes, plain after it 2, plain repeated 0. The sha256 list then equals a fresh plain staging. A unit test pins mtimes.
4 A missing dir, an unexpected file and a name clash each fail with a named problem ✅ The extra rejections match the installer's own filter, so nothing passes the build only to be skipped at install.
5 release.yml fails every job that runs build:skill with the variable set, and a test pins it ✅ See the guard notes below.
6 Install then uninstall of an extension-staged skill leaves no added file ✅
7 The EXTENSION_API_VERSION minor version is bumped ✅ See the version-bump note below.
8 BASELINES unchanged and the CLI exits 0 ✅ The fixture names no product.

The release guard (criterion 5).

  • The guard sits immediately before Build and stage skill resources in both jobs.
  • It runs under bash, with no if: and no continue-on-error.
  • Extending the existing guard step is the better choice.

The version bump (criterion 7).

Code Review Findings

  • 🟢 macOS .DS_Store and .gitkeep fail the build. 📁 scripts/build-skill.ts:502-523
    • Every dev:tauri run fails while Finder keeps recreating the file.
    • Skip dot-entries, or pin the rejection with a test.
  • 🟢 syncTreeByContent is now called only by tests. 📁 scripts/build-skill.ts:268-274, :278
    • Move it into the test file.
    • Update the pruneEmptyDirs doc.
  • 🟢 Nit: the files.size > 0 guard in the kind-flip condition is not pinned. 📁 scripts/build-skill.ts:236
    • Removing it survives the suite.
    • Add a test: an empty source dir over a staged file returns 1.
  • 🟢 Nit: a symlinked references/ is reported as "is not a directory". 📁 scripts/build-skill.ts:509
    • Name the symlink in the message.
  • 🟢 Nit: the fail-fast comment overstates it. 📁 scripts/build-skill.ts:597-598
    • skill:check (cargo) runs first, so say "before tsc and staging".
  • 🟢 Nit: the relative-path base is underspecified. 📁 scripts/build-skill.ts:474,491
    • Say that it is the repository root under bun run build:skill.
  • 🟢 Nit: the guard test matches only the literal bun run build:skill. 📁 scripts/release-workflow-extensions-guard.test.ts:22
    • The root bun run build and bun run scripts/build-skill.ts both run the skill build and would escape the scan.
  • 🟢 Nit: CLAUDE.md:174 does not mention NODESPACE_SKILL_EXTENSIONS.

Strengths

  • Validation, merge, mirroring and orchestration are cleanly separated.
  • The staging loop can now be tested.
  • The additions are merged into each entry's file map rather than copied after it, so the staging stays idempotent.
  • The tests pin behaviour: 5 of 6 spot mutations were killed, and the survivor is the count-only guard above.
  • No issue references in comments, and no lint suppressions.

Recommendation: APPROVE. No correctness, security or idempotence problem was found, and every finding is optional polish.

🤖 Generated with Claude Code

@mstomar125 mstomar125 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review: APPROVE, posted as a comment because GitHub blocks self-approval. The full findings are in the review comment above. All 8 acceptance criteria are met, and every finding is optional polish.

@mstomar125
mstomar125 force-pushed the issue-3369-skill-extensions-input branch from 83fbb97 to f207c38 Compare October 1, 2026 07:14
@mstomar125

Copy link
Copy Markdown
Contributor Author

Address review

Commit f207c38a. The branch is also rebased onto origin/main, which now includes #3400, #3401 and #3402; the rebase was clean.

✅ Addressed (7)

  1. .DS_Store and .gitkeep failed the build.
    • readSkillExtensions now skips dot-entries at the root and under references/, and never stages them.
    • Tests cover reading and staging.
    • Hand check: an extension directory with .DS_Store at both levels staged only the fixture's two files.
    • The PR body records this as a deviation from the issue's "reject anything else".
  2. syncTreeByContent was used only by tests.
    • It is removed from build-skill.ts.
    • Its tests mirror a tree through a local helper, syncTree, built on syncFilesByContent(treeSources(src), dest).
    • The pruneEmptyDirs doc now names syncFilesByContent.
  3. The files.size > 0 guard was not pinned. A new test stages an empty map over a staged plain file and expects a count of 1, with the file removed.
  4. The symlinked references/ message. It now reads references is a symlink; symlinks are not accepted, and a rejection case covers it.
  5. The fail-fast comment. It now says "before tsc and staging run".
  6. The relative-path base. The module doc and the readSkillExtensions doc say it is the repository root under bun run build:skill.
  7. The guard test matched only the literal bun run build:skill.
    • The matcher now also covers the root build, build:windows, build:windows:quick and scripts/build-skill.ts. The Windows scripts run the skill build too.
    • It excludes Bun's bundler, bun build, which build-headless uses.
    • It requires a whitespace or end-of-line boundary, so build:skill-repo does not match.
    • A test pins the matcher both ways. That test caught the missing anchor while I was writing it.

⏭️ Skipped (1)

Not a code change

Verification

  • bun test scripts/build-skill.test.ts scripts/release-workflow-extensions-guard.test.ts: 99 pass.
  • bun run test:changed on the rebased branch passed every tier: frontend 109s, scripts 25s, skill, browser, and Rust nextest 80s.
  • quality:scripts:fix is clean. The ratchet exits 0, with 0 hits in the changed files.
  • Mutation: the 8 new review-round mutants are all killed, and the 41 earlier runs are still all killed after the changes. That is 49 runs of 48 distinct mutations in total.

Re-Review Decision

Decision: RE-REVIEW NEEDED, scoped to f207c38a. Skipping dot-entries changes what the build accepts. The rest is docs and tests.

🤖 Generated with Claude Code

@mstomar125
mstomar125 force-pushed the issue-3369-skill-extensions-input branch from f207c38 to 7b5d520 Compare October 1, 2026 07:24
@mstomar125

Copy link
Copy Markdown
Contributor Author

Automated pragmatic code re-review (medium depth)

Review Type: Re-Review, scoped to f207c38a, which was rebased onto 4cd8a8bf.

Previous Review Summary: 8 recommendations.

  • Addressed: 7. Six are fully fixed, and the guard matcher (Svelte frontend renders with placeholder panels #7) is partly fixed.
  • Not addressed: 1. The CLAUDE.md line was skipped as out of scope, which is accepted.
  • New issues: 1 (🟡), plus 1 optional 🟢.

What was checked

  • git range-diff: 95711fde is the same patch as 83fbb979.
  • EXTENSION_API_VERSION still reads 1.1 in Rust and TypeScript.
  • bun test (99 pass) and the ratchet exit 0.
  • No issue references or lint suppressions were added.
  • syncTreeByContent has no remaining reference.
# Finding Status
1 Dot-entries failed the build ✅ Fixed, and the skip is safe (below)
2 syncTreeByContent was used only by tests ✅ Removed, and the pruneEmptyDirs doc is updated
3 The files.size > 0 guard was not pinned ✅ The new test fails without the guard
4 The symlinked references/ message ✅
5 The fail-fast comment ✅
6 The relative-path base ✅
7 The guard matcher ⚠️ Partly fixed (below)
8 The CLAUDE.md line ⏭️ Skip accepted

Why the dot-entry skip is safe

  • A root dot-entry can never be named SKILL.md or references.
  • Skipped reference entries never enter extensions.references.
  • stagedSources stages only that map and the fragment, so a dot-file can neither be staged nor clobber anything.
  • As a bonus, AppleDouble ._x.md junk is no longer staged.

Findings

🟡 The matcher misses commands that stage the skill. 📁 scripts/release-workflow-extensions-guard.test.ts:22-26, :137-143

  • build:macos runs tauri:build, which runs bun run --cwd ../.. build:skill. None of these three commands matches.
  • The new test asserts that bun run build:macos does not match, which is false.
  • Recommendation:
    • add tauri:build|build:macos to the matcher;
    • allow a --cwd before the script name;
    • move build:macos to the positive list.
  • This is a test-only change of about three lines, and needs no further re-review if it stays limited to the regex and its two lists.

🟢 Nit: a hidden .md reference is dropped quietly.

  • Optionally name skipped *.md dot-entries in the log line.

Recommendation: APPROVE once the 🟡 matcher fix is in.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Address re-review

Commit 7b5d520a. The branch is rebased onto origin/main again, which now includes #3405. The rebase was clean, and EXTENSION_API_VERSION still reads 1.1 on both sides.

✅ Addressed: 🟡 the skill-build matcher

  • Verified the chain first. The desktop app's tauri:build runs bun run --cwd ../.. build:skill, the root tauri:build runs it, and build:macos runs the root one. The build:macos negative in the earlier test was wrong; I had checked only for a direct build:skill string.

  • What the matcher accepts now:

    • build:skill or tauri:build, from any --cwd. Both stage the skill in every package that defines them, which is root and desktop-app.
    • The root build, build:macos, build:windows and build:windows:quick, without --cwd. With a --cwd, build is another package's build, such as packages/desktop-app (vite) or packages/skill (tsc), which does not stage the skill.
    • scripts/build-skill.ts.
  • Positive cases added: build:macos, tauri:build, cd packages/desktop-app && bun run tauri:build, bun run --cwd packages/desktop-app tauri:build and bun run --cwd ../.. build:skill.

  • Negative cases added: bun run --cwd packages/skill build and bunx tauri build, whose beforeBuildCommand is the desktop-app build.

  • Mutation, all 7 killed:

    • tauri:build dropped;
    • build:macos dropped;
    • --cwd disallowed;
    • --cwd allowed before build, which also flags build-headless;
    • bun build accepted;
    • reverted to the literal build:skill;
    • end anchor dropped.

    My first harness's bun build mutant was malformed and didn't actually widen the regex. Once corrected, it is killed.

  • The change is limited to the regex, its comment and the two lists, per the reviewer's scoping. No further re-review is needed.

⏭️ Skipped: 🟢 log skipped hidden .md files

Dot-files are hidden by convention, and the module doc and the readSkillExtensions doc both state the skip. Logging skipped entries would mostly print .DS_Store on every macOS dev build. If a hidden guidance file turns out to be a real authoring mistake, a .md-only notice is easy to add then.

Verification

  • bun run test:changed on the rebased branch passed every tier: frontend 127s, scripts 34s, skill, browser, and Rust nextest 71s.
  • Lint and typecheck are clean. The ratchet exits 0, with 0 hits in the changed files. The push gate passed.
  • Final mutation tally: 53 runs of 52 distinct mutations, all killed, plus the Rust pin test.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED. This is a test-only matcher fix, scoped exactly as the re-review allowed.

🤖 Generated with Claude Code

mstomar125 and others added 4 commits October 1, 2026 09:50
- build-skill.ts: readSkillExtensions validates the directory named by
  NODESPACE_SKILL_EXTENSIONS (an optional non-empty SKILL.md and a flat
  references/*.md whose names do not clash with core's, compared without
  case) and returns its references and fragment. stageSkillResources merges
  them into the staged references/ and SKILL.md. syncTreeByContent becomes a
  wrapper over syncFilesByContent, which mirrors a file map (copied files or
  in-memory bytes), so a plain run after an extension run removes the
  additions and an unchanged run rewrites nothing. Unset or empty, the
  staged skill is byte-identical to before.
- scripts/fixtures/skill-extension: a fragment and one added reference.
- release.yml: the extensions guard also refuses NODESPACE_SKILL_EXTENSIONS
  and runs before build:skill in both Tauri build jobs; its test pins the
  guard ahead of build:skill in every job that runs it.
- installer test: install and uninstall from an extension-staged package
  root leave no added file.
- EXTENSION_API_VERSION 1.0 -> 1.1 in Rust and TypeScript (additive input).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- readSkillExtensions skips entries whose names start with a dot, at the
  root and under references/, and never stages them, so a .DS_Store that
  Finder recreates no longer fails every dev build. A symlinked references/
  now reports that symlinks are not accepted.
- syncTreeByContent had no caller outside the tests; it is removed and the
  tests mirror a tree through a local helper over syncFilesByContent.
- A test pins that an empty file map over a staged plain file removes it
  and counts it.
- The release guard test recognizes every command that stages the skill
  (build:skill, the root build, build:windows, build:windows:quick and
  scripts/build-skill.ts) and not Bun's bundler, and a test pins the matcher.
- Docs: the relative-path base is the repository root under
  bun run build:skill; the early read fails before tsc and staging.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e guard test

The desktop app's tauri:build runs `bun run --cwd ../.. build:skill`, and the
root tauri:build and build:macos reach it, so the release guard test now
counts a step running any of them, or build:skill from any --cwd, as staging
the skill. A --cwd before `build` still names another package's build and
does not count. The matcher test moves build:macos to the positive cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The initial extension build-out stays at 1.0, and the bump rule applies once
the version checks land. Restores the Rust and TypeScript constants and the
pin test to their values on main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mstomar125
mstomar125 force-pushed the issue-3369-skill-extensions-input branch from 66c751b to e2afdaf Compare October 1, 2026 07:50
@mstomar125
mstomar125 merged commit 57cb0c7 into main Oct 1, 2026
@mstomar125
mstomar125 deleted the issue-3369-skill-extensions-input branch October 1, 2026 07:50
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.

Add the NODESPACE_SKILL_EXTENSIONS build input to core's skill build

1 participant