Files
cadcraft/AGENTS.md
T
FredApps aa1c896ef2 Copy the shared house rules into AGENTS.md.
The blocks come from craft-contrib at dde09ea31e2e457f5b4653a6e76f7cdf55944bdf. CLAUDE.md imports AGENTS.md. The house-rules workflow checks the copy.
2026-11-06 11:50:01 +01:00

15 KiB

House rules

These apply in every Craft repository. A later rule may be stricter, not weaker. The source is standards/house-rules-core.md in storytold/craft-contrib. Propose changes there, not in a copy.

  1. A person is accountable. Whoever runs an agent answers for what it opens and for its review comments.
  2. Check, then claim. Before writing code, read the issue comments, search pull requests for #N and the keywords, and check recent commits on main. Comment on the issue first. Release a claim you will not finish.
  3. Verify, don't guess. Open a definition before using it. Confirm the cause in the code, even when someone names a location.
  4. Keep fixes narrow and tested. Fix what the issue describes, where the bug is. Add a test that fails without the fix.
  5. Review the diff before opening a pull request. Identifiers exist as used, the test fails without the fix, nothing unrelated changed, and the description is true.
  6. Look for a better pull request. If another fixes the same thing, close yours when it is better or equal, and say why.
  7. Report only what ran. Say what you tested and what you could not run. Without a local build or test, say so and rely on CI before marking ready.
  8. main changes through a pull request. Do not push to it. Branch protection enforces this. There is no exception.
  9. Stop and ask only about licensing outside the allowlist, publishing, releases, a new remote, secrets, spending money, destructive git, and anything else hard to undo. Otherwise keep working. plan/ is a gitignored notebook, not rules. Without it, do not ask for it and do not stop.
  10. Keep secrets and personal details out of the repository, logs and requests.
  11. CI stays shared. Workflows call storytold/craft-common-actions. Do not change CI in a feature or fix pull request. If CI cannot cover a change, open an issue there.
  12. Guards say why. A check that looks removable says what it prevents. Read that before changing it.
  13. Instructions must be readable by everyone. No notes about one machine, and no links to files a reader cannot open. craftrules is retired. Do not link to it.
  14. Keep pull requests moving. Concurrent pull requests are fine; unanswered actionable feedback is not. Respond in 7 days, a reminder at 14, closure eligible at 30, from when an actionable request waits on the author. Suggestions and unconfirmed bot findings do not start the clock. A fix, explanation or agreed plan resets it; unrelated activity does not. Waiting on a reviewer or maintainer pauses it and does not count against the author. A maintainer decides closure; it is never automatic. Reuse search results, do not poll, and stop at a rate limit.
  15. No agent attribution. A pull request does not say an agent wrote it. A repository rule may not require that.

Rust Craft repositories

These apply to native Craft apps and to shared Rust libraries. Select them by repository type. A repository that merely contains some Rust does not take this block. Rules later in a repository's file may be stricter, but not weaker. The source is standards/house-rules-rust.md in storytold/craft-contrib.

  1. Never crash. Non-test code does not panic and has no unsafe, except where the repository file names an exception. Return errors, treat input as hostile, and bound recursion and allocations. New production crate roots copy the deny attribute from an existing crate: clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable. Every crash fix comes with a test that panicked before the fix.
  2. Clean room. Learn from observed behaviour and public specifications. Do not copy another product's code, assets, strings or artwork. Check a dependency's licence before adding it.
  3. Assets and fonts. Every asset is original or suitably licensed, and is recorded in ATTRIBUTION.md in the same change. Font files live in storytold/craft-fonts, not in the app repository.
  4. Rust only for native Craft apps. No handwritten JavaScript or TypeScript, and no Tauri, Electron or webview shell, in those apps. Shared tooling follows its documented technical scope and maintainer-approved exceptions. Craft PR Review's existing Tauri and TypeScript UI is one such exception. It does not relax this rule for native apps. Preserve any existing web build.
  5. Time goes through chrono. Do not hand-roll calendar conversion. For dates beyond what chrono can represent, follow standards/time.md.
  6. Contributor credits. Add or edit only your own person's entry in contributors/people.toml, and only after asking them. Never guess a name or hand-edit contributors.json.

Licence allowlist

Dependencies and assets use SPDX identifiers. An expression is allowed when every identifier is in this list. A repository may name a shorter list. It may not add an identifier here by editing its own copy of these rules.

  • ISC
  • MIT
  • BSD-2-Clause
  • BSD-3-Clause
  • Apache-2.0
  • OFL-1.1
  • Ubuntu-font-1.0
  • Bitstream-Vera
  • CC0-1.0
  • CC-BY-4.0
  • CC-BY-SA-4.0
  • LicenseRef-Public-Domain

LicenseRef-Storyteller-Trademark is not in this list. It covers Storyteller brand marks only, where a repository already says so.

CADCraft — instructions for agents

CADCraft is a clean-room, open-source, pure-Rust computer-aided design and drafting application targeting Autodesk AutoCAD parity — and superiority (speed, openness, agent control). It runs natively on macOS, Windows, Linux and FreeBSD, and on the web via WASM. Siblings with the same conventions: ../photocraft (Photoshop-class), ../vectorcraft (Illustrator), ../filmcraft (Premiere), ../lightcraft (Lightroom), ../pdfcraft (Acrobat), ../effectcraft (After Effects), ../designcraft (InDesign).

Start every session here

Read ROADMAP.md and docs/gaps.md. plan/ is an optional gitignored notebook (status, execution notes, plan/autocad/*). Do not ask for it and do not stop when it is absent. Licence choices stay inside the house-rules allowlist.

Never crash

People trust CADCraft with their drawings; a crash loses their work. This outranks feature work.

  • No panics in non-test code: no unwrap(), expect(), panic!, unreachable!, todo!, unimplemented!; no unsafe (unsafe_code = "forbid").
  • Errors are Result<T, E> through the crate's error type and ?. An unfinished feature returns an error or reports "not available yet"; it never panics.
  • Input-derived numbers are hostile (DXF/DWG files, command-line text, MCP/control params): get() not [i], checked arithmetic, no NaN casts, cap input-sized allocations and loop counts.
  • Bound recursion (nested/cyclic block references: MAX_BLOCK_DEPTH).
  • Last-resort guard: Session::execute and every step of an interactive command (its factory, begin, input, prompt, preview and the passes after it; crates/engine/src/guard.rs) run under catch_unwind; an escaped panic restores the drawing and reports an error. It does nothing on wasm, where a panic aborts.
  • Prove it: every crash fix lands with a regression test (see crates/engine/tests/panic_hunt.rs and hostile_dxf_does_not_panic in crates/io/src/tests.rs).
  • Every workspace crate manifest carries [lints] workspace = true to inherit [workspace.lints]; every production crate root carries #![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)].

Non-negotiables

  • Clean-room. AutoCAD is installed on the dev machine and may be observed black-box: run it, use its UI with synthetic drawings, take screenshots (by window id) stored only under plan/autocad/screenshots/ (never committed). Never read, disassemble or copy anything inside the AutoCAD bundle (names/listings only); never copy Autodesk fonts (SHX), hatch patterns (.pat), linetypes (.lin), templates, CUI/PGP files, icons, artwork or help text; never commit files produced by AutoCAD. File formats come from public specifications (Autodesk's published DXF Reference, the Open Design Alliance's public DWG specification) and our own synthetic tests. Never copy or link GPL/LGPL/AGPL code (LibreDWG, LibreCAD, QCAD, FreeCAD's planegcs, SolveSpace, OpenCASCADE) — don't even read their sources.
  • Assets — absolutely essential. CADCraft contains no Autodesk, Adobe or Avid iconography, images, fonts, patterns or artwork — ever. Every icon is drawn in code (crates/ui-egui/src/icons.rs), every hatch pattern and linetype is our own definition (crates/doc/src/library.rs), the drafting font is our own (crates/fonts/src/stroke.rs). Any file asset must be original, public domain/CC0, OSI-licensed, or redistributable Creative Commons (or licensed open source by a contributor who made it), and must have a row in ATTRIBUTION.md with author, source and licence (cargo xtask assets enforces it). The only exception is the ArtCraft brand in docs/brand/ (trademarks, docs/brand/LICENSE-brand.txt). Screenshots of Autodesk software are never committed. Breaking this rule is the most serious mistake you can make in this repo.
  • Fonts live in storytold/craft-fonts, never in this repo. It is an optional build input (CRAFT_FONTS_DIR, embedded by crates/fonts/build.rs), never a Cargo.toml dependency. Code and tests must work without it.
  • Shared test corpora live in separate repos (storytold/<app>-corpus); never commit large binary fixtures here.
  • Everything is a command. User-visible behaviour = a command in crates/engine/src/cmd/* (CommandSpec: id = AutoCAD's command name in lower case, label, menu path, shortcut, aliases, params doc, enabled, JSON run, optional interactive prompt machine) + tests. UI-only commands live in crates/ui-egui/src/menus.rs (UI_COMMANDS). The command line, menus, toolbar, Tool Sets, scripts, CLI, control channel and MCP all reach the same commands.
  • Programmatic calls never open dialogs. engine.execute runs the JSON form with defaults; only menu/toolbar invocation starts the interactive prompt sequence.
  • Layering is enforced by cargo xtask layers: L0 geom, dxf → L1 color, doc → L2 fonts, render, constraints → L3 io → L4 engine → L5 ui-egui, mcp → apps. Nothing below L5 depends on egui/eframe/winit/wgpu/rfd. The UI crate is swappable.
  • The UI is thin: panels read engine state and act through app.run(id, params) / app.start(id) / app.cmdline(text). Colours come from theme::Tokens.
  • Rust only (no handwritten JS/TS). Never break wasm (cargo xtask wasm).
  • Quality gates before every commit: cargo xtask ci (fmt, clippy -D warnings, tests, assets, layers, wasm). Commit after every feature arc that builds.

Running and looking at the app

  • cargo run --release -p cadcraft -- --sample --control PORT (sample drawing + control channel). Pick a free port; other crafting apps use control ports too.
  • Drive it with JSON lines on 127.0.0.1:PORT:
    • {"id":1,"method":"cmdline.input","params":{"text":"circle 0,0 5"}} — type at the command line exactly like a user (prompts, keywords, @dx,dy, @d<a, direct distance entry).
    • {"id":2,"method":"engine.execute","params":{"command":"line","params":{"points":[[0,0],[10,0]]}}} — JSON form.
    • {"id":3,"method":"ui.screenshot","params":{"path":"/tmp/shot.png"}} then read the PNG.
    • Methods: crates/ui-egui/src/control.rs; protocol doc: docs/control-protocol.md.
  • For UI work, look at the result (screenshot, read the PNG) and compare with plan/autocad/screenshots/. If no frame is presented (screen locked) use ui.render or cadcraft-cli.
  • Headless: cadcraft-cli run --sample --script 'LINE 0,0 10,10\n' --export out.png; cadcraft-cli info file.dxf; cadcraft-cli mcp.
  • Shell gotcha: mv/cp may be aliased interactive — use /bin/mv -f / /bin/cp -f.
  • Parallel agents: separate CARGO_TARGET_DIR per agent; edit only the crates you own; delete your target dir when done (disk).

Roadmap

ROADMAP.md (committed) is the one-page summary: stage, parity numbers, estimates. The assessment is docs/target-app-parity.md, the work list docs/gaps.md (pick work from its top rows), milestones docs/roadmap.md, deep checklists docs/geometry-parity.md, docs/ui-parity.md, docs/file-format-parity.md, docs/hardware-parity.md, docs/localization-parity.md. PRs don't edit these docs: name the affected rows in the PR description, and maintainers update the rows, status lines and revision history in batches, which keeps open PRs from conflicting. cargo xtask parity regenerates the menu-breadth checklist in docs/parity-checklist.md.

Contributor credits (About window)

  • About ▸ Contributors/Models are compiled into the binary from contributors/contributors.json (commit stats; never hand-edit) and contributors/people.toml (names people chose for themselves). See docs/contributors.md.
  • Agents working for a contributor: when you prepare a PR, check whether your human's GitHub username has a [people.<username>] entry in contributors/people.toml. If not, ask them once whether they want to be credited by more than their username: a real name, a display name, and/or their public GitHub profile name (sync_github_name = true). If yes, add only their own entry (copy the template at the top of the file) and include it in their PR, committed as them. If no, change nothing: they are credited as @username anyway.
  • Never add, edit, guess or copy anyone else's entry or name (not from git config, commit authors or GitHub profiles). Never hand-edit contributors.json.

CI workflows

  • Workflows in .github/workflows/ call the shared workflows in storytold/craft-common-actions at @main, with their inputs and secrets. No other jobs: if no shared workflow does what's needed, it doesn't go here.
  • Don't add or change CI in a feature or fix PR. If the existing workflows can't build or test a change, link an existing craft-common-actions issue or PR, or open a new issue, or a PR only for a small fix that is safe for every app and does not increase CI time.
  • Some workflow files here still run their own jobs. Don't add to them. Moving a job into craft-common-actions is its own task, never part of another PR, and the job stays here until a shared workflow runs it.