Expand description
Local content packs (#155): a versioned, user-controlled bundle of break ideas (hint pools) and guided routines that the user imports/exports as a plain JSON file. No cloud, no remote registry — everything is a local file the user explicitly picks.
Import is additive and non-clobbering: pack hints are appended to the
existing pools (exact duplicates skipped) and pack routines are added to
custom_routines (ids colliding with a bundled starter or an existing
custom routine are skipped). Export captures the current pools +
custom_routines, so export→import round-trips losslessly.
The schema is versioned and intentionally extensible: sound and theme/overlay bundling are deferred to a future version bump rather than crammed in here.
parse_pack / validate_pack / merge_pack / export_pack are pure and
fully unit-tested; the file I/O and IPC wrapping live in
commands::content_pack.
Structs§
- Added
Content - The concrete content a merge added, so an uninstall can remove exactly
those entries (the merge-and-track model). Mirrors
PackHintsplus the ids of routines that were appended tocustom_routines. - Content
Pack - A content pack: versioned, named, with optional hints and routines.
- Merge
Summary - What an import added, surfaced to the UI so the user sees the effect.
- Pack
Hints - Hint pools a pack can carry. Each maps to the matching
Settingspool; all optional so a pack can ship only what it wants.
Constants§
- CONTENT_
PACK_ VERSION - Schema version this build reads and writes. Bumped only on a breaking-change to the bundle shape.
- MAX_
HINTS_ 🔒PER_ POOL - MAX_
ROUTINES 🔒 - Defensive caps so a malformed or hostile bundle can’t bloat settings or stall the UI. Generous relative to any hand-curated pack.
- MAX_
STEPS_ 🔒PER_ ROUTINE - MAX_
STEP_ 🔒SECONDS - MAX_
STRING_ 🔒LEN
Functions§
- check_
string 🔒 - export_
pack - Build a content pack capturing the user’s current pools + custom routines, so it can be written to a file and imported elsewhere.
- merge_
pack - Merge a validated pack into
settings, returning only the summary counts. Thin wrapper overmerge_pack_trackedfor the content-pack import path, which has no uninstall and so doesn’t need theAddedContentrecord. - merge_
pack_ tracked - Merge a validated pack into
settings, recording exactly what was added. Append hints to each pool and routines tocustom_routines, skipping ids that collide with a bundled starter or an already-present custom routine. Non-destructive — nothing is removed or overwritten. Returns the summary counts plus the concreteAddedContentfor a laterremove_content. - merge_
pool 🔒 - Append
additionstopool, skipping blanks and exact duplicates (against both the existing pool and earlier additions). Returns the strings actually added (so an uninstall can remove exactly those). Order-preserving and non-clobbering. - parse_
pack - Parse a content pack from JSON, mapping serde errors to a user-facing
string. Does not validate beyond shape — call
validate_packnext. - remove_
content - Remove exactly the content recorded in
addedfromsettings(the uninstall half of merge-and-track): drop the recorded hint strings from each pool and the recorded routine ids fromcustom_routines. Tolerant of intervening user edits — anything already gone is simply skipped. Returns(hints_removed, routines_removed). - sanitize_
imported_ 🔒step - Clear any field of a step arriving from an UNSIGNED imported pack that only the signed-plugin installer is allowed to populate.
- serialize_
pack - Serialise a pack to pretty JSON.
- validate_
pack - Validate a parsed pack: supported version, non-empty name, size caps, and well-formed routines (non-empty id/label, 1..=N steps with non-empty text and a sane duration, no duplicate ids within the pack). Returns a clear, user-facing error on the first problem.