mermaid-cli 0.14.0

Open-source AI pair programmer with agentic capabilities. Local-first with Ollama, native tool calling, and beautiful TUI.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
name: Release

on:
  push:
    tags:
      - 'v*.*.*'
  workflow_dispatch:
    inputs:
      version:
        description: 'Version to release (e.g., v0.1.0)'
        required: true
        type: string

env:
  CARGO_TERM_COLOR: always

jobs:
  # Fail fast if the tag and Cargo.toml version disagree. Otherwise a tag pushed
  # without the version bump publishes artifacts (and a Homebrew formula whose
  # `mermaid version` test then fails) that report the previous version — first
  # noticed at users' machines, not in CI.
  verify-version:
    name: Verify tag matches Cargo.toml
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
      - name: Compare tag to Cargo.toml version
        run: |
          set -euo pipefail
          TAG="${{ github.event.inputs.version || github.ref_name }}"
          CARGO_VERSION=$(grep -m1 '^version = ' Cargo.toml | sed -E 's/^version = "(.*)"/\1/')
          echo "release tag: $TAG / Cargo.toml: v$CARGO_VERSION"
          if [ "$TAG" != "v$CARGO_VERSION" ]; then
            echo "::error::Release tag $TAG does not match Cargo.toml version v$CARGO_VERSION"
            exit 1
          fi

  # Create release and build binaries
  release:
    name: Release - ${{ matrix.platform.release_for }}
    needs: [verify-version]
    strategy:
      fail-fast: false
      matrix:
        platform:
          - release_for: Linux-x86_64
            os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            bin: mermaid
            daemon_bin: mermaidd
            package_suffix: linux-x86_64
            name: mermaid-linux-x86_64.tar.gz
            command: build

          - release_for: Linux-aarch64
            os: ubuntu-latest
            target: aarch64-unknown-linux-gnu
            bin: mermaid
            daemon_bin: mermaidd
            package_suffix: linux-aarch64
            name: mermaid-linux-aarch64.tar.gz
            command: build

          - release_for: Windows-x86_64
            os: windows-latest
            target: x86_64-pc-windows-msvc
            bin: mermaid.exe
            daemon_bin: mermaidd.exe
            name: mermaid-windows-x86_64.zip
            command: build

          - release_for: macOS-x86_64
            os: macos-latest
            target: x86_64-apple-darwin
            bin: mermaid
            daemon_bin: mermaidd
            name: mermaid-macos-x86_64.tar.gz
            command: build

          - release_for: macOS-aarch64
            os: macos-latest
            target: aarch64-apple-darwin
            bin: mermaid
            daemon_bin: mermaidd
            name: mermaid-macos-aarch64.tar.gz
            command: build

    runs-on: ${{ matrix.platform.os }}
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

      - name: Install Rust
        uses: dtolnay/rust-toolchain@67ef31d5b988238dd797d409d6f9574278e20537 # master
        with:
          toolchain: stable
          targets: ${{ matrix.platform.target }}

      - name: Cache cargo registry
        uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2

      # Install cross-compilation tools for Linux ARM64
      - name: Install cross-compilation tools
        if: matrix.platform.target == 'aarch64-unknown-linux-gnu'
        run: |
          sudo apt-get update
          sudo apt-get install -y gcc-aarch64-linux-gnu

      - name: Build binary
        shell: bash
        run: |
          if [ "${{ matrix.platform.target }}" = "aarch64-unknown-linux-gnu" ]; then
            export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
          fi
          cargo build --verbose --release --target ${{ matrix.platform.target }}

      - name: Package as archive (Linux/macOS)
        if: contains(matrix.platform.os, 'ubuntu') || contains(matrix.platform.os, 'macos')
        run: |
          cd target/${{ matrix.platform.target }}/release
          tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} ${{ matrix.platform.daemon_bin }}
          cd -

      - name: Package as ZIP (Windows)
        if: contains(matrix.platform.os, 'windows')
        run: |
          cd target/${{ matrix.platform.target }}/release
          7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} ${{ matrix.platform.daemon_bin }}
          cd -

      - name: Install Linux packaging tools
        if: contains(matrix.platform.os, 'ubuntu')
        run: |
          cargo install cargo-deb --locked
          cargo install cargo-generate-rpm --locked

      - name: Package Linux distro artifacts
        if: contains(matrix.platform.os, 'ubuntu')
        shell: bash
        run: |
          cargo deb --no-build --target ${{ matrix.platform.target }} --output mermaid-cli-${{ matrix.platform.package_suffix }}.deb
          cargo generate-rpm --target ${{ matrix.platform.target }} --output mermaid-cli-${{ matrix.platform.package_suffix }}.rpm

      - name: Upload artifacts
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: ${{ matrix.platform.name }}
          path: ${{ matrix.platform.name }}

      - name: Upload Linux distro artifacts
        if: contains(matrix.platform.os, 'ubuntu')
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: mermaid-packages-${{ matrix.platform.package_suffix }}
          path: |
            mermaid-cli-${{ matrix.platform.package_suffix }}.deb
            mermaid-cli-${{ matrix.platform.package_suffix }}.rpm

  # Create GitHub release and attach binaries
  publish:
    name: Publish Release
    needs: [release]
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
        with:
          # Full history + tags so the changelog step's `git describe` can find
          # the previous tag; a shallow clone made it always emit "First release".
          fetch-depth: 0

      - name: Download artifacts
        uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
        with:
          path: ./artifacts

      - name: Generate changelog
        id: changelog
        run: |
          # Get the previous tag
          PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
          if [ -z "$PREV_TAG" ]; then
            echo "First release" > CHANGELOG.md
          else
            echo "## Changes since $PREV_TAG" > CHANGELOG.md
            git log $PREV_TAG..HEAD --pretty=format:"- %s" >> CHANGELOG.md
          fi

      - name: Generate SHA256 checksums
        run: |
          find artifacts -type f | while IFS= read -r f; do
            ( cd "$(dirname "$f")" && sha256sum "$(basename "$f")" )
          done | sort -k2 > SHA256SUMS
          cat SHA256SUMS

      - name: Create Release
        uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3.0.1
        with:
          # Explicit tag so the manual `workflow_dispatch` path (which runs off a
          # branch, not a tag ref) still creates/targets the right release; on a
          # tag push this equals the pushed tag.
          tag_name: ${{ github.event.inputs.version || github.ref_name }}
          files: |
            ./artifacts/**/*
            SHA256SUMS
          draft: false
          prerelease: false
          generate_release_notes: true
          body_path: CHANGELOG.md
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  # Optional: Publish to crates.io
  publish-crate:
    name: Publish to crates.io
    needs: [release]
    runs-on: ubuntu-latest
    # Only run if explicitly enabled (requires CARGO_REGISTRY_TOKEN secret)
    if: ${{ vars.PUBLISH_TO_CRATES_IO == 'true' }}
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

      - name: Install Rust
        uses: dtolnay/rust-toolchain@67ef31d5b988238dd797d409d6f9574278e20537 # master
        with:
          toolchain: stable

      - name: Publish to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: |
          # Publish the workspace library first, then the binary crate that
          # depends on it. Recent cargo waits for the dependency to appear on
          # the index before publishing the dependent crate.
          cargo publish -p mermaid-runtime
          cargo publish -p mermaid-cli

  # Bump the Homebrew tap + Scoop bucket to the new release. This is a no-op
  # until TAP_TOKEN is set — a PAT (Contents: read/write) on
  # noahsabaj/homebrew-mermaid and noahsabaj/scoop-mermaid. No other setup.
  publish-packages:
    name: Publish package managers
    needs: [publish]
    runs-on: ubuntu-latest
    steps:
      - name: Check for TAP_TOKEN
        id: gate
        env:
          TAP_TOKEN: ${{ secrets.TAP_TOKEN }}
        run: |
          if [ -n "$TAP_TOKEN" ]; then
            echo "enabled=true" >> "$GITHUB_OUTPUT"
          else
            echo "TAP_TOKEN not set — skipping Homebrew/Scoop bump."
            echo "enabled=false" >> "$GITHUB_OUTPUT"
          fi

      - name: Resolve version + checksums
        if: steps.gate.outputs.enabled == 'true'
        id: rel
        run: |
          set -euo pipefail
          TAG="${{ github.event.inputs.version || github.ref_name }}"
          VERSION="${TAG#v}"
          curl -fsSL -o SHA256SUMS \
            "https://github.com/noahsabaj/mermaid-cli/releases/download/${TAG}/SHA256SUMS"
          h() { grep " mermaid-$1$" SHA256SUMS | awk '{print $1}'; }
          {
            echo "tag=$TAG"
            echo "version=$VERSION"
            echo "mac_arm=$(h macos-aarch64.tar.gz)"
            echo "mac_x86=$(h macos-x86_64.tar.gz)"
            echo "lin_arm=$(h linux-aarch64.tar.gz)"
            echo "lin_x86=$(h linux-x86_64.tar.gz)"
            echo "win_x86=$(h windows-x86_64.zip)"
          } >> "$GITHUB_OUTPUT"

      - name: Update Homebrew tap
        if: steps.gate.outputs.enabled == 'true'
        env:
          TAP_TOKEN: ${{ secrets.TAP_TOKEN }}
          TAG: ${{ steps.rel.outputs.tag }}
          VERSION: ${{ steps.rel.outputs.version }}
          MAC_ARM: ${{ steps.rel.outputs.mac_arm }}
          MAC_X86: ${{ steps.rel.outputs.mac_x86 }}
          LIN_ARM: ${{ steps.rel.outputs.lin_arm }}
          LIN_X86: ${{ steps.rel.outputs.lin_x86 }}
        run: |
          set -euo pipefail
          git clone "https://x-access-token:${TAP_TOKEN}@github.com/noahsabaj/homebrew-mermaid.git" tap
          cat > tap/Formula/mermaid.rb <<RUBY
          class Mermaid < Formula
            desc "Open-source, model-agnostic AI pair programmer for the terminal"
            homepage "https://github.com/noahsabaj/mermaid-cli"
            version "${VERSION}"
            license any_of: ["MIT", "Apache-2.0"]

            on_macos do
              on_arm do
                url "https://github.com/noahsabaj/mermaid-cli/releases/download/${TAG}/mermaid-macos-aarch64.tar.gz"
                sha256 "${MAC_ARM}"
              end
              on_intel do
                url "https://github.com/noahsabaj/mermaid-cli/releases/download/${TAG}/mermaid-macos-x86_64.tar.gz"
                sha256 "${MAC_X86}"
              end
            end

            on_linux do
              on_arm do
                url "https://github.com/noahsabaj/mermaid-cli/releases/download/${TAG}/mermaid-linux-aarch64.tar.gz"
                sha256 "${LIN_ARM}"
              end
              on_intel do
                url "https://github.com/noahsabaj/mermaid-cli/releases/download/${TAG}/mermaid-linux-x86_64.tar.gz"
                sha256 "${LIN_X86}"
              end
            end

            def install
              bin.install "mermaid"
              bin.install "mermaidd"
            end

            test do
              assert_match "Mermaid v#{version}", shell_output("#{bin}/mermaid version")
            end
          end
          RUBY
          cd tap
          if git diff --quiet; then echo "Homebrew tap already current"; exit 0; fi
          git -c user.name="github-actions[bot]" \
              -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
              commit -am "mermaid ${VERSION}"
          git push

      - name: Update Scoop bucket
        if: steps.gate.outputs.enabled == 'true'
        env:
          TAP_TOKEN: ${{ secrets.TAP_TOKEN }}
          TAG: ${{ steps.rel.outputs.tag }}
          VERSION: ${{ steps.rel.outputs.version }}
          WIN_X86: ${{ steps.rel.outputs.win_x86 }}
        run: |
          set -euo pipefail
          git clone "https://x-access-token:${TAP_TOKEN}@github.com/noahsabaj/scoop-mermaid.git" bucket
          cat > bucket/bucket/mermaid.json <<JSON
          {
              "version": "${VERSION}",
              "description": "Open-source, model-agnostic AI pair programmer for the terminal.",
              "homepage": "https://github.com/noahsabaj/mermaid-cli",
              "license": "MIT OR Apache-2.0",
              "architecture": {
                  "64bit": {
                      "url": "https://github.com/noahsabaj/mermaid-cli/releases/download/${TAG}/mermaid-windows-x86_64.zip",
                      "hash": "${WIN_X86}"
                  }
              },
              "bin": [
                  "mermaid.exe",
                  "mermaidd.exe"
              ],
              "checkver": {
                  "github": "https://github.com/noahsabaj/mermaid-cli"
              },
              "autoupdate": {
                  "architecture": {
                      "64bit": {
                          "url": "https://github.com/noahsabaj/mermaid-cli/releases/download/v\$version/mermaid-windows-x86_64.zip"
                      }
                  },
                  "hash": {
                      "url": "https://github.com/noahsabaj/mermaid-cli/releases/download/v\$version/SHA256SUMS"
                  }
              }
          }
          JSON
          cd bucket
          if git diff --quiet; then echo "Scoop bucket already current"; exit 0; fi
          git -c user.name="github-actions[bot]" \
              -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
              commit -am "mermaid ${VERSION}"
          git push

  # Bump the WinGet package (NoahSabaj.Mermaid) by opening a PR to
  # microsoft/winget-pkgs. No-op until WINGET_TOKEN is set — a *classic* PAT
  # with `public_repo` scope, owned by the account that holds the fork of
  # microsoft/winget-pkgs (fine-grained PATs are NOT supported by the action).
  # The action only *bumps* an existing package; the first version of
  # NoahSabaj.Mermaid is seeded manually once.
  publish-winget:
    name: Publish to WinGet
    needs: [publish]
    runs-on: ubuntu-latest
    steps:
      - name: Check for WINGET_TOKEN
        id: gate
        env:
          WINGET_TOKEN: ${{ secrets.WINGET_TOKEN }}
        run: |
          if [ -n "$WINGET_TOKEN" ]; then
            echo "enabled=true" >> "$GITHUB_OUTPUT"
          else
            echo "WINGET_TOKEN not set — skipping WinGet submission."
            echo "enabled=false" >> "$GITHUB_OUTPUT"
          fi

      - name: Resolve version
        if: steps.gate.outputs.enabled == 'true'
        id: ver
        run: |
          TAG="${{ github.event.inputs.version || github.ref_name }}"
          echo "tag=$TAG" >> "$GITHUB_OUTPUT"
          echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"

      - name: Submit to WinGet
        if: steps.gate.outputs.enabled == 'true'
        # The action only *bumps* an existing winget-pkgs entry; until
        # NoahSabaj.Mermaid is seeded (microsoft/winget-pkgs#391817, pending
        # upstream review) this step fails. Tolerate it so the release run stays
        # green — it becomes a no-op once the seed lands and the bump succeeds.
        # Remove this line then.
        continue-on-error: true
        uses: vedantmgoyal9/winget-releaser@4ffc7888bffd451b357355dc214d43bb9f23917e # v2
        with:
          identifier: NoahSabaj.Mermaid
          version: ${{ steps.ver.outputs.version }}
          installers-regex: 'mermaid-windows-x86_64\.zip$'
          release-tag: ${{ steps.ver.outputs.tag }}
          fork-user: noahsabaj
          token: ${{ secrets.WINGET_TOKEN }}