Skip to content

Install skill references from the staged directory and record installed files #3368

Closed

Description

@mstomar125

Summary

Change core's skill installer (packages/skill) as ADR-082 (proposed) §5 specifies, so the skill's reference files are no longer a hand-kept list.

  • Install every reference. Install every references/*.md file in the skill the installer runs from, instead of the references/... entries in each agent's shims. That skill is the staged resources/skill/, or packages/skill/ in a source checkout.
  • Record what it installed, per agent. Uninstall removes exactly the recorded files. A later install removes any recorded file the new skill no longer contains.
  • Derive the public skill repository's file list the same way.

This is the first half of ADR-082 §5's skill-content extension point. #3369 adds the build input. #3370 then removes the Pro-only guidance, and this record makes that removal clean on users' machines.

Context

  • How the installer works today (packages/skill/src/installer.ts):
    • install() copies each agent's config.shims.
    • uninstall() removes the same list, then prunes only the directories derived from shims (ownedDirs).
    • installedName() keeps references/ nested and flattens harness shims.
  • The hand-kept lists. Each agent's shims in packages/skill/src/agents.ts names three references: references/cli.md, references/shared-workspaces.md and references/graph-authored-guidance.md.
  • packages/skill/references/ holds six files. Besides those three, it holds jira-playbook.md, linear-playbook.md and spec-driven-playbook.md.
    • SKILL.md's "Work tracking" line (~272) points agents at the three playbooks, but no agent's shims lists them. Both the installed skill and the public skill repository therefore link to files that are not there.
    • The PTY-session embed in packages/agent (context_assembly.rs, write_skill_md) already writes all six.
    • Taking the list from the directory fixes this: the three playbooks start being installed and published. This is a deliberate, visible change, so state it in the PR description.
  • Files outlive the list today.
    • install() never deletes a file it no longer ships.
    • uninstall() removes only the current shims. A dropped reference therefore keeps references/, and with it the install directory, alive without SKILL.md: the stranded-directory case installedName's doc warns about.
  • The public repository. scripts/publish-skill-repo.ts publishes sharedShimPaths(), the intersection of every agent's shims. readSkillSource() reads four named files.
  • Most installs will have no record. The first-launch install runs once: ~/.nodespace/setup.json's skill_installed flag makes later launches no-ops (skill_setup.rs module doc). So most existing installs predate any record. See "Installs without a record".
  • ADR-082 §5 depends on ADR-081 R3.

Scope

  • packages/skill/src/agents.ts. Remove every references/* entry from every agent's shims. Keep SKILL.md and the harness shims.
  • packages/skill/src/installer.ts.
    • Add listReferenceFiles(packageRoot). It returns the sorted *.md files directly under <packageRoot>/references/. It is not recursive: ADR-082 §5 accepts only Markdown files there. It returns [] when the directory is absent.
    • install(targetAgents?, packageRoot):
      • Copy the shims as today, then copy each reference to <installDir>/references/<name>.
      • After copying, write the record <installDir>/.nodespace-install.json, as { "files": [ ...sorted relative paths ] }.
      • Then delete every file named in the previous record that is not in the new set. Delete only paths that resolve inside installDir and are regular files, and ignore any other entry.
      • Prune references/ if it is now empty.
    • uninstall(targetAgents?, packageRoot = PACKAGE_ROOT):
      • With a record: remove exactly the recorded files and the record.
      • Without a record: remove the agent's shims, plus every file from listReferenceFiles(packageRoot) that exists in the install directory. Add the pre-record list if the reviewer accepts option A below.
      • Then prune: references/, and the install directory when it is empty, as today.
    • Pass the resource root into uninstall. Update the caller in packages/skill/src/install.ts (uninstall(targetAgents), ~197) to pass the --resource-root it already parses. The Claude Code plugin reconciliation (uninstall(['claude-code']) inside install) passes its own packageRoot.
    • Don't change checkInstalled. The record file must not make it, or the "directory is now empty" check, misbehave.
  • Installs without a record (reviewer decision; name the choice in the PR):
    • Option A (recommended). Treat a missing record as the files the pre-record installer wrote:

      • SKILL.md;
      • the agent's harness shim;
      • references/cli.md, references/shared-workspaces.md and references/graph-authored-guidance.md.

      Put the three references in an exported PRE_RECORD_REFERENCES constant. Its doc should say it covers installs made before the record existed, and can be deleted once those are gone. CLAUDE.md's no-backward-compatibility rule is about data; this is installer hygiene for files core itself put on users' machines.

    • Option B. Add no constant. Legacy installs keep any reference a later skill drops, and uninstalling them may strand references/.

  • scripts/publish-skill-repo.ts.
    • sharedShimPaths() returns the shared shims (now only SKILL.md), plus references/<name> for every *.md in packages/skill/references/.
    • Update the header doc, readSkillSource() (return the references as a map, or drop the per-file fields) and the renderPublishFiles doc.
    • This script never reads NODESPACE_SKILL_EXTENSIONS (ADR-082 §5).
  • scripts/publish-skill-repo.test.ts.
    • Update the expected lists (the tests at ~40, ~84 and ~105) to SKILL.md plus the six references.
    • Add a test that every references/... link in the published SKILL.md resolves to a published file.
  • packages/skill/src/tests/installer.test.ts.
    • Make seedPkgRoot also seed references/, and update its comment (36-41) and the comment at 252-257.
    • Change the config test "each agent has … at least one agent shim" (70-77). Antigravity's shims becomes only SKILL.md, so assert that every agent has SKILL.md, and that every agent except antigravity has a harness shim.
    • Add the tests listed under Tests and verification.
  • No change to packages/agent, whose embed already writes every reference, or to tauri.conf.json (resources/skill/**/*).

