Artifact 8a94ab01ff8d0ab75158cd2a2c8c03032e7a87f85e72182c46e5e15817d20cdc:
- File
src/tui/fuzzy.h
— part of check-in
[fb82c37817]
at
2026-11-19 14:01:47
on branch models
— Model picker, slash command menu and Pi's model catalog
Models are chosen as in Pi. pic carries a snapshot of Pi's catalog for its providers (653 chat models; tools/model-catalog.sh regenerates it from pi.dev/api/models) and lays fresher per-provider lists from pi.dev over it, cached in ~/.pic/models-store.json with ETags and trusted for four hours, used only when newer than the snapshot. Resolution takes a model's API, endpoint, limits and compat settings from the catalog before the models file. pic models lists the models of providers with a key (--all every one, --json, --refresh); pic models --default saves the model used when none is given.
In the terminal interface, Ctrl+L or /model opens a picker of the models whose provider has a key, filtered by Pi's fuzzy matching as you type, current and default first; Enter uses the model, Ctrl+S also saves it as the default; Ctrl+P cycles. Typing / shows a menu of commands with their arguments (Tab completes, Enter runs) and /model completes model names. New commands show the conversation's details and token counts, copy the last reply (OSC 52 and the system clipboard), export, clone and list the hotkeys. (user: dmestas, size: 760) [annotate] [blame] [check-ins using] [more...]
/* Fuzzy matching, ported from Pi (reference/pi/packages/tui/src/fuzzy.ts) * so filtering ranks as Pi's does: the model picker and the slash-command * menu (fuzzy.c). */ #ifndef PIC_TUI_FUZZY_H #define PIC_TUI_FUZZY_H #include <stddef.h> /* Pi's fuzzyMatch: whether QUERY matches TEXT and its score (lower is a * better match, as in Pi). */ int tui_fuzzy_match(const char *query, const char *text, double *score); /* Pi's fuzzyFilter over N texts: writes the indexes of the matching texts * to order[] (capacity n) best first, ties in input order, and returns how * many matched. An empty or all-space query matches everything in input * order. */ size_t tui_fuzzy_filter(const char *query, const char *const *texts, size_t n, size_t *order); #endif