Skip to content
Back to search

ade

SkillWorks with Claude CodeGitHub

Parse documents and extract schema-shaped data with the ADE (Agentic Document Extraction) v2 APIs through the ade CLI. A local job-item store makes every run idempotent, resumable, and citable — repeat runs are free, interrupted runs resume, and every answer can cite element ids with visual evidence.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/landing-ai--ade-cli/badge.svg)](/listings/landing-ai--ade-cli)

HTML

<a href="/listings/landing-ai--ade-cli"><img src="/api/listings/landing-ai--ade-cli/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

These steps run a script from the network that findsafeskills does not scan.

Each release ships self-contained binaries for macOS, Linux, and Windows (arm64 and x86_64). No Python or `uv` needed.

**macOS / Linux**

curl -fsSL https://raw.githubusercontent.com/landing-ai/ade-cli/main/scripts/install.sh | sh

**Windows (PowerShell)**

irm https://raw.githubusercontent.com/landing-ai/ade-cli/main/scripts/install.ps1 | iex

**Windows (CMD)**

curl -fsSL https://raw.githubusercontent.com/landing-ai/ade-cli/main/scripts/install.cmd -o install.cmd && install.cmd && del install.cmd

To develop or install from source, see [CONTRIBUTING.md](CONTRIBUTING.md).

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

