Metadata-Version: 2.4
Name: arch-insight-cli
Version: 0.5.0
Summary: Command-line client for ARCH-Insight tasks, factsheets and secrets.
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: arch-secrets>=1.1.2

# arch-cli

`arch-cli` is the ARCH-Insight command-line client. It includes commands for
working with the product API, importing architecture data, and using the
secrets vault.

## Install

```sh
python -m pip install arch-insight-cli
```

The installed command is `arch` (also available as `arch-cli`). Python 3.9 or
newer is required.

## Sign in

```sh
arch login                               # opens the browser; MFA and consent as for any connected app
arch login --email you@example.com       # unattended: password from ARCH_PASSWORD, or asked for
arch whoami
arch logout
```

The session is stored for your user (`%APPDATA%\arch-insight\credentials.json`
on Windows, `~/.config/arch-insight/credentials.json` elsewhere, readable by
you only) and refreshed automatically, so scheduled jobs keep working.
`ARCH_ACCESS_TOKEN` or `--token` still override it. Set
`ARCH_API_URL` for a self-hosted deployment (default `https://arch-insight.com`)
and, if its sign-in is not at `auth.<host>`, `ARCH_AUTH_URL`.

### API keys

For scripts and CI, create a personal API key under **Account > API keys**:
it belongs to one organisation, carries only the scopes you chose (`read`,
`finance:write`, `finance:invoice`, ...) and is shown once, starting with
`ai_live_`.

```sh
export ARCH_API_KEY=ai_live_...          # used as is, nothing stored
arch login --api-key                     # or check it and store it (read from ARCH_API_KEY, or asked for)
arch whoami                              # shows the key as ai_live_...last4, never in full
```

Order of precedence: `--token`, `ARCH_ACCESS_TOKEN`, `ARCH_API_KEY`, then
what `arch login` stored. A key cannot manage keys, billing or members; a
missing scope comes back as an HTTP 403 with the reason.

## Tasks

```sh
arch task create "Review database costs" \
  --description "Check the quarterly forecast" \
  --project-id 12 --board-id 4 --priority high \
  --assignee "Alex Example" --due-date 2026-12-01

arch task list --project-id 12
```

The create command prints the created task as JSON. Repeat `--assignee` to
assign more than one person.

## Fact sheets

Create one fact sheet from JSON, import one or more JSON objects, or import an
ARCH-Insight ZIP export:

```sh
arch factsheet create application.json
arch factsheet import fact-sheets.json
arch factsheet import archi_insight_export.zip
arch factsheet list
```

JSON imports create rows one at a time through the same API used by the web
app. If an item fails, earlier successful items remain created. ZIP imports use
the application's import endpoint and report imported and skipped entries.

## Projects, tasks, tickets and notes

```sh
arch project list
arch project create "Webshop" --priority high
arch task create "Release Stripe production account" --project-id 12 --assignee st@example.com --due-date 2026-09-14
arch task update 41 --status in_review
arch ticket create "Alfen box offline" --message "Since 2026-09-14 after reset" --priority high
arch ticket reply 7 --message "2026-09-15: back online after factory reset"
arch document create "Meeting 2026-10-05" --file minutes.md --folder "Change Control Board"
```

Move a whole list in at once -- projects, their tasks, a dated status log
kept as a ticket, and notes -- from one JSON file. Re-running it creates
nothing twice:

```sh
arch project import plan.json --dry-run
arch project import plan.json
```

See `arch_cli/work.py` for the file format.

## Organisation

```sh
arch org show                 # name, members, whether Entra sign-in is on
arch org entra show           # the Redirect URI to register in Entra
ARCH_ENTRA_CLIENT_SECRET=... arch org entra set --tenant-id <Directory ID> --client-id <Application ID>
```

With Entra sign-in on, members choose "Sign in with your organization" on the
login screen and type the organisation's name. `--domain` (a domain proven
under Organization -> Access) also sends that domain's addresses to Entra by
themselves. The secret is read from `ARCH_ENTRA_CLIENT_SECRET` or asked for,
never taken as an argument.

`arch login` prints the organisation it signed in to. A browser sign-in uses
the account that browser is signed in to; check it before importing.

## Marketing e-mail

Contact lists drop malformed addresses and reserved domains (`example.com`,
`*.invalid`, `*.test`, ...) and duplicates, and say what they dropped:

```sh
arch email-list create "Customers" --file customers.csv --exclude-domain mycompany.com
arch email-list create "Team" --members --dry-run
arch email-list add 4 --email new@customer.org
arch email-list export 4 --out customers.csv
```

A campaign's own subject and bodies are the English base. Each recipient who
chose a language in ARCH-Insight gets that language's version when the
campaign has one, everyone else the base:

```sh
arch marketing campaign create --name "Release 3.1" --subject "ARCH-Insight 3.1" \
  --html release.html --text release.txt --list 4 --translations translations.json
arch marketing campaign preview 12 --language ja --out preview.html
arch marketing campaign test 12 --to me@mycompany.com --language ja   # stays a draft
arch marketing campaign send 12 --yes
```

`translations.json`:

```json
{"ja": {"subject": "ARCH-Insight 3.1", "body_html_file": "release.ja.html", "body_text_file": "release.ja.txt"},
 "de": {"subject": "ARCH-Insight 3.1 ist da"}}
```

Set the logo shown at the top of every e-mail with `arch org logo logo.png`.

## Finance

```sh
arch finance accounts list
arch finance tx list --account 3 --type income --from 2026-10-01 --to 2026-10-31 --search acme
arch finance tx add --account 3 --type income --category Sales --buyer "ACME GmbH" \
  --line "Consulting:2:500:19" --line "Travel:1:80:19"
arch finance tx import statement.csv --account 3 --dry-run     # validate; nothing is booked
arch finance tx import statement.xlsx --account 3 --map category=5
```

`tx import` uses the column mapping the server guesses, the same as the web
import; `--map field=index` (0-based, `field=` to drop a guess) corrects it.
Rows already booked are reported as duplicates rather than booked twice.

E-invoices (EN 16931: ZUGFeRD, XRechnung CII and UBL):

```sh
arch finance invoice validate 41 --format xrechnung-cii        # checks only; exits 1 when invalid
arch finance invoice issue 41                                  # RE-2026-00041.pdf (XML embedded)
arch finance invoice issue 41 --format xrechnung-ubl           # RE-2026-00041.xml
arch finance invoice list --tx 41
arch finance invoice download 7 --as xml                       # the archived file, byte for byte
arch finance invoice credit-note 7 --reason "Wrong amount"      # asks first; --yes in scripts
arch finance invoice bulk 41 42 43 --out october.zip
arch finance invoice send 41 --to ap@customer.example           # issue and e-mail; asks first
arch finance invoice send --invoice 7 --to ap@customer.example --attach pdf_xml --yes
arch finance invoice import supplier-invoice.pdf               # prints the draft, saves nothing
arch finance invoice import supplier-invoice.xml --account 3   # ... or books it
arch finance customers add --name "Stadt Musterhausen" --leitweg-id 991-12345-67 --email rechnung@stadt.example
```

A transaction is invoiced once: `issue` assigns the next gap-free number and
archives the invoice, and issuing it again takes a credit note first. The
buyer is the transaction's customer unless `--buyer` says otherwise;
`--format` is passed to the server as given and, left out, the
organisation's default applies. In `send`, `{invoice_no}` in `--subject` is
replaced with the number.

Recurring invoices, issued (and, if you like, sent) by the server on a schedule:

```sh
arch finance recurring add --name "Hosting" --customer 3 --account 6 \
  --description "Hosting {month}" --line "Hosting:1:100:19" --preset monthly --start 2026-12-01 \
  --send auto --to ap@customer.example                 # --preview shows the next dates first
arch finance recurring add --file schedule.json        # the API's fields; flags override them
arch finance recurring list
arch finance recurring runs 9
arch finance recurring pause 9 / resume 9 / run 9 --yes / delete 9
arch finance sends list --status pending_approval      # --send approval queues each e-mail
arch finance sends approve 12
```

For automation, sign in with an API key (`ARCH_API_KEY=ai_live_...` in the
environment) and pass `--yes` to commands that would otherwise ask. Every
command prints JSON and exits non-zero on failure. An API key needs `read` to
list, `finance:write` to add or import transactions and `finance:invoice` to
issue, send or schedule invoices.

## Secrets

The dedicated `arch-secrets` command remains available. The same functionality
can be reached through `arch secrets`:

```sh
export ARCH_SECRETS_TOKEN='your-vault-token'
arch secrets run -- npm start
arch secrets export > .env
arch secrets push .env
```

The vault token is scoped independently from the user access token used by
product commands.
