Skip to content

refactor(examples/hooks-and-scripts): export main and let the generated envelope own the process (RFC #50 Phase 2) - #55

Merged
ScriptedAlchemy merged 1 commit into
mainfrom
feat/hooks-scripts-phase2
Aug 31, 2026
Merged

ScriptedAlchemy merged 1 commit into
mainfrom
feat/hooks-scripts-phase2

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Summary

Phase-2 wave (RFC #50, plan §1.2 — executable-envelope witness), on top of the merged Phase-1 implementation (#52).

  • src/scripts/verify-release.ts and src/scripts/detect-risk.ts drop the top-level self-executing try/catch rituals and instead export const main = async (): Promise<number>; the framework's generated executable envelope (build/entry-shell.ts) owns argv, awaiting, and numeric exit-code adoption.
  • detect-risk's blocking path now return 2 — the wave's non-trivial exit-code witness: the envelope adopts the numeric return verbatim (process.exitCode = code), verified end-to-end (built .mjs exits 2 with REL-204 on stderr from an unrelated cwd).
  • Asset-relative new URL('../assets/…', import.meta.url) resolution is unchanged: the envelope is a virtual wrapper bundled into the same emitted scripts/<name>.mjs, so module-URL semantics are identical to today's direct bundle.
  • src/hooks/session-start.ts untouched (already the convention). README gains one line noting the scripts export main with a generated process envelope; walkthrough sections unchanged.
  • Zero edits to examples-contract.test.ts — all pinned assertions (compiledEntries names, verify stdout, detect-risk exit 2 + REL-204) hold as-is.

Q5 resolution (verified against shipped Phase-1 source)

  • Artifact Scripts take the envelope on a main export only (build/entries.ts wraps iff hasMainExport); default is reserved for bin entries (build/package-build.ts).
  • Numeric return of 2 is adopted verbatim by the generated wrapper.
  • import.meta.url semantics unchanged under the wrapper (empirically: built script resolves packaged assets from an unrelated cwd).

Verification

  • pnpm --filter @agent-bundle-example/hooks-and-scripts check — pass, zero diagnostics.
  • AGENT_BUNDLE_WORKBENCH_PREBUILT=1 AGENT_BUNDLE_PACKAGE_PREBUILT=1 pnpm exec rstest --config rstest.integration.config.ts packages/agent-bundle/tests/examples-contract.test.ts — all 3 examples pass, no assertion changes.
  • Root pnpm typecheck + pnpm lint — clean.
  • Skills-starter sentinel (plan §1.1/Q10, read-only): check passes, inspect shows packageBuild absent and scripts: [], default-dist artifact manifest intact, zero drift.

…ed envelope own the process (RFC #50 Phase 2)

Both artifact Scripts drop the self-executing try/catch ritual and export
`main` returning their exit code; the framework-generated executable
envelope owns argv, awaiting, and numeric exit-code adoption — including
detect-risk's blocking return of 2, the wave's non-zero/non-one witness.
Asset resolution via `new URL('../assets/…', import.meta.url)` is
unchanged: the wrapper bundles into the same emitted module. Zero
examples-contract assertions change.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-08-31T02:18:31.493181Z fb595a1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Aug 31, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle@55
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/@agent-bundle/rsc-runtime@55

commit: fb595a1

@ScriptedAlchemy
ScriptedAlchemy merged commit fd3cc24 into main Aug 31, 2026
9 checks passed
@ScriptedAlchemy
ScriptedAlchemy deleted the feat/hooks-scripts-phase2 branch August 31, 2026 03:12
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.

1 participant