Skip to content

fix(cli): stage git-ref installs the way release.sh stages packages - #13928

Open
oliver-mee wants to merge 4 commits into
paperclipai:masterfrom
oliver-mee:fix/git-install-release-staging
Open

oliver-mee wants to merge 4 commits into
paperclipai:masterfrom
oliver-mee:fix/git-install-release-staging

Conversation

@oliver-mee

@oliver-mee oliver-mee commented Sep 24, 2026 •

Copy link
Copy Markdown

Thinking Path

  • Paperclip is the open source app people use to manage AI agents for work
  • Operators can install Paperclip from a GitHub branch, tag, or commit with paperclipai install --ref, and doc/INSTALLING.md documents this for forks too
  • A git-ref install builds the checkout and packs each workspace package into a local payload
  • These packaging steps are a copy of the release flow in scripts/release.sh
  • When @paperclipai/server became a bundled package, the release flow got new staging steps, but the git-ref install did not get them
  • So a git-ref install now fails during packaging, on master and on the latest stable tag
  • This pull request adds the four missing release steps to the git-ref install
  • The benefit is that paperclipai install --ref makes a working payload again, and the unit tests check each step

Linked Issues or Issue Description

Refs #10045

Refs #13923

No issue exists for this bug. This is the description.

What happened?

paperclipai install --ref <ref> fails after the build, while it packs the workspace packages. Four separate errors occur. Each one stops the install. You see the next one only after you fix the one before it:

  1. ENOENT: no such file or directory, lstat '.../source/server/ui-dist'. scripts/prepare-bundled-package.mjs copies the package files directly. Thus the server prepack script, which builds ui-dist, does not run.
  2. ENOENT: no such file or directory, lstat '.../source/server/skills'. release.sh copies the root skills/ into server, packages/adapters/claude-local and packages/adapters/codex-local. The install does not. The two adapters use plain pnpm pack, so they do not fail. They pack without their skills.
  3. npm pack on the staged server fails with command sh -c pnpm run prepare:ui-dist && pnpm run build. The release flow packs staged bundles with --ignore-scripts (run_bundled_npm_pack in scripts/release-lib.sh). The install does not, so npm runs prepack in the staging directory, where ../scripts/prepare-server-ui-dist.sh does not exist.
  4. npm error notarget No matching version found for @paperclipai/plugin-sdk@0.3.1. In source, @paperclipai/plugin-sdk has version 1.0.0 and the other packages have 0.3.1. materializePublishManifest changes each workspace:* dependency to the version of the package that has the dependency. The staged server thus asks for plugin-sdk@0.3.1. No local tarball has that version, so npm goes to the public registry and fails. The release flow runs release-package-map.mjs set-version first, so all versions are the same.

Expected behavior

paperclipai install --ref <ref> builds, packs, and activates a payload. The payload has the server UI and the skills, the same as a published npm release.

Steps to reproduce

  1. Use a ref where pnpm install --frozen-lockfile passes. On master today, the lockfile problem in paperclipai install --ref aborts on lockfile drift: install.ts runs a frozen pnpm install with no fallback, unlike provision-worktree.sh and release.yml #13923 stops the install before these steps. The tag v2026.916.1 has a clean lockfile.
  2. Run npx paperclipai install --ref v2026.916.1 --yes.
  3. Wait for the build. The install stops with error 1 above.
  4. Fix each error in sequence to see the next one.

Paperclip version or commit

v2026.916.1 (d554c4789ed3). The same cli/src/commands/install.ts and the same test file are on master at 7b7c4d4172d6.

Installation method

paperclipai install --ref (managed git-ref install).

Node.js version

v24.20.0

Operating system

Ubuntu 24.04, arm64

