feat: compressed tool responses for llm token efficiency

Closes #9

Description:

Adds a compression layer so each tool returns only the data its purpose justifies, and minifies every tool's JSON output. The guiding principle: compression is the tool-boundary contract, advanced_search is for discovery, get_inscription/get_bibliography are for depth, and token savings fall out of clean separation.

What changed

  • compress.ts (new): pure projections, no I/O:
    • compressArtifact: flat ArtifactSummary discovery card; has_inscription/publication_count are signals, not inline ATF/publications.
    • compressPublication: compact citation; flattens nested author names.
    • denoise: recursively strips FK (*_id) and admin (created_by) fields and empty arrays while keeping full depth.
  • client.ts: cdliArtifactUrl(id) for the canonical artifact page URL.
  • types.ts: typed nested input shapes (CdliArtifactRecord, CdliPublicationEntry) + projected output shapes (ArtifactSummary, CompressedPublication). No any.
  • Wiring: advanced_search -> cards + drill-down hint; get_bibliography -> compressed citations; get_metadata -> denoise on by-ID artifact only.
  • Minify: dropped pretty-print whitespace from all tool success payloads (advanced_search, get_bibliography, get_metadata, search_entity); errors were already minified.

For the search page https://cdli.earth/search.json?atf_translation_text=king

Tokens before -

image.png

Tokens after (91.4% reduction):

image.png

Edited by Armaan Gupta

Merge request reports

Loading