Skip to content

Latest commit

 

History

History
105 lines (103 loc) · 25.2 KB

AGENTS.md

File metadata and controls

105 lines (103 loc) · 25.2 KB

quarry

Rust and C/C++ IDE. Tauri 2 + React 19 shell; clangd, rust-analyzer and lldb-dap do the real work.

  • Scope: Rust + C/C++ only, CLion parity on the daily loop. Never a general editor.
  • CLion is the reference for both UI and features — reverse-engineer it with the rea MCP tools when the target behaviour is unclear, instead of guessing; screenshots live in the gitignored docs/reference/.
  • Plan is docs/plans/001-clion-parity.md — parity matrix, slices, estimates, non-goals; read before feature work.
  • Non-goals stay non-goals: profiler, remote, embedded, DB, Docker, AI, plugin API, other languages.
  • Toolchains are detected, never bundled — probe PATH then xcrun --find; GUI launch carries launchd's PATH.
  • A PATH-only probe misses Homebrew and cargo binaries — a Dock-launched app sees /usr/bin:/bin:/usr/sbin:/sbin; src-tauri/src/format/tool_search.rs therefore searches PATH first, then /opt/homebrew/bin, /usr/local/bin and $HOME/.cargo/bin, and taplo 0.10.0 at /opt/homebrew/bin/taplo is only reachable that way.
  • Machine paths: rustup shims /opt/homebrew/opt/rustup/bin; lldb-dap and clang-format only via xcrun; cmake and ninja exist at /opt/homebrew/bin (Homebrew), which a GUI launch does not see on PATH.
  • No cargo run as a debug launch — build first, pass lldb-dap the binary from cargo JSON.
  • Rust module is build_task.rs, never build.rs (Cargo's build script).
  • src/ only, @/* maps to ./src/*; no root-level lib/.
  • Logic is src/lib, rendering is src/ui — the feature directory name is kept on both sides (lib/editor/theme.ts, ui/editor/Editor.tsx); @/ for cross-tree imports, relative only inside one directory; consts in src/lib/consts.
  • No file over 200 lines — scripts/check-file-size.ts runs as the gate's first step and fails on a new offender or on a stale entry in docs/refactor/oversized.txt, which may only shrink.
  • Split Rust by module directories (foo.rs → foo/mod.rs + mod bar; + pub use), so lib.rs needs no edit; never include!("partN.rs"), which keeps one scope and is not a module split at all (measured 2026-10-23: 195 compile errors).
  • Stylesheets split with bun scripts/split-css.ts <file> — section files under <name>/ plus an @import index, so cascade order survives.
  • A new stylesheet is named for what it styles (run-log.css), never numbered — the existing 1-root.css…20-menubar.css are legacy and keep their names; styles.css order is what decides the cascade, not the filename.
  • Starter file contents live in src-tauri/src/new_project/templates.rs, and inserted snippets in src/lib/consts/generate.ts — a template is content the user reads and judges, and inline in a format! it cannot be asserted whole, edited in one place, or found by search (2026-11-09: the C++ starter, the Rust library and both .gitignore files were string literals inside create_project).
  • Gates: bun check for types, bun fmt --check for formatting, biome lint for lint, bun test for frontend units, bun run gate before a commit — hard tabs 4 wide, print width 100; warnings fail, so leave zero.
  • A biome lint failure can hide its error past the diagnostic cutoff — the output shows warnings and a bare "Found 1 error"; rerun bunx biome lint --max-diagnostics=500 --reporter=json <path> and read the severity: "error" entry (2026-11-09: a test helper named escape tripped noShadowRestrictedNames).
  • A component test that needs a DOM sets up its own window — @/test/dom registers once per process, so a new file importing it starved three neighbour dialog tests of document; src/test/render.tsx adds only what is missing and deletes only what it added (2026-11-09).
  • fireEvent.input reaches React's onInput, never its onChange, in this harness — a field a DOM test types into listens with onInput (src/ui/structure/StructurePalette.tsx); fireEvent.change is inert too, so neither is a substitute.
  • bun run gate runs two lanes at once and reports milliseconds — the frontend checks and the cargo chain are independent, and inside a lane the steps stay sequential because cargo holds the target directory lock; cargo check --all-targets is deliberately absent because clippy typechecks every target and then lints it, so re-adding the check pass buys a second compile and nothing else (2026-11-09: 10.65s to 5.62s on one crate rebuild).
  • The gate runs the tests with cargo-nextest when it is installed and falls back to cargo test — same suite, its own parallel runner and no doc-test compile (6.99s to 4.95s); ci.yml installs it so the fallback is not the path that ships.
  • Tests are Cargo and GoogleTest in one dock — list_tests returns TestDiscovery (items, the gtest program asked, one note per source that failed); a gtest list comes only from a .quarry/launch.json preset naming a program, never a guessed path.
  • A Cargo test list is built per binary, never from cargo's Running … headers (2026-11-14) — cargo prints those headers on unbuffered stderr while the name: test lines go to buffered stdout, so any merged-stream attribution labels an integration case with whichever binary the interleave put first (measured: tests/parity.rs shown under src/lib.rs); cargo test --no-run --message-format=json gives each target's src_path and executable, and each binary is listed on its own.
  • A gtest case is discovered with <program> --gtest_list_tests under a 20 s kill and run as --gtest_filter=Suite.Case through the same capture path as Cargo — the C++ gutter places markers from TEST/TEST_F/TYPED_TEST lines, matched by suite and case.
  • scripts/unstyled-classes.ts is a gate step and scans every src/ui tsx — it reads template holes, ternary branches and comparison operands are excluded, so a class with no rule fails the gate; new rules go in a stylesheet named for what it styles and a sheet over 200 lines is split with bun scripts/split-css.ts, since the file-size step covers CSS too (2026-11-09: it had been reading one debugger subtree and one quoted literal, and 63 classes had no rule).
  • C/C++ formatting always expands every brace pair — clang-format gets the nearest .clang-format plus AllowShort*: Never|None|false, so a one-line body never survives a format.
  • Config files are languages of their own — src/lib/editor/languages.ts maps TOML/JSON/YAML by extension and the names with no revealing one (Cargo.lock, Cargo.toml.orig, Gopkg.lock, Pipfile, poetry.lock, uv.lock, .cargo/config), and its single languageNameForPath table also feeds the status-bar label so the two cannot drift; CLion ships the same split as bundled toml/json/yaml plugins.
  • Which extensions are Rust or C++ lives only in src/lib/consts/extensions.ts — fileKind, editor/languages, lsp/served, lsp/rootSignals and generate/model all import it; the same list used to exist five times, and .hxx was known to one copy only, so a header was classified as C++ yet not served or highlighted.
  • Format dispatch is per language, never silent — JSON is formatted in the frontend keeping the file's indent and trailing newline and leaves invalid text untouched, TOML needs a detected taplo/taplo-cli or says no formatter for .toml: install taplo-cli, YAML names the gap, and Rust/C++ keep the server and clang-format paths.
  • bun fmt is the formatter, configured in bunfig.toml [fmt] (useTabs, tabWidth = 4, printWidth = 100) — Biome no longer formats; it lints only, so biome check would flag tab/width drift the formatter owns.
  • bun fmt also formats Markdown, this file included — it rewrites *emphasis* to _emphasis_, so an AGENTS.md edit that skips bun fmt fails CI on that commit and on every later one until fixed; run it after editing this file.
  • No typescript dependency: bun check is the type checker and vite build transpiles; verified by removing the package and passing both (2026-10-22).
  • bun only — never npm; bun run build keeps run (built-in subcommand).
  • Full-document LSP sync only; revisit only on a measured stall.
  • CLion 2026.2's C++ engine is radler, not the old Java cidr highlighter — colour keys are OCHighlightingKeys (53 in intellij.cidr.psi.base.jar), labels in plugins/clion-radler/lib/modules/intellij.clion.radler.core.jar!/messages/RadBundle.properties (color.*), defaults in that jar's colorSchemes/OC*.xml; grep those, never chase CidrHighlighter.
  • A jar is deflated, so rg over it or a class name finds nothing, and REA opens an archive but refuses search_strings on target_kind: archive — extract with unzip first, then grep the extracted class constant pools or javap -v.
  • clangd reports a static member as variable + static + classScope, never property, and answers auto with enum + deduced — semanticTokens.test.ts pins those measured shapes, so a colour on the wrong token fails the suite.
  • One DAP session per project root, but one LSP session per server kind — rust-analyzer starts only when the root has a Cargo.toml, clangd only for a compile_commands.json, CMakeLists.txt or a C/C++ source, and both run together when both are present; rootSignals.ts probes bounded (depth 4, 64 dirs, skipping target/node_modules/.git/build/out).
  • Every language-server session is keyed {kind}::{root} — the root parameter of every lsp_* command carries that id, so a request built from a bare project root answers "unknown session" and is swallowed by a try/catch, which reads as a dead feature.
  • A feature guard means a running session serves the file — servedByRunningServer(path, running) and sessionForPath(...) in src/lib/lsp/served.ts; an extension-only check sends a .c file to a rust-only project's clangd session and reports an error for it.
  • Distant LSP features read the session from src/lib/lsp/context.ts — the shell publishes root plus running set via setLspContext, and sessionForContext(path) answers without drilling props through Outline, Goto, breadcrumb, problem actions; the lsp_* wrappers throw expects a session id, got a path in dev so a missed call site is loud.
  • A server only receives files it serves — src/lib/lsp/served.ts holds one extension table per server (rust-analyzer .rs; clangd .c .h .cc .cpp .cxx .hh .hpp), and an unserved path is never opened, changed or closed; without that gate rust-analyzer was handed Cargo.toml, Cargo.lock and .gitignore, and the status chip claimed coverage it did not have.
  • The clangd hand-off configures the profile the build was given — start_lsp carries the window's effective profile, a tree configured for another one is reconfigured once and reported once, and a multi-config tree is never asked for a CMAKE_BUILD_TYPE (its cache is empty, so asking would reconfigure every start).
  • PATH-mutating Rust tests share one lock in src-tauri/src/test_support.rs — the helper used to be copied per test module, so each copy held its own OnceLock and two modules mutated the process-wide PATH at once; a resolve test failed only when a new PATH-reading test changed the schedule.
  • Never publish a crate named quarry — use quarry-app, quarry-lsp, quarry-dap; frontend @jyz/quarry-*.
  • MIT. Zed is GPL-3.0: read its debugger code for patterns, copy nothing.
  • .gitignore carries .DS_Store at the top level.
  • lldb-dap is Xcode's LLVM 21.0.0; readMemory, disassemble and data breakpoints work — measured in docs/spikes/dap.md.
  • A CMake project needs -DCMAKE_BUILD_TYPE at configure time or it has no debug info — a single-config generator ignores --config at build time, so the binary is built without -g, lldb resolves no breakpoint, and the debugger looks broken; scripts/dap-cpp-probe.ts builds one project both ways and asserts only the configured one stops.
  • Never rewrite a CMakeCache.txt the product did not write (2026-11-14) — the parity probe configures CLion-shaped fixture trees itself, so an -U CMAKE_BUILD_TYPE or any cache edit makes opening the project look like a reconfigure and fails the generator: Xcode / Ninja Multi-Config rows; report what the cache says and let the next configure own it.
  • Editor popups are bounded by the editor pane, not the window — tooltips({ tooltipSpace }) in extensionsBehaviour.ts gives CodeMirror the scroller's rect via tooltipSpace() (src/lib/editor/tooltipSpace.ts), so a caret near the pane's bottom flips the hover above it instead of dropping it over the panels below; a pane shorter than 200px falls back to the window so a popup is never hidden.
  • Rail buttons are toggles over one region each — Explorer and Source control pick the left column's view (railCollapsed + gitOpen), light only while that column shows that view, and a second click hides the column; a dock button selects its tab and expands the dock, and a second click collapses it; tool windows that need a project are disabled without one.
  • A native menu accelerator owns its chord before the webview sees it, so an in-app binding on the same chord never runs; SHORTCUT_GROUPS marks those rows menu: true and src/ui/app/shortcuts.test.ts pins them against src-tauri/src/menu/mod.rs.
  • The docs site reuses the app, and deploys from the repository root — website/ imports src/lib/themes/*, src/ui/app/shellShortcuts.ts and assets/icon.svg through the @/ alias, so Vercel project quarry-docs builds with root . and the commands in vercel.json, serving quarry.jyz.land; a website-only build context cannot see those files.
  • The docs site installs only website/package.json, so any bare import inside src/lib or src/ui that website/ does not declare fails on Vercel while passing locally — the app's node_modules sits one directory up, which is exactly how @xterm/xterm reached a production build; bun scripts/docs-deps.ts walks the import graph from website/src into src/ and is a gate step, and a missing package gets added to website/package.json rather than left to hoisting.
  • Terminal rendering and keystrokes belong to xterm, not React — useXterm.ts owns one emulator per PTY; a prompt that repaints itself with carriage returns needs a VT grid, which a line parser cannot be taught. focusTarget.ts decides whether a click may take focus.
  • Raw PTY bytes reach the emulator through subscribeRaw in useTerminalSessions.ts, which also replays the handshake buffer — a blank panel beside a live pid means a missing subscription, not a PTY fault.
  • A terminal retires its own map entry when the shell is reaped, guarded by Arc::ptr_eq — so a reused id is safe, and the drop closes the master and writer instead of leaking them to tab close.
  • No kill calls a bare wait() — teardown::until_gone bounds every reap by KILL_GRACE and hands a survivor to its own thread, in both the pty and run paths.
  • Rust pretty printing needs initCommands: ["command script import <sysroot>/lib/rustlib/etc/lldb_lookup.py"] — without it Vec/String arrive as raw structs, silently.
  • Never gate memory or disassembly on supportsMemoryReferences — it is false while frames carry instructionPointerReference and both requests work.
  • evaluate works on Rust only when the request carries the stopped frame's frameId — without it lldb-dap refuses every expression, so a no-frame probe reads as "Rust is broken"; measured 2026-11-09.
  • The Rust evaluate parser rejects method calls and as casts — simple names, arithmetic and v[0] answer, while v.len() and tag as u32 fall back to Objective-C++ and fail.
  • Data breakpoint dataId is <hex>/<size> with no 0x, hitBreakpointIds is null, and the stop reports the line after the store.
  • realpath the project directory before launch — /var/… versus /private/var/… leaves every breakpoint unverified.
  • Every git run goes through git::output_within with GIT_TIMEOUT (30s), never a bare Command::output() — a held index lock or a credential prompt otherwise pins the command thread forever.
  • The DAP pump bounds its wait by adapter liveness, not by frame silence — a paused debuggee emits nothing for minutes, so wait_frame polls PUMP_POLL_INTERVAL and only ends when the process is gone.
  • cargo fmt in src-tauri rewrites lsp.rs — that file is not rustfmt-clean, so a crate-wide format adds an out-of-unit diff. Format the one file instead: rustfmt --edition 2024 src/dap.rs.
  • A dispatched unit's report is a claim, not evidence: check the call site exists, not just the helper — one shipped an unused resolveDebugArtifact and an unwired panel, another left its lib.rs registration out, which fails only at runtime.
  • An empty handler is the new unwired panel — a parity batch shipped four commands with real labels, accelerators and run: () => {} plus a keymap file nothing imported; audit command → handler → API → visible result, and rg 'run: \(\) => \{\}' in commandList.ts must return nothing.
  • Updater signing key: private ~/.tauri/quarry-updater.key (no password), public key in src-tauri/tauri.conf.json plugins.updater.pubkey — never print or commit the private one, never rotate it once a release ships, or every installed app orphans.
  • A local bun run tauri build needs TAURI_SIGNING_PRIVATE_KEY set (the key path or content) because bundle.createUpdaterArtifacts is on; without it the bundler refuses to produce updater artefacts.
  • Alphas publish from this Mac with bun run release:local — signed macOS bundle, latest.json, release, then a check that the public manifest serves it.
  • The release build is universal (--target universal-apple-darwin), so its artefacts live under src-tauri/target/universal-apple-darwin/release/bundle/, and reading target/release/bundle picks up the previous arch-only build — the version guard catches it as the updater archive was signed for <old version>; verify with lipo -info on Contents/MacOS/quarry.
  • The app icon is drawn on Apple's grid by scripts/make-icon.swift — the rounded plate is 824 of a 1024 canvas and the rest is transparent, because art that fills its canvas renders oversized in the Dock; bunx tauri icon src-tauri/icons/icon.png then fills the Windows, Store and ico art from it.
  • CI builds all three platforms only for quarry-beta* and v* tags, or a manual dispatch; scripts/bump-version.ts keeps five version files in step — root package.json, src-tauri/Cargo.toml, src-tauri/Cargo.lock, src-tauri/tauri.conf.json and website/package.json, so stage all five or the docs site keeps claiming the previous release.
  • The workflow builds Windows, so Rust must compile there: gate every std::os::unix, PermissionsExt and from_mode behind #[cfg(unix)]; a macOS-only build hides it until CI.
  • Linux bundles AppImage and Windows nsis only — the deb and msi bundlers reject the hyphen in X.Y.Z-alpha.N (invalid version), AppImage and nsis accept it.
  • Main agent may push alpha tags and publish test releases here; subagents never push, tag or release. Tag quarry-alphaN pairs with version X.Y.Z-alpha.N (bun scripts/bump-version.ts alpha), and a stable tag is v<version>.
  • Landings go through a pull request, never a push to main (user, 2026-11-02): branch, git push bot HEAD:refs/heads/<branch>, open the PR as jyzbot, and wait — GitHub forbids self-approval, so the owner approves and merges, and the alpha is cut from the merged main. The bot remote is https on purpose: github-jyzbot ssh was timing out on port 22 here (2026-11-02), while the https path already authenticates as jyzbot through gh auth git-credential.
  • Do not flood the owner's GitHub notifications (user, 2026-11-10: "stop making prs and ci fails notify my github account", "this repo only") — batch a wave into one PR per area instead of a PR per tiny change, never leave main red, and keep the repo muted rather than muting the account globally; the mute needs the notifications scope, which neither gh login here has, so it is gh auth refresh -s notifications then gh api -X PUT /repos/JeffreyJYZ/quarry/subscription -f ignored=true as the owner.
  • main protection must keep dismiss_stale_reviews off — with it on, the release tag push dismissed the owner approval within seconds and every PR needed an admin bypass (measured 2026-11-04); 1 approval, no code owners, no last-push rule, enforce_admins false.
  • Bump the version inside the feature branch, not in a second PR — protection blocks a direct main push, so a separate bump PR doubles the approvals for one alpha; bun scripts/bump-version.ts alpha before the branch is pushed keeps each release to one review (2026-11-03).
  • Standing permission (user, 2026-10-26): release an alpha whenever there is something to ship — no ask, no "want me to cut a release?"; bump, push, bun run release:local, report the version.
  • Report a release by version and the PR link only — the app auto-updates, so dmg and latest.json URLs are noise the user deletes (2026-11-04); never paste them unless asked.
  • The release upload prints nothing through a | tail pipe for minutes, and that is not a hang — gh release create uploads the dmg and the updater tarball before it prints anything; check for a live bun run scripts/release-local.ts process before retrying, or the second run collides with the first (measured 2026-11-04).
  • Never pipe a build, release or test sweep through tail/head (user, 2026-11-04: "no more pipes!!! so i can actually see it") — the pipe buffers every line until the command ends, so a three-minute upload reads as a hang and nothing is visible; run it unpiped and let the output stream.
  • Gate one worktree at a time, unpiped — every worktree owns its own target/, so six parallel gates compiled the dependency tree six times and load hit 78 on four performance cores, one cargo nextest step alone taking 138s (measured 2026-11-09); serial, or one shared CARGO_TARGET_DIR, and never through tail/head, which hides the progress.
  • Every gate run goes in the background (background: true) — a foreground bun run gate blocks the whole turn for minutes while it compiles (user, 2026-11-09: "REMEMBER ALL GATE RUNS IN BACKGROUND").
  • release:local refuses a commit whose CI run has failed or been cancelled, and runs bun run gate itself before building — it does not wait on a queued or running run (CI repeats the same nine steps), and --skip-ci is the loud escape hatch for both checks.
  • The updater needs updater:allow-download and updater:allow-install separately in src-tauri/capabilities/default.json; allow-download-and-install covers only that one command, so download() then install() dies Command plugin:updater|download not allowed by ACL at runtime, never at gate.
  • src/lib/updates/capabilities.test.ts guards that pairing — it reads the capability file and the store, so a renamed updater call fails the suite instead of failing silently in the app.
  • The updater installs into the bundle it is running from, so a second copy silently freezes — 2026-10-26: /Applications/quarry.app sat at alpha.7 while alpha.16/17 self-updated the repo bundle; check both defaults read <app>/Contents/Info.plist CFBundleShortVersionString values when a version looks wrong.
  • Never swap /Applications/quarry.app by hand — a self-update is the only end-to-end proof the ACL and signature work; replacing the bundle skips the one path that broke (user, 2026-10-26).
  • Verification ladder: bun run gate and bun run build; Rust adds cargo test, cargo check --all-targets, cargo clippy --all-targets -- -D warnings; LSP work adds scripts/lsp-*.ts, debugger work scripts/dap-*.ts. Evaluate is measured by scripts/dap-eval-contexts.ts, which passes; the older dap-eval-probe.ts failures were no-frame-id requests.
  • The debugger probes need sudo DevToolsSecurity -enable once — until then every launch sits 20 s on the Touch ID prompt and reads as dap-cpp: launch timed out; enabled 2026-11-05, and dap-cpp-probe, dap-spike and dap-eval-contexts then pass.
  • Screenshot a launch only once the window has painted — an 8 s capture of the installed app showed a blank frame twice (2026-11-05) and read as a crash; the same session renders normally seconds later, so wait for a rail icon or a tab before calling it broken.
  • UI work adds bun run scripts/unstyled-classes.ts — it prints every class a component uses that no stylesheet defines, which is how a restructure silently drops styling; the count must be 0.
  • A branch that passes the gate can still break it once merged — two findings each appended to files/tests_items.rs, 211 lines together, and only the merged tree showed it; run bun run gate on main after landing several branches and before cutting the release (2026-11-08).
  • A tauri dev window outlives its CLI — killing bun run tauri dev leaves target/debug/quarry running, so six restarts left seven quarry windows on screen; kill target/debug/quarry too and check pgrep -f target/debug/quarry after each run.