What Changed

  • cli/src/commands/install.ts: after the server build, run scripts/prepare-server-ui-dist.sh with PAPERCLIP_RELEASE_REUSE_UI_DIST=1. This is the same as step 2 of release.sh.
  • cli/src/commands/install.ts: copy the root skills/ into server, packages/adapters/claude-local and packages/adapters/codex-local. These are the same three directories that release.sh uses.
  • cli/src/commands/install.ts: before the pack steps, set the CLI version on each package that the install packs, and on the workspace: ranges that point at those packages. This has the same result as step 3 of release.sh (release-package-map.mjs set-version) for these packages. That script is not used here, because it validates every public package in the repo, and an unrelated package in a fork can then stop the install.
  • cli/src/commands/install.ts: pack staged bundled packages with npm pack --ignore-scripts. This is the same as run_bundled_npm_pack.
  • cli/src/__tests__/install-command.test.ts: the fixture now has a root skills/ directory. The mock pnpm pack of the server fails if server/skills is missing. New assertions check that the UI dist step and the version step run before packing, and that the staged pack uses --ignore-scripts.

Verification

  • pnpm exec vitest run cli/src/__tests__/install-command.test.ts cli/src/__tests__/install-store.test.ts: 29 of 29 pass.
  • Control: with the new test file and the old install.ts, the tests fail. Each fix makes its assertion pass.
  • pnpm --filter paperclipai typecheck: pass.
  • Full cli/src/__tests__/ suite: this change adds no failures. Some tests fail on my machine with and without the change (company, prompt, doctor, company-import-transfer and company-import-export-e2e). They fail because of the local environment (a pnpm version pin and timeouts), not because of this change.
  • End to end: paperclipai install --repo <fork> --ref <branch> --yes, where the branch is v2026.916.1 plus these fixes. The four earlier runs stopped at errors 1 to 4 in sequence. The run with all four fixes completed: Installed paperclipai git payload <sha12>. The payload has @paperclipai/server/ui-dist/index.html, skills/ in the server and in both adapters, and "@paperclipai/plugin-sdk": "0.3.1" in the server manifest. paperclipai --version runs from the managed shim.

Risks

  • Low risk. The change is only in the git-ref install path. The npm install path and the release flow do not change.
  • The install now changes package.json versions in its temporary checkout. The checkout is deleted when the install completes, so no user files change.
  • The list of three skills/ directories is a copy of the list in release.sh. If the release list changes, this list must change too. A shared helper for both flows can prevent this drift. I did not add one here, to keep this change small.

Model Used

  • Anthropic Claude Opus 5.5 (claude-opus-5-5), 1M context, agentic tool use (shell, file edits, test runs). The model found the four failures in real install runs, wrote the fix and the tests, and wrote this description. A human directed the work and reviewed the result.

Checklist

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

🤖 Generated with Claude Opus 5.5
🧑‍💻 Ideated, directed and reviewed by a human, @oliver-mee

@greptile-apps

greptile-apps Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Changes how git-ref installs stage workspace packages.

The PR appears safe to merge; no outstanding finding or new actionable issue remains.

Summary

The PR aligns Git-reference installation with release packaging. It stages UI assets and skills, unifies versions for packages in the payload, and skips lifecycle scripts when packing staged bundles. The latest change limits local dependency traversal to workspace: ranges.

Reviews (6) · Last reviewed commit: "fix(cli): stage only workspace-range @pa..."

Comment thread cli/src/commands/install.ts Resolved

@superagent-security superagent-security Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Superagent found 1 security concern(s).

