Skip to content

feat(create-agent-bundle): scaffold through Effect FileSystem/Path; adopt @effect/platform-node for ordinary I/O (phase 1) - #501

Merged
ScriptedAlchemy merged 3 commits into
mainfrom
feat/effect-filesystem-phase1
Sep 4, 2026
Merged

feat(create-agent-bundle): scaffold through Effect FileSystem/Path; adopt @effect/platform-node for ordinary I/O (phase 1)#501
ScriptedAlchemy merged 3 commits into
mainfrom
feat/effect-filesystem-phase1

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Phase 1 of the Effect FileSystem / Path adoption (maintainer decision: adopt @effect/platform-node for ordinary I/O). One module per PR; this PR is the scaffolder pilot plus the convention flip.

What changes

packages/create-agent-bundle — every filesystem operation now runs as an Effect program over FileSystem.FileSystem and Path.Path:

Site (before) After
scaffold.ts assertScaffoldTargetreaddir + ENOENT check fs.readDirectory + Effect.catch on reason._tag === 'NotFound'; other PlatformErrors propagate untouched
scaffold.ts scaffoldreadFile / mkdir / readdir({ withFileTypes }) / writeFile recursive copy fs.readFileString / fs.makeDirectory({ recursive }) / fs.readDirectory + fs.stat(...).type === 'Directory' / fs.writeFileString; path.join
framework.ts localTarballPackageNamereadFile + try/catchUsageError fs.readFile (+ lifted gunzip / JSON.parse) with Effect.catchUsageError; path.resolve
framework.ts validatedRuntimeSpecForFrameworkPromise.all Effect.all(..., { concurrency: 'unbounded' })
index.ts ownVersion / template root — readFile(new URL(...)), fileURLToPath, resolve path.fromFileUrl (Effect.orDie: the URL comes from import.meta.url), fs.readFileString, path.resolve
index.ts runCli the one composition root: runPromise(Effect.provide(scaffoldProgram(flags), NodeServices.layer))

New: src/effect/boundary.ts (the package's sole runPromise; PlatformError unwraps to its Node cause so messages are byte-identical; UsageError / Error rethrow as the same instances; interruption → AbortError) and src/effect/lift.ts (identity lifts typed Error, never unknown).

Kept raw, deliberately: the @clack/prompts calls and process.stdout/stderr writes in index.ts (the Terminal sibling on feat/effect-terminal-cli-io owns stdout), spawn for the package-manager install (lifted, not ported — child processes are effect/unstable/process, not in scope), parseArgs. The scaffolded templates are untouched: they must not depend on an Effect runtime.

docs/effect-conventions.md — the 2026-09-01 "declined" decision for @effect/platform-node is superseded: adopted for ordinary I/O, with the explicit adopt vs keep-raw rules (durable-fs and dependents, install/doctor/receipt lstat/wx/atomic rename, IPC inode locks, sync SQLite, chokidar watcher, sync config/discovery on the compiler path, Rspack I/O, every emitted artifact). Boundary-module list, re-pin chore, and the parked-toolchain row now include the scaffolder and @effect/platform-node.

Layer wiring

NodeServices.layer (FileSystem + Path + Stdio + Terminal + Crypto + ChildProcessSpawner) provided once in runCli, as instructed, so the Terminal sibling can use the same layer. Imported via the @effect/platform-node/NodeServices subpath; undici is not in the bundle.

Behaviour parity (old origin/main build vs this branch, same scenarios, byte-diffed stdout + stderr + exit code + scaffolded tree)

--help, unknown flag, no args, missing template, non-preview build without --framework-version, minimal / mcp-server / cli-tool scaffolds (absolute and relative file: tarballs, --targets portable,cursor / plugin), missing tarball, corrupt gzip, misnamed tarball, occupied target dir, target path is a file (ENOTDIR) — all identical, exit codes 0 / 1 / 2 unchanged, e.g. the missing-tarball message is still Cannot inspect local package tarball "file:/…/absent.tgz": ENOENT: no such file or directory, open '/…/absent.tgz'.

Sizes (rc.112, Rslib bundle, node target)

before after (NodeServices.layer) narrow NodeFileSystem + NodePath only (measured, not used)
dist/index.js 73.7 kB 456.8 kB 264.7 kB
npm pack tarball / unpacked 33.0 kB / 122.6 kB 110.2 kB / 505.9 kB
create-agent-bundle --help wall time (5 runs) 0.04 s 0.06–0.07 s
import('./dist/index.js') 18 ms 40 ms

effect and @effect/platform-node are devDependencies and inlined, so the published package still declares zero runtime dependencies (the create-rstack shape the Rslib config documents).

Tests

  • tests/scaffold.test.ts, tests/framework.test.ts: moved to effect-rstest (layer(NodeServices.layer, { excludeTestServices: true }) + it.effect); fixtures use makeTempDirectoryScoped, so the per-test try/finally rm is gone. Same assertions as before (plus the ENOENT message text).
  • tests/scaffold-noop.test.ts (new): FileSystem.layerNoop({...}) protocol tests — exact readDirectory / stat / readFileString / makeDirectory / writeFileString sequence for a template copy, rename table, placeholder + manifest + config rewrites, "validates before writing anything", NotFound vs PermissionDenied discrimination in assertScaffoldTarget.
  • tests/effect-boundary.test.ts (new): the Promise-edge contract.
  • tests/scaffold-packed.e2e.test.ts (unchanged) — still packs and drives the real binary: passes locally (node scripts/run-packed-tests.mjs packages/create-agent-bundle/tests/scaffold-packed.e2e.test.ts).
  • Locally: pnpm typecheck, pnpm lint, pnpm test:unit (3117 passed), pnpm docs:site:build.

Coordination

  • feat/effect-terminal-cli-io may also add @effect/platform-node (same exact pin 4.0.0-rc.112) and touch create-agent-bundle/src/index.ts; whoever lands second rebases and dedupes the lockfile entry.
  • effect-rstest is added to the scaffolder's devDependencies at the same pkg.pr.new preview the other packages pin (tracked in the parked-toolchain table).

Review status

  • Awaiting automated review on the current head.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 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-09-04T02:39:40.483902Z 68ac2e1 Manual request
ℹ️ 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.

ScriptedAlchemy added a commit that referenced this pull request Sep 4, 2026
@changeset-bot

changeset-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 68ac2e1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
create-agent-bundle Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Sep 4, 2026

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

commit: 68ac2e1

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a7f3f2996e

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"create-agent-bundle": patch
---

Run the `create-agent-bundle` scaffolder's filesystem work (template copy, `package.json`/config/README rewrites, local `file:` tarball inspection, target-directory check) on Effect's `FileSystem` and `Path` services, provided once by `@effect/platform-node`'s `NodeServices.layer` at the `create-agent-bundle` bin entry. Scaffolded files, messages, and exit codes are unchanged (`UsageError` still exits 2 and filesystem failures still report the Node error text); the self-contained `dist/index.js` bundle grows from 74 kB to 457 kB and the published tarball from 33 kB to 110 kB. (#PR)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Rewrite the changeset as a user-facing summary

This summary documents the internal Effect migration, dependency wiring, and bundle-size measurements while explicitly saying that scaffolded files, messages, and exit codes are unchanged. That makes the generated release note an implementation note rather than a user-facing description, contrary to the repository's changeset requirements; replace it with a concise imperative statement of the user-visible outcome.

AGENTS.md reference: AGENTS.md:L104-L105

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Rewritten in 6628e5b as a user-facing imperative summary (single error boundary, same error text and exit codes, tarball 33 kB → 110 kB), with the migration mechanics left to the PR body.

"@types/node": "26.4.0"
"@types/node": "26.4.0",
"effect": "4.0.0-rc.112",
"effect-rstest": "https://pkg.pr.new/ScriptedAlchemy/effect-rstest@e5f8d5f"

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 Badge Include the new preview pin in its upgrade tracker

Adding effect-rstest here creates a third pkg.pr.new preview pin, but docs/effect-conventions.md still records only the agent-bundle and rsc-runtime pins and instructs the eventual release chore to replace “both” URLs. When effect-rstest is published, following that documented procedure will leave this package on the temporary preview dependency; update the tracker and its replacement count/package list with this addition.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Tracker row updated in 6628e5b: the effect-rstest preview pin now lists packages/create-agent-bundle as the third devDependency and the release step says "replace all three preview URLs".

@ScriptedAlchemy

Copy link
Copy Markdown
Owner Author

@codex review

…th NodeServices.layer

Phase 1 of the FileSystem/Path adoption: the scaffolder's reads, writes,
mkdir, readdir, stat and local-tarball inspection run as Effect programs
over FileSystem.FileSystem and Path.Path; runCli provides
@effect/platform-node's NodeServices.layer once and crosses back to the
bin's Promise contract through the package's new src/effect/boundary.ts,
which unwraps PlatformError to its Node cause so messages and exit codes
are unchanged. Unit tests move to effect-rstest with scoped temp
directories plus FileSystem.layerNoop protocol tests; the packed e2e that
drives the real binary is untouched. docs/effect-conventions.md flips the
platform-node decision to adopted-for-ordinary-I/O with the explicit
keep-raw carve-outs.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 6628e5b802

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ScriptedAlchemy
ScriptedAlchemy force-pushed the feat/effect-filesystem-phase1 branch from 6628e5b to 68ac2e1 Compare September 4, 2026 02:27
@ScriptedAlchemy

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 68ac2e10b6

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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