Skip to content

Add the NODESPACE_SKILL_EXTENSIONS build input to core's skill build #3369

Closed

Description

@mstomar125

Summary

Add ADR-082 (proposed) §5's build-time skill-content input to scripts/build-skill.ts. NODESPACE_SKILL_EXTENSIONS names a directory.

  • Unset, as in every core build and test run, the staged skill is exactly core's.
  • Set, the build also stages the directory's references/*.md into resources/skill/references/, and appends the directory's SKILL.md fragment, if there is one, to the staged SKILL.md.
  • It rejects anything else in the directory, a name clash with core's references, and a missing directory.

Core's release workflow fails if the variable is set. This is the Pro build's way to add its agent guidance (ADR-082 §1 step 3), and the counterpart of NODESPACE_EXTENSIONS for the frontend.

Context

  • How staging works. scripts/build-skill.ts main() syncs each of STAGED_ENTRIES (dist, shims, SKILL.md, references, package.json) from packages/skill/ into packages/desktop-app/src-tauri/resources/skill/ with syncTreeByContent.
    • syncTreeByContent deletes staged files that are missing from the source, and rewrites only files whose bytes differ.
    • The module doc explains why that idempotence matters: every staged byte is a tauri-build rerun input.
    • Extension files must therefore be merged into what is staged, not copied after it. Otherwise the next plain run deletes them, and a run with the variable set churns them.
  • The installer already copes. After Install skill references from the staged directory and record installed files #3368 it installs every staged references/*.md and records it, so an added reference is installed and uninstalled like core's own.
  • What the Pro build does today. It never runs build:skill (ADR-082 §1). nodespace-sync's side of this change is the SYNC item on Move the Pro shared-workspaces agent guidance out of core's skill #3370.
  • ADR-082 §7 and §8.
    • The input, its accepted layout and the install/uninstall behaviour are part of the versioned extension API.
    • A fixture directory exercises them in core's script tests.
    • The gate that watches fixture files requires an EXTENSION_API_VERSION bump when they change.
  • Where the release guard goes. .github/workflows/release.yml runs bun run build:skill in two jobs (~124 and ~349 at af8ddb6).