SKILL.md · Manifest · 199 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. ---
  2. name: ade
  3. description: Parse documents and extract schema-shaped data with the ADE (Agentic Document Extraction) v2 APIs through the ade CLI. A local job-item store makes every run idempotent, resumable, and citable — repeat runs are free, interrupted runs resume, and every answer can cite element ids with visual evidence.
  4. ---
  5. # ade — agent skill
  6. ade drives the ADE (Agentic Document Extraction) v2 document APIs
  7. (parse, extract) and persists
  8. everything it produces in a local store under `~/.ade`. You are the
  9. judgment; the CLI is deterministic plumbing: it parses, persists,
  10. searches, renders, and totals — it never ranks or selects for you.
  11. ## First move
  12. ```
  13. ade help --json
  14. ```
  15. One call returns the whole shipped surface: every command and flag, each
  16. verb's `--json` result shape, the exit states, and the store layout.
  17. Prefer it over N `--help` round trips. `ade help workflow` (also
  18. `output`, `credentials`, `errors`) is the conceptual page behind it.
  19. Check credentials with `ade auth status --json`; if logged out, set
  20. `ADE_API_KEY`, or pipe a key in (`echo $KEY | ade auth login`) — no
  21. terminal required either way. An API key acts in the organization it
  22. was created in; browser (OAuth) sessions carry their own selection —
  23. `status` reports it, `ade auth org list --json` shows the memberships,
  24. and `ade auth org switch <org> --env <env>` changes it. If a run must
  25. bill to a specific organization, confirm the selection *before*
  26. parsing: re-running the same invocation after a switch joins the
  27. recorded run instead of re-billing under the new organization.
  28. ## Conventions
  29. - **Always pass `--json`.** Every command emits one stable JSON
  30. object/array on stdout — errors and pending payloads included. Human
  31. text is for terminals, not for parsing. The **whole result is on
  32. stdout**: the extraction, the matches, the paths. Reading the store is
  33. a convenience, never a requirement — and `ade help --json` publishes
  34. each verb's shape, so you never have to discover it by running.
  35. - **`--id-only` when you only need the id.** `parse`, `extract`, and
  36. `find` take it: the id(s), one per line, nothing else —
  37. `JOB=$(ade parse -d report.pdf --id-only)`. Errors go to stderr, so a
  38. captured id is never a sentence.
  39. - **Job item ids are the currency.** Every parse or extract run is a
  40. *job item*: one folder under `~/.ade/jobs/<job-item-id>/`, keyed by the
  41. invocation (verb × environment × source × content × params; URL
  42. sources are keyed by the URL alone — no content component, so remote
  43. drift does not re-key). Commands accept an
  44. unambiguous id prefix. Changing the file, its path, or any param mints
  45. a *sibling* item — nothing is silently replaced.
  46. - **Commands are guarantees.** `parse` means "ensure this exact run
  47. exists", not "fire a request". Re-running an already-done invocation is
  48. **free** — served from disk with an `already parsed` notice and
  49. `"cached": true`. Only `--force` re-bills.
  50. ## The loop
  51. 1. **Parse** (free if already done):
  52. ```
  53. ade parse -d report.pdf --json
  54. ```
  55. The payload carries `job_item_id` — hold onto it. Everything else
  56. keys off it. The markdown and the elements projection stay on disk
  57. unless you ask for them: `--include markdown`, `--include elements`.
  58. 2. **Discover element ids** (local, instant, no API call):
  59. ```
  60. ade find JOB_ITEM_ID "total revenue" --json
  61. ade find JOB_ITEM_ID --type table_cell --page 3 --json
  62. ```
  63. (`--job JOB_ITEM_ID` is the equivalent flag spelling — repeat it to search
  64. several items in one call.)
  65. Matches are citation records: `{job_item_id, element_id, type, page,
  66. box, text}`. Filters compose (AND); results come in document order,
  67. never ranked — selection is your job.
  68. 3. **Extract** structured data against a JSON Schema:
  69. ```
  70. ade extract JOB_ITEM_ID --schema schema.json --json
  71. ```
  72. The result is its own job item. The payload's `extraction` key is the
  73. schema-shaped result itself — read it there, not off disk. Per-field
  74. evidence (`evidence`, persisted as `evidence.json`) joins extraction
  75. spans to element ids, pages, and boxes — non-empty fields the model
  76. synthesised rather than quoted are flagged `ungroundable`;
  77. empty-valued fields (blank cells, absent optionals — nothing to
  78. ground) are labeled `empty`. Neither is ever silently dropped.
  79. 4. **Cite and show.** `ade view JOB_ITEM_ID --json` builds a
  80. self-contained HTML viewer; deep links are the citation contract:
  81. ```
  82. ade view JOB_ITEM_ID --element-id ELEMENT_ID --json # emits view.html#element=ELEMENT_ID
  83. ade crop JOB_ITEM_ID --element-id ELEMENT_ID --json # PNG of that element's region
  84. ade crop JOB_ITEM_ID --type figure --json # every figure, one command
  85. ```
  86. End answers with one deep link per job item, citing element ids.
  87. Use `crop` when you need to *look at* evidence mid-reasoning — it
  88. takes `find`'s own filters (`--type`, `--page`, `--all`), so a
  89. selection crops in one call and returns `crops[]`; never loop `find`
  90. into `crop` yourself.
  91. ## Reuse posture — parse bills once
  92. Every parse the CLI ever runs is a reusable job item. Given a document
  93. path, `extract -d FILE --schema …` reuses the latest completed parse of
  94. that path+content (logged in the summary; no parse billed). If none
  95. exists, it runs a **standalone parse first** — a normal, top-level
  96. parse item, exactly as if you had run `parse -d` — then the extraction
  97. referencing it: two billable runs, both itemised. Repeat `extract -d`
  98. runs of the same file then reuse that parse, so it bills exactly once.
  99. Prefer the explicit two-step (`parse -d`, then `extract JOB_ITEM_ID`) when
  100. you want the same parse to feed several schemas — the id makes the reuse
  101. visible.
  102. ## Pending and resume
  103. Wait expiry is a normal outcome, not an error. If the poll budget
  104. (`--wait`, default 600s) runs out, the command exits with code 3 and a
  105. `{"status": "pending", "run_id": …, "job_item_id": …}` payload while the
  106. run continues server-side (submitted work always completes and bills —
  107. there is no cancel). **The recovery gesture is always the same command,
  108. re-run.** A re-run joins the recorded run; it never resubmits and never
  109. re-bills. Interrupts (Ctrl-C) stop the waiting, not the work — same
  110. gesture. `--wait 0` submits and returns immediately.
  111. Submit-and-return, then collect later — the pending payload carries the
  112. id too, so this works in both steps:
  113. ```
  114. JOB=$(ade parse -d report.pdf --wait 0 --id-only) # exit 3, run continuing
  115. ade parse -d report.pdf --json # re-run: resumes, never re-bills
  116. ```
  117. ## Exit codes
  118. | Code | State | Meaning |
  119. |------|-------|---------|
  120. | 0 | ok | Success — the payload is on stdout. |
  121. | 1 | failed | The run failed or the target cannot serve the request. |
  122. | 2 | usage | The invocation itself was wrong; nothing was submitted. |
  123. | 3 | pending | Wait budget expired; the run continues server-side. Re-run the same command to resume. |
  124. | 4 | rate_limited | Submit was rate-limited and the wait budget ran out before a run existed; nothing billed. Re-run to retry. |
  125. ## Reading the store directly
  126. Optional, never required: every result is already on stdout. Artifacts
  127. are plain files — `history list --json` gives every item's records, and
  128. the summaries print each item's store path.
  129. - `parse.json` — raw ParseResponse (ground truth, verbatim)
  130. - `parse.md` — the parse markdown extraction spans index
  131. - `elements.json` — flat element records with inline grounding; boxes
  132. are normalized `{xmin, ymin, xmax, ymax}` fractions of page size in
  133. `[0, 1]`
  134. - `extract.json` — raw extraction result with per-field spans
  135. - `evidence.json` — the field→box join (element ids, pages, boxes)
  136. One vocabulary note when reading these files: on-disk records
  137. (`meta.json`, `job.json`, `parse/ref.json`) spell the server-side run id
  138. as `job_id` — the wire contract's name for the same value `--json`
  139. payloads report as `run_id`. Neither is ever the job item id.
  140. Prefer `find` over loading `elements.json` into context: it returns
  141. joined records, not lines. `history clear JOB_ITEM_ID` deletes an item;
  142. clearing a parse item cascades to the extractions referencing it.
  143. ## Sharp edges
  144. - **`--options` is a verbatim ParseOptions pass-through** — the server
  145. rejects unknown keys with a 422, so consult `ade help parse` for
  146. the accepted keys rather than guessing.
  147. - **Parse variants coexist.** The same document parsed with different
  148. params is a sibling item, not a replacement. An extraction goes stale
  149. only when its exact parse item is re-run in place with `--force`.
  150. - **Moving or editing a file changes identity** — the next parse of it
  151. is a new job item that bills. The old item and its evidence stay
  152. intact and true of the run they came from.
  153. - **`--markdown` extractions have no page evidence** (there is no parse
  154. to join against) — evidence degrades to spans-only, and `view`
  155. renders the markdown pane alone.
  156. - **URL parses have no local bytes**, so page imagery renders from an
  157. attached copy: `parse --document-url … --keep-copy` fetches it at
  158. parse time (reliable — pre-signed URLs expire); otherwise the first
  159. `view`/`crop` downloads it automatically (`--no-download` skips;
  160. the payload records `downloaded`, and on a failed fetch `view`
  161. degrades to an empty preview with `download_error` while `crop`
  162. errors). Markdown, elements, and extractions work either way.
README.md · README · 132 lines · 2 findings marked

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # ade-cli
  2. [![Release](https://img.shields.io/github/v/release/landing-ai/ade-cli)](https://github.com/landing-ai/ade-cli/releases)
  3. [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
  4. **Agentic Document Extraction (ADE), from your terminal.** Run `ade parse` to
  5. turn documents with tables, figures, and charts into grounded Markdown and
  6. elements, and `ade extract` to pull schema-shaped fields with page-and-box
  7. evidence. Both save to a local store at `~/.ade`, so re-running an identical
  8. command consumes no credits.
  9. **[CLI documentation](https://docs.landing.ai/cli/quickstart)** ·
  10. **[Playground](https://ade.landing.ai)** ·
  11. **[Get an API key](https://ade.landing.ai/settings/api-key)**
  12. ## Install
  13. Each release ships self-contained binaries for macOS, Linux, and Windows
  14. (arm64 and x86_64). No Python or `uv` needed.
  15. **macOS / Linux**
  16. ```sh
  17. curl -fsSL https://raw.githubusercontent.com/landing-ai/ade-cli/main/scripts/install.sh | sh
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 24 on GitHub
  18. ```
  19. **Windows (PowerShell)**
  20. ```powershell
  21. irm https://raw.githubusercontent.com/landing-ai/ade-cli/main/scripts/install.ps1 | iex
  22. ```
  23. **Windows (CMD)**
  24. ```bat
  25. curl -fsSL https://raw.githubusercontent.com/landing-ai/ade-cli/main/scripts/install.cmd -o install.cmd && install.cmd && del install.cmd
  26. ```
  27. To develop or install from source, see [CONTRIBUTING.md](CONTRIBUTING.md).
  28. ## First run
  29. Log in once per machine, parse a document, then extract the fields you want
  30. from it. The parse summary prints the job item ID that `extract` takes.
  31. ```sh
  32. ade login
  33. ade parse -d invoice.pdf
  34. ade extract JOB_ITEM_ID --schema schema.json
  35. ```
  36. The [CLI Quickstart](https://docs.landing.ai/cli/quickstart) walks through the
  37. same three steps with a sample document and a sample schema, and ends in the
  38. viewer that shows where each extracted value came from.
  39. ## Commands
  40. Every command takes `--json` for one stable JSON object on stdout. Run
  41. `ade help COMMAND` for its flags and result shape, or see the
  42. [CLI Reference](https://docs.landing.ai/cli/reference).
  43. | command | what it does |
  44. |---|---|
  45. | `ade parse` | Parse a document into Markdown, elements, and grounding |
  46. | `ade extract` | Pull schema-shaped fields from a parse, with per-field evidence |
  47. | `ade find` | Search a parse's elements locally, with no API call |
  48. | `ade crop` | Save an element's region of the page as a PNG |
  49. | `ade view` | Build and open a self-contained HTML viewer for a job item |
  50. | `ade history list` | List stored job items, newest first |
  51. | `ade history clear` | Delete stored job items |
  52. | `ade login` / `ade auth login` | Log in with your browser or an API key |
  53. | `ade auth status` | Show how you are authenticated and where |
  54. | `ade auth org list` / `switch` / `clear` | Choose which organization your runs act in |
  55. | `ade logout` / `ade auth logout` | Log out of one environment, or all of them |
  56. | `ade version` | Print the version and install mode |
  57. | `ade update` | Self-update to the latest release |
  58. | `ade help` | Print the whole command surface, including `--json` result shapes |
  59. The documentation covers what these tables cannot: how job items work and why
  60. re-runs are free ([CLI Concepts](https://docs.landing.ai/cli/concepts)),
  61. [parsing](https://docs.landing.ai/cli/parse) and
  62. [extraction](https://docs.landing.ai/cli/extract) in depth,
  63. [searching and cropping evidence](https://docs.landing.ai/cli/find-crop-view),
  64. [authentication and organizations](https://docs.landing.ai/cli/authentication),
  65. and [scripting the CLI](https://docs.landing.ai/cli/scripting-automation).
  66. ## For agents
  67. Agents are first-class callers. Running `ade help --json` returns the entire
  68. shipped surface in one call: every command, flag, result shape, topic, exit
  69. state, and the store layout. Every command then takes `--json` and emits one
  70. stable object whose shape is published per verb, and the full result is always
  71. on stdout rather than only in a store file.
  72. [`SKILL.md`](SKILL.md) ships the agent contract: the loop, the conventions, and
  73. the sharp edges.
  74. A process that is already running keeps the environment it started with, so
  75. `ade` may not be on the PATH inside CI, cron, or an agent harness. Call the
  76. absolute path instead: `~/.ade/bin/ade` on macOS and Linux, or
  77. `%USERPROFILE%\.ade\bin\ade.exe` on Windows. For credentials, set
  78. `ADE_API_KEY`.
  79. ## Managing your install
  80. | | macOS and Linux | Windows |
  81. |---|---|---|
  82. | App | `~/.ade/bin/ade` | `%USERPROFILE%\.ade\bin\ade.exe` |
  83. | Store | `~/.ade` | `%USERPROFILE%\.ade` |
  84. | Reaches your PATH via | a symlink in `~/.local/bin` | a user PATH entry |
  85. Set `ADE_HOME` to move the app and the store, `ADE_CLI_VERSION` to pin a
  86. version, and `ADE_CLI_INSTALL_DIR` to change the destination.
  87. Run `ade update` to self-update, with `--yes` to skip the confirmation. For a
  88. `uv` or `pipx` install it points at `uv tool upgrade ade-cli` instead. The CLI
  89. mentions new releases on stderr once a day. Set `ADE_NO_UPDATE_CHECK=1` to turn
  90. that off.
  91. To uninstall, remove the app directory, and on macOS and Linux the
  92. `~/.local/bin/ade` symlink too. Never delete all of `.ade`: the rest of that
  93. directory holds results that already consumed credits.
  94. ## Project history
  95. This repository was **`agentic-doc`**, the original Agentic Document Extraction
  96. SDK. That SDK is preserved unchanged, and no longer developed, on the
  97. [`legacy`](https://github.com/landing-ai/ade-cli/tree/legacy) branch. Since
  98. 2026-07-31 this repository ships the ADE CLI.
  99. ## License
  100. [Apache-2.0](LICENSE).
scripts/install.cmd · Bundled script · 23 lines · 1 finding marked
  1. @echo off
  2. rem ade-cli installer for Windows CMD — a thin wrapper that runs the
  3. rem PowerShell installer (install.ps1), the single Windows install body.
  4. rem
  5. rem curl -fsSL https://raw.githubusercontent.com/landing-ai/ade-cli/main/scripts/install.cmd -o install.cmd && install.cmd && del install.cmd
  6. rem
  7. rem Same knobs as install.ps1: ADE_CLI_VERSION, ADE_CLI_INSTALL_DIR, and
  8. rem GITHUB_TOKEN/GH_TOKEN (also used here to fetch install.ps1 itself while
  9. rem the repo is private).
  10. setlocal
  11. set "PS1_URL=https://raw.githubusercontent.com/landing-ai/ade-cli/main/scripts/install.ps1"
  12. where powershell >nul 2>nul
  13. if errorlevel 1 (
  14. echo error: PowerShell is required but was not found on PATH. 1>&2
  15. exit /b 1
  16. )
  17. powershell -NoProfile -ExecutionPolicy Bypass -Command ^
  18. "$t = $env:GITHUB_TOKEN; if (-not $t) { $t = $env:GH_TOKEN };" ^
  19. "$p = @{ Uri = '%PS1_URL%' }; if ($t) { $p.Headers = @{ Authorization = 'Bearer ' + $t } };" ^
  20. "Invoke-RestMethod @p | Invoke-Expression"
  21. exit /b %errorlevel%
scripts/install.ps1 · Bundled script · 116 lines · 1 finding marked
  1. # ade-cli installer for Windows (x86_64 / arm64).
  2. #
  3. # irm https://raw.githubusercontent.com/landing-ai/ade-cli/main/scripts/install.ps1 | iex
    • Note: Runs a downloaded PowerShell script (iex / Invoke-Expression)
    • Line 3 on GitHub
  4. #
  5. # Environment knobs:
  6. # ADE_CLI_VERSION release to install ("0.2.0" or "v0.2.0"; default: latest)
  7. # ADE_CLI_INSTALL_DIR where the app lands: ade.exe plus its _internal\
  8. # support dir (default: %USERPROFILE%\.ade\bin — inside
  9. # the CLI's own home, next to the store; honors ADE_HOME)
  10. # GITHUB_TOKEN/GH_TOKEN required while the repo is private; downloads go
  11. # through the GitHub API instead of the public URL.
  12. #
  13. # Uninstall: remove %USERPROFILE%\.ade\bin (ade.exe and its _internal\
  14. # support dir). Never delete all of .ade — the rest of that directory is
  15. # your local store (billed results).
  16. $ErrorActionPreference = "Stop"
  17. $Repo = "landing-ai/ade-cli"
  18. $InstallDir = if ($env:ADE_CLI_INSTALL_DIR) { $env:ADE_CLI_INSTALL_DIR }
  19. elseif ($env:ADE_HOME) { Join-Path $env:ADE_HOME "bin" }
  20. else { Join-Path $env:USERPROFILE ".ade\bin" }
  21. $Version = if ($env:ADE_CLI_VERSION) { $env:ADE_CLI_VERSION } else { "latest" }
  22. $Token = if ($env:GITHUB_TOKEN) { $env:GITHUB_TOKEN } elseif ($env:GH_TOKEN) { $env:GH_TOKEN } else { $null }
  23. # --- pick the release asset for this machine --------------------------------
  24. $target = switch ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) {
  25. "Arm64" { "windows-arm64" }
  26. "X64" { "windows-x86_64" }
  27. default { throw "unsupported architecture: $_" }
  28. }
  29. $Asset = "ade-cli-$target.zip"
  30. $Tag = if ($Version -eq "latest") { $null }
  31. elseif ($Version.StartsWith("v")) { $Version } else { "v$Version" }
  32. $Tmp = Join-Path ([System.IO.Path]::GetTempPath()) "ade-cli-install-$PID"
  33. New-Item -ItemType Directory -Force -Path $Tmp | Out-Null
  34. try {
  35. # --- download ------------------------------------------------------------
  36. # Anonymous installs use the public download URL; with a token we resolve
  37. # asset ids through the API, which also works while the repo is private.
  38. $ReleaseJson = $null
  39. function Fetch-Asset([string]$Name, [string]$OutFile) {
  40. if ($Token) {
  41. if (-not $script:ReleaseJson) {
  42. $RelUrl = if ($Tag) { "https://api.github.com/repos/$Repo/releases/tags/$Tag" }
  43. else { "https://api.github.com/repos/$Repo/releases/latest" }
  44. $script:ReleaseJson = Invoke-RestMethod -Uri $RelUrl -Headers @{ Authorization = "Bearer $Token" }
  45. }
  46. $Found = $script:ReleaseJson.assets | Where-Object { $_.name -eq $Name }
  47. if (-not $Found) { throw "release has no asset $Name" }
  48. Invoke-WebRequest -Uri "https://api.github.com/repos/$Repo/releases/assets/$($Found.id)" `
  49. -Headers @{ Authorization = "Bearer $Token"; Accept = "application/octet-stream" } `
  50. -OutFile $OutFile
  51. } else {
  52. $Url = if ($Tag) { "https://github.com/$Repo/releases/download/$Tag/$Name" }
  53. else { "https://github.com/$Repo/releases/latest/download/$Name" }
  54. Invoke-WebRequest -Uri $Url -OutFile $OutFile
  55. }
  56. }
  57. Write-Host "downloading $Asset ($Version) ..."
  58. $Zip = Join-Path $Tmp $Asset
  59. try {
  60. Fetch-Asset $Asset $Zip
  61. } catch {
  62. throw "download failed ($_) — while the repo is private, set GITHUB_TOKEN and retry"
  63. }
  64. # --- verify ----------------------------------------------------------------
  65. $Sums = Join-Path $Tmp "SHA256SUMS.txt"
  66. try { Fetch-Asset "SHA256SUMS.txt" $Sums } catch { $Sums = $null }
  67. if ($Sums) {
  68. $Line = Get-Content $Sums | Where-Object { $_ -match [regex]::Escape($Asset) + "$" }
  69. if (-not $Line) { throw "SHA256SUMS.txt has no entry for $Asset" }
  70. $Expected = ($Line -split "\s+")[0]
  71. $Actual = (Get-FileHash -Algorithm SHA256 $Zip).Hash
  72. if ($Expected -ne $Actual) { throw "checksum mismatch for $Asset" }
  73. Write-Host "checksum OK"
  74. } else {
  75. Write-Warning "SHA256SUMS.txt not found on the release; skipping verification"
  76. }
  77. # --- install ---------------------------------------------------------------
  78. # The zip holds a onedir app: ade\ade.exe plus ade\_internal\ with the
  79. # bundled libraries (a single-file exe would re-extract those on
  80. # every launch and get rescanned each time — issue #83). Both pieces land
  81. # in $InstallDir so the exe sits next to its _internal dir.
  82. New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
  83. Expand-Archive -Path $Zip -DestinationPath $Tmp -Force
  84. Remove-Item -Recurse -Force (Join-Path $InstallDir "_internal") -ErrorAction SilentlyContinue
  85. Remove-Item -Force (Join-Path $InstallDir "ade.exe") -ErrorAction SilentlyContinue
  86. Remove-Item -Force (Join-Path $InstallDir "ade-cli.exe") -ErrorAction SilentlyContinue
  87. Move-Item -Force (Join-Path $Tmp "ade\_internal") (Join-Path $InstallDir "_internal")
  88. Move-Item -Force (Join-Path $Tmp "ade\ade.exe") (Join-Path $InstallDir "ade.exe")
  89. Write-Host "installed $(& (Join-Path $InstallDir 'ade.exe') version) to $InstallDir\ade.exe"
  90. # --- PATH (user-level) -------------------------------------------------------
  91. $UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
  92. if (($UserPath -split ";") -notcontains $InstallDir) {
  93. $NewPath = if ($UserPath) { "$UserPath;$InstallDir" } else { $InstallDir }
  94. [Environment]::SetEnvironmentVariable("Path", $NewPath, "User")
  95. $env:Path = "$env:Path;$InstallDir"
  96. Write-Host "added $InstallDir to your user PATH (open a new terminal to pick it up)"
  97. }
  98. Write-Host "run: ade --help"
  99. # The user PATH above reaches processes started after it — a runner or
  100. # service already running keeps the environment it launched with, so
  101. # give machine callers the spelling that always resolves.
  102. Write-Host ""
  103. Write-Host "driving ade from CI or an agent? Processes already running keep their old PATH:"
  104. Write-Host " $InstallDir\ade.exe help --json # absolute path - always resolves"
  105. Write-Host "then pass --json to every command: the full result is on stdout."
  106. } finally {
  107. Remove-Item -Recurse -Force $Tmp -ErrorAction SilentlyContinue
  108. }
scripts/install.sh · Bundled script · 197 lines · 2 findings marked
  1. #!/bin/sh
  2. # ade-cli installer for macOS / Linux.
  3. #
  4. # curl -fsSL https://raw.githubusercontent.com/landing-ai/ade-cli/main/scripts/install.sh | sh
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 4 on GitHub
  5. #
  6. # Environment knobs:
  7. # ADE_CLI_VERSION release to install ("0.2.0" or "v0.2.0"; default: latest)
  8. # ADE_CLI_INSTALL_DIR where the app lands: the binary plus its _internal/
  9. # support dir (default: ~/.ade/bin — inside the CLI's
  10. # own home, next to the store; honors ADE_HOME)
  11. # GITHUB_TOKEN/GH_TOKEN required while the repo is private; downloads go
  12. # through the GitHub API instead of the public URL.
  13. #
  14. # Uninstall: remove ~/.ade/bin (the binary and its _internal/ support dir)
  15. # and the ~/.local/bin/ade symlink. Never `rm -rf ~/.ade` — the rest of
  16. # that directory is your local store (billed parse/extract results).
  17. set -eu
  18. REPO="landing-ai/ade-cli"
  19. INSTALL_DIR="${ADE_CLI_INSTALL_DIR:-${ADE_HOME:-$HOME/.ade}/bin}"
  20. VERSION="${ADE_CLI_VERSION:-latest}"
  21. TOKEN="${GITHUB_TOKEN:-${GH_TOKEN:-}}"
  22. say() { printf '%s\n' "$*" >&2; }
  23. fail() { say "error: $*"; exit 1; }
  24. command -v curl >/dev/null 2>&1 || fail "curl is required"
  25. # --- pick the release asset for this platform ------------------------------
  26. case "$(uname -s)-$(uname -m)" in
  27. Darwin-arm64) target="darwin-arm64" ;;
  28. Darwin-x86_64) target="darwin-x86_64" ;;
  29. Linux-aarch64 | Linux-arm64) target="linux-arm64" ;;
  30. Linux-x86_64 | Linux-amd64) target="linux-x86_64" ;;
  31. Windows* | MINGW* | MSYS* | CYGWIN*)
  32. fail "use install.ps1 on Windows: irm .../install.ps1 | iex" ;;
  33. *)
  34. fail "unsupported platform: $(uname -s) $(uname -m)" ;;
  35. esac
  36. asset="ade-cli-${target}.tar.gz"
  37. case "$VERSION" in
  38. latest) tag="" ;;
  39. v*) tag="$VERSION" ;;
  40. *) tag="v$VERSION" ;;
  41. esac
  42. tmp="$(mktemp -d)"
  43. staging=""
  44. trap 'rm -rf "$tmp"; if [ -n "$staging" ]; then rm -rf "$staging"; fi' EXIT INT TERM
  45. # --- download ---------------------------------------------------------------
  46. # Anonymous installs use the public download URL; with a token we resolve
  47. # asset ids through the API, which also works while the repo is private.
  48. fetch_public() { # $1 asset name, $2 output path
  49. if [ -n "$tag" ]; then
  50. url="https://github.com/${REPO}/releases/download/${tag}/$1"
  51. else
  52. url="https://github.com/${REPO}/releases/latest/download/$1"
  53. fi
  54. curl -fsSL --retry 3 -o "$2" "$url"
  55. }
  56. # Returns non-zero (never exits) when the release or asset is unavailable:
  57. # callers decide what is fatal — the binary is, SHA256SUMS.txt is optional.
  58. release_json="" # cached across fetch_api calls
  59. fetch_api() { # $1 asset name, $2 output path
  60. if [ -z "$release_json" ]; then
  61. if [ -n "$tag" ]; then
  62. rel_url="https://api.github.com/repos/${REPO}/releases/tags/${tag}"
  63. else
  64. rel_url="https://api.github.com/repos/${REPO}/releases/latest"
  65. fi
  66. release_json="$(curl -fsSL --retry 3 -H "Authorization: Bearer ${TOKEN}" "$rel_url")" || {
  67. say "cannot read release ${VERSION} of ${REPO} (bad token or no release yet?)"
  68. release_json=""
  69. return 1
  70. }
  71. fi
  72. # Normalize the JSON to one whitespace-free token per line so the match
  73. # doesn't depend on GitHub's pretty-printing. Inside the "assets" array,
  74. # an asset's numeric id is the last "id" emitted before its "name" (the
  75. # guard keeps a release titled like an asset filename from matching).
  76. asset_id="$(printf '%s' "$release_json" | tr '{,' '\n\n' | tr -d ' \t' \
  77. | awk -v name="\"name\":\"$1\"" '
  78. /^"assets":\[/ { in_assets = 1 }
  79. in_assets && /^"id":[0-9]+$/ { id = substr($0, 6) }
  80. in_assets && index($0, name) == 1 { print id; exit }')"
  81. if [ -z "$asset_id" ]; then
  82. say "release has no asset $1"
  83. return 1
  84. fi
  85. curl -fsSL --retry 3 -o "$2" \
  86. -H "Authorization: Bearer ${TOKEN}" \
  87. -H "Accept: application/octet-stream" \
  88. "https://api.github.com/repos/${REPO}/releases/assets/${asset_id}"
  89. }
  90. fetch() {
  91. if [ -n "$TOKEN" ]; then fetch_api "$1" "$2"; else fetch_public "$1" "$2"; fi
  92. }
  93. say "downloading ${asset} (${VERSION}) ..."
  94. fetch "$asset" "$tmp/$asset" \
  95. || fail "download failed — while the repo is private, set GITHUB_TOKEN and retry"
  96. # --- verify -----------------------------------------------------------------
  97. if fetch "SHA256SUMS.txt" "$tmp/SHA256SUMS.txt" 2>/dev/null; then
  98. expected="$(grep " ${asset}\$" "$tmp/SHA256SUMS.txt" | awk '{print $1}')"
  99. [ -n "$expected" ] || fail "SHA256SUMS.txt has no entry for ${asset}"
  100. if command -v sha256sum >/dev/null 2>&1; then
  101. actual="$(sha256sum "$tmp/$asset" | awk '{print $1}')"
  102. else
  103. actual="$(shasum -a 256 "$tmp/$asset" | awk '{print $1}')"
  104. fi
  105. [ "$expected" = "$actual" ] || fail "checksum mismatch for ${asset}"
  106. say "checksum OK"
  107. else
  108. say "warning: SHA256SUMS.txt not found on the release; skipping verification"
  109. fi
  110. # --- install ----------------------------------------------------------------
  111. # The archive holds a onedir app: ade/ade plus ade/_internal/ with the
  112. # bundled libraries. A single-file binary would re-extract those to
  113. # fresh inodes on every launch, making macOS re-validate every code
  114. # signature each run (~10s per command, issue #83); the app dir pays that
  115. # once, right below at the warm-up run.
  116. tar -xzf "$tmp/$asset" -C "$tmp"
  117. mkdir -p "$INSTALL_DIR"
  118. # Stage inside the destination dir so the final steps are same-filesystem
  119. # renames: mv from the temp mount would degrade to copy+delete and could
  120. # leave a half-copied tree under a running `ade`. A concurrently
  121. # *launched* ade can still hit the brief window between the renames;
  122. # an already-running one keeps its open inodes and is unaffected.
  123. staging="$INSTALL_DIR/.ade.new.$$"
  124. cp -R "$tmp/ade" "$staging"
  125. chmod 755 "$staging/ade"
  126. rm -rf "$INSTALL_DIR/_internal" "$INSTALL_DIR/ade" "$INSTALL_DIR/ade-cli"
  127. mv -f "$staging/_internal" "$INSTALL_DIR/_internal"
  128. mv -f "$staging/ade" "$INSTALL_DIR/ade"
  129. rmdir "$staging"
  130. staging=""
  131. # The version call doubles as the warm-up: macOS validates each bundled
  132. # library once per inode, so the one slow launch happens here, not on the
  133. # user's first real command.
  134. case "$target" in
  135. darwin-*) say "verifying the app (first launch validates its libraries; can take ~10s) ..." ;;
  136. esac
  137. say "installed $("$INSTALL_DIR/ade" version) to ${INSTALL_DIR}/ade"
  138. # --- expose on PATH -----------------------------------------------------------
  139. # Prefer a symlink in ~/.local/bin (the XDG user bin dir, already on PATH in
  140. # most setups) over asking the user to edit rc files — and create the dir if
  141. # it is missing rather than skipping the link. Never clobber a real file
  142. # there: only create or refresh a symlink.
  143. local_bin="$HOME/.local/bin"
  144. link="$local_bin/ade"
  145. linked=0
  146. if [ "$INSTALL_DIR" != "$local_bin" ]; then
  147. if [ -e "$link" ] && [ ! -L "$link" ]; then
  148. say "note: $link exists and is not a symlink; leaving it untouched"
  149. elif mkdir -p "$local_bin" 2>/dev/null && ln -sf "$INSTALL_DIR/ade" "$link" 2>/dev/null; then
  150. # A link that doesn't run is not an install: prove it resolves before
  151. # reporting it, and withdraw it if it doesn't.
  152. if "$link" version >/dev/null 2>&1; then
  153. linked=1
  154. say "linked $link -> $INSTALL_DIR/ade"
  155. else
  156. rm -f "$link"
  157. say "note: ade would not run through $link; skipped the symlink"
  158. fi
  159. fi
  160. fi
  161. on_path() { case ":$PATH:" in *":$1:"*) return 0 ;; *) return 1 ;; esac; }
  162. say ""
  163. if on_path "$INSTALL_DIR" || { [ "$linked" -eq 1 ] && on_path "$local_bin"; }; then
  164. say "run: ade --help"
  165. else
  166. say "put it on PATH for this shell:"
  167. say " export PATH=\"$INSTALL_DIR:\$PATH\""
  168. say "and to keep it, append that line to your shell's rc file:"
  169. say " echo 'export PATH=\"$INSTALL_DIR:\$PATH\"' >> ~/.$(basename "${SHELL:-sh}")rc"
  170. say "then run: ade --help"
  171. fi
  172. # Printed even when the PATH check above passed: that check reads *this*
  173. # shell's PATH, and the shells CI jobs, cron, and agent harnesses spawn are
  174. # non-interactive — they source no rc file, so an rc-provided ~/.local/bin
  175. # is not there for them. The absolute path is the one spelling that always
  176. # resolves, and `help --json` is where a machine caller should start.
  177. say ""
  178. say "driving ade from CI, cron, or an agent? Those shells source no rc file:"
  179. say " $INSTALL_DIR/ade help --json # absolute path — always resolves"
  180. say " export PATH=\"$INSTALL_DIR:\$PATH\" # ...or put it on PATH first"
  181. say "then pass --json to every command: the full result is on stdout."

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.