paperclip/cli/src/commands
Devin Foley f4a05dc35c
fix(cli): prepare plugin sdk before cli dev boot (#3343)
## Thinking Path

> - Paperclip orchestrates AI agents for zero-human companies
> - The company import/export e2e exercises the local CLI startup path
that boots the dev server inside a workspace
> - That startup path loads server and plugin code which depends on
built workspace package artifacts such as `@paperclipai/shared` and
`@paperclipai/plugin-sdk`
> - In a clean worktree those `dist/*` artifacts may not exist yet even
though `paperclipai run` can still attempt to import the local server
entry
> - That mismatch caused the import/export e2e to fail before the actual
company package flow ran
> - This pull request adds a CLI preflight step that prepares the needed
workspace build dependencies before the local server import and fails
closed if that preflight is interrupted or stalls
> - The benefit is that clean worktrees can boot `paperclipai run`
reliably without silently continuing after incomplete dependency
preparation

## What Changed

- Updated `cli/src/commands/run.ts` to execute
`scripts/ensure-plugin-build-deps.mjs` before importing
`server/src/index.ts` for local dev startup.
- Ensured `paperclipai run` can materialize missing workspace artifacts
such as `packages/shared/dist` and `packages/plugins/sdk/dist`
automatically in clean worktrees.
- Made the preflight fail closed when the child process exits via signal
and bounded it with a 120-second timeout so the CLI does not hang
indefinitely.
- Kept the fix isolated to the CLI startup path; no API contract,
schema, or UI behavior changed.
- Reused the existing
`cli/src/__tests__/company-import-export-e2e.test.ts` coverage that
already exercises the failing boot path, so no additional test file was
needed.

## Verification

- `pnpm test:run cli/src/__tests__/company-import-export-e2e.test.ts`
- `pnpm --filter paperclipai typecheck`
- On the isolated branch, confirmed `packages/shared/dist/index.js` and
`packages/plugins/sdk/dist/index.js` were absent before the run, then
reran the targeted e2e and observed a passing result.

## Risks

- Low risk: the change only affects the local CLI dev startup path
before the server import.
- Residual risk: other entrypoints still rely on their own
preflight/build behavior, so this does not normalize every workspace
startup path.
- The 120-second timeout is intentionally generous, but unusually slow
machines could still hit it and surface a startup error instead of
waiting forever.

## Model Used

- OpenAI Codex, GPT-5-based coding agent in the Codex CLI environment,
with shell/tool execution enabled. The exact runtime revision and
context window are not exposed by this environment.

## 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 run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] If this change affects the UI, I have included before/after
screenshots
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge
2026-04-10 17:01:06 -07:00
..
client fix: restore cli telemetry config handling in worktrees 2026-04-02 10:47:30 -05:00
allowed-hostname.ts fix(cli): add restart hint after allowed-hostname change 2026-03-10 16:43:40 -07:00
auth-bootstrap-ceo.ts Unblock canary onboard smoke bootstrap 2026-03-09 16:06:16 -05:00
configure.ts feat: implement app-side telemetry sender 2026-04-02 10:47:29 -05:00
db-backup.ts feat(backups): tiered daily/weekly/monthly retention with UI controls 2026-04-08 14:40:05 +02:00
doctor.ts Fix doctor summary after repairs 2026-03-10 10:13:05 -05:00
env.ts centralize URLs into single canonical URL var 2026-03-05 17:55:34 -03:00
heartbeat-run.ts refactor: rename packages to @paperclipai and CLI binary to paperclipai 2026-03-03 08:45:26 -06:00
onboard.ts fix: restore cli telemetry config handling in worktrees 2026-04-02 10:47:30 -05:00
routines.ts fix(routines): address Greptile review findings 2026-04-02 12:09:02 -05:00
run.ts fix(cli): prepare plugin sdk before cli dev boot (#3343) 2026-04-10 17:01:06 -07:00
worktree-lib.ts feat: implement app-side telemetry sender 2026-04-02 10:47:29 -05:00
worktree-merge-history-lib.ts Add merge-history project import option 2026-03-23 08:14:51 -05:00
worktree.ts Merge pull request #3015 from aronprins/feature/backups-configuration 2026-04-10 11:56:12 -05:00