# meld

> Meld: A template language for LLM prompts

Latest version **10.3.1** (published 2025-03-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install meld
pnpm add meld
yarn add meld
bun add meld
```

Provides the command `meld`.

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; large bundle.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 10.3.1 |
| Published | 2025-03-12 |
| First published | 2012-07-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 18 |
| Unpacked size | 11.2 MB |
| Known vulnerabilities | 0 (+16 in 1 direct dependencies) |
| Install scripts | yes |
| Author | Adam Avenir |
| Maintainers | adamavenir |
| Keywords | meld, interpreter, language, llm, prompt, cli |

## Links

- npm: https://www.npmjs.com/package/meld
- Repository: https://github.com/adamavenir/meld
- Homepage: https://github.com/adamavenir/meld#readme
- Issues: https://github.com/adamavenir/meld/issues
- npm.io page: https://npm.io/package/meld

## Dependencies (18)

- [glob](https://npm.io/package/glob.md) ^11.0.1
- [uuid](https://npm.io/package/uuid.md) ^11.1.0
- [chalk](https://npm.io/package/chalk.md) ^4.1.2
- [peggy](https://npm.io/package/peggy.md) ^4.2.0
- [yargs](https://npm.io/package/yargs.md) ^17.7.2
- [llmxml](https://npm.io/package/llmxml.md) ^1.4.0
- [marked](https://npm.io/package/marked.md) ^4.0.12
- [xmldom](https://npm.io/package/xmldom.md) ^0.6.0
- [winston](https://npm.io/package/winston.md) ^3.17.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^11.3.0
- [meld-ast](https://npm.io/package/meld-ast.md) ^3.4.3
- [tsyringe](https://npm.io/package/tsyringe.md) ^4.8.0
- [commander](https://npm.io/package/commander.md) ^13.1.0
- [meld-spec](https://npm.io/package/meld-spec.md) ^0.4.1
- [minimatch](https://npm.io/package/minimatch.md) ^3.0.4
- [@types/uuid](https://npm.io/package/@types/uuid.md) ^10.0.0
- [@types/xmldom](https://npm.io/package/@types/xmldom.md) ^0.1.34
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.2.2

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 10.3.1 (latest) — 2025-03-12
- 10.3.0 — 2025-03-07
- 10.2.4 — 2025-03-06
- 10.2.3 — 2025-03-06
- 10.2.2 — 2025-03-06
- 10.2.1 — 2025-03-06
- 10.1.2 — 2025-03-06
- 10.1.1 — 2025-03-06
- 10.1.0 — 2025-03-06
- 10.0.2 — 2025-03-06
- 10.0.1 — 2025-03-06
- 10.0.0 — 2025-02-20
- 1.3.2 — 2015-04-21
- 1.3.1 — 2014-04-18
- 1.3.0 — 2013-04-23
- … 11 more at https://npm.io/package/meld/versions

## README

**NOTE:** If you're looking for [the old 'meld' package for aspect oriented programming](https://www.npmjs.com/package/meld/v/1.3.2), you'll want to pin your version to `<2.0.0`

---

# meld (pre-release)

meld is a prompt scripting language.

## Installation

```bash
npm install -g meld
```

or just run it with `npx meld`

## CLI Usage

Process meld files from the command line:

```bash
# Basic usage - outputs .xml file
meld input.mld

# Specify output format
meld input.mld --format md

# Specify output file
meld input.mld --output output.xml

# Print to stdout instead of file
meld input.mld --stdout
```

### Supported Options

- `--format, -f`: Output format (default: md)
  - Supported formats: md, xml
- `--output, -o`: Output file path (default: input filename with new extension)
- `--stdout`: Print to stdout instead of file

### Supported File Extensions

- `.mld` is standard `.mld.md` is another option.
- `.md`: Meld can just interpret regular old markdown files with added meld syntax, too.

## JavaScript API

Meld has a fairly extensive js API which give access to its AST, interpreted variables, etc., but it's not documented yet. However, here's meld's simple API for processing content directly:

```javascript
// ES Module import
import runMeld from 'meld';

// Process meld content
const meldContent = `
  @text greeting = "Hello"
  @text name = "World"
  
  ${greeting}, ${name}!
`;

// Simple usage
const result = await runMeld(meldContent);
console.log(result); // "Hello, World!"

// With options
const xmlResult = await runMeld(meldContent, {
  format: 'xml',
  transformation: true
});
```

## Writing Meld Files

Meld is a simple scripting language designed to work within markdown-like documents. It processes special `@directive` lines while preserving all other content as-is.

### Core Directives

```meld
@text name = "value"              # Define a text variable
@data config = { "key": "value" } # Define a structured data variable
@path docs = "$PROJECTPATH/docs"  # Define a path (must use $PROJECTPATH or $HOMEPATH)
@embed [file.md]                  # Embed content from another file
@embed [file.md # section]        # Embed specific section from file
@run [command]                    # Run a shell command
@import [file.mld]               # Import another meld file
@define cmd = @run [echo "hi"]    # Define a reusable command
```

### Variables & Interpolation

```meld
{{variable}}            # Reference a variable
{{datavar.field}}       # Access data field
$pathvar                # Reference a path variable

# Variables can be used in strings and commands:
@text greeting = "Hello {{name}}!"
@run [cat {{file}}]
```

### Comments & Code Fences

```meld
>> This is a comment
>> Comments must start at line beginning

# Code fences preserve content exactly:
```python
def hello():
    print("Hi")  # @text directives here are preserved as-is
```
```

### String Values

- Use single quotes, double quotes, or backticks
- Quotes must match (no mixing)
- Use backticks for template strings with variables:
```meld
@text simple = "Hello"
@text template = `Hello {{name}}!`
@text multiline = [[`
  Multi-line
  template with {{vars}}
`]]
```

### Path Variables

- Must use `$PROJECTPATH` (or `$.`) or `$HOMEPATH` (or `$~`)
- Forward slashes as separators
```meld
@path docs = "$PROJECTPATH/docs"
@path home = "$HOMEPATH/meld"
```

### Data Variables

- Store structured data (objects/arrays)
- Support field access
```meld
@data user = { "name": "Alice", "id": 123 }
@text name = "User: {{user.name}}"
```

## License

[MIT](LICENSE)

---
_Source: https://npm.io/package/meld · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
