Add startup process lifecycle policies and prepare v1.1.0 - #1
Merged
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
It introduces a sizable, cross-platform process-lifecycle state machine (ownership tracking + restart/stop escalation) that warrants final human review for edge-case correctness and operational safety.
Pull request overview
This PR introduces configurable startup-command lifecycle policies and a cross-platform process-tree shutdown mechanism, then wires these capabilities through the plugin server so OpenCode can dispose/cleanup owned processes reliably.
Changes:
- Adds
onExistingProcess(start/skip/restart) andstopOnExitpolicies to configuration, docs, and tests. - Implements a
process-treecontroller with POSIX process-group and Windowstaskkill.exeshutdown behavior, plus sanitized stop lifecycle logging. - Refactors startup core to track owner-aware process records, expose an async
disposehook, and synchronizesdist/+ release/package-contract checks.
File summaries
| File | Description |
|---|---|
| tests/server.test.ts | Expands server/core tests to cover dispose semantics, ownership, and lifecycle policy behaviors. |
| tests/release-package.test.ts | Updates package-contract expectations to include new dist/process-tree.* artifacts. |
| tests/readme.test.ts | Extends README assertions to document lifecycle policies and stop behavior; relaxes line-count cap. |
| tests/process-tree.test.ts | Adds comprehensive unit/integration coverage for POSIX + Windows process-tree stopping behaviors. |
| tests/logger.type-test.ts | Adds type-level safety coverage for new stop lifecycle log events and allowed fields. |
| tests/logger.test.ts | Verifies console/file formatting and sanitization for new stop lifecycle events. |
| tests/fixtures/process-tree-parent.mjs | Adds real-process fixture parent that spawns a child and persists PIDs for stop tests. |
| tests/fixtures/process-tree-child.mjs | Adds real-process fixture child used to validate descendant cleanup. |
| tests/config.type-test.ts | Extends config type tests for new lifecycle-policy fields and validation. |
| tests/config.test.ts | Adds runtime config normalization/validation tests for onExistingProcess and stopOnExit. |
| src/server.ts | Wires a single processTree controller into the production server dependencies. |
| src/server-internal.ts | Returns an async dispose hook backed by core activation cleanup and extends dependency typing. |
| src/process-tree.ts | Implements cross-platform process-tree stopping with reasoned failure results and timeouts. |
| src/logger.ts | Adds stop lifecycle event types, formatting, and ensures sanitized stop logging. |
| src/core.ts | Replaces simple “started set” with owner-aware identity records, restart/skip/start policies, and disposal cleanup. |
| src/config.ts | Introduces lifecycle-policy fields/types and validates/defaults them during config load. |
| scripts/release-package.mjs | Updates required package paths to include process-tree dist outputs. |
| README.md | Documents lifecycle policies, ownership semantics, and cross-platform stop behavior + logging guarantees. |
| dist/server.js.map | Updates built artifact map for server dependency wiring changes. |
| dist/server.js | Updates built server to include createProcessTreeController() wiring. |
| dist/server.d.ts.map | Updates built type map for server changes. |
| dist/server-internal.js.map | Updates built artifact map for server-internal dispose hook changes. |
| dist/server-internal.js | Updates built server-internal to return dispose hook and await activation. |
| dist/server-internal.d.ts.map | Updates built type map for server-internal dependency typing changes. |
| dist/server-internal.d.ts | Updates built typings to extend StartupDependencies (incl. processTree) and reflect new contract. |
| dist/process-tree.js.map | Adds built artifact map for new process-tree module. |
| dist/process-tree.js | Adds built JS for new process-tree controller. |
| dist/process-tree.d.ts.map | Adds built type map for new process-tree module. |
| dist/process-tree.d.ts | Adds built typings for new process-tree controller and result types. |
| dist/logger.js.map | Updates built artifact map for new stop lifecycle log formatting. |
| dist/logger.js | Updates built logger output formatting for stop lifecycle events. |
| dist/logger.d.ts.map | Updates built type map for logger stop lifecycle additions. |
| dist/logger.d.ts | Updates built logger typings for stop lifecycle events and trigger/reason types. |
| dist/core.js | Updates built core with new state machine, ownership tracking, and disposal behavior. |
| dist/core.d.ts.map | Updates built type map for new core APIs and types. |
| dist/core.d.ts | Updates built core typings (new StartupState shape, processTree dep, and async activation/dispose). |
| dist/config.js.map | Updates built artifact map for new config lifecycle fields. |
| dist/config.js | Updates built config loader to validate/default lifecycle policy fields. |
| dist/config.d.ts.map | Updates built type map for new config types. |
| dist/config.d.ts | Updates built config typings to include lifecycle-policy fields and OnExistingProcessPolicy. |
Review details
- Files reviewed: 19/42 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation
Release
This branch now contains the v1.1.0 release-preparation metadata. After CI passes, merge this PR into main, tag the merge commit as v1.1.0, then publish the verified opencode-startup-commands-1.1.0.tgz artifact to npm.