Scope

  • scripts/build-skill.ts.
    • Export readSkillExtensions(env = process.env). It returns undefined when NODESPACE_SKILL_EXTENSIONS is unset or empty; otherwise it returns { references: Map<name, absPath>, fragment?: string }. It throws a clear error when:
      • the directory does not exist;
      • it holds anything other than an optional SKILL.md and references/*.md (no subdirectories under references/, no other files);
      • an added reference has the same name as one in packages/skill/references/.
    • Stage references from the union of core's files and the extension's, reusing syncTreeByContent's byte-compare-and-delete behaviour. Generalize it to take a file map, or add a sibling helper, so a plain run after an extension run removes the added files and an unchanged run rewrites nothing.
    • Stage SKILL.md as core's content, followed by \n and the fragment when there is one. Write it only if the bytes differ.
    • Log one line naming the extension directory and the added files, so a Pro build log shows what it added.
  • scripts/build-skill.test.ts. Add the tests listed under Tests and verification.
  • Fixture: scripts/fixtures/skill-extension/.
    • SKILL.md: a one-line fragment pointing at references/fixture-guide.md.
    • references/fixture-guide.md: neutral content.
    • Name no product: the Pro-boundary ratchet scans scripts/.
  • packages/skill/src/tests/installer.test.ts. One test that installs from a package root shaped like an extension-staged skill (core's references plus fixture-guide.md), uninstalls, and asserts no added file remains. This is ADR-082 §8's "install followed by uninstall leaves no added file behind".
  • .github/workflows/release.yml.
    • Before each bun run build:skill step, add a step that fails when the variable is set:
      test -z "${NODESPACE_SKILL_EXTENSIONS:-}" || { echo "::error::NODESPACE_SKILL_EXTENSIONS must not be set in a core release (ADR-082 §9)"; exit 1; }
    • If Turn the UI-extension registry into ADR-082's build-time frontend extension API #3317 already added a release guard for NODESPACE_EXTENSIONS, extend that step to check both variables instead.
    • Add a DOM-free bun test, next to the existing scripts/update-homebrew-cask.test.ts checks of release.yml, asserting that every job that runs bun run build:skill runs the guard earlier in the same job.
  • Extension API version. If EXTENSION_API_VERSION exists at your base commit (added by Split the desktop Tauri crate and add ADR-082's Tauri extension points #3322 or Turn the UI-extension registry into ADR-082's build-time frontend extension API #3317), bump its minor version: a new optional input is an additive change (ADR-082 §7). Add an "Extension API" line to the PR description. If it does not exist yet, tell the issue that adds it to list this input and fixture among its watched fixtures.

Out of scope

Steps

  1. Follow CLAUDE.md's startup sequence:
    • pull main;
    • EnterWorktree({name: "issue-<N>-skill-extensions-input"});
    • bun install, then the bun run test baseline;
    • self-assign at pickup and set In Progress.
  2. Confirm Install skill references from the staged directory and record installed files #3368 has merged.
  3. Implement readSkillExtensions and the merged staging, then the fixture and tests. Mutation-check each new test.
  4. Add the release guard and its test.
  5. Check by hand:
    • bun run build:skill stages exactly core's skill;
    • NODESPACE_SKILL_EXTENSIONS=scripts/fixtures/skill-extension bun run build:skill adds fixture-guide.md and the fragment;
    • a plain bun run build:skill afterwards removes both;
    • a second plain run reports "nothing rewritten".
  6. Run bun run scripts/check-pro-boundary.ts. This PR should neither add nor remove a marker.
  7. Verify, then finish:
    • bun run quality:fix, and commit;
    • git push origin HEAD:issue-<N>-skill-extensions-input;
    • gh pr create --head issue-<N>-skill-extensions-input;
    • merge only with bun run merge <PR#> once approved.

Acceptance criteria

  • With the variable unset, the staged skill is byte-identical to one staged before this PR.
  • With the fixture set, the staged skill has core's references plus fixture-guide.md, and SKILL.md ends with the fragment.
  • A plain run after a fixture run restores core's staging, and an unchanged run rewrites nothing.
  • A missing directory, an unexpected file and a name clash each fail the build with a message naming the problem.
  • release.yml fails any job that runs build:skill with the variable set, and a test pins that.
  • Install followed by uninstall of an extension-staged skill leaves no added file.
  • EXTENSION_API_VERSION's minor version is bumped, or the PR says why not.
  • BASELINES in scripts/check-pro-boundary.ts still equals the CLI's counts (this PR adds and removes no marker), and the CLI exits 0.

Tests and verification

New tests in scripts/build-skill.test.ts. Use a temporary directory per test.

  • Unset or empty: readSkillExtensions returns undefined.
  • Valid fixture: it returns the added reference and the fragment.
  • Each rejection: a missing directory, a stray file at the root, a subdirectory under references/, a non-.md file, and a name clash with a core reference.
  • Merged staging:
    • adds the extension's files;
    • a later plain staging deletes them;
    • identical inputs rewrite nothing and preserve mtimes.

Commands:

  • bun run test:scripts
  • bun run test:skill
  • bun run quality:scripts:check
  • bun run build:skill
  • bun run test:changed
  • bun run scripts/check-pro-boundary.ts

Dependencies

Risks and rollback

  • Staging churn. If the merged staging rewrites unchanged files, every tauri dev rebuilds the app crate. The mtime-preservation test guards against it.
  • A core release built with the variable set. The release guard stops it before the skill is staged.
  • Rollback. Revert the PR. With the variable unset, staging is unchanged, so no core build notices.

Plan key: C10.6b (pro-boundary DAG).

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

Labels

pro-boundary

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions