Files
PaperClipAI/packages
6b980871b5 fix(grok-local): copy SSH skill contents into the created directory (#22120)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The `grok_local` adapter can run a Grok agent on a remote SSH
workspace
> - Before the run, `prepareGrokRemoteProjectAssets` copies the selected
skills into `.claude/skills` on the target
> - It creates each skill directory and then calls `fs.cpSync` on that
same directory with `force: false` and `errorOnExist: true`
> - Node 24 rejects this with `ERR_FS_CP_EEXIST`, so every Grok run over
SSH fails with "Could not prepare Grok SSH runtime assets"
> - This pull request copies the contents of each skill into the new
empty directory
> - The benefit is that Grok SSH runs work again and the shared CI test
groups go green on master and on open PRs

## Linked Issues or Issue Description

Refs #22078

**What happened?**
Every Grok run on an SSH target fails before it starts. The error is
"Could not prepare Grok SSH runtime assets". The script on the target
fails with `SystemError [ERR_FS_CP_EEXIST]: Target already exists: cp
returned EEXIST (.../.claude/skills/selected already exists)`.

**Steps to reproduce**
1. Use Node 24.
2. Run `pnpm --filter @paperclipai/adapter-grok-local exec vitest run
src/server/remote-project-assets.test.ts`.
3. The "existing", "new" and "changed" cases fail.

**Expected behavior**
The skills are copied into `.claude/skills/<name>`, and the existing
project files stay safe.

**Impact**
CI fails on master and on unrelated open PRs:
- `ci / General tests (workspaces-b)`, in
`remote-project-assets.test.ts`
- the server group that runs `ssh-remote-workspace.integration.test.ts >
runs an assigned grok_local-cli task through heartbeat over SSH`

## What Changed

- `packages/adapters/grok-local/src/server/remote-project-assets.ts`:
after the script creates a skill directory, it now copies each child of
the source skill into that directory. Before, it copied the skill
directory onto itself. The copy keeps `force: false` and `errorOnExist:
true`, so it still does not overwrite files.

## Verification

- Red: on `origin/master` with Node v24.22.3,
`remote-project-assets.test.ts` fails 3 of 4 cases with
`ERR_FS_CP_EEXIST`. I saw this error in the script's stderr.
- Green: with this change, `vitest run src/server` in
`packages/adapters/grok-local` passes 137 tests in 9 files, and all 4
cases of `remote-project-assets.test.ts` pass.
- I could not run the SSH integration test locally. It needs a real SSH
server, so it is skipped here. CI runs it.

## Risks

Low risk. The change affects only the copy step for each new skill
directory. Cleanup and the safety checks for symlinks and paths do not
change. The script creates the target directory just before the copy, so
the directory is empty.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude
Code with tool use (shell, file edits, test runs).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [ ] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

The existing `remote-project-assets.test.ts` cases already cover this
bug: they fail before the fix and pass after it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: lucktastic <13757243+lucktastic@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 16:30:51 -08:00
..