agentleFS
xuzhougengxuzhougeng/WispStudy/CLAUDE.md

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.

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
  1. Very specific:

    Never query the database from render: cache in Library::reload or once a frame before drawing.

    line 88

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

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 no rustfmt.toml: the code is hand-formatted with long lines and one-line if x { return } bodies. Do not run cargo fmt; match the surrounding style.
  • Windows needs the MSVC build tools.
  • A Mac with only the Command Line Tools (no Xcode, so no metal compiler) fails in gpui's build script with xcrun: error: unable to find utility "metal". Add --features gpui/runtime_shaders to every cargo command that builds the app (cargo run, cargo build, cargo clippy --all-targets, cargo test); -p wisp_core commands need nothing, and scripts/package-macos.sh does it by itself.
  • CI runs clippy with -D warnings and the tests on Windows and macOS, and the three windowless crates on Linux. A release is a pushed tag v<version> matching Cargo.toml, always signed. A pull request touching scripts/ or the workflow rehearses the packaging unsigned, so keep site/ out of scripts/. 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 of docs/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" in docs/dev/release-and-site.md.
  • WISP_STUDY_HOME moves both the data folder and settings.json to one directory; use it for any manual run so the real library in Documents/WispStudy is not touched.
  • Debugging without the real library, an API key or a screen (demo data with the seed example, the structure, docx and mermaid examples for files and diagrams that come out wrong, mock_model as a fake model endpoint, model_probe to ask real models the same things and compare what became of the manuscript, cache_probe to see how much of a conversation's requests a service reads from its cache, WISP_STUDY_DEV steps that script a debug window and take shot: screenshots): docs/dev/debugging.md. A new debug step is an arm of dev_step in src/dev.rs and listed there.
  • In a #[cfg(test)] module of a file that has use gpui::*, do not write use super::*: it brings in gpui's test attribute, and #[test] then fails with "recursion limit reached". Import the names you need.

Where the detail is

Before working onRead
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 savingdocs/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 inputdocs/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 appdocs/dev/debugging.md
CI, signing, releases, site/docs/dev/release-and-site.md
What each step of the roadmap built and left outdocs/dev/roadmap.md
Vendored patchesvendor/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 EXISTS batch guarded by SCHEMA_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), then title_key; a PDF taken in is also known by its bytes (Store::paper_holding, the sha256 of resources), so the same file under another name is not a second paper. Trashed papers stay in papers (marked by a trashed_papers row) so they keep blocking re-import.
  • Store::in_memory is what tests use.
  • Paper::fulltext is computed, not stored: missing, linked, stored, or textless (a full-text file is there and no text came of any). Why a file gave no text is the sentence kept in fulltext_text.error; fulltext::failure_kind tells 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 key excluded is 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 in call_in. Nothing else: wisp <tool> reads its flags off the schema (cli_args), and mcp::handle lists and calls whatever the catalog holds. The test every_tool_is_callable fails 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_section changes a section where its words stand, write_section writes the whole of one: as one tool, a model replaced a section where it meant a change). tools::fitted reads 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, run model_probe on 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 what chat_step sends. 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, no library); the home page's (draft_catalog) also reads the libraries on the shelf through the tools of ACROSS, which never write (tools::across).
  • ToolDef::writes marks the tools that change a library (the WRITING list); wisp mcp --read-only leaves them out, and the chat reloads the library after one ran. ToolDef::confirm (the CONFIRMING list: 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_section and set_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 set screening.
  • Tables added after the first schema are made beside the library's own (CREATE TABLE IF NOT EXISTS, no version bump), columns through store::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.rs holds all state in one root view, Workspace (lib: Option<Library> is the open library, None is the home page). Every click is a Cmd enum value (commands.rs), wired with self.on(Cmd::…, cx) and handled in Workspace::run. Popup menus are built from a MenuKind in open_menu (menus.rs); dialogs are Modal variants, built and submitted in modal.rs.
  • app.rs is the state and nothing a subject of its own could hold: what the window runs is impl Workspace blocks by subject, each beside the state it runs. chat_state.rs is a conversation as the window holds it and chat_run.rs a 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, and dev.rs (the WISP_STUDY_DEV steps, debug builds only). New code goes into the file of its subject, or a new one, not into app.rs. The types those files define are passed on by app.rs (pub use), so every module takes them from crate::app; a method or field another module needs is pub(crate).
  • home.rs, library.rs, detail.rs, chat.rs, dialogs.rs are impl Workspace blocks that only render. A new feature usually means: a Cmd variant, its arm in run (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, calls Library::reload (re-reads papers, fields, files, trash and refilters) and shows a toast on failure. Library::shown is indices into papers, recomputed by refilter.
  • Background work (PDF text extraction, lookups, chat streaming) runs on cx.background_executor() and comes back through this.update. Each task captures the library id (chats also a generation counter) 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 of works.rs (筛选, 提取, 查找全文, translations) go on when their library is left: it is kept in Workspace::parked and their callbacks go through Workspace::in_library instead 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, and chat_of!(lib, talk) borrows the one meant.
  • shortcuts.rs owns every key binding. shortcuts::rebuild clears and re-binds all of them (the text field's too) from the defaults plus Settings::shortcuts; call it after any change. While 设置 › 快捷键 waits for a key, all bindings are cleared and Workspace::record_key receives the key. A new shortcut needs an entry in SHORTCUTS, an action, its binding in rebuild, an .on_action in home.rs and an arm in Workspace::shortcut.
  • Motion is with_animation through the helpers in ui.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. A with_animation has 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 (Beats in mascot.rs; docs/dev/app.md, 工作动画).
  • Colours come only from theme.rs, which has a light and a dark set (theme::dark()); Workspace::apply_appearance picks one from the setting or the system. Do not hard-code colours elsewhere; text on an accent fill is Theme::on_accent(), a library colour is Accent::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 is TextInput::replace_range / replace_apart, one step of its Undo.
  • A row of a uniform_list needs w_full(), and a text it shows on one line goes through ui::one_line: truncate keeps hard line breaks, which draw over the next row. A Div built with flex_1() keeps its basis of 0 under a later flex_none().w(…): give it a parent of that width. A wrapping TextInput under ancestors whose widths are all percentages is measured at 240px: give its wrapper a pixel width. Wrapping text in a w_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 with w_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 a flex().justify_center() row the column stretches (the subsections under a section being written, under 铺满).
  • Never query the database from render: cache in Library::reload or once a frame before drawing.
  • build.rs embeds every file under assets/ (of branding/, only app-icon.png) into the binary; icons are loaded by name through ui::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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.