@@ -278,16 +305,24 @@ export async function installGitPayload(repo: string, sha: string, runCommand: C
await runCommand("corepack", ["pnpm", "install", "--frozen-lockfile"], { cwd: checkoutPath, env: buildEnv(), maxBuffer: 32 * 1024 * 1024 });
await runCommand("bash", ["scripts/build-npm.sh", "--skip-checks", "--skip-typecheck"], { cwd: checkoutPath, env: buildEnv(), maxBuffer: 32 * 1024 * 1024 });
await runCommand("corepack", ["pnpm", "-r", "--filter", "@paperclipai/server...", "--if-present", "run", "build"], { cwd: checkoutPath, env: buildEnv(), maxBuffer: 32 * 1024 * 1024 });
// Stage the non-built publish artifacts the way release.sh does. Bundled packages go through
// prepare-bundled-package, which copies `files` without running prepack, so nothing else creates them.
await runCommand("bash", ["scripts/prepare-server-ui-dist.sh"], { cwd: checkoutPath, env: buildEnv({ PAPERCLIP_RELEASE_REUSE_UI_DIST: "1" }), maxBuffer: 32 * 1024 * 1024 });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The git-ref installer newly runs fork-controlled UI build scripts with ambient credentials

New UI build execution inherits process.env, including GH_TOKEN/GITHUB_TOKEN, from a downloaded fork.

Sanitize the git-ref build environment and remove ambient tokens before running fork-controlled package scripts.

AI prompt
Check if this security scanner issue is valid. If so, understand the root cause and fix it. If appropriate, update or add tests. Keep the change focused and preserve intended behavior.

<file name="cli/src/commands/install.ts">
<violation number="1" location="cli/src/commands/install.ts:310">
<priority>P2</priority>
<title>The git-ref installer newly runs fork-controlled UI build scripts with ambient credentials</title>
<evidence>The git-ref install path now executes `bash scripts/prepare-server-ui-dist.sh` from the downloaded repository. That script runs `pnpm ... --filter @paperclipai/ui build`, so a fork/ref controls the UI package build command and its imported build configuration. The command receives `buildEnv(...)`, which is derived from `{ ...process.env, ...extra }`; therefore ambient `GH_TOKEN` or `GITHUB_TOKEN` and other user environment secrets are inherited by the fork-controlled build. A less-trusted fork maintainer can place code in the UI build path that sends those values to a remote service when a user installs that fork/ref. The existing install confirmation warns that repository dependency and build scripts execute, but it does not remove credentials from the child-process environment.</evidence>
<recommendation>Run repository-controlled build steps with a minimal sanitized environment that excludes GH_TOKEN, GITHUB_TOKEN, cloud credentials, and other secrets. Preferably build the UI using trusted installer-owned tooling or explicitly document and enforce that git-ref builds cannot access ambient credentials.</recommendation>
</violation>
</file>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for flagging it. I checked, and this does not add a new exposure. On current master, the git-ref install already runs code from the downloaded checkout with the same buildEnv(): pnpm install (with lifecycle scripts), scripts/build-npm.sh, and pnpm -r --filter @paperclipai/server... run build. Before the server became a bundled package, pnpm pack also ran its prepack, which is the same UI build. So the downloaded ref could already read ambient tokens before this PR, and stripping them only from the UI step would not change that.

Removing tokens such as GH_TOKEN and GITHUB_TOKEN from every git-install build step could still be a sensible hardening, but it is a separate policy change for the whole path (some installs may need a token for private dependencies). I have kept it out of this PR so it stays focused on the packaging fix, and I am happy to open an issue for it if the maintainers want one.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The developer correctly notes that ambient credential exposure is pre-existing across the git-ref install path (lifecycle scripts, build scripts, and prior prepack hooks), so this PR does not introduce a new vulnerability. Removing tokens only for the UI build would be inconsistent and provide incomplete protection. We agree that comprehensive environment sanitization for all fork-controlled build steps is better handled as a focused follow-up hardening change. Please open a tracking issue for sanitizing the entire git-ref installer environment, and ensure the install confirmation warning clearly states that ambient credentials are visible to the downloaded ref.

Comment thread cli/src/commands/install.ts Resolved
Comment thread cli/src/commands/install.ts Resolved
oliver-mee and others added 3 commits September 25, 2026 12:55
`paperclipai install --ref` builds a checkout and packs it into a payload,
but its packaging steps are a copy of the release flow that stopped
matching it once @paperclipai/server became a bundled package. Four steps
from release.sh were missing, and each one fails the install on its own:

- server/ui-dist was never built. prepare-bundled-package copies `files`
  directly, so the server's prepack never runs (ENOENT on server/ui-dist).
- skills/ was never copied into server, claude-local and codex-local
  (ENOENT on server/skills; the two adapters pack without their skills).
- The staged bundled package was packed without --ignore-scripts, so npm
  re-ran the server's prepack inside the staging directory, where
  ../scripts/prepare-server-ui-dist.sh does not exist.
- Workspace versions were not unified. plugin-sdk is 1.0.0 in source and
  the server pins it to its own version, 0.3.1, so the final npm install
  fails with ETARGET against the public registry.

Run prepare-server-ui-dist.sh, copy skills/, run
`release-package-map.mjs set-version` with the CLI version, and pack the
staged package with --ignore-scripts, matching release.sh and
release-lib.sh. The install-command tests now assert each step and its
order.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
`release-package-map.mjs set-version` validates every public workspace
package against the release manifest. A fork that adds an unrelated
public package would fail the whole git install at that step, although
the install packs only the server's workspace dependency closure.

Rewrite the version and the `workspace:` ranges only for the packages
this install packs, plus the CLI's ranges that point at them. Other
packages and ranges are left as they are.

The git-install test now models the server as a bundled package, so it
goes through prepare-bundled-package and `npm pack`, and it checks the
skills in the staged server directory. A new test covers the version
rewrite and confirms that an unrelated package does not change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The CLI is packed with plain `npm pack`, which does not rewrite
`workspace:` ranges. The staged set only held the server's dependency
closure, so a CLI runtime dependency outside that closure kept its
`workspace:*` range, and the final `npm install` could not resolve it.

Resolve the CLI's runtime @paperclipai dependencies as roots next to the
server, so they are versioned, packed and installed as local tarballs
too. On the current repo every CLI dependency is already in the server
closure, so the staged set is the same 17 packages.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@oliver-mee
oliver-mee force-pushed the fix/git-install-release-staging branch from c63cf56 to bbdcf46 Compare September 25, 2026 04:56
@oliver-mee

Copy link
Copy Markdown
Author

Rebased onto current master (now at efce9356, "fix(ui): offer recovery when the app fails before React starts", #13970). The commits replayed cleanly with no logic changes. The General tests (chat 1/3) and verify failures from the previous run came from the stale base and pass on this head.

A registry-published @paperclipai dependency installs from the registry
and need not be in the release manifest, so skip it instead of failing
the git-ref install.
oliver-mee added a commit to oliver-mee/paperclip that referenced this pull request Sep 29, 2026
A git-ref payload carries no .git, so /api/health reported git unavailable
and every package kept the 0.3.1 source placeholder version.

- Write the resolved SHA to @paperclipai/server/.paperclip-build-commit in
  the payload, where server/src/build-commit.ts already looks (Docker
  builds set PAPERCLIP_BUILD_COMMIT for the same reason).
- When the ref is a version tag (v2026.916.1, or a fork's
  <name>-<version> tag such as ome-2026.916.1-2), unify the packed
  packages to that version, as release.sh does before packing. Branch and
  SHA refs keep the source version.

Extends paperclipai#13928.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@commitperclip

commitperclip Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

@greptileai

DragonNameLeo added a commit to DragonNameLeo/paperclip that referenced this pull request Oct 22, 2026
Git-ref installs run build-npm.sh and then pack the workspace packages.
They never run the release.sh staging step, so prepare-bundled-package
fails on the missing server/ui-dist, and the server and adapter
packages ship without the Paperclip skills. Stage both here.

Refs paperclipai#17063, paperclipai#13928

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@appleguy

appleguy commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for this PR. I rechecked the current #13928 code against our updated installer branch. The main four fixes in #13928 already cover server UI dist, copying the root skills into the server and two adapters, npm pack --ignore-scripts, and staging uniform package versions. There is no need to replace those fixes.

These are the additional parts of our branch, with the overlap made explicit:

  1. Still missing: Unset CARGO_TARGET_DIR in the git-build environment. Otherwise a custom Cargo target can put the runner outside the staging path.
  2. Still missing: Build the issue-thread viewer before bundling with pnpm --filter @paperclipai/paperclip-runner run build:issue-thread.
  3. Already addressed for the three named packages: fix(cli): stage git-ref installs the way release.sh stages packages #13928 copies the real root skills/ content. Our branch now does the same. It also creates an empty skills/ directory only as a fallback for other packaged workspace directories that list it but lack it. Please keep the real skills copy rather than replace it with empty directories.
  4. Still missing: Hydrate both applicable @embedded-postgres/<platform-arch> locations when native/pg-symlinks.json and scripts/hydrate-symlinks.js exist, both after npm install and on cached-payload reuse. The branch now handles both locations rather than returning after the first.
  5. Still missing: Include the last 6000 characters of build stdout in command failure diagnostics.
  6. Still missing: Pack the CLI with corepack pnpm --dir cli pack to resolve workspace: ranges. Our branch also resolves CLI-only runtime workspace dependencies and does not mistake registry ranges for local packages.
  7. Alternative, not needed for fix(cli): stage git-ref installs the way release.sh stages packages #13928's version fix: Our bundled-package preparation reads actual per-package versions from scripts/release-package-manifest.json. fix(cli): stage git-ref installs the way release.sh stages packages #13928 instead unifies temporary checkout package versions. Both solve the reported mismatch with different semantics. I would not combine them without a separate decision about preserving independent package versions.
  8. Still missing: Isolate uninstall tests from real launchd services. This is test safety, independent of the four packaging failures.

The current branch is https://github.com/appleguy/paperclip/tree/fix/installer-bundled-workspaces (two commits). The focused installer suite passed 32 tests, and the bundled-package packaging suite passed 29 tests in an isolated checkout.

I recommend a separate small follow-up PR after #13928 merges, limited to the independent missing parts. I will not open it here.


Generated by Claude Code

@james8814

Copy link
Copy Markdown

I checked this PR against the current master (8b3348c6b). The four defects are still on master, and this PR still fixes them.

What I checked:

  • cli/src/commands/install.ts on master still has the old staging steps (lines 283-297). There is no UI dist step, no skills copy, no version step, and the staged bundle is packed without --ignore-scripts.
  • Defect 1 with the real script on master: node scripts/prepare-bundled-package.mjs server <dir> stops with ENOENT ... lstat '<checkout>/server/ui-dist'.
  • Defect 4 with the real script on master: materializePublishManifest(server/package.json) asks for @paperclipai/plugin-sdk@0.3.1. The local packages/plugins/sdk is 1.0.0. The public registry has no 0.3.1 for that package.
  • The four commits apply to master with one small conflict. master added resolvePublishedVersion to the test import list (fix(cli): accept npm 12 array output when resolving published version #14000). Keep both names in the import.
  • After that, npx vitest run src/__tests__/install-command.test.ts in cli/ passes 18 of 18. With install.ts from master and the test file from this PR, 4 tests fail. npx tsc --noEmit -p cli/tsconfig.json passes.

A test to consider adding. The git-install tests replace prepare-bundled-package.mjs with a copy, so no test reads the range that the staged server really asks for. This test runs the version step and then the real materializePublishManifest. It passes on this PR. It fails with expected '0.3.1' to be '1.0.0' when the version step skips the packages.

it("stages a bundled server that asks for the plugin-sdk version the install packs", async () => {
  const checkout = path.join(root, "checkout");
  const write = (dir: string, packageJson: Record<string, unknown>) => {
    fs.mkdirSync(path.join(checkout, dir), { recursive: true });
    fs.writeFileSync(path.join(checkout, dir, "package.json"), JSON.stringify(packageJson));
  };
  write("packages/plugins/sdk", { name: "@paperclipai/plugin-sdk", version: "1.0.0" });
  write("server", { name: "@paperclipai/server", version: "0.3.1", dependencies: { "@paperclipai/plugin-sdk": "workspace:*" }, bundleDependencies: ["acpx"] });
  write("cli", { name: "paperclipai", version: "0.3.1" });
  const read = (dir: string) => JSON.parse(fs.readFileSync(path.join(checkout, dir, "package.json"), "utf8"));
  const { materializePublishManifest } = await import(new URL("../../../scripts/prepare-bundled-package.mjs", import.meta.url).href) as {
    materializePublishManifest: (pkg: Record<string, unknown>) => { dependencies: Record<string, string> };
  };

  unifyGitInstallWorkspaceVersions(checkout, [
    { dir: "packages/plugins/sdk", name: "@paperclipai/plugin-sdk" },
    { dir: "server", name: "@paperclipai/server" },
  ], "0.3.1");

  expect(materializePublishManifest(read("server")).dependencies["@paperclipai/plugin-sdk"]).toBe(read("packages/plugins/sdk").version);
});

Two other notes:

We carry these four commits in a fork since late September.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants