OpenForm
CLICommands

attach

Last updated on

Attach files to artifacts as layers or content references

Attaches a file to an artifact as a layer or content reference.

Usage

ofm attach <artifact> <file> [options]

Arguments

ArgumentDescription
artifactArtifact file (JSON/YAML) to attach file to
fileFile to attach (PDF, image, Markdown, etc.)

Options

OptionDescription
-y, --yesSkip interactive prompts
-n, --name <name>Layer name (key in layers object)
-t, --title <title>Human-readable title
-d, --description <desc>Description text
-m, --mime-type <type>Override auto-detected MIME type
--dry-runShow what would be changed without modifying the file
--as <target>Attach as: layer (default), instructions, or agent-instructions

Description

The attach command adds a file reference to an artifact. It computes the relative path from the artifact directory and a SHA-256 checksum, then writes the result back to the artifact file.

By default, the file is attached as a layer. Use --as instructions or --as agent-instructions to attach the file as a content reference instead.

In interactive mode (without -y), the command prompts for a layer name, title, and description. The layer name defaults to a sanitized version of the filename. In non-interactive mode, a name is derived automatically or can be set with --name.

If the target content reference already exists, you will be prompted to confirm the overwrite (unless -y is set).

MIME type is auto-detected from the file extension. Use --mime-type to override.

Examples

Attach a PDF as a layer (interactive):

ofm attach my-form.yaml ./lease-template.pdf

Attach a layer with explicit options:

ofm attach my-form.yaml ./lease-template.pdf --name pdf --title "Lease Template" -y

Attach a file as instructions:

ofm attach my-form.yaml ./instructions.md --as instructions

Attach a file as agent instructions:

ofm attach my-form.yaml ./agent-guide.md --as agent-instructions

Preview changes without writing:

ofm attach my-form.yaml ./lease-template.pdf --dry-run

Output

When attaching as a layer:

Attach File to Artifact

File: ./lease-template.pdf
MIME type: application/pdf
Checksum: sha256:abc123...

Layer to add:
  layers.pdf:
    kind: file
    path: ./lease-template.pdf
    mimeType: application/pdf
    checksum: sha256:abc123...

Attached "pdf" layer to: my-form.yaml

When attaching as a content reference:

Content reference to set:
  instructions:
    kind: file
    path: ./instructions.md
    mimeType: text/markdown
    checksum: sha256:def456...

Set "instructions" on: my-form.yaml

Supported file types

TypeMIME Type
PDFapplication/pdf
PNGimage/png
JPEGimage/jpeg
GIFimage/gif
SVGimage/svg+xml
HTMLtext/html
Markdowntext/markdown

See also

  • detach - Remove layers or content references
  • fix - Compute checksums for attached files
  • render - Render artifact layers

On this page