-
Notifications
You must be signed in to change notification settings - Fork 0
feat(create-agent-bundle): scaffold through Effect FileSystem/Path; adopt @effect/platform-node for ordinary I/O (phase 1) #501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "create-agent-bundle": patch | ||
| --- | ||
|
|
||
| Scaffold through Effect's `FileSystem` and `Path` services (`@effect/platform-node`): every filesystem failure during `create-agent-bundle` now surfaces once, at the CLI boundary, with the same Node error text and exit codes as before; the published tarball grows from 33 kB to 110 kB. (#501) |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import { Cause, Effect, Exit } from 'effect'; | ||
| import { PlatformError } from 'effect/PlatformError'; | ||
|
|
||
| /** | ||
| * The sole Effect → Promise edge for `create-agent-bundle`. | ||
| * | ||
| * The scaffolder's filesystem work runs as Effect programs over the | ||
| * `FileSystem` / `Path` services; `runCli` provides the Node platform layer | ||
| * and crosses back to the bin's Promise contract here. Nothing in this module | ||
| * is exported from the package. See `docs/effect-conventions.md`. | ||
| * | ||
| * Error mapping keeps the CLI's observable contract: `UsageError` (exit 2) | ||
| * and every other `Error` (exit 1, message printed) rethrow unchanged, and a | ||
| * `PlatformError` unwraps to the Node error it wraps, so a failed read still | ||
| * reports `ENOENT: no such file or directory, open '...'` — the message the | ||
| * scaffolder printed before the filesystem moved onto Effect. | ||
| */ | ||
|
|
||
| const abortError = (cause: unknown): DOMException => { | ||
| const error = new DOMException('The operation was aborted', 'AbortError'); | ||
| error.cause = cause; | ||
| return error; | ||
| }; | ||
|
|
||
| /** | ||
| * `FileSystem` and `Path` fail with `PlatformError` whose `cause` is the | ||
| * original `NodeJS.ErrnoException`. The CLI's user-facing messages are | ||
| * built from that Node error, so the wrapper is peeled off here. | ||
| */ | ||
| export const toCliError = (value: unknown): Error => { | ||
| if (value instanceof PlatformError) { | ||
| return value.cause instanceof Error ? value.cause : value; | ||
| } | ||
| if (value instanceof Error) return value; | ||
| return new Error(String(value)); | ||
| }; | ||
|
|
||
| /** The message a failed platform operation prints: the Node error's, when there is one. */ | ||
| export const describeError = (value: unknown): string => toCliError(value).message; | ||
|
|
||
| export const mapCause = <E>(cause: Cause.Cause<E>): Error => { | ||
| if (Cause.hasInterruptsOnly(cause)) return abortError(cause); | ||
| return toCliError(Cause.squash(cause)); | ||
| }; | ||
|
|
||
| /** Promise edge. Typed CLI failures rethrow as-is; platform failures unwrap to their Node cause. */ | ||
| export const runPromise = async <A, E>(effect: Effect.Effect<A, E>): Promise<A> => { | ||
| const exit = await Effect.runPromiseExit(effect); | ||
| if (Exit.isSuccess(exit)) return exit.value; | ||
| throw mapCause(exit.cause); | ||
| }; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { Effect } from 'effect'; | ||
|
|
||
| import { toCliError } from './boundary.ts'; | ||
|
|
||
| /** | ||
| * Lifts for the scaffolder's remaining Promise/sync helpers (gunzip, | ||
| * `JSON.parse`, the package-manager child process, the Clack prompts). The | ||
| * thrown/rejected value stays identity-preserved when it already is an | ||
| * `Error` — the CLI's `UsageError` contract crosses `src/effect/boundary.ts` | ||
| * untouched — and anything else is normalized to one, so the fail channel is | ||
| * typed `Error`, never `unknown`. | ||
| */ | ||
|
|
||
| export const liftPromise = <A>(evaluate: () => PromiseLike<A>): Effect.Effect<A, Error> => | ||
| Effect.tryPromise({ catch: toCliError, try: evaluate }); | ||
|
|
||
| export const liftTry = <A>(evaluate: () => A): Effect.Effect<A, Error> => | ||
| Effect.try({ catch: toCliError, try: evaluate }); |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding
effect-rstesthere creates a third pkg.pr.new preview pin, butdocs/effect-conventions.mdstill records only theagent-bundleandrsc-runtimepins and instructs the eventual release chore to replace “both” URLs. Wheneffect-rstestis 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 👍 / 👎.
There was a problem hiding this comment.
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-rstestpreview pin now listspackages/create-agent-bundleas the third devDependency and the release step says "replace all three preview URLs".