# aivis aivis is a Python CLI that administers a prompt library to AI models, extracts tracked-brand observations with an EDSL judge, stores deterministic JSON time-series records, and reports share of voice, mention rate, recommendations, sentiment, and citation influence. It can create and maintain a brand-measurement project, collect repeated API samples, re-extract immutable responses under versioned judge methods, and export analysis-ready CSV or nested JSON. ![A panel of AI agents answering a recommendation prompt around the EDSL parrot](assets/aivis-overview.png) Run `aivis guide` for the workflow and `aivis next` in the project directory for the next step. ## Copy and paste into a coding agent ```text Set up aivis and help me measure how my brand and competitors appear in AI answers. Install it in a Python 3.11+ environment, then run `aivis version`, `aivis capabilities`, `aivis guide`, and `aivis --help`. Initialize a project, add representative prompts, and run `aivis run --dry-run` plus `aivis doctor`. Show me the planned model-call count and stop for approval before paid inference. Never print or commit API keys. After collection, preserve and commit `.aivis/data/`, inspect `aivis report`, and export CSV for analysis. ``` ## Install and quickstart ```bash uv tool install --python 3.11 "aivis @ git+https://github.com/expectedparrot/aivis.git@main" aivis version aivis capabilities aivis init --brand Upwork --no-generate aivis prompts add "how do I hire a freelance developer" --cluster category aivis configure --engines gpt-4o,claude-sonnet-4-6,gemini-2.5-flash --samples-per-prompt 1 aivis config set sampling.max_tokens 8192 aivis run --no-extract --dry-run aivis doctor aivis run --no-extract aivis competitors discover --run last-complete --category "freelance marketplace" --estimate aivis competitors discover --run last-complete --category "freelance marketplace" --review # Review candidates and evidence, then apply without another model call: aivis competitors discover --run last-complete --category "freelance marketplace" --saved --apply aivis configure --engines gpt-4o,claude-sonnet-4-6,gemini-2.5-flash --samples-per-prompt 3 aivis run --dry-run # Collect the separate measurement after reviewing its paid scope: aivis run aivis --human report aivis report-context --run last --out report-context.json ``` The default interface emits one JSON envelope to stdout; use `--human` for Rich tables. Project discovery walks upward from the current directory, or `--project PATH` selects one explicitly. Commit `.aivis/data/` after each run: new runs are additions, while versioned re-extraction produces narrow semantic changes. New projects use EDSL remote inference through Expected Parrot by default, so one `EXPECTED_PARROT_API_KEY` covers every configured engine and the judge. Set `collection.remote: false` only when intentionally using direct provider keys. `aivis run --dry-run` reports the selected inference mode and `aivis doctor` validates the corresponding authentication path. `report-context` creates one deterministic JSON handoff for a driving agent. It contains run coverage, reportability limits, metrics with denominators, engine and cluster slices, prompt-level outcomes, and exact response excerpts linked to stored sample files. It does not draft or render a narrative report. ## Measurement and cost caveats ### Discover competitors and use a broader model panel `competitors discover` extracts candidates from saved, successful unbranded answers with recorded finish reasons and no output cutoff. It verifies verbatim name spans and retains evidence IDs. `--review` adds a paid consolidation step that merges name variants and filters category mismatches; review those decisions before `--saved --apply`. Applying requires complete extraction and consolidated candidates. The default selection threshold is two source answers, counted once per brand per answer. Discovery frequencies describe that discovery set; collect fresh answers after freezing the vocabulary for the measurement itself. Use `ep models` to inspect the live model catalog. `aivis capabilities` reports the project's configured panel. API engine records support a safe local `id`, an optional provider `model` name, and optional `service`, so model names containing slashes can be used without becoming store paths. See the [eight-model HBS setup](examples/hbs_mba/broad/setup.py) for a complete example. `sampling.max_tokens` controls the collection model's output budget. New samples retain finish reasons and `output_truncated`; coverage reports expose cutoff counts and unknown finish reasons. A returned answer can be successful yet truncated, so check both collection success and output quality. Changing the output budget or the model behind an engine ID suppresses comparison deltas. API models are not consumer products: they may lack browsing, memory, personalization, and product-specific system instructions. Treat results as a proxy trend line, not a replica of a user's ChatGPT, Claude, or Gemini session. Collection caching defaults off because repeated fresh answers are the data. Judge caching defaults on because deterministic re-reading should not be paid for twice. Collection calls equal prompts × engines × samples. Judge work is two first-pass questions per successful sample (an ordered list of mentioned brands and cited domains) plus one framing question per mentioned brand; `aivis extract --estimate` reports question-call bounds before cache savings and retries. `run --no-extract --dry-run` reports zero judge work. Browser engines are a v3 milestone and remain disabled. Automated Google querying may violate Google's Terms of Service; aivis will not solve CAPTCHAs or evade bot detection. The flat-file design targets roughly 1,800 samples per weekly run for two years. Keep `raw/` and `screenshots/` gitignored; use ordinary `git gc` and shallow clones if history grows large. ## Automation ```cron 0 8 * * 1 cd /srv/visibility && aivis run && git add .aivis/data && git commit -m "aivis weekly run" ``` In CI, run `aivis doctor`, then `aivis run`; commit and push `.aivis/data/` only after a successful run. Exit `1` denotes an operational failure, including partial collection or failed extraction. Threshold exit `2`, multi-run trends, HTML, raw pruning, and Playwright collection are later milestones from `SPEC.md`. ### Incomplete measurements and recovery Missing or invalid judge answers remain unmeasured; they never become “not mentioned” or “neutral.” Successful observations are saved even when other judgments fail. The error envelope includes a run ID and recovery commands. Retry judgment with: ```bash aivis extract --run RUN_ID --estimate aivis extract --run RUN_ID ``` Retries judge only missing observations and preserve finalized samples and successful observations. Reports expose missing-observation and extraction-failure counts. Metric values are `null` (a dash in human tables) for slices with incomplete judgment; fully judged engine or cluster slices remain usable. Mention and recommendation `n` still counts successful collection samples; conditional denominators remain unknown (`n=0`) until judgment is complete. Prompt-level mention counts describe judged samples only and include `judged_samples`. Run status describes collection. A run can have `status: complete` and `extraction_status: failed`; the command exits `1` in that case. An intentional `--no-extract` run reports `extraction_status: skipped` and exits `0` if collection is complete. Failed collection samples are preserved; collecting again creates a new run rather than overwriting them. New runs snapshot the selected prompts and their clusters. Older runs remain readable, but reports disclose that their prompt metadata comes from the current library. Each new extraction version records its configuration and method fingerprint. Changing the judge, tracked brands, aliases, or extraction implementation requires a new `--judge-version`. Legacy observations without this metadata also require a fresh version for re-extraction. For example, if version 1 exists, estimate and then extract with `aivis extract --run RUN_ID --judge-version 2`. Earlier versions coexist unchanged; reports use the latest version, including its saved brand and judge configuration. See [SPEC.md](SPEC.md) for the complete schemas, metric definitions, and milestones. For a worked introduction, see the [LaTeX usage manual](docs/manual/README.md). Build its PDF and verified synthetic example with `make -C docs/manual`; the output is `docs/manual/build/aivis-manual.pdf`. The build runs offline and makes no model calls. ### Discovery and run selection `aivis capabilities` lists engine IDs, provider-prefixed aliases, the built-in clusters (`branded`, `category`, `comparison`, `use_case`), and the `custom:` extension. With a project, it lists that project's configured engines. Discovery is offline: availability is `not_checked`; use `aivis doctor` for authentication preflight. `configure` and `run --engines` accept aliases such as `google/gemini-2.5-flash` and normalize them to configured IDs. Run selectors are shared by report, report-context, extract, and export: `last` selects the newest run regardless of status, `last-complete` selects the newest complete run, and an explicit ID selects exactly that run. Partial-run reports include coverage, failure counts, and reportability qualifications. ### Comparing runs and finding competitive gaps `diff` works offline and reads saved samples and observations. By default it compares the two newest complete collection runs; extraction coverage is checked separately. Use explicit selectors to inspect partial runs: ```bash aivis diff aivis --human diff aivis diff --from RUN_ID --to last aivis diff --view metrics --engine gpt-4o --cluster category --brand Upwork aivis diff --view prompts --limit 10 aivis diff --view gaps --min-gap-samples 2 aivis diff --view evidence --evidence-id sample:SAMPLE_ID aivis diff --view methodology ``` The summary shows up to five of the largest metric changes, five prompt changes, and five current competitive gaps. Metric changes include mention rate, recommendation rate, and share of voice overall, by engine, and by cluster. Values include denominators and small-sample flags; deltas are percentage points, after minus before. These rates describe a matched cohort and can differ from a standalone report over the entire run. Comparison requires the same saved prompt text and cluster, engine ID, and repetition index, with collection successful on both sides. Removed engines, added prompts, extra repetitions, and collection failures cannot change the weighting on just one side. Coverage reports the exclusions. Repetition indices identify sampling slots, not individual answers moving between states. Deltas are descriptive; they do not establish statistical significance or causality. Changed extraction methods, tracked brands/aliases, or collection temperature, caching, or inference mode suppress deltas. Missing historical prompt snapshots or verified method metadata also prevent an unqualified comparison. Version labels may differ if the method fingerprints match, with an explicit qualification. Missing judgment withholds affected slice values; complete slices remain usable. No overlapping successful units produces `comparability.status: no_overlap` and empty metric tables. Competitive gaps use the **current run**, including new prompts outside the comparison cohort. A gap answer recommends a competitor while the focal brand is absent or negatively framed. A row needs at least two such answers by default and reports the gap count, successful-sample denominator, both brands' outcomes, and up to three supporting evidence IDs. Rows sort by gap percentage, then gap count, with stable ties. A prompt/engine group with missing judgment is withheld. Small samples and collection failures still limit generalization; these are questions to investigate. Views are `summary`, `metrics`, `prompts`, `gaps`, `evidence`, `coverage`, and `methodology`. Use `--engine`, `--cluster`, or `--prompt-id` to narrow the cohort; `--brand` filters metrics, gaps, or evidence. JSON views support `--limit` (default 20), `--offset`, and `next_offset`, plus `--max-bytes` (default 100000). Evidence excerpts default to 600 characters. Evidence records include retrieval commands that pin the project, both runs, and their judge versions. Use `--from-judge-version N --to-judge-version N` to reproduce an earlier comparison after re-extraction; the default uses each run's latest observation version. An incompatible or empty comparison exits `0` with its limitations in the structured result; invalid selectors, arguments, or store records exit `1`. Threshold alerting is not implemented. The existing `report` command supplies sentiment and citation snapshots; changes in those measures and multi-run trends remain future work. ### Bounded report inspection Use `report --view` to retrieve canonical reporting slices without opening store files or recalculating metrics: ```bash aivis report --run last --view coverage aivis report --run last --view metrics --format csv aivis report --run last --view metrics --brand Acme --engine gpt-4o --cluster category aivis report --run last --view prompts --limit 20 aivis report --run last --view evidence --prompt-id PROMPT_ID --limit 5 aivis report --run last --view evidence --evidence-id sample:SAMPLE_ID aivis report --run last --view methodology ``` Additional views are `run`, `engines`, and `clusters`. JSON views return `schema_version`, `run_id`, `reportability`, `rows`, `total`, `offset`, `limit`, and `next_offset`. Ordering is deterministic. Follow `next_offset` using `--offset` to obtain subsequent pages, including complete metric tables with more than 100 brands. CSV metrics include values, denominators (`n`), small-sample flags, run ID, and reportability. Engine and cluster filters together select that intersection; unmatched filters return empty rows. The default page limit is 100 (maximum 1000). `--excerpt-chars` bounds response excerpts (default 1200, maximum 10000). `--max-bytes` sets a conservative output budget (default 100000, maximum 1000000); oversized views return a structured error suggesting smaller pages or narrower filters. Unsupported filters are rejected. Coverage and methodology return one structured row each. `report-context --out context.json --evidence-limit 0` omits full evidence records while preserving all evidence IDs and a follow-up CLI retrieval command. Any nonnegative evidence limit is supported; omitting it preserves the full context. Reports use the run's saved configuration and include observed judge models so later configuration changes do not relabel historical metrics.