Skip to content

Add 'cratis arc screenplay' to fetch a .play file from a running Arc application #44

Description

@woksin

Problem / motivation

We are adding a Cratis.Arc.Screenplay package to the Arc repo that generates a Screenplay .play file describing an Arc application's full event model — concepts, modules, features, slices, commands, events, validation, authorization, constraints, queries, reactors and projections.

It surfaces the result the same way Arc already surfaces its other introspection data: a new endpoint

GET /.cratis/screenplay        → text/plain, the .play source

alongside the existing /.cratis/commands and /.cratis/queries.

What is missing is the CLI side. The point of generating a .play file is to get it into Cratis Studio, and today there is no command to fetch one, write it to disk, or import it.

Proposed solution

A cratis arc screenplay command under the existing arc branch, following the exact pattern of arc commands list / arc queries list (Source/Cli/Commands/Arc/):

cratis arc screenplay                              # print .play to stdout
cratis arc screenplay -o Library.play              # write to a file
cratis arc screenplay --url http://localhost:5100  # non-default app URL

It should subclass ArcCommand<T> so it inherits ArcSettings.ResolveUrl() (flag → ARC_URL env var → launch settings → default) and the standard "cannot connect" handling, then GET {url}/.cratis/screenplay and emit the body.

Note this endpoint returns text/plain, not JSON — unlike the existing introspection commands, the response is the artifact itself. So OutputFormatter's table/JSON shaping does not apply; the raw body is the output. Worth confirming how that should interact with the global -o/--output format flag, since -o is currently the format switch — an output file may need a different flag name (e.g. --file/-f) to avoid a collision.

Alternatives considered

  • Generating the file in the CLI itself, by loading the app's assemblies offline. Rejected upstream: fluent IProjectionFor<T> and IConstraint definitions only materialise when Define() is actually executed, which needs a live DI container. The in-process endpoint gets full fidelity; an offline loader silently drops DI-dependent artifacts.
  • Having Studio pull directly from the running app. Skips the CLI entirely, but loses the ability to diff a .play file in source control, and requires Studio to reach the developer's machine.

Additional context

Depends on the Arc-side endpoint landing first — that work is in progress in the Arc repo (Cratis.Arc.Screenplay). This issue can be picked up as soon as /.cratis/screenplay is available.

Acceptance criteria

  • cratis arc screenplay fetches /.cratis/screenplay from the resolved URL and writes the .play source to stdout.
  • A flag writes the output to a file instead, without mangling it (exact bytes, trailing newline preserved — Screenplay output ends with exactly one \n).
  • URL resolution, connection-failure messaging and exit codes match the existing arc commands list behavior.
  • Non-success HTTP status produces the standard server-error exit code and message.
  • Carries [CliCommand], [CliExample] and [LlmDescription] attributes consistent with the sibling Arc commands.
  • Specs in Source/Cli.Specs covering: successful fetch, write-to-file, server error, and connection failure.
  • Documented under Documentation/arc/.

Follow-up (separate issue, not this one)

Importing the generated .play into Studio — either cratis arc screenplay --import or a dedicated cratis studio import command. Worth designing once the fetch path exists and we know what Studio's import contract looks like.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions