Skip to content

skills: record flat skill name in lockfile for namespaced skills (#15147) - #15158

Open
wellparth wants to merge 2 commits into
cli:trunkfrom
wellparth:fix-skill-install-lock-key
Open

wellparth wants to merge 2 commits into
cli:trunkfrom
wellparth:fix-skill-install-lock-key

Conversation

@wellparth

Copy link
Copy Markdown

Fixes #15147

Description

When installing a skill with a namespace prefix (e.g. skills/alice/deploy with name deploy and namespace alice), gh skill install intentionally writes files to a flat directory (baseDir/deploy) so agent hosts (Copilot, Claude Code, etc.) can discover them as immediate subdirectories.

However, internal/skills/installer/installer.go previously recorded skill.InstallName() ("alice/deploy") as the key in the shared ~/.agents/.skill-lock.json file. Because Vercel's skills CLI lockfile specification uses the lockfile key to locate the installed skill folder on disk, running skills update looked for a folder named alice/deploy, could not find it, and failed with No matching skills found.

Additionally, in pkg/cmd/skills/install/install.go, printFileTree attempted to look up the on-disk directory using the unstripped install name (filepath.Join(dir, "alice/deploy")), which caused the post-install tree view to emit (could not read directory).

This change:

  1. Records skill.Name instead of skill.InstallName() in lockfile.RecordInstall, ensuring the lockfile key matches the flat directory on disk.
  2. Resolves the directory name in printFileTree using filepath.Base(...), allowing the installed file tree to render properly for namespaced skills.
  3. Adds unit and regression tests in internal/skills/installer and pkg/cmd/skills/install.

How did you test this change?

  1. Unit and Integration Tests:

    • Ran go test -v ./internal/skills/installer -run TestInstall: verified TestInstall/namespaced_skill_records_flat_name_in_lockfile passes, writing "deploy" to .skill-lock.json and ensuring "alice/deploy" is not written.
    • Ran go test -v ./pkg/cmd/skills/install -run "TestInstallRun/remote_install_namespaced_exact_match": verified that the tree output for a namespaced install renders xlsx-pro/ on stderr without (could not read directory).
    • Ran all skills test suites (go test ./internal/skills/... ./pkg/cmd/skills/...): all 13 packages passed cleanly.
  2. Manual Walkthrough:

    • Given an installation of a namespaced skill bob/xlsx-pro into a temporary directory
    • When Install runs
    • Then .skill-lock.json records "xlsx-pro" under skills, matching the xlsx-pro directory created in the target path.

Key points

  • Result.Installed continues to preserve skill.InstallName() so user-facing completion output (✓ Installed alice/deploy) and review hints (gh skill preview repo alice/deploy) retain full remote namespace context.
  • Only the lockfile key (which maps directly to the on-disk folder name) and the local tree inspection (printFileTree) are flattened to match the actual filesystem layout.

Notes for reviewers

  • Review can start in internal/skills/installer/installer.go lines 79 and 132, followed by the tree helper in pkg/cmd/skills/install/install.go line 1150.
  • Associated unit tests are in internal/skills/installer/installer_test.go and pkg/cmd/skills/install/install_test.go.

Authorship and follow-up

Who wrote this:

  • A human wrote it.
  • An agent wrote it under close human direction.
  • An agent wrote it independently, and no human has guided the implementation beyond the initial prompt.

Who answers review comments:

  • @wellparth will read and reply directly.
  • An agent will draft replies and @wellparth will read them before they are posted.
  • Nobody has explicitly committed to replying.

…#15147)

When a namespaced skill is installed, gh skill installs it into a flat
directory so agent clients can discover it, but previously recorded the
namespaced name in ~/.agents/.skill-lock.json.

This broke interoperability with the Vercel skills CLI, which looks up
the skill directory by its lockfile key during 'skills update'. In
addition, printFileTree attempted to read the namespaced path on disk
and failed with '(could not read directory)'.

Record skill.Name in the lockfile to match the on-disk directory layout,
and resolve the directory name in printFileTree.

Signed-off-by: Parth Gorde <[email protected]>
@wellparth
wellparth requested review from a team as code owners November 25, 2026 06:37
@wellparth
wellparth requested review from sergiou87 and a balanced review from Copilot November 25, 2026 06:37
@github-actions github-actions Bot added external pull request originating outside of the CLI core team needs-triage needs to be reviewed unmet-requirements and removed needs-triage needs to be reviewed labels Nov 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your pull request! Unfortunately, it doesn't meet the requirements for review:

  • None of the referenced issues have the help wanted label

Please update your PR to address the above. This PR will be automatically closed in 4 days if these requirements are not met.

Full contribution requirements
  1. Include a detailed description of what this PR does
  2. Link to an issue with the help wanted label (use Fixes #123 or Closes #123)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Regression tests can pass with the tree fix reverted and do not cover namespaced lockfile keys in multi-skill installs, leaving both regressions undetected.

2 open issues
What changed in this PR

This PR addresses #15147 by aligning namespaced skill lockfile keys and file-tree lookups with the flat directories that gh skill install creates, improving compatibility with the Vercel skills updater.

Changes:

  • Record flat skill names in the lockfile for single and batch installs.
  • Use flat directory names when rendering installed file trees.
  • Add regression tests while preserving namespaced identifiers in installation results.
File Description
pkg/​cmd/​skills/​install/​install.go Resolve and display flat directory names in file trees.
pkg/​cmd/​skills/​install/​install_test.go Add a tree-output expectation for a namespaced install.
internal/​skills/​installer/​installer.go Record flat names in both lockfile-writing paths.
internal/​skills/​installer/​installer_test.go Add a namespaced install case and lockfile-key checks.

Review effort: Balanced

skill := opts.Skills[i]
if err := lockfile.RecordInstall(opts.Host, skill.InstallName(), opts.Owner, opts.Repo, skill.Path+"/SKILL.md", skill.TreeSHA, opts.PinnedRef); err != nil {
warnings = append(warnings, fmt.Sprintf("could not record install for %s: %v", skill.InstallName(), err))
if err := lockfile.RecordInstall(opts.Host, skill.Name, opts.Owner, opts.Repo, skill.Path+"/SKILL.md", skill.TreeSHA, opts.PinnedRef); err != nil {
Comment thread pkg/cmd/skills/install/install_test.go Outdated
}
},
wantStdout: "Installed bob/xlsx-pro",
wantStderr: "xlsx-pro/",
…rendering

- Add multi-skill test ensuring namespaced skills write flat lock keys in batch installs
- Assert file tree output renders child SKILL.md under flat directory heading

Signed-off-by: Parth Gorde <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team unmet-requirements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gh skill writes namespaced lock keys for flat installations, breaking skills update

2 participants