Out of scope

Steps

  1. Follow CLAUDE.md's startup sequence:
    • pull main;
    • EnterWorktree({name: "issue-<N>-skill-install-record"});
    • bun install, then the bun run test baseline;
    • self-assign at pickup and set In Progress.
  2. Confirm ADR-081 R3 and ADR-082 §5 have merged, and note R3's outcome in the PR.
  3. Change agents.ts and installer.ts, then install.ts's uninstall call.
  4. Update the publish script and its tests.
  5. Update and add the installer tests. Mutation-check each new test individually.
  6. Run bun run build:skill and confirm the staged resources/skill/references/ is unchanged (six files).
  7. Run bun run scripts/check-pro-boundary.ts. This PR should neither add nor remove a marker; if a count moved, find out why.
  8. Verify, then finish:
    • bun run quality:fix, and commit;
    • git push origin HEAD:issue-<N>-skill-install-record;
    • gh pr create --head issue-<N>-skill-install-record;
    • merge only with bun run merge <PR#> once approved.

Acceptance criteria

  • agents.ts names no references/ path.
  • Installing from a package root installs every references/*.md (six at af8ddb6), and every references/... link in the installed SKILL.md resolves.
  • Each install writes a record listing exactly what it wrote. A reinstall from a skill without one reference deletes that reference and updates the record.
  • Uninstall with a record leaves no install directory behind. A user's own file in references/ survives, and so do references/ and the install directory around it.
  • A record entry that points outside the install directory is ignored.
  • The public file list is SKILL.md plus every reference in packages/skill/references/.
  • The PR description names the behaviour change (three playbooks now installed and published) and the reviewer's option A or B choice.
  • 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 installer tests. Mutation-check each one by reverting the matching installer.ts change and confirming it fails.

  1. Install copies every references/*.md in the package root, including one that agents.ts does not name.
  2. Install writes a record listing exactly the files it wrote.
  3. A second install from a package root missing one reference deletes that installed reference and updates the record.
  4. Uninstall with a record removes the recorded files and the record, and leaves no install directory.
  5. Uninstall keeps a user's own file in references/, and therefore keeps references/ and the install directory.
  6. A record entry such as ../outside.md is never deleted.
  7. Option A only: uninstall without a record removes the pre-record references, including one the current package no longer ships, and prunes the directory.

Commands:

  • bun run test:skill
  • bun run test:scripts
  • bun run skill:check
  • bun run build:skill
  • bun run test:changed (skill and scripts tiers)
  • bun run scripts/check-pro-boundary.ts

Dependencies

Risks and rollback

  • Users who reinstall get three more reference files. It is intended: SKILL.md already links them.
  • A new dotfile appears in each skill directory. Agent harnesses discover a skill by SKILL.md, so it is inert there.
  • Rollback. Revert the PR. An older installer ignores the record, so after a rollback, uninstall leaves .nodespace-install.json behind and keeps the install directory. Delete that file by hand if needed.

Plan key: C10.6a (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