WispStudy
CLAUDE.md39 starsChanged 4 days agoMITView on GitHub
It holds what applies to every change; per-feature detail is in docs/dev/ (see the table below). Read the matching section there before changing a feature, and put new per-feature detail there, not here. Wisp Study is a local-first literature library desktop app (collect papers, organise, preview PDFs, ask an LLM about the library), written in Rust with GPUI. Targets Windows and macOS; Linux compiles but is untested. The desktop UI supports Chinese and English (Settings › General). Use i18n::t with…
- Reads credentials
In this repositoryOne other file it gives its agents.
- wisp-studySkill
The file
We split this CLAUDE.md into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 88
Never query the database from render: cache in Library::reload or once a frame before drawing.
≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. It holds what applies to every change; per-feature detail is in docs/dev/ (see the table below). Read the matching section there before changing a feature, and put new per-feature detail there, not here.
Wisp Study is a local-first literature library desktop app (collect papers, organise, preview PDFs, ask an LLM about the library), written in Rust with GPUI. Targets Windows and macOS; Linux compiles but is untested. The desktop UI supports Chinese and English (Settings › General). Use i18n::t with Chinese keys in locales/en.json for static labels, and tf! with both Rust format literals for dynamic messages. Translate shared label tables at display sites; keep stored keys, user content and model prompts unchanged. Code comments are in English.
Commands
cargo run --release # run the app
cargo test # all four crates (workspace default-members)
cargo run -p wisp_cli -- help # the `wisp` command line; `-- mcp` is the MCP server
cargo test -p wisp_core # engine only; no GPUI build, much faster
cargo test -p wisp_core store:: # one module's tests
cargo test -p wisp_core <test_name> # one test
cargo test -- --ignored lookup # live Crossref / Europe PMC lookups (network)
cargo clippy --all-targets # expected to be warning-free- The toolchain is pinned in
rust-toolchain.toml(clippy only). There is no rustfmt component and norustfmt.toml: the code is hand-formatted with long lines and one-lineif x { return }bodies. Do not runcargo fmt; match the surrounding style. - Windows needs the MSVC build tools.
- A Mac with only the Command Line Tools (no Xcode, so no
metalcompiler) fails in gpui's build script withxcrun: error: unable to find utility "metal". Add--features gpui/runtime_shadersto every cargo command that builds the app (cargo run,cargo build,cargo clippy --all-targets,cargo test);-p wisp_corecommands need nothing, andscripts/package-macos.shdoes it by itself. - CI runs clippy with
-D warningsand the tests on Windows and macOS, and the three windowless crates on Linux. A release is a pushed tagv<version>matchingCargo.toml, always signed. A pull request touchingscripts/or the workflow rehearses the packaging unsigned, so keepsite/out ofscripts/. Details:docs/dev/release-and-site.md. - Once a release's tag is pushed, look at what the release brought (
git log --first-parent v<previous>..v<version>, the diff ofdocs/FEATURES.md) and tell the owner whether tutorials are called for: which new features a person would use that no tutorial on the project page (site/tutorials/) shows, and for each whether it wants a tutorial of its own or a section in an existing one. It is a suggestion made after the tag, not a step the release waits for; the tutorials are written when the owner says so. Steps: "A release, step by step" indocs/dev/release-and-site.md. WISP_STUDY_HOMEmoves both the data folder andsettings.jsonto one directory; use it for any manual run so the real library inDocuments/WispStudyis not touched.- Debugging without the real library, an API key or a screen (demo data with the
seedexample, thestructure,docxandmermaidexamples for files and diagrams that come out wrong,mock_modelas a fake model endpoint,model_probeto ask real models the same things and compare what became of the manuscript,cache_probeto see how much of a conversation's requests a service reads from its cache,WISP_STUDY_DEVsteps that script a debug window and takeshot:screenshots):docs/dev/debugging.md. A new debug step is an arm ofdev_stepinsrc/dev.rsand listed there. - In a
#[cfg(test)]module of a file that hasuse gpui::*, do not writeuse super::*: it brings in gpui'stestattribute, and#[test]then fails with "recursion limit reached". Import the names you need.
Where the detail is
| Before working on | Read |
A module of the engine: journal metrics (分区 / 影响因子), 文字识别 (ocr, and sight for what the system itself reads), 副表 (table, the tool read_table), docx, slides (pptx), diagrams (mermaid), 批注, 配引用, citation styles and their 调整 (csl, adjust), 出处, an assistant's changes to a section (revise), 助手写, 图片库, 方法库 and 导言库 (excerpt), 图号看图 (figref), 思维导图 (mindmap), screening, 提取, providers / 生图 / 判断, translation, 术语表 (glossary) and the versions of 换个说法 / 译成… (versions), full text and structure, links in a PDF (pdflink), candidates, open full texts, search sources, web search (websearch, tools::Reach), note saving | docs/dev/core.md |
| A feature of the window: the conversations and the diagrams in an answer, 写作 and its modes (翻译 among them), 术语 and the card of versions, citations, 综述, 图片库, 方法库 and 导言库, 提取, 筛选, 自定义 (connectors, skills, OAuth), settings, layout, keyboard and selection, the PDF view and its columns, 思维导图, 工作动画 (the pixel researcher), the text input | docs/dev/app.md |
| Anything the person sees: layout, a new panel, header, bar or label (the design principles, 安静的版面) | docs/dev/design.md |
| Running, scripting and looking at the app | docs/dev/debugging.md |
CI, signing, releases, site/ | docs/dev/release-and-site.md |
| What each step of the roadmap built and left out | docs/dev/roadmap.md |
| Vendored patches | vendor/PATCHES.md |
User-facing docs (Chinese) are docs/FEATURES.md, TUTORIAL.md, CLI.md, DATA.md, DEVELOPMENT.md, ZOTERO.md. The README comes in two: README.md is English (what GitHub shows) and README.zh-CN.md is the same page in Chinese; a change to one goes into the other.
Architecture
A Cargo workspace of four crates. Dependencies point one way only: wisp_net depends on core, the app and the command line depend on both.
crates/core (wisp_core): the engine, no GPUI
Everything that can be decided without a window or a socket lives here, and it is where nearly all tests are. That includes the pure halves of networked features: lookup builds Crossref / Europe PMC URLs and turns their JSON into a Paper; ai builds the context, the request body for the three protocols (Anthropic Messages, OpenAI-compatible chat completions, OpenAI Responses) and parses stream lines into StreamEvents. The actual HTTP (blocking ureq) is in crates/net (wisp_net), shared by the app and wisp; its tests serve canned responses from a local port. wisp_net also holds the two things a tool is lent that are no HTTP: a PDF's pages drawn as pictures (pages, hayro) and the system's own text recognition (sight: Vision on macOS, Windows.Media.Ocr on Windows, each in a file of its own under sight/). Code in core that needs the network takes the fetching function as an argument (sources::Fetch), so core tests pass a closure.
On-disk layout: the data root holds one folder per library, each with library.json (libraries), wisp-paper.sqlite (named before the app was renamed from Wisp Paper; kept) and papers/ (store). A data folder or settings file left under the old name WispPaper stays in use where it is (settings::default_root, settings_file), and WISP_PAPER_* variables are read when the WISP_STUDY_* one is unset (settings::env). Attachment paths in the database are relative to the library folder so a folder can be copied elsewhere. Removing a library or attachment moves it to removed/, and the records an undone import takes out of the library are written there as BibTeX first; nothing is deleted, with one exception: a paper leaving the trash (Store::purge_trashed, Store::empty_trash) has its files unlinked.
store.rs notes:
- The schema is one
CREATE TABLE IF NOT EXISTSbatch guarded bySCHEMA_VERSION/PRAGMA user_version; a newer database is refused. Bump the version when an older build would misread the data. - Deduplication is by DOI, PMID (
paper_identifiers), thentitle_key; a PDF taken in is also known by its bytes (Store::paper_holding, thesha256ofresources), so the same file under another name is not a second paper. Trashed papers stay inpapers(marked by atrashed_papersrow) so they keep blocking re-import. Store::in_memoryis what tests use.Paper::fulltextis computed, not stored:missing,linked,stored, ortextless(a full-text file is there and no text came of any). Why a file gave no text is the sentence kept infulltext_text.error;fulltext::failure_kindtells the kinds apart (locked,parser,encoding,no_text,file,unsupported), messages of earlier builds included, and a new reason is a constant there, not a string somewhere else.- Status values are stored as English keys and shown through the label tables in
model.rs(SCREENINGS,READINGS, …). The labels are not translations: the stored keyexcludedis displayed as 「相关」.
tools.rs is the one table of what an agent can do with a library; the command line, MCP and (next) the in-app assistant all end in tools::call, so a rule belongs there and not in a front end. ai.rs holds the model side of the loop: the request with tool definitions for each protocol, TurnReader (one streamed turn → text, tool calls, the message to send back), tool_results, and the slash commands (SLASH: the prompt templates behind /search, /cite, /review, /compare, /write and /slides).
- A new tool is an entry in
catalog()(name, Chinese description, JSON Schema) and an arm incall_in. Nothing else:wisp <tool>reads its flags off the schema (cli_args), andmcp::handlelists and calls whatever the catalog holds. The testevery_tool_is_callablefails when an entry has no arm. - What a tool does must not depend on how a model fills the call in. Two things a call could do are two tools, each with what it needs required, not one tool told apart by which optional parameter was given (
edit_sectionchanges a section where its words stand,write_sectionwrites the whole of one: as one tool, a model replaced a section where it meant a change).tools::fittedreads every call's arguments as the schema means them first (a list or a number a model wrote as a string). Before changing a tool's schema or the note a model is given, runmodel_probeon both sides (docs/dev/debugging.md). - What a request holds is measured before it is changed, not reasoned out: a service reads a request from its head and keeps what it read, so a byte changed early has everything after it read anew. Before changing the tool table, the context, what stays on the wire or how a conversation is compacted (
compact), run both sides on a real service:cache_probe(docs/dev/debugging.md), or where it has no case for the change (it asks three questions; compaction wants a long conversation) a probe that sends whatchat_stepsends. The change says what was measured. - Tools take
library(id or name, optional when there is one library) and return JSON; an error is a Chinese sentence for the caller, person or model. The window's assistant is bound to the library it is in (library_catalog, nolibrary); the home page's (draft_catalog) also reads the libraries on the shelf through the tools ofACROSS, which never write (tools::across). ToolDef::writesmarks the tools that change a library (theWRITINGlist);wisp mcp --read-onlyleaves them out, and the chat reloads the library after one ran.ToolDef::confirm(theCONFIRMINGlist: the imports,run_search,undo_import,remove_search,find_pdf,ocr_pdf, which sends a file to a service that bills by the page,organise_papers,restyle_docx, which writes a Word file's citations anew into a new file,make_slides, which writes a deck of slides as a new file, and the three that write a manuscript,edit_section,write_sectionandset_outline) marks those the window's assistant runs only after the person agreed. The screening decision stays the person's: an agent may propose, never setscreening.- Tables added after the first schema are made beside the library's own (
CREATE TABLE IF NOT EXISTS, no version bump), columns throughstore::add_columns. - A model proposes, the person decides: screening status, custom fields, completed metadata and proposals on a manuscript are written only by the window on the person's action, never by a tool or a model. Quotations and excerpts are kept only when found in the text (
ai::locate_quote,ai::check_quote). - Author names go through
model::author_names, the one reader that says which word is the family name.
crates/cli (wisp_cli): the wisp binary
A thin shell over tools and mcp: argument words in, JSON out; wisp mcp is newline-delimited JSON-RPC on stdin/stdout. It is a separate binary because the app is a Windows GUI-subsystem program with no console. It opens the same data folder as the app (settings::default_root / settings_file), possibly while the app is running.
Root crate (wisp_study): the GPUI app
src/app.rsholds all state in one root view,Workspace(lib: Option<Library>is the open library,Noneis the home page). Every click is aCmdenum value (commands.rs), wired withself.on(Cmd::…, cx)and handled inWorkspace::run. Popup menus are built from aMenuKindinopen_menu(menus.rs); dialogs areModalvariants, built and submitted inmodal.rs.app.rsis the state and nothing a subject of its own could hold: what the window runs isimpl Workspaceblocks by subject, each beside the state it runs.chat_state.rsis a conversation as the window holds it andchat_run.rsa question and its answer;importing.rs,exporting.rs(a list or the cited papers as a file for another program),fetch.rs(查找全文),viewers.rs(the PDF views, the panes beside them, 版面),paper_files.rs,listening.rs(朗读, 播客),screen_run.rs,sorting.rs, anddev.rs(theWISP_STUDY_DEVsteps, debug builds only). New code goes into the file of its subject, or a new one, not intoapp.rs. The types those files define are passed on byapp.rs(pub use), so every module takes them fromcrate::app; a method or field another module needs ispub(crate).home.rs,library.rs,detail.rs,chat.rs,dialogs.rsareimpl Workspaceblocks that only render. A new feature usually means: aCmdvariant, its arm inrun(kept short: more than a few lines is a method in the subject's file), and the element that emits it.- Store writes go through
Workspace::change, which runs the closure, callsLibrary::reload(re-reads papers, fields, files, trash and refilters) and shows a toast on failure.Library::shownis indices intopapers, recomputed byrefilter. - Background work (PDF text extraction, lookups, chat streaming) runs on
cx.background_executor()and comes back throughthis.update. Each task captures the library id (chats also agenerationcounter) and stops when the user has since closed the library or started a new conversation; keep that check in new async code. A conversation that is answering and the runs ofworks.rs(筛选, 提取, 查找全文, translations) go on when their library is left: it is kept inWorkspace::parkedand their callbacks go throughWorkspace::in_libraryinstead of asking for the library on show (docs/dev/app.md, "Leaving a conversation does not stop it"). - A library has three conversations, told apart by
Talk(Library,Paper,Write); every function and command of the chat takes one, andchat_of!(lib, talk)borrows the one meant. shortcuts.rsowns every key binding.shortcuts::rebuildclears and re-binds all of them (the text field's too) from the defaults plusSettings::shortcuts; call it after any change. While 设置 › 快捷键 waits for a key, all bindings are cleared andWorkspace::record_keyreceives the key. A new shortcut needs an entry inSHORTCUTS, an action, its binding inrebuild, an.on_actioninhome.rsand an arm inWorkspace::shortcut.- Motion is
with_animationthrough the helpers inui.rs(spinner,fade_in). An animation's state lives under its element id, so give animated rows an id made from what they show (a paper id), not their position: the screening queue is sorted anew with every suggestion. Awith_animationhas the whole window drawn anew with every frame of the screen for as long as it runs, so it is for what ends, or shows only while something works; what stands while nothing happens, or moves in steps, is drawn when its picture changes (Beatsinmascot.rs;docs/dev/app.md, 工作动画). - Colours come only from
theme.rs, which has a light and a dark set (theme::dark());Workspace::apply_appearancepicks one from the setting or the system. Do not hard-code colours elsewhere; text on an accent fill isTheme::on_accent(), a library colour isAccent::strong()/soft(). - An element only hears the pointer moving over itself: while something is dragged (an edge, a floating window, a selection) a layer over the whole window takes the moves (
home.rs). - Text a reader may want to copy goes through
Workspace::selectable; an owner's change to a text field isTextInput::replace_range/replace_apart, one step of its Undo. - A row of a
uniform_listneedsw_full(), and a text it shows on one line goes throughui::one_line:truncatekeeps hard line breaks, which draw over the next row. ADivbuilt withflex_1()keeps its basis of 0 under a laterflex_none().w(…): give it a parent of that width. A wrappingTextInputunder ancestors whose widths are all percentages is measured at 240px: give its wrapper a pixel width. Wrapping text in aw_full().max_w(…)column nested in a wider one is measured at the wider width and drawn at the narrower, so a scroll container under it stops short of the end: give the column its width in pixels (设置's page column). A block centred withw_full().max_w(…).mx_auto()in a flex column whose width is not in pixels is as wide as its longest line, centred: put it in aflex().justify_center()row the column stretches (the subsections under a section being written, under 铺满). - Never query the database from render: cache in
Library::reloador once a frame before drawing. build.rsembeds every file underassets/(ofbranding/, onlyapp-icon.png) into the binary; icons are loaded by name throughui::icon. On Windows it also compiles the icon resource.
vendor/
gpui 0.2.2, taffy 0.9.0 and xattr 0.2.3 are vendored with local patches and wired in through [patch.crates-io]. Patched spots carry a quiet.md: comment and are listed in vendor/PATCHES.md. When changing vendored code, add a row there and keep the comment; do not bump these versions without re-applying the patches. GPUI APIs here are 0.2.2 plus those patches (for example grid_col_widths, ListState::estimated_scroll_metrics), so check vendor/gpui/src rather than upstream docs.
Scope
Ported from BiblioCell, without its datasets and web version. The roadmap (tools with CLI and MCP, the agent chat, search and import, screening, 写作, 图片库, 方法库 and 导言库, 批注, 改稿, 生图, 判断, 出处, 助手写, slides) and what each step left out are in docs/dev/roadmap.md. API keys are stored in plain text in settings.json; when empty, ANTHROPIC_API_KEY / OPENAI_API_KEY are read from the environment.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

