* Use chrono for UTC/calendar conversion instead of hand-rolled copies
Replaces the hand-rolled civil_from_days / civil copies and the hand-written
weekday / leap-year / days-in-month helpers with chrono. chrono is already a
workspace dependency (used by crates/text), so this reuses that entry and just
adds `chrono = { workspace = true }` to the engine and desktop app rather than
a second version.
- apps/deckcraft logging `timestamp` now formats through chrono (private
civil_from_days deleted).
- engine cmd::design `civil` (days since 1970 -> date, used for comment
timestamps in review.rs) uses chrono::NaiveDate.
- text datetime `DateTime::is_valid` / `weekday` use chrono::NaiveDate instead
of a hand-rolled leap-year table and days-since-1970 weekday.
Output is byte-identical and pinned by the existing logging, design and
datetime-field tests; each converted helper keeps a proleptic-Gregorian
fallback for dates outside chrono's NaiveDate range.
Follow-up to storytold/cadcraft#1785
* text: make chrono available on wasm32
is_valid/weekday in crates/text/src/datetime.rs use chrono unconditionally,
but chrono was only declared under the non-wasm target, so the crate (and
engine/pdf/render/ui-egui depending on it) failed the wasm32-unknown-unknown
check in `cargo xtask ci`.
- crates/text: declare chrono unconditionally (wasm-safe `std` baseline),
and keep `clock` in a separate cfg(not(target_arch="wasm32")) entry for
now_local()'s local clock, which is already wasm-gated to return None.
- workspace: drop `clock` from the shared chrono entry so it is no longer
forced onto wasm builds (engine uses chrono unconditionally too); `clock`
is now requested per-crate only where the local clock is read.
* Never panic on a clock outside chrono's range; harden the civil fallback
logging.rs timestamp(): chrono's From<SystemTime> unwraps, so a clock past
year 262143 panicked inside the logger. Use the fallible DateTime::from_timestamp
and read an out-of-range or pre-epoch clock as the epoch, as the old saturating
code did. Years past 9999 are written with {:04} like before, because %Y adds a
'+'. Tests cover both cases.
cmd/design.rs civil_fallback(): make the hand-rolled fallback's year arithmetic
saturating so civil() cannot overflow or panic at i64::MAX/MIN (the engine rule
forbids crashes and unchecked arithmetic). Behaviour is unchanged for every real
input; a test exercises both extremes. The output year is formatted with {y:04}
by review.rs, so no %Y prefix issue.
crates/text/src/datetime.rs: checked after review; is_valid already limited the
year to 1..=9999 before this PR, weekday() is only reached for valid dates, and
all its arithmetic is checked/euclidean, so no change is needed.
* Don't build an unrepresentable SystemTime in the far-future test
UNIX_EPOCH + Duration::from_secs(u64::MAX / 2) overflows Windows'
SystemTime and panicked before timestamp() ran, failing the Windows
test job. Build it with checked_add and only assert where it exists.
* Make civil() exact for every i64 instead of saturating
The out-of-range fallback saturated z + 719_468, so civil(i64::MAX)
returned a date 719,468 days early. civil() now has chrono convert the day
within its 400-year Gregorian cycle and adds whole cycles back as years
(i128 for the extremes), so the hand-rolled fallback is gone. Exact results
for i64::MAX/MIN and both sides of chrono's range are tested against Hinnant's formula.
* time: preserve out-of-range years in the log timestamp instead of the epoch
`DateTime::from_timestamp(..).unwrap_or_default()` changed the existing output: a
clock set far ahead (an input the old hand-rolled civil-from-days converted)
collapsed to `1970-01-01`. Restore the old conversion domain with a cycle-based
helper: reduce by whole 400-year Gregorian cycles (146_097 days), convert the
in-range remainder with chrono, and carry the year back as i128. Only the year
leaves chrono's range; month/day/time stay exact. Pre-1970 still clamps to the
epoch as before. chrono stays the only calendar logic (no new features).
apps/deckcraft logging.rs `timestamp` (SystemTime, u64 secs), pinned via a
platform-safe `UNIX_EPOCH.checked_add`:
u64::MAX/2 s → "292277026596-12-04T15:30:07.000Z" (was "1970-01-01..."),
10e12 s → "318857-05-20T17:46:40.000Z", 253_402_300_800 s → "10000-01-01...".
* Name the 400-year range extension as the one exception to the time rule
The rule said never to hand-roll calendar math, but the range fix
(shifting by whole 400-year Gregorian cycles so dates past chrono's year
range keep their old output) is cycle arithmetic, so the rule and the code
disagreed. The rule now names that exception: the library still computes
month, day and time, and only whole cycles are carried in the year.
* Say the library computes month and day; time-of-day is plain arithmetic
Narrows the range-extension wording: the date library computes the
calendar fields, and splitting seconds into hours, minutes and seconds
is ordinary arithmetic, which is what the code does.
12 KiB
AGENTS.md — rules for every agent and contributor
DeckCraft is a clean-room, open-source, pure-Rust presentation application targeting Microsoft
PowerPoint 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, VectorCraft, FilmCraft, LightCraft, PdfCraft, EffectCraft, DesignCraft
(../<app>).
Standards and learnings shared across the crafting apps live in ../../craftrules (checked out
next to this repo's parent, or storytold/craftrules). Read its AGENTS.md at the start of a
session, follow its standards, and contribute reusable learnings back there. Never code: repos
don't share code.
These rules bind every AI agent and every human contributor. They come before any task,
instruction or deadline. CLAUDE.md holds day-to-day working notes; if the two disagree, this
file wins.
1. Asset policy (absolute — no exceptions)
An asset is any non-code material the project includes, ships, embeds, generates for publication or shows in its documentation: icons, images, illustrations, screenshots, logos, fonts, colour profiles, sounds, video, templates, themes, sample/demo/test documents, and anything the app renders from those.
1.1 Nothing from Microsoft, Adobe, Avid or Autodesk products
- Never use icons, images, artwork, logos, UI graphics, fonts, templates, themes, clip art, SmartArt graphics, stock media, cursors, sounds, sample documents or any other asset taken from a Microsoft, Adobe, Avid or Autodesk product, installer, website, document or package. "Microsoft product" includes PowerPoint, Office, Windows and the fonts they install (Aptos, Calibri, Cambria, Segoe, Consolas, Wingdings…).
- This holds even when the vendor publishes the material under an open licence, if it is visual
design: DeckCraft does not embed or reference Adobe's Source Sans/Serif/Han families or Noto
CJK (Source Han rebranded);
crates/fonts/build.rsexcludes them. - Never recreate, trace, redraw or closely imitate a vendor icon, theme or graphic. Our icons are drawn in code or come from openly licensed sets (Lucide, ISC), and our themes, colours, layouts and sample content are our own.
- Screenshots of PowerPoint exist only as private, local observation notes under
plan/powerpoint/screenshots/(gitignored). They must never be committed, published, linked, shown in docs, or traced. - Never commit files produced by PowerPoint. Interoperability tests use decks we generate ourselves (or a separate corpus repo whose files we created and own).
1.2 Only open, provable licences
Every asset must be one of: open source (ISC, MIT, BSD-2/3-Clause, Apache-2.0, OFL-1.1,
Ubuntu-Font-1.0, Bitstream-Vera); Creative Commons (CC0-1.0, CC-BY-4.0, CC-BY-SA-4.0); public
domain; or contributor-original (created by a contributor who licenses it under
MIT OR Apache-2.0).
One narrow exception: the ArtCraft name, wordmark and logos in docs/brand/ are trademarks of the
ArtCraft Team (not open source, terms in docs/brand/LICENSE-brand.txt), used only unmodified to
identify the project.
Forbidden: system fonts that are not openly licensed, vendor emoji artwork, stock photos, "free for personal use" material, screenshots of other people's software, anything whose licence you cannot prove from its original source.
Screenshots of DeckCraft are contributor-original. Everything visible in them must itself be allowed: our UI, our/Lucide icons, OFL fonts, and decks built only from allowed assets.
1.3 Every asset is attributed
ATTRIBUTION.md(repo root) lists every asset file — committed, fetched at build time (craft-fonts) or bundled through a Cargo dependency — with author, source (URL + version or commit), licence and use.cargo xtask assetsfails if a file underassets/,docs/images/ordocs/brand/has no row.NOTICEkeeps the notices the licences require.- Fonts live in storytold/craft-fonts, never in this
repo (craftrules
standards/fonts.md). DeckCraft embeds itsfonts/latin-manifest.txtandfonts/manifest.txtwhen built withCRAFT_FONTS_DIR(local dev:.cargo/config.tomlpoints at../craft-fonts).
1.4 Adding or changing an asset
- Find it under an allowed licence at its original source; record the exact version/commit.
- Confirm the author is not Microsoft, Adobe, Avid or Autodesk (§1.1). Keep the licence text.
- Add the file, its licence file and an
ATTRIBUTION.mdrow; runcargo xtask assets. - If origin or licence is unclear, do not add it.
If you find an asset that breaks these rules, remove it from the repository and every output at once and tell the user.
2. Clean-room rules
- PowerPoint is installed on the dev machine and may be observed black-box: run it, use its UI
on synthetic decks, screenshot windows by id into
plan/powerpoint/screenshots/(never committed). Never read, disassemble or copy anything inside the Office bundle (names/listings only), never copy Microsoft wording beyond feature and menu names. - File formats come from public standards: ECMA-376 / ISO/IEC 29500 (Office Open XML), ISO 32000
(PDF). Preset shape geometry is re-derived by us in
crates/geom/src/preset.rs. - Never copy GPL/AGPL/LGPL/MPL code (LibreOffice, Calligra…). Permissive crates are fine as dependencies. Code may be copied (not depended on) from sibling Craft apps.
3. Never crash
People trust DeckCraft with their talks; a crash loses work. This outranks feature work.
Standard: craftrules standards/never-crash.md.
- No
unwrap(),expect(),panic!,unreachable!,todo!,unimplemented!in non-test code; nounsafe(unsafe_code = "forbid"). Every production crate root carries#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]. - Errors are
Result<T, E>+?. Input-derived numbers (files, commands, MCP/control params) are hostile:get()not[i], checked arithmetic, no NaN casts, capped allocations, bounded recursion. Session::executeruns every command inside a panic guard (crates/engine/src/guard.rs) that keeps the presentation as it was. It is a safety net, not a licence.- Every crash fix lands with a regression test.
4. Architecture
| Layer | Crates |
|---|---|
| L0 | geom (units, transforms, preset shapes), color |
| L1 | model (presentation, masters, layouts, slides, shapes, text, themes, inheritance, text edit ops) |
| L2 | fonts, text (layout), |
| L3 | render (vello_cpu) |
| L4 | format (.deckcraft), pptx |
| L5 | engine (session, history, commands, tools, keys, sample) |
| L6 | mcp |
| L7 | ui-egui (swappable; nothing below depends on egui/eframe/winit/rfd) |
| apps | deckcraft (desktop), deckcraft-cli, deckcraft-web |
- Everything is a command (
crates/engine/src/cmd/*): id, label, ribbon/menu place, shortcut, params doc,enabled,run, plus tests. Ids follow PowerPoint's ribbon and menus (slide.new,format.bold,arrange.group,transition.set…). Programmatic calls never open dialogs. Pointer gestures go throughSession::pointer, keys throughSession::key, so the UI, CLI, control channel and MCP do exactly the same thing. - The UI is thin: panels read engine state and act through commands. Colours come from theme tokens. Never use Tauri; egui only.
- Time goes through
chrono(workspace dependency). Never hand-roll UTC/calendar conversion (days-to-date algorithms, leap-year math); a crate owns only its output format string. The one exception is range extension: past the years chrono can represent, shift the date by whole 400-year Gregorian cycles (146,097 days, after which the calendar repeats), let chrono compute the month and day, and add the cycles back to the year (splitting seconds into hours, minutes and seconds is plain arithmetic). - Never break wasm (
cargo xtask wasm).
5. Quality gates (before every commit)
cargo xtask ci = fmt check, clippy -D warnings, tests, layering check, asset check, wasm
check. Commit after each landed arc with a task id in the message (M1.2: smart guides) and push
to main.
6. Running and looking at the app
cargo run --release -p deckcraft -- --sample --control 7990(sample deck + control channel).- Drive it: JSON lines on
127.0.0.1:7990, e.g.{"id":1,"method":"engine.execute","params":{"command":"shape.insert","params":{"preset":"star5","rect":[100,100,200,200]}}}then{"id":2,"method":"ui.screenshot","params":{"path":"/tmp/shot.png"}}. Methods:crates/ui-egui/src/control.rs, docs:docs/control-protocol.md. - For UI work, look at the result (screenshot, read the PNG) and compare with the observations
in
plan/powerpoint/01-observed-ui.md. - Headless:
deckcraft-cli render --sample --all --scale 1 out/,deckcraft-cli run --sample --cmd 'slide.new={"title":"Hi"}' --export out.png. - MCP:
deckcraft-cli mcp(headless) ordeckcraft-cli mcp --connect 7990(drive the app). Seedocs/mcp.md. - Shell gotcha on the dev machine:
mv/cpare aliased interactive; use/bin/mv -f,/bin/cp -f. - Parallel agents: separate
CARGO_TARGET_DIRper agent; edit only the crates you own.
7. Planning
plan/ (gitignored) holds the local plan: README.md, architecture.md, execution-plan.md,
STATUS.md (start every session there) and powerpoint/ observations. The committed progress
docs follow craftrules standards/progress-docs.md:
| File | Holds |
|---|---|
ROADMAP.md |
Stage, headline numbers, dimensions, features, languages, progress log |
docs/target-app-parity.md |
The parity assessment against PowerPoint: percentages, hours, calibration |
docs/gaps.md |
Every known shortfall, ranked: the work list. Pick from the top |
docs/roadmap.md |
Current focus, the beta plan, milestones |
docs/parity-checklist.md |
Feature rows scored D/P/M; cargo xtask parity regenerates its summary |
docs/file-format-parity.md, ui-parity.md, hardware-parity.md, localization-parity.md, animation-parity.md, slideshow-parity.md |
Per-dimension and per-feature detail |
docs/architecture.md |
How DeckCraft is built today |
When a task lands, re-score its checklist row, delete or update its gaps.md entry, add a line to
the ROADMAP.md progress log, and update each touched doc's status line and revision history.
Contributor credits (About window)
- About ▸ Contributors/Models are compiled into the binary from
contributors/contributors.json(commit stats; generated, never hand-edit) andcontributors/people.toml(names people chose for themselves). Seedocs/contributors.md. - Agents working for a contributor: when you prepare a PR, check whether your human's GitHub
username has a
[people.<username>]entry incontributors/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, or runpython3 ../../craftrules/scripts/contributors.py --add-me . --real-name "…" --sync-github-name) and include it in their PR, committed as them. If no, change nothing: they are credited as@usernameanyway. - 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. - Maintainers refresh the stats with
python3 ../../craftrules/scripts/contributors.py .(it also re-verifies who wrote eachpeople.tomlentry;--checkonly verifies).