Skip to content

[NOT READY FOR REVIEW] feat(dev): CodeZip dev runner and process lifecycle core - #1883

Open
tejaskash wants to merge 3 commits into
feat/project-foundationfrom
feat/dev-server-core
Open

[NOT READY FOR REVIEW] feat(dev): CodeZip dev runner and process lifecycle core#1883
tejaskash wants to merge 3 commits into
feat/project-foundationfrom
feat/dev-server-core

Conversation

@tejaskash

Copy link
Copy Markdown
Contributor

Second PR in the agentcore project dev stack, on top of #1880. This adds the machinery that actually runs an agent locally — nothing is user-visible yet; the dev handler wires it up in a later PR.

What changed

src/core/dev/ is new and has three pieces:

spawnServer (process.ts) owns process lifecycle for a long-running server: streams output line by line to a log callback, escalates SIGTERM → SIGKILL on stop, and registers a process-group reaper so a detached server can't outlive the CLI and squat on the port. The child is spawned detached (its own process group) on POSIX so stopping it also stops uvicorn's reload workers — killing just the parent leaves the worker holding the socket.

CodeZipDevRunner (codezip.ts) runs a CodeZip runtime from a resolved project. Python entrypoints get a uv-managed venv (uv sync on first run, skipped when uvicorn is already in .venv) and then uvicorn --reload. TypeScript entrypoints get npm install + tsx watch. The agent process receives PORT and LOCAL_DEV=1 plus whatever env the caller passes — .env.local loading comes with the handler PR.

The DevRunner interface lives in handlers/project/dev/types.ts next to its future consumer, following the repo's dependency-inversion rule. The runner takes injectable run/spawn seams, so its tests never start real uv or uvicorn; the process tests use real short-lived node -e processes, since process handling is the thing under test there.

One deliberate duplication: run.ts carries the same CommandRunner shape as src/io/exec.ts from #1872. Whichever lands second folds into the other — noted in the file.

Compared to the old CLI's dev server, this drops the Python traceback filtering and stderr ring buffer. Raw output first; filtering can come back if it proves painful in practice.

Testing

Runner tests cover the missing-code-directory error, venv bootstrap vs. skip, the uvicorn/tsx command shapes, and env injection. Process tests cover line streaming, stderr classification, stop(), and a nonexistent binary. 565 tests pass, tsc clean.

Stack

#1880 (project foundation) → this PR → container runner → OTLP collector → Inspector web server → project dev handler.

@github-actions github-actions Bot added the size/l PR size: L label Jul 31, 2026
@github-actions github-actions Bot added the agentcore-harness-reviewing AgentCore Harness review in progress label Jul 31, 2026
@codecov-commenter

codecov-commenter commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.46067% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.75%. Comparing base (252c61c) to head (be40e1d).

Files with missing lines Patch % Lines
src/core/dev/run.ts 10.71% 25 Missing ⚠️
src/errors/errors.tsx 58.82% 7 Missing ⚠️
src/core/dev/process.ts 98.46% 1 Missing ⚠️
Additional details and impacted files
@@                     Coverage Diff                     @@
##           feat/project-foundation    #1883      +/-   ##
===========================================================
- Coverage                    96.01%   95.75%   -0.27%     
===========================================================
  Files                          208      211       +3     
  Lines                         9764     9942     +178     
===========================================================
+ Hits                          9375     9520     +145     
- Misses                         389      422      +33     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Jul 31, 2026
@tejaskash tejaskash changed the title feat(dev): CodeZip dev runner and process lifecycle core [NOT READY FOR REVIEW] feat(dev): CodeZip dev runner and process lifecycle core Jul 31, 2026
@tejaskash
tejaskash force-pushed the feat/dev-server-core branch from f5e0f3a to ba41e68 Compare July 31, 2026 16:55
@tejaskash
tejaskash force-pushed the feat/dev-server-core branch from ba41e68 to 720de89 Compare July 31, 2026 17:07
The first executable slice of agentcore project dev. CodeZipDevRunner
bootstraps a uv venv (or node_modules) on first run, then serves the
entrypoint with uvicorn --reload (or tsx watch). spawnServer owns process
lifecycle: line-streamed logs, SIGTERM->SIGKILL escalation on stop, and a
process-group reaper so a detached server can't outlive the CLI and hold
the port.

The DevRunner interface lives with its consumer (handlers/project/dev),
per the dependency-inversion convention. Command execution and server
spawning are injectable, so runner tests never start real uv or uvicorn;
process tests use real short-lived node processes because process
handling is the thing under test.

run.ts duplicates the CommandRunner shape from #1872 deliberately; fold
into src/io/exec.ts once that lands.
…to src/errors

All typed errors live in src/errors; the dev module was defining its own
inline.
@tejaskash
tejaskash force-pushed the feat/dev-server-core branch from 720de89 to be40e1d Compare August 3, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/l PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants