Artifact acc0ef8f36c3fad5c09f965e290b4faf41e3f73f13679f95efd120ff8fabdbba:
- File
src/userdb.h
— part of check-in
[adeb66a371]
at
2026-11-19 18:13:50
on branch slash
— The rest of Pi's slash commands (ticket 03abef634d)
The terminal gains /settings, /scoped-models (Ctrl+P then cycles only those), /thinking and Shift+Tab (the levels the model supports), /tree (continue from any branch point), /reload, /trust, /import of a Pi v3 JSONL conversation (text only), /export to a self-contained web page, /changelog, /share (a secret gist through gh, after a yes) and /bug (a local report in picu_bug; nothing is sent). /login and /logout say they are not available yet. State lives in pic.sqlite. New subcommands back them: pic tree, export --html, import, trust, scoped-models and bug. (user: dmestas, size: 1922) [annotate] [blame] [check-ins using] [more...]
/* pic's user database, ~/.pic/pic.sqlite (userdb.c): every piece of * user-level state pic keeps, in picu_ tables, shared by every pic process * (WAL, a busy timeout). The legacy ~/.pic/settings.json and * ~/.pic/models-store.json are imported on first open, then deleted. */ #ifndef PIC_USERDB_H #define PIC_USERDB_H #include <stddef.h> #include "sqlite3.h" /* The process's connection (opened on first use, schema and migration * done; sqlar functions registered), or NULL with err when there is no * home directory or the database cannot be opened. */ sqlite3 *pic_userdb(char *err, size_t errcap); void pic_userdb_close(void); /* A setting's value (malloc'd), or NULL when unset. */ char *pic_setting(const char *key); /* Sets KEY (VALUE NULL removes it). 0 or -1. */ int pic_setting_set(const char *key, const char *value); /* Calls fn for each setting, by key. */ int pic_settings_each(int (*fn)(void *ctx, const char *key, const char *value), void *ctx); /* Records that WORKSPACE uses the journal at JOURNAL (now). */ int pic_workspace_touch(const char *workspace, const char *journal); /* Ctrl+P's scope (picu_scoped_model): model patterns ("provider/model", or * with * and ?), in cycling order. Replaces the whole list; N 0 clears it. */ int pic_scoped_set(const char *const *patterns, size_t n); int pic_scoped_each(int (*fn)(void *ctx, const char *pattern), void *ctx); /* Whether PATH (a real path) is trusted (picu_trust): 1, 0, or -1 undecided. */ int pic_trust_get(const char *path); int pic_trust_set(const char *path, int trusted); /* A bug report kept in picu_bug; nothing is sent anywhere. Returns its id, or -1. */ long long pic_bug_add(const char *workspace, const char *conversation, const char *model, const char *description); int pic_bugs_each(int (*fn)(void *ctx, long long id, long long ms, const char *workspace, const char *description), void *ctx